Skip to content

Commit

Permalink
new tests for negative lat
Browse files Browse the repository at this point in the history
  • Loading branch information
anacmontoya committed Jun 30, 2024
1 parent 7a3a5c0 commit b232cc9
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions tests/io/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import numpy as np

from io import StringIO

Check failure on line 9 in tests/io/test_text.py

View workflow job for this annotation

GitHub Actions / Flake8

[ruff] reported by reviewdog 🐶 F401 [*] `io.StringIO` imported but unused Raw Output: tests/io/test_text.py:9:16: F401 [*] `io.StringIO` imported but unused

from metpy.cbook import get_test_data
from metpy.io import parse_wpc_surface_bulletin
from metpy.io.text import _decode_coords

Check failure on line 13 in tests/io/test_text.py

View workflow job for this annotation

GitHub Actions / Flake8

[ruff] reported by reviewdog 🐶 F401 [*] `metpy.io.text._decode_coords` imported but unused Raw Output: tests/io/test_text.py:13:27: F401 [*] `metpy.io.text._decode_coords` imported but unused

Check notice

Code scanning / CodeQL

Unused import Note test

Import of '_decode_coords' is not used.
Expand Down Expand Up @@ -64,22 +66,36 @@ def test_parse_wpc_surface_bulletin():
assert all(df.valid == datetime(2021, 6, 28, 18, 0, 0))


def test_negative_lat_highres():
def test_negative_lat_highres():
"""Test decoding of high res coordinates with negative latitude."""

Check failure on line 70 in tests/io/test_text.py

View workflow job for this annotation

GitHub Actions / Flake8

[ruff] reported by reviewdog 🐶 D202 [*] No blank lines allowed after function docstring (found 1) Raw Output: tests/io/test_text.py:70:5: D202 [*] No blank lines allowed after function docstring (found 1)
coord = '-4920344'
lon, lat = _decode_coords(coord)
assert lon == -34.4
assert lat == -49.2

from io import BytesIO
import shapely.geometry as sgeom

sample = BytesIO(b'''

Check failure on line 75 in tests/io/test_text.py

View workflow job for this annotation

GitHub Actions / Flake8

[ruff] reported by reviewdog 🐶 Q001 [*] Single quote multiline found but double quotes preferred Raw Output: tests/io/test_text.py:75:22: Q001 [*] Single quote multiline found but double quotes preferred
178

Check failure on line 76 in tests/io/test_text.py

View workflow job for this annotation

GitHub Actions / Flake8

[ruff] reported by reviewdog 🐶 W291 Trailing whitespace Raw Output: tests/io/test_text.py:76:4: W291 Trailing whitespace
ASUS02 KWBC 281800
CODSUS

Check failure on line 79 in tests/io/test_text.py

View workflow job for this annotation

GitHub Actions / Flake8

[ruff] reported by reviewdog 🐶 W293 Blank line contains whitespace Raw Output: tests/io/test_text.py:79:1: W293 Blank line contains whitespace
CODED SURFACE FRONTAL POSITIONS
NWS WEATHER PREDICTION CENTER COLLEGE PARK MD
342 PM EDT MON JUN 28 2021

Check failure on line 83 in tests/io/test_text.py

View workflow job for this annotation

GitHub Actions / Flake8

[ruff] reported by reviewdog 🐶 W293 Blank line contains whitespace Raw Output: tests/io/test_text.py:83:1: W293 Blank line contains whitespace
VALID 062818Z
HIGHS 1022 -3961069 1020 -3851069 1026 3750773 1022 4430845 1019 5520728 1018
''')
df = parse_wpc_surface_bulletin(sample)
assert df.geometry[0] == sgeom.Point([-106.9, -39.6])


def test_negative_lat():
"""Test decoding of coordinates with negative latitude."""

Check failure on line 92 in tests/io/test_text.py

View workflow job for this annotation

GitHub Actions / Flake8

[ruff] reported by reviewdog 🐶 D202 [*] No blank lines allowed after function docstring (found 1) Raw Output: tests/io/test_text.py:92:5: D202 [*] No blank lines allowed after function docstring (found 1)
coord_4_digit = '-2378'
lon, lat = _decode_coords(coord_4_digit)
assert lon == -78
assert lat == -23

coord_5_digit = '-65134'
lon, lat = _decode_coords(coord_5_digit)
assert lon == -134
assert lat == -65

from io import BytesIO
import shapely.geometry as sgeom

sample = BytesIO(b'''12HR PROG VALID xxxxxxZ

Check failure on line 97 in tests/io/test_text.py

View workflow job for this annotation

GitHub Actions / Flake8

[ruff] reported by reviewdog 🐶 Q001 [*] Single quote multiline found but double quotes preferred Raw Output: tests/io/test_text.py:97:22: Q001 [*] Single quote multiline found but double quotes preferred
HIGHS -351 -3985 -4046 -38117 -7510
''')
df = parse_wpc_surface_bulletin(sample)
assert df.geometry[0] == sgeom.Point([-51, -3])

0 comments on commit b232cc9

Please sign in to comment.