apsg 2.0.3__tar.gz → 2.0.5__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.
Files changed (56) hide show
  1. {apsg-2.0.3/src/apsg.egg-info → apsg-2.0.5}/PKG-INFO +1 -1
  2. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/__init__.py +1 -1
  3. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/feature/_geodata.py +2 -1
  4. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/feature/_tensor2.py +14 -7
  5. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/feature/_tensor3.py +14 -7
  6. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/helpers/_notation.py +16 -8
  7. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/math/_vector.py +5 -3
  8. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_fabricplot.py +15 -9
  9. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_plot_artists.py +9 -2
  10. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_stereonet.py +9 -3
  11. {apsg-2.0.3 → apsg-2.0.5/src/apsg.egg-info}/PKG-INFO +1 -1
  12. {apsg-2.0.3 → apsg-2.0.5}/tests/test_apsg.py +23 -0
  13. {apsg-2.0.3 → apsg-2.0.5}/tests/test_plotting.py +19 -0
  14. {apsg-2.0.3 → apsg-2.0.5}/tests/test_tensors.py +47 -0
  15. {apsg-2.0.3 → apsg-2.0.5}/LICENSE +0 -0
  16. {apsg-2.0.3 → apsg-2.0.5}/README.md +0 -0
  17. {apsg-2.0.3 → apsg-2.0.5}/pyproject.toml +0 -0
  18. {apsg-2.0.3 → apsg-2.0.5}/setup.cfg +0 -0
  19. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/config.py +0 -0
  20. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/database/__init__.py +0 -0
  21. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/database/_sdbmodels.py +0 -0
  22. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/database/_sdbsession.py +0 -0
  23. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/database/_websdbsession.py +0 -0
  24. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/database/_webtransport.py +0 -0
  25. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/feature/__init__.py +0 -0
  26. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/feature/_container.py +0 -0
  27. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/feature/_paleomag.py +0 -0
  28. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/feature/_statistics.py +0 -0
  29. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/helpers/__init__.py +0 -0
  30. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/helpers/_helper.py +0 -0
  31. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/helpers/_math.py +0 -0
  32. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/math/__init__.py +0 -0
  33. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/math/_matrix.py +0 -0
  34. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/pandas/__init__.py +0 -0
  35. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/pandas/_accessors.py +0 -0
  36. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/pandas/_gbfunctions.py +0 -0
  37. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/pandas/_pandas_api.py +0 -0
  38. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/__init__.py +0 -0
  39. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_paleomagplots.py +0 -0
  40. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_roseplot.py +0 -0
  41. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_stereo_engine/__init__.py +0 -0
  42. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_stereo_engine/_axes.py +0 -0
  43. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_stereo_engine/_stereogrid.py +0 -0
  44. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_stereo_engine/_transforms.py +0 -0
  45. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_stereo_engine/_utils.py +0 -0
  46. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_stereogrid.py +0 -0
  47. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/plotting/_styles.py +0 -0
  48. {apsg-2.0.3 → apsg-2.0.5}/src/apsg/shell.py +0 -0
  49. {apsg-2.0.3 → apsg-2.0.5}/src/apsg.egg-info/SOURCES.txt +0 -0
  50. {apsg-2.0.3 → apsg-2.0.5}/src/apsg.egg-info/dependency_links.txt +0 -0
  51. {apsg-2.0.3 → apsg-2.0.5}/src/apsg.egg-info/entry_points.txt +0 -0
  52. {apsg-2.0.3 → apsg-2.0.5}/src/apsg.egg-info/requires.txt +0 -0
  53. {apsg-2.0.3 → apsg-2.0.5}/src/apsg.egg-info/top_level.txt +0 -0
  54. {apsg-2.0.3 → apsg-2.0.5}/tests/test_containers.py +0 -0
  55. {apsg-2.0.3 → apsg-2.0.5}/tests/test_pandas.py +0 -0
  56. {apsg-2.0.3 → apsg-2.0.5}/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
3
+ Version: 2.0.5
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>
@@ -195,6 +195,6 @@ __all__ = (
195
195
  "velgrad2",
196
196
  )
197
197
 
198
- __version__ = "2.0.3"
198
+ __version__ = "2.0.5"
199
199
  __author__ = "Ondrej Lexa"
200
200
  __email__ = "lexa.ondrej@gmail.com"
