Skip to content

Commit

Permalink
Merge pull request #3 from cgahr/improved_setup
Browse files Browse the repository at this point in the history
Improved setup
  • Loading branch information
cgahr authored Apr 6, 2023
2 parents 001c51b + f7bc948 commit 1b42dc2
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 41 deletions.
39 changes: 0 additions & 39 deletions setup.py

This file was deleted.

16 changes: 16 additions & 0 deletions src/latexplotlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
from ._latexplotlib import *
from ._version import __version__


def _make_styles_available() -> None:
from pathlib import Path

import matplotlib.pyplot as plt

lpl_styles = plt.style.core.read_style_directory(
Path(__path__[0]) / "styles" # noqa: F405
)

plt.style.core.update_nested_dict(plt.style.library, lpl_styles)
plt.style.core.available[:] = sorted(plt.style.library.keys())


_make_styles_available()
23 changes: 23 additions & 0 deletions src/latexplotlib/_latexplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, Iterator, Optional, Sequence, Tuple, Union

import matplotlib as mpl
import matplotlib.pyplot as plt
from appdirs import user_config_dir

Expand Down Expand Up @@ -327,3 +328,25 @@ def subplots(
)

return plt.subplots(nrows, ncols, figsize=_figsize, **kwargs)


def delete_styles_from_previous_installation() -> None:
"""A helper function to remove old style files."""
old = [
"latex10pt-minimal.mplstyle",
"latex10pt.mplstyle",
"latex11pt-minimal.mplstyle",
"latex11pt.mplstyle",
"latex12pt-minimal.mplstyle",
"latex12pt.mplstyle",
"latex9pt-minimal.mplstyle",
"latex9pt.mplstyle",
]

styledir = Path(mpl.get_configdir()) / "stylelib"

for name in old:
style = styledir / name

if style.exists() and input(f"delete {style}? [y/N]") == "y":
style.unlink()
2 changes: 1 addition & 1 deletion src/latexplotlib/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.3"
__version__ = "0.6.0"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import matplotlib.pyplot as plt
import pytest

styles_folder = Path("styles/")
styles_folder = Path("src/latexplotlib/styles/")


class TestStyles:
Expand Down

0 comments on commit 1b42dc2

Please sign in to comment.