Skip to content

Commit

Permalink
245 fix testcases and notebooks after ridge and transform change (#246)
Browse files Browse the repository at this point in the history
* fix test_3_plottopologies.py

* fix 03-WorkingWithPoints.ipynb

* fix 07-WorkingWithPlateTectonicStats.ipynb

* remove data files which are created by notebook
  • Loading branch information
michaelchin authored Aug 5, 2024
1 parent c04cd25 commit 1567e6f
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 804 deletions.
22 changes: 11 additions & 11 deletions Notebooks/03-WorkingWithPoints.ipynb

Large diffs are not rendered by default.

48 changes: 14 additions & 34 deletions Notebooks/07-WorkingWithPlateTectonicStats.ipynb

Large diffs are not rendered by default.

252 changes: 0 additions & 252 deletions Notebooks/NotebookFiles/Merdith2021-PlateTectonicStats.csv

This file was deleted.

232 changes: 0 additions & 232 deletions Notebooks/NotebookFiles/Muller2016-PlateTectonicStats.csv

This file was deleted.

252 changes: 0 additions & 252 deletions Notebooks/NotebookFiles/Muller2019-PlateTectonicStats.csv

This file was deleted.

9 changes: 3 additions & 6 deletions gplately/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,12 @@ class PlotTopologies(object):
- pygplates.FeatureType.gpml_topological_slab_boundary
- pygplates.FeatureType.gpml_topological_closed_plate_boundary
ridge_transforms : iterable/list of <pygplates.Feature>
ridges : iterable/list of <pygplates.Feature>
A list containing ridge and transform boundary sections of type
pygplates.FeatureType.gpml_mid_ocean_ridge
ridges : iterable/list of <pygplates.Feature>
A list containing ridge boundary sections of type pygplates.FeatureType.gpml_mid_ocean_ridge
transforms : iterable/list of <pygplates.Feature>
A list containing transform boundary sections of type pygplates.FeatureType.gpml_mid_ocean_ridge
A list containing transform boundary sections of type pygplates.FeatureType.gpml_transforms
trenches : iterable/list of <pygplates.Feature>
A list containing trench boundary sections of type pygplates.FeatureType.gpml_subduction_zone
Expand Down Expand Up @@ -853,7 +850,7 @@ def plot_ridges(self, ax, color="black", **kwargs):
Notes
-----
The ridges sections for plotting are accessed from the
The `ridges` sections for plotting are accessed from the
`PlotTopologies` object's `ridges` attribute. These `ridges`
are reconstructed to the `time` passed to the `PlotTopologies` object and converted
into Shapely polylines. The reconstructed `ridges` are plotted onto the
Expand Down
104 changes: 87 additions & 17 deletions tests-dir/pytestcases/test_3_plottopologies.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest
import matplotlib.pyplot as plt
import numpy as np
from conftest import reconstruction_times
import pytest
from conftest import gplately_plot_topologies_object as gplot
from conftest import reconstruction_times

# ========================================= <gplately.PlotTopologies> =========================================

Expand Down Expand Up @@ -47,55 +47,124 @@
- plot_plate_motion_vectors
"""


# CALL THE PLOT TOPOLOGIES OBJECT
@pytest.mark.parametrize("time", reconstruction_times)
def test_gplately_plotTopologies_object(time, gplot):
#assert gplot, "No <gplately.PlotTopologies> object made with {}.".format(model)
assert gplot, "Unable to create a <gplately.PlotTopologies> object with Müller et al. (2019) at {} Ma.".format(time)
# assert gplot, "No <gplately.PlotTopologies> object made with {}.".format(model)
assert (
gplot
), "Unable to create a <gplately.PlotTopologies> object with Müller et al. (2019) at {} Ma.".format(
time
)


# ================================================================================================================================================================================================================


# ENSURE PLOT TOPOLOGIES' ATTRIBUTES EXIST AND ARE CORRECT
# Topologies
@pytest.mark.parametrize("time", reconstruction_times)
def test_PlotTopologies_topologies(time, gplot):
assert gplot.topologies, "No topological features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(time)
assert (
gplot.topologies
), "No topological features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(
time
)


# Ridge_transforms
@pytest.mark.parametrize("time", reconstruction_times)
def test_PlotTopologies_ridge_transforms(time, gplot):
assert gplot.ridge_transforms, "No ridge/transform features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(time)
assert [ridge_transform.get_feature_type() == "gpml:MidOceanRidge" for ridge_transform in gplot.ridge_transforms], "<gplately.PlotTopologies> ridge/transforms are not all of type gpml:MidOceanRidge in Müller et al. (2019) at {} Ma.".format(time)
assert (
gplot.ridges
), "No ridge/transform features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(
time
)
assert [
ridge_transform.get_feature_type() == "gpml:MidOceanRidge"
for ridge_transform in gplot.ridges
], "<gplately.PlotTopologies> ridge/transforms are not all of type gpml:MidOceanRidge in Müller et al. (2019) at {} Ma.".format(
time
)


# Ridges
@pytest.mark.parametrize("time", reconstruction_times)
def test_PlotTopologies_ridges(time, gplot):
assert gplot.ridges, "No ridge features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(time)
assert [ridge.get_feature_type() == "gpml:MidOceanRidge" for ridge in gplot.ridges], "<gplately.PlotTopologies> ridges are not all of type gpml:MidOceanRidge in Müller et al. (2019) at {} Ma.".format(time)
assert (
gplot.ridges
), "No ridge features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(
time
)
assert [
ridge.get_feature_type() == "gpml:MidOceanRidge" for ridge in gplot.ridges
], "<gplately.PlotTopologies> ridges are not all of type gpml:MidOceanRidge in Müller et al. (2019) at {} Ma.".format(
time
)


# Transforms
@pytest.mark.parametrize("time", reconstruction_times)
def test_PlotTopologies_transforms(time, gplot):
assert gplot.transforms, "No transform features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(time)
assert [transform.get_feature_type() == "gpml:MidOceanRidge" for transform in gplot.transforms], "<gplately.PlotTopologies> transforms are not all of type gpml:MidOceanRidge in Müller et al. (2019) at {} Ma.".format(time)
assert (
gplot.transforms
), "No transform features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(
time
)
assert [
transform.get_feature_type() == "gpml:MidOceanRidge"
for transform in gplot.transforms
], "<gplately.PlotTopologies> transforms are not all of type gpml:MidOceanRidge in Müller et al. (2019) at {} Ma.".format(
time
)


# Trenches
@pytest.mark.parametrize("time", reconstruction_times)
def test_PlotTopologies_trenches(time, gplot):
assert gplot.trenches, "No trench features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(time)
assert [trench.get_feature_type() == "gpml:SubductionZone" for trench in gplot.trenches], "<gplately.PlotTopologies> trenches are not all of type gpml:SubductionZone in Müller et al. (2019) at {} Ma.".format(time)
assert (
gplot.trenches
), "No trench features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(
time
)
assert [
trench.get_feature_type() == "gpml:SubductionZone" for trench in gplot.trenches
], "<gplately.PlotTopologies> trenches are not all of type gpml:SubductionZone in Müller et al. (2019) at {} Ma.".format(
time
)


# Trench_left
@pytest.mark.parametrize("time", reconstruction_times)
def test_PlotTopologies_trench_L(time, gplot):
assert gplot.trench_left, "No trench (L) features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(time)
assert [trench_l.get_feature_type() == "gpml:SubductionZone" for trench_l in gplot.trench_left], "<gplately.PlotTopologies> trenches (L) are not all of type gpml:SubductionZone in Müller et al. (2019) at {} Ma.".format(time)
assert (
gplot.trench_left
), "No trench (L) features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(
time
)
assert [
trench_l.get_feature_type() == "gpml:SubductionZone"
for trench_l in gplot.trench_left
], "<gplately.PlotTopologies> trenches (L) are not all of type gpml:SubductionZone in Müller et al. (2019) at {} Ma.".format(
time
)


# Trench_right
@pytest.mark.parametrize("time", reconstruction_times)
def test_PlotTopologies_trench_R(time, gplot):
assert gplot.trench_right, "No trench (R) features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(time)
assert [trench_r.get_feature_type() == "gpml:SubductionZone" for trench_r in gplot.trench_right], "<gplately.PlotTopologies> trenches (R) are not all of type gpml:SubductionZone in Müller et al. (2019) at {} Ma.".format(time)
assert (
gplot.trench_right
), "No trench (R) features from Müller et al. (2019) at {} Ma are attributed to <gplately.PlotTopologies>.".format(
time
)
assert [
trench_r.get_feature_type() == "gpml:SubductionZone"
for trench_r in gplot.trench_right
], "<gplately.PlotTopologies> trenches (R) are not all of type gpml:SubductionZone in Müller et al. (2019) at {} Ma.".format(
time
)


# Subduction teeth
Expand All @@ -108,5 +177,6 @@ def test_PlotTopologies_subduction_teeth(gplot):

def test_pickle_Points():
import pickle

gplot_dump = pickle.dumps(gplot)
gplot_load = pickle.loads(gplot_dump)

0 comments on commit 1567e6f

Please sign in to comment.