genutil.averager throws a weird exception when using a tuple for 'weights'
jypeter opened this issue · 5 comments
jypeter commented
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 commented
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.
jypeter commented
Also a good candidate for displaying readable error messages ;-)
jasonb5 commented
We'll fix this to support list or tuple.
github-actions commented
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.