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
Handle kwargs
and bounds
in curve_fit
#2545
Conversation
src/scipp/optimize/__init__.py
Outdated
if isinstance(b, Variable): | ||
if b.shape != [2]: | ||
raise ValueError("Parameter bounds must be either a tuple of scalar " | ||
"variables or a 2-element array variable. " | ||
f"Got sizes={b.sizes} as bounds for '{name}'.") | ||
return tuple(b.to(unit=unit, dtype=float).values) |
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.
It is a bit odd to support this, I think? What is the meaning of the dimension?
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.
None as far as curve_fit
is concerned. I was just thinking it might be useful, similarly to passing limits as a length-2 array to sc.array
.
But I don't mind removing 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.
similarly to passing limits as a length-2 array to sc.array.
Not sure what you are referring to?
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.
I meant sc.arange
: #2140 (comment)
tests/optimize/curve_fit_test.py
Outdated
'a': sc.scalar(1.0, unit='s'), | ||
'b': sc.scalar(1.0, unit='m') | ||
}, | ||
bounds={'b': sc.array(dims=['xyz'], values=[-2.0, 2.0], unit='m')}) |
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.
As mentioned above, we have an odd dummy dimension here?
Fixes #2541