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.conversion._to_numpy: Add tests for pandas.Series with pyarrow numeric dtypes by seisman · Pull Request #3585 · GenericMappingTools/pygmt Conversation
|
| # PyArrow dtypes can be specified using the following formats: | ||
| # | ||
| # - Prefixed with the name of the dtype and "[pyarrow]" (e.g., "int8[pyarrow]") | ||
| # - Specified using ``ArrowDType`` (e.g., "pd.ArrowDtype(pa.int8())") |
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.
We can't use pd.ArrowDtype(pa.int8()) here because pa is not defined when pyarrow is not installed. So we have to use the string aliases.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| pytest.param("float64[pyarrow]", np.float64, id="float64[pyarrow]"), | ||
| ], | ||
| ) | ||
| def test_to_numpy_pandas_series_pyarrow_dtypes_numeric(dtype, expected_dtype): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This test is exactly the same as the test test_to_numpy_pandas_series_numpy_dtypes_numeric above, but I don't think we should merge them into a single test.
To merge them into a single test, we have to change the pytest.param to
pytest.param("float64[pyarrow]", np.float64, id="float64[pyarrow]", marks=skip_if_no(package="pyarrow")),
which is too long to fit in one line and will make the pytest.params too long to read.
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.
Managed to fit it into a single test like so:
from pygmt.helpers.testing import skip_if_no pa_marks = {"marks": skip_if_no(package="pyarrow")} @pytest.mark.parametrize( ("dtype", "expected_dtype"), [ ..., pytest.param("int8[pyarrow]", np.int8, id="int8[pyarrow]", **pa_marks), pytest.param("int16[pyarrow]", np.int16, id="int16[pyarrow]", **pa_marks), pytest.param("int32[pyarrow]", np.int32, id="int32[pyarrow]", **pa_marks), pytest.param("int64[pyarrow]", np.int64, id="int64[pyarrow]", **pa_marks), pytest.param("uint8[pyarrow]", np.uint8, id="uint8[pyarrow]", **pa_marks), pytest.param("uint16[pyarrow]", np.uint16, id="uint16[pyarrow]", **pa_marks), pytest.param("uint32[pyarrow]", np.uint32, id="uint32[pyarrow]", **pa_marks), pytest.param("uint64[pyarrow]", np.uint64, id="uint64[pyarrow]", **pa_marks), pytest.param("float16[pyarrow]", np.float16, id="float16[pyarrow]", **pa_marks), pytest.param("float32[pyarrow]", np.float32, id="float32[pyarrow]", **pa_marks), pytest.param("float64[pyarrow]", np.float64, id="float64[pyarrow]", **pa_marks), ], )
The longest line is just under 88 characters.
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 a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nice changes. We probably should merge this PR into #3584, so that we can test all pandas dtypes (including pyarrow-backed) in a single PR.
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.
Sure, I see that this branch is targetting to_numpy/pandas_numeric/#3584, so you can merge this in 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.
| # In PyArrow, array types can be specified in two ways: | ||
| # | ||
| # - Using string aliases (e.g., "int8") | ||
| # - Using pyarrow.DataType (e.g., ``pa.int8()``) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Again, we can't use pa.int8() here because pa is undefined if pyarrow is not installed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
70341af to
e09aa75
Compare
This reverts commit 50e6872.
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.