Skip to content

Commit f39053a

Browse files
author
Josh Sixsmith
committed
Added tests for UTM, mercator, equidistant cylindrical. Minor additions to other projection tests.
1 parent a43d4c8 commit f39053a

File tree

1 file changed

+100
-12
lines changed

1 file changed

+100
-12
lines changed

pygmt/tests/test_projections.py

+100-12
Original file line numberDiff line numberDiff line change
@@ -222,53 +222,68 @@ class TestMercatorCylindrical:
222222
Tests for the Mercator Cylindrical projection.
223223
"""
224224

225-
prj = projection.MercatorCylindrical(
225+
prj1 = projection.MercatorCylindrical(
226226
central_longitude=145, central_latitude=-35, width=12
227227
)
228+
prj2 = projection.MercatorCylindrical(width=12)
228229

229230
def test_default_unit(self):
230231
"Test the default value for the figure units"
231-
assert self.prj.unit == "c"
232+
assert self.prj1.unit == "c"
232233

233-
def test_string_conversion(self):
234+
def test_string_conversion1(self):
235+
"Test the string representation of the projection class"
236+
assert str(self.prj1) == "M145/-35/12c"
237+
238+
def test_string_conversion2(self):
234239
"Test the string representation of the projection class"
235-
assert str(self.prj) == "M145/-35/12c"
240+
assert str(self.prj2) == "M12c"
236241

237242

238243
class TestCylindricalStereographic:
239244
"""
240245
Tests for the Cylindrical Stereographic projection.
241246
"""
242247

243-
prj = projection.CylindricalStereographic(
248+
prj1 = projection.CylindricalStereographic(
244249
central_longitude=145, central_latitude=-35, width=12
245250
)
251+
prj2 = projection.CylindricalStereographic(width=12)
246252

247253
def test_default_unit(self):
248254
"Test the default value for the figure units"
249-
assert self.prj.unit == "c"
255+
assert self.prj1.unit == "c"
250256

251-
def test_string_conversion(self):
257+
def test_string_conversion1(self):
252258
"Test the string representation of the projection class"
253-
assert str(self.prj) == "Cyl_stere/145/-35/12c"
259+
assert str(self.prj1) == "Cyl_stere/145/-35/12c"
260+
261+
def test_string_conversion2(self):
262+
"Test the string representation of the projection class"
263+
assert str(self.prj2) == "Cyl_stere/12c"
254264

255265

256266
class TestCylindricalEqualArea:
257267
"""
258268
Tests for the Cylindrical Equal Area projection.
259269
"""
260270

261-
prj = projection.CylindricalEqualArea(
271+
prj1 = projection.CylindricalEqualArea(
262272
central_longitude=145, central_latitude=-35, width=12
263273
)
274+
prj2 = projection.CylindricalEqualArea(width=12)
264275

265276
def test_default_unit(self):
266277
"Test the default value for the figure units"
267-
assert self.prj.unit == "c"
278+
assert self.prj1.unit == "c"
268279

269-
def test_string_conversion(self):
280+
def test_string_conversion1(self):
270281
"Test the string representation of the projection class"
271-
assert str(self.prj) == "Y145/-35/12c"
282+
assert str(self.prj1) == "Y145/-35/12c"
283+
284+
def test_string_conversion2(self):
285+
"Test the string representation of the projection class"
286+
assert str(self.prj1) == "Y12c"
272287

273288

274289
class TestHammerEqualArea:
@@ -505,6 +520,7 @@ class TestObliqueMercator1:
505520
"""
506521
Tests for the Oblique Mercator projection (option 1).
507522
"""
523+
508524
prj1 = projection.ObliqueMercator1(
509525
central_longitude=145, central_latitude=-35, azimuth=45, width=12
510526
)
@@ -536,6 +552,7 @@ class TestObliqueMercator2:
536552
"""
537553
Tests for the Oblique Mercator projection (option 2).
538554
"""
555+
539556
prj1 = projection.ObliqueMercator2(
540557
central_longitude=145, central_latitude=-35, oblique_longitude=110, oblique_latitude=-20, width=12
541558
)
@@ -567,6 +584,7 @@ class TestObliqueMercator3:
567584
"""
568585
Tests for the Oblique Mercator projection (option 3).
569586
"""
587+
570588
prj1 = projection.ObliqueMercator3(
571589
central_longitude=145, central_latitude=-35, pole_longitude=110, pole_latitude=-20, width=12
572590
)
@@ -594,6 +612,76 @@ def test_string_conversion3(self):
594612
assert str(self.prj2) == "O145/-35/110/-20/12c+v"
595613

596614

615+
class TestTransverseMercator:
616+
"""
617+
Tests for the Transverse Mercator projection.
618+
"""
619+
620+
prj1 = projection.TransverseMercator(central_longitude=145, width=12)
621+
prj2 = projection.TransverseMercator(
622+
central_longitude=145, central_latitude=-35, width=12
623+
)
624+
625+
def test_default_unit(self):
626+
"Test the default value for the figure units"
627+
assert self.prj1.unit == "c"
628+
629+
def test_string_conversion1(self):
630+
"Test the string representation of the projection class"
631+
assert str(self.prj1) == "T145/12c"
632+
633+
def test_string_conversion2(self):
634+
"Test the string representation of the projection class"
635+
assert str(self.prj2) == "T145/-35/12c"
636+
637+
638+
class TestUniversalTransverseMercator:
639+
"""
640+
Tests for the Universal Transverse Mercator projection.
641+
"""
642+
643+
prj1 = projection.UniversalTransverseMercator(zone="-55", width=12)
644+
prj2 = projection.UniversalTransverseMercator(zone="55H", width=12)
645+
646+
def test_default_unit(self):
647+
"Test the default value for the figure units"
648+
assert self.prj1.unit == "c"
649+
650+
def test_string_conversion1(self):
651+
"Test the string representation of the projection class"
652+
assert str(self.prj1) == "U-55/12c"
653+
654+
def test_string_conversion2(self):
655+
"Test the string representation of the projection class"
656+
assert str(self.prj1) == "U55H/12c"
657+
658+
659+
class TestEquidistantCylindrical:
660+
"""
661+
Tests for the Equidistant Cylindrical projection.
662+
"""
663+
664+
prj1 = projection.EquidistantCylindrical(width=12)
665+
prj2 = projection.EquidistantCylindrical(central_longitude=145, width=12)
666+
prj3 = projection.EquidistantCylindrical(central_longitude=145, central_latitude=-35, width=12)
667+
668+
def test_default_unit(self):
669+
"Test the default value for the figure units"
670+
assert self.prj1.unit == "c"
671+
672+
def test_string_conversion1(self):
673+
"Test the string representation of the projection class"
674+
assert str(self.prj1) == "Q12c"
675+
676+
def test_string_conversion2(self):
677+
"Test the string representation of the projection class"
678+
assert str(self.prj2) == "Q145/12c"
679+
680+
def test_string_conversion3(self):
681+
"Test the string representation of the projection class"
682+
assert str(self.prj2) == "Q145/-35/12c"
683+
684+
597685
class TestPolar:
598686
"""
599687
Tests for the Polar projection.

0 commit comments

Comments
 (0)