Break MaxandArgmax Op to seperate TensorMax Op and Argmax Op#731
Break MaxandArgmax Op to seperate TensorMax Op and Argmax Op#731ricardoV94 merged 4 commits intopymc-devs:mainfrom
Conversation
fb47422 to
18085b8
Compare
1d9a484 to
a278272
Compare
Scalar problem solved Finalise changes to seperate MaxAndArgmax Op
a278272 to
8c29314
Compare
You can mark the test with |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #731 +/- ##
==========================================
+ Coverage 80.83% 80.87% +0.03%
==========================================
Files 162 163 +1
Lines 46862 46847 -15
Branches 11465 11463 -2
==========================================
+ Hits 37881 37887 +6
- Misses 6733 6747 +14
+ Partials 2248 2213 -35
|
ricardoV94
left a comment
There was a problem hiding this comment.
Almost there, just some cleanup needed
6b07a6e to
25c8b4b
Compare
ricardoV94
left a comment
There was a problem hiding this comment.
Small notes. Reverting the white space changes is useful, because git diff will then only show the files that have meaningful changes from this PR
| def __getattr__(name): | ||
| if name == "MaxandArgmax": | ||
| warnings.warn( | ||
| "The class `MaxandArgmax` has been deprecated. " | ||
| "Call `Max` and `Argmax` seperately as an alternative.", | ||
| FutureWarning, | ||
| ) | ||
|
|
There was a problem hiding this comment.
This has to raise some sort of error because MaxAndArgmax no longer exist. It can't simply be a warning. I think it's better to just remove it
There was a problem hiding this comment.
should we raise an AttributeError here?
There was a problem hiding this comment.
Whatever error would be raised if this helper was not here, AttrubetError sounds about right but confirm with trying without the special code
There was a problem hiding this comment.
The helper also needs to raise the standard error for things other than MaxandArgmax
There was a problem hiding this comment.
Confirmed that AttributeError is raised
There was a problem hiding this comment.
This is how we implement it in pymc for reference: https://github.com/pymc-devs/pymc/blob/f44071bdda363f743548187d3e124a027adfdb77/pymc/distributions/transforms.py#L54-L67
Although according to the PEP it should probably have a !r in the standard AttributeError message: https://peps.python.org/pep-0562/#rationale
There was a problem hiding this comment.
In our case, we won't have to give a warning right?
There was a problem hiding this comment.
Yes in our case we just raise a more informative AttributeError instead of the default one
There was a problem hiding this comment.
In your last change you made this useless, it's the same as if we didn't implement __getattr__ at all. The point of adding it is to have a custom message for the deprecated Op, but have the default behavior for everything else.
25c8b4b to
9ab88f4
Compare
9ab88f4 to
c992d3a
Compare
|
Almost there, looks great. Just 3 unresolved comments above |
c992d3a to
25af747
Compare
tests/tensor/test_math.py
Outdated
|
|
||
|
|
||
| def test_MaxAndArgmax_deprecated(): | ||
| with pytest.raises(AttributeError): |
There was a problem hiding this comment.
Add the specific message we expect for trying to access the MaxAndArgmax
| with pytest.raises(AttributeError): | |
| with pytest.raises(AttributeError, match=...): |
8be1cfd to
cabb593
Compare
|
Some tests failing, it seems there are still some internal imports of |
cabb593 to
d953a0d
Compare
My bad. I rectified this. JAX tests are skipped locally so could not test them anywhere other than the CI. Hopefully, they'll pass now. |
|
Thanks @Dhruvanshu-Joshi ! |
Description
MaxandArgmax Op calculates both maximum and argmax together. With this PR, we aim to have seperate ops for the two operations.
Related Issue
MaxAndArgmaxOp#334Checklist
Type of change