Skip to content

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

@jypeter

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

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