From 96576afaf84ad0a18702c78fb82f2a43002be1b9 Mon Sep 17 00:00:00 2001 From: Zebedee Nicholls Date: Tue, 16 May 2023 20:53:28 +1000 Subject: [PATCH 1/5] Fix pint regression --- src/openscm_units/_unit_registry.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/openscm_units/_unit_registry.py b/src/openscm_units/_unit_registry.py index 0f504f9..946033a 100644 --- a/src/openscm_units/_unit_registry.py +++ b/src/openscm_units/_unit_registry.py @@ -354,9 +354,12 @@ def add_standards(self): "Tt = 1000000000000 * t" ) # since Tt is used for "tex" in the defaults - self.define("ppt = [concentrations]") - self.define("ppb = 1000 * ppt") - self.define("ppm = 1000 * ppb") + self.define("ppm = [concentrations]") + self.define("ppb = ppm / 1000") + self.define("ppt = ppb / 1000") + # Have to rebuild cache to get right units for ppm as it is defined in + # pint + self._build_cache() def enable_contexts(self, *names_or_contexts, **kwargs): """ From b35194eef67dd463ccb87c420aa151eda5faeb80 Mon Sep 17 00:00:00 2001 From: Zebedee Nicholls Date: Tue, 16 May 2023 20:57:08 +1000 Subject: [PATCH 2/5] CHANGELOG --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 81a989c..ccf4b10 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,8 @@ Changelog ========= +- (`#40 `_) Fixed broken definition of ppm, caused by regression in Pint where `'ppm' was added to Pint `_ + v0.5.1 ------ From cee2c7fa0c9588087d62d1e7d982bd13b21e38fb Mon Sep 17 00:00:00 2001 From: Zebedee Nicholls Date: Tue, 16 May 2023 21:03:25 +1000 Subject: [PATCH 3/5] Fix up CI --- src/openscm_units/_unit_registry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/openscm_units/_unit_registry.py b/src/openscm_units/_unit_registry.py index 946033a..3d66c01 100644 --- a/src/openscm_units/_unit_registry.py +++ b/src/openscm_units/_unit_registry.py @@ -302,7 +302,7 @@ } -class ScmUnitRegistry(pint.UnitRegistry): +class ScmUnitRegistry(pint.UnitRegistry): # pylint: disable=too-many-ancestors """ Unit registry class. @@ -332,6 +332,8 @@ def __init__(self, *args, metric_conversions=None, **kwargs): Passed to the ``__init__`` method of the super class """ self._metric_conversions = metric_conversions + # If we didn't call init here, we wouldn't need to rebuild the cache + # below but that also feels like a bad pattern super().__init__(*args, **kwargs) def add_standards(self): From 8d134b0bd0bcae4d5af4686294a1d5cbfd09eb5d Mon Sep 17 00:00:00 2001 From: Zebedee Nicholls Date: Wed, 17 May 2023 10:32:31 +1000 Subject: [PATCH 4/5] Add pint versions to matrix --- .github/workflows/ci-cd-workflow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-cd-workflow.yml b/.github/workflows/ci-cd-workflow.yml index 8fdc6b5..2ac050e 100644 --- a/.github/workflows/ci-cd-workflow.yml +++ b/.github/workflows/ci-cd-workflow.yml @@ -55,6 +55,7 @@ jobs: strategy: matrix: python-version: [3.7, 3.8, 3.9] + pint-version: [0.18, 0.19, 0.20, 0.21] steps: - name: Checkout repository @@ -67,6 +68,7 @@ jobs: run: | pip install --upgrade pip pip install -e .[tests] + pip install 'pint==${{ matrix.pint-version }}' - name: Test with pytest env: MIN_COVERAGE: 70 # TODO: put this back up to 95 once we start writing From 90f835b71317f7e5fb2bf15203520adb80c073ce Mon Sep 17 00:00:00 2001 From: Zebedee Nicholls Date: Wed, 17 May 2023 11:35:07 +1000 Subject: [PATCH 5/5] Revert CI changes --- .github/workflows/ci-cd-workflow.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci-cd-workflow.yml b/.github/workflows/ci-cd-workflow.yml index 2ac050e..8fdc6b5 100644 --- a/.github/workflows/ci-cd-workflow.yml +++ b/.github/workflows/ci-cd-workflow.yml @@ -55,7 +55,6 @@ jobs: strategy: matrix: python-version: [3.7, 3.8, 3.9] - pint-version: [0.18, 0.19, 0.20, 0.21] steps: - name: Checkout repository @@ -68,7 +67,6 @@ jobs: run: | pip install --upgrade pip pip install -e .[tests] - pip install 'pint==${{ matrix.pint-version }}' - name: Test with pytest env: MIN_COVERAGE: 70 # TODO: put this back up to 95 once we start writing