@@ -5,6 +5,7 @@ import numpy as np
5
5
  from apsg.helpers._helper import is_jsonable
6
6
  from apsg.helpers._math import atan2d
7
7
  from apsg.helpers._notation import (
8
+ _fmt_deg,
8
9
  fol2vec_rhr,
9
10
  format_linear,
10
11
  format_planar,
@@ -45,7 +46,7 @@ class Direction(Axial2):
45
46
  """
46
47
 
47
48
  def __repr__(self):
48
- return f"D:{self.direction:.0f}"
49
+ return f"D:{_fmt_deg(self.direction, azimuth=True)}"
49
50
 
50
51
 
51
52
  class Lineation(Axial3):
@@ -114,22 +114,23 @@ class DeformationGradient2(Matrix2):
114
114
 
115
115
  Keyword Args:
116
116
  R (Rotation2): rotation resolving the ambiguity, to be determined from
117
- independent data. Default is the identity, i.e. the simplest,
118
- purely coaxial solution.
117
+ independent data. Default None gives the simplest, purely coaxial
118
+ solution F = Q @ D @ Qᵗ (a symmetric stretch, no rotation).
119
119
 
120
120
  Returns:
121
121
  DeformationGradient2: recovered ``DeformationGradient2``.
122
122
  """
123
- if R is None:
124
- R = Rotation2()
123
+ if form not in ("left", "B", "right", "C"):
124
+ raise TypeError("Wrong form argument")
125
125
  Q = np.column_stack(E.eigenvectors())
126
126
  D = np.diag(np.sqrt(E.eigenvalues()))
127
+ if R is None:
128
+ # symmetric, so the left and right forms coincide
129
+ return cls(Q @ D @ Q.T)
127
130
  if form in ("left", "B"):
128
131
  return cls(Q @ D @ np.asarray(R))
129
- elif form in ("right", "C"):
130
- return cls(np.asarray(R) @ D @ Q.T)
131
132
  else:
132
- raise TypeError("Wrong form argument")
133
+ return cls(np.asarray(R) @ D @ Q.T)
133
134
 
134
135
 
135
136
  class Rotation2(DeformationGradient2):
@@ -158,6 +159,12 @@ class Rotation2(DeformationGradient2):
158
159
  coefs = U @ np.diag([1, np.linalg.det(U @ Vt)]) @ Vt
159
160
  self._coefs = tuple(coefs[0]), tuple(coefs[1])
160
161
 
162
+ def _derive(self, coefs):
163
+ # products such as R @ F or R + R are rotations only when orthogonal
164
+ if np.allclose(np.dot(np.transpose(coefs), coefs), np.eye(2)):
165
+ return type(self)._from_canonical(coefs)
166
+ return DeformationGradient2._from_canonical(coefs)
167
+
161
168
  def angle(self):
162
169
  """Return rotation angle."""
163
170
  return atan2d(self[1, 0], self[0, 0])
@@ -194,22 +194,23 @@ class DeformationGradient3(Matrix3):
194
194
  Keyword Args:
195
195
  R (Rotation3): rotation resolving the ambiguity, to be determined from
196
196
  independent data (e.g. paleomagnetic vectors or a known shear-plane
197
- orientation). Default is the identity, i.e. the simplest, purely
198
- coaxial solution.
197
+ orientation). Default None gives the simplest, purely coaxial
198
+ solution F = Q @ D @ Qᵗ (a symmetric stretch, no rotation).
199
199
 
200
200
  Returns:
201
201
  DeformationGradient3: recovered ``DeformationGradient3``.
