'nansqrt' function?

Dear ALL,
In the process of porting an existing (but abandoned) package to the latest version of Numpy, I stumbled upon a call to a 'numpy.nansqrt' function, which seems not to exist.
Here is the specific code:
def normTrans(y): denom = np.nansqrt(np.nansum(y**2)) return y/denom
As far as I could find, there is no such 'nansqrt' function in the current version of Numpy, so I suspect that the above code has not been properly tested.
Am I right, or that function had existed in some past version of Numpy?
Thanks in advance for any comments or suggestions.
Best regards,

On Wed, Feb 13, 2019 at 1:35 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Dear ALL,
In the process of porting an existing (but abandoned) package to the latest version of Numpy, I stumbled upon a call to a 'numpy.nansqrt' function, which seems not to exist.
Here is the specific code:
def normTrans(y): denom = np.nansqrt(np.nansum(y**2)) return y/denom
As far as I could find, there is no such 'nansqrt' function in the current version of Numpy, so I suspect that the above code has not been properly tested.
Am I right, or that function had existed in some past version of Numpy?
Thanks in advance for any comments or suggestions.
I don't recall any such function, but nansum will not result in any nans, so plain old sqrt should work.
Chuck

Chuck,
Sure, using numpy.sqrt works fine.
Thank you very much.
Best regards,
Em qua, 13 de fev de 2019 às 19:09, Charles R Harris < charlesr.harris@gmail.com> escreveu:
On Wed, Feb 13, 2019 at 1:35 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Dear ALL,
In the process of porting an existing (but abandoned) package to the latest version of Numpy, I stumbled upon a call to a 'numpy.nansqrt' function, which seems not to exist.
Here is the specific code:
def normTrans(y): denom = np.nansqrt(np.nansum(y**2)) return y/denom
As far as I could find, there is no such 'nansqrt' function in the current version of Numpy, so I suspect that the above code has not been properly tested.
Am I right, or that function had existed in some past version of Numpy?
Thanks in advance for any comments or suggestions.
I don't recall any such function, but nansum will not result in any nans, so plain old sqrt should work.
Chuck _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion

On Wed, Feb 13, 2019 at 2:14 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Chuck,
Sure, using numpy.sqrt works fine.
Thank you very much.
Best regards,
Em qua, 13 de fev de 2019 às 19:09, Charles R Harris < charlesr.harris@gmail.com> escreveu:
On Wed, Feb 13, 2019 at 1:35 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Dear ALL,
In the process of porting an existing (but abandoned) package to the latest version of Numpy, I stumbled upon a call to a 'numpy.nansqrt' function, which seems not to exist.
Here is the specific code:
def normTrans(y): denom = np.nansqrt(np.nansum(y**2)) return y/denom
As far as I could find, there is no such 'nansqrt' function in the current version of Numpy, so I suspect that the above code has not been properly tested.
Am I right, or that function had existed in some past version of Numpy?
Thanks in advance for any comments or suggestions.
I don't recall any such function, but nansum will not result in any nans, so plain old sqrt should work.
Note that there are various nan stat functions:
- `nanmin` -- minimum non-NaN value - `nanmax` -- maximum non-NaN value - `nanargmin` -- index of minimum non-NaN value - `nanargmax` -- index of maximum non-NaN value - `nansum` -- sum of non-NaN values - `nanprod` -- product of non-NaN values - `nancumsum` -- cumulative sum of non-NaN values - `nancumprod` -- cumulative product of non-NaN values - `nanmean` -- mean of non-NaN values - `nanvar` -- variance of non-NaN values - `nanstd` -- standard deviation of non-NaN values - `nanmedian` -- median of non-NaN values - `nanquantile` -- qth quantile of non-NaN values - `nanpercentile` -- qth percentile of non-NaN values
Chuck

Chuck,
I attempted to find such a list from the Numpy website. A complete list like yours should be quite handy for users if available there.
Best regards,
Em qua, 13 de fev de 2019 às 20:10, Charles R Harris < charlesr.harris@gmail.com> escreveu:
On Wed, Feb 13, 2019 at 2:14 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Chuck,
Sure, using numpy.sqrt works fine.
Thank you very much.
Best regards,
Em qua, 13 de fev de 2019 às 19:09, Charles R Harris < charlesr.harris@gmail.com> escreveu:
On Wed, Feb 13, 2019 at 1:35 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Dear ALL,
In the process of porting an existing (but abandoned) package to the latest version of Numpy, I stumbled upon a call to a 'numpy.nansqrt' function, which seems not to exist.
Here is the specific code:
def normTrans(y): denom = np.nansqrt(np.nansum(y**2)) return y/denom
As far as I could find, there is no such 'nansqrt' function in the current version of Numpy, so I suspect that the above code has not been properly tested.
Am I right, or that function had existed in some past version of Numpy?
Thanks in advance for any comments or suggestions.
I don't recall any such function, but nansum will not result in any nans, so plain old sqrt should work.
Note that there are various nan stat functions:
- `nanmin` -- minimum non-NaN value
- `nanmax` -- maximum non-NaN value
- `nanargmin` -- index of minimum non-NaN value
- `nanargmax` -- index of maximum non-NaN value
- `nansum` -- sum of non-NaN values
- `nanprod` -- product of non-NaN values
- `nancumsum` -- cumulative sum of non-NaN values
- `nancumprod` -- cumulative product of non-NaN values
- `nanmean` -- mean of non-NaN values
- `nanvar` -- variance of non-NaN values
- `nanstd` -- standard deviation of non-NaN values
- `nanmedian` -- median of non-NaN values
- `nanquantile` -- qth quantile of non-NaN values
- `nanpercentile` -- qth percentile of non-NaN values
Chuck _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion

