'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 _______________________________________________ NumPyDiscussion mailing list NumPyDiscussion@python.org https://mail.python.org/mailman/listinfo/numpydiscussion
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 nonNaN value  `nanmax`  maximum nonNaN value  `nanargmin`  index of minimum nonNaN value  `nanargmax`  index of maximum nonNaN value  `nansum`  sum of nonNaN values  `nanprod`  product of nonNaN values  `nancumsum`  cumulative sum of nonNaN values  `nancumprod`  cumulative product of nonNaN values  `nanmean`  mean of nonNaN values  `nanvar`  variance of nonNaN values  `nanstd`  standard deviation of nonNaN values  `nanmedian`  median of nonNaN values  `nanquantile`  qth quantile of nonNaN values  `nanpercentile`  qth percentile of nonNaN 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 nonNaN value
 `nanmax`  maximum nonNaN value
 `nanargmin`  index of minimum nonNaN value
 `nanargmax`  index of maximum nonNaN value
 `nansum`  sum of nonNaN values
 `nanprod`  product of nonNaN values
 `nancumsum`  cumulative sum of nonNaN values
 `nancumprod`  cumulative product of nonNaN values
 `nanmean`  mean of nonNaN values
 `nanvar`  variance of nonNaN values
 `nanstd`  standard deviation of nonNaN values
 `nanmedian`  median of nonNaN values
 `nanquantile`  qth quantile of nonNaN values
 `nanpercentile`  qth percentile of nonNaN values
Chuck _______________________________________________ NumPyDiscussion mailing list NumPyDiscussion@python.org https://mail.python.org/mailman/listinfo/numpydiscussion
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 _______________________________________________ NumPyDiscussion mailing list NumPyDiscussion@python.org https://mail.python.org/mailman/listinfo/numpydiscussion
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#L1L22). 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 _______________________________________________ NumPyDiscussion mailing list NumPyDiscussion@python.org https://mail.python.org/mailman/listinfo/numpydiscussion
 Dr. Mauro J. Cavalcanti Email: maurobio@gmail.com Web: http://sites.google.com/site/maurobio "Life is complex. It consists of real and imaginary parts." _______________________________________________ NumPyDiscussion mailing list NumPyDiscussion@python.org https://mail.python.org/mailman/listinfo/numpydiscussion
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, _______________________________________________ NumPyDiscussion mailing list NumPyDiscussion@python.org https://mail.python.org/mailman/listinfo/numpydiscussion
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, _______________________________________________ NumPyDiscussion mailing list NumPyDiscussion@python.org https://mail.python.org/mailman/listinfo/numpydiscussion
 Robert McLeod, Ph.D. robbmcleod@gmail.com robbmcleod@protonmail.com robert.mcleod@hitachihhtc.ca www.entropyreduction.al
NumPyDiscussion mailing list NumPyDiscussion@python.org https://mail.python.org/mailman/listinfo/numpydiscussion
participants (4)

Andras Deak

Charles R Harris

Mauro Cavalcanti

Robert McLeod