plothist 1.3.0__py3-none-any.whl → 1.3.2__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 CHANGED
@@ -1,7 +1,3 @@
1
- """Plot histograms in a scalable way and a beautiful style."""
2
-
3
- __version__ = "1.3.0"
4
-
5
1
  from .plotters import (
6
2
  create_comparison_figure,
7
3
  plot_hist,
@@ -95,13 +91,11 @@ __all__ = [
95
91
 
96
92
 
97
93
  # Get style file and use it
98
- # Deprecated since 3.11 function to access style file, to be updated
99
- # https://docs.python.org/3/library/importlib.resources.html
100
94
  import matplotlib.pyplot as plt
101
- from importlib.resources import path as resources_path
95
+ from importlib.resources import files
102
96
 
103
- with resources_path("plothist", "default_style.mplstyle") as style_file:
104
- plt.style.use(style_file.as_posix())
97
+ style_file = files("plothist").joinpath("default_style.mplstyle")
98
+ plt.style.use(style_file)
105
99
 
106
100
  # Check the fonts
107
101
  from matplotlib.font_manager import findfont
@@ -1,4 +1,4 @@
1
- from importlib.resources import path as resources_path
1
+ from importlib.resources import files
2
2
  import numpy as np
3
3
 
4
4
 
@@ -11,7 +11,7 @@ def get_dummy_data():
11
11
  data : numpy ndarray
12
12
  Dummy data.
13
13
  """
14
- with resources_path("plothist", "dummy_data.csv") as dummy_data:
15
- with open(dummy_data, "r") as f:
16
- data = np.genfromtxt(f, delimiter=",", names=True)
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
17
  return data
@@ -1,11 +1,7 @@
1
- # Set style
2
- # Deprecated since 3.11 function to access style file, to be updated
3
- # https://docs.python.org/3/library/importlib.resources.html
4
1
  import matplotlib.pyplot as plt
5
2
  import numpy as np
6
3
  import matplotlib as mpl
7
- import matplotlib.colors as mcolors
8
- from importlib.resources import path as resources_path
4
+ from importlib.resources import files
9
5
 
10
6
 
11
7
  def set_style(style="default"):
@@ -33,8 +29,8 @@ def set_style(style="default"):
33
29
  available_styles = ["default"]
34
30
 
35
31
  if style in available_styles:
36
- with resources_path("plothist", f"{style}_style.mplstyle") as style_file:
37
- plt.style.use(style_file.as_posix())
32
+ style_file = files("plothist").joinpath(f"{style}_style.mplstyle")
33
+ plt.style.use(style_file)
38
34
  else:
39
35
  raise ValueError(f"{style} not in the available styles: {available_styles}")
40
36
 
@@ -127,7 +123,7 @@ def get_color_palette(cmap, N):
127
123
  Parameters
128
124
  ----------
129
125
  cmap : str
130
- The name of the colormap to use. Use "ggplot" get the cycle of the default style. Use "cubehelix" to get the cubehelix palette with default settings. Can also be any colormap from matplotlib (we recommend "viridis", "coolwarm" or "YlGnBu_r").
126
+ The name of the colormap to use. Use "ggplot" get the cycle of the plothist style. Use "cubehelix" to get the cubehelix palette with default settings. Can also be any colormap from matplotlib (we recommend "viridis", "coolwarm" or "YlGnBu_r").
131
127
  N : int
132
128
  The number of colors to sample.
133
129
 
@@ -151,10 +147,17 @@ def get_color_palette(cmap, N):
151
147
  if cmap == "ggplot":
152
148
  if N > 7:
153
149
  raise ValueError(
154
- f"Only 7 colors are available in the default style cycle ({N} asked).",
150
+ f"Only 7 colors are available in the ggplot style cycle ({N} asked).",
155
151
  )
156
- prop_cycle = plt.rcParams["axes.prop_cycle"]
157
- return [mcolors.hex2color(prop["color"]) for prop in prop_cycle][:N]
152
+ return [
153
+ "#348ABD",
154
+ "#E24A33",
155
+ "#988ED5",
156
+ "#777777",
157
+ "#FBC15E",
158
+ "#8EBA42",
159
+ "#FFB5B8",
160
+ ][0:N]
158
161
 
159
162
  elif cmap == "cubehelix":
160
163
  return cubehelix_palette(N)
@@ -352,7 +355,7 @@ def add_luminosity(
352
355
 
353
356
  text = (
354
357
  r"$\mathrm{\mathbf{"
355
- + collaboration.replace(" ", "\,\,")
358
+ + collaboration.replace(" ", r"\,\,")
356
359
  + "}"
357
360
  + (r"\,\,preliminary}$" if preliminary else "}$")
358
361
  )
@@ -58,15 +58,15 @@ def make_examples(no_input=False, check_svg=False, print_code=False):
58
58
  else os.environ.get("PLOTHIST_PATH")
59
59
  )
60
60
 
61
- example_folder = plothist_folder + "/docs/examples"
62
- img_folder = plothist_folder + "/docs/img"
61
+ example_folder = plothist_folder + "/../../docs/examples"
62
+ img_folder = plothist_folder + "/../../docs/img"
63
63
 
64
64
  if not os.path.exists(example_folder) or not os.path.exists(img_folder):
65
65
  raise FileNotFoundError(
66
- f"Could not find the example or img folder for the documentation.\nIf you installed plothist from source using flit, please run `export PLOTHIST_PATH=path/to/plothist` before launching the script."
66
+ f"Could not find the example {example_folder} or img {img_folder} folder for the documentation.\nTry to run `export PLOTHIST_PATH=path/to/plothist` before launching the script."
67
67
  )
68
68
 
69
- temp_img_folder = plothist_folder + "/docs/temp_img"
69
+ temp_img_folder = plothist_folder + "/../../docs/temp_img"
70
70
 
71
71
  # Get all python files in the example folder
72
72
  python_files = [
@@ -171,6 +171,8 @@ def make_examples(no_input=False, check_svg=False, print_code=False):
171
171
  )
172
172
  if result.returncode != 0 and check_svg:
173
173
  fail(f"Error while redoing {file}:\n{result.stderr}\n{result.stdout}")
174
+ elif result.returncode != 0:
175
+ print(f"Error while redoing {file}:\n{result.stderr}\n{result.stdout}")
174
176
 
175
177
  # Move the svg files to the img folder
176
178
  for file in os.listdir(temp_img_folder):
@@ -1,27 +1,32 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: plothist
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Plot histograms in a scalable way and a beautiful style.
5
+ Project-URL: Homepage, https://github.com/cyrraz/plothist
6
+ Project-URL: Documentation, https://plothist.readthedocs.io/
7
+ Project-URL: Bug Tracker, https://github.com/cyrraz/plothist/issues
5
8
  Author-email: Cyrille Praz <cyrraz.code@protonmail.com>, Tristan Fillinger <tristan.github@gmail.com>
6
- Requires-Python: >=3.9
7
- Description-Content-Type: text/x-rst
9
+ License-File: AUTHORS.md
10
+ License-File: LICENSE
8
11
  Classifier: Intended Audience :: Developers
9
12
  Classifier: Intended Audience :: Education
10
- Classifier: Intended Audience :: Financial and Insurance Industry
11
13
  Classifier: Intended Audience :: Science/Research
12
14
  Classifier: License :: OSI Approved :: BSD License
13
15
  Classifier: Operating System :: OS Independent
14
16
  Classifier: Programming Language :: Python
15
17
  Classifier: Topic :: Scientific/Engineering
18
+ Requires-Python: >=3.9
16
19
  Requires-Dist: boost-histogram>=1.4.0
17
- Requires-Dist: numpy>=1.14.5
18
20
  Requires-Dist: matplotlib>=3.0
21
+ Requires-Dist: numpy>=1.14.5
19
22
  Requires-Dist: pyyaml>=5.3.1
20
- Requires-Dist: scipy>=1.6.0
21
23
  Requires-Dist: requests>=2.25.0
22
- Project-URL: Bug Tracker, https://github.com/cyrraz/plothist/issues
23
- Project-URL: Documentation, https://plothist.readthedocs.io/
24
- Project-URL: Homepage, https://github.com/cyrraz/plothist
24
+ Requires-Dist: scipy>=1.6.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pre-commit>=4.1.0; extra == 'dev'
27
+ Provides-Extra: test
28
+ Requires-Dist: pytest>=8.3.5; extra == 'test'
29
+ Description-Content-Type: text/x-rst
25
30
 
26
31
 
27
32
  ========
@@ -78,4 +83,3 @@ plothist
78
83
  :target: https://zenodo.org/doi/10.5281/zenodo.10995667
79
84
  .. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
80
85
  :target: https://github.com/psf/black
81
-
@@ -0,0 +1,18 @@
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,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: flit 3.10.1
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ install_latin_modern_fonts = plothist.scripts.install_latin_modern_fonts:install_latin_modern_fonts
3
+ plothist_make_examples = plothist.scripts.make_examples:make_examples
@@ -0,0 +1,2 @@
1
+ Cyrille Praz ([@cyrraz](https://github.com/cyrraz))
2
+ Tristan Fillinger ([@0ctagon](https://github.com/0ctagon))
@@ -1,17 +0,0 @@
1
- plothist/__init__.py,sha256=6oSa6gAt-3ta4LwyMh7PCtHsX7a2fwFrVxePSb3qCes,3314
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=7GrWea75f0vWGi1IQg1TRpq_NzaDsTQiXm7kQ7eZOdI,434
6
- plothist/histogramming.py,sha256=A9tGRqhJ1-M85IuCSsgs5OVLZWxWoRtNnr1kXhJXQdU,10201
7
- plothist/plothist_style.py,sha256=JEAez2o7i5o_OGAdl_-77zx0OXStRB6QLh6nA561jks,12908
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=b6QHG_a4G2KnAl0yjL7tL0n_Kovo5d84h7xODqBaAts,7373
13
- plothist-1.3.0.dist-info/entry_points.txt,sha256=8YWfI0-xVfDK4EmTWzQLfP4r0wJoUc4CTLk0lj2mKJY,185
14
- plothist-1.3.0.dist-info/LICENSE,sha256=zLdEtgFx6ObRPsz6Ofa0zJb5EuL0Z54FJP8egGX_unU,1523
15
- plothist-1.3.0.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
16
- plothist-1.3.0.dist-info/METADATA,sha256=Tn05Jj-tG9OBXfVet8Ux2qRPLCzJmJ7158iDG2tYRrQ,3688
17
- plothist-1.3.0.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- [console_scripts]
2
- install_latin_modern_fonts=plothist.scripts.install_latin_modern_fonts:install_latin_modern_fonts
3
- plothist_make_examples=plothist.scripts.make_examples:make_examples
4
-