-
Notifications
You must be signed in to change notification settings - Fork 225
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
clib.conversion: Remove the unused array_to_datetime function #3507
Merged
Merged
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
3661e54
Refactor vectors_to_arrays and deprecate the array_to_datetime function
seisman 20b9215
No need to use pd.api.types.is_string_dtype anymore
seisman 83673cf
Add tests for vectors_to_arrays
seisman 56a0841
Rename test_clib_conversion.py to test_clib_vectors_to_arrays.py
seisman 6338cde
Add one line of code back
seisman 1864556
Explicitly checking array.dtype.type
seisman 54160bf
Correctly skip the tests if pyarrow is not installed
seisman f4e1a5f
Explicitly specify how to convert pandas/pyarrow string dtype to nump…
seisman ed3be20
Ensure the resulting numpy dtypes are supported by GMT
seisman 8ab6c6c
Merge branch 'main' into remove/array-to-datetime
seisman e26afbf
Revert any changes that enhances the conversion process
seisman be3c93e
Rename array_to_datetime to _array_to_datetime
seisman 3d40687
Merge branch 'main' into remove/array-to-datetime
seisman 8f99a97
Some numpy dtypes like np.float16 can't be recognized by GMT
seisman 5ecf445
Merge branch 'main' into remove/array-to-datetime
seisman cd75c5c
Merge branch 'main' into remove/array-to-datetime
seisman 91e10a7
Merge branch 'main' into remove/array-to-datetime
seisman 47214e5
Merge branch 'main' into remove/array-to-datetime
seisman d8777e5
Check three variants for string dtypes
seisman 3286f08
Merge branch 'main' into remove/array-to-datetime
seisman 38b839a
Also check TypeError
seisman 76cb837
Merge branch 'main' into remove/array-to-datetime
seisman 9573fb6
Merge branch 'main' into remove/array-to-datetime
seisman bccae94
Remove the tests for pandas string dtypes
seisman d64c795
Merge branch 'main' into remove/array-to-datetime
seisman a410357
Remove the array_to_datetime function
seisman 53288dc
Merge branch 'main' into remove/array-to-datetime
seisman 765d6c3
Merge branch 'main' into remove/array-to-datetime
seisman d847eee
Merge branch 'main' into remove/array-to-datetime
seisman b0d4029
Merge branch 'main' into remove/array-to-datetime
seisman 9743bbf
Merge branch 'main' into remove/array-to-datetime
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
import pandas as pd | ||
import xarray as xr | ||
from pygmt.clib.conversion import ( | ||
array_to_datetime, | ||
dataarray_to_matrix, | ||
sequence_to_ctypes_array, | ||
strings_to_ctypes_array, | ||
|
@@ -934,11 +933,6 @@ def _check_dtype_and_dim(self, array: np.ndarray, ndim: int) -> int: | |
msg = f"Expected a numpy {ndim}-D array, got {array.ndim}-D." | ||
raise GMTInvalidInput(msg) | ||
|
||
# For 1-D arrays, try to convert unknown object type to np.datetime64. | ||
if ndim == 1 and array.dtype.type is np.object_: | ||
with contextlib.suppress(ValueError): | ||
array = array_to_datetime(array) | ||
Comment on lines
-937
to
-940
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. Moved to the |
||
|
||
# 1-D arrays can be numeric or text, 2-D arrays can only be numeric. | ||
valid_dtypes = DTYPES if ndim == 1 else DTYPES_NUMERIC | ||
if (dtype := array.dtype.type) not in valid_dtypes: | ||
|
@@ -993,7 +987,7 @@ def put_vector( | |
gmt_type = self._check_dtype_and_dim(vector, ndim=1) | ||
if gmt_type in {self["GMT_TEXT"], self["GMT_DATETIME"]}: | ||
if gmt_type == self["GMT_DATETIME"]: | ||
vector = np.datetime_as_string(array_to_datetime(vector)) | ||
vector = np.datetime_as_string(vector) | ||
vector_pointer = strings_to_ctypes_array(vector) | ||
else: | ||
vector_pointer = vector.ctypes.data_as(ctp.c_void_p) | ||
|
Oops, something went wrong.
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.
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.
These doctests are already covered by the tests in
test_clib_to_numpy.py