-
Notifications
You must be signed in to change notification settings - Fork 17
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
Resolve #468 #470
Resolve #468 #470
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #470 +/- ##
==========================================
- Coverage 94.60% 94.57% -0.03%
==========================================
Files 90 90
Lines 5578 5585 +7
==========================================
+ Hits 5277 5282 +5
- Misses 301 303 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
scico/functional/_functional.py
Outdated
@@ -38,15 +43,15 @@ def __init__(self): | |||
def __repr__(self): | |||
return f"""{type(self)} (has_eval = {self.has_eval}, has_prox = {self.has_prox})""" | |||
|
|||
def __mul__(self, other): | |||
def __mul__(self, other: Union[float, int]) -> ScaledFunctional: | |||
if snp.isscalar(other) or isinstance(other, jax.core.Tracer): |
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.
(1) I suggest snp.util.is_scalar_equiv
here, remember snp.isscalar(jnp.sum(1.0)) == False
(2) I suggest removing the jax.core.Tracer
check. That would return true for traced arrays as well as scalars, which seems wrong. And snp.util.is_scalar_equiv
should be true for scalar tracers (if not, let's fix it)
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.
Good point. Done.
Resolve #468.
Also:
ScaledFunctional
, so that e.g.5.0 * (2.0 * functional.L2Norm())
is aScaledFunctional
with a scale of 10 of anL2Norm
rather than aScaledFunctional
with a scale of 5 of aScaledFunctional
.CHANGES.rst
.