You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Detrending fake LC:
Found 8 candidate(s) in the (0,5731) gap.
100%|################################################################################################################################################################|
The total number of injected flares is 1200.
Traceback (most recent call last):
File "/path/to/some.py", line 47, in<module>
flcc = flcd.characterize_flares(ampl_bins=10, dur_bins=10)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/AltaiPony/altaipony/flarelc.py", line 947, in characterize_flares
flares = wrap_characterization_of_flares(flc.fake_flares, flc.flares,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/AltaiPony/altaipony/injrecanalysis.py", line 44, in wrap_characterization_of_flares
flcc, dscc = characterize_flares(flares, injrec, otherfunc="count",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/AltaiPony/altaipony/injrecanalysis.py", line 111, in characterize_flares
flares[typ] = flares.apply(helper, axis=1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/frame.py", line 9423, in apply
returnop.apply().__finalize__(self, method="apply")
^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/apply.py", line 678, in apply
returnself.apply_standard()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/apply.py", line 798, in apply_standard
results, res_index = self.apply_series_generator()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/apply.py", line 814, in apply_series_generator
results[i] = self.f(v)
^^^^^^^^^
File "/path/to/AltaiPony/altaipony/injrecanalysis.py", line 108, in<lambda>
helper = lambda x: multiindex_into_df_with_nans(x, d,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/AltaiPony/altaipony/injrecanalysis.py", line 231, in multiindex_into_df_with_nans
return df.loc[(x[i1], x[i2]), i3]
~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/indexing.py", line 1097, in __getitem__
return self._getitem_tuple(key)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/indexing.py", line 1280, in _getitem_tuple
return self._getitem_lowerdim(tup)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/indexing.py", line 976, in _getitem_lowerdim
return self._getitem_nested_tuple(tup)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/indexing.py", line 1077, in _getitem_nested_tuple
obj = getattr(obj, self.name)._getitem_axis(key, axis=axis)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/indexing.py", line 1343, in _getitem_axis
return self._get_label(key, axis=axis)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/indexing.py", line 1293, in _get_label
return self.obj.xs(label, axis=axis)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/generic.py", line 4088, in xs
loc, new_index = index._get_loc_level(key, level=0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/indexes/multi.py", line 2998, in _get_loc_level
indexer = self.get_loc(key)
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pandas/core/indexes/multi.py", line 2795, in get_loc
self._check_indexing_error(key)
File "/usr/local/lib/python3.11/site-packages/pandas/core/indexes/multi.py", line 2516, in _check_indexing_error
raise InvalidIndexError(key)
pandas.errors.InvalidIndexError: (MaskedNDArray(0.00629842), 0.004086749358975794)
I get it when I call characterize_flares() function.
A script to reproduce the problem
fromaltaipony.lcioimportfrom_mastimportpandasflc=from_mast(
"Kepler-114",
mode="LC",
cadence="short",
mission="Kepler"
)
forjinrange(len(flc)):
print(f"\n--- {j} ---\n")
# detrend curveflcd=flc[j].detrend("savgol")
# find flaresflcd=flcd.find_flares(N1=3, N2=1, N3=3, minsep=3)
flcdpanda=flcd.flares# print(flcdpanda)ifnotflcdpanda.empty:
# injection of simulated flaresflcd, fakeflc=flcd.sample_flare_recovery(
inject_before_detrending=True,
mode="savgol",
iterations=20,
fakefreq=2,
ampl=[1e-4, 0.5],
dur=[.001/6., 0.1/6.]
)
print(f"Total number of injected flares is {flcd.fake_flares.shape[0]}")
# here it fails with uncaught exceptionflcc=flcd.characterize_flares(ampl_bins=10, dur_bins=10)
else:
print("DataFrame is empty, no flares")
I believe, the problem is that except block catches only KeyError, while the actual exception in my case was pandas.errors.InvalidIndexError. So the patch would be:
The text was updated successfully, but these errors were encountered:
retifrav
changed the title
Uncaught pandas.errors.InvalidIndexError in multiindex_into_df_with_nans()
Uncaught pandas.errors.InvalidIndexError
Aug 5, 2023
There is an uncaught exception in multiindex_into_df_with_nans() function on the line
return df.loc[(x[i1], x[i2]), i3]
:Full error output, just in case
I get it when I call
characterize_flares()
function.A script to reproduce the problem
I believe, the problem is that
except
block catches onlyKeyError
, while the actual exception in my case waspandas.errors.InvalidIndexError
. So the patch would be:Tested with aa6ba8d revision.
The text was updated successfully, but these errors were encountered: