GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||
GeezerVison is showing github.com — clib.Session.virtualfile_from_vectors: Now takes a sequence of vectors as its single argument (Passing multiple arguments will be unsupported in v0.16.0) by seisman · Pull Request #3522 · GenericMappingTools/pygmt Conversation
|
| # "_data" is the data that will be passed to the _virtualfile_from function. | ||
| # "_data" defaults to "data" but should be adjusted for some cases. | ||
| _data = data | ||
| match kind: | ||
| case "arg" | "file" | "geojson" | "grid" | "image" | "stringio": |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe just put _data = data in the case _ below? I'd actually prefer if we make it more explicit like:
case "arg" | "file" | "geojson" | "grid" | "stringio":
_data = data
So that if there's a new kind in the future, we know to add it explicitly.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'd actually prefer if we make it more explicit like:
case "arg" | "file" | "geojson" | "grid" | "stringio": _data = dataSo that if there's a new
kindin the future, we know to add it explicitly.
We can't do it like this, because we're currently writing case statements like case "image" if data.dtype != "uint8":, which only catches the case when kind="image" and data.dtype != "uint8".
We can refactor the codes to:
case "arg" | "file" | "geojson" | "grid" | "stringio":
_data = data
case "image":
_data = data
if data.dtype != "uint8":
# do something
case "matrix":
_data = data
if data.dtype.kind not in "iuf":
# do something
or
case "arg" | "file" | "geojson" | "grid" | "stringio":
_data = data
case "image" if data.dtype != "uint8":
raise ...
case "matrix" if data.dtype.kind not in "iuf":
...
case _:
_data = data # this is necessary to catch cases like kind="matrix" and dtype in "iuf"
I still prefer the current codes, which set _data to data by default and the match-case statements only need to deal with exceptions.
So that if there's a new
kindin the future, we know to add it explicitly.
If there is a new kind in the future, _data=data is still the default. If needs special handling and we forget to add it, then the related tests will fail anyway.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, that makes sense, let's keep _data = data at the top then.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Getting very close to (finally) implementing #1076!
I've changed the label from 'maintenance' to 'deprecation'. Should we mention this is scheduled for removal in PyGMT v0.16.0?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.