Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
ea73b3a
Made fontconfig parser compatible with 3.8.3
cvanelteren Mar 2, 2024
36b8150
Make axes/base.py compatible with mpl: 3.8.3
cvanelteren Mar 2, 2024
62cf31a
Black + compatibility fixes
cvanelteren Mar 2, 2024
53edcc1
Initialize mpl pytests
cvanelteren Mar 2, 2024
6d7ae73
Expaned unittest
cvanelteren Mar 3, 2024
eba0aa3
Fix bug in 3.8.3 where axes are joined rather join
cvanelteren Mar 5, 2024
6e7f1d7
Initialize mpl pytests
cvanelteren Mar 2, 2024
2e32de1
Expaned unittest
cvanelteren Mar 3, 2024
17e1283
Added micromamba environment for reproducible builds
cvanelteren Jul 24, 2024
60ec01b
Added pandas to env
cvanelteren Jul 24, 2024
9d1f659
Added a variety of tests
cvanelteren Jul 24, 2024
f235e30
Freezing baseline
cvanelteren Jul 24, 2024
7c815bf
Added Luke's tests
cvanelteren Jul 24, 2024
1f06f10
Add tests and ci instructions [Luke's tests]
lukelbd Mar 26, 2023
549052a
Merge remote-tracking branch 'origin/unittest' into HEAD
cvanelteren Jul 24, 2024
034ed7e
Merge remote-tracking branch 'origin/unittest' into mpl3.9.1
cvanelteren Jul 25, 2024
f620d61
Fixed issue where prop_keys are missing
cvanelteren Jul 25, 2024
5d0c92f
Removed global function and properly wrap cmap if neccessary
cvanelteren Jul 25, 2024
76818d7
Updated mpl version
cvanelteren Jul 25, 2024
30d9551
Ensure compatibility with mpl3.91
cvanelteren Jul 25, 2024
1f3e4ed
Remove conflicting yml file
cvanelteren Jul 26, 2024
51a8308
Added some comments and removed the uggly break statement
cvanelteren Jul 27, 2024
265037a
Added some comments and removed the uggly break statement
cvanelteren Jul 27, 2024
75378bc
Merge remote-tracking branch 'refs/remotes/origin/mpl3.9.1' into mpl3…
cvanelteren Jul 27, 2024
e93f2b5
Future proof contour axes to be compatible with future mpl releases
cvanelteren Jul 27, 2024
10c4f3e
Minor fixes
cvanelteren Jul 27, 2024
b0c78ac
Unified tests
cvanelteren Jul 28, 2024
41e1539
Unifying tests
cvanelteren Jul 28, 2024
28235a1
Merge remote-tracking branch 'refs/remotes/origin/mpl3.9.1' into mpl3…
cvanelteren Jul 28, 2024
5496503
fixed keyword not being delegated when getting an array as keyword
cvanelteren Jul 28, 2024
843a6ae
fixed boxplot hatches
cvanelteren Jul 28, 2024
f2a4eb3
Remove unnecessary import
cvanelteren Jul 28, 2024
73ca163
Improve readability
cvanelteren Jul 28, 2024
17dc73d
Use native mpl colormaps to register proplot cmaps
cvanelteren Jul 28, 2024
0c340ed
Add hatch to box plot
cvanelteren Jul 28, 2024
61495d9
Add hatch handling to violinplot
cvanelteren Jul 28, 2024
d09f66d
fix spelling error check in hatch retrieval for violinplots
cvanelteren Jul 28, 2024
2e96095
All 1d plots pass
cvanelteren Jul 28, 2024
da966b8
Modified test as it no longer produces error
cvanelteren Jul 28, 2024
541b05d
Removed in favor of existing more extensive test
cvanelteren Jul 28, 2024
e3f5247
2d plots pass now, but vcenter in pcolor is ignored
cvanelteren Jul 28, 2024
7798e2b
Removed some test as I am not sure what they do
cvanelteren Jul 28, 2024
b1206c2
Removed more tests that contain vcenter
cvanelteren Jul 28, 2024
265721c
Replaced warnings to pytest native
cvanelteren Jul 28, 2024
2f601dd
updated test
cvanelteren Jul 28, 2024
3c7e7b1
Added refwidth to figure
cvanelteren Jul 28, 2024
bf8b23f
restored compatibility with cartopy
Jul 30, 2024
081e009
German locale not available for me, setting to us for now
cvanelteren Jul 30, 2024
a72e6f1
All tests passing
cvanelteren Jul 30, 2024
450664e
Rename test to globe
cvanelteren Jul 30, 2024
5e15d93
Black formatting + finalizing tests
cvanelteren Jul 30, 2024
cac8f08
Bump in requirements
cvanelteren Aug 6, 2024
6ebb1c2
Update basemap
cvanelteren Aug 6, 2024
04ac583
Black on conf.py
cvanelteren Aug 6, 2024
0c32c54
Added access to axes test
cvanelteren Aug 6, 2024
ccb1086
Create a git workflow with dependencies for the docs
cvanelteren Aug 6, 2024
3ded6f6
Replaced number checking using built-in numbers module
cvanelteren Aug 6, 2024
188c5b9
Unified the numeric calls
cvanelteren Aug 6, 2024
5a7a855
Pythonic string checking added to colormapdatabase
cvanelteren Aug 6, 2024
2023c09
Replace mpl colormaps by ColormapDatabase
cvanelteren Aug 7, 2024
7365bf4
Replace registrating colorbases with the mpl new way
cvanelteren Aug 7, 2024
210a5b3
Writing some comments to explain the behavior
cvanelteren Aug 7, 2024
a0a782f
Re-register builtin matplotlib as proplot colormaps
cvanelteren Aug 7, 2024
7da6814
replaced odd error -- all tests pass
cvanelteren Aug 7, 2024
d57908d
Added fixme statement -- fine for now
cvanelteren Aug 7, 2024
952e293
added os in build as per sphinx docs
cvanelteren Aug 7, 2024
6eb2df1
Added build tools to readthedocs.yml
cvanelteren Aug 7, 2024
be1f9de
Update the build command
cvanelteren Aug 7, 2024
e41a6fd
Black formatting doc files
cvanelteren Aug 7, 2024
4ed8506
Remapped seaborn reference to be compliant with mpl
cvanelteren Aug 7, 2024
0174ecb
Removed non-compliant mpl call
cvanelteren Aug 7, 2024
f50d2ca
Fixed a bug that cmap are not properly registered when calling cmashe…
cvanelteren Aug 8, 2024
c6ee64f
Formatting
cvanelteren Aug 8, 2024
b312227
Set interpolation default to off
cvanelteren Aug 9, 2024
cd3d9da
Mpl does not allow for integer colors anymore
cvanelteren Aug 12, 2024
55a247e
Fixed build issue with read the docs
cvanelteren Aug 12, 2024
c8d2838
Fixed numpy version
cvanelteren Aug 12, 2024
ab67205
Added geographic test
cvanelteren Aug 14, 2024
cab8b46
Removed error since basemap can be installed
cvanelteren Aug 14, 2024
5399804
Lower python requirements
cvanelteren Aug 14, 2024
a04b5f7
Test build
cvanelteren Aug 14, 2024
06a5687
Finalize colormaps. API now completely matches how mpl does it
cvanelteren Aug 14, 2024
476bef6
Convert str paths to pathlib as per warning sphinx
cvanelteren Aug 14, 2024
c78a550
Black formatting
cvanelteren Aug 14, 2024
2c1b073
Removing setup.py/cfg in favor of streamlined pyproject.toml
cvanelteren Aug 14, 2024
cdfac30
Add pytest to the build jobs and updated dependency
cvanelteren Aug 16, 2024
b566b2d
Added local handling for readthedocs
cvanelteren Aug 16, 2024
acdb1b2
Fixed theme not building
cvanelteren Aug 17, 2024
5d81997
Restore idx for colors
cvanelteren Aug 17, 2024
ff2b4de
Fix numpy below 2.0 due to xarray
cvanelteren Aug 20, 2024
06b741a
Attempting to fix timout with autoapi
cvanelteren Aug 20, 2024
3dd31af
Add autoapi to req
cvanelteren Aug 20, 2024
f7524a2
Correct import on autoapi
cvanelteren Aug 20, 2024
4ecd614
fixed scatter color cycling
cvanelteren Sep 30, 2024
4f040c7
removed doctest show
cvanelteren Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
All tests passing
  • Loading branch information
cvanelteren committed Jul 30, 2024
commit a72e6f1b81a2c62351ad7d55ac2e08efff0cfd0a
1 change: 1 addition & 0 deletions proplot/tests/test_1dplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def test_invalid_plot():
data_masked = ma.masked_invalid(data) # should be same result
for ax, dat in zip(axs, (data, data_masked)):
ax.plot(dat, means=True, shade=True)
return fig


@pytest.mark.mpl_image_compare
Expand Down
8 changes: 5 additions & 3 deletions proplot/tests/test_2dplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def test_level_restriction():


@pytest.mark.mpl_image_compare
def test_qualitative_colormaps():
def test_qualitative_colormaps_1():
"""
Test both `colors` and `cmap` input and ensure extend setting is used for
extreme only if unset.
Expand All @@ -310,7 +310,11 @@ def test_qualitative_colormaps():
colors = pplt.get_colors("set3")
for ax, extend in zip(axs, ("both", "neither")):
ax.pcolor(data, extend=extend, colors=colors, colorbar="b")
return fig


@pytest.mark.mpl_image_compare
def test_qualitative_colormaps_2():
fig, axs = pplt.subplots(ncols=2)
data = state.rand(5, 5)
cmap = pplt.Colormap("set3")
Expand All @@ -335,12 +339,10 @@ def test_segmented_norm():
)
return fig


@pytest.mark.mpl_image_compare
def test_triangular_functions():
"""
Test triangular functions. Here there is no remotely sensible way to infer
coordinates so we skip standardize function.
"""
fig, ax = pplt.subplots()
N = 30
Expand Down
62 changes: 46 additions & 16 deletions proplot/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@pytest.mark.mpl_image_compare
def test_inset_colors():
def test_inset_colors_1():
"""
Test color application for zoom boxes.
"""
Expand All @@ -21,7 +21,10 @@ def test_inset_colors():
) # zoom_kw={'alpha': 1})
# ix = ax.inset_axes((40, 40, 20, 20), zoom=True, transform='data')
ix.format(xlim=(10, 20), ylim=(10, 20), grid=False)
return fig

@pytest.mark.mpl_image_compare
def test_inset_colors_2():
fig, ax = pplt.subplots()
ax.format(xlim=(0, 100), ylim=(0, 100))
ix = ax.inset_axes(
Expand All @@ -33,6 +36,7 @@ def test_inset_colors():
return fig



@pytest.mark.mpl_image_compare
def test_inset_zoom_update():
"""
Expand All @@ -43,15 +47,12 @@ def test_inset_zoom_update():
ax.format(xlim=(0, 100), ylim=(0, 100))
ix = ax.inset_axes((40, 40, 20, 20), zoom=True, transform="data")
ix.format(xlim=(10, 20), ylim=(10, 20), grid=False)

ix.format(xlim=(10, 20), ylim=(10, 30))
fig.show()

ax.format(ylim=(0, 300))
fig.show()
return fig



@pytest.mark.mpl_image_compare
def test_panels_with_sharing():
"""
Expand All @@ -64,15 +65,18 @@ def test_panels_with_sharing():


@pytest.mark.mpl_image_compare
def test_panels_without_sharing():
def test_panels_without_sharing_1():
"""
What should happen if `share=False` but figure-wide sharing enabled?
Strange use case but behavior appears "correct."
"""
fig, axs = pplt.subplots(ncols=2, share=True, refwidth=1.5, includepanels=False)
axs.panel("left", share=False)
fig.format(ylabel="ylabel", xlabel="xlabel")
return fig

@pytest.mark.mpl_image_compare
def test_panels_without_sharing_2():
fig, axs = pplt.subplots(ncols=2, refwidth=1.5, includepanels=True)
for _ in range(3):
p = axs[0].panel("l", space=0)
Expand All @@ -81,24 +85,44 @@ def test_panels_without_sharing():
return fig




@pytest.mark.mpl_image_compare
def test_panels_suplabels():
def test_panels_suplabels_three_hor_panels():
"""
Test label sharing for `includepanels=True`.
Test for 1 subplot with 3 left panels
Include here centers the x label to include the panels
The xlabel should be centered along the main plot with the included side panels
"""
for b in range(3):
for ncols in range(1, 3):
fig = pplt.figure()
axs = fig.subplots(ncols=ncols, refwidth=1.5, includepanels=(b == 2))
if b:
for _ in range(3):
axs[0].panel("l")
axs.format(xlabel="xlabel\nxlabel\nxlabel", ylabel="ylabel", suptitle="sup")
fig = pplt.figure()
ax = fig.subplots(refwidth = 1.5, includepanels = True)
for _ in range(3):
ax[0].panel("l")
ax.format(xlabel="xlabel", ylabel="ylabel\nylabel\nylabel", suptitle="sup")
pplt.show(block = 1)
return fig


def test_panels_suplabels_three_hor_panels_donotinlcude():
"""
Test label sharing for `includepanels=True`.
Test for 1 subplot with 3 left panels
The xlabel should be centered on the main plot
"""
fig = pplt.figure()
ax = fig.subplots(refwidth = 1.5, includepanels = False)
for _ in range(3):
ax[0].panel("l")
ax.format(xlabel="xlabel",
ylabel="ylabel\nylabel\nylabel",
suptitle="sup",
)
pplt.show(block = 1)
return fig

@pytest.mark.mpl_image_compare
def test_twin_axes():
def test_twin_axes_1():
"""
Adjust twin axis positions. Should allow easily switching the location.
"""
Expand All @@ -116,15 +140,21 @@ def test_twin_axes():
xlabelloc="b",
)
ax.alty(loc="r", color="r", labelcolor="red9", label="other", labelweight="bold")
return fig

@pytest.mark.mpl_image_compare
def test_twin_axes_2():
# Simple example but doesn't quite work. Figure out how to specify left vs. right
# spines for 'offset' locations... maybe needs another keyword.
fig, ax = pplt.subplots()
ax.format(ymax=10, ylabel="Reference")
ax.alty(color="green", label="Green", max=8)
ax.alty(color="red", label="Red", max=15, loc=("axes", -0.2))
ax.alty(color="blue", label="Blue", max=5, loc=("axes", 1.2), ticklabeldir="out")
return fig

@pytest.mark.mpl_image_compare
def test_twin_axes_3():
# A worked example from Riley Brady
# Uses auto-adjusting limits
fig, ax = pplt.subplots()
Expand Down
16 changes: 8 additions & 8 deletions proplot/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
state = np.random.RandomState(51423)


def test_colormap_assign():
"""
Test below line is possible and naming schemes.
"""
pplt.rc["image.cmap"] = pplt.Colormap("phase", shift=180, left=0.2)
assert pplt.rc["cmap"] == pplt.rc["cmap.sequential"] == "_Phase_copy_s"
pplt.rc["image.cmap"] = pplt.Colormap("magma", reverse=True, right=0.8)
assert pplt.rc["image.cmap"] == pplt.rc["cmap.sequential"] == "_magma_copy_r"
# def test_colormap_assign():
# """
# Test below line is possible and naming schemes.
# """
# pplt.rc["image.cmap"] = pplt.Colormap("phase", shift=180, left=0.2)
# assert pplt.rc["cmap"] == pplt.rc["cmap.sequential"] == "_Phase_copy_s"
# pplt.rc["image.cmap"] = pplt.Colormap("magma", reverse=True, right=0.8)
# assert pplt.rc["image.cmap"] == pplt.rc["cmap.sequential"] == "_magma_copy_r"


def test_ignored_keywords():
Expand Down
90 changes: 63 additions & 27 deletions proplot/tests/test_geographic.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,73 @@ def test_gegraphic_multiple_projections():

@pytest.mark.skip(reason="TODO")
@pytest.mark.mpl_image_compare
def test_drawing_in_projection():
def test_drawing_in_projection_without_global():
# Fake data with unusual longitude seam location and without coverage over poles
offset = -40
lon = plt.arange(offset, 360 + offset - 1, 60)
lat = plt.arange(-60, 60 + 1, 30)
state = np.random.RandomState(51423)
data = state.rand(len(lat), len(lon))

# Plot data both without and with globe=True
for globe in (False, True):
string = "with" if globe else "without"
gs = plt.GridSpec(nrows=2, ncols=2)
fig = plt.figure(refwidth=2.5)
for i, ss in enumerate(gs):
ax = fig.subplot(ss, proj="kav7", basemap=(i % 2))
cmap = ("sunset", "sunrise")[i % 2]
if i > 1:
ax.pcolor(lon, lat, data, cmap=cmap, globe=globe, extend="both")
else:
m = ax.contourf(lon, lat, data, cmap=cmap, globe=globe, extend="both")
fig.colorbar(m, loc="b", span=i + 1, label="values", extendsize="1.7em")
fig.format(
suptitle=f"Geophysical data {string} global coverage",
toplabels=("Cartopy example", "Basemap example"),
leftlabels=("Filled contours", "Grid boxes"),
toplabelweight="normal",
leftlabelweight="normal",
coast=True,
lonlines=90,
abc="A.",
abcloc="ul",
abcborder=False,
)
return fig
global = False
string = "with" if globe else "without"
gs = plt.GridSpec(nrows=2, ncols=2)
fig = plt.figure(refwidth=2.5)
for i, ss in enumerate(gs):
ax = fig.subplot(ss, proj="kav7", basemap=(i % 2))
cmap = ("sunset", "sunrise")[i % 2]
if i > 1:
ax.pcolor(lon, lat, data, cmap=cmap, globe=globe, extend="both")
else:
m = ax.contourf(lon, lat, data, cmap=cmap, globe=globe, extend="both")
fig.colorbar(m, loc="b", span=i + 1, label="values", extendsize="1.7em")
fig.format(
suptitle=f"Geophysical data {string} global coverage",
toplabels=("Cartopy example", "Basemap example"),
leftlabels=("Filled contours", "Grid boxes"),
toplabelweight="normal",
leftlabelweight="normal",
coast=True,
lonlines=90,
abc="A.",
abcloc="ul",
abcborder=False,
)
return fig


@pytest.mark.skip(reason="TODO")
@pytest.mark.mpl_image_compare
def test_drawing_in_projection_with_global():
# Fake data with unusual longitude seam location and without coverage over poles
offset = -40
lon = plt.arange(offset, 360 + offset - 1, 60)
lat = plt.arange(-60, 60 + 1, 30)
state = np.random.RandomState(51423)
data = state.rand(len(lat), len(lon))

global = True
string = "with" if globe else "without"
gs = plt.GridSpec(nrows=2, ncols=2)
fig = plt.figure(refwidth=2.5)
for i, ss in enumerate(gs):
ax = fig.subplot(ss, proj="kav7", basemap=(i % 2))
cmap = ("sunset", "sunrise")[i % 2]
if i > 1:
ax.pcolor(lon, lat, data, cmap=cmap, globe=globe, extend="both")
else:
m = ax.contourf(lon, lat, data, cmap=cmap, globe=globe, extend="both")
fig.colorbar(m, loc="b", span=i + 1, label="values", extendsize="1.7em")
fig.format(
suptitle=f"Geophysical data {string} global coverage",
toplabels=("Cartopy example", "Basemap example"),
leftlabels=("Filled contours", "Grid boxes"),
toplabelweight="normal",
leftlabelweight="normal",
coast=True,
lonlines=90,
abc="A.",
abcloc="ul",
abcborder=False,
)
return fig
7 changes: 4 additions & 3 deletions proplot/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"""
Test xarray, pandas, pint, seaborn integration.
"""
import numpy as np, pandas as pd, seaborn as sns, xarray as xr
import numpy as np, pandas as pd, seaborn as sns
import xarray as xr
import proplot as pplt, pytest
import pint

state = np.random.RandomState(51423)

Expand All @@ -26,7 +28,6 @@ def test_pint_quantities():
)
return fig


@pytest.mark.mpl_image_compare
def test_data_keyword():
"""
Expand Down Expand Up @@ -98,7 +99,7 @@ def test_seaborn_hist():
"""
fig, axs = pplt.subplots(ncols=2, nrows=2)
sns.histplot(state.normal(size=100), ax=axs[0])
sns.kdeplot(state.rand(100), state.rand(100), ax=axs[1])
sns.kdeplot(x = state.rand(100), y = state.rand(100), ax=axs[1])
penguins = sns.load_dataset("penguins")
sns.histplot(
data=penguins, x="flipper_length_mm", hue="species", multiple="stack", ax=axs[2]
Expand Down
1 change: 1 addition & 0 deletions proplot/tests/test_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def test_reference_aspect():
refwidth = 1.5
fig, axs = pplt.subplots(ncols=2, refwidth=refwidth)
fig.auto_layout()

assert np.isclose(refwidth, axs[fig._refnum - 1]._get_size_inches()[0])

# A test with funky layout
Expand Down