202
202
  """
203
- if R is None:
204
- R = Rotation3()
203
+ if form not in ("left", "B", "right", "C"):
204
+ raise TypeError("Wrong form argument")
205
205
  Q = np.column_stack(E.eigenvectors())
206
206
  D = np.diag(np.sqrt(E.eigenvalues()))
207
+ if R is None:
208
+ # symmetric, so the left and right forms coincide
209
+ return cls(Q @ D @ Q.T)
207
210
  if form in ("left", "B"):
208
211
  return cls(Q @ D @ np.asarray(R))
209
- elif form in ("right", "C"):
210
- return cls(np.asarray(R) @ D @ Q.T)
211
212
  else:
212
- raise TypeError("Wrong form argument")
213
+ return cls(np.asarray(R) @ D @ Q.T)
213
214
 
214
215
 
215
216
  class Rotation3(DeformationGradient3):
@@ -235,6 +236,12 @@ class Rotation3(DeformationGradient3):
235
236
  coefs = U @ np.diag([1, 1, np.linalg.det(U @ Vt)]) @ Vt
236
237
  self._coefs = tuple(coefs[0]), tuple(coefs[1]), tuple(coefs[2])
237
238
 
239
+ def _derive(self, coefs):
240
+ # products such as R @ F or R + R are rotations only when orthogonal
241
+ if np.allclose(np.dot(np.transpose(coefs), coefs), np.eye(3)):
242
+ return type(self)._from_canonical(coefs)
243
+ return DeformationGradient3._from_canonical(coefs)
244
+
238
245
  def axisangle(self):
239
246
  """Return rotation as (axis, angle) tuple."""
240
247
 
@@ -171,16 +171,24 @@ _LINEAR_QUADRANT_RE = re.compile(
171
171
  )
172
172
 
173
173
 
174
+ def _fmt_deg(value, azimuth=False):
175
+ """Format angle rounded to whole degrees, without '-0' (and '360' for azimuths)."""
176
+ v = round(value) # int, so no negative zero; same round-half-even as :.0f
177
+ if azimuth:
178
+ v %= 360
179
+ return str(v)
180
+
181
+
174
182
  def azi2bearing(azi):
175
183
  """Format azimuth (0-360 degrees) as quadrant bearing string, e.g. 45 -> 'N45E'."""
176
184
  azi = azi % 360
177
185
  if azi <= 90:
178
- return f"N{azi:.0f}E"
186
+ return f"N{_fmt_deg(azi)}E"
179
187
  if azi <= 180:
180
- return f"S{180 - azi:.0f}E"
188
+ return f"S{_fmt_deg(180 - azi)}E"
181
189
  if azi <= 270:
182
- return f"S{azi - 180:.0f}W"
183
- return f"N{360 - azi:.0f}W"
190
+ return f"S{_fmt_deg(azi - 180)}W"
191
+ return f"N{_fmt_deg(360 - azi)}W"
184
192
 
185
193
 
186
194
  def bearing2azi(s):
@@ -228,7 +236,7 @@ def format_quadrant_planar(strike, dip):
228
236
  """
229
237
  dip_azi = (strike + 90) % 360
230
238
  display_strike = strike if (strike <= 90 or strike > 270) else strike - 180
231
- return f"{azi2bearing(display_strike)},{dip:.0f}{_dip_qualifier(dip_azi)}"
239
+ return f"{azi2bearing(display_strike)},{_fmt_deg(dip)}{_dip_qualifier(dip_azi)}"
232
240
 
233
241
 
234
242
  def parse_quadrant_linear(s):
@@ -242,18 +250,18 @@ def parse_quadrant_linear(s):
242
250
 
243
251
  def format_quadrant_linear(azi, inc):
244
252
  """Format (trend, plunge) as quadrant linear measurement string."""
245
- return f"{azi2bearing(azi)},{inc:.0f}"
253
+ return f"{azi2bearing(azi)},{_fmt_deg(inc)}"
246
254
 
247
255
 
248
256
  def format_planar(azi, inc):
249
257
  """Format a planar geo-tuple according to the active `apsg_conf.notation`."""
250
258
  if apsg_conf.notation == "quadrant":
251
259
  return format_quadrant_planar(azi, inc)
252
- return f"{azi:.0f}/{inc:.0f}"
260
+ return f"{_fmt_deg(azi, azimuth=True)}/{_fmt_deg(inc)}"
253
261
 
254
262
 
255
263
  def format_linear(azi, inc):
256
264
  """Format a linear geo-tuple according to the active `apsg_conf.notation`."""
257
265
  if apsg_conf.notation == "quadrant":
258
266
  return format_quadrant_linear(azi, inc)
259
- return f"{azi:.0f}/{inc:.0f}"
267
+ return f"{_fmt_deg(azi, azimuth=True)}/{_fmt_deg(inc)}"
@@ -7,6 +7,7 @@ from apsg.config import apsg_conf
7
7
  from apsg.helpers._helper import is_jsonable
8
8
  from apsg.helpers._math import acosd, atan2d, cosd, sind
