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

TypeError: ufunc 'isnan' not supported for the input types, #4

Closed
MIriamastro opened this issue Jul 17, 2019 · 4 comments
Closed

TypeError: ufunc 'isnan' not supported for the input types, #4

MIriamastro opened this issue Jul 17, 2019 · 4 comments

Comments

@MIriamastro
Copy link

MIriamastro commented Jul 17, 2019

UPDATE: I changed in File "/home/user/.local/lib/python3.6/site-packages/ndradex/grid.py", line 228, where is said if np.any(np.isnan(coord)): I wrote if np.any(pd.isnull(coord)) , and seems like it's fixed it.


I'm running ndradex, with spyder,
and I get the following error:

`100%|██████████| 1/1 [00:00<00:00, 27.19it/s]

Traceback (most recent call last):

File "", line 1, in
runfile('/media/user/radex/prueba_pyradex.py', wdir='/media/user/radex')

File "/usr/lib/python3/dist-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
execfile(filename, namespace)

File "/usr/lib/python3/dist-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "/media/user/radex/prueba_pyradex.py", line 11, in
ds = nd.run('co', '1-0', 100, 1e15, 1e3)

File "/home/user/.local/lib/python3.6/site-packages/ndradex/utils.py", line 30, in wrapper
return func(*bound.args, **bound.kwargs)

File "/home/user/.local/lib/python3.6/site-packages/ndradex/grid.py", line 169, in run
return finalize(dataset, squeeze)

File "/home/user/.local/lib/python3.6/site-packages/ndradex/grid.py", line 228, in finalize
if np.any(np.isnan(coord)):

File "/home/user/.local/lib/python3.6/site-packages/xarray/core/arithmetic.py", line 69, in array_ufunc
dask='allowed')

File "/home/user/.local/lib/python3.6/site-packages/xarray/core/computation.py", line 969, in apply_ufunc
keep_attrs=keep_attrs)

File "/home/user/.local/lib/python3.6/site-packages/xarray/core/computation.py", line 217, in apply_dataarray_vfunc
result_var = func(*data_vars)

File "/home/user/.local/lib/python3.6/site-packages/xarray/core/computation.py", line 564, in apply_variable_ufunc
result_data = func(*input_data)

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''`

How can I fix this?

@astropenguin
Copy link
Owner

Hi @MIriamastro, thank you for using ndRADEX! I think that the workaround (replacing np.isnan with pd.isnull) is correct but unfortunately I could not reproduce the error if I run the code ds = nd.run('co', '1-0', 100, 1e15, 1e3) in my environment (Google Colaboratory). Before fixing it, could you tell me a little more in detail about the code you ran and your environment?

@MIriamastro
Copy link
Author

MIriamastro commented Aug 1, 2019

Hi @astropenguin .
I run the code in spyder3, python 3.6.8, on ubuntu 18.04.
also the ndradex version I'm using is 0.1.8; xarray 0.12.3; pandas 0.24.2

@astropenguin
Copy link
Owner

astropenguin commented Aug 7, 2019

Hi @MIriamastro, thank you for sharing your environment. I found that the TypeError in ndRADEX was caused by a bug of xarray whose version is v0.12.2 or later (released a month ago). This bug changes the dtype of some coordinates, which is an unexpected behavior for ndRADEX.

It seems that the bug will be fixed in the next version of xarray (v0.12.4?), so could you please keep using xarray v0.12.1 or earlier to avoid that behavior until the next xarray is released?

@astropenguin
Copy link
Owner

astropenguin commented Sep 3, 2019

Hi @MIriamastro, I released ndRADEX v0.2.0, in which I stopped using xarray v0.12.2 or v0.12.3. I hope upgrading ndRADEX (e.g., pip install -U ndradex) will fix your problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants