Skip to content

Commit f51e55a

Browse files
committed
more path simplifications
1 parent 0956bac commit f51e55a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/tikzplotlib/_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ def _gen_filepath(data, nb_key, ext):
55
rel_filepath = Path(f"{data['base name']}-{data[nb_key]:03d}{ext}")
66

77
if data["rel data path"]:
8-
rel_filepath = Path(data["rel data path"]) / rel_filepath
8+
rel_filepath = data["rel data path"] / rel_filepath
99

10-
return Path(data["output dir"]) / rel_filepath, rel_filepath
10+
return data["output dir"] / rel_filepath, rel_filepath
1111

1212

1313
def new_filepath(data, file_kind, ext):

src/tikzplotlib/_save.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from __future__ import annotations
22

33
import enum
4-
import pathlib
54
import tempfile
65
import warnings
6+
from pathlib import Path
77

88
import matplotlib as mpl
99
import matplotlib.pyplot as plt
@@ -18,7 +18,7 @@
1818

1919
def get_tikz_code(
2020
figure="gcf",
21-
filepath: str | pathlib.Path | None = None,
21+
filepath: str | Path | None = None,
2222
axis_width: str | None = None,
2323
axis_height: str | None = None,
2424
textsize: float = 10.0,
@@ -152,18 +152,20 @@ def get_tikz_code(
152152
data = {}
153153
data["axis width"] = axis_width
154154
data["axis height"] = axis_height
155-
data["rel data path"] = tex_relative_path_to_data
155+
data["rel data path"] = (
156+
None if tex_relative_path_to_data is None else Path(tex_relative_path_to_data)
157+
)
156158
data["externalize tables"] = externalize_tables
157159
data["override externals"] = override_externals
158160
data["externals search path"] = externals_search_path
159161

160162
if filepath:
161-
filepath = pathlib.Path(filepath)
163+
filepath = Path(filepath)
162164
data["output dir"] = filepath.parent
163165
data["base name"] = filepath.stem
164166
else:
165167
directory = tempfile.mkdtemp()
166-
data["output dir"] = pathlib.Path(directory)
168+
data["output dir"] = Path(directory)
167169
data["base name"] = "tmp"
168170

169171
data["strict"] = strict
@@ -247,7 +249,7 @@ def get_tikz_code(
247249
return code
248250

249251

250-
def save(filepath: str | pathlib.Path, *args, encoding: str | None = None, **kwargs):
252+
def save(filepath: str | Path, *args, encoding: str | None = None, **kwargs):
251253
"""Same as `get_tikz_code()`, but actually saves the code to a file.
252254
253255
:param filepath: The file to which the TikZ output will be written.

0 commit comments

Comments
 (0)