-
-
Notifications
You must be signed in to change notification settings - Fork 30
Add converters benchmark and add Bitarray column test for votable #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stvoutsin
wants to merge
2
commits into
astropy:main
Choose a base branch
from
stvoutsin:votable-benchmarks-bitarray
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import numpy as np | ||
import numpy.ma as ma | ||
from astropy.io.votable.converters import bool_to_bitarray, bitarray_to_bool | ||
|
||
SMALL_SIZE = 1000 | ||
LARGE_SIZE = 100000 | ||
|
||
|
||
class TimeBitArrayConverters: | ||
"""Direct converter function benchmarks.""" | ||
|
||
def setup(self): | ||
rng = np.random.default_rng(42) | ||
|
||
self.small_bool = rng.integers(0, 2, SMALL_SIZE, dtype=bool) | ||
self.large_bool = rng.integers(0, 2, LARGE_SIZE, dtype=bool) | ||
|
||
mask = rng.random(LARGE_SIZE) < 0.2 | ||
self.masked_bool = ma.array(self.large_bool, mask=mask) | ||
|
||
self.small_bits = bool_to_bitarray(self.small_bool) | ||
self.large_bits = bool_to_bitarray(self.large_bool) | ||
|
||
def time_bool_to_bitarray_small(self): | ||
bool_to_bitarray(self.small_bool) | ||
|
||
def time_bool_to_bitarray_large(self): | ||
bool_to_bitarray(self.large_bool) | ||
|
||
def time_bool_to_bitarray_masked(self): | ||
bool_to_bitarray(self.masked_bool) | ||
|
||
def time_bitarray_to_bool_small(self): | ||
bitarray_to_bool(self.small_bits, len(self.small_bool)) | ||
|
||
def time_bitarray_to_bool_large(self): | ||
bitarray_to_bool(self.large_bits, len(self.large_bool)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some new code here that hasn't been formatted with Ruff. New code should be formatted with Ruff so that when Ruff is adopted in this repository then the patch to update the formatting would be smaller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't core library. We never even discussed PEP 8 here, much less ruff. So I wouldn't suddenly enforce that now as a rule that would block merge here.