Allow a season method with sources, where the pages differ

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-20 10:38:35 -07:00
1 parent cb6cdadd41
commit 667b2ea00f
4 files changed
+27 -6

No files matched your search

+1 -1
View File
@@ -139,7 +139,7 @@ Optional: a record without `[hike]` is valid. The table holds the facts a hiker
| `season` | string | The months in which the whole trail is usually walked, as a short phrase. Not the dates a park or hut is open, unless those set the walking season. `season` and `months` come together: one is never given without the other. For an estimated season (`season_basis = "estimate"`) the phrase is built from the months. | `"July to September"` |
| `months` | array of integers | The same season as month numbers, 1 to 12, for filtering: every month in which the whole trail, or a usual start, is normally walked. A month counts when about half of it or more is in season. Given whenever `season` is, and never without it. | `[7, 8, 9]` |
| `season_basis` | string | Required whenever `season` is present, and refused without it. Where the season came from, one of: `primary` (the page is published by the body that manages the trail, the trail's own association, or, for a route worked out by a hiker, that route's author); `sources` (no primary page, but two or more pages from different publishers agree on the season); `source` (one page that is not a primary one); `estimate` (no page states a season, so it is worked out from climate). A route author's stated season counts as `primary`. | `"primary"` |
| `season_method` | string | Required with `season_basis = "estimate"`, and refused otherwise. One sentence naming the method and its inputs: the dataset, the period, the points used and the rule version. | `"Estimated from 1991-2020 climate normals at 5 track points (rule version 1)."` |
| `season_method` | string | Required with `season_basis = "estimate"`, where it is one sentence naming the method and its inputs: the dataset, the period, the points used and the rule version. Allowed with `sources`, where it says in one sentence how the season was settled when the pages differ. Refused with `primary` and `source`. | `"Estimated from 1991-2020 climate normals at 5 track points (rule version 1)."` |
| `high_point` | string | Name of the highest point on the trail. | `"Mount Mansfield"` |
| `high_point_m` | integer | The elevation of the highest point in metres, rounded to the nearest metre (converted from feet where the source gives feet). May be given without `high_point` where a source states the elevation but not a name. | `1340` |
| `terrain` | array of strings | One to three of `alpine`, `forest`, `desert`, `coast`, `prairie`, `canyon`, `tundra`, `lakes`, `farmland`: the main kinds of country only. | `["forest"]` |
@@ -54,6 +54,9 @@ others, and the site says which.
how much it is trusted.
- Climate data may be used to estimate, with the known weakness that people do
hike in snow and cold.
- When pages disagree and none is the managing body, association or route
author, the season is set by judgement from all the pages and the climate
estimate, and the record says how.
## Design (designer's calls, for the owner to correct)
+9 -5
View File
@@ -41,14 +41,18 @@ def check_season(tid, hike, errors):
errors.append(
f"{tid}: hike.season_basis must be one of {', '.join(BASES)}, not {basis!r}")
if basis == "estimate":
if has_method:
method = hike.get("season_method")
if not isinstance(method, str) or not method.strip():
errors.append(f"{tid}: hike.season_method is required with season_basis \"estimate\"")
if basis not in ("estimate", "sources"):
errors.append(
f"{tid}: hike.season_method is only given with season_basis \"estimate\" "
"or \"sources\"")
elif not isinstance(method, str) or not method.strip():
errors.append(f"{tid}: hike.season_method must not be empty")
elif len(method) >= 400:
errors.append(f"{tid}: hike.season_method must be under 400 characters")
elif has_method:
errors.append(f"{tid}: hike.season_method is only given with season_basis \"estimate\"")
elif basis == "estimate":
errors.append(f"{tid}: hike.season_method is required with season_basis \"estimate\"")
naming_season = _naming(sources, "season")
if basis in ("primary", "source"):
+14
View File
@@ -80,6 +80,20 @@ class SeasonBasisTest(unittest.TestCase):
same = [src("Park Service"), src("Park Service", url="https://example.org/b")]
self.assertEqual(check(season_basis="source", source=same), [])
def test_method_is_allowed_with_sources_only_besides_estimate(self):
two = [src("Park Service"), src("Blog", url="https://example.org/b")]
ok = check(season_basis="sources", source=two,
season_method="The pages differ; set from both and the climate estimate.")
self.assertEqual(ok, [])
self.assertEqual(check(season_basis="sources", source=two), [])
for basis in ("primary", "source"):
errors = check(season_basis=basis, season_method="Some sentence.")
self.assertTrue(any("season_method" in e for e in errors), (basis, errors))
long = check(season_basis="sources", source=two, season_method="x" * 401)
self.assertTrue(any("400" in e for e in long), long)
blank = check(season_basis="sources", source=two, season_method=" ")
self.assertTrue(any("season_method" in e for e in blank), blank)
def test_primary_needs_a_naming_source(self):
errors = check(source=[src("Park Service", facts=("days",))])
self.assertTrue(errors)