From 2c59326fef0aba74f060e26cd922e308c595b340 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 5 Nov 2024 15:44:18 +0800 Subject: [PATCH 01/18] Add docs for the supported numeric dtypes --- doc/techref/array_dtypes.md | 35 +++++++++++++++++++++++++++++++++++ doc/techref/index.md | 1 + 2 files changed, 36 insertions(+) create mode 100644 doc/techref/array_dtypes.md diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md new file mode 100644 index 00000000000..6d9584b7d36 --- /dev/null +++ b/doc/techref/array_dtypes.md @@ -0,0 +1,35 @@ +# Supported Array Dtypes + +PyGMT uses NumPy arrays to store data and passes them to the GMT C library. In this way, +PyGMT can support a wide range of dtypes. This page documents array dtypes supported by +PyGMT. + +## Numeric Dtypes + +For 1-D and 2-D arrays, PyGMT supports most numeric dtypes provided by NumPy, pandas, and +PyArrow. + +**Signed Integers:** + +- `numpy.int8`, `numpy.int16`, `numpy.int32`, `numpy.int64` +- `pandas.Int8`, `pandas.Int16`, `pandas.Int32`, `pandas.Int64` +- `pyarrow.int8`, `pyarrow.int16`, `pyarrow.int32`, `pyarrow.int64` + +**Unsigned Integers:** + +- `numpy.uint8`, `numpy.uint16`, `numpy.uint32`, `numpy.uint64` +- `pandas.UInt8`, `pandas.UInt16`, `pandas.UInt32`, `pandas.UInt64` +- `pyarrow.uint8`, `pyarrow.uint16`, `pyarrow.uint32`, `pyarrow.uint64` + +**Floating-point numbers:** + +- `numpy.float32`, `numpy.float64` +- `pandas.Float32`, `pandas.Float64` +- `pyarrow.float32`, `pyarrow.float64` + +For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit unsigned +intergers (i.e., `numpy.uint8`) are supported. + +## String Dtypes + +## Datetime Dtypes diff --git a/doc/techref/index.md b/doc/techref/index.md index bbba3ead6b4..96e75e0b493 100644 --- a/doc/techref/index.md +++ b/doc/techref/index.md @@ -8,6 +8,7 @@ visit the {gmt-docs}`GMT Technical Reference `. ```{toctree} :maxdepth: 1 +array_dtypes.md projections.md fonts.md patterns.md From 466ef40c48bfef4a0d0061f96924875ce487c7bc Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 11 Nov 2024 10:18:13 +0800 Subject: [PATCH 02/18] Add notes about float16 and longdouble --- doc/techref/array_dtypes.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 6d9584b7d36..99ee051d3e3 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -6,8 +6,8 @@ PyGMT. ## Numeric Dtypes -For 1-D and 2-D arrays, PyGMT supports most numeric dtypes provided by NumPy, pandas, and -PyArrow. +For 1-D and 2-D arrays, PyGMT supports most numeric dtypes provided by NumPy, pandas, +and PyArrow. **Signed Integers:** @@ -27,8 +27,12 @@ PyArrow. - `pandas.Float32`, `pandas.Float64` - `pyarrow.float32`, `pyarrow.float64` -For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit unsigned -intergers (i.e., `numpy.uint8`) are supported. +.. notes:: + + 1. Currently, `numpy.float16`, `numpy.longdouble` and `pyarrow.float16` are not + supported + 2. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit + unsigned intergers (i.e., `numpy.uint8`) are supported. ## String Dtypes From 9dc90afe3ed2fcd14424de340e159b64c2cd50f6 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 11 Nov 2024 10:33:00 +0800 Subject: [PATCH 03/18] Add a few examples for numeric arrays --- doc/techref/array_dtypes.md | 50 +++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 99ee051d3e3..261e83eddf2 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -1,38 +1,62 @@ # Supported Array Dtypes -PyGMT uses NumPy arrays to store data and passes them to the GMT C library. In this way, -PyGMT can support a wide range of dtypes. This page documents array dtypes supported by -PyGMT. +PyGMT uses NumPy arrays as its fundamental data structure for storing data, as well as +for exchanging data with the GMT C library. In this way, PyGMT can support a wide +range of dtypes, as long as they can be converted to a NumPy array. This page provides +a comprehensive overview of the dtypes supported by PyGMT. ## Numeric Dtypes -For 1-D and 2-D arrays, PyGMT supports most numeric dtypes provided by NumPy, pandas, -and PyArrow. +In addition to the Python built-in numeric types (i.e., `int` and `float`), PyGMT +supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. -**Signed Integers:** +**Signed Integers** - `numpy.int8`, `numpy.int16`, `numpy.int32`, `numpy.int64` - `pandas.Int8`, `pandas.Int16`, `pandas.Int32`, `pandas.Int64` - `pyarrow.int8`, `pyarrow.int16`, `pyarrow.int32`, `pyarrow.int64` -**Unsigned Integers:** +**Unsigned Integers** - `numpy.uint8`, `numpy.uint16`, `numpy.uint32`, `numpy.uint64` - `pandas.UInt8`, `pandas.UInt16`, `pandas.UInt32`, `pandas.UInt64` - `pyarrow.uint8`, `pyarrow.uint16`, `pyarrow.uint32`, `pyarrow.uint64` -**Floating-point numbers:** +**Floating-point numbers** - `numpy.float32`, `numpy.float64` - `pandas.Float32`, `pandas.Float64` - `pyarrow.float32`, `pyarrow.float64` -.. notes:: +```{note} - 1. Currently, `numpy.float16`, `numpy.longdouble` and `pyarrow.float16` are not - supported - 2. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit - unsigned intergers (i.e., `numpy.uint8`) are supported. +1. Currently, `numpy.float16`, `numpy.longdouble` and `pyarrow.float16` are not + supported. +2. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit + unsigned integers (i.e., `numpy.uint8`) are supported. +``` + +````{example} +```python +# A list of integers +[1, 2, 3] + +# A NumPy array with np.int32 dtype +np.array([1, 2, 3], dtype=np.int32) + +# A pandas.Series with pandas's Int32 dtype +pd.Series([1, 2, 3], dtype="Int32") + +# A pandas.Series with pandas's nullable Int32 dtype +pd.Series([1, 2, pd.NA], dtype="Int32") + +# A pandas.Series with PyArrow-backed float64 dtype +pd.Series([1, 2, 3], dtype="float64[pyarrow]") + +# A PyArrow array with pyarrow.uint8 dtype +pa.array([1, 2, 3], type=pa.uint8()) +``` +```` ## String Dtypes From 441de81555ef0359f09eb09880e94396b745cd5d Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 11 Nov 2024 14:27:04 +0800 Subject: [PATCH 04/18] Fix syntax --- doc/techref/array_dtypes.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 261e83eddf2..93afdc7bfd7 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -28,15 +28,15 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. - `pandas.Float32`, `pandas.Float64` - `pyarrow.float32`, `pyarrow.float64` -```{note} +:::{note} 1. Currently, `numpy.float16`, `numpy.longdouble` and `pyarrow.float16` are not supported. 2. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit unsigned integers (i.e., `numpy.uint8`) are supported. -``` +::: -````{example} +:::{tip} Examples ```python # A list of integers [1, 2, 3] @@ -56,7 +56,7 @@ pd.Series([1, 2, 3], dtype="float64[pyarrow]") # A PyArrow array with pyarrow.uint8 dtype pa.array([1, 2, 3], type=pa.uint8()) ``` -```` +::: ## String Dtypes From 9a032f21d9e5fcca6e828f18130b8b5eb3c6558d Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 11 Nov 2024 15:37:26 +0800 Subject: [PATCH 05/18] Fix some myst syntax --- doc/techref/array_dtypes.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 93afdc7bfd7..9c4226acb26 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -36,7 +36,10 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. unsigned integers (i.e., `numpy.uint8`) are supported. ::: -:::{tip} Examples +:::{note} + +Here are some examples for creating array-like objects that PyGMT supports: + ```python # A list of integers [1, 2, 3] From b725be7d6b66dac6f8a09886067e88c6bb2eca5f Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 12 Nov 2024 18:04:58 +0800 Subject: [PATCH 06/18] Add documents about string dtypes --- doc/techref/array_dtypes.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 9c4226acb26..a0e8c7a2abc 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -38,7 +38,7 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. :::{note} -Here are some examples for creating array-like objects that PyGMT supports: +Here are some examples for creating array-like numeric objects that PyGMT supports: ```python # A list of integers @@ -63,4 +63,32 @@ pa.array([1, 2, 3], type=pa.uint8()) ## String Dtypes +In addition to the Python built-in `str` type, PyGMT also support following string dtypes: + +- NumPy: `numpy.str_` +- pandas: `pandas.StringDtype` (including `string[python]`, `string[pyarrow]` and + `string[pyarrow_numpy]`) +- PyArrow: `pyarrow.string`, `pyarrow.large_string`, and `pyarrow.string_view` + +:::{note} +Here are some examples for creating string arrays that PyGMT supports: + +```python +# A list of strings +["a", "b", "c"] + +# A NumPy string array +np.array(["a", "b", "c"]) +np.array(["a", "b", "c"], dtype=np.str_) + +# A pandas.Series string array +pd.Series(["a", "b", "c"], dtype="string") +pd.Series(["a", "b", "c"], dtype="string[python]") +pd.Series(["a", "b", "c"], dtype="string[pyarrow]") +pd.Series(["a", "b", "c"], dtype="string[pyarrow_numpy]") + +# A PyArrow array with pyarrow.string dtype +pa.array(["a", "b", "c"], type=pa.string()) +``` + ## Datetime Dtypes From 52e9c3d2a5cbca6ae494dd96046fd4fd8316497d Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 14 Nov 2024 13:43:12 +0800 Subject: [PATCH 07/18] Add date32/date64 dtypes --- doc/techref/array_dtypes.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index a0e8c7a2abc..7eb3ce46ee4 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -92,3 +92,6 @@ pa.array(["a", "b", "c"], type=pa.string()) ``` ## Datetime Dtypes + +- pandas: `date32[day][pyarrow]`, `date64[ms][pyarrow]` +- PyArrow: `pyarrow.date32`, `pyarrow.date64` From 9df0d51a21393692900e0d68111fab9ff0fab691 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 30 Oct 2025 01:15:23 +0800 Subject: [PATCH 08/18] Improve the doc --- doc/techref/array_dtypes.md | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 7eb3ce46ee4..6b63c1cb61b 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -1,9 +1,9 @@ # Supported Array Dtypes PyGMT uses NumPy arrays as its fundamental data structure for storing data, as well as -for exchanging data with the GMT C library. In this way, PyGMT can support a wide -range of dtypes, as long as they can be converted to a NumPy array. This page provides -a comprehensive overview of the dtypes supported by PyGMT. +for exchanging data with the GMT C API. In this way, PyGMT can support a wide range of +dtypes, as long as they can be converted to a NumPy array. This page provides a +comprehensive overview of the dtypes supported by PyGMT. ## Numeric Dtypes @@ -12,27 +12,32 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. **Signed Integers** -- `numpy.int8`, `numpy.int16`, `numpy.int32`, `numpy.int64` -- `pandas.Int8`, `pandas.Int16`, `pandas.Int32`, `pandas.Int64` +- `numpy.int8`, `numpy.int16`, `numpy.int32`, `numpy.int64`, `numpy.longlong` +- `pandas.Int8Dtype`, `pandas.Int16Dtype`, `pandas.Int32Dtype`, `pandas.Int64Dtype` - `pyarrow.int8`, `pyarrow.int16`, `pyarrow.int32`, `pyarrow.int64` **Unsigned Integers** -- `numpy.uint8`, `numpy.uint16`, `numpy.uint32`, `numpy.uint64` -- `pandas.UInt8`, `pandas.UInt16`, `pandas.UInt32`, `pandas.UInt64` +- `numpy.uint8`, `numpy.uint16`, `numpy.uint32`, `numpy.uint64`, `numpy.ulonglong` +- `pandas.UInt8Dtype`, `pandas.UInt16Dtype`, `pandas.UInt32Dtype`, `pandas.UInt64Dtype` - `pyarrow.uint8`, `pyarrow.uint16`, `pyarrow.uint32`, `pyarrow.uint64` **Floating-point numbers** - `numpy.float32`, `numpy.float64` -- `pandas.Float32`, `pandas.Float64` +- `pandas.Float32Dtype`, `pandas.Float64Dtype` - `pyarrow.float32`, `pyarrow.float64` :::{note} - -1. Currently, `numpy.float16`, `numpy.longdouble` and `pyarrow.float16` are not - supported. -2. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit +1. Numeric dtypes `numpy.float16`, `numpy.longdouble`, and `pyarrow.float16` are not + supported and should be cast into one of the supported dtypes before passing to + PyGMT. +2. Complex numeric dtypes such as `numpy.complex64` are not supported. +3. pandas and PyArrow's signed/unsigned integer dtypes (e.g., `pandas.Int8Dtype`, + `pyarrow.int8`) support missing values such as `None` or `pandas.NA`, but numpy's + corrresponding dtypes don't. Arrays of these dtypes with missing values are always + cast into `numpy.float64` internally. +4. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit unsigned integers (i.e., `numpy.uint8`) are supported. ::: @@ -95,3 +100,8 @@ pa.array(["a", "b", "c"], type=pa.string()) - pandas: `date32[day][pyarrow]`, `date64[ms][pyarrow]` - PyArrow: `pyarrow.date32`, `pyarrow.date64` + + +## Bool Dtypes + +Currently, `numpy.bool` is not supported. \ No newline at end of file From 80635c2e5f1c1170fd76d7c4a547f06329672aa1 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 30 Oct 2025 19:16:05 +0800 Subject: [PATCH 09/18] Improve the documentation --- doc/techref/array_dtypes.md | 43 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 6b63c1cb61b..b55508c0839 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -1,14 +1,14 @@ # Supported Array Dtypes -PyGMT uses NumPy arrays as its fundamental data structure for storing data, as well as -for exchanging data with the GMT C API. In this way, PyGMT can support a wide range of -dtypes, as long as they can be converted to a NumPy array. This page provides a -comprehensive overview of the dtypes supported by PyGMT. +PyGMT uses NumPy arrays as its core data structure for storing data and exchanging data +with the GMT C API. This design allows PyGMT to support a wide range of data types +(*dtypes*), as long as they can be converted to NumPy arrays. This page provides a +comprehensive overview of the array dtypes supported by PyGMT. ## Numeric Dtypes -In addition to the Python built-in numeric types (i.e., `int` and `float`), PyGMT -supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. +In addition to Python's built-in numeric types (`int` and `float`), PyGMT supports most +of the numeric dtypes provided by NumPy, pandas, and PyArrow. **Signed Integers** @@ -29,46 +29,45 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. - `pyarrow.float32`, `pyarrow.float64` :::{note} -1. Numeric dtypes `numpy.float16`, `numpy.longdouble`, and `pyarrow.float16` are not - supported and should be cast into one of the supported dtypes before passing to +1. The numeric dtypes `numpy.float16`, `numpy.longdouble`, and `pyarrow.float16` are not + supported and should be cast to one of the supported dtypes before passing them to PyGMT. 2. Complex numeric dtypes such as `numpy.complex64` are not supported. -3. pandas and PyArrow's signed/unsigned integer dtypes (e.g., `pandas.Int8Dtype`, - `pyarrow.int8`) support missing values such as `None` or `pandas.NA`, but numpy's - corrresponding dtypes don't. Arrays of these dtypes with missing values are always - cast into `numpy.float64` internally. +3. Signed and unsigned integer dtypes from pandas and PyArrow (e.g., `pandas.Int8Dtype`, + `pyarrow.int8`) support missing values like `None` or `pandas.NA`, whereas NumPy's + corrresponding dtypes (e.g., `numpy.int8`) don't. Arrays of these dtypes containing + missing values are automatically cast to `numpy.float64` internally. 4. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit unsigned integers (i.e., `numpy.uint8`) are supported. ::: :::{note} - -Here are some examples for creating array-like numeric objects that PyGMT supports: +Examples of numeric arrays supported by PyGMT: ```python # A list of integers [1, 2, 3] -# A NumPy array with np.int32 dtype +# A NumPy array with dtype int32 np.array([1, 2, 3], dtype=np.int32) -# A pandas.Series with pandas's Int32 dtype +# A pandas Series with nullable Int32 dtype pd.Series([1, 2, 3], dtype="Int32") -# A pandas.Series with pandas's nullable Int32 dtype +# A pandas Series with nullable Int32 dtype and missing values pd.Series([1, 2, pd.NA], dtype="Int32") -# A pandas.Series with PyArrow-backed float64 dtype +# A pandas Series using a PyArrow-backed float64 dtype pd.Series([1, 2, 3], dtype="float64[pyarrow]") -# A PyArrow array with pyarrow.uint8 dtype +# A PyArrow array with dtype uint8 pa.array([1, 2, 3], type=pa.uint8()) ``` ::: ## String Dtypes -In addition to the Python built-in `str` type, PyGMT also support following string dtypes: +In addition to Python's built-in `str` type, PyGMT also support following string dtypes: - NumPy: `numpy.str_` - pandas: `pandas.StringDtype` (including `string[python]`, `string[pyarrow]` and @@ -76,7 +75,7 @@ In addition to the Python built-in `str` type, PyGMT also support following stri - PyArrow: `pyarrow.string`, `pyarrow.large_string`, and `pyarrow.string_view` :::{note} -Here are some examples for creating string arrays that PyGMT supports: +Examples of string arrays supported by PyGMT: ```python # A list of strings @@ -104,4 +103,4 @@ pa.array(["a", "b", "c"], type=pa.string()) ## Bool Dtypes -Currently, `numpy.bool` is not supported. \ No newline at end of file +Currently, `numpy.bool` is not supported. From 493af463735cb44fa559c774c13f0403478d5d3d Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 31 Oct 2025 22:51:15 +0800 Subject: [PATCH 10/18] Improve docs --- doc/techref/array_dtypes.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index b55508c0839..38884cd7c72 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -1,9 +1,9 @@ # Supported Array Dtypes PyGMT uses NumPy arrays as its core data structure for storing data and exchanging data -with the GMT C API. This design allows PyGMT to support a wide range of data types -(*dtypes*), as long as they can be converted to NumPy arrays. This page provides a -comprehensive overview of the array dtypes supported by PyGMT. +with the GMT C API. This design allows PyGMT to support a wide range of array-like +objects and data types (*dtypes*), as long as they can be converted to NumPy arrays. +This page provides a comprehensive overview of the array dtypes supported by PyGMT. ## Numeric Dtypes @@ -69,10 +69,11 @@ pa.array([1, 2, 3], type=pa.uint8()) In addition to Python's built-in `str` type, PyGMT also support following string dtypes: -- NumPy: `numpy.str_` -- pandas: `pandas.StringDtype` (including `string[python]`, `string[pyarrow]` and - `string[pyarrow_numpy]`) -- PyArrow: `pyarrow.string`, `pyarrow.large_string`, and `pyarrow.string_view` +- NumPy: `numpy.str_` or fixed-width Unicode string dtype (e.g., ``"U10"``) +- pandas: `pandas.StringDtype`, with different storage backends, including + `string[python]`, `string[pyarrow]`, and `string[pyarrow_numpy]` +- PyArrow: `pyarrow.string`/`pyarrow.utf8`, `pyarrow.large_string`/`pyarrow.large_utf8`, + and `pyarrow.string_view` :::{note} Examples of string arrays supported by PyGMT: From 5491f389997481fce77749701a5002f9277d62d9 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 31 Oct 2025 23:15:35 +0800 Subject: [PATCH 11/18] Expand the section for datetime dtypes --- doc/techref/array_dtypes.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 38884cd7c72..7de16e0505e 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -75,6 +75,8 @@ In addition to Python's built-in `str` type, PyGMT also support following string - PyArrow: `pyarrow.string`/`pyarrow.utf8`, `pyarrow.large_string`/`pyarrow.large_utf8`, and `pyarrow.string_view` +PyGMT also tries to convert arrays of `np.object_` dtype into string arrays if possible. + :::{note} Examples of string arrays supported by PyGMT: @@ -98,9 +100,19 @@ pa.array(["a", "b", "c"], type=pa.string()) ## Datetime Dtypes -- pandas: `date32[day][pyarrow]`, `date64[ms][pyarrow]` -- PyArrow: `pyarrow.date32`, `pyarrow.date64` +PyGMT supports a variety of datetime types: + +- A list/tuple of elements in Python's built-in `datetime.datetime` or `datetime.date`, + NumPy's `numpy.datetime64`, panda's `pandas.Timestamp` types, datetime-like strings, + or mixed. +- NumPy arrays: `numpy.datetime64` with various resolutions +- pandas objects with `numpy.datetime64`, `pandas.DatetimeTZDtype`, + `pyarrow.timestamp` with various resolution and timezone support, and + pyarrow-backend dtypes like `date32[day][pyarrow]` and `date64[ms][pyarrow]`, +- PyArrow: `pyarrow.date32`, `pyarrow.date64` and `pyarrow.timestamp` with various + resolutions and timezone support. + ## Bool Dtypes From 775c85c0f9bfcb296d9ebfb953de3b544977f432 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 25 Jul 2026 12:24:44 +0800 Subject: [PATCH 12/18] Make dtypes clickable Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- doc/techref/array_dtypes.md | 55 ++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 7de16e0505e..08696141ffa 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -7,36 +7,40 @@ This page provides a comprehensive overview of the array dtypes supported by PyG ## Numeric Dtypes -In addition to Python's built-in numeric types (`int` and `float`), PyGMT supports most -of the numeric dtypes provided by NumPy, pandas, and PyArrow. +In addition to Python's built-in numeric types ({class}`int` and {class}`float`), PyGMT +supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. **Signed Integers** - `numpy.int8`, `numpy.int16`, `numpy.int32`, `numpy.int64`, `numpy.longlong` -- `pandas.Int8Dtype`, `pandas.Int16Dtype`, `pandas.Int32Dtype`, `pandas.Int64Dtype` -- `pyarrow.int8`, `pyarrow.int16`, `pyarrow.int32`, `pyarrow.int64` +- {class}`pandas.Int8Dtype`, {class}`pandas.Int16Dtype`, {class}`pandas.Int32Dtype`, + {class}`pandas.Int64Dtype` +- {func}`pyarrow.int8`, {func}`pyarrow.int16`, {func}`pyarrow.int32`, + {func}`pyarrow.int64` **Unsigned Integers** - `numpy.uint8`, `numpy.uint16`, `numpy.uint32`, `numpy.uint64`, `numpy.ulonglong` -- `pandas.UInt8Dtype`, `pandas.UInt16Dtype`, `pandas.UInt32Dtype`, `pandas.UInt64Dtype` -- `pyarrow.uint8`, `pyarrow.uint16`, `pyarrow.uint32`, `pyarrow.uint64` +- {class}`pandas.UInt8Dtype`, {class}`pandas.UInt16Dtype`, {class}`pandas.UInt32Dtype`, {class}`pandas.UInt64Dtype` +- {func}`pyarrow.uint8`, {func}`pyarrow.uint16`, {func}`pyarrow.uint32`, + {func}`pyarrow.uint64` **Floating-point numbers** - `numpy.float32`, `numpy.float64` -- `pandas.Float32Dtype`, `pandas.Float64Dtype` -- `pyarrow.float32`, `pyarrow.float64` +- {class}`pandas.Float32Dtype`, {class}`pandas.Float64Dtype` +- {func}`pyarrow.float32`, {func}`pyarrow.float64` :::{note} -1. The numeric dtypes `numpy.float16`, `numpy.longdouble`, and `pyarrow.float16` are not - supported and should be cast to one of the supported dtypes before passing them to - PyGMT. +1. The numeric dtypes `numpy.float16`, `numpy.longdouble`, and {func}`pyarrow.float16` + are not supported and should be cast to one of the supported dtypes before passing + them to PyGMT. 2. Complex numeric dtypes such as `numpy.complex64` are not supported. -3. Signed and unsigned integer dtypes from pandas and PyArrow (e.g., `pandas.Int8Dtype`, - `pyarrow.int8`) support missing values like `None` or `pandas.NA`, whereas NumPy's - corrresponding dtypes (e.g., `numpy.int8`) don't. Arrays of these dtypes containing - missing values are automatically cast to `numpy.float64` internally. +3. Signed and unsigned integer dtypes from pandas and PyArrow (e.g., + {class}`pandas.Int8Dtype`, {func}`pyarrow.int8`) support missing values like `None` + or {class}`pandas.NA`, whereas NumPy's corrresponding dtypes (e.g., `numpy.int8`) + don't. Arrays of these dtypes containing missing values are automatically cast to + `numpy.float64` internally. 4. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit unsigned integers (i.e., `numpy.uint8`) are supported. ::: @@ -70,10 +74,11 @@ pa.array([1, 2, 3], type=pa.uint8()) In addition to Python's built-in `str` type, PyGMT also support following string dtypes: - NumPy: `numpy.str_` or fixed-width Unicode string dtype (e.g., ``"U10"``) -- pandas: `pandas.StringDtype`, with different storage backends, including +- pandas: {class}`pandas.StringDtype`, with different storage backends, including `string[python]`, `string[pyarrow]`, and `string[pyarrow_numpy]` -- PyArrow: `pyarrow.string`/`pyarrow.utf8`, `pyarrow.large_string`/`pyarrow.large_utf8`, - and `pyarrow.string_view` +- PyArrow: {func}`pyarrow.string`/{func}`pyarrow.utf8`, + {func}`pyarrow.large_string`/{func}`pyarrow.large_utf8`, and + {func}`pyarrow.string_view` PyGMT also tries to convert arrays of `np.object_` dtype into string arrays if possible. @@ -102,15 +107,15 @@ pa.array(["a", "b", "c"], type=pa.string()) PyGMT supports a variety of datetime types: -- A list/tuple of elements in Python's built-in `datetime.datetime` or `datetime.date`, - NumPy's `numpy.datetime64`, panda's `pandas.Timestamp` types, datetime-like strings, - or mixed. +- A list/tuple of elements in Python's built-in {class}`datetime.datetime` or + {class}`datetime.date`, NumPy's `numpy.datetime64`, pandas' {class}`pandas.Timestamp` + types, datetime-like strings, or mixed. - NumPy arrays: `numpy.datetime64` with various resolutions -- pandas objects with `numpy.datetime64`, `pandas.DatetimeTZDtype`, - `pyarrow.timestamp` with various resolution and timezone support, and +- pandas objects with `numpy.datetime64`, {class}`pandas.DatetimeTZDtype`, + {func}`pyarrow.timestamp` with various resolution and timezone support, and pyarrow-backend dtypes like `date32[day][pyarrow]` and `date64[ms][pyarrow]`, -- PyArrow: `pyarrow.date32`, `pyarrow.date64` and `pyarrow.timestamp` with various - resolutions and timezone support. +- PyArrow: {func}`pyarrow.date32`, {func}`pyarrow.date64` and {func}`pyarrow.timestamp` + with various resolutions and timezone support. From 7aed4abce53ecaeb39c6e3bb496c256f33e98029 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 25 Jul 2026 14:06:53 +0800 Subject: [PATCH 13/18] Make more links clickable --- doc/techref/array_dtypes.md | 38 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 08696141ffa..46618e9f5e9 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -12,7 +12,8 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. **Signed Integers** -- `numpy.int8`, `numpy.int16`, `numpy.int32`, `numpy.int64`, `numpy.longlong` +- {class}`numpy.int8`, {class}`numpy.int16`, {class}`numpy.int32`, {class}`numpy.int64`, + {class}`numpy.longlong` - {class}`pandas.Int8Dtype`, {class}`pandas.Int16Dtype`, {class}`pandas.Int32Dtype`, {class}`pandas.Int64Dtype` - {func}`pyarrow.int8`, {func}`pyarrow.int16`, {func}`pyarrow.int32`, @@ -20,29 +21,31 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. **Unsigned Integers** -- `numpy.uint8`, `numpy.uint16`, `numpy.uint32`, `numpy.uint64`, `numpy.ulonglong` -- {class}`pandas.UInt8Dtype`, {class}`pandas.UInt16Dtype`, {class}`pandas.UInt32Dtype`, {class}`pandas.UInt64Dtype` +- {class}`numpy.uint8`, {class}`numpy.uint16`, {class}`numpy.uint32`, + {class}`numpy.uint64`, {class}`numpy.ulonglong` +- {class}`pandas.UInt8Dtype`, {class}`pandas.UInt16Dtype`, {class}`pandas.UInt32Dtype`, + {class}`pandas.UInt64Dtype` - {func}`pyarrow.uint8`, {func}`pyarrow.uint16`, {func}`pyarrow.uint32`, {func}`pyarrow.uint64` **Floating-point numbers** -- `numpy.float32`, `numpy.float64` +- {class}`numpy.float32`, {class}`numpy.float64` - {class}`pandas.Float32Dtype`, {class}`pandas.Float64Dtype` - {func}`pyarrow.float32`, {func}`pyarrow.float64` :::{note} -1. The numeric dtypes `numpy.float16`, `numpy.longdouble`, and {func}`pyarrow.float16` - are not supported and should be cast to one of the supported dtypes before passing - them to PyGMT. -2. Complex numeric dtypes such as `numpy.complex64` are not supported. +1. The numeric dtypes {class}`numpy.float16`, {class}`numpy.longdouble`, and + {func}`pyarrow.float16` are not supported and should be cast to one of the supported + dtypes before passing them to PyGMT. +2. Complex numeric dtypes such as {class}`numpy.complex64` are not supported. 3. Signed and unsigned integer dtypes from pandas and PyArrow (e.g., {class}`pandas.Int8Dtype`, {func}`pyarrow.int8`) support missing values like `None` - or {class}`pandas.NA`, whereas NumPy's corrresponding dtypes (e.g., `numpy.int8`) - don't. Arrays of these dtypes containing missing values are automatically cast to - `numpy.float64` internally. + or {class}`pandas.NA`, whereas NumPy's corrresponding dtypes (e.g., + {class}`numpy.int8`) don't. Arrays of these dtypes containing missing values are + automatically cast to {class}`numpy.float64` internally. 4. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit - unsigned integers (i.e., `numpy.uint8`) are supported. + unsigned integers (i.e., {class}`numpy.uint8`) are supported. ::: :::{note} @@ -73,14 +76,15 @@ pa.array([1, 2, 3], type=pa.uint8()) In addition to Python's built-in `str` type, PyGMT also support following string dtypes: -- NumPy: `numpy.str_` or fixed-width Unicode string dtype (e.g., ``"U10"``) +- NumPy: {class}`numpy.str_` or fixed-width Unicode string dtype (e.g., `"U10"`) - pandas: {class}`pandas.StringDtype`, with different storage backends, including `string[python]`, `string[pyarrow]`, and `string[pyarrow_numpy]` - PyArrow: {func}`pyarrow.string`/{func}`pyarrow.utf8`, {func}`pyarrow.large_string`/{func}`pyarrow.large_utf8`, and {func}`pyarrow.string_view` -PyGMT also tries to convert arrays of `np.object_` dtype into string arrays if possible. +PyGMT also tries to convert arrays of {class}`numpy.object_` dtype into string arrays if +possible. :::{note} Examples of string arrays supported by PyGMT: @@ -108,10 +112,10 @@ pa.array(["a", "b", "c"], type=pa.string()) PyGMT supports a variety of datetime types: - A list/tuple of elements in Python's built-in {class}`datetime.datetime` or - {class}`datetime.date`, NumPy's `numpy.datetime64`, pandas' {class}`pandas.Timestamp` + {class}`datetime.date`, NumPy's {class}`numpy.datetime64`, pandas' {class}`pandas.Timestamp` types, datetime-like strings, or mixed. -- NumPy arrays: `numpy.datetime64` with various resolutions -- pandas objects with `numpy.datetime64`, {class}`pandas.DatetimeTZDtype`, +- NumPy arrays: {class}`numpy.datetime64` with various resolutions +- pandas objects with {class}`numpy.datetime64`, {class}`pandas.DatetimeTZDtype`, {func}`pyarrow.timestamp` with various resolution and timezone support, and pyarrow-backend dtypes like `date32[day][pyarrow]` and `date64[ms][pyarrow]`, - PyArrow: {func}`pyarrow.date32`, {func}`pyarrow.date64` and {func}`pyarrow.timestamp` From 63649088fac54385cfd9d2c431fc564d0d3013fa Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 25 Jul 2026 15:36:06 +0800 Subject: [PATCH 14/18] Add the end tag for notes --- doc/techref/array_dtypes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 46618e9f5e9..e0888b475fe 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -106,6 +106,7 @@ pd.Series(["a", "b", "c"], dtype="string[pyarrow_numpy]") # A PyArrow array with pyarrow.string dtype pa.array(["a", "b", "c"], type=pa.string()) ``` +::: ## Datetime Dtypes From d14bf8bef4ae5d8761e529774463070c9b093878 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 25 Jul 2026 15:41:14 +0800 Subject: [PATCH 15/18] Make str clickable --- doc/techref/array_dtypes.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index e0888b475fe..86527b28157 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -74,7 +74,8 @@ pa.array([1, 2, 3], type=pa.uint8()) ## String Dtypes -In addition to Python's built-in `str` type, PyGMT also support following string dtypes: +In addition to Python's built-in {class}`str` type, PyGMT also support following string +dtypes: - NumPy: {class}`numpy.str_` or fixed-width Unicode string dtype (e.g., `"U10"`) - pandas: {class}`pandas.StringDtype`, with different storage backends, including From fbffb4576e15ecc2ff5d0069c204092d4112b4a9 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 25 Jul 2026 16:02:38 +0800 Subject: [PATCH 16/18] Update docs --- doc/techref/array_dtypes.md | 50 ++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 86527b28157..319a87fbb00 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -1,9 +1,8 @@ # Supported Array Dtypes PyGMT uses NumPy arrays as its core data structure for storing data and exchanging data -with the GMT C API. This design allows PyGMT to support a wide range of array-like -objects and data types (*dtypes*), as long as they can be converted to NumPy arrays. -This page provides a comprehensive overview of the array dtypes supported by PyGMT. +with the GMT C API. This page provides a comprehensive overview of the dtypes accepted +by PyGMT's array-conversion and GMT virtual-file interfaces. ## Numeric Dtypes @@ -35,16 +34,12 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. - {func}`pyarrow.float32`, {func}`pyarrow.float64` :::{note} -1. The numeric dtypes {class}`numpy.float16`, {class}`numpy.longdouble`, and - {func}`pyarrow.float16` are not supported and should be cast to one of the supported - dtypes before passing them to PyGMT. -2. Complex numeric dtypes such as {class}`numpy.complex64` are not supported. -3. Signed and unsigned integer dtypes from pandas and PyArrow (e.g., +1. Signed and unsigned integer dtypes from pandas and PyArrow (e.g., {class}`pandas.Int8Dtype`, {func}`pyarrow.int8`) support missing values like `None` - or {class}`pandas.NA`, whereas NumPy's corrresponding dtypes (e.g., + or {class}`pandas.NA`, whereas NumPy's corresponding dtypes (e.g., {class}`numpy.int8`) don't. Arrays of these dtypes containing missing values are automatically cast to {class}`numpy.float64` internally. -4. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit +2. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit unsigned integers (i.e., {class}`numpy.uint8`) are supported. ::: @@ -74,19 +69,16 @@ pa.array([1, 2, 3], type=pa.uint8()) ## String Dtypes -In addition to Python's built-in {class}`str` type, PyGMT also support following string -dtypes: +In addition to Python's built-in {class}`str` type, PyGMT also supports the following +string dtypes: - NumPy: {class}`numpy.str_` or fixed-width Unicode string dtype (e.g., `"U10"`) - pandas: {class}`pandas.StringDtype`, with different storage backends, including - `string[python]`, `string[pyarrow]`, and `string[pyarrow_numpy]` + `string[python]` and `string[pyarrow]` - PyArrow: {func}`pyarrow.string`/{func}`pyarrow.utf8`, {func}`pyarrow.large_string`/{func}`pyarrow.large_utf8`, and {func}`pyarrow.string_view` -PyGMT also tries to convert arrays of {class}`numpy.object_` dtype into string arrays if -possible. - :::{note} Examples of string arrays supported by PyGMT: @@ -102,7 +94,6 @@ np.array(["a", "b", "c"], dtype=np.str_) pd.Series(["a", "b", "c"], dtype="string") pd.Series(["a", "b", "c"], dtype="string[python]") pd.Series(["a", "b", "c"], dtype="string[pyarrow]") -pd.Series(["a", "b", "c"], dtype="string[pyarrow_numpy]") # A PyArrow array with pyarrow.string dtype pa.array(["a", "b", "c"], type=pa.string()) @@ -123,8 +114,27 @@ PyGMT supports a variety of datetime types: - PyArrow: {func}`pyarrow.date32`, {func}`pyarrow.date64` and {func}`pyarrow.timestamp` with various resolutions and timezone support. - +## Timedelta Dtypes + +PyGMT supports NumPy arrays with the {class}`numpy.timedelta64` dtype. Timedelta values +are passed to GMT as their underlying integer values, so their unit determines the +numeric scale. For example, a `timedelta64[D]` array is interpreted as days, whereas a +`timedelta64[s]` array is interpreted as seconds. + +Timedelta values can also be used in sequence-valued parameters such as ``region``. +The timedelta dtype does not, by itself, configure a GMT relative-time axis; configure +GMT time settings explicitly when a relative-time axis is required. + +## Unsupported Dtypes + +The following dtypes are intentionally unsupported, and should be cast to an appropriate +supported dtype before passing to PyGMT: -## Bool Dtypes +- Floating-point dtypes: {class}`numpy.float16`, {func}`pyarrow.float16`, {class}`numpy.longdouble` +- Boolean dtypes: {class}`numpy.bool_`, {class}`pandas.BooleanDtype`, {func}`pyarrow.bool_` +- Complex dtypes: {class}`numpy.complex64`, {class}`numpy.complex128` +- {class}`numpy.bytes_` and {class}`numpy.void` -Currently, `numpy.bool` is not supported. +The {class}`numpy.object_` dtype is also not supported. PyGMT may convert object arrays +that can be interpreted as datetimes or text, but applications should create arrays with +an explicit supported dtype instead. From ca51e26d4a782813db24a13bd9e6f17ff29af23d Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sat, 25 Jul 2026 17:16:45 +0800 Subject: [PATCH 17/18] Fix references to numpy dtypes --- doc/techref/array_dtypes.md | 45 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index 319a87fbb00..e2f913e2723 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -1,8 +1,9 @@ # Supported Array Dtypes PyGMT uses NumPy arrays as its core data structure for storing data and exchanging data -with the GMT C API. This page provides a comprehensive overview of the dtypes accepted -by PyGMT's array-conversion and GMT virtual-file interfaces. +with the GMT C API. This design allows PyGMT to support a wide range of array-like +objects and data types (*dtypes*), as long as they can be converted to NumPy arrays. +This page provides a comprehensive overview of the array dtypes supported by PyGMT. ## Numeric Dtypes @@ -11,8 +12,7 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. **Signed Integers** -- {class}`numpy.int8`, {class}`numpy.int16`, {class}`numpy.int32`, {class}`numpy.int64`, - {class}`numpy.longlong` +- `numpy.int8`, `numpy.int16`, `numpy.int32`, `numpy.int64`, `numpy.longlong` - {class}`pandas.Int8Dtype`, {class}`pandas.Int16Dtype`, {class}`pandas.Int32Dtype`, {class}`pandas.Int64Dtype` - {func}`pyarrow.int8`, {func}`pyarrow.int16`, {func}`pyarrow.int32`, @@ -20,8 +20,7 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. **Unsigned Integers** -- {class}`numpy.uint8`, {class}`numpy.uint16`, {class}`numpy.uint32`, - {class}`numpy.uint64`, {class}`numpy.ulonglong` +- `numpy.uint8`, `numpy.uint16`, `numpy.uint32`, `numpy.uint64`, `numpy.ulonglong` - {class}`pandas.UInt8Dtype`, {class}`pandas.UInt16Dtype`, {class}`pandas.UInt32Dtype`, {class}`pandas.UInt64Dtype` - {func}`pyarrow.uint8`, {func}`pyarrow.uint16`, {func}`pyarrow.uint32`, @@ -29,18 +28,18 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. **Floating-point numbers** -- {class}`numpy.float32`, {class}`numpy.float64` +- `numpy.float32`, `numpy.float64` - {class}`pandas.Float32Dtype`, {class}`pandas.Float64Dtype` - {func}`pyarrow.float32`, {func}`pyarrow.float64` :::{note} 1. Signed and unsigned integer dtypes from pandas and PyArrow (e.g., {class}`pandas.Int8Dtype`, {func}`pyarrow.int8`) support missing values like `None` - or {class}`pandas.NA`, whereas NumPy's corresponding dtypes (e.g., - {class}`numpy.int8`) don't. Arrays of these dtypes containing missing values are - automatically cast to {class}`numpy.float64` internally. + or {class}`pandas.NA`, whereas NumPy's corresponding dtypes (e.g., `numpy.int8`) + don't. Arrays of these dtypes containing missing values are automatically cast to + `numpy.float64` internally. 2. For 3-D {class}`xarray.DataArray` objects representing raster images, only 8-bit - unsigned integers (i.e., {class}`numpy.uint8`) are supported. + unsigned integers (i.e., `numpy.uint8`) are supported. ::: :::{note} @@ -72,7 +71,7 @@ pa.array([1, 2, 3], type=pa.uint8()) In addition to Python's built-in {class}`str` type, PyGMT also supports the following string dtypes: -- NumPy: {class}`numpy.str_` or fixed-width Unicode string dtype (e.g., `"U10"`) +- NumPy: `numpy.str_` or fixed-width Unicode string dtype (e.g., `"U10"`) - pandas: {class}`pandas.StringDtype`, with different storage backends, including `string[python]` and `string[pyarrow]` - PyArrow: {func}`pyarrow.string`/{func}`pyarrow.utf8`, @@ -105,10 +104,10 @@ pa.array(["a", "b", "c"], type=pa.string()) PyGMT supports a variety of datetime types: - A list/tuple of elements in Python's built-in {class}`datetime.datetime` or - {class}`datetime.date`, NumPy's {class}`numpy.datetime64`, pandas' {class}`pandas.Timestamp` + {class}`datetime.date`, NumPy's `numpy.datetime64`, pandas' {class}`pandas.Timestamp` types, datetime-like strings, or mixed. -- NumPy arrays: {class}`numpy.datetime64` with various resolutions -- pandas objects with {class}`numpy.datetime64`, {class}`pandas.DatetimeTZDtype`, +- NumPy arrays: `numpy.datetime64` with various resolutions +- pandas objects with `numpy.datetime64`, {class}`pandas.DatetimeTZDtype`, {func}`pyarrow.timestamp` with various resolution and timezone support, and pyarrow-backend dtypes like `date32[day][pyarrow]` and `date64[ms][pyarrow]`, - PyArrow: {func}`pyarrow.date32`, {func}`pyarrow.date64` and {func}`pyarrow.timestamp` @@ -116,9 +115,9 @@ PyGMT supports a variety of datetime types: ## Timedelta Dtypes -PyGMT supports NumPy arrays with the {class}`numpy.timedelta64` dtype. Timedelta values -are passed to GMT as their underlying integer values, so their unit determines the -numeric scale. For example, a `timedelta64[D]` array is interpreted as days, whereas a +PyGMT supports NumPy arrays with the `numpy.timedelta64` dtype. Timedelta values are +passed to GMT as their underlying integer values, so their unit determines the numeric +scale. For example, a `timedelta64[D]` array is interpreted as days, whereas a `timedelta64[s]` array is interpreted as seconds. Timedelta values can also be used in sequence-valued parameters such as ``region``. @@ -130,11 +129,11 @@ GMT time settings explicitly when a relative-time axis is required. The following dtypes are intentionally unsupported, and should be cast to an appropriate supported dtype before passing to PyGMT: -- Floating-point dtypes: {class}`numpy.float16`, {func}`pyarrow.float16`, {class}`numpy.longdouble` -- Boolean dtypes: {class}`numpy.bool_`, {class}`pandas.BooleanDtype`, {func}`pyarrow.bool_` -- Complex dtypes: {class}`numpy.complex64`, {class}`numpy.complex128` -- {class}`numpy.bytes_` and {class}`numpy.void` +- Floating-point dtypes: `numpy.float16`, {func}`pyarrow.float16`, `numpy.longdouble` +- Boolean dtypes: `numpy.bool_`, {class}`pandas.BooleanDtype`, {func}`pyarrow.bool_` +- Complex dtypes: `numpy.complex64`, `numpy.complex128` +- `numpy.bytes_` and `numpy.void` -The {class}`numpy.object_` dtype is also not supported. PyGMT may convert object arrays +The `numpy.object_` dtype is also not supported. PyGMT may convert object arrays that can be interpreted as datetimes or text, but applications should create arrays with an explicit supported dtype instead. From 6734cb4cb73d376e926dec397e671f3a41cb7af9 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 31 Jul 2026 10:45:18 +0800 Subject: [PATCH 18/18] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- doc/techref/array_dtypes.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/doc/techref/array_dtypes.md b/doc/techref/array_dtypes.md index e2f913e2723..2a4534bc51a 100644 --- a/doc/techref/array_dtypes.md +++ b/doc/techref/array_dtypes.md @@ -12,7 +12,7 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. **Signed Integers** -- `numpy.int8`, `numpy.int16`, `numpy.int32`, `numpy.int64`, `numpy.longlong` +- `numpy.int8`, `numpy.int16`, `numpy.int32`, `numpy.int64`, {class}`numpy.longlong` - {class}`pandas.Int8Dtype`, {class}`pandas.Int16Dtype`, {class}`pandas.Int32Dtype`, {class}`pandas.Int64Dtype` - {func}`pyarrow.int8`, {func}`pyarrow.int16`, {func}`pyarrow.int32`, @@ -20,7 +20,7 @@ supports most of the numeric dtypes provided by NumPy, pandas, and PyArrow. **Unsigned Integers** -- `numpy.uint8`, `numpy.uint16`, `numpy.uint32`, `numpy.uint64`, `numpy.ulonglong` +- `numpy.uint8`, `numpy.uint16`, `numpy.uint32`, `numpy.uint64`, {class}`numpy.ulonglong` - {class}`pandas.UInt8Dtype`, {class}`pandas.UInt16Dtype`, {class}`pandas.UInt32Dtype`, {class}`pandas.UInt64Dtype` - {func}`pyarrow.uint8`, {func}`pyarrow.uint16`, {func}`pyarrow.uint32`, @@ -71,7 +71,7 @@ pa.array([1, 2, 3], type=pa.uint8()) In addition to Python's built-in {class}`str` type, PyGMT also supports the following string dtypes: -- NumPy: `numpy.str_` or fixed-width Unicode string dtype (e.g., `"U10"`) +- NumPy: {class}`numpy.str_` or fixed-width Unicode string dtype (e.g., ``"U10"``) - pandas: {class}`pandas.StringDtype`, with different storage backends, including `string[python]` and `string[pyarrow]` - PyArrow: {func}`pyarrow.string`/{func}`pyarrow.utf8`, @@ -104,10 +104,9 @@ pa.array(["a", "b", "c"], type=pa.string()) PyGMT supports a variety of datetime types: - A list/tuple of elements in Python's built-in {class}`datetime.datetime` or - {class}`datetime.date`, NumPy's `numpy.datetime64`, pandas' {class}`pandas.Timestamp` - types, datetime-like strings, or mixed. -- NumPy arrays: `numpy.datetime64` with various resolutions -- pandas objects with `numpy.datetime64`, {class}`pandas.DatetimeTZDtype`, + {class}`datetime.date`, datetime-like strings, or mixed. +- NumPy arrays: {class}`numpy.datetime64` with various resolutions +- pandas objects with {class}`numpy.datetime64`, {class}`pandas.DatetimeTZDtype`, {func}`pyarrow.timestamp` with various resolution and timezone support, and pyarrow-backend dtypes like `date32[day][pyarrow]` and `date64[ms][pyarrow]`, - PyArrow: {func}`pyarrow.date32`, {func}`pyarrow.date64` and {func}`pyarrow.timestamp` @@ -115,9 +114,9 @@ PyGMT supports a variety of datetime types: ## Timedelta Dtypes -PyGMT supports NumPy arrays with the `numpy.timedelta64` dtype. Timedelta values are -passed to GMT as their underlying integer values, so their unit determines the numeric -scale. For example, a `timedelta64[D]` array is interpreted as days, whereas a +PyGMT supports NumPy arrays with the {class}`numpy.timedelta64` dtype. Timedelta values +are passed to GMT as their underlying integer values, so their unit determines the +numeric scale. For example, a `timedelta64[D]` array is interpreted as days, whereas a `timedelta64[s]` array is interpreted as seconds. Timedelta values can also be used in sequence-valued parameters such as ``region``. @@ -129,11 +128,13 @@ GMT time settings explicitly when a relative-time axis is required. The following dtypes are intentionally unsupported, and should be cast to an appropriate supported dtype before passing to PyGMT: -- Floating-point dtypes: `numpy.float16`, {func}`pyarrow.float16`, `numpy.longdouble` -- Boolean dtypes: `numpy.bool_`, {class}`pandas.BooleanDtype`, {func}`pyarrow.bool_` +- Floating-point dtypes: `numpy.float16`, {func}`pyarrow.float16` and + {class}`numpy.longdouble` +- Boolean dtypes: {class}`numpy.bool`, {class}`pandas.BooleanDtype` and + {func}`pyarrow.bool_` - Complex dtypes: `numpy.complex64`, `numpy.complex128` -- `numpy.bytes_` and `numpy.void` +- {class}`numpy.bytes_` and {class}`numpy.void` -The `numpy.object_` dtype is also not supported. PyGMT may convert object arrays +The {class}`numpy.object_` dtype is also not supported. PyGMT may convert object arrays that can be interpreted as datetimes or text, but applications should create arrays with an explicit supported dtype instead.