On Wed, 2021-09-15 at 17:25 +0000, george trojan wrote: > Responding to the post by [email protected] (I subscribe to > the > digest). > > I just wrote the following code: > > twb = scipy.optimize.fsolve(phi, tdb, args=(tdb, p, w, hd_tdb, > hg_tdb), > xtol=1e-8) > tdb, p, w, hd_tdb, hg_tdb > twb.shape > print("wet-bulb temperature {:.5f} [deg K]".format(float(twb))) > > The output is > > (313.15, 101325.0, 0.009200033532084696, 40182.343155896095, > 2573510.322137241) > > (1,) > > wet-bulb temperature 295.17583 [deg K] > > All arguments are floats, the function phi returns float as well. I > did > expect the output to be float. Instead I got a 1d array. Were my > expectations wrong? The print statement would stop working after > deprecation.
Yes, this is exactly the type of issue that we are interested in this
discussion. I don't know whether this one could be exactly one of
those things that have been fixed in SciPy. But right now the code
ends up just "flattening" your 0-D array:
x0 = asarray(x0).flatten()
Which may be unexpected (or maybe it should be expected?). The
question is how common it is. If it is rare enough, I would like to
get away with it personally. But if it is too annoying in in the real
word...
One thing we could try to do is improve the error message (it is pretty
good already I think). We could go as far as including instructions
depending on whether the array is 1-D or N-D and even link to a website
for more pointers.
Cheers,
Sebastian
>
> George
> _______________________________________________
> NumPy-Discussion mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/numpy-discussion
signature.asc
Description: This is a digitally signed message part
_______________________________________________ NumPy-Discussion mailing list [email protected] https://mail.python.org/mailman/listinfo/numpy-discussion
