DOC: document late-binding behavior of Transformer serialization methods#1604
Open
madhavcodez wants to merge 1 commit into
Open
DOC: document late-binding behavior of Transformer serialization methods#1604madhavcodez wants to merge 1 commit into
madhavcodez wants to merge 1 commit into
Conversation
Transformer.from_crs builds a PROJ late-binding transformer that defers selecting a concrete transformation until transform() is called. Until then to_wkt() and to_json() return None and to_json_dict() raises TypeError, none of which the docstrings mentioned, so downstream code that trusted the documented str/dict return crashed. Add a Notes section to to_wkt, to_json, and to_json_dict describing the late-binding case and the two workarounds (get_last_used_operation after transform, or TransformerGroup), qualify the Returns of to_wkt/to_json to allow None, and add a history entry. Closes pyproj4#1549
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
Transformerbuilt withTransformer.from_crs(...)is late-binding: PROJ does not select a concrete operation untiltransform()is called with coordinates. Until thento_json()andto_wkt()returnNone, andto_json_dict()raisesTypeError: the JSON object must be str, bytes or bytearray, not NoneType(#1549). The docstrings did not mention this, so theNoneand theTypeErrorlook like bugs.Changes
to_json,to_wkt, andto_json_dictdocstrings, including the two ways to obtain a serializable operation: callget_last_used_operation()aftertransform()(PROJ 9.1+), or build aTransformerGroupand serialize one of its candidate operations.to_json/to_wktreturnNonewhileto_json_dictraisesTypeError.Returnsofto_json/to_wktasstr or None.docs/history.rstentry.Docs only, no behavior change.
Closes #1549