plothist 1.3.2__py3-none-any.whl → 1.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plothist/__init__.py +66 -74
- plothist/_version.py +21 -0
- plothist/_version.pyi +2 -0
- plothist/comparison.py +4 -1
- plothist/histogramming.py +20 -12
- plothist/plothist_style.py +9 -7
- plothist/plotters.py +89 -55
- plothist/scripts/__init__.py +3 -2
- plothist/scripts/make_examples.py +27 -28
- plothist/variable_registry.py +17 -14
- {plothist-1.3.2.dist-info → plothist-1.4.0.dist-info}/METADATA +20 -12
- plothist-1.4.0.dist-info/RECORD +17 -0
- plothist-1.4.0.dist-info/entry_points.txt +2 -0
- {plothist-1.3.2.dist-info → plothist-1.4.0.dist-info}/licenses/LICENSE +1 -1
- plothist/dummy_data.csv +0 -100001
- plothist/get_dummy_data.py +0 -17
- plothist/scripts/install_latin_modern_fonts.py +0 -145
- plothist-1.3.2.dist-info/RECORD +0 -18
- plothist-1.3.2.dist-info/entry_points.txt +0 -3
- {plothist-1.3.2.dist-info → plothist-1.4.0.dist-info}/WHEEL +0 -0
- {plothist-1.3.2.dist-info → plothist-1.4.0.dist-info}/licenses/AUTHORS.md +0 -0
plothist/get_dummy_data.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from importlib.resources import files
|
|
2
|
-
import numpy as np
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def get_dummy_data():
|
|
6
|
-
"""
|
|
7
|
-
Get dummy data for plotting examples as a numpy ndarray.
|
|
8
|
-
|
|
9
|
-
Returns
|
|
10
|
-
-------
|
|
11
|
-
data : numpy ndarray
|
|
12
|
-
Dummy data.
|
|
13
|
-
"""
|
|
14
|
-
dummy_data_file = files("plothist").joinpath("dummy_data.csv")
|
|
15
|
-
with open(dummy_data_file, "r") as f:
|
|
16
|
-
data = np.genfromtxt(f, delimiter=",", names=True)
|
|
17
|
-
return data
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import subprocess
|
|
2
|
-
import os
|
|
3
|
-
import platform
|
|
4
|
-
from pathlib import PosixPath
|
|
5
|
-
import time
|
|
6
|
-
import matplotlib
|
|
7
|
-
import requests
|
|
8
|
-
from zipfile import ZipFile
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def _download_font(url, font_directory, font_name):
|
|
12
|
-
"""
|
|
13
|
-
Download a font from a URL and save it in a directory.
|
|
14
|
-
|
|
15
|
-
Parameters
|
|
16
|
-
----------
|
|
17
|
-
url : str
|
|
18
|
-
The URL of the font.
|
|
19
|
-
font_directory : PosixPath
|
|
20
|
-
The directory where the font should be installed.
|
|
21
|
-
|
|
22
|
-
Raises
|
|
23
|
-
------
|
|
24
|
-
RuntimeError
|
|
25
|
-
If the download fails.
|
|
26
|
-
"""
|
|
27
|
-
print(f"Downloading {font_name}...")
|
|
28
|
-
attempt = 0
|
|
29
|
-
max_attempt = 10
|
|
30
|
-
success = False
|
|
31
|
-
|
|
32
|
-
while not success and attempt < max_attempt:
|
|
33
|
-
try:
|
|
34
|
-
r = requests.get(url)
|
|
35
|
-
with (font_directory / url.split("/")[-1]).open("wb") as f:
|
|
36
|
-
f.write(r.content)
|
|
37
|
-
success = True
|
|
38
|
-
except Exception as e:
|
|
39
|
-
# Print the output to the terminal
|
|
40
|
-
print(f"Error: {e}\nTry {attempt + 1} of {max_attempt}")
|
|
41
|
-
# Increment attempt counter and wait before the next attempt
|
|
42
|
-
attempt += 1
|
|
43
|
-
time.sleep(attempt)
|
|
44
|
-
|
|
45
|
-
if not success:
|
|
46
|
-
raise RuntimeError(
|
|
47
|
-
f"Failed to download {font_name} after {max_attempt} attempts. Try to install it manually (see https://plothist.readthedocs.io/en/latest/usage/font_installation.html)."
|
|
48
|
-
)
|
|
49
|
-
print(f"{font_name} downloaded successfully.")
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def install_latin_modern_fonts():
|
|
53
|
-
"""
|
|
54
|
-
Install Latin Modern Math, Latin Modern Roman and Latin Modern Sans fonts.
|
|
55
|
-
The font cache of matplotlib is removed, so matplotlib will be forced to update its font list.
|
|
56
|
-
|
|
57
|
-
The Latin Modern Math font is available at http://mirrors.ctan.org/fonts/lm-math/opentype/latinmodern-math.otf
|
|
58
|
-
The Latin Modern Roman and Latin Modern Sans fonts are available at https://www.1001fonts.com/latin-modern-roman-font.html and https://www.1001fonts.com/latin-modern-sans-font.html
|
|
59
|
-
|
|
60
|
-
This function is only implemented for Linux and MacOS.
|
|
61
|
-
|
|
62
|
-
Raises:
|
|
63
|
-
------
|
|
64
|
-
NotImplementedError: If the function is called on an unsupported operating system.
|
|
65
|
-
RuntimeError: If the installation of the fonts fails.
|
|
66
|
-
"""
|
|
67
|
-
if platform.system() == "Linux": # Linux
|
|
68
|
-
font_directory = PosixPath("~/.fonts/").expanduser()
|
|
69
|
-
font_directory.mkdir(parents=True, exist_ok=True)
|
|
70
|
-
elif platform.system() == "Darwin": # MacOS
|
|
71
|
-
font_directory = PosixPath(f"/Users/{os.getlogin()}/Library/Fonts").expanduser()
|
|
72
|
-
else:
|
|
73
|
-
raise NotImplementedError(
|
|
74
|
-
f"This script is only implemented for Linux and MacOS. If you manage to make it work on {platform.system()}, please submit a pull request."
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
if not PosixPath(font_directory / "latinmodern-math.otf").exists():
|
|
78
|
-
# Install Latin Modern Math
|
|
79
|
-
_download_font(
|
|
80
|
-
"http://mirrors.ctan.org/fonts/lm-math/opentype/latinmodern-math.otf",
|
|
81
|
-
font_directory,
|
|
82
|
-
"Latin Modern Math",
|
|
83
|
-
)
|
|
84
|
-
print("Latin Modern Math installed successfully.\n")
|
|
85
|
-
else:
|
|
86
|
-
print("Latin Modern Math already installed.\n")
|
|
87
|
-
|
|
88
|
-
# Install Latin Modern Roman and Latin Modern Sans
|
|
89
|
-
for lm in ["roman", "sans"]:
|
|
90
|
-
if PosixPath(font_directory / f"latin-modern-{lm}").exists():
|
|
91
|
-
print(f"Latin Modern {lm} already installed.\n")
|
|
92
|
-
continue
|
|
93
|
-
|
|
94
|
-
attempt = 0
|
|
95
|
-
max_attempt = 10
|
|
96
|
-
success = False
|
|
97
|
-
|
|
98
|
-
while not success and attempt < max_attempt:
|
|
99
|
-
_download_font(
|
|
100
|
-
f"https://www.1001fonts.com/download/latin-modern-{lm}.zip",
|
|
101
|
-
font_directory,
|
|
102
|
-
f"Latin Modern {lm}",
|
|
103
|
-
)
|
|
104
|
-
print(f"Unzipping Latin Modern {lm}...")
|
|
105
|
-
|
|
106
|
-
try:
|
|
107
|
-
with ZipFile(font_directory / f"latin-modern-{lm}.zip", "r") as zip_ref:
|
|
108
|
-
zip_ref.extractall(font_directory / f"latin-modern-{lm}")
|
|
109
|
-
success = True
|
|
110
|
-
except Exception as e:
|
|
111
|
-
# Print the output to the terminal
|
|
112
|
-
print(f"Error: {e}\nTry {attempt + 1} of {max_attempt}")
|
|
113
|
-
# Increment attempt counter and wait before the next attempt
|
|
114
|
-
attempt += 1
|
|
115
|
-
time.sleep(attempt)
|
|
116
|
-
subprocess.run(
|
|
117
|
-
["rm", "-f", (font_directory / f"latin-modern-{lm}.zip")]
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
print(f"Latin Modern {lm} installed successfully.\n")
|
|
121
|
-
subprocess.run(["rm", "-f", (font_directory / f"latin-modern-{lm}.zip")])
|
|
122
|
-
|
|
123
|
-
# Remove font cache files
|
|
124
|
-
matplotlib_font_cache_files = PosixPath(matplotlib.get_cachedir()).glob(
|
|
125
|
-
"fontlist-v???.json"
|
|
126
|
-
)
|
|
127
|
-
for matplotlib_font_cache in matplotlib_font_cache_files:
|
|
128
|
-
try:
|
|
129
|
-
subprocess.run(
|
|
130
|
-
["rm", "-v", matplotlib_font_cache],
|
|
131
|
-
check=True,
|
|
132
|
-
)
|
|
133
|
-
except subprocess.CalledProcessError:
|
|
134
|
-
print(
|
|
135
|
-
f"""
|
|
136
|
-
Error while trying to remove {matplotlib_font_cache}, but maybe this is not needed.
|
|
137
|
-
Check whether the Latin Modern fonts are now available in your matplotlib.
|
|
138
|
-
If they are not, find the correct fontlist-XXX.json file in your matplotlib cache and remove it manually.
|
|
139
|
-
If it still does not work, please check the documentation at https://plothist.readthedocs.io/en/latest/usage/font_installation.html
|
|
140
|
-
"""
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if __name__ == "__main__":
|
|
145
|
-
install_latin_modern_fonts()
|
plothist-1.3.2.dist-info/RECORD
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
plothist/__init__.py,sha256=diRwBlD_Ly-EB-wJqO6IDZ5TCvg3BWRR95lEQWybE7A,3058
|
|
2
|
-
plothist/comparison.py,sha256=qrQHQ0vv-0rBWaSAvkeZLeZyJb-I4rhsEQtLWQxO3jc,17431
|
|
3
|
-
plothist/default_style.mplstyle,sha256=7MmB2uiXmD_DSqFHeH1xxC-lTctBD_EASxMdSOsPep0,1574
|
|
4
|
-
plothist/dummy_data.csv,sha256=sb4LCjYW4ZO2bLCJvrunrIses-0CHe7CNwd5-BgCme8,5936219
|
|
5
|
-
plothist/get_dummy_data.py,sha256=jfSCdeNlfXSJ4ODn0vEXrnBOSHYt6uJnbU3Aadeedxk,412
|
|
6
|
-
plothist/histogramming.py,sha256=A9tGRqhJ1-M85IuCSsgs5OVLZWxWoRtNnr1kXhJXQdU,10201
|
|
7
|
-
plothist/plothist_style.py,sha256=9Ucp40-wsHyjizUlnJFsBeWJaw56nj8FwK2cFX-pV9c,12755
|
|
8
|
-
plothist/plotters.py,sha256=n9XBamhdWRvbfuYWLQjRLT3MiphtAqfh5sUgWRoo_yc,42479
|
|
9
|
-
plothist/variable_registry.py,sha256=_fJEhr_jfm6CwxmfFK5qcRUE1VAxUlecnZEzHeuinDs,10207
|
|
10
|
-
plothist/scripts/__init__.py,sha256=FRe2fYlnv0lJYqn8wPxAmhDs1XME8pvEs3rQgJpjp3k,108
|
|
11
|
-
plothist/scripts/install_latin_modern_fonts.py,sha256=e4el7nYf8vXX1bXw535Lu6fLatXud8ZSaJNGYSx2ejo,5485
|
|
12
|
-
plothist/scripts/make_examples.py,sha256=ZGvtxpx287kLk4ldeLcZZb2ArkKSvjw4iIuRK8XZKp8,7500
|
|
13
|
-
plothist-1.3.2.dist-info/METADATA,sha256=lbWNRW2womMcFQhdoyN7JoEFCaL3mJvFGH3cWT600EE,3804
|
|
14
|
-
plothist-1.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
15
|
-
plothist-1.3.2.dist-info/entry_points.txt,sha256=JfZzqUK75dTTwdqP26s5hcAFms0-IACyuc2p8kPxqCI,188
|
|
16
|
-
plothist-1.3.2.dist-info/licenses/AUTHORS.md,sha256=02x3_8PNyTsXcRs0IlJeCTOmpGNRqymcJ71-2QtR37E,111
|
|
17
|
-
plothist-1.3.2.dist-info/licenses/LICENSE,sha256=zLdEtgFx6ObRPsz6Ofa0zJb5EuL0Z54FJP8egGX_unU,1523
|
|
18
|
-
plothist-1.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|