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

store.write_result: ValueError: 1 indexing arguments for 0 dimensions #1205

Closed
dweindl opened this issue Nov 21, 2023 · 0 comments · Fixed by #1206
Closed

store.write_result: ValueError: 1 indexing arguments for 0 dimensions #1205

dweindl opened this issue Nov 21, 2023 · 0 comments · Fixed by #1206
Assignees
Labels
bug Something isn't working fixed but not released

Comments

@dweindl
Copy link
Member

dweindl commented Nov 21, 2023

I just encountered ValueError: 1 indexing arguments for 0 dimensions below store.write_result when saving profiling results in https://github.com/ICB-DCM/pyPESTO/actions/runs/6940677433/job/18880030097.

Seems like some inputs aren't checked properly.

Full stack (doc/example/amici.ipynb):

nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
------------------
# create temporary file
fn = tempfile.mktemp(".h5")

# write result with write_result function.
# Choose which parts of the result object to save with
# corresponding booleans.
store.write_result(
    result=result,
    filename=fn,
    problem=True,
    optimize=True,
    sample=True,
    profile=True,
)
------------------


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[39], line 7
      2 fn = tempfile.mktemp(".h5")
      4 # write result with write_result function.
      5 # Choose which parts of the result object to save with
      6 # corresponding booleans.
----> 7 store.write_result(
      8     result=result,
      9     filename=fn,
     10     problem=True,
     11     optimize=True,
     12     sample=True,
     13     profile=True,
     14 )

File ~/work/pyPESTO/pyPESTO/.tox/notebooks1/lib/python3.9/site-packages/pypesto/store/save_to_hdf5.py:298, in write_result(result, filename, overwrite, problem, optimize, profile, sample)
    296 if profile:
    297     pypesto_profile_writer = ProfileResultHDF5Writer(filename)
--> 298     pypesto_profile_writer.write(result, overwrite=overwrite)
    300 if sample:
    301     pypesto_sample_writer = SamplingResultHDF5Writer(filename)

File ~/work/pyPESTO/pyPESTO/.tox/notebooks1/lib/python3.9/site-packages/pypesto/store/save_to_hdf5.py:244, in ProfileResultHDF5Writer.write(self, result, overwrite)
    242 for key in parameter_profile.keys():
    243     if isinstance(parameter_profile[key], np.ndarray):
--> 244         write_float_array(
    245             result_grp, key, parameter_profile[key]
    246         )
    247     elif parameter_profile[key] is not None:
    248         result_grp.attrs[key] = parameter_profile[key]

File ~/work/pyPESTO/pyPESTO/.tox/notebooks1/lib/python3.9/site-packages/pypesto/store/hdf5.py:72, in write_float_array(f, path, values, dtype)
     70 else:
     71     dset = f[path]
---> 72 dset[:] = values

File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()

File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()

File ~/work/pyPESTO/pyPESTO/.tox/notebooks1/lib/python3.9/site-packages/h5py/_hl/dataset.py:965, in Dataset.__setitem__(self, args, val)
    962     mtype = None
    964 # Perform the dataspace selection
--> 965 selection = sel.select(self.shape, args, dataset=self)
    967 if selection.nselect == 0:
    968     return

File ~/work/pyPESTO/pyPESTO/.tox/notebooks1/lib/python3.9/site-packages/h5py/_hl/selections.py:82, in select(shape, args, dataset)
     79     space = h5s.create_simple(shape)
     80     selector = _selector.Selector(space)
---> 82 return selector.make_selection(args)

File h5py/_selector.pyx:282, in h5py._selector.Selector.make_selection()

File h5py/_selector.pyx:107, in h5py._selector.Selector.apply_args()

ValueError: 1 indexing arguments for 0 dimensions
@dweindl dweindl self-assigned this Nov 21, 2023
dweindl added a commit to dweindl/pyPESTO that referenced this issue Nov 21, 2023
* Refactor ProfileResultHDF5Writer to be more readable
* Raise more informative error if writing to HDF5 fails
* Don't index 0-dimensional datasets (Fixes ICB-DCM#1205)
dweindl added a commit to dweindl/pyPESTO that referenced this issue Nov 21, 2023
* Refactor ProfileResultHDF5Writer to be more readable
* Raise more informative error if writing to HDF5 fails
* Don't index 0-dimensional datasets (Fixes ICB-DCM#1205)
@dweindl dweindl linked a pull request Nov 21, 2023 that will close this issue
@dweindl dweindl added the bug Something isn't working label Nov 21, 2023
dweindl added a commit to dweindl/pyPESTO that referenced this issue Nov 21, 2023
* Make all `*_path` attributes numpy arrays as promised in the type hints

  This caused ICB-DCM#1205, because some entries were just plain `nan`. Fixes ICB-DCM#1205.

* Fixes a lurking issue of potentially mismatching path lengths

  If e.g. x_path with length >1 was passed, but any of the default arguments would be missing,
  the *_paths wouldn't be aligned properly

* Remove some unnecessary complexity
dweindl added a commit that referenced this issue Nov 22, 2023
* Make all `*_path` attributes numpy arrays as promised in the type hints

  This caused #1205, because some entries were just plain `nan`. Fixes #1205.

* Fixes a lurking issue of potentially mismatching path lengths

  If e.g. `x_path` with length >1 was passed, but any of the default arguments would be missing, the `*_paths` wouldn't be aligned properly. I don't think this problem occurred here yet.

* Remove some unnecessary complexity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed but not released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants