Skip to content

Commit

Permalink
Ellipsoid.from_name(unknown) raises KeyError instead of warning
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Feb 26, 2023
1 parent b11460e commit bc695e4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ filterwarnings = [

[tool.coverage.run]
branch = true
source = "src/"
source = ["src/"]

[tool.coverage.report]
# Regexes for lines to exclude from consideration
Expand Down
5 changes: 0 additions & 5 deletions src/pymap3d/ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from math import sqrt
from dataclasses import dataclass, field
import sys
import warnings
from typing import Dict # for Python < 3.9

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

if name not in cls.models:
warnings.warn(f"{name} model not implemented", stacklevel=2)
return None

return cls(
cls.models[name]["a"], cls.models[name]["b"], name=cls.models[name]["name"], model=name
)
5 changes: 5 additions & 0 deletions src/pymap3d/tests/test_ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def test_reference(model, f):
assert pm.Ellipsoid.from_name(model).flattening == approx(f)


def test_bad_name():
with pytest.raises(KeyError):
pm.Ellipsoid.from_name("badname")


def test_ellipsoid():

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

0 comments on commit bc695e4

Please sign in to comment.