Open dallan-keylogic opened 2 years ago
I thought Pyomo in general had issues with numpy
floats
(let alone ints
) - I seem to recall having run into issues with this before. Thus, I am wondering if this should be a more general issue of catching numpy
representations and casting them to general Python.
When a Pyomo component is assigned a value that's a Numpy Int, the model serializer spits out an error when trying to serialize the issue.
Note that this exception is not thrown with Numpy float types.
While the code in that minimum example would never be produced naturally, it's easy to run into this issue if you're using Pandas dataframes:
A workaround is to explicitly cast the dataframe's output to a
float
orint
, as appropriate, before setting/fixing the Pyomo component to a value:There may be edge cases where you can get integer overflow, I'm not sure about how Python numeric types compare to Numpy ones.