Repository navigation
MNT: v1.14.0 final review fixes #1243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
94abad4
3b4c7ad
f42149a
d3e7bc7
60258f7
45f3508
86366b9
c9b99e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,28 +9,6 @@ | |
| from ..prints.parachute_prints import _ParachutePrints | ||
|
|
||
|
|
||
| def _is_a_height_trigger(trigger): | ||
| """Whether ``trigger`` is a number this class will read as a height. | ||
|
|
||
| ``numbers.Real`` rather than ``(int, float)`` so that NumPy scalars are | ||
| accepted: ``numpy.float64`` happens to subclass ``float``, but | ||
| ``numpy.int64`` and ``numpy.float32`` subclass neither and were refused | ||
| even though every arithmetic use of them here works. | ||
|
|
||
| What that spelling leaves out is what should be left out. ``numpy.bool_`` | ||
| and the complex types are not ``Real``, so they still fall through to the | ||
| error. ``bool`` is excluded by hand because it *is* an ``int``, and ``True`` | ||
| would otherwise be taken as a height of one metre. | ||
|
|
||
| This is the single definition of the numeric boundary. The height form and | ||
| the delay of a ``("time", t_deploy)`` trigger both use it, and | ||
| ``StochasticParachute`` validates the same triggers before a ``Parachute`` | ||
| is ever built and calls this rather than restating it, because the two | ||
| spellings drifted apart once already. | ||
| """ | ||
| return isinstance(trigger, Real) and not isinstance(trigger, bool) | ||
|
|
||
|
|
||
| class Parachute: | ||
| """Keeps information of the parachute, which is modeled as a hemispheroid. | ||
|
|
||
|
|
@@ -409,8 +387,8 @@ def wrapper(p, h, y, sensors, u_dot): | |
| self.triggerfunc = _make_wrapper(trigger) | ||
| return | ||
|
|
||
| # Numeric altitude trigger | ||
| if _is_a_height_trigger(trigger): | ||
| # Numeric altitude trigger. Real accepts NumPy numbers, bool is an int | ||
| if isinstance(trigger, Real) and not isinstance(trigger, bool): | ||
| self._trigger_falling_only = True | ||
|
|
||
| def triggerfunc(p, h, y, sensors, u_dot): # pylint: disable=unused-argument | ||
|
|
@@ -442,11 +420,8 @@ def triggerfunc(p, h, y, sensors, u_dot): # pylint: disable=unused-argument | |
| and isinstance(trigger[0], str) | ||
| and trigger[0].lower() == "time" | ||
| ): | ||
| # Same numeric boundary as a height, so the two forms cannot | ||
| # disagree about what counts as a number. Notably this refuses a | ||
| # string delay rather than quietly coercing it: float("3.0") would | ||
| # otherwise make ("time", "3.0") work by accident. | ||
| if not _is_a_height_trigger(trigger[1]): | ||
| # A number, as for a height. A string delay is refused, not converted. | ||
| if not isinstance(trigger[1], Real) or isinstance(trigger[1], bool): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (optional): The numeric test is now written twice with opposite polarity ( Scenario: someone widens one site (for example to accept another numeric type) and
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping the inline checks: two one-line expressions are easier to follow than a helper, and the trigger rules now live in |
||
| raise ValueError( | ||
| f"Unable to set the trigger function for parachute '{self.name}'. " | ||
| + "Time trigger delay must be a positive number of seconds, " | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (optional): Dropping the
python_version < '3.14'marker turns thebackgroundmap on for Python 3.14, but CHANGELOG.md has no entry for it. I checked that rasterio ships cp314 wheels and that CI already runs 3.14, so no packaging change is needed. Fix: add a changelog line for the 3.14 support ofcontextily.Scenario: users on 3.14 who read the old notebook note (now removed) or the changelog have no record of when the feature became available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the line is in the PR description under "Changelog lines for after the merge". It goes into CHANGELOG.md after the merge.