PySCeS / pysces

The official PySCeS project source code repository.
https://pysces.github.io
Other
34 stars 10 forks source link

Type error when simulating model #36

Closed elofgren closed 4 years ago

elofgren commented 4 years ago

A fresh install of Anaconda and PySceS 0.9.7 on Ubuntu, when I run the following code:

mod.mode_integrator = 'LSODA'
mod.sim_start = 0.0
mod.sim_end = 300.0
mod.sim_points = 300.0
mod.Simulate()

It produces the following error message:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
    116     try:
--> 117         num = operator.index(num)
    118     except TypeError:

TypeError: 'float' object cannot be interpreted as an integer

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-12-f7beeeafa7ee> in <module>
      3 mod.sim_end = 300.0
      4 mod.sim_points = 300.0
----> 5 mod.Simulate()

~/anaconda3/lib/python3.7/site-packages/pysces/PyscesModel.py in Simulate(self, userinit)
   4171                 print('*****\nWARNING: simulations require a minimum of 2 points, setting sim_points = 2.0\n*****')
   4172                 self.sim_points = 2.0
-> 4173             self.sim_time = numpy.linspace(self.sim_start, self.sim_end, self.sim_points, endpoint=1, retstep=0)
   4174             eval(self.__mapFunc_R__)
   4175 

<__array_function__ internals> in linspace(*args, **kwargs)

~/anaconda3/lib/python3.7/site-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
    119         raise TypeError(
    120             "object of type {} cannot be safely interpreted as an integer."
--> 121                 .format(type(num)))
    122 
    123     if num < 0:

TypeError: object of type <class 'float'> cannot be safely interpreted as an integer.

Any idea what is going on?

bgoli commented 4 years ago

Hi thanks for raising this issue. I've just run into this myself and suspect it might be a change in numpy. I've just pushed a fix (9529516) to master but if you want to fix it in your current installation:

jmrohwer commented 4 years ago

Closing, fixed in master.