|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 | 3 | import enum
|
4 |
| -import pathlib |
5 | 4 | import tempfile
|
6 | 5 | import warnings
|
| 6 | +from pathlib import Path |
7 | 7 |
|
8 | 8 | import matplotlib as mpl
|
9 | 9 | import matplotlib.pyplot as plt
|
|
18 | 18 |
|
19 | 19 | def get_tikz_code(
|
20 | 20 | figure="gcf",
|
21 |
| - filepath: str | pathlib.Path | None = None, |
| 21 | + filepath: str | Path | None = None, |
22 | 22 | axis_width: str | None = None,
|
23 | 23 | axis_height: str | None = None,
|
24 | 24 | textsize: float = 10.0,
|
@@ -152,18 +152,20 @@ def get_tikz_code(
|
152 | 152 | data = {}
|
153 | 153 | data["axis width"] = axis_width
|
154 | 154 | 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 | + ) |
156 | 158 | data["externalize tables"] = externalize_tables
|
157 | 159 | data["override externals"] = override_externals
|
158 | 160 | data["externals search path"] = externals_search_path
|
159 | 161 |
|
160 | 162 | if filepath:
|
161 |
| - filepath = pathlib.Path(filepath) |
| 163 | + filepath = Path(filepath) |
162 | 164 | data["output dir"] = filepath.parent
|
163 | 165 | data["base name"] = filepath.stem
|
164 | 166 | else:
|
165 | 167 | directory = tempfile.mkdtemp()
|
166 |
| - data["output dir"] = pathlib.Path(directory) |
| 168 | + data["output dir"] = Path(directory) |
167 | 169 | data["base name"] = "tmp"
|
168 | 170 |
|
169 | 171 | data["strict"] = strict
|
@@ -247,7 +249,7 @@ def get_tikz_code(
|
247 | 249 | return code
|
248 | 250 |
|
249 | 251 |
|
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): |
251 | 253 | """Same as `get_tikz_code()`, but actually saves the code to a file.
|
252 | 254 |
|
253 | 255 | :param filepath: The file to which the TikZ output will be written.
|
|
0 commit comments