Skip to content

Commit 87d20f1

Browse files
authored
switch from deprecated pylab to pyplot (#1028)
1 parent f5038ec commit 87d20f1

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

tests/smoke_tests/alpert_and_knopf_2016/test_ak16_fig_1.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring
22
import numpy as np
33
import pytest
4-
from matplotlib import pylab
4+
from matplotlib import pyplot
55
from PySDM_examples.Alpert_and_Knopf_2016 import Table1, simulation
66

77
from PySDM.physics import si
@@ -56,30 +56,30 @@ def test_ak16_fig_1(multiplicity, plot=False): # pylint: disable=too-many-local
5656
f"{key}: σ=ln({int(cases[key]['ISA'].s_geom)}),"
5757
f"N={int(cases[key]['ISA'].norm_factor * dv)}"
5858
)
59-
pylab.step(
59+
pyplot.step(
6060
dt / si.min * np.arange(len(output_item[run])),
6161
output_item[run],
6262
label=label if run == 0 else None,
6363
color=cases[key]["color"],
6464
linewidth=0.666,
6565
)
6666
output_item.append(np.mean(np.asarray(output_item), axis=0))
67-
pylab.step(
67+
pyplot.step(
6868
dt / si.min * np.arange(len(output_item[-1])),
6969
output_item[-1],
7070
color=cases[key]["color"],
7171
linewidth=1.666,
7272
)
7373

74-
pylab.legend()
75-
pylab.yscale("log")
76-
pylab.ylim(1e-2, 1)
77-
pylab.xlim(0, total_time / si.min)
78-
pylab.xlabel("t / min")
79-
pylab.ylabel("$f_{ufz}$")
80-
pylab.gca().set_box_aspect(1)
74+
pyplot.legend()
75+
pyplot.yscale("log")
76+
pyplot.ylim(1e-2, 1)
77+
pyplot.xlim(0, total_time / si.min)
78+
pyplot.xlabel("t / min")
79+
pyplot.ylabel("$f_{ufz}$")
80+
pyplot.gca().set_box_aspect(1)
8181
if plot:
82-
pylab.show()
82+
pyplot.show()
8383

8484
# Assert
8585
np.testing.assert_array_less(

tests/unit_tests/physics/test_freezing_temperature_spectra.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring
22
import numpy as np
33
import pytest
4-
from matplotlib import pylab
4+
from matplotlib import pyplot
55

66
from PySDM import Formulae
77
from PySDM.physics import constants as const
@@ -24,18 +24,18 @@ def test_freezing_temperature_spectra(model, plot=False):
2424
cdf = formulae.freezing_temperature_spectrum.cdf(temperature, A)
2525

2626
# Plot
27-
pylab.plot(temperature, pdf, linestyle="-", marker="o", label="pdf")
28-
pdfax = pylab.gca()
27+
pyplot.plot(temperature, pdf, linestyle="-", marker="o", label="pdf")
28+
pdfax = pyplot.gca()
2929
cdfax = pdfax.twinx()
3030
cdfax.plot(temperature, cdf, linestyle="--", marker="x", label="cdf")
31-
pylab.xlabel("T [K]")
32-
pylab.xlim(np.amax(temperature), np.amin(temperature))
31+
pyplot.xlabel("T [K]")
32+
pyplot.xlim(np.amax(temperature), np.amin(temperature))
3333
pdfax.set_ylabel("pdf [K$^{-1}$]")
3434
cdfax.set_ylabel("cdf [1]")
35-
pylab.grid()
36-
pylab.title(model)
35+
pyplot.grid()
36+
pyplot.title(model)
3737
if plot:
38-
pylab.show()
38+
pyplot.show()
3939

4040
# Assert
4141
dT = abs(temperature[1] - temperature[0])

tests/unit_tests/physics/test_spectra_top_hat.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pylint: disable=missing-module-docstring,missing-class-docstring,missing-function-docstring
22
import numpy as np
3-
from matplotlib import pylab
3+
from matplotlib import pyplot
44

55
from PySDM.initialisation import spectra
66

@@ -19,14 +19,14 @@ def test_cumulative(plot=False):
1919

2020
# plot
2121
if plot:
22-
pylab.axhline(0)
23-
pylab.axhline(norm_factor)
24-
pylab.axvline(endpoints[0])
25-
pylab.axvline(endpoints[1])
26-
pylab.plot(x, y, color="red")
27-
pylab.xlim(x[0], x[-1])
28-
pylab.grid()
29-
pylab.show()
22+
pyplot.axhline(0)
23+
pyplot.axhline(norm_factor)
24+
pyplot.axvline(endpoints[0])
25+
pyplot.axvline(endpoints[1])
26+
pyplot.plot(x, y, color="red")
27+
pyplot.xlim(x[0], x[-1])
28+
pyplot.grid()
29+
pyplot.show()
3030

3131
# assert
3232
for point in y:
@@ -51,12 +51,12 @@ def test_percentiles(plot=False):
5151

5252
# plot
5353
if plot:
54-
pylab.axvline(0)
55-
pylab.axvline(1)
56-
pylab.axhline(spectrum.endpoints[0])
57-
pylab.axhline(spectrum.endpoints[1])
58-
pylab.plot(x, y, color="red")
59-
pylab.show()
54+
pyplot.axvline(0)
55+
pyplot.axvline(1)
56+
pyplot.axhline(spectrum.endpoints[0])
57+
pyplot.axhline(spectrum.endpoints[1])
58+
pyplot.plot(x, y, color="red")
59+
pyplot.show()
6060

6161
# assert
6262
assert y[0] == spectrum.endpoints[0]

0 commit comments

Comments
 (0)