@@ -307,3 +307,74 @@ def test_susceptibility_tensor(self, ellipsoid):
307307
308308 expected = [8 * " " + line for line in str (sus ).splitlines ()]
309309 assert matrix_lines == expected
310+
311+
312+ class TestRepr :
313+ """Test the ``Ellipsoid.__repr__`` method."""
314+
315+ a , b , c = 3 , 2 , 1
316+ yaw , pitch , roll = 73 , 14 , - 35
317+ center = (43.0 , - 72.0 , 105 )
318+
319+ @pytest .fixture
320+ def ellipsoid (self ):
321+ return Ellipsoid (
322+ self .a ,
323+ self .b ,
324+ self .c ,
325+ yaw = self .yaw ,
326+ pitch = self .pitch ,
327+ roll = self .roll ,
328+ center = self .center ,
329+ )
330+
331+ def test_triaxial (self , ellipsoid ):
332+ expected = (
333+ "harmonica.Ellipsoid("
334+ "a=3.0, b=2.0, c=1.0, center=(43.0, -72.0, 105.0), "
335+ "yaw=73.0, pitch=14.0, roll=-35.0"
336+ ")"
337+ )
338+ assert expected == repr (ellipsoid )
339+
340+ def test_density (self , ellipsoid ):
341+ ellipsoid .density = - 400
342+ expected = (
343+ "harmonica.Ellipsoid("
344+ "a=3.0, b=2.0, c=1.0, center=(43.0, -72.0, 105.0), "
345+ "yaw=73.0, pitch=14.0, roll=-35.0, density=-400.0"
346+ ")"
347+ )
348+ assert expected == repr (ellipsoid )
349+
350+ def test_susceptibility (self , ellipsoid ):
351+ ellipsoid .susceptibility = 0.3
352+ expected = (
353+ "harmonica.Ellipsoid("
354+ "a=3.0, b=2.0, c=1.0, center=(43.0, -72.0, 105.0), "
355+ "yaw=73.0, pitch=14.0, roll=-35.0, susceptibility=0.3"
356+ ")"
357+ )
358+ assert expected == repr (ellipsoid )
359+
360+ def test_remanent_mag (self , ellipsoid ):
361+ ellipsoid .remanent_mag = (12 , - 43 , 59 )
362+ expected = (
363+ "harmonica.Ellipsoid("
364+ "a=3.0, b=2.0, c=1.0, center=(43.0, -72.0, 105.0), "
365+ "yaw=73.0, pitch=14.0, roll=-35.0, remanent_mag=[ 12 -43 59]"
366+ ")"
367+ )
368+ assert expected == repr (ellipsoid )
369+
370+ def test_susceptibility_tensor (self , ellipsoid ):
371+ sus = np .array ([[1 , 0 , 0 ], [0 , 2 , 0 ], [0 , 0 , 3 ]])
372+ ellipsoid .susceptibility = sus
373+ expected = (
374+ "harmonica.Ellipsoid("
375+ "a=3.0, b=2.0, c=1.0, center=(43.0, -72.0, 105.0), "
376+ "yaw=73.0, pitch=14.0, roll=-35.0, "
377+ "susceptibility=[[1 0 0] [0 2 0] [0 0 3]]"
378+ ")"
379+ )
380+ assert expected == repr (ellipsoid )
0 commit comments