-
Notifications
You must be signed in to change notification settings - Fork 26
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
Check DynamicTableRegion data is in bounds #1168
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1168 +/- ##
==========================================
- Coverage 88.89% 85.65% -3.24%
==========================================
Files 45 45
Lines 9834 9853 +19
Branches 2794 2802 +8
==========================================
- Hits 8742 8440 -302
- Misses 776 1076 +300
- Partials 316 337 +21 ☔ View full report in Codecov by Sentry. |
for val in self.data: | ||
self._validate_new_data_element(val) |
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.
You might want to try this as a list comprehension [self._validate_new_data_element(val) for val in self.data]
just because they tend to be faster in Python than regular for loops
for val in data: | ||
if val >= len(table) or val < 0: | ||
error_msg = f"DynamicTableRegion index {val} is out of bounds for {type(table)} '{table.name}'." | ||
self._error_on_new_warn_on_construct(error_msg, error_cls=IndexError) |
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.
Instead of iterating through all the values, I think checking for np.max(data) >= len(table)
would be more efficient.
Motivation
Fix #210
Checklist
CHANGELOG.md
with your changes?