On Thu, 2022-11-03 at 11:37 +0100, Oscar Gustafsson wrote:
> Hi all,
> 
> I hope this is the correct way to propose a new feature.
> https://github.com/numpy/numpy/issues/22522
> 

Thanks for the proposal.  I don't have much of an opinion on this and
right now I am mainly wondering whether there is prior art which can
inform us that this is relatively widely useful?

> Currently, the around-function supports rounding to a given number of
> decimal digits. It is often quite convenient to be able to round to a
> given
> number of binary digits to mimic fixed-point representations.
> Currently
> this can be readily achieved using e.g.
> 
> fractional_bits = 5
> scale = 2**fractional_bits
> x_round = np.around(x*scale)/scale
> 
> However, it would be more convenient (and probably faster) to provide
> dedicated support for it.


This seems more like a a place for some bit-fiddling, but I am not
sure.  Also a question is whether rounding modes make sense and what
you want (truncate, round to even?).

I suspect that this would be more something for a project similar to
Warrens ufunclab:

    https://github.com/WarrenWeckesser/ufunclab

I.e. written as a NumPy ufunc, but not in NumPy iself.


- Sebastian


> 
> I see a few different ways to obtain this:
> 1. Provide a separate function (binaryround?)
> 2. Provide a base argument to around which defaults to 10.
> 3. Provide a quant(ization) function where the argument is the step-
> size.
> (For completeness, one may think of having multiple quantization
> modes, not
> just rounding)
> 
> Any opinions?
> 
> BR Oscar Gustafsson
> _______________________________________________
> 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: sebast...@sipsolutions.net


_______________________________________________
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

Reply via email to