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

genutil.averager throws a weird exception when using a tuple for 'weights' #32

Open
jypeter opened this issue Dec 12, 2019 · 5 comments · May be fixed by #43
Open

genutil.averager throws a weird exception when using a tuple for 'weights' #32

jypeter opened this issue Dec 12, 2019 · 5 comments · May be fixed by #43
Assignees
Labels
kind/bug Categorizes issue related to bug.
Milestone

Comments

@jypeter
Copy link
Member

jypeter commented Dec 12, 2019

It took me some time find out that you have to use a list and not a tuple for the weights parameter. Can you update the code so that a tuple is accepted, or a better error message is printed?

An example below of what I got, with a slice of your clt.nc test file

>>> cdutil.averager(clt, axis='xy', weights=['weighted','weighted'])
variable_140
masked_array(data=62.71149853,
             mask=False,
       fill_value=1e+20)

>>> cdutil.averager(clt, axis='yx', weights=('weighted','weighted'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/share/unix_files/cdat/miniconda3/envs/cdatm_py3/lib/python3.6/site-packages/genutil/averager.py", line 1264, in averager
    filled_wtoptions = __check_weightoptions(V, axis, weights)
  File "/home/share/unix_files/cdat/miniconda3/envs/cdatm_py3/lib/python3.6/site-packages/genutil/averager.py", line 486, in __check_weightoptions
    'Error: Multiple axes passed without weights to match')
genutil.averager.AveragerError: ('E', 'r', 'r', 'o', 'r', ':', ' ', 'M', 'u', 'l', 't', 'i', 'p', 'l', 'e', ' ', 'a', 'x', 'e', 's', ' ', 'p', 'a', 's', 's', 'e', 'd', ' ', 'w', 'i', 't', 'h', 'o', 'u', 't', ' ', 'w', 'e', 'i', 'g', 'h', 't', 's', ' ', 't', 'o', ' ', 'm', 'a', 't', 'c', 'h')
>>>
@github-actions
Copy link

Marking issue as stale, since there has been no activity in 30 days.

Unless the issue is updated or the 'stale' tag is removed, this issue will be closed in 7 days.

@github-actions github-actions bot added the stale label Aug 27, 2020
@durack1
Copy link
Member

durack1 commented Aug 27, 2020

@jasonb5 another usability/doc tweak here

@jypeter
Copy link
Member Author

jypeter commented Aug 28, 2020

Also a good candidate for displaying readable error messages ;-)

@jasonb5
Copy link
Contributor

jasonb5 commented Aug 28, 2020

We'll fix this to support list or tuple.

@jasonb5 jasonb5 added this to the 8.2.2 milestone Aug 28, 2020
@jasonb5 jasonb5 added the bug label Aug 28, 2020
@jasonb5 jasonb5 self-assigned this Aug 28, 2020
@jasonb5 jasonb5 linked a pull request Aug 29, 2020 that will close this issue
@github-actions
Copy link

Marking issue as stale, since there has been no activity in 30 days.

Unless the issue is updated or the 'stale' tag is removed, this issue will be closed in 7 days.

@github-actions github-actions bot added the stale label Sep 27, 2020
@jasonb5 jasonb5 added kind/bug Categorizes issue related to bug. and removed bug stale labels Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue related to bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants