-
Notifications
You must be signed in to change notification settings - Fork 8
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
make sure to copy attributes on subtraction #961
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #961 +/- ##
==========================================
+ Coverage 96.95% 97.21% +0.26%
==========================================
Files 19 31 +12
Lines 8012 10986 +2974
==========================================
+ Hits 7768 10680 +2912
- Misses 244 306 +62
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Thanks @dannyjacobs!
If you're going to make this change, I'd suggest making parallel changes to __add__
and __mult__
and __floordiv__
and __truediv__
. I'd also like to see at least one unit test that exposes the issue you were having and is fixed by this change.
|
||
# iterate over D keys | ||
for i, k in enumerate(D.keys()): | ||
if self.__contains__(k): | ||
newD[k] = self.__getitem__(k) - D[k] | ||
|
||
return DataContainer(newD) | ||
return newD | ||
|
||
else: | ||
newD = copy.deepcopy(self) |
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 line is now redundant.
Have made the following changes:
|
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.
Assuming my change passes tests, I'm good to go. Thanks @dannyjacobs !
Subtracting two datacontainers returned a new datacontainer shorn of all attributes. This fixes the problem by always returning the difference with all the attributes of the A, where the difference being computed is A - B.