Skip to content
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

Merged
merged 11 commits into from
Jul 24, 2024
Merged

make sure to copy attributes on subtraction #961

merged 11 commits into from
Jul 24, 2024

Conversation

dannyjacobs
Copy link
Contributor

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.

@dannyjacobs dannyjacobs requested a review from jsdillon July 22, 2024 19:20
@dannyjacobs dannyjacobs self-assigned this Jul 22, 2024
Copy link

codecov bot commented Jul 22, 2024

Codecov Report

Attention: Patch coverage is 98.20359% with 63 lines in your changes missing coverage. Please review.

Project coverage is 97.21%. Comparing base (87c9f7a) to head (3893871).
Report is 1495 commits behind head on main.

Files Patch % Lines
hera_cal/io.py 96.22% 24 Missing ⚠️
hera_cal/frf.py 97.79% 7 Missing ⚠️
hera_cal/lst_stack/config.py 98.32% 7 Missing ⚠️
hera_cal/lst_stack/binning.py 98.26% 5 Missing ⚠️
hera_cal/_cli_tools.py 97.56% 4 Missing ⚠️
hera_cal/lst_stack/calibration.py 98.07% 3 Missing ⚠️
hera_cal/nucal.py 99.29% 3 Missing ⚠️
hera_cal/__init__.py 80.00% 2 Missing ⚠️
hera_cal/lst_stack/io.py 98.13% 2 Missing ⚠️
hera_cal/lst_stack/wrappers.py 97.53% 2 Missing ⚠️
... and 4 more
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     
Flag Coverage Δ
unittests 97.21% <98.20%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jsdillon jsdillon left a 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)
Copy link
Member

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.

hera_cal/datacontainer.py Show resolved Hide resolved
@dannyjacobs
Copy link
Contributor Author

Have made the following changes:

  1. Change propagated to add, sub, mul, div
  2. Docstring informs about returning a copy object
  3. updated test so that it fails without this fix.
  4. branch adder_fail adds just the test to the main branch. See main fail!

Copy link
Member

@jsdillon jsdillon left a 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 !

@jsdillon jsdillon merged commit 1596d60 into main Jul 24, 2024
8 of 9 checks passed
@jsdillon jsdillon deleted the fixsub branch July 24, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants