-
Notifications
You must be signed in to change notification settings - Fork 116
Open
Description
I noticed that there are assert statements that are catched wrongly, if an assert statement fails it throws an AssertionError not ValueError nor KeyError.
Lines 429 to 438 in 34504c1
| try: | |
| assert (point.size == self.ndim) | |
| except ValueError: | |
| raise ValueError( | |
| "Point must be same dimension as existing points in tree.") | |
| # Check for existing index in leaves dict | |
| try: | |
| assert (index not in self.leaves) | |
| except KeyError: | |
| raise KeyError("Index already exists in leaves dict.") |
Also consider removing all assert statements, because they are ignored if __debug__ is not True. This is the case when you run in production (See Docs).
The lines could be rewritten as:
if not point.size == self.ndim:
raise ValueError(
"Point must be same dimension as existing points in tree.")
# Check for existing index in leaves dict
try:
self.leaves[index]
except KeyError:
raise KeyError("Index already exists in leaves dict.")Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels