diff --git a/pyvaporation/__init__.py b/pyvaporation/__init__.py index d59ef76..ab3ee92 100644 --- a/pyvaporation/__init__.py +++ b/pyvaporation/__init__.py @@ -52,3 +52,5 @@ "Component", "Components", ] + +__version__ = "1.1.6" diff --git a/pyvaporation/mixtures/mixture.py b/pyvaporation/mixtures/mixture.py index faf974b..f59d79d 100644 --- a/pyvaporation/mixtures/mixture.py +++ b/pyvaporation/mixtures/mixture.py @@ -7,11 +7,6 @@ from ..utils import NRTLParameters, R -def _is_in_0_to_1_range(instance: typing.Any, attribute, value: float) -> None: - if not 0 <= value <= 1: - raise ValueError("Give %s value is not in [0, 1] range" % value) - - class CompositionType: """ A class to describe type of the composition @@ -39,9 +34,15 @@ class Composition: A class to represent composition of the mixtures """ - p: float = attr.ib(validator=_is_in_0_to_1_range) + p: float type: str + def __attrs_post_init__(self): + if self.p < 0: + self.p = 0 + if self.p > 1: + self.p = 1 + @property def first(self) -> float: """ diff --git a/setup.py b/setup.py index 24710ff..1cd03e6 100644 --- a/setup.py +++ b/setup.py @@ -3,11 +3,11 @@ setup( name="pyvaporation", packages=find_packages(), - version="1.1.5", + version="1.1.6", license="Apache license 2.0", description="Set of tools for modelling pervaporation processes", author="Denis Sapegin, Aleksei Chekmachev", - author_email="a.checkmachev@gmail.com", + author_email="dasapegin@sr-systems.ru", url="https://github.com/Membrizard/PyVaporation", download_url="https://github.com/Membrizard/PyVaporation/archive/refs/tags/v1.1.5.tar.gz", long_description=open("README.md", "r").read(), diff --git a/tests/test_mixtures/test_mixture_methods.py b/tests/test_mixtures/test_mixture_methods.py index f6a4028..4c1806a 100644 --- a/tests/test_mixtures/test_mixture_methods.py +++ b/tests/test_mixtures/test_mixture_methods.py @@ -174,3 +174,8 @@ def test_get_nrtl_partial_pressures_from_weight_composition(): ) < 1e-3 ) + + +def test_invalid_compositions(): + assert Composition(p=-1, type="weight") == Composition(p=0, type="weight") + assert Composition(p=2, type="weight") == Composition(p=1, type="weight")