apsg 2.0.1__tar.gz → 2.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {apsg-2.0.1/src/apsg.egg-info → apsg-2.0.2}/PKG-INFO +2 -1
- {apsg-2.0.1 → apsg-2.0.2}/pyproject.toml +8 -1
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/__init__.py +1 -1
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/feature/_container.py +36 -6
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_plot_artists.py +2 -2
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_roseplot.py +7 -1
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_stereonet.py +31 -14
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_styles.py +1 -1
- {apsg-2.0.1 → apsg-2.0.2/src/apsg.egg-info}/PKG-INFO +2 -1
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg.egg-info/requires.txt +1 -0
- {apsg-2.0.1 → apsg-2.0.2}/tests/test_containers.py +35 -0
- {apsg-2.0.1 → apsg-2.0.2}/tests/test_plotting.py +132 -27
- {apsg-2.0.1 → apsg-2.0.2}/LICENSE +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/README.md +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/setup.cfg +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/config.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/database/__init__.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/database/_sdbmodels.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/database/_sdbsession.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/database/_websdbsession.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/database/_webtransport.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/feature/__init__.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/feature/_geodata.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/feature/_paleomag.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/feature/_statistics.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/feature/_tensor2.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/feature/_tensor3.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/helpers/__init__.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/helpers/_helper.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/helpers/_math.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/helpers/_notation.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/math/__init__.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/math/_matrix.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/math/_vector.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/pandas/__init__.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/pandas/_accessors.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/pandas/_gbfunctions.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/pandas/_pandas_api.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/__init__.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_fabricplot.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_paleomagplots.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_stereo_engine/__init__.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_stereo_engine/_axes.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_stereo_engine/_stereogrid.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_stereo_engine/_transforms.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_stereo_engine/_utils.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/plotting/_stereogrid.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg/shell.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg.egg-info/SOURCES.txt +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg.egg-info/dependency_links.txt +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg.egg-info/entry_points.txt +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/src/apsg.egg-info/top_level.txt +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/tests/test_apsg.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/tests/test_pandas.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/tests/test_tensors.py +0 -0
- {apsg-2.0.1 → apsg-2.0.2}/tests/test_websdb.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apsg
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: APSG - The package for structural geologists
|
|
5
5
|
Author-email: Ondrej Lexa <lexa.ondrej@gmail.com>
|
|
6
6
|
Maintainer-email: Ondrej Lexa <lexa.ondrej@gmail.com>
|
|
@@ -29,6 +29,7 @@ Requires-Dist: jupyterlab; extra == "lab"
|
|
|
29
29
|
Provides-Extra: tests
|
|
30
30
|
Requires-Dist: pytest; extra == "tests"
|
|
31
31
|
Requires-Dist: pytest-cov; extra == "tests"
|
|
32
|
+
Requires-Dist: pytest-xdist; extra == "tests"
|
|
32
33
|
Provides-Extra: docs
|
|
33
34
|
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
34
35
|
Requires-Dist: shibuya; extra == "docs"
|
|
@@ -19,7 +19,7 @@ dependencies = ["numpy", "matplotlib>=3.9", "scipy", "sqlalchemy", "pandas", "py
|
|
|
19
19
|
|
|
20
20
|
[project.optional-dependencies]
|
|
21
21
|
lab = ["jupyterlab"]
|
|
22
|
-
tests = ["pytest", "pytest-cov"]
|
|
22
|
+
tests = ["pytest", "pytest-cov", "pytest-xdist"]
|
|
23
23
|
docs = [
|
|
24
24
|
"sphinx>=7.0",
|
|
25
25
|
"shibuya",
|
|
@@ -49,6 +49,11 @@ build-backend = "setuptools.build_meta"
|
|
|
49
49
|
[tool.setuptools.dynamic]
|
|
50
50
|
version = { attr = "apsg.__version__" }
|
|
51
51
|
|
|
52
|
+
[tool.pytest.ini_options]
|
|
53
|
+
# parallel by default (pytest-xdist); use `-p no:xdist` or `-n0` to fall back to a single
|
|
54
|
+
# process for interactive debugging (--pdb, -s with breakpoints don't work under a worker)
|
|
55
|
+
addopts = ["-n", "auto"]
|
|
56
|
+
|
|
52
57
|
[tool.ruff]
|
|
53
58
|
line-length = 88
|
|
54
59
|
target-version = "py310"
|
|
@@ -59,6 +64,8 @@ ignore = ["E731", "E741"]
|
|
|
59
64
|
|
|
60
65
|
[tool.ruff.lint.per-file-ignores]
|
|
61
66
|
"__init__.py" = ["F401"]
|
|
67
|
+
"src/apsg/math/_matrix.py" = ["E743"] # Matrix.I: numpy-style inverse property
|
|
68
|
+
"src/apsg/shell.py" = ["F403"] # from apsg import * populates the interactive shell
|
|
62
69
|
|
|
63
70
|
[tool.ruff.format]
|
|
64
71
|
quote-style = "double"
|
|
@@ -1137,7 +1137,7 @@ class Vector3Set(FeatureSet):
|
|
|
1137
1137
|
return Rotation3(R.as_matrix())
|
|
1138
1138
|
|
|
1139
1139
|
@classmethod
|
|
1140
|
-
def from_csv(cls, filename, acol=0, icol=1):
|
|
1140
|
+
def from_csv(cls, filename, acol=0, icol=1, name=None):
|
|
1141
1141
|
"""Create ``FeatureSet`` object from csv file of azimuths and inclinations.
|
|
1142
1142
|
|
|
1143
1143
|
Args:
|
|
@@ -1147,10 +1147,13 @@ class Vector3Set(FeatureSet):
|
|
|
1147
1147
|
acol (int or str): azimuth column (starts from 0). Default 0.
|
|
1148
1148
|
icol (int or str): inclination column (starts from 0). Default 1.
|
|
1149
1149
|
When acol and icol are strings they are used as column headers.
|
|
1150
|
+
name (str): name of the created feature set. Default is the
|
|
1151
|
+
filename without its directory part.
|
|
1150
1152
|
|
|
1151
1153
|
Examples:
|
|
1152
1154
|
>>> gf = folset.from_csv('file1.csv') #doctest: +SKIP
|
|
1153
1155
|
>>> gl = linset.from_csv('file2.csv', acol=1, icol=2) #doctest: +SKIP
|
|
1156
|
+
>>> gl = linset.from_csv('file2.csv', name='My data') #doctest: +SKIP
|
|
1154
1157
|
|
|
1155
1158
|
Returns:
|
|
1156
1159
|
FeatureSet: The created feature set.
|
|
@@ -1179,7 +1182,9 @@ class Vector3Set(FeatureSet):
|
|
|
1179
1182
|
raise ValueError("No header line in CSV file...")
|
|
1180
1183
|
|
|
1181
1184
|
azi, inc = zip(*r)
|
|
1182
|
-
return cls.from_array(
|
|
1185
|
+
return cls.from_array(
|
|
1186
|
+
azi, inc, name=name if name is not None else basename(filename)
|
|
1187
|
+
)
|
|
1183
1188
|
|
|
1184
1189
|
def to_csv(self, filename, delimiter=","):
|
|
1185
1190
|
"""Save ``FeatureSet`` object to csv file of azimuths and inclinations.
|
|
@@ -1595,8 +1600,14 @@ class PairSet(FeatureSet):
|
|
|
1595
1600
|
lacol=2,
|
|
1596
1601
|
licol=3,
|
|
1597
1602
|
scol=4,
|
|
1603
|
+
name=None,
|
|
1598
1604
|
):
|
|
1599
|
-
"""Read ``PairSet`` from csv file.
|
|
1605
|
+
"""Read ``PairSet`` from csv file.
|
|
1606
|
+
|
|
1607
|
+
Keyword Args:
|
|
1608
|
+
name (str): name of the created ``PairSet``. Default is the
|
|
1609
|
+
filename without its directory part.
|
|
1610
|
+
"""
|
|
1600
1611
|
|
|
1601
1612
|
with open(filename) as csvfile:
|
|
1602
1613
|
has_header = csv.Sniffer().has_header(csvfile.read(1024))
|
|
@@ -1658,7 +1669,13 @@ class PairSet(FeatureSet):
|
|
|
1658
1669
|
raise ValueError("No header line in CSV file...")
|
|
1659
1670
|
|
|
1660
1671
|
fazi, finc, lazi, linc = zip(*r)
|
|
1661
|
-
return cls.from_array(
|
|
1672
|
+
return cls.from_array(
|
|
1673
|
+
fazi,
|
|
1674
|
+
finc,
|
|
1675
|
+
lazi,
|
|
1676
|
+
linc,
|
|
1677
|
+
name=name if name is not None else basename(filename),
|
|
1678
|
+
)
|
|
1662
1679
|
|
|
1663
1680
|
def to_csv(self, filename, delimiter=","):
|
|
1664
1681
|
"""Save ``PairSet`` object to csv file.
|
|
@@ -1819,8 +1836,14 @@ class FaultSet(PairSet):
|
|
|
1819
1836
|
lacol=2,
|
|
1820
1837
|
licol=3,
|
|
1821
1838
|
scol=4,
|
|
1839
|
+
name=None,
|
|
1822
1840
|
):
|
|
1823
|
-
"""Read ``FaultSet`` from csv file.
|
|
1841
|
+
"""Read ``FaultSet`` from csv file.
|
|
1842
|
+
|
|
1843
|
+
Keyword Args:
|
|
1844
|
+
name (str): name of the created ``FaultSet``. Default is the
|
|
1845
|
+
filename without its directory part.
|
|
1846
|
+
"""
|
|
1824
1847
|
|
|
1825
1848
|
with open(filename) as csvfile:
|
|
1826
1849
|
has_header = csv.Sniffer().has_header(csvfile.read(1024))
|
|
@@ -1912,7 +1935,14 @@ class FaultSet(PairSet):
|
|
|
1912
1935
|
raise ValueError("No header line in CSV file...")
|
|
1913
1936
|
|
|
1914
1937
|
fazi, finc, lazi, linc, sense = zip(*r)
|
|
1915
|
-
return cls.from_array(
|
|
1938
|
+
return cls.from_array(
|
|
1939
|
+
fazi,
|
|
1940
|
+
finc,
|
|
1941
|
+
lazi,
|
|
1942
|
+
linc,
|
|
1943
|
+
sense,
|
|
1944
|
+
name=name if name is not None else basename(filename),
|
|
1945
|
+
)
|
|
1916
1946
|
|
|
1917
1947
|
def to_csv(self, filename, delimiter=",", sense_str=False):
|
|
1918
1948
|
"""Save ``FaultSet`` object to csv file.
|
|
@@ -429,10 +429,10 @@ class StereoNetArtistFactory:
|
|
|
429
429
|
|
|
430
430
|
@staticmethod
|
|
431
431
|
def create_hoeppner(*args, **kwargs):
|
|
432
|
-
"""Create stereonet Hoeppner plot artist from Fault data."""
|
|
432
|
+
"""Create stereonet Hoeppner plot artist from Fault/Pair data."""
|
|
433
433
|
return StereoNetArtistFactory._create(
|
|
434
434
|
"create_hoeppner",
|
|
435
|
-
(Fault, FaultSet),
|
|
435
|
+
(Fault, FaultSet, Pair, PairSet),
|
|
436
436
|
"_hoeppner",
|
|
437
437
|
"stereonet_hoeppner",
|
|
438
438
|
"Fault",
|
|
@@ -59,7 +59,13 @@ class RosePlot:
|
|
|
59
59
|
# self.ax.format_coord = self.format_coord
|
|
60
60
|
self.ax.set_theta_direction(-1) # type: ignore
|
|
61
61
|
self.ax.set_theta_zero_location("N") # type: ignore
|
|
62
|
-
self.
|
|
62
|
+
if self._kwargs["grid"]:
|
|
63
|
+
self.ax.grid(True, **self._kwargs["grid_kws"])
|
|
64
|
+
else:
|
|
65
|
+
# matplotlib's grid() enables the grid regardless of a false first
|
|
66
|
+
# argument -- with a warning -- when grid_kws is non-empty, so it must
|
|
67
|
+
# be omitted entirely to actually keep the grid off
|
|
68
|
+
self.ax.grid(False)
|
|
63
69
|
|
|
64
70
|
def _plot_artists(self):
|
|
65
71
|
for artist in self._artists:
|
|
@@ -182,11 +182,17 @@ class StereoNet:
|
|
|
182
182
|
self.ax.set_rotation(self._rotation)
|
|
183
183
|
|
|
184
184
|
def _draw_layout(self):
|
|
185
|
-
self.
|
|
186
|
-
self.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
if self._kwargs["grid"]:
|
|
186
|
+
self.ax.grid(
|
|
187
|
+
True,
|
|
188
|
+
linestyle=self._kwargs["grid_style"],
|
|
189
|
+
color=self._kwargs["grid_color"],
|
|
190
|
+
)
|
|
191
|
+
else:
|
|
192
|
+
# matplotlib's grid() enables the grid regardless of a false first
|
|
193
|
+
# argument -- with a warning -- when style kwargs are also given, so
|
|
194
|
+
# those must be omitted entirely to actually keep the grid off
|
|
195
|
+
self.ax.grid(False)
|
|
190
196
|
self.ax.set_longitude_grid(self._kwargs["grid_step"])
|
|
191
197
|
self.ax.set_latitude_grid(self._kwargs["grid_step"])
|
|
192
198
|
self.ax.set_clip_pole(self._kwargs["clip_pole"])
|
|
@@ -606,14 +612,16 @@ class StereoNet:
|
|
|
606
612
|
|
|
607
613
|
def hoeppner(self, *args, **kwargs):
|
|
608
614
|
"""
|
|
609
|
-
Plot fault feature(s) on Hoeppner (tangent lineation) plot.
|
|
615
|
+
Plot fault or pair feature(s) on Hoeppner (tangent lineation) plot.
|
|
610
616
|
|
|
611
617
|
Note: Arrow is styled according to default arrow config, except its
|
|
612
618
|
pivot, which is taken from apsg_conf.stereonet_hoeppner.pivot
|
|
613
|
-
(default "middle")
|
|
619
|
+
(default "middle"). A ``Pair``/``PairSet`` has no movement sense,
|
|
620
|
+
so its lineation is drawn as a plain line through the plane's
|
|
621
|
+
pole, with no arrowhead, instead of an arrow.
|
|
614
622
|
|
|
615
623
|
Args:
|
|
616
|
-
Fault or
|
|
624
|
+
Fault, FaultSet, Pair or PairSet feature(s)
|
|
617
625
|
|
|
618
626
|
Keyword Args:
|
|
619
627
|
alpha (scalar): Set the alpha value. Default None
|
|
@@ -623,7 +631,7 @@ class StereoNet:
|
|
|
623
631
|
lw (float): Set line width. Default 1.5
|
|
624
632
|
|
|
625
633
|
Returns:
|
|
626
|
-
None: Fault features are plotted on Hoeppner plot.
|
|
634
|
+
None: Fault/pair features are plotted on Hoeppner plot.
|
|
627
635
|
"""
|
|
628
636
|
self._add_artist(StereoNetArtistFactory.create_hoeppner, *args, **kwargs)
|
|
629
637
|
|
|
@@ -813,7 +821,7 @@ class StereoNet:
|
|
|
813
821
|
smoothing or "sph" for spherical harmonics method. Default "kamb"
|
|
814
822
|
levels (int or list): number or values of contours. Default 6
|
|
815
823
|
cmap: matplotlib colormap. Default "Greys" when `clip` is True, or
|
|
816
|
-
"
|
|
824
|
+
"RdBu_r" (diverging, centered on 0) when `clip` is False
|
|
817
825
|
clip (bool): restrict to the positive (above-uniform) region only.
|
|
818
826
|
Default True
|
|
819
827
|
colorbar (bool): Show colorbar. Default False
|
|
@@ -1050,7 +1058,15 @@ class StereoNet:
|
|
|
1050
1058
|
quiver_kwargs["pivot"] = pivot
|
|
1051
1059
|
quiver_kwargs["color"] = h[0].get_color()
|
|
1052
1060
|
for arg in args:
|
|
1053
|
-
|
|
1061
|
+
if isinstance(arg, (Fault, FaultSet)):
|
|
1062
|
+
self._arrow(arg.fol, arg.lin, sense=arg.sense, **quiver_kwargs)
|
|
1063
|
+
else:
|
|
1064
|
+
# Pair/PairSet: no movement sense, so no arrowhead -- a plain
|
|
1065
|
+
# line through the planar symbol's center (pivot="middle").
|
|
1066
|
+
line_kwargs = dict(
|
|
1067
|
+
quiver_kwargs, headwidth=0, headlength=0, headaxislength=0
|
|
1068
|
+
)
|
|
1069
|
+
self._arrow(arg.fol, arg.lin, sense=1, **line_kwargs)
|
|
1054
1070
|
|
|
1055
1071
|
def _fill_quadrants(self, quads, max_alpha, **kwargs):
|
|
1056
1072
|
"""Fill each ``(arcset, outside)`` of ``quads`` with one color and one legend
|
|
@@ -1173,10 +1189,11 @@ class StereoNet:
|
|
|
1173
1189
|
linestyles = kwargs.pop("linestyles")
|
|
1174
1190
|
# apsg_conf.stereonet_contour.clip defaults to True; when cmap isn't
|
|
1175
1191
|
# given explicitly, apsg's own default is "Greys" for that clipped
|
|
1176
|
-
# (positive/above-uniform only) view, or "
|
|
1177
|
-
# on 0) for the full range when
|
|
1192
|
+
# (positive/above-uniform only) view, or "RdBu_r" (diverging, centered
|
|
1193
|
+
# on 0, blue below/red above uniform) for the full range when
|
|
1194
|
+
# clip=False is requested.
|
|
1178
1195
|
if kwargs.get("cmap") is None:
|
|
1179
|
-
kwargs["cmap"] = "Greys" if kwargs.get("clip") else "
|
|
1196
|
+
kwargs["cmap"] = "Greys" if kwargs.get("clip") else "RdBu_r"
|
|
1180
1197
|
if not filled:
|
|
1181
1198
|
# linewidths/linestyles are meaningless for filled contours
|
|
1182
1199
|
# (contourf ignores/warns about them) -- only forward for lines
|
|
@@ -153,7 +153,7 @@ class StereoNetFaultStyle(StereoNetStyle):
|
|
|
153
153
|
class StereoNetHoeppnerStyle(StereoNetStyle):
|
|
154
154
|
def __init__(self, **kwargs):
|
|
155
155
|
"""Initialize stereonet Hoeppner plot style."""
|
|
156
|
-
self._valid = (Fault, FaultSet)
|
|
156
|
+
self._valid = (Fault, FaultSet, Pair, PairSet)
|
|
157
157
|
self.kwargs = apsg_conf.stereonet_hoeppner.copy()
|
|
158
158
|
super().__init__(**kwargs)
|
|
159
159
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: apsg
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: APSG - The package for structural geologists
|
|
5
5
|
Author-email: Ondrej Lexa <lexa.ondrej@gmail.com>
|
|
6
6
|
Maintainer-email: Ondrej Lexa <lexa.ondrej@gmail.com>
|
|
@@ -29,6 +29,7 @@ Requires-Dist: jupyterlab; extra == "lab"
|
|
|
29
29
|
Provides-Extra: tests
|
|
30
30
|
Requires-Dist: pytest; extra == "tests"
|
|
31
31
|
Requires-Dist: pytest-cov; extra == "tests"
|
|
32
|
+
Requires-Dist: pytest-xdist; extra == "tests"
|
|
32
33
|
Provides-Extra: docs
|
|
33
34
|
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
34
35
|
Requires-Dist: shibuya; extra == "docs"
|
|
@@ -827,6 +827,21 @@ class TestLineationSet:
|
|
|
827
827
|
v = LineationSet.from_array([110, 30], [26, 10])
|
|
828
828
|
assert len(v) == 2
|
|
829
829
|
|
|
830
|
+
def test_from_csv_name_defaults_to_filename(self, tmp_path):
|
|
831
|
+
v = LineationSet.from_array([110, 30], [26, 10])
|
|
832
|
+
path = tmp_path / "mele.csv"
|
|
833
|
+
v.to_csv(str(path))
|
|
834
|
+
loaded = LineationSet.from_csv(str(path))
|
|
835
|
+
assert loaded.name == "mele.csv"
|
|
836
|
+
|
|
837
|
+
def test_from_csv_name_kwarg(self, tmp_path):
|
|
838
|
+
v = LineationSet.from_array([110, 30], [26, 10])
|
|
839
|
+
path = tmp_path / "mele.csv"
|
|
840
|
+
v.to_csv(str(path))
|
|
841
|
+
loaded = LineationSet.from_csv(str(path), name="Mele")
|
|
842
|
+
assert loaded.name == "Mele"
|
|
843
|
+
assert len(loaded) == 2
|
|
844
|
+
|
|
830
845
|
def test_random_fisher(self):
|
|
831
846
|
np.random.seed(42)
|
|
832
847
|
v = LineationSet.random_fisher(10, position=Lineation(120, 40))
|
|
@@ -938,6 +953,16 @@ class TestPairSet:
|
|
|
938
953
|
p = PairSet([Pair(140, 30, 110, 26), Pair(200, 40, 180, 20)])
|
|
939
954
|
assert len(p) == 2
|
|
940
955
|
|
|
956
|
+
def test_from_csv_name_kwarg(self, tmp_path):
|
|
957
|
+
p = PairSet([Pair(140, 30, 110, 26), Pair(200, 40, 180, 20)])
|
|
958
|
+
path = tmp_path / "mele.csv"
|
|
959
|
+
p.to_csv(str(path))
|
|
960
|
+
loaded = PairSet.from_csv(str(path), name="Mele")
|
|
961
|
+
assert loaded.name == "Mele"
|
|
962
|
+
assert len(loaded) == 2
|
|
963
|
+
loaded_default = PairSet.from_csv(str(path))
|
|
964
|
+
assert loaded_default.name == "mele.csv"
|
|
965
|
+
|
|
941
966
|
def test_fol_property(self):
|
|
942
967
|
p = PairSet([Pair(140, 30, 110, 26)])
|
|
943
968
|
f = p.fol
|
|
@@ -1076,6 +1101,16 @@ class TestFaultSet:
|
|
|
1076
1101
|
)
|
|
1077
1102
|
assert len(f) == 2
|
|
1078
1103
|
|
|
1104
|
+
def test_from_csv_name_kwarg(self, tmp_path):
|
|
1105
|
+
f = FaultSet([Fault(140, 30, 110, 26, -1), Fault(200, 40, 180, 20, 1)])
|
|
1106
|
+
path = tmp_path / "mele.csv"
|
|
1107
|
+
f.to_csv(str(path))
|
|
1108
|
+
loaded = FaultSet.from_csv(str(path), name="Mele")
|
|
1109
|
+
assert loaded.name == "Mele"
|
|
1110
|
+
assert len(loaded) == 2
|
|
1111
|
+
loaded_default = FaultSet.from_csv(str(path))
|
|
1112
|
+
assert loaded_default.name == "mele.csv"
|
|
1113
|
+
|
|
1079
1114
|
def test_sense_property(self):
|
|
1080
1115
|
f = FaultSet([Fault(140, 30, 110, 26, -1)])
|
|
1081
1116
|
np.testing.assert_array_equal(f.sense, [-1])
|
|
@@ -2,6 +2,8 @@ import matplotlib
|
|
|
2
2
|
|
|
3
3
|
matplotlib.use("Agg")
|
|
4
4
|
|
|
5
|
+
import random
|
|
6
|
+
|
|
5
7
|
import matplotlib.colors
|
|
6
8
|
import matplotlib.contour
|
|
7
9
|
import matplotlib.lines
|
|
@@ -30,6 +32,7 @@ from apsg import (
|
|
|
30
32
|
ortensor,
|
|
31
33
|
ortensorset,
|
|
32
34
|
pair,
|
|
35
|
+
pairset,
|
|
33
36
|
quicknet,
|
|
34
37
|
rotation_from_axis_angle,
|
|
35
38
|
stereonet_styles,
|
|
@@ -81,6 +84,7 @@ def _tensor_sets(n=12, seed=3):
|
|
|
81
84
|
("pair", (pair(140, 30, 110, 26),), (lin(10, 20),)),
|
|
82
85
|
("fault", (fault(140, 30, 110, 26, 1),), (lin(10, 20),)),
|
|
83
86
|
("hoeppner", (fault(140, 30, 110, 26, 1),), (lin(10, 20),)),
|
|
87
|
+
("hoeppner", (pair(140, 30, 110, 26),), (lin(10, 20),)),
|
|
84
88
|
("dihedra", (fault(140, 30, 110, 26, 1),), (lin(10, 20),)),
|
|
85
89
|
("beachball", (stress([[8, 0, 0], [0, 5, 0], [0, 0, 1]]),), (lin(10, 20),)),
|
|
86
90
|
(
|
|
@@ -1044,7 +1048,7 @@ def test_contour_clip_defaults_true():
|
|
|
1044
1048
|
assert s._artists[-1].kwargs["clip"] is True
|
|
1045
1049
|
|
|
1046
1050
|
|
|
1047
|
-
def
|
|
1051
|
+
def test_contour_default_cmap_is_greys_when_clipped_else_rdbu_r():
|
|
1048
1052
|
l = linset.random_fisher(position=lin(60, 40), n=40)
|
|
1049
1053
|
s = StereoNet()
|
|
1050
1054
|
s.contour(l) # clip defaults to True
|
|
@@ -1067,7 +1071,7 @@ def test_contour_default_cmap_is_greys_when_clipped_else_rdbu():
|
|
|
1067
1071
|
for c in s2.ax.get_children()
|
|
1068
1072
|
if isinstance(c, matplotlib.contour.ContourSet) and c.filled
|
|
1069
1073
|
]
|
|
1070
|
-
assert filled2[0].get_cmap().name == "
|
|
1074
|
+
assert filled2[0].get_cmap().name == "RdBu_r"
|
|
1071
1075
|
assert min(filled2[0].levels) < 0
|
|
1072
1076
|
|
|
1073
1077
|
|
|
@@ -1325,6 +1329,26 @@ def test_grid_color_reaches_gridlines():
|
|
|
1325
1329
|
assert s.ax.yaxis.get_gridlines()[0].get_color() == "blue"
|
|
1326
1330
|
|
|
1327
1331
|
|
|
1332
|
+
def test_grid_false_stays_off_and_does_not_warn(recwarn):
|
|
1333
|
+
# regression: matplotlib's Axes.grid() re-enables the grid (and warns) if
|
|
1334
|
+
# style kwargs (grid_style/grid_color) are passed alongside a false first
|
|
1335
|
+
# argument -- those must be withheld entirely when grid=False
|
|
1336
|
+
s = StereoNet(grid=False, grid_color="red")
|
|
1337
|
+
s.init_figure()
|
|
1338
|
+
s._render()
|
|
1339
|
+
assert not any(l.get_visible() for l in s.ax.xaxis.get_gridlines())
|
|
1340
|
+
assert not any(l.get_visible() for l in s.ax.yaxis.get_gridlines())
|
|
1341
|
+
assert not [w for w in recwarn.list if issubclass(w.category, UserWarning)]
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
def test_roseplot_grid_false_stays_off_and_does_not_warn(recwarn):
|
|
1345
|
+
r = RosePlot(grid=False, grid_kws={"color": "red"})
|
|
1346
|
+
r.init_figure()
|
|
1347
|
+
r._render()
|
|
1348
|
+
assert not any(l.get_visible() for l in r.ax.yaxis.get_gridlines())
|
|
1349
|
+
assert not [w for w in recwarn.list if issubclass(w.category, UserWarning)]
|
|
1350
|
+
|
|
1351
|
+
|
|
1328
1352
|
def test_stereogrid_default_n_and_type_from_config():
|
|
1329
1353
|
g = StereoGrid()
|
|
1330
1354
|
assert g.grid_n == 3000
|
|
@@ -1639,6 +1663,71 @@ def test_hoeppner_arrow_pivots_on_point():
|
|
|
1639
1663
|
assert q.Y[0] == pytest.approx(py[0], abs=1e-9)
|
|
1640
1664
|
|
|
1641
1665
|
|
|
1666
|
+
def test_hoeppner_pair_draws_headless_line():
|
|
1667
|
+
p = pair(140, 30, 110, 26)
|
|
1668
|
+
s = StereoNet()
|
|
1669
|
+
s.hoeppner(p)
|
|
1670
|
+
s.init_figure()
|
|
1671
|
+
s._render()
|
|
1672
|
+
|
|
1673
|
+
quivers = [
|
|
1674
|
+
c for c in s.ax.get_children() if isinstance(c, matplotlib.quiver.Quiver)
|
|
1675
|
+
]
|
|
1676
|
+
assert len(quivers) == 1
|
|
1677
|
+
q = quivers[0]
|
|
1678
|
+
|
|
1679
|
+
assert q.headwidth == 0
|
|
1680
|
+
assert q.headlength == 0
|
|
1681
|
+
assert q.headaxislength == 0
|
|
1682
|
+
assert q.pivot == "middle"
|
|
1683
|
+
px, py = s.ax.project(np.asarray(p.fol), clip_inside=True, fold=True)
|
|
1684
|
+
assert q.X[0] == pytest.approx(px[0], abs=1e-9)
|
|
1685
|
+
assert q.Y[0] == pytest.approx(py[0], abs=1e-9)
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
def test_hoeppner_fault_keeps_arrowhead():
|
|
1689
|
+
# regression: the new Pair branch must not affect Fault's own arrow
|
|
1690
|
+
f = fault(170, 60, 182, 59, -1)
|
|
1691
|
+
s = StereoNet()
|
|
1692
|
+
s.hoeppner(f)
|
|
1693
|
+
s.init_figure()
|
|
1694
|
+
s._render()
|
|
1695
|
+
|
|
1696
|
+
(q,) = [c for c in s.ax.get_children() if isinstance(c, matplotlib.quiver.Quiver)]
|
|
1697
|
+
assert q.headwidth != 0
|
|
1698
|
+
assert q.headlength != 0
|
|
1699
|
+
assert q.headaxislength != 0
|
|
1700
|
+
|
|
1701
|
+
|
|
1702
|
+
def test_hoeppner_pairset():
|
|
1703
|
+
ps = pairset([pair(140, 30, 110, 26), pair(160, 40, 90, 20)])
|
|
1704
|
+
s = StereoNet()
|
|
1705
|
+
s.hoeppner(ps)
|
|
1706
|
+
s.init_figure()
|
|
1707
|
+
s._render()
|
|
1708
|
+
|
|
1709
|
+
(q,) = [c for c in s.ax.get_children() if isinstance(c, matplotlib.quiver.Quiver)]
|
|
1710
|
+
assert q.headlength == 0
|
|
1711
|
+
assert q.N == 2
|
|
1712
|
+
|
|
1713
|
+
|
|
1714
|
+
def test_hoeppner_mixed_fault_and_pair():
|
|
1715
|
+
f = fault(170, 60, 182, 59, -1)
|
|
1716
|
+
p = pair(140, 30, 110, 26)
|
|
1717
|
+
s = StereoNet()
|
|
1718
|
+
s.hoeppner(f, p)
|
|
1719
|
+
s.init_figure()
|
|
1720
|
+
s._render()
|
|
1721
|
+
|
|
1722
|
+
quivers = [
|
|
1723
|
+
c for c in s.ax.get_children() if isinstance(c, matplotlib.quiver.Quiver)
|
|
1724
|
+
]
|
|
1725
|
+
assert len(quivers) == 2
|
|
1726
|
+
headlengths = sorted(q.headlength for q in quivers)
|
|
1727
|
+
assert headlengths[0] == 0
|
|
1728
|
+
assert headlengths[1] != 0
|
|
1729
|
+
|
|
1730
|
+
|
|
1642
1731
|
def test_hoeppner_pivot_is_configurable():
|
|
1643
1732
|
f = faultset([fault(170, 60, 182, 59, -1)])
|
|
1644
1733
|
with apsg_conf_context(stereonet_hoeppner={"pivot": "tail"}):
|
|
@@ -2272,13 +2361,15 @@ def test_dihedra_fills_the_dihedra_containing_the_t_axis(name):
|
|
|
2272
2361
|
assert _dihedra_mismatches(_DIHEDRA_FAULTS[name]) == 0
|
|
2273
2362
|
|
|
2274
2363
|
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2364
|
+
@pytest.mark.parametrize("seed", range(25))
|
|
2365
|
+
def test_dihedra_random_faults(seed):
|
|
2366
|
+
# each case gets its own distinct, deterministic seed -- not the exact same 25
|
|
2367
|
+
# faults a single seed-once-then-loop would draw, but an equally valid,
|
|
2368
|
+
# equally reproducible sample for this fuzz test, and split into independent
|
|
2369
|
+
# items so a parallel run can distribute them across workers
|
|
2370
|
+
random.seed(11 + seed)
|
|
2371
|
+
np.random.seed(11 + seed)
|
|
2372
|
+
assert _dihedra_mismatches(fault.random(), n=60, seed=seed) == 0
|
|
2282
2373
|
|
|
2283
2374
|
|
|
2284
2375
|
def test_dihedra_upper_hemisphere():
|
|
@@ -2315,14 +2406,20 @@ def test_dihedra_is_one_color_and_one_legend_entry_for_a_set():
|
|
|
2315
2406
|
assert [p.get_label() for p in s.ax.patches].count("extension") == 1
|
|
2316
2407
|
|
|
2317
2408
|
|
|
2318
|
-
def
|
|
2409
|
+
def test_dihedra_alpha_default_is_none():
|
|
2319
2410
|
assert apsg_conf.stereonet_dihedra["alpha"] is None
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2411
|
+
|
|
2412
|
+
|
|
2413
|
+
@pytest.mark.parametrize("n,expected", [(1, 0.3), (3, 0.3), (25, 0.06)])
|
|
2414
|
+
def test_dihedra_alpha_default_scales_with_the_number_of_faults(n, expected):
|
|
2415
|
+
s = StereoNet()
|
|
2416
|
+
s.dihedra(faultset([_dihedra_fault(120 + i, 55, 90) for i in range(n)]))
|
|
2417
|
+
s.init_figure()
|
|
2418
|
+
s._render()
|
|
2419
|
+
assert {p.get_alpha() for p in s.ax.patches} == {expected}
|
|
2420
|
+
|
|
2421
|
+
|
|
2422
|
+
def test_dihedra_alpha_is_configurable():
|
|
2326
2423
|
s = StereoNet()
|
|
2327
2424
|
s.dihedra(_DIHEDRA_FAULTS["reverse"], alpha=0.8, color="r")
|
|
2328
2425
|
s.init_figure()
|
|
@@ -2435,9 +2532,11 @@ def test_beachball_fills_the_quadrants_containing_the_p_axis(name):
|
|
|
2435
2532
|
assert _beachball_mismatches(_BEACHBALL_STRESSES[name]) == 0
|
|
2436
2533
|
|
|
2437
2534
|
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2535
|
+
@pytest.mark.parametrize("seed", range(25))
|
|
2536
|
+
def test_beachball_random_stresses(seed):
|
|
2537
|
+
# split into independent items so a parallel run can distribute them across
|
|
2538
|
+
# workers -- _rotated_stress(seed) is already independent per seed
|
|
2539
|
+
assert _beachball_mismatches(_rotated_stress(seed), n=60, seed=seed) == 0
|
|
2441
2540
|
|
|
2442
2541
|
|
|
2443
2542
|
def test_beachball_upper_hemisphere():
|
|
@@ -2521,16 +2620,22 @@ def test_beachball_is_one_color_and_one_legend_entry_for_a_set():
|
|
|
2521
2620
|
assert [p.get_label() for p in s.ax.patches].count("P quadrants") == 1
|
|
2522
2621
|
|
|
2523
2622
|
|
|
2524
|
-
def
|
|
2623
|
+
def test_beachball_defaults_are_black_and_no_alpha():
|
|
2525
2624
|
assert apsg_conf.stereonet_beachball["color"] == "k"
|
|
2526
2625
|
assert apsg_conf.stereonet_beachball["alpha"] is None
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2626
|
+
|
|
2627
|
+
|
|
2628
|
+
@pytest.mark.parametrize("n,expected", [(1, 1.0), (25, 0.06)])
|
|
2629
|
+
def test_beachball_alpha_scales_with_the_number_of_tensors(n, expected):
|
|
2630
|
+
s = StereoNet()
|
|
2631
|
+
s.beachball(stressset([_rotated_stress(i) for i in range(n)]))
|
|
2632
|
+
s.init_figure()
|
|
2633
|
+
s._render()
|
|
2634
|
+
assert {p.get_alpha() for p in s.ax.patches} == {expected}
|
|
2635
|
+
assert matplotlib.colors.same_color(s.ax.patches[0].get_facecolor()[:3], "k")
|
|
2636
|
+
|
|
2637
|
+
|
|
2638
|
+
def test_beachball_alpha_and_color_are_configurable():
|
|
2534
2639
|
s = StereoNet()
|
|
2535
2640
|
s.beachball(_rotated_stress(0), alpha=0.4, color="r")
|
|
2536
2641
|
s.init_figure()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|