Skip to content

Commit bc695e4

Browse files
committed
Ellipsoid.from_name(unknown) raises KeyError instead of warning
1 parent b11460e commit bc695e4

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ filterwarnings = [
5555

5656
[tool.coverage.run]
5757
branch = true
58-
source = "src/"
58+
source = ["src/"]
5959

6060
[tool.coverage.report]
6161
# Regexes for lines to exclude from consideration

src/pymap3d/ellipsoid.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from math import sqrt
55
from dataclasses import dataclass, field
66
import sys
7-
import warnings
87
from typing import Dict # for Python < 3.9
98

109
if sys.version_info >= (3, 8):
@@ -155,10 +154,6 @@ def __init__(
155154
def from_name(cls, name: str) -> Ellipsoid | None:
156155
"""Create an Ellipsoid from a name."""
157156

158-
if name not in cls.models:
159-
warnings.warn(f"{name} model not implemented", stacklevel=2)
160-
return None
161-
162157
return cls(
163158
cls.models[name]["a"], cls.models[name]["b"], name=cls.models[name]["name"], model=name
164159
)

src/pymap3d/tests/test_ellipsoid.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ def test_reference(model, f):
4848
assert pm.Ellipsoid.from_name(model).flattening == approx(f)
4949

5050

51+
def test_bad_name():
52+
with pytest.raises(KeyError):
53+
pm.Ellipsoid.from_name("badname")
54+
55+
5156
def test_ellipsoid():
5257

5358
assert pm.ecef2geodetic(*xyz0, ell=pm.Ellipsoid.from_name("maupertuis")) == approx(

0 commit comments

Comments
 (0)