Repository navigation
pyarrow: Check compatibility of pyarrow.array and pyarrow.table with numeric and timestamp types - #2864
Draft
weiji14 wants to merge 9 commits into
Draft
pyarrow: Check compatibility of pyarrow.array and pyarrow.table with numeric and timestamp types#2864weiji14 wants to merge 9 commits into
weiji14 wants to merge 9 commits into
Conversation
Install pyarrow as an optional dependency, and ensure that pyarrow.array objects with int64 and timestamp types can be read by pygmt.info.
Ensure that pyarrow.table objects can be passed into pygmt functions like blockm, info, nearneighbor, project, triangulate and xyz2grd.
Member
Author
|
/format |
weiji14
commented
Dec 9, 2023
Comment on lines
+165
to
+178
| pytest.param( | ||
| getattr(pa, "table", None), | ||
| "vector memory", | ||
| marks=td.skip_if_no(package="pyarrow"), | ||
| ), | ||
| ], | ||
| ) | ||
| def test_info_2d_array(array_func, expected_memory): | ||
| """ | ||
| Make sure info works on 2-D numpy.ndarray inputs. | ||
| Make sure info works on 2-D numpy.ndarray and pyarrow.table inputs. | ||
| """ | ||
| table = np.loadtxt(POINTS_DATA) | ||
| table = array_func(pd.read_csv(POINTS_DATA, sep=" ", header=None)) | ||
| output = info(data=table) | ||
| expected_output = ( | ||
| "<matrix memory>: N = 20 <11.5309/61.7074> <-2.9289/7.8648> <0.1412/0.9338>\n" | ||
| ) | ||
| expected_output = f"<{expected_memory}>: N = 20 <11.5309/61.7074> <-2.9289/7.8648> <0.1412/0.9338>\n" |
Member
Author
There was a problem hiding this comment.
Note that pyarrow.table goes through put_vector rather than put_matrix, because pyarrow.table is more akin to pandas.DataFrame (which allows for columns with different dtypes) than a numpy.array object (which only allows for one dtype).
Done by casting the pyarrow.TimestampScalar to a string first, before letting pd.to_datetime do the formatting. Have added a new parametrized unit test to test_solar_set_terminator_datetime with pyarrow and pd.Timestamp array_func to test this.
CodSpeed Performance ReportMerging #2864 will degrade performances by 6.62%Falling back to comparing Summary
Benchmarks breakdown
|
This branch has not been deployed
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.
Description of proposed changes
Check that
pyarrow.arrayandpyarrow.tableobjects of various types (uint/int/timestamp) can be passed to PyGMT modules/functions.TODO:
pyarrow.arrayby adding parametrized tests topygmt.infopyarrow.tableto unit tests that already have the@pytest.mark.parametrize("array_func", ...)pyarrow.arrayobjects can be used in place ofnumpy.arraysolar's terminator_datetime parameter to accept apyarrow.TimestampScalarinputAddresses #2800 (comment), part of #2800.
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.Slash Commands
You can write slash commands (
/command) in the first line of a comment to performspecific operations. Supported slash commands are:
/format: automatically format and lint the code/test-gmt-dev: run full tests on the latest GMT development version