Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in genutils.statistics.percentiles #38

Closed
lee1043 opened this issue Jun 28, 2020 · 4 comments · Fixed by #40
Closed

Error in genutils.statistics.percentiles #38

lee1043 opened this issue Jun 28, 2020 · 4 comments · Fixed by #40
Labels
Milestone

Comments

@lee1043
Copy link

lee1043 commented Jun 28, 2020

Forwarding below from report to this issue board for future following up:

From: owner-cdat-support@listserv.llnl.gov on behalf of Dileepkumar R dileepkunjaai@gmail.com
Date: Sunday, June 28, 2020 at 11:10 AM
To: "CDAT-SUPPORT@listserv.llnl.gov" CDAT-SUPPORT@listserv.llnl.gov
Cc: "cdat-discussion@lists.sourceforge.net" cdat-discussion@lists.sourceforge.net
Subject: Error in genutils.statistics.percentiles

Dear All,

I am getting the following error when using genutils.statistics.percentiles function.

import cdms2
import MV2
from genutil import statistics
import numpy
a = numpy.array([1.0,2.0,3.0,4.0,5.0])
statistics.percentiles(a,percentiles=[1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dileep/anaconda3/envs/cdat81/lib/python3.6/site-packages/genutil/statistics.py", line 1767, in percentiles
    p = _percentiles(x, percentiles)
  File "/home/dileep/anaconda3/envs/cdat81/lib/python3.6/site-packages/genutil/statistics.py", line 1717, in _percentiles
    tmp = (p - Ai) / (Aii - Ai) * arrayindexing.get(out, ii) + \
  File "/home/dileep/anaconda3/envs/cdat81/lib/python3.6/site-packages/genutil/arrayindexing.py", line 66, in get
    Indices = Indices.data.astype('i')
AttributeError: 'memoryview' object has no attribute 'astype'

Thank you in advance

Dileepkumar R

@lee1043
Copy link
Author

lee1043 commented Jun 28, 2020

My error log is slightly different:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-81442f10e5b1> in <module>
      4 import numpy
      5 a = numpy.array([1.0,2.0,3.0,4.0,5.0])
----> 6 statistics.percentiles(a,percentiles=[1])

/opt/anaconda3/envs/cdat_nightly_20200616/lib/python3.6/site-packages/genutil/statistics.py in percentiles(x, percentiles, axis)
   1751         xatt = x.attributes
   1752     x, dum, weights, axis, ax = __checker(x, None, None, axis)
-> 1753     p = _percentiles(x, percentiles)
   1754     if ax is not None and ax != []:
   1755         pax = cdms2.createAxis(percentiles)

/opt/anaconda3/envs/cdat_nightly_20200616/lib/python3.6/site-packages/genutil/statistics.py in _percentiles(out, percent)
   1697         Aii = numpy.where(numpy.equal(ns, 1), 100., tmp)
   1698         ii = numpy.where(numpy.equal(ii, ns), ns - 1, ii)
-> 1699         if numpy.rank(ii) > 0:
   1700             ii = ii.astype(numpy.int)
   1701 # tmp = (p-Ai)/(Aii-Ai)*array_indexing.extract(out,ii) + \

AttributeError: module 'numpy' has no attribute 'rank'

I don't know whether the error from my conda env has the same cause with the aforementioned, but it looks like numpy.rank that is used from genutil has been disabled in the current version of numpy.

import numpy
numpy.rank
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-b38d67d32117> in <module>
      1 import numpy
----> 2 numpy.rank

@lee1043
Copy link
Author

lee1043 commented Jun 28, 2020

@muryanto1 is this related to #35?

@lee1043 lee1043 added the bug label Jun 28, 2020
@muryanto1
Copy link
Member

muryanto1 commented Jun 28, 2020

I confirmed that the AttributeError: 'memoryview' object has no attribute 'astype' is also in our nightly.
Thank you for reporting.

muryanto1 added a commit to muryanto1/genutil-feedstock that referenced this issue Jul 13, 2020
muryanto1 added a commit to conda-forge/genutil-feedstock that referenced this issue Jul 13, 2020
@jasonb5 jasonb5 linked a pull request Jul 27, 2020 that will close this issue
@jasonb5 jasonb5 added this to the 8.2.1 milestone Jul 27, 2020
@jasonb5
Copy link
Contributor

jasonb5 commented Jul 27, 2020

Fix will be in CDAT 8.2.1

@jasonb5 jasonb5 closed this as completed Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants