afeinstein20 / stella

For characterizing flares with convolutional neural networks
https://adina.feinste.in/stella
MIT License
26 stars 18 forks source link

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'' #22

Open dani753 opened 2 years ago

dani753 commented 2 years ago

Hello, I'm getting problems while running "other_features.ipynb" tutorial. My python version is 3.7 and I'm working with Windows11. I have installed stella by means of git clone.

The error happens when I run "mProt.run_LS()". I haven't modified any line of this tutorial. I'll be very greatful if someone can help me to understand why I'm having this issue.

Here is the full error trace that I'm getting:


TypeError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_6684\355224878.py in ----> 1 mProt.run_LS()

c:\users\dani\appdata\local\programs\python\python37\lib\site-packages\stella-0.2.0rc2-py3.7.egg\stella\rotations.py in run_LS(self, minf, maxf, spp) 222 # SPLITS BY ORBIT 223 diff = np.diff(time) --> 224 brk = np.where(diff >= np.nanmedian(diff)+14*np.nanstd(diff))[0] 225 226 if len(brk) > 1:

<__array_function__ internals> in nanmedian(*args, **kwargs) c:\users\dani\appdata\local\programs\python\python37\lib\site-packages\numpy\lib\nanfunctions.py in nanmedian(a, axis, out, overwrite_input, keepdims) 1112 1113 r, k = function_base._ureduce(a, func=_nanmedian, axis=axis, out=out, -> 1114 overwrite_input=overwrite_input) 1115 if keepdims and keepdims is not np._NoValue: 1116 return r.reshape(k) c:\users\dani\appdata\local\programs\python\python37\lib\site-packages\numpy\lib\function_base.py in _ureduce(a, func, **kwargs) 3513 keepdim = (1,) * a.ndim 3514 -> 3515 r = func(a, **kwargs) 3516 return r, keepdim 3517 c:\users\dani\appdata\local\programs\python\python37\lib\site-packages\numpy\lib\nanfunctions.py in _nanmedian(a, axis, out, overwrite_input) 981 part = a.ravel() 982 if out is None: --> 983 return _nanmedian1d(part, overwrite_input) 984 else: 985 out[...] = _nanmedian1d(part, overwrite_input) c:\users\dani\appdata\local\programs\python\python37\lib\site-packages\numpy\lib\nanfunctions.py in _nanmedian1d(arr1d, overwrite_input) 964 """ 965 arr1d, overwrite_input = _remove_nan_1d(arr1d, --> 966 overwrite_input=overwrite_input) 967 if arr1d.size == 0: 968 return np.nan c:\users\dani\appdata\local\programs\python\python37\lib\site-packages\numpy\lib\nanfunctions.py in _remove_nan_1d(arr1d, overwrite_input) 162 """ 163 --> 164 c = np.isnan(arr1d) 165 s = np.nonzero(c)[0] 166 if s.size == arr1d.size: 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''
github-actions[bot] commented 2 years ago

Hi there! This is a test of github actions.

ansony1691 commented 1 year ago

I have same type error when i try to use pretrained model (It also fails when I train a model by myself): TypeError Traceback (most recent call last) Input In [50], in <cell line: 1>() ----> 1 cnn.predict(modelname='hlsp_stella_tess_ensemblemodel_s003_tess_v0.1.0_cnn.h5', 2 times=lc.time, 3 fluxes=lc.flux, 4 errs=lc.flux_err) 5 single_pred = cnn.predictions[0]

File ~\anaconda3\envs\stella\lib\site-packages\stella\neural_network.py:543, in ConvNN.predict(self, modelname, times, fluxes, errs, multi_models, injected) 540 lc = fluxes[j] / np.nanmedian(fluxes[j]) # MUST BE NORMALIZED 541 err = errs[j] + 0.0 --> 543 q = ( (np.isnan(time) == False) & (np.isnan(lc) == False)) 544 time, lc, err = time[q], lc[q], err[q] 546 # APPENDS MASKED LIGHT CURVES TO KEEP TRACK OF

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


TypeError Traceback (most recent call last) Input In [100], in <cell line: 1>() ----> 1 cnn.predict(modelname='/Users/anson/Python/Stella_Prueba/results/ensemble_s0123_i0200_b0.73.h5', 2 times=lc.time, 3 fluxes=lc.flux, 4 errs=lc.flux_err)

File ~\anaconda3\envs\stella\lib\site-packages\stella\neural_network.py:543, in ConvNN.predict(self, modelname, times, fluxes, errs, multi_models, injected) 540 lc = fluxes[j] / np.nanmedian(fluxes[j]) # MUST BE NORMALIZED 541 err = errs[j] + 0.0 --> 543 q = ( (np.isnan(time) == False) & (np.isnan(lc) == False)) 544 time, lc, err = time[q], lc[q], err[q] 546 # APPENDS MASKED LIGHT CURVES TO KEEP TRACK OF

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

I use Python 3.9.12 on windows 11. I instaled stella 0.2.0rc2

Sudip-Pramanik commented 1 year ago

I got the same error while using stella. did you get the solution for it ?