copasi / basico

A simplified python interface to COPASI.
https://basico.readthedocs.io/
Artistic License 2.0
19 stars 5 forks source link

get_compartments() returns a type incompatible with set_compartments() #49

Closed pmendes closed 5 months ago

pmendes commented 5 months ago

when trying to set_compartment() with values copied from a previous call to get_compartments() I get this error: TypeError: in method 'CCompartment_setDimensionality', argument 2 of type 'unsigned int' the error goes away when I cast the variable in question to be an int. It seems that for dimensionality get_compartments() returns an unsigned int but for set_compartments() it needs an int

fbergmann commented 5 months ago

The issue was, that the integer in the data frame is a numpy.int64 rather than an int. I'll release a new version that fixes the issue. In general for your tool I would recommend working with dictionaries (that would have worked before the fix):

# retrieve info as dictionary
v = as_dict(get_compartments('v', exact=True))
# make changes that need to be made to the dictionary then apply with
set_compartments(exact=True, **v)
fbergmann commented 5 months ago

i've released an updated package to solve the issue.

pmendes commented 5 months ago

Thank you!