Skip to content

Commit

Permalink
Bump to mizani ~0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
has2k1 committed Oct 24, 2024
1 parent f1b0d56 commit 6f60f5a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 21 deletions.
4 changes: 1 addition & 3 deletions plotnine/scales/_expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion plotnine/scales/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions plotnine/scales/scale_continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
11 changes: 0 additions & 11 deletions plotnine/scales/scale_datetime.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 9 additions & 3 deletions tests/test_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 6f60f5a

Please sign in to comment.