Skip to content

Commit

Permalink
Merge pull request #37 from cgahr/number
Browse files Browse the repository at this point in the history
Version 0.8.2
  • Loading branch information
cgahr committed Jul 9, 2024
2 parents 40e4430 + 84a526d commit bec7215
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ This release exports all functions in `matplotlib.pyplot` to `latexplotlib`. Thi
- fix previously unnoticed ruff errors
- update badges

## Version 0.x.x
## Version 0.8.2

- update `lpl.subplots` docstring
- typing: allow both floats and ints as widths and height

### Development
- remove unused packages from environment.yml
- add requirements.txt
3 changes: 0 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ channels:
- conda-forge
- defaults
dependencies:
- black
- coverage
- ipython
- matplotlib
- mypy
- pip
- pre-commit
- pytest
Expand All @@ -16,7 +14,6 @@ dependencies:
- python>=3.8
- ruff
- pip:
- ruff-lsp
- python-lsp-server
- pylsp-mypy
- "--editable=.[tests]"
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--editable .[tests]
ipykernel
numpy
pre-commit
pylsp-mypy
python-lsp-server
ruff
18 changes: 9 additions & 9 deletions src/latexplotlib/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

from appdirs import user_config_dir

Number = Union[int, float]
ConfigData = Union[Number, bool]

GOLDEN_RATIO: float = (5**0.5 + 1) / 2
NAME: str = "latexplotlib"
_PURGED_OLD = "_purged_old_styles"

CONFIGFILE: str = "config.ini"
CONFIGDIR: Path = Path(user_config_dir(NAME))
CONFIGPATH: Path = CONFIGDIR / CONFIGFILE
DEFAULT_CONFIG: Dict[str, int] = {"width": 630, "height": 412, _PURGED_OLD: False}


ConfigData = Union[int, bool]
DEFAULT_CONFIG: Dict[str, Number] = {"width": 630, "height": 412, _PURGED_OLD: False}


class Config:
Expand Down Expand Up @@ -60,8 +60,8 @@ def __setitem__(self, name: str, value: ConfigData) -> None:


class Size:
_width: int
_height: int
_width: Number
_height: Number

def __init__(self) -> None:
self._width, self._height = config["width"], config["height"]
Expand All @@ -70,7 +70,7 @@ def reload(self) -> None:
config.reload()
self._width, self._height = config["width"], config["height"]

def get(self) -> Tuple[int, int]:
def get(self) -> Tuple[Number, Number]:
"""Returns the current size of the figure in pts.
Returns
Expand All @@ -80,7 +80,7 @@ def get(self) -> Tuple[int, int]:
"""
return self._width, self._height

def set(self, width: int, height: int) -> None:
def set(self, width: Number, height: Number) -> None:
"""Sets the size of the latex page in pts.
You can find the size of the latex page with the following commands:
Expand All @@ -99,7 +99,7 @@ def set(self, width: int, height: int) -> None:
self._width, self._height = width, height

@contextmanager
def context(self, width: int, height: int) -> Iterator[None]:
def context(self, width: Number, height: Number) -> Iterator[None]:
"""This context manager temporarily sets the size of the figure in pts.
Parameters
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.1"
__version__ = "0.8.2"

0 comments on commit bec7215

Please sign in to comment.