Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/53 odds and ends #54

Merged
merged 6 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.8.2
current_version = 0.8.3
commit = True
tag = True

Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.3] - 2024-10-09

### Changed
- name of function in `nzshm_common.location` from `_lat_lon` to `lat_lon_by_id`
- import `location.location` functions into base package init for ease of use

### Fixed
- docstring for function `nzshm_common.location.location_by_id`

## [0.8.2] - 2024-09-21
### Added
- within_polygon helper function
Expand Down
2 changes: 1 addition & 1 deletion nzshm_common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = "GNS Science"
__email__ = '[email protected]'
__version__ = '0.8.2'
__version__ = '0.8.3'

from .location import location

Expand Down
1 change: 1 addition & 0 deletions nzshm_common/location/__init__.py
chrisbc marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .coded_location import CodedLocation, CodedLocationBin
from .location import get_location_list, get_location_list_names, get_locations, lat_lon_by_id, location_by_id
8 changes: 4 additions & 4 deletions nzshm_common/location/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}


def _lat_lon(_id) -> Optional[LatLon]:
def lat_lon_by_id(_id) -> Optional[LatLon]:
chrisbc marked this conversation as resolved.
Show resolved Hide resolved
chrisbc marked this conversation as resolved.
Show resolved Hide resolved
loc = location_by_id(_id)
if loc:
return LatLon(loc['latitude'], loc['longitude'])
Expand All @@ -83,7 +83,7 @@ def _load_csv(locations_filepath, resolution):

def location_by_id(location_code: str) -> Optional[Dict[str, Any]]:
"""
Get the CodedLocation for a location identified by an id.
Get the information for a location identified by an id.

Parameters:
location_code: the code (e.g. "WLG") for the location
Expand Down Expand Up @@ -125,10 +125,10 @@ def get_locations(locations: Iterable[str], resolution: float = DEFAULT_RESOLUTI
lat, lon = location_id.split('~')
coded_locations.append(CodedLocation(float(lat), float(lon), resolution))
elif location_by_id(location_id):
coded_locations.append(CodedLocation(*_lat_lon(location_id), resolution)) # type: ignore
coded_locations.append(CodedLocation(*lat_lon_by_id(location_id), resolution)) # type: ignore
elif LOCATION_LISTS.get(location_id):
location_ids = LOCATION_LISTS[location_id]["locations"]
coded_locations += [CodedLocation(*_lat_lon(_id), resolution) for _id in location_ids] # type: ignore
coded_locations += [CodedLocation(*lat_lon_by_id(_id), resolution) for _id in location_ids] # type: ignore
else:
try:
coded_locations += [CodedLocation(*loc, resolution) for loc in load_grid(location_id)] # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nzshm-common"
version = "0.8.2"
version = "0.8.3"
homepage = "https://github.com/GNS-Science/nzshm-common-py"
description = "A small pure python library for shared NZ NSHM data like locations."
authors = ["GNS Science <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ def get_lat_lon(id):


def test_missing_lat_lon_returns_None():
assert location._lat_lon("missingid") is None, "An unknown ID should return a None"
assert location.lat_lon_by_id("missingid") is None, "An unknown ID should return a None"