From 9574f01e2caf2406a48914038b5f46c4d6656ed4 Mon Sep 17 00:00:00 2001 From: Milan Rother Date: Wed, 4 Nov 2026 21:09:23 +0100 Subject: [PATCH 1/2] Remove Polynomial, pathsim.blocks.Polynomial replaces it --- src/pathsim_chem/__init__.py | 12 ++++++++- .../thermodynamics/correlations.py | 26 ------------------- tests/thermodynamics/test_correlations.py | 25 ++++-------------- 3 files changed, 16 insertions(+), 47 deletions(-) diff --git a/src/pathsim_chem/__init__.py b/src/pathsim_chem/__init__.py index 1b51985..1bd5be1 100644 --- a/src/pathsim_chem/__init__.py +++ b/src/pathsim_chem/__init__.py @@ -19,6 +19,16 @@ from .neutronics import * +#blocks that were removed -> what to use instead +_REMOVED = { + "Polynomial": "pathsim.blocks.Polynomial with the coefficients in descending order (numpy.polyval)", +} + + def __getattr__(name): - """Deprecated aliases for the blocks that moved, see 'tritium'""" + """Deprecated aliases for the blocks that moved, see 'tritium', and an + error that names the replacement for the blocks that were removed. + """ + if name in _REMOVED: + raise ImportError(f"'{name}' was removed from pathsim-chem, use {_REMOVED[name]}") return getattr(tritium, name) diff --git a/src/pathsim_chem/thermodynamics/correlations.py b/src/pathsim_chem/thermodynamics/correlations.py index 96f25fe..4bbf871 100644 --- a/src/pathsim_chem/thermodynamics/correlations.py +++ b/src/pathsim_chem/thermodynamics/correlations.py @@ -16,32 +16,6 @@ # BLOCKS ================================================================================ -class Polynomial(Function): - r"""Polynomial correlation (IK-CAPE code: POLY). - - .. math:: - - f(T) = \sum_{i=0}^{n} a_i \, T^i - - General-purpose polynomial for temperature-dependent properties. - - Parameters - ---------- - coeffs : list or tuple of float - Polynomial coefficients :math:`[a_0, a_1, \ldots, a_n]` (up to 10). - """ - - input_port_labels = {"T": 0} - output_port_labels = {"value": 0} - - def __init__(self, coeffs): - self.coeffs = tuple(coeffs) - super().__init__(func=self._eval) - - def _eval(self, T): - return sum(a * T**i for i, a in enumerate(self.coeffs)) - - class ExponentialPolynomial(Function): r"""Exponential polynomial correlation (IK-CAPE code: EPOL). diff --git a/tests/thermodynamics/test_correlations.py b/tests/thermodynamics/test_correlations.py index e1e99af..14a5715 100644 --- a/tests/thermodynamics/test_correlations.py +++ b/tests/thermodynamics/test_correlations.py @@ -13,7 +13,6 @@ import numpy as np from pathsim_chem.thermodynamics import ( - Polynomial, ExponentialPolynomial, Watson, Antoine, @@ -43,25 +42,12 @@ def eval_block(block, T): # TESTS ================================================================================ -class TestPolynomial(unittest.TestCase): +class TestPolynomialRemoved(unittest.TestCase): - def test_init(self): - P = Polynomial(coeffs=[1.0, 2.0, 3.0]) - self.assertEqual(P.coeffs, (1.0, 2.0, 3.0)) - - def test_constant(self): - P = Polynomial(coeffs=[42.0]) - self.assertAlmostEqual(eval_block(P, 300), 42.0) - - def test_linear(self): - P = Polynomial(coeffs=[10.0, 0.5]) - # f(300) = 10 + 0.5*300 = 160 - self.assertAlmostEqual(eval_block(P, 300), 160.0) - - def test_quadratic(self): - P = Polynomial(coeffs=[1.0, 0.0, 0.01]) - # f(10) = 1 + 0 + 0.01*100 = 2 - self.assertAlmostEqual(eval_block(P, 10), 2.0) + def test_import_names_replacement(self): + #removed in favour of pathsim.blocks.Polynomial, the coefficient order differs + with self.assertRaisesRegex(ImportError, "pathsim.blocks.Polynomial"): + from pathsim_chem import Polynomial class TestExponentialPolynomial(unittest.TestCase): @@ -339,7 +325,6 @@ class TestSmokeAllBlocks(unittest.TestCase): def test_all_blocks_at_300K(self): blocks = [ - Polynomial(coeffs=[1.0, 0.01]), ExponentialPolynomial(coeffs=[2.0, 0.001]), Watson(a0=5e7, a1=0.38, a2=647.0), Antoine(a0=23.2256, a1=3835.18, a2=-45.343), From 1757339bf65e3578463808522f9f821afdd270a8 Mon Sep 17 00:00:00 2001 From: Milan Rother Date: Wed, 4 Nov 2026 21:31:05 +0100 Subject: [PATCH 2/2] Remove the Polynomial icon --- src/pathsim_chem/icons/Polynomial.svg | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/pathsim_chem/icons/Polynomial.svg diff --git a/src/pathsim_chem/icons/Polynomial.svg b/src/pathsim_chem/icons/Polynomial.svg deleted file mode 100644 index 376ce60..0000000 --- a/src/pathsim_chem/icons/Polynomial.svg +++ /dev/null @@ -1 +0,0 @@ -