Use simpler form for doctests
This commit is contained in:
parent
e60a62a3df
commit
bfd93bd55b
14
read_in.py
14
read_in.py
|
@ -24,13 +24,13 @@ def read_single_elevation(dat: str) -> Result[int, str]:
|
||||||
string. Otherwise, returns the elevation in millimeters.
|
string. Otherwise, returns the elevation in millimeters.
|
||||||
|
|
||||||
>>> read_single_elevation("1.9333473e+02")
|
>>> read_single_elevation("1.9333473e+02")
|
||||||
Ok(val=193334)
|
Ok(193334)
|
||||||
|
|
||||||
>>> read_single_elevation("1.0")
|
>>> read_single_elevation("1.0")
|
||||||
Ok(val=1000)
|
Ok(1000)
|
||||||
|
|
||||||
>>> read_single_elevation("10.0m")
|
>>> read_single_elevation("10.0m")
|
||||||
Err(err='10.0m')
|
Err('10.0m')
|
||||||
"""
|
"""
|
||||||
return map_res(
|
return map_res(
|
||||||
meters_to_millimeters, # fuck floating points
|
meters_to_millimeters, # fuck floating points
|
||||||
|
@ -55,10 +55,10 @@ def read_elevation_line(line: str) -> Result[Iterator[int], Tuple[int, str]]:
|
||||||
in these columns will not be returned.
|
in these columns will not be returned.
|
||||||
|
|
||||||
>>> map_res(list, read_elevation_line("1.9e2 18e1 181 179.1 ignored 170.1 1.8e2 18i+2 20e1"))
|
>>> map_res(list, read_elevation_line("1.9e2 18e1 181 179.1 ignored 170.1 1.8e2 18i+2 20e1"))
|
||||||
Ok(val=[190000, 180000, 181000, 179100])
|
Ok([190000, 180000, 181000, 179100])
|
||||||
|
|
||||||
>>> map_res(list, read_elevation_line("1.9e2 18e 181 179.1 ignored 170.1 1.8e2 18i+2 20e1"))
|
>>> map_res(list, read_elevation_line("1.9e2 18e 181 179.1 ignored 170.1 1.8e2 18i+2 20e1"))
|
||||||
Err(err=(2, '18e'))
|
Err((2, '18e'))
|
||||||
"""
|
"""
|
||||||
return sequence([
|
return sequence([
|
||||||
map_err(
|
map_err(
|
||||||
|
@ -99,14 +99,14 @@ def read_elevations(lines: str) -> Result[Iterator[int], ErrorLocation]:
|
||||||
... 11 2.0 3e1 4 5 6 7 bwa 9 10
|
... 11 2.0 3e1 4 5 6 7 bwa 9 10
|
||||||
... 11 2.0 3e0 4 5 ign err 8 9 10
|
... 11 2.0 3e0 4 5 ign err 8 9 10
|
||||||
... '''))
|
... '''))
|
||||||
Ok(val=[1000, 2000, 3000, 4000, 5000, 11000, 2000, 30000, 4000, 5000, 11000, 2000, 3000, 4000, 5000])
|
Ok([1000, 2000, 3000, 4000, 5000, 11000, 2000, 30000, 4000, 5000, 11000, 2000, 3000, 4000, 5000])
|
||||||
|
|
||||||
>>> map_res(list, read_elevations('''
|
>>> map_res(list, read_elevations('''
|
||||||
... 1 2 3 4 5 6 7 8 9e 10
|
... 1 2 3 4 5 6 7 8 9e 10
|
||||||
... 11 ERR 3e1 4 5 6 7 bwa 9 10
|
... 11 ERR 3e1 4 5 6 7 bwa 9 10
|
||||||
... 11 2.0 3e0 4 5 ign err 8 9 10
|
... 11 2.0 3e0 4 5 ign err 8 9 10
|
||||||
... '''))
|
... '''))
|
||||||
Err(err=ErrorLocation(line_no=2, col_no=2, invalid_entry='ERR'))
|
Err(ErrorLocation(line_no=2, col_no=2, invalid_entry='ERR'))
|
||||||
"""
|
"""
|
||||||
return map_res(
|
return map_res(
|
||||||
chain.from_iterable,
|
chain.from_iterable,
|
||||||
|
|
Loading…
Reference in a new issue