-
Notifications
You must be signed in to change notification settings - Fork 224
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
pyarrow: Check compatibility of pyarrow.array with string type #2933
Changes from 4 commits
1f32a7c
4c4e064
07fbca6
d379e46
cfda386
0a6cda5
f59f93c
757da24
17c1e9c
0105d64
3ad0c86
4bea288
371174a
b588730
faf2065
b2efbb4
9fd77dc
ccf4eff
44d01ed
a927202
7b00248
7dc353b
ce76152
ef431af
acaf350
6ad6eb9
d88accd
265132e
edb3438
8172102
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,31 @@ | |
from pygmt import clib | ||
from pygmt.exceptions import GMTCLibError | ||
from pygmt.helpers import GMTTempFile | ||
from pygmt.helpers.testing import skip_if_no | ||
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. Also need to revert changes in this PR, since the low-level function 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. Ok, just to document things, the way we are intending pyarrow.string inputs to go through high-level modules like
For the record, the original intention in this PR, mostly in commit d379e46, was to let |
||
|
||
try: | ||
import pyarrow as pa | ||
except ImportError: | ||
pa = None | ||
|
||
|
||
@pytest.mark.benchmark | ||
def test_put_strings(): | ||
@pytest.mark.parametrize( | ||
("array_func", "dtype"), | ||
[ | ||
pytest.param(np.array, {"dtype": str}, id="str"), | ||
pytest.param( | ||
getattr(pa, "array", None), | ||
{"type": pa.string()}, | ||
marks=skip_if_no(package="pyarrow"), | ||
id="pyarrow", | ||
), | ||
], | ||
) | ||
def test_put_strings(array_func, dtype): | ||
""" | ||
Check that assigning a numpy array of dtype str to a dataset works. | ||
Check that assigning a numpy array of dtype str, or a pyarrow.StringArray to a | ||
dataset works. | ||
""" | ||
with clib.Session() as lib: | ||
dataset = lib.create_data( | ||
|
@@ -24,7 +43,7 @@ def test_put_strings(): | |
) | ||
x = np.array([1, 2, 3, 4, 5], dtype=np.int32) | ||
y = np.array([6, 7, 8, 9, 10], dtype=np.int32) | ||
strings = np.array(["a", "bc", "defg", "hijklmn", "opqrst"], dtype=str) | ||
strings = array_func(["a", "bc", "defg", "hijklmn", "opqrst"], **dtype) | ||
lib.put_vector(dataset, column=lib["GMT_X"], vector=x) | ||
lib.put_vector(dataset, column=lib["GMT_Y"], vector=y) | ||
lib.put_strings( | ||
|
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.
Need to figure out how to fix the
mypy
type errors for an optional import 🤔