On Wed, Feb 13, 2019 at 3:45 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Chuck,
I attempted to find such a list from the Numpy website. A complete list like yours should be quite handy for users if available there.
In ipython
In [1]: numpy.lib.nanfunctions?
will give it to you. But it looks like a module level entry should be added to the documentation under "NaN functions (numpy.lib.nanfunctions)" in a "Routines" entry. Maybe "Histograms" also.
<snip>
Chuck

Chuck,
IPython is full of secrets! More traditional users (myself included) usually look for the official documentation, so it would be really useful if such hints were also available there.
Best regards,
Em qui, 14 de fev de 2019 às 00:44, Charles R Harris < charlesr.harris@gmail.com> escreveu:
On Wed, Feb 13, 2019 at 3:45 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Chuck,
I attempted to find such a list from the Numpy website. A complete list like yours should be quite handy for users if available there.
In ipython
In [1]: numpy.lib.nanfunctions?
will give it to you. But it looks like a module level entry should be added to the documentation under "NaN functions (numpy.lib.nanfunctions)" in a "Routines" entry. Maybe "Histograms" also.
<snip>
Chuck _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion

On Thu, Feb 14, 2019 at 10:46 AM Mauro Cavalcanti maurobio@gmail.com wrote:
Chuck,
IPython is full of secrets! More traditional users (myself included) usually look for the official documentation, so it would be really useful if such hints were also available there.
Sorry if I'm stating the obvious, but what ipython does is merely give you the appropriate docstring, in this case the module docstring of numpy.lib.nanfunctions (https://github.com/numpy/numpy/blob/master/numpy/lib/nanfunctions.py#L1-L22). So you have to know where to look to find it, but it's official. I believe Chuck's remark of "looks like a module level entry should be added to the documentation under 'NaN functions (numpy.lib.nanfunctions)'" suggests exactly to have this information in the online docs, somewhere at https://docs.scipy.org/doc/numpy/reference/routines.html Regards,
András
Best regards,
Em qui, 14 de fev de 2019 às 00:44, Charles R Harris charlesr.harris@gmail.com escreveu:
On Wed, Feb 13, 2019 at 3:45 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Chuck,
I attempted to find such a list from the Numpy website. A complete list like yours should be quite handy for users if available there.
In ipython
In [1]: numpy.lib.nanfunctions?
will give it to you. But it looks like a module level entry should be added to the documentation under "NaN functions (numpy.lib.nanfunctions)" in a "Routines" entry. Maybe "Histograms" also.
<snip>
Chuck _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
-- Dr. Mauro J. Cavalcanti E-mail: maurobio@gmail.com Web: http://sites.google.com/site/maurobio "Life is complex. It consists of real and imaginary parts." _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion

The `bottleneck` library is a very good package if there's some function in NumPy that you want to handle `nan`s in reductions without exploding.
https://github.com/kwgoodman/bottleneck
On Wed, Feb 13, 2019 at 12:35 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Dear ALL,
In the process of porting an existing (but abandoned) package to the latest version of Numpy, I stumbled upon a call to a 'numpy.nansqrt' function, which seems not to exist.
Here is the specific code:
def normTrans(y): denom = np.nansqrt(np.nansum(y**2)) return y/denom
As far as I could find, there is no such 'nansqrt' function in the current version of Numpy, so I suspect that the above code has not been properly tested.
Am I right, or that function had existed in some past version of Numpy?
Thanks in advance for any comments or suggestions.
Best regards, _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion

Thanks! I didn't heard of this package and will look into it.
Best regards,
Em Qua, 13 de fev de 2019 22:10, Robert McLeod <robbmcleod@gmail.com escreveu:
The `bottleneck` library is a very good package if there's some function in NumPy that you want to handle `nan`s in reductions without exploding.
https://github.com/kwgoodman/bottleneck
On Wed, Feb 13, 2019 at 12:35 PM Mauro Cavalcanti maurobio@gmail.com wrote:
Dear ALL,
In the process of porting an existing (but abandoned) package to the latest version of Numpy, I stumbled upon a call to a 'numpy.nansqrt' function, which seems not to exist.
Here is the specific code:
def normTrans(y): denom = np.nansqrt(np.nansum(y**2)) return y/denom
As far as I could find, there is no such 'nansqrt' function in the current version of Numpy, so I suspect that the above code has not been properly tested.
Am I right, or that function had existed in some past version of Numpy?
Thanks in advance for any comments or suggestions.
Best regards, _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
-- Robert McLeod, Ph.D. robbmcleod@gmail.com robbmcleod@protonmail.com robert.mcleod@hitachi-hhtc.ca www.entropyreduction.al
NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
participants (4)
-
Andras Deak
-
Charles R Harris
-
Mauro Cavalcanti
-
Robert McLeod