ACCarnall / bagpipes

Bagpipes is a state of the art code for generating realistic model galaxy spectra and fitting these to spectroscopic and photometric observations. Users should install with pip, not by cloning the repository.
http://bagpipes.readthedocs.io
GNU General Public License v3.0
71 stars 37 forks source link

an error when saving hdf5 file after fitting #32

Closed mjastro closed 1 year ago

mjastro commented 1 year ago

Hi,

I have recently changed my conda environment from anaconda3 to miniforge and reinstalled the bagpipes, and now I am getting the following error message which seems to be relevant to the hdf5 (when saving the fitting result) that bagpipes is using.

File "/opt/homebrew/Caskroom/miniforge/base/envs/bagpipes/lib/python3.10/site-packages/bagpipes/fitting/fit.py", line 150, in fit
    dd.io.save(self.fname[:-1] + ".h5", self.results)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/bagpipes/lib/python3.10/site-packages/deepdish/io/hdf5io.py", line 584, in save
    _save_level(h5file, group, value, name=key,
  File "/opt/homebrew/Caskroom/miniforge/base/envs/bagpipes/lib/python3.10/site-packages/deepdish/io/hdf5io.py", line 250, in _save_level
    _save_ndarray(handler, group, name, level, filters=filters)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/bagpipes/lib/python3.10/site-packages/deepdish/io/hdf5io.py", line 125, in _save_ndarray
    elif x.dtype == np.object:
  File "/opt/homebrew/Caskroom/miniforge/base/envs/bagpipes/lib/python3.10/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'object'. Did you mean: 'object_'?

I am suspecting this might not be an issue directly relevant to bagpipes' rather on my side but would still wonder whether any of you can help me if you have encountered the same issue.

I am using Mac (M1 silicon) and I had an issue when installing the bagpipes with this new setup (i.e., everything set on the arm architecture) and I have to manually specify the HDF5_DIR by typing export HDF5_DIR="$(brew --prefix hdf5)", which then completed the bagpipes installation.

Following is the error when I got trying to install bagpipes using pip install bagpipes


  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      /var/folders/r0/7k7m3h6j2xxg6chj893x90km0000gp/T/H5closetkx7wfdz.c:2:5: error: implicit declaration of function 'H5close' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
          H5close();
          ^
      1 error generated.
      cpuinfo failed, assuming no CPU features: 'flags'
      * Using Python 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:25:29) [Clang 14.0.6 ]
      * Found cython 0.29.33
      * USE_PKGCONFIG: False
      * Found conda env: ``/opt/homebrew/Caskroom/miniforge/base/envs/bagpipes``
      .. ERROR:: Could not find a local HDF5 installation.
         You may need to explicitly state where your local HDF5 headers and
         library can be found by setting the ``HDF5_DIR`` environment
         variable or by using the ``--hdf5`` command-line option.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

Thank you very much for any help you could offer!!

Best, Minju

ACCarnall commented 1 year ago

Hi Minju,

This appears to be an issue with the deepdish module, which is not yet compatible with numpy >= 1.2.4:

uchicago-cs/deepdish#50

Hopefully this will be patched soon, but in the mean time if you downgrade your numpy version this should make things work again.

Cheers, Adam

mjastro commented 1 year ago

aha! With the downgrade, it worked. Thanks a lot!! :)

hantke commented 1 year ago

Actually, if you just modify np.object -> object, then the code become compatible with the latest numpy version (at least it worked for me)

ACCarnall commented 1 year ago

Just to note that I've now replaced deepdish with h5py from bagpipes v1.0.2, so hopefully the code should now again be compatible with the most recent versions of numpy.