EPFL-LCSB / pytfa

A Python 3 implementation of Thermodynamics-based Flux Analysis
https://lcsb.epfl.ch/
Apache License 2.0
38 stars 26 forks source link

Problem with pytfa.relax_dgo due to sympy #47

Open embt opened 3 years ago

embt commented 3 years ago

Hello, first of all big thanks for supporting the package! I had a problem with the function relax_dgo and also a possible solution: from pytfa.optim.relaxation import relax_dgo relaxed_model, slack_model, relax_table = relax_dgo(mytfa)

The follwing Error occours:

~\AppData\Roaming\Python\Python38\site-packages\pytfa\optim\utils.py in symbol_sum(variables) 108 k=0 109 # If we encounter a zero, which is a special type, increase k --> 110 while isinstance(variables[k], sympy.numbers.Zero) and k<len(variables): 111 k+=1 112 if k == len(variables):

AttributeError: module 'sympy' has no attribute 'numbers'

By changing sympy.numbers.Zero to sympy.core.numbers.Zero in ~\AppData\Roaming\Python\Python38\site-packages\pytfa\optim\utils.py the Error is gone. This seems like sympy changed something there.

I'm using Python Python 3.8.5 and sympy version 1.6.2

Regards, Emil

psalvy commented 3 years ago

Good day Emil,

Thanks a lot for using our package! Looks like sympy changed the behavior/location of their Zero object (this suggests maybe it was 14 months ago ?). Thanks for the quick fix you provided! Would you mind sending out a PR for this ? Cheers, Pierre

embt commented 3 years ago

I hope I did everything right, I'm a bit new to GitHub. Thanks!