Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Migrated to Pint >= 0.24 (the `ScaleConverter` and `UnitDefinition` classes moved to `pint.facets.plain` and changed argument signatures). This reverses the `Pint < 0.20` pin introduced in 0.3.5 and restores compatibility with numpy 2.x, which older Pint versions could not import.
- Added support for Python 3.14.
- Dropped support for Python 3.9 as Pint >= 0.24 requires Python >= 3.10.
- Added support for sympy 1.13 and 1.14 (minimum supported sympy version is now 1.10).

# Release 0.3.7
- Added support for Python 3.12 and 3.13.
Expand Down
3 changes: 2 additions & 1 deletion cellmlmanip/_singularity_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ def _fix_expr_parts(expr, V, U_offset, exp_function):
expr_parts.append(_generate_piecewise(ex, V, sp, Vmin, Vmax) if sp is not None else ex)
return (None, None, None, Add(*expr_parts), is_piecewise)

elif isinstance(expr, Pow) and expr.args[1] == -1.0 and len(expr.args) == 2: # 1/A
# 1/A
elif isinstance(expr, Pow) and len(expr.args) == 2 and expr.args[1].is_number and float(expr.args[1]) == -1.0:
# Find singularities in A and adjust result to represent 1 / A
Vmin, Vmax, sp, ex, has_piecewise = _fix_expr_parts(expr.args[0], V, U_offset, exp_function)
has_piecewise = has_piecewise or Vmin is not None
Expand Down
6 changes: 0 additions & 6 deletions cellmlmanip/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def __init__(self, store=None):
self._calculator = UnitCalculator(self)

# Expose the Unit and Quantity classes
# TODO Might not be needed in 0.10 anymore
self.Unit = self._registry.Unit
self.Quantity = self._registry.Quantity

Expand Down Expand Up @@ -164,7 +163,6 @@ def add_unit(self, name, expression):
# Add prefixes inside expression
expression = _WORD.sub(self._prefix_expression, expression)

# Dimensionless units can't be created using a string expression.
# To test if this is a dimensionless unit, parse the string as a Quantity and check if it's dimensionless
quantity = self._registry.parse_expression(expression)
if quantity.units == self._registry.dimensionless:
Expand Down Expand Up @@ -277,10 +275,6 @@ def get_conversion_factor(self, from_unit, to_unit):
cf = self.convert(1 * from_unit, to_unit).magnitude
if isinstance(cf, numbers.Number) and math.isclose(cf, 1.0):
return 1
elif isinstance(cf, sympy.Mul) and 1.0 in cf.args: # pragma: no cover
# We get an ugly artefact whereby pint gives us a 1.0*cf as conversion factor; remove the 1.0
# But only on older pint, e.g. 3.9
return sympy.Mul(*[a for a in cf.args if a != 1.0])
return cf

def convert(self, quantity, unit):
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ classifiers = [
]
dependencies = [
"lxml>=4.7",
"networkx>=2.1",
"Pint>=0.24, <0.26",
"rdflib>=4",
"sympy>=1.4, <1.13",
"networkx>=2.7",
"Pint>=0.24, <0.26", # Occasional breaking changes in minor versions
"rdflib>=6.2",
"sympy>=1.10, <1.15", # Occasional breaking changes in minor versions
]
Comment thread
kwabenantim marked this conversation as resolved.
dynamic = ["version"]

Expand Down
6 changes: 3 additions & 3 deletions requirements/base.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lxml>=4.7
pint>=0.24, <0.26
rdflib>=4
networkx>=2.1
sympy>=1.4, <1.13
rdflib>=6.2
networkx>=2.7
sympy>=1.10, <1.15
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pyparsing==3.3.2
# via rdflib
rdflib==7.6.0
# via -r base.in
sympy==1.12.1
sympy==1.14.0
# via -r base.in
typing-extensions==4.16.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pytest-cov==7.1.0
# via -r test.in
rdflib==7.6.0
# via -r base.in
sympy==1.12.1
sympy==1.14.0
# via -r base.in
tomli==2.4.1
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pytest-cov==7.1.0
# via -r test.in
rdflib==7.6.0
# via -r base.in
sympy==1.12.1
sympy==1.14.0
# via -r base.in
tomli==2.4.1
# via
Expand Down
2 changes: 1 addition & 1 deletion tests/test_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_symbol(self):

def test_number(self):
self.assert_equal('<cn>1</cn>',
[sympy.Number(1)])
[sympy.Number(1.0)])

def test_ignore_comment(self):
self.assert_equal('<!-- ignore this -->', [])
Expand Down