9
9
  from apsg.helpers._notation import (
10
+ _fmt_deg,
10
11
  geo2vec_linear,
11
12
  vec2geo_linear_signed,
12
13
  )
@@ -213,7 +214,7 @@ class Vector2(Vector):
213
214
 
214
215
  def __repr__(self):
215
216
  n = apsg_conf.ndigits
216
- return f"Vector2({round(self.x, n):g}, {round(self.y, n):g})"
217
+ return f"Vector2({round(self.x, n) + 0.0:g}, {round(self.y, n) + 0.0:g})"
217
218
 
218
219
  def __len__(self):
219
220
  return 2
@@ -427,10 +428,11 @@ class Vector3(Vector):
427
428
  def __repr__(self):
428
429
  if apsg_conf.vec2geo:
429
430
  azi, inc = self.geo
430
- return f"V:{azi:.0f}/{inc:.0f}"
431
+ return f"V:{_fmt_deg(azi, azimuth=True)}/{_fmt_deg(inc)}"
431
432
  else:
432
433
  n = apsg_conf.ndigits
433
- return f"Vector3({round(self.x, n):g}, {round(self.y, n):g}, {round(self.z, n):g})"
434
+ x, y, z = (round(c, n) + 0.0 for c in (self.x, self.y, self.z))
435
+ return f"Vector3({x:g}, {y:g}, {z:g})"
434
436
 
435
437
  def __len__(self):
436
438
  return 3
@@ -12,6 +12,12 @@ from apsg.plotting._styles import FabricPlotStyle
12
12
  __all__ = ["FlinnPlot", "HsuPlot", "RamsayPlot", "VollmerPlot"]
13
13
 
14
14
 
15
+ def _flat(values):
16
+ """Join per-argument values (scalars or arrays) into one 1-D array, so that a
17
+ set is drawn with a single artist and a single legend entry."""
18
+ return np.concatenate([np.atleast_1d(v) for v in values])
19
+
20
+
15
21
  class FabricPlot:
