Skip to content

Commit

Permalink
Merge pull request #86 from heathhenley/dev_hh_utm_np_arg_modify_update
Browse files Browse the repository at this point in the history
Make sure numpy northing array is not modified in place in `to_latlon`
  • Loading branch information
bartvanandel authored Feb 1, 2024
2 parents cca0788 + e9e005c commit 418d9c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 13 additions & 0 deletions test/test_utm.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,16 @@ def test_force_west():

def test_version():
assert isinstance(UTM.__version__, str) and "." in UTM.__version__


@pytest.mark.skipif(not use_numpy, reason="numpy not installed")
def test_numpy_args_not_modified():
TEST_EASTING = 387358.0
TEST_NORTHING = 8145567.0
easting = np.array(TEST_EASTING)
northing = np.array(TEST_NORTHING)
zone = 55
letter = "K"
UTM.to_latlon(easting, northing, zone, letter)
assert easting == TEST_EASTING
assert northing == TEST_NORTHING
5 changes: 1 addition & 4 deletions utm/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ def to_latlon(easting, northing, zone_number, zone_letter=None, northern=None, s
northern = (zone_letter >= 'N')

x = easting - 500000
y = northing

if not northern:
y -= 10000000
y = northing if northern else northing - 10000000

m = y / K0
mu = m / (R * M1)
Expand Down

0 comments on commit 418d9c4

Please sign in to comment.