Starfish-develop / Starfish

Tools for Flexible Spectroscopic Inference
https://starfish.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
68 stars 22 forks source link

Calling a SpectrumModel object returns a TypeError #144

Closed thomasgaudin-astro closed 2 years ago

thomasgaudin-astro commented 2 years ago

I am following the example notebooks included with the code and I keep running into a TypeError when I try to build my spectrum model. I am running the following SpectrumModel class object:

model = SpectrumModel(emu, data, grid_params = [3500.0, 5.0, 0.0], Av=0, global_cov=dict(log_amp=38, log_ls=2))

When I then try to call or print model, I get the following error:

TypeError: a bytes-like object is required, not 'str'

I have looked for a byte-object that is attempting to be read as a string. This error is repeatable using multiple emulators and data files. It is also repeatable in both Jupyter Notebooks and Spyder. Alleviating the issue will be required in order to plot or train the model.

mileslucas commented 2 years ago

Thanks for the bug report, I'll look into this!

mileslucas commented 2 years ago

Okay, this sounds like an error with the HDF5 read/write code for emulator loading, but I can't recreate this locally. Can you please paste your

  1. Python version
  2. Starfish version (and whether you installed from pip or GitHub, or somehow else)
  3. h5py version
thomasgaudin-astro commented 2 years ago

1: Python version: 3.8.5 2: Starfish version: 0.4.0, pip installed 3: h5py version: 2.10.0

mileslucas commented 2 years ago

ah okay, can you try upgrading the h5py version you're using? In Starfish/setup.py the minimum version is 3.0.0, so there's something weird happening in your environment.

$ pip install -U h5py
$ python -c 'import h5py; print(h5py.__version__)'
3.6.0

Troubleshooting

What I've done is used a docker container (clean install) and installed

$ pip install astrostarfish

just like this, I can follow the tutorial in the docs without issue (also running pytest succeeds)

Now, if I manually demote to h5py 2.10.0

$ sudo apt update && sudo apt install libhdf5-dev
$ pip install h5py==2.10.0

this error is something that should be heeded!

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
astrostarfish 0.4.0 requires h5py==3.*, but you have h5py 2.10.0 which is incompatible

and now I cannot load the emulator, recreating your error.