Re: optimize.Bounds - does lb need to be less than ub?

Warren Weckesser <[email protected]> Thu, 18 May 2023 13:23:45 -0400
Newsgroups gmane.comp.python.scientific.devel
Message-ID <CAGzF1ueYZt=_vR4_UbAaZGChh1T7GaR+MsNio8c5vFkxsaPvCg@mail.gmail.com>
On 5/18/23, David Menéndez Hurtado <[email protected]> wrote:
> My first thought is that if the bounds are flipped, in the majority of
> cases it is a bug, and erroring out is the correct action.
>
> What kind of scenario do you have? And can't you apply the fix to the
> boundaries before the function?
>
> /David
>
> On Thu, 18 May 2023, 18:41 Andrew Nelson, <[email protected]> wrote:
>
>> Hi all,
>> in https://github.com/scipy/scipy/pull/18483 `Bounds` is being modified
>> slightly.
>>
>> Currently there's a check in there:
>>
>> ```
>> if (self.lb > self.ub).any():
>>     raise ValueError("An upper bound is less than the corresponding lower
>> bound.")
>> ```
>>
>> I would personally find it useful if Bounds was more robust in this area,
>> and was able to deal with lb entries that were greater than the ub. I
>> would
>> like Bounds to have a clear up code with something like:
>>
>> ```
>> _lb = np.minimum(self.lb, self.ub)
>> _ub = np.maximum(self.lb, self.ub)
>> self.lb = _lb
>> self.ub = _ub
>> ```
>>
>> What are peoples thoughts on this?
>>

My first thought is the same as David's: this sounds like it will hide
bugs.  `lb` and `ub` clearly stand for "lower bound" and "upper
bound", and having our code guess that the user wants them reversed if
`lb` > `ub` seems like a bad idea.

Warren


>> A.
>>
>>
>> _____________________________________
>> Dr. Andrew Nelson
>>
>>
>> _____________________________________
>> _______________________________________________
>> SciPy-Dev mailing list -- [email protected]
>> To unsubscribe send an email to [email protected]
>> https://mail.python.org/mailman3/lists/scipy-dev.python.org/
>> Member address: [email protected]
>>
>
_______________________________________________
SciPy-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/scipy-dev.python.org/
Member address: [email protected]