Skip to content

Commit

Permalink
fix test get_combined_vertical_prop_in_latitude_range
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimmel committed Jan 23, 2025
1 parent 002787b commit 741337a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
3 changes: 3 additions & 0 deletions openskistats/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ def set_latitude_metrics() -> None:

rlbh = RunLatitudeBearingHistogram()
set_variables(
latitude__between_35_50__combined_vertical_prop=rlbh.get_combined_vertical_prop_in_latitude_range(
35, 50
),
latitude__between_40_50__combined_vertical_prop=rlbh.get_combined_vertical_prop_in_latitude_range(
40, 50
),
Expand Down
7 changes: 4 additions & 3 deletions openskistats/plot_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def get_combined_vertical_prop_in_latitude_range(
latitude_lower_bound, latitude_upper_bound = sorted(
[latitude_lower_bound, latitude_upper_bound]
)
return float(
metric_df = (
self.load_and_filter_runs_pl()
.with_columns(
latitude_in_window=pl.col.latitude.is_between(
Expand All @@ -124,9 +124,10 @@ def get_combined_vertical_prop_in_latitude_range(
)
.collect()
.filter(pl.col("latitude_in_window"))
.select("combined_vertical_prop")
.item()
)
if metric_df.is_empty():
return 0.0
return float(metric_df.select("combined_vertical_prop").item())

def _get_agg_metrics(self) -> list[pl.Expr]:
return [
Expand Down
37 changes: 22 additions & 15 deletions openskistats/tests/data/_variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ hemisphere:
run_count: 1.0
segment_count: 1.0
ski_areas_count: 1.0
latitude:
between_35_50:
combined_vertical_prop: 1.0
between_40_50:
combined_vertical_prop: 1.0
between_45_58:
combined_vertical_prop: 0.0
openskimap:
countries:
counts:
Expand All @@ -17,11 +24,11 @@ openskimap:
01_raw_by_geometry:
LineString: 5
download:
checksum_sha256: 9252019438acbfaa737466cf73d50659b9c0728e8defbec5d05fb74544ecec04
compressed_size_mb: 6.891986846923828
content_size_mb: 99.43077945709229
downloaded: '2024-12-27T19:57:31+00:00'
last_modified: '2024-12-27T02:26:14+00:00'
checksum_sha256: bb31f5fc7ae7754a40b7684e1268fdd46d8ec03a83dbe8e4b2a03671e78d324f
compressed_size_mb: 6.950000762939453
content_size_mb: 99.65091800689697
downloaded: '2025-01-14T20:31:51+00:00'
last_modified: '2025-01-14T02:34:53+00:00'
relative_path: data/openskimap/lifts.geojson.xz
url: https://tiles.openskimap.org/geojson/lifts.geojson
runs:
Expand All @@ -44,11 +51,11 @@ openskimap:
vertical:
04_downhill_clean: 1793.500244140625
download:
checksum_sha256: 4549037d1c8c60f91e1963363940ba3e6ca51752ddde7f181cf906e57a027f04
compressed_size_mb: 92.48648071289062
content_size_mb: 894.6473083496094
downloaded: '2024-12-27T19:57:55+00:00'
last_modified: '2024-12-27T02:26:16+00:00'
checksum_sha256: 881f6cae0da5db71cb3fa3c54a31f355c1aa8101cb0e48f8fc154323c2272141
compressed_size_mb: 93.12430191040039
content_size_mb: 901.8432960510254
downloaded: '2025-01-14T20:32:31+00:00'
last_modified: '2025-01-14T02:34:56+00:00'
relative_path: data/openskimap/runs.geojson.xz
url: https://tiles.openskimap.org/geojson/runs.geojson
segments:
Expand All @@ -64,10 +71,10 @@ openskimap:
04_downhill_operating_1_lift_us: 2
05_downhill_operating_5_lift: 0
download:
checksum_sha256: 9ba4f0091d8978ade54f83be9d3fc379703eaf307835b5e32d2d0beac59ee940
compressed_size_mb: 2.4046401977539062
content_size_mb: 15.647958755493164
downloaded: '2024-12-27T19:57:49+00:00'
last_modified: '2024-12-27T02:26:13+00:00'
checksum_sha256: 50cda86fbbfab74b1987114b2c118db4b96ba027413c348c10c30d61ca91b0b8
compressed_size_mb: 2.4207916259765625
content_size_mb: 15.78530216217041
downloaded: '2025-01-14T20:32:23+00:00'
last_modified: '2025-01-14T02:34:53+00:00'
relative_path: data/openskimap/ski_areas.geojson.xz
url: https://tiles.openskimap.org/geojson/ski_areas.geojson

0 comments on commit 741337a

Please sign in to comment.