Skip to content

Document the return-tuple order of Points.reconstruct(time, return_array=True) #398

Description

@dietmarmuller

Points.reconstruct(time, return_array=True) returns a tuple of two arrays — but which one is longitudes and which is latitudes is not obvious from the current docstring. Both unpackings compile, and at most one is correct; the other silently swaps the coordinates and mis-plots reconstructed points into the wrong hemisphere with no exception.

In our tutorial suite, two notebooks happen to disagree:

# T05 — unpacks longitudes first
plon, plat = pt.reconstruct(time=t, return_array=True)

# T06 — unpacks latitudes first
end_lats, end_lons = ENDS.reconstruct(time=T, return_array=True)

Once the canonical order is confirmed we will fix whichever of T05 / T06 is wrong.

Request

  1. Document the order explicitly in the Points.reconstruct docstring. Something as short as "Returns: (lats, lons) when return_array=True" (or (lons, lats) — whichever it is) would do it. The pygplates convention is generally (lat, lon); if Points.reconstruct follows a different convention, that's especially worth flagging.

  2. (Optional, longer-term) Consider returning a structured object (a NamedTuple or small dataclass with .lats and .lons attributes) when return_array=True. That makes the order self-documenting at call sites and removes the silent failure mode entirely.

Happy to send a docstring PR once the canonical order is confirmed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions