dwavesystems / dwavesystems/dimod
Add a method for reordering the variables in a sample set
- 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
Assessment
This issue has not been assessed yet.