Skip to content

types (module)

types

This module contains common type definitions.

When imported from an external package, the types defined here should also be available at the top level of the package, e.g.:

>>> from nzshm_common import LatLon

LatLon

Bases: NamedTuple

A lightweight type for (latitude, longitude) float pairs.

This is a named tuple with latitude and longitude fields.

Examples:

>>> wlg = LatLon(-41.3, 174.78)
>>> wlg
LatLon(latitude=-41.3, longitude=174.78)
>>> wlg.latitude
-41.3
>>> wlg[0]
-41.3
Source code in nzshm_common/location/types.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class LatLon(NamedTuple):
    """
    A lightweight type for `(latitude, longitude)` float pairs.

    This is a named tuple with latitude and longitude fields.

    Examples:
        ```py
        >>> wlg = LatLon(-41.3, 174.78)
        >>> wlg
        LatLon(latitude=-41.3, longitude=174.78)
        >>> wlg.latitude
        -41.3
        >>> wlg[0]
        -41.3
        ```
    """

    latitude: float
    longitude: float