Hello Sebastian, I rarely use NumPy scalars directly, but the repr change could have impact in assorted downstream projects' documentation.
For clarity, this idea would not alter how NumPy arrays print, would it - since they already include the type information? >>> np.array([34.3, 10.1, -0.5], np.float32) array([34.3, 10.1, -0.5], dtype=float32) >>> np.array([5, 10, 0], np.uint8) array([ 5, 10, 0], dtype=uint8) Thanks, Peter On Thu, Sep 8, 2022 at 10:42 AM Sebastian Berg <sebast...@sipsolutions.net> wrote: > > TL;DR: NumPy scalars representation is e.g. `34.3` instead of > `float32(34.3)`. So the representation is missing the type > information. What are your thoughts on changing that? > > > Hi all, > > I am thinking about the next steps for NEP 50 (The NEP wants to fix the > NumPy promotion rules, especially with respect to scalars): > > https://numpy.org/neps/nep-0050-scalar-promotion.html > > In relation to that, there was one point that Stéfan brought up > previously. > > The NumPy scalars (representation) currently print as numbers: > > >>> np.float32(34.3) > 34.3 > >>> np.uint8(5) > 5 > > That can already be confusing now. However, it gets more problematic > if NEP 50 is introduced since the behavior between a Python `34.3` and > `np.float32(34.3)` would differ more than it does now (please refer to > the NEP). > > The change would be that we should print as: > > float64(34.3) (or similar?) > > This Email is mainly to ask for any feedback or concern on such a > change. I suspect we may have to write a very brief NEP about it. > > If there is little concern, maybe we could move forward such a change > promptly. Otherwise it could be moved forward together with NEP 50 and > take effect in a "major" release [1]. > > Cheers, > > Sebastian > > > > [1] Note that for me, even a major release would hopefully not affect > the majority of users or be very disruptive. > > _______________________________________________ > NumPy-Discussion mailing list -- numpy-discussion@python.org > To unsubscribe send an email to numpy-discussion-le...@python.org > https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ > Member address: p.j.a.c...@googlemail.com >
_______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com