Skip to content

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

Open

Description

@jypeter

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')
>>>

Activity

  1. github-actions commented on Aug 27, 2020

    @github-actions

    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.

  2. durack1 commented on Aug 27, 2020

    @durack1
    Member

    @jasonb5 another usability/doc tweak here

  3. jypeter commented on Aug 28, 2020

    @jypeter
    MemberAuthor

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

  4. jasonb5 commented on Aug 28, 2020

    @jasonb5
    Contributor

    We'll fix this to support list or tuple.

  5. added this to the 8.2.2 milestone on Aug 28, 2020
  6. self-assigned this
    on Aug 28, 2020
  7. github-actions commented on Sep 27, 2020

    @github-actions

    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.

  8. added
    kind/bugCategorizes issue related to bug.
    and removed on Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue related to bug.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions