Skip to content

Commit

Permalink
[FIX] Adjusted labels check with the use of utilities functions
Browse files Browse the repository at this point in the history
This is just in case we change the labels in the utilities functions, then we do not get into troubles with the tests and do not have to change it here too
  • Loading branch information
MOchiara authored Dec 17, 2024
1 parent 1b4e750 commit f313ee8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_plots(start_prof=0, end_prof=100):
ds = ds.drop_vars(['DENSITY'])
fig, ax = plots.plot_basic_vars(ds, start_prof=start_prof, end_prof=end_prof)
assert ax[0].get_ylabel() == 'Depth (m)'
assert ax[0].get_xlabel() == 'Temperature \n(°C)'
assert ax[0].get_xlabel() == f'{utilities.plotting_labels("TEMP")} \n({utilities.plotting_units(ds,"TEMP")})'


def test_up_down_bias(v_res=1):
Expand All @@ -24,20 +24,20 @@ def test_up_down_bias(v_res=1):
lims = np.abs(df.dc)
assert ax.get_xlim() == (-np.nanpercentile(lims, 99.5), np.nanpercentile(lims, 99.5))
assert ax.get_ylim() == (df.depth.max() + 1, -df.depth.max() / 30)
assert ax.get_xlabel() == 'Practical salinity (PSU)'
assert ax.get_xlabel() == f'{utilities.plotting_labels("PSAL")} ({utilities.plotting_units(ds,"PSAL")})'
# check without passing axis
new_fig, new_ax = plots.plot_updown_bias(ds, var='PSAL', v_res=1)
assert new_ax.get_xlim() == (-np.nanpercentile(lims, 99.5), np.nanpercentile(lims, 99.5))
assert new_ax.get_ylim() == (df.depth.max() + 1, -df.depth.max() / 30)
assert new_ax.get_xlabel() == 'Practical salinity (PSU)'
assert new_ax.get_xlabel() == f'{utilities.plotting_labels("PSAL")} ({utilities.plotting_units(ds,"PSAL")})'


def test_chl(var1='CHLA', var2='BBP700'):
ds = fetchers.load_sample_dataset()
ax = plots.process_optics_assess(ds, var=var1)
assert ax.get_ylabel() == 'Chlorophyll (mg m⁻³)'
assert ax.get_ylabel() == f'{utilities.plotting_labels(var1)} ({utilities.plotting_units(ds,var1)})'
ax = plots.process_optics_assess(ds, var=var2)
assert ax.get_ylabel() == 'Red backscatter, b${bp}$(700) (m⁻¹)'
assert ax.get_ylabel() == f'{utilities.plotting_labels(var2)} ({utilities.plotting_units(ds,var2)})'
with pytest.raises(KeyError) as e:
plots.process_optics_assess(ds, var='nonexistent_variable')

Expand All @@ -53,7 +53,7 @@ def test_quench_sequence(ylim=45):

fig, ax = plots.plot_daynight_avg(ds, var='TEMP')
assert ax.get_ylabel() == 'Depth (m)'
assert ax.get_xlabel() == 'Temperature (°C)'
assert ax.get_xlabel() == f'{utilities.plotting_labels("TEMP")} ({utilities.plotting_units(ds,"TEMP")})'


def test_temporal_drift(var='DOXY'):
Expand Down Expand Up @@ -128,4 +128,4 @@ def test_plot_sampling_period_all():

def test_plot_max_depth():
ds = fetchers.load_sample_dataset()
plots.plot_max_depth_per_profile(ds)
plots.plot_max_depth_per_profile(ds)

0 comments on commit f313ee8

Please sign in to comment.