Skip to content

Commit

Permalink
Update test module to note expected failures & link Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sadielbartholomew committed Jul 19, 2024
1 parent 5e99087 commit 7b2a1ea
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions cfplot/test/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,29 @@ def test_example_8(self):
cfp.con(f.collapse("mean", "longitude"), ylog=1)
compare_images(8)

@unittest.expectedFailure # works standalone, test suite gives IndexError
def test_example_9(self):
"""Test Example 9."""
# TODO SLB, flaky/bad test alert! This works in interactive Python
# but in test suite it fails with:
# Traceback (most recent call last):
# File "/home/slb93/git-repos/cf-plot/cfplot/test/test_examples.py", line 551, in test_example_9
# cfp.con(lat_mean)
# File "/home/slb93/git-repos/cf-plot/cfplot/cfplot.py", line 3262, in con
# f = f.subspace(Y=cf.wi(-90.0, plotvars.boundinglat))
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# File "/home/slb93/git-repos/cf-python/cf/subspacefield.py", line 353, in __call__
# raise error
# File "/home/slb93/git-repos/cf-python/cf/subspacefield.py", line 348, in __call__
# out = field[indices]
# ~~~~~^^^^^^^^^
# File "/home/slb93/git-repos/cf-python/cf/field.py", line 450, in __getitem__
# raise IndexError(
# IndexError: Indices [slice(None, None, None), slice(None, None, None),
# array([], dtype=int64), slice(None, None, None)] result in a
# subspaced shape of (1, 23, 0, 320), but can't create a subspace
#of Field that has a size 0 axis

cfp.setvars(file="fig9.png")
f = cf.read(f"{self.data_dir}/ggap.nc")[0]

Expand Down Expand Up @@ -632,6 +653,7 @@ def test_example_15(self):
)
compare_images(15)

@unittest.expectedFailure # errors due to cf-python Issue #797
def test_example_16(self):
"""Test Example 16."""
cfp.setvars(file="fig16.png")
Expand All @@ -646,6 +668,8 @@ def test_example_16(self):
g = g.subspace(X=cf.wi(80, 160))
g = g.collapse("T: mean X: mean")

# This fails due to a cf-python field bug, see cf-python Issue #797:
# https://github.com/NCAS-CMS/cf-python/issues/797
cfp.vect(
u=c,
v=-g,
Expand All @@ -655,7 +679,6 @@ def test_example_16(self):
key_location=[0.95, -0.05],
)

# TODO SLB, EXAMPLE IS BROKEN SO NO OUTPUT TO COMPARE TO
compare_images(16)

def test_example_17(self):
Expand Down Expand Up @@ -715,6 +738,7 @@ def test_example_19(self):
cfp.gclose()
compare_images(19)

@unittest.expectedFailure # works standalone, test suite gives ValueError
def test_example_20(self):
"""Test Example 20."""
cfp.setvars(file="fig20.png")
Expand All @@ -723,6 +747,7 @@ def test_example_20(self):
cfp.con(f.subspace[9])
compare_images(20)

@unittest.expectedFailure # works standalone, test suite gives ValueError
def test_example_21(self):
"""Test Example 21."""
cfp.setvars(file="fig21.png")
Expand All @@ -738,6 +763,7 @@ def test_example_21(self):
)
compare_images(21)

@unittest.expectedFailure # works standalone, test suite gives ValueError
def test_example_22(self):
"""Test Example 22."""
cfp.setvars(file="fig22.png")
Expand Down Expand Up @@ -773,10 +799,10 @@ def test_example_23(self):

compare_images(23)

@unittest.expectedFailure # IndexError after griddata API conformance
def test_example_24(self):
"""Test Example 24."""
cfp.setvars(file="fig24.png")
# SADIE GRID THREE HERE

# Arrays for data
lons = []
Expand Down Expand Up @@ -808,6 +834,7 @@ def test_example_24(self):
cfp.con(x=lons_new, y=lats_new, f=temp_new, ptype=1)
compare_images(24)

@unittest.expectedFailure # IndexError after griddata API conformance
def test_example_25(self):
"""Test Example 25."""
cfp.setvars(file="fig25.png")
Expand Down Expand Up @@ -855,6 +882,7 @@ def test_example_25(self):

compare_images(25)

@unittest.expectedFailure # ValueError after griddata API conformance
def test_example_26(self):
"""Test Example 26."""
cfp.setvars(file="fig26.png")
Expand All @@ -881,7 +909,7 @@ def test_example_26(self):

lons_new = np.arange(181 * 8) * 0.25 - 180.0
lats_new = np.arange(91 * 8) * 0.25 - 90.0
# TODO SLB needs fixing, fails on an IndexError
# TODO SLB needs fixing, fails on a ValueError
temp_new = griddata(
points=(lons, lats), values=temp, xi=(lons_new, lats_new),
method="linear"
Expand Down Expand Up @@ -980,6 +1008,7 @@ def test_example_30(self):
# TODO SLB missing example 30.
pass

@unittest.expectedFailure # errors due to 1 of 2 x bugs, see #59 and #60
def test_example_31(self):
"""Test Example 31."""
# TODO SLB this test errors
Expand Down

0 comments on commit 7b2a1ea

Please sign in to comment.