-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new ax feature #109
Add new ax feature #109
Changes from all commits
c8d673a
ebe0451
6901b63
4fbb76f
a138df7
e6529a1
b486996
5f2353d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,36 +1,44 @@ | ||||
"""Test transect.""" | ||||
|
||||
import cmcrameri | ||||
import pytest | ||||
import matplotlib as mpl | ||||
import matplotlib.pyplot as plt | ||||
from pathlib import Path | ||||
from gliderpy.plotting import plot_track | ||||
from gliderpy.plotting import plot_transect | ||||
from gliderpy.plotting import plot_track, plot_transect | ||||
from gliderpy.fetchers import GliderDataFetcher | ||||
|
||||
root = Path(__file__).parent | ||||
|
||||
@pytest.mark.mpl_image_compare(baseline_dir=root.joinpath("baseline/")) | ||||
def test_plot_track(): | ||||
@pytest.fixture | ||||
def glider_data(): | ||||
glider_grab = GliderDataFetcher() | ||||
|
||||
glider_grab.fetcher.dataset_id = "whoi_406-20160902T1700" | ||||
df = glider_grab.to_pandas() | ||||
# Generate the plot | ||||
fig, ax = plot_track(df) | ||||
return df | ||||
|
||||
@pytest.mark.mpl_image_compare(baseline_dir=root.joinpath("baseline/")) | ||||
def test_plot_track(glider_data): | ||||
# Generate the plot | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
fig, ax = plot_track(glider_data) | ||||
# Return the figure for pytest-mpl to compare | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
return fig | ||||
|
||||
|
||||
|
||||
@pytest.mark.mpl_image_compare(baseline_dir=root.joinpath("baseline/")) | ||||
def test_plot_transect(): | ||||
glider_grab = GliderDataFetcher() | ||||
|
||||
glider_grab.fetcher.dataset_id = "whoi_406-20160902T1700" | ||||
df = glider_grab.to_pandas() | ||||
def test_plot_transect(glider_data): | ||||
# Generate the plot | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
fig, ax = plot_transect(df, 'temperature') | ||||
fig, ax = plot_transect(glider_data, 'temperature') | ||||
# Return the figure for pytest-mpl to compare | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
return fig | ||||
|
||||
@pytest.mark.mpl_image_compare(baseline_dir=root.joinpath("baseline/")) | ||||
def test_plot_transect_multiple_figures(glider_data): | ||||
# Generate the plot with multiple figures | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
fig, (ax0, ax1) = plt.subplots(figsize=(15, 9), nrows=2, sharex=True, sharey=True) | ||||
glider_data.plot_transect(var="temperature", ax=ax0) | ||||
glider_data.plot_transect(var="salinity", ax=ax1, cmap=cmcrameri.cm.davos) | ||||
# Return the figure for pytest-mpl to compare | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
return fig | ||||
|
||||
def test_plot_transect_size(glider_data): | ||||
# Generate the plot with a specific size | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
fig, ax = plt.subplots(figsize=(15, 9)) | ||||
glider_data.plot_transect(var="temperature", ax=ax) | ||||
assert fig.get_size_inches() == pytest.approx([15., 9.]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏽