-
Notifications
You must be signed in to change notification settings - Fork 1
DM-53388: Add copy, deepcopy, and getitem methods to most scarlet_lite objects #23
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
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #23 +/- ##
==========================================
+ Coverage 92.41% 92.81% +0.40%
==========================================
Files 49 49
Lines 5432 6013 +581
==========================================
+ Hits 5020 5581 +561
- Misses 412 432 +20 ☔ View full report in Codecov by Sentry. |
cb4a3d4 to
5954b92
Compare
python/lsst/scarlet/lite/bbox.py
Outdated
|
|
||
| def __deepcopy__(self, memo: dict[int, Any]) -> Box: | ||
| """Deep copy of the box""" | ||
| if id(self) in memo: |
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.
I assume this is not performance-critical but you can do if (item := memo.get(id(self))) is not None: return item.
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.
Yeah, it's not a big deal but I did define my_id = id(self) since it is used multiple times in this method both inside and outside of the if block.
| """Implementation of unused abstract method""" | ||
|
|
||
| def parameterize(self, parameterization: Callable) -> None: | ||
| """Implementation of unused abstract method""" |
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.
Shouldn't this at least warn, if not raise NotImplementedError, rather than silently do nothing?
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.
I added a logger warning. There is nothing wrong with having a component that does not update but I agree with your point that the user should at least be warned if they are using it in fitting code.
| return self._model | ||
|
|
||
| def resize(self, model_box: Box) -> bool: | ||
| """Test whether or not the component needs to be resized""" |
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.
I probably reviewed this ages ago but I think it's more clear to say something like "Resize the component if needed and return whether it was resized".
This maybe should also warn if it can't ever be resized and if that could be surprising to users.
| with self.assertRaises(AssertionError): | ||
| assert_array_equal(param.x, param_deepcopy.x) | ||
|
|
||
| assert_array_equal(param.helpers["m"], param_deepcopy.helpers["m"]) |
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.
I think this is repetitive enough to warrant a loop.
| self.assertIsNot(source, source_copy) | ||
| self.assertEqual(source.n_components, 2) | ||
| self.assertEqual(source.n_components, source_copy.n_components) | ||
| self.assertFactorizedComponentEqual(source.components[0], source_copy.components[0]) |
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.
Shouldn't you check both components?
59b01cd to
de53ac2
Compare
Checklist
doc/changes