Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expressions issue #522

Open
Princeofthebow opened this issue Oct 27, 2020 · 5 comments
Open

Expressions issue #522

Princeofthebow opened this issue Oct 27, 2020 · 5 comments

Comments

@Princeofthebow
Copy link

Hello, I have the following code

#test_model.py
from pysb import *
from pysb.pathfinder import set_path
from pysb.simulator import ScipyOdeSimulator
set_path('bng', 'C:\Program Files\BNG')

Model()
Monomer('A',['a'])
Parameter('Hcoeff',1.0)
Parameter('A0',20)
Observable('A_total', A())
Expression('kf_A', A_total*Hcoeff)

Rule('bindA', A(a=None) + A(a=None) >> A(a=1) % A(a=1), kf_A)
Initial(A(a=None),A0)

simres = ScipyOdeSimulator(model, tspan=[0,20]).run()

but unfortunately I get the following error:

AttributeError: 'str' object has no attribute 'args'

I think the code is correct. May this be a bug?

@jmuhlich
Copy link
Member

Could you paste the full stack trace from the exception? Just the final error message is not quite enough to go on. Thanks.

@Princeofthebow
Copy link
Author

Sure, so if I omitted it.

Traceback (most recent call last):
  File "test.py", line 17, in <module>
    simres = ScipyOdeSimulator(model, tspan=[0,20]).run()
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\simulator\scipyode.py", line 165, in __init__
    pysb.bng.generate_equations(self._model, self.cleanup, self.verbose)
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\bng.py", line 731, in generate_equations
    lines = iter(generate_network(model, cleanup=cleanup,
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\bng.py", line 672, in generate_network
    bngfile.execute()
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\bng.py", line 443, in execute
    output += self.generator.get_content()
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\generator\bng.py", line 26, in get_content
    self.generate_content()
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\generator\bng.py", line 31, in generate_content
    self.generate_parameters()
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\generator\bng.py", line 42, in generate_parameters
    exprs = self.model.expressions_constant()
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\core.py", line 1976, in expressions_constant
    cset = ComponentSet(e for e in self.expressions
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\core.py", line 2255, in __init__
    for value in iterable:
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\core.py", line 1977, in <genexpr>
    if e.is_constant_expression())
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\pysb\core.py", line 1644, in is_constant_expression
    for a in self.expr.atoms())
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\sympy\core\basic.py", line 523, in atoms
    result = {node for node in nodes if not node.args}
  File "C:\Users\Jpk\AppData\Local\Programs\Python\Python38\lib\site-packages\sympy\core\basic.py", line 523, in <setcomp>
    result = {node for node in nodes if not node.args}
AttributeError: 'str' object has no attribute 'args'

@jmuhlich
Copy link
Member

Could you also paste the output of python -m pip freeze? I wonder if there is some dependency (like sympy) that's not up to date.

@jmuhlich
Copy link
Member

I should add that your code looks correct and runs OK for me, so the problem is not your own code.

@JamesPino
Copy link
Contributor

I believe this is the same issue as #503 ? Sympy >1.6 breakage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants