speed-up the function to add country borders and coastlines - #1073
Merged
Jenkins - WCR / Tests / Declarative: Post Actions
failed
Jul 11, 2025 in 0s
climada.engine.unsequa.test.test_unsequa.TestOutput.test_save_load_pass failed
climada.engine.unsequa.test.test_unsequa.TestOutput.test_save_load_pass failed
Details
climada.engine.unsequa.test.test_unsequa.TestOutput.test_save_load_pass
pandas.errors.InvalidIndexError: Reindexing only valid with uniquely valued Index objects
Stack trace
self = <climada.engine.unsequa.test.test_unsequa.TestOutput testMethod=test_save_load_pass>
def test_save_load_pass(self):
"""Test save and load output data"""
exp_unc, impf_unc, _ = make_input_vars()
haz = haz_dem()
unc_calc = CalcImpact(exp_unc, impf_unc, haz)
unc_data_save = unc_calc.make_sample(
N=2, sampling_kwargs={"calc_second_order": True}
)
filename = unc_data_save.to_hdf5()
unc_data_load = UncOutput.from_hdf5(filename)
for attr_save, val_save in unc_data_save.__dict__.items():
if isinstance(val_save, pd.DataFrame):
df_load = getattr(unc_data_load, attr_save)
self.assertTrue(df_load.equals(val_save))
self.assertEqual(unc_data_load.sampling_method, unc_data_save.sampling_method)
self.assertEqual(unc_data_load.sampling_kwargs, unc_data_save.sampling_kwargs)
filename.unlink()
unc_data_save = unc_calc.uncertainty(
unc_data_save, calc_eai_exp=True, calc_at_event=False
)
filename = unc_data_save.to_hdf5()
unc_data_load = UncOutput.from_hdf5(filename)
for attr_save, val_save in unc_data_save.__dict__.items():
if isinstance(val_save, pd.DataFrame):
df_load = getattr(unc_data_load, attr_save)
self.assertTrue(df_load.equals(val_save))
self.assertEqual(unc_data_load.sampling_method, unc_data_save.sampling_method)
self.assertEqual(unc_data_load.sampling_kwargs, unc_data_save.sampling_kwargs)
filename.unlink()
unc_data_save = unc_calc.sensitivity(
unc_data_save, sensitivity_kwargs={"calc_second_order": True}
)
filename = unc_data_save.to_hdf5()
> unc_data_load = UncOutput.from_hdf5(filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
climada/engine/unsequa/test/test_unsequa.py:308:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada/engine/unsequa/unc_output.py:1206: in from_hdf5
setattr(unc_data, var_name[1:], store.get(var_name))
^^^^^^^^^^^^^^^^^^^
../../../../../miniforge3/envs/climada_env/lib/python3.11/site-packages/pandas/io/pytables.py:812: in get
return self._read_group(group)
^^^^^^^^^^^^^^^^^^^^^^^
../../../../../miniforge3/envs/climada_env/lib/python3.11/site-packages/pandas/io/pytables.py:1879: in _read_group
return s.read()
^^^^^^^^
../../../../../miniforge3/envs/climada_env/lib/python3.11/site-packages/pandas/io/pytables.py:3292: in read
columns = items[items.get_indexer(blk_items)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Index([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0],
dtype='int64')
target = Index([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0],
dtype='int64')
method = None, limit = None, tolerance = None
@Appender(_index_shared_docs["get_indexer"] % _index_doc_kwargs)
@final
def get_indexer(
self,
target,
method: ReindexMethod | None = None,
limit: int | None = None,
tolerance=None,
) -> npt.NDArray[np.intp]:
method = clean_reindex_fill_method(method)
orig_target = target
target = self._maybe_cast_listlike_indexer(target)
self._check_indexing_method(method, limit, tolerance)
if not self._index_as_unique:
> raise InvalidIndexError(self._requires_unique_msg)
E pandas.errors.InvalidIndexError: Reindexing only valid with uniquely valued Index objects
../../../../../miniforge3/envs/climada_env/lib/python3.11/site-packages/pandas/core/indexes/base.py:3875: InvalidIndexError
Loading