Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate python 3.8 and other deprecations #34

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.12"]
python-version: ["3.9", "3.10", "3.11"]
coverage: [false]
include:
- python-version: "3.11"
- python-version: "3.12"
coverage: true
steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ This release exports all functions in `matplotlib.pyplot` to `latexplotlib`. Thi

- bugfix: fix bug introduced in 0.8.1, where 'width_ratios' and 'height_ratios' were silently overwritten

## Version 0.X.X

## Version 0.9.0

- deprecated python 3.8 support
- deprecate `fraction` and `ratio` argument of `lpl.subplots`

### Development
- add tests for bugfix introduced in 0.8.3
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ authors = [
{email = "[email protected]", name = "Constantin Gahr"}
]
classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -31,7 +30,7 @@ keywords = [
license = {text = "MIT"}
name = "latexplotlib"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"

[project.optional-dependencies]
tests = [
Expand Down
3 changes: 1 addition & 2 deletions src/latexplotlib/_cleanup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import filecmp
from pathlib import Path
from typing import List

from matplotlib import get_configdir

Expand All @@ -20,7 +19,7 @@
STYLES_FOLDER = "styles"


def purge_old_styles(path: List[str]) -> None:
def purge_old_styles(path: list[str]) -> None:
if config[_PURGED_OLD]:
return

Expand Down
11 changes: 6 additions & 5 deletions src/latexplotlib/_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
from collections.abc import Iterator, Mapping
from contextlib import contextmanager
from pathlib import Path
from typing import Dict, Iterator, Mapping, Tuple, Union
from typing import Union

from appdirs import user_config_dir

Expand All @@ -15,7 +16,7 @@
CONFIGFILE: str = "config.ini"
CONFIGDIR: Path = Path(user_config_dir(NAME))
CONFIGPATH: Path = CONFIGDIR / CONFIGFILE
DEFAULT_CONFIG: Dict[str, Number] = {"width": 630, "height": 412, _PURGED_OLD: False}
DEFAULT_CONFIG: dict[str, Number] = {"width": 630, "height": 412, _PURGED_OLD: False}


class Config:
Expand All @@ -27,9 +28,9 @@ def __init__(self, path: Path) -> None:

self._config = self._open(path)

def _open(self, path: Path) -> Dict[str, ConfigData]:
def _open(self, path: Path) -> dict[str, ConfigData]:
with path.open(encoding="utf-8") as fh:
config: Dict[str, ConfigData] = json.load(fh)
config: dict[str, ConfigData] = json.load(fh)
return config

def _write(self, cfg: Mapping[str, ConfigData]) -> None:
Expand Down Expand Up @@ -70,7 +71,7 @@ def reload(self) -> None:
config.reload()
self._width, self._height = config["width"], config["height"]

def get(self) -> Tuple[Number, Number]:
def get(self) -> tuple[Number, Number]:
"""Returns the current size of the figure in pts.

Returns
Expand Down
38 changes: 6 additions & 32 deletions src/latexplotlib/_latexplotlib.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import warnings
from typing import (
TYPE_CHECKING,
Any,
Dict,
Literal,
Optional,
Sequence,
Tuple,
Union,
)
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Literal, Optional, Union

import matplotlib.pyplot as plt

Expand Down Expand Up @@ -83,7 +75,7 @@ def figsize( # noqa: PLR0913
aspect: Union[float, Literal["auto", "equal"]] = GOLDEN_RATIO,
height_ratios: Optional[Sequence[float]] = None,
width_ratios: Optional[Sequence[float]] = None,
) -> Tuple[float, float]:
) -> tuple[float, float]:
"""Computes the optimal figsize.

This function computes width and height (in inches) such that a figure using this
Expand Down Expand Up @@ -155,12 +147,10 @@ def subplots( # noqa: PLR0913
squeeze: bool = True,
width_ratios: Optional[Sequence[float]] = None,
height_ratios: Optional[Sequence[float]] = None,
subplot_kw: Optional[Dict[str, Any]] = None,
gridspec_kw: Optional[Dict[str, Any]] = None,
ratio: Any = None, # noqa: ANN401
fraction: Any = None, # noqa: ANN401
subplot_kw: Optional[dict[str, Any]] = None,
gridspec_kw: Optional[dict[str, Any]] = None,
**fig_kw: Any, # noqa: ANN401
) -> Tuple[Figure, Any]:
) -> tuple[Figure, Any]:
"""
Create a figure and a set of subplots.

Expand Down Expand Up @@ -283,22 +273,6 @@ def subplots( # noqa: PLR0913
"keyword 'figsize' is ignored and its value discarded.", stacklevel=2
)

if ratio is not None:
warnings.warn(
"the keyword argument 'ratio' is deprecated and will removed in the "
"future. Use 'aspect' instead.",
DeprecationWarning,
stacklevel=2,
)

if fraction is not None:
warnings.warn(
"the keyword argument 'fraction' is deprecated and will be removed in the "
"future. Use 'scale' instead.",
DeprecationWarning,
stacklevel=2,
)

gridspec_kw = dict(gridspec_kw or {})
if height_ratios is not None:
if "height_ratios" in gridspec_kw:
Expand Down
3 changes: 1 addition & 2 deletions src/latexplotlib/_styles.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from pathlib import Path
from typing import List

from matplotlib.pyplot import style


def make_styles_available(path: List[str]) -> None:
def make_styles_available(path: list[str]) -> None:
lpl_styles = style.core.read_style_directory(Path(path[0]) / "styles")

style.core.update_nested_dict(style.library, lpl_styles)
Expand Down
2 changes: 1 addition & 1 deletion src/latexplotlib/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.3"
__version__ = "0.9.0"
4 changes: 2 additions & 2 deletions tests/test_30_latexplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ def test_args(self):
lpl.subplots(2, 3)

def test_deprecates_ratio(self):
with pytest.warns(DeprecationWarning):
with pytest.raises(AttributeError):
lpl.subplots(1, 1, ratio=1)

def test_deprecates_fraction(self):
with pytest.warns(DeprecationWarning):
with pytest.raises(AttributeError):
lpl.subplots(1, 1, fraction=1)

def test_warns_if_figsize_used(self):
Expand Down