16
22
  """
17
23
  Metaclas for Fabric plots
@@ -352,9 +358,9 @@ class VollmerPlot(FabricPlot):
352
358
  self.ax.plot(x, y, **kwargs)
353
359
 
354
360
  def _point(self, *args, **kwargs):
355
- P = [arg.P for arg in args]
356
- G = [arg.G for arg in args]
357
- R = [arg.R for arg in args]
361
+ P = _flat([arg.P for arg in args])
362
+ G = _flat([arg.G for arg in args])
363
+ R = _flat([arg.R for arg in args])
358
364
  self._triplot(P, G, R, **kwargs)
359
365
 
360
366
  def _path(self, *args, **kwargs):
@@ -470,8 +476,8 @@ class RamsayPlot(FabricPlot):
470
476
  ########################################
471
477
 
472
478
  def _point(self, *args, **kwargs):
473
- e23 = [arg.e23 for arg in args]
474
- e12 = [arg.e12 for arg in args]
479
+ e23 = _flat([arg.e23 for arg in args])
480
+ e12 = _flat([arg.e12 for arg in args])
475
481
 
476
482
  self.ax.plot(e23, e12, **kwargs)
477
483
 
@@ -585,8 +591,8 @@ class FlinnPlot(FabricPlot):
585
591
  ########################################
586
592
 
587
593
  def _point(self, *args, **kwargs):
588
- Ryz = [arg.Ryz for arg in args]
589
- Rxy = [arg.Rxy for arg in args]
594
+ Ryz = _flat([arg.Ryz for arg in args])
595
+ Rxy = _flat([arg.Rxy for arg in args])
590
596
 
591
597
  self.ax.plot(Ryz, Rxy, **kwargs)
592
598
 
@@ -683,8 +689,8 @@ class HsuPlot(FabricPlot):
683
689
  ########################################
684
690
 
685
691
  def _point(self, *args, **kwargs):
686
- lode = [arg.lode * np.pi / 6 for arg in args]
687
- eoct = [arg.eoct for arg in args]
692
+ lode = _flat([arg.lode for arg in args]) * np.pi / 6
693
+ eoct = _flat([arg.eoct for arg in args])
688
694
 
689
695
  self.ax.plot(lode, eoct, **kwargs)
690
696
 
@@ -6,6 +6,7 @@ from apsg.feature._container import (
6
6
  ConeSet,
7
7
  EllipsoidSet,
8
8
  FaultSet,
9
+ FeatureSet,
9
10
  FoliationSet,
10
11
  PairSet,
11
12
  Stress3Set,
@@ -476,8 +477,14 @@ class StereoNetArtistFactory:
476
477
 
477
478
  @staticmethod
478
479
  def create_tensor(*args, **kwargs):
479
- """Create stereonet tensor artist from Tensor3 data."""
480
- if all(isinstance(arg, Tensor3) for arg in args[:1]):
480
+ """Create stereonet tensor artist from Tensor3 data or a set of them."""
481
+ if args and (
482
+ isinstance(args[0], Tensor3)
483
+ or (
484
+ isinstance(args[0], FeatureSet)
485
+ and all(isinstance(t, Tensor3) for t in args[0])
486
+ )
487
+ ):
481
488
  return StereoNet_Tensor("create_tensor", *args, **kwargs)
482
489
  else:
483
490
  raise TypeError("Not valid arguments for Stereonet tensor")
@@ -709,7 +709,7 @@ class StereoNet:
709
709
  Plot principal planes or principal directions of tensor.
710
710
 
711
711
  Args:
712
- OrientationTensor3 like feature(s)
712
+ OrientationTensor3 like feature, or a set of them (e.g. ``EllipsoidSet``)
713
713
 
714
714
  Keyword Args:
715
715
  planes (bool): When True, plot principal planes, otherwise principal
@@ -1126,12 +1126,19 @@ class StereoNet:
1126
1126
  h.set_clip_path(self.primitive)
1127
1127
 
1128
1128
  def _tensor(self, *args, **kwargs):
1129
+ # a set is drawn as one feature set per principal axis, so each axis gets
1130
+ # a single legend entry
1131
+ if isinstance(args[0], Tensor3):
1132
+ fols = args[0].eigenfols()
1133
+ lins = args[0].eigenlins()
1134
+ else:
1135
+ fols = [FoliationSet([t.eigenfols()[k] for t in args[0]]) for k in range(3)]
1136
+ lins = [LineationSet([t.eigenlins()[k] for t in args[0]]) for k in range(3)]
1129
1137
  if kwargs.get("planes"):
1130
1138
  selkw = {
1131
1139
  key: kwargs[key]
1132
1140
  for key in kwargs.keys() & {"alpha", "ls", "lw", "label"}
1133
1141
  }
1134
- fols = args[0].eigenfols()
1135
1142
  if kwargs["color"] is None:
1136
1143
  del kwargs["color"]
1137
1144
  self._great_circle(fols[0], color=kwargs.get("color", "red"), **selkw)
@@ -1144,7 +1151,6 @@ class StereoNet:
1144
1151
  & {"alpha", "marker", "mec", "mew", "ms", "label"}
1145
1152
  }
1146
1153
  kwargs["ls"] = "none"
1147
- lins = args[0].eigenlins()
1148
1154
  if kwargs["color"] is None:
1149
1155
  del kwargs["color"]
1150
1156
  if selkw["label"] != "_tensor":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apsg
3
- Version: 2.0.3
3
+ Version: 2.0.5
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>
@@ -1274,3 +1274,26 @@ class TestJSONRoundtrip:
1274
1274
  j = a.to_json()
1275
1275
  a2 = feature_from_json(j)
1276
1276
  assert a == a2
1277
+
1278
+
1279
+ # Repr formatting: no "-0" and no "360"
1280
+
1281
+
1282
+ def test_repr_no_negative_zero():
1283
+ assert repr(-lin(219, 0)) == "L:39/0"
1284
+ assert repr(lin(Vector3(1, 1, -0.0))) == "L:45/0"
1285
+ assert repr(Vector3(1, 0, -0.0)) == "Vector3(1, 0, 0)"
1286
+ assert repr(Vector2(-0.0, 1)) == "Vector2(0, 1)"
1287
+
1288
+
1289
+ def test_repr_azimuth_wraps_to_zero():
1290
+ assert repr(lin(359.8, 10)) == "L:0/10"
1291
+ assert repr(fol(359.7, 30)) == "S:0/30"
1292
+ assert repr(dir2(359.7)) == "D:0"
1293
+ with apsg_conf_context(notation="rhr"):
1294
+ assert repr(fol(359.7, 30)) == "S:0/30"
1295
+
1296
+
1297
+ def test_repr_quadrant_no_negative_zero():
1298
+ with apsg_conf_context(notation="quadrant"):
1299
+ assert repr(-lin(219, 0)) == "L:N39E,0"
@@ -2648,3 +2648,22 @@ def test_beachball_style_factory():
2648
2648
  style = stereonet_styles.beachball(color="r")
2649
2649
  artist = style.create_artist(_rotated_stress(0))
2650
2650
  assert artist.kwargs["color"] == "r"
2651
+
2652
+
2653
+ def test_flinn_point_set_is_one_artist():
2654
+ es = ellipsoidset([ellipsoid.from_stretch(2 + 0.1 * i, 1, 0.5) for i in range(5)])
2655
+ fp = FlinnPlot()
2656
+ fp.point(es)
2657
+ fp.init_figure()
2658
+ fp._render()
2659
+ points = [line for line in fp.ax.lines if len(line.get_xdata()) == 5]
2660
+ assert len(points) == 1
2661
+
2662
+
2663
+ def test_stereonet_tensor_accepts_set():
2664
+ es = ellipsoidset([ellipsoid.from_stretch(2 + 0.1 * i, 1, 0.5) for i in range(5)])
2665
+ for planes in (True, False):
2666
+ s = StereoNet()
2667
+ s.tensor(es, planes=planes)
2668
+ s.init_figure()
2669
+ s._render()
@@ -1589,3 +1589,50 @@ class TestStressConvention:
1589
1589
  pytest.raises(ValueError, match="stress_convention"),
1590
1590
  ):
1591
1591
  Stress3.from_comp(xx=1)
1592
+
1593
+
1594
+ class TestCoaxialAndProducts:
1595
+ def test_rotation_left_matmul_gives_general_defgrad(self):
1596
+ R = rotation2.from_angle(30)
1597
+ F = defgrad2.from_ratio(3)
1598
+ assert isinstance(R @ F, DeformationGradient2)
1599
+ assert not isinstance(R @ F, Rotation2)
1600
+ assert np.allclose(np.asarray(R @ F), np.asarray(R) @ np.asarray(F))
1601
+
1602
+ def test_rotation_left_matmul_gives_general_defgrad_3d(self):
1603
+ R = rotation.from_axisangle(Lineation(120, 60), 50)
1604
+ F = defgrad.from_ratios(Rxy=2, Ryz=3)
1605
+ assert isinstance(R @ F, DeformationGradient3)
1606
+ assert not isinstance(R @ F, Rotation3)
1607
+
1608
+ def test_rotation_products_stay_rotations(self):
1609
+ R1 = rotation2.from_angle(30)
1610
+ R2 = rotation2.from_angle(20)
1611
+ assert isinstance(R1 @ R2, Rotation2)
1612
+ assert isinstance((R1 @ R2).T, Rotation2)
1613
+ assert isinstance(rotation.from_axisangle(Lineation(120, 60), 50).T, Rotation3)
1614
+
1615
+ def test_rotation_transform_with_defgrad(self):
1616
+ R = rotation2.from_angle(30)
1617
+ F = defgrad2.from_ratio(3)
1618
+ assert isinstance(R.transform(F), DeformationGradient2)
1619
+
1620
+ def test_ellipse_defgrad_is_purely_coaxial(self):
1621
+ # default is symmetric stretch Q D Qᵗ: F Fᵗ = E and F = Fᵗ
1622
+ E = ellipse.from_ratio(2)
1623
+ F = np.asarray(E.defgrad())
1624
+ assert np.allclose(F @ F.T, np.asarray(E))
1625
+ assert np.allclose(F, F.T)
1626
+
1627
+ def test_ellipsoid_defgrad_is_purely_coaxial(self):
1628
+ E = ellipsoid.from_ratios(Rxy=2, Ryz=3)
1629
+ F = np.asarray(E.defgrad())
1630
+ assert np.allclose(F @ F.T, np.asarray(E))
1631
+ assert np.allclose(F, F.T)
1632
+
1633
+ def test_explicit_rotation_is_respected(self):
1634
+ E = ellipse.from_ratio(2)
1635
+ R = rotation2.from_angle(40)
1636
+ F = np.asarray(E.defgrad(R=R))
1637
+ assert np.allclose(F @ F.T, np.asarray(E))
1638
+ assert not np.allclose(F, F.T)
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