DedalusProject/dedalus

Dedalus v2.2207 requires numpy 1.20 but uses `numpy.int` which is deprecated for numpy >1.19?

navidcy opened this issue · 2 comments

seems like v2.2207 requires numpy 1.20 and beyond

"numpy >= 1.20.0",

but also uses numpy.int which is deprecated from numpty v1.20?

('iteration', np.int),
('write_number', np.int)]:

Calling solver.step(dt) gives me error, e.g.,

2022-12-27 16:25:57,228 __main__ 0/1 INFO :: Starting loop
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[8], line 11
      9 while solver.ok:
     10     forcing_func.args = [dt]
---> 11     solver.step(dt)
     12     if (solver.iteration-1) % 10 == 0:
     13         logger.info('Iteration: %i, day: %e, dt: %e' %(solver.iteration, solver.sim_time, dt))

File ~/miniforge3/envs/dedalus2/lib/python3.9/site-packages/dedalus/core/solvers.py:581, in InitialValueSolver.step(self, dt, trim)
    579     self.warmup_time = wall_time
    580 # Advance using timestepper
--> 581 self.timestepper.step(self, dt)
    582 # (Safety scatter)
    583 self.state.scatter()

File ~/miniforge3/envs/dedalus2/lib/python3.9/site-packages/dedalus/core/timesteppers.py:579, in RungeKuttaIMEX.step(self, solver, dt)
    576 evaluator_kw['sim_time'] = solver.sim_time
    577 if i == 1:
    578     # No need to scatter since gather occured just before step was called
--> 579     evaluator.evaluate_scheduled(**evaluator_kw)
    580 else:
    581     state.scatter()

File ~/miniforge3/envs/dedalus2/lib/python3.9/site-packages/dedalus/core/evaluator.py:107, in Evaluator.evaluate_scheduled(self, wall_time, sim_time, iteration, **kw)
    104         handler.last_sim_div  = sim_div
    105         handler.last_iter_div = iter_div
--> 107 self.evaluate_handlers(scheduled_handlers, wall_time=wall_time, sim_time=sim_time, iteration=iteration, **kw)

File ~/miniforge3/envs/dedalus2/lib/python3.9/site-packages/dedalus/core/evaluator.py:159, in Evaluator.evaluate_handlers(self, handlers, id, **kw)
    157 # Process
    158 for handler in handlers:
--> 159     handler.process(**kw)

File ~/miniforge3/envs/dedalus2/lib/python3.9/site-packages/dedalus/core/evaluator.py:559, in FileHandler.process(self, world_time, wall_time, sim_time, timestep, iteration, **kw)
    556 def process(self, world_time, wall_time, sim_time, timestep, iteration, **kw):
    557     """Save task outputs to HDF5 file."""
--> 559     file = self.get_file()
    560     self.total_write_num += 1
    561     self.file_write_num += 1

File ~/miniforge3/envs/dedalus2/lib/python3.9/site-packages/dedalus/core/evaluator.py:431, in FileHandler.get_file(self)
    429         self.create_current_file()
    430 else:
--> 431     self.create_current_file()
    432 # Open current file
    433 if self.parallel:

File ~/miniforge3/envs/dedalus2/lib/python3.9/site-packages/dedalus/core/evaluator.py:474, in FileHandler.create_current_file(self)
    472     if FILEHANDLER_TOUCH_TMPFILE:
    473         tmpfile.unlink()
--> 474 self.setup_file(file)
    475 file.close()

File ~/miniforge3/envs/dedalus2/lib/python3.9/site-packages/dedalus/core/evaluator.py:496, in FileHandler.setup_file(self, file)
    490 scale_group = file.create_group('scales')
    491 # Start time scales with shape=(0,) to chunk across writes
    492 for sn, dtype in [('sim_time', np.float64),
    493                   ('world_time', np.float64),
    494                   ('wall_time', np.float64),
    495                   ('timestep', np.float64),
--> 496                   ('iteration', np.int),
    497                   ('write_number', np.int)]:
    498     scale = scale_group.create_dataset(name=sn, shape=(0,), maxshape=(None,), dtype=dtype)
    499     scale.make_scale(sn)

File ~/miniforge3/envs/dedalus2/lib/python3.9/site-packages/numpy/__init__.py:284, in __getattr__(attr)
    281     from .testing import Tester
    282     return Tester
--> 284 raise AttributeError("module {!r} has no attribute "
    285                      "{!r}".format(__name__, attr))

AttributeError: module 'numpy' has no attribute 'int'

This was fixed on v2_master with commit 43f9a0d, and I'll get around to releasing an update on pip in the next few days. In the mean time though, it should work if you use numpy < 0.24, since the deprecation was only made hard at that point.

Gotcha. Thanks!