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

Add support for addition of functionals #258

Merged
merged 8 commits into from
Mar 23, 2022
Merged

Conversation

bwohlberg
Copy link
Collaborator

Add support for addition of functionals. The result is a functional without a prox, but that can be evaluated if both summand functionals can be evaluated.

@bwohlberg bwohlberg added the improvement Improvement of existing code, including addressing of omissions or inconsistencies label Mar 22, 2022
@codecov
Copy link

codecov bot commented Mar 22, 2022

Codecov Report

Merging #258 (b98143f) into main (dbe88ab) will increase coverage by 0.02%.
The diff coverage is 92.85%.

@@            Coverage Diff             @@
##             main     #258      +/-   ##
==========================================
+ Coverage   93.59%   93.61%   +0.02%     
==========================================
  Files          49       49              
  Lines        3528     3541      +13     
==========================================
+ Hits         3302     3315      +13     
  Misses        226      226              
Flag Coverage Δ
unittests 93.61% <92.85%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
scico/solver.py 98.87% <ø> (ø)
scico/functional/_functional.py 90.41% <92.85%> (+2.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dbe88ab...b98143f. Read the comment docs.

if isinstance(other, Functional):
return FunctionalSum(self, other)
raise NotImplementedError(
f"Operation __add__ not defined between {type(self)} and {type(other)}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recommended way to do this is to return the constant NotImplemented rather than raise an exception; see https://docs.python.org/3/library/constants.html#NotImplemented

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. (I wouldn't be surprised if there are some other instances of this error floating around in other modules.)

@bwohlberg bwohlberg merged commit ec37e48 into main Mar 23, 2022
@bwohlberg bwohlberg deleted the brendt/sum-functional branch March 23, 2022 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement of existing code, including addressing of omissions or inconsistencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants