dwavesystems / dwavesystems/dimod

Add a method for reordering the variables in a sample set

Open
#1,325 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
143
Forks
91
Avg merge
1h 24m
Merged PRs (30d)
3

Description

It would be good to have something like
```python
reordered_sampleset = sampleset.reorder_variables(order)
```
**Additional Context**
This can currently be done "manually"
```python
# Get the samples as an unlabelled array, but with the columns ordered by variable_order
samples_array = sampleset.samples(sorted_by=None)[:, variable_order]

# Construct a new sampleset with that array and variable order, keeping everything else the
# same
reordered_sampleset = dimod.SampleSet.from_samples(
(samples_array, variable_order), # the samples array, with the new order
vartype=sampleset.vartype, # vartype is the same
sort_labels=False, # don't sort the labels
**sampleset.data_vectors, # energy, num_occurances, etc are all the same
)
```
but it might be nice to have it all bundled into a method

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.