Potential issue with loading injection data for different backends
The following discussion from !36 (merged) should be addressed:
-
@amanda.farah started a discussion: (+1 comment) Just a note that the new "backends" infrastructure seems to cause problems in
vt_helper.py
, at least when I pulled these changes two days ago. The problem comes in around line 171 (inload_injection_data.py
)if vt_file.endswith(".pkl"): with open(vt_file, "rb") as ff: data = dill.load(ff) for key, value in data.items(): if isinstance(value, np.ndarray): data[key] = xp.asarray(value) return data
I think this block of code is meant to change numpy arrays to cupy or jax arrays, but they always stay numpy arrays, which causes problems almost immediately downstream with
cupy
. If I print outxp
andnp
, I always get<module 'numpy' from '/home/amanda.farah/.conda/envs/analyst_guidelines_2/lib/python3.10/site-packages/numpy/__init__.py'>
regardless of what I set thebackend
argument to in my config file. I tried to fix this with afrom gwpopulation.backend import set_backend
and aset_backend(args.backend)
in the relevant function, but this had no effect onxp
ornp
. This seemed like it should have worked based on whatset_backend()
does, but I have to admit I don't fully understand howimportlib.metadata.entry_points
works.