<div dir="auto">Your example used np.round(), not the builtin round(). np.round() is not changing. If you want the dtype of the output to be the dtype of the input, you can certainly keep using np.round() (or its canonical spelling, np.around()).</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 27, 2020, 12:05 AM Ilhan Polat <<a href="mailto:ilhanpolat@gmail.com">ilhanpolat@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">It's not about what I want but this changes the output of round. In my example I didn't use any arrays but a scalar type which looks like will upcasted. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 26, 2020, 23:04 Robert Kern <<a href="mailto:robert.kern@gmail.com" target="_blank" rel="noreferrer">robert.kern@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">On Wed, Feb 26, 2020 at 5:41 PM <<a href="mailto:josef.pktd@gmail.com" rel="noreferrer noreferrer" target="_blank">josef.pktd@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 26, 2020 at 5:30 PM Ilhan Polat <<a href="mailto:ilhanpolat@gmail.com" rel="noreferrer noreferrer" target="_blank">ilhanpolat@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Does this mean that np.round(np.float32(5)) return a 64 bit upcasted int?<div dir="auto"><br></div><div dir="auto">That would be really awkward for many reasons pandas frame size being bloated just by rounding for an example. Or numpy array size growing for no apparent reason</div><div dir="auto"><br></div><div dir="auto">I am not really sure if I understand why LSP should hold in this case to be honest. Rounding is an operation specific for the number instance and not for the generic class. </div><div dir="auto"><br></div><div dir="auto"><br></div><br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Wed, Feb 26, 2020, 21:38 Robert Kern <<a href="mailto:robert.kern@gmail.com" rel="noreferrer noreferrer" target="_blank">robert.kern@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Wed, Feb 26, 2020 at 3:19 PM Hameer Abbasi <<a href="mailto:einstein.edison@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">einstein.edison@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="en-DE">
<div>
<p class="MsoNormal"><br></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">There still remains the question, do we return Python
</span><span lang="EN-US" style="font-size:11pt;font-family:Menlo">int</span><span lang="EN-US" style="font-size:11pt">s or
</span><span lang="EN-US" style="font-size:11pt;font-family:Menlo">np.int64</span><span lang="EN-US" style="font-size:11pt">s?<u></u><u></u></span></p>
<ul type="disc">
<li style="margin-left:0cm">
<span lang="EN-US" style="font-size:11pt">Python </span>
<span lang="EN-US" style="font-size:11pt;font-family:Menlo">int</span><span lang="EN-US" style="font-size:11pt">s have the advantage of not overflowing.<u></u><u></u></span></li><li style="margin-left:0cm">
<span lang="EN-US" style="font-size:11pt">If we decide to add
</span><span lang="EN-US" style="font-size:11pt;font-family:Menlo">__round__</span><span lang="EN-US" style="font-size:11pt"> to arrays in the future, Python
</span><span lang="EN-US" style="font-size:11pt;font-family:Menlo">int</span><span lang="EN-US" style="font-size:11pt">s may become inconsistent with our design, as such a method will return an
</span><span lang="EN-US" style="font-size:11pt;font-family:Menlo">int64</span><span lang="EN-US" style="font-size:11pt"> array.<u></u><u></u></span></li></ul>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11pt">This was issue was discussed in the weekly triage meeting today, and the following plan of action was proposed:<u></u><u></u></span></p>
<ul type="disc">
<li class="MsoNormal">
<span style="font-size:11pt">change scalar floats to return integers for
</span><span style="font-size:11pt;font-family:Menlo">__round__</span><span lang="EN-US" style="font-size:11pt"> (which integer type was not discussed, I propose
</span><span lang="EN-US" style="font-size:11pt;font-family:Menlo">np.int64</span><span lang="EN-US" style="font-size:11pt">)</span><span style="font-size:11pt"><u></u><u></u></span></li><li class="MsoNormal">
<span style="font-size:11pt">not change anything else: not 0d arrays and not other numpy functionality</span></li></ul></div></div></blockquote></div></div></blockquote></div></div></blockquote><div><br></div><div>I think making numerical behavior different between arrays and numpy scalars with the same dtype, will create many happy debugging hours.</div></div></div></blockquote><div><br></div><div>round(some_ndarray) isn't implemented, so there is no difference to worry about.</div><div><br></div><div>If you want the float->float rounding, use np.around(). That function should continue to behave like it currently does for both arrays and scalars.</div><div><br></div><div>-- <br></div></div><div dir="ltr">Robert Kern</div></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" rel="noreferrer noreferrer" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank" rel="noreferrer">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div>