Add a method for reordering the variables in a sample set
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- python
- Domain
- backend-api-design
Research direction
Start with the SampleSet API and review the existing samples, vartype, variable-order, and data_vectors behavior shown in the issue. Add a reorder_variables(order) entry point that returns the same sampleset information with variables in the requested order, then verify that the reordered samples and metadata match the documented manual approach.
Written by the indexing model from the issue text.
Description
It would be good to have something like
reordered_sampleset = sampleset.reorder_variables(order)
Additional Context
This can currently be done "manually"
# 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
- Dominant language
- Python
- Stars
- 143
- Forks
- 91
- Avg merge
- 1h 24m
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dwavesystems/dimod
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
dwavesystems/dimod#1427 · 1 comment ·
-
bug
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
dwavesystems/dimod#1122 ·
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
dwavesystems/dimod#1418 ·
-
bug
dwavesystems/dimod#1412 · 1 comment · 1 assignee ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
dwavesystems/dimod#1405 · 1 comment ·
All issues in dwavesystems/dimod
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100