Skip to content

Speed up printing of large sample sets#1075

Merged
arcondello merged 2 commits into
dwavesystems:mainfrom
arcondello:fix/printing-speed
Jan 13, 2022
Merged

Speed up printing of large sample sets#1075
arcondello merged 2 commits into
dwavesystems:mainfrom
arcondello:fix/printing-speed

Conversation

@arcondello

Copy link
Copy Markdown
Member

Comparison:

import time

import dimod
import numpy as np

sampleset = dimod.SampleSet.from_samples(np.ones((91, 500000)), vartype='BINARY', energy=np.zeros(91))

t = time.perf_counter()
dimod.serialization.format.Formatter().format(sampleset)
print(time.perf_counter() - t)

As an example, running this simple test locally gives 22.33913665200089 without the change and 0.007365263998508453 with.

Also add variable object slicing.

Closes #1069
Closes #1068

@arcondello arcondello added the enhancement New feature or request label Jan 12, 2022
@arcondello arcondello requested a review from seatim January 12, 2022 20:27
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #1075 (9871201) into main (52901df) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1075   +/-   ##
=======================================
  Coverage   92.86%   92.87%           
=======================================
  Files          81       81           
  Lines        7349     7354    +5     
=======================================
+ Hits         6825     6830    +5     
  Misses        524      524           
Impacted Files Coverage Δ
dimod/serialization/format.py 97.57% <100.00%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 52901df...9871201. Read the comment docs.

Comment thread dimod/serialization/format.py Outdated

@seatim seatim left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

Note that there are more invasive changes that could
improve this even more - this just adds a sanity check
at the beginning.

Closes dwavesystems#1068
@arcondello arcondello merged commit 739233e into dwavesystems:main Jan 13, 2022
@arcondello arcondello deleted the fix/printing-speed branch January 13, 2022 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow slicing of Variables objects Improve performance when printing large sample sets

3 participants