From 6f60f5a3c5df673058b0cf4786a496a778983e39 Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Thu, 24 Oct 2024 14:17:55 +0300 Subject: [PATCH] Bump to mizani ~0.13.0 --- plotnine/scales/_expand.py | 4 +--- plotnine/scales/scale.py | 1 - plotnine/scales/scale_continuous.py | 3 +-- plotnine/scales/scale_datetime.py | 11 ----------- pyproject.toml | 2 +- tests/test_coords.py | 12 +++++++++--- 6 files changed, 12 insertions(+), 21 deletions(-) diff --git a/plotnine/scales/_expand.py b/plotnine/scales/_expand.py index c62ad602c..3663d83a7 100644 --- a/plotnine/scales/_expand.py +++ b/plotnine/scales/_expand.py @@ -9,8 +9,6 @@ from ..iapi import range_view if TYPE_CHECKING: - from typing import Type - from mizani.transforms import trans from plotnine.typing import CoordRange @@ -32,7 +30,7 @@ def _expand_range_distinct( def expand_range( x: CoordRange, expand: tuple[float, float] | tuple[float, float, float, float], - trans: trans | Type[trans], + trans: trans, ) -> range_view: """ Expand Coordinate Range in coordinate space diff --git a/plotnine/scales/scale.py b/plotnine/scales/scale.py index c6316cedb..ce2cb4358 100644 --- a/plotnine/scales/scale.py +++ b/plotnine/scales/scale.py @@ -3,7 +3,6 @@ from abc import ABC from copy import copy, deepcopy from dataclasses import dataclass, field -from functools import cached_property from typing import TYPE_CHECKING, Generic, cast import numpy as np diff --git a/plotnine/scales/scale_continuous.py b/plotnine/scales/scale_continuous.py index d85060082..ae873c1e0 100644 --- a/plotnine/scales/scale_continuous.py +++ b/plotnine/scales/scale_continuous.py @@ -2,7 +2,6 @@ from contextlib import suppress from dataclasses import dataclass -from functools import cached_property from typing import TYPE_CHECKING, Sequence from warnings import warn @@ -507,7 +506,7 @@ def get_labels( if self.labels is False or self.labels is None: labels = [] elif self.labels is True: - labels = self._trans.format(breaks) # type: ignore + labels = self._trans.format(breaks) elif callable(self.labels): labels = self.labels(breaks) elif isinstance(self.labels, dict): diff --git a/plotnine/scales/scale_datetime.py b/plotnine/scales/scale_datetime.py index d40f98583..958bd485b 100644 --- a/plotnine/scales/scale_datetime.py +++ b/plotnine/scales/scale_datetime.py @@ -1,21 +1,10 @@ from __future__ import annotations from dataclasses import KW_ONLY, InitVar, dataclass -from datetime import timedelta -from typing import TYPE_CHECKING, overload - -import numpy as np from ._runtime_typing import TransUser # noqa: TCH001 from .scale_continuous import scale_continuous -if TYPE_CHECKING: - from typing import Sequence - - import pandas as pd - - from plotnine.typing import FloatArray - @dataclass class scale_datetime(scale_continuous): diff --git a/pyproject.toml b/pyproject.toml index 0e0c41c4a..568317bb9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ dependencies = [ "matplotlib>=3.8.0", "pandas>=2.2.0", - "mizani~=0.12.2", + "mizani~=0.13.0", "numpy>=1.23.5", "scipy>=1.8.0", "statsmodels>=0.14.0", diff --git a/tests/test_coords.py b/tests/test_coords.py index e9147552a..a77d82b10 100644 --- a/tests/test_coords.py +++ b/tests/test_coords.py @@ -3,7 +3,7 @@ import numpy as np import pandas as pd import pytest -from mizani.transforms import trans_new +from mizani.transforms import trans from plotnine import ( aes, @@ -40,11 +40,17 @@ def test_coord_fixed(): def test_coord_trans(): - double_trans = trans_new("double", np.square, np.sqrt) + class double_trans(trans): + def transform(self, x): + return np.square(x) + + def inverse(self, x): + return np.sqrt(x) + # Warns probably because of a bad value around the left # edge of the domain. with pytest.warns(RuntimeWarning): - assert p + coord_trans(y=double_trans) == "coord_trans" + assert p + coord_trans(y=double_trans()) == "coord_trans" def test_coord_trans_reverse():