ChristopherMayes / Xopt

Flexible high-level optimization in Python
Apache License 2.0
59 stars 20 forks source link

Neldermead generator does not work with numpy 2.x #236

Open wenatuhs opened 1 week ago

wenatuhs commented 1 week ago

Here is the error stack when call try_load_all_generators():

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/anaconda3/envs/fnal/lib/python3.12/site-packages/xopt/generators/__init__.py", line 43, in try_load_all_generators
    get_generator_dynamic(gn)
  File "/usr/local/anaconda3/envs/fnal/lib/python3.12/site-packages/xopt/generators/__init__.py", line 64, in get_generator_dynamic
    from xopt.generators.scipy.neldermead import NelderMeadGenerator
  File "/usr/local/anaconda3/envs/fnal/lib/python3.12/site-packages/xopt/generators/scipy/neldermead.py", line 7, in <module>
    from numpy import asfarray
ImportError: cannot import name 'asfarray' from 'numpy' (/usr/local/anaconda3/envs/fnal/lib/python3.12/site-packages/numpy/__init__.py). Did you mean: 'asarray'?
wenatuhs commented 1 week ago

Downgrading numpy to v1.x fixed this issue but we might want to adapt the generator to numpy v2 at some point.