Skip to content

Commit

Permalink
worked around PY2 sympy bug and added numpy to package requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Apr 14, 2020
1 parent 4fb7690 commit 5a1eda1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
20 changes: 12 additions & 8 deletions nineml/abstraction/expressions/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,18 @@ def _parse_expr(self, expr):
if self._logic_relation_re.search(expr):
expr = self._parse_relationals(expr)
self.escaped_names = set()
# try:
expr = sympy_parse(
expr, transformations=([self] + self._sympy_transforms),
local_dict=self.inline_randoms_dict)
# except Exception as e:
# raise NineMLMathParseError(
# "Could not parse math-inline expression: "
# "{}\n\n{}".format(expr, e))
# This is a work around for a PY2 bug in Sympy where the inspect module
# can't get the argument spec of a Callable object (instead of a func.)
def parser(tokens, local_dict, global_dict):
return self(tokens, local_dict, global_dict)
try:
expr = sympy_parse(
expr, transformations=([parser] + self._sympy_transforms),
local_dict=self.inline_randoms_dict)
except Exception as e:
raise NineMLMathParseError(
"Could not parse math-inline expression: "
"{}\n\n{}".format(expr, e))
return self._postprocess(expr)

def _preprocess(self, tokens):
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ lxml>=3.7.3
pyyaml>=3.1
h5py>=2.7.0
future>=0.16.0
sympy>=1.1
numpydoc >= 0.7.0
sympy>=1.5
numpy>=1.11.0
numpydoc>=0.7.0
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
'future>=0.16.0',
'h5py>=2.7.0',
'PyYAML>=3.1',
'sympy>=1.2'],
'sympy>=1.5.1',
'numpy>=1.11.0'],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4',
tests_require=['nose', 'numpy']
tests_require=['nose']
)
2 changes: 1 addition & 1 deletion test/unittests/abstraction_test/dynamics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def test_trigger(self):
'V < (V+10',
'V (< V+10)',
'V (< V+10)',
'1 / ( 1 + mg_conc * eta * exp (( -1 * gamma*V))'
'1 / ( 1 + mg_conc * eta * exp(-1 * gamma*V))'
'1..0'
'..0']
for tr in invalid_triggers:
Expand Down

0 comments on commit 5a1eda1

Please sign in to comment.