Skip to content

Commit

Permalink
Merge branch 'main' into plot-1d-array-symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Oct 27, 2024
2 parents 45cf127 + ced2e5f commit 21b36f7
Show file tree
Hide file tree
Showing 12 changed files with 438 additions and 284 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci_tests_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ jobs:
pcre
zlib
# Install the GSHHG and DCW datasets on Linux/macOS to avoid corrupted files
# during GMT auto-downloading. Currently, we can't install them on Windows CI,
# because the Windows CI fails to compile "gshhg_version.c" due to unknown reasons
# (likely missing DLLs).
- name: Install GMT GSHHG and DCW datasets (Linux/macOS)
run: micromamba install dcw-gmt gshhg-gmt
if: runner.os != 'Windows'

# Checkout current GMT repository
- name: Checkout the GMT source from ${{ matrix.gmt_git_ref }} branch
uses: actions/[email protected]
Expand Down
38 changes: 2 additions & 36 deletions pygmt/clib/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,41 +168,7 @@ def vectors_to_arrays(vectors: Sequence[Any]) -> list[np.ndarray]:
True
>>> all(isinstance(i, np.ndarray) for i in arrays)
True
>>> data = [[1, 2], (3, 4), range(5, 7)]
>>> all(isinstance(i, np.ndarray) for i in vectors_to_arrays(data))
True
>>> # Sequence of scalars are converted to 1-D arrays
>>> data = vectors_to_arrays([1, 2, 3.0])
>>> data
[array([1]), array([2]), array([3.])]
>>> [i.ndim for i in data] # Check that they are 1-D arrays
[1, 1, 1]
>>> series = pd.Series(data=[0, 4, pd.NA, 8, 6], dtype=pd.Int32Dtype())
>>> vectors_to_arrays([series])
[array([ 0., 4., nan, 8., 6.])]
>>> import datetime
>>> import pytest
>>> pa = pytest.importorskip("pyarrow")
>>> vectors = [
... pd.Series(
... data=[datetime.date(2020, 1, 1), datetime.date(2021, 12, 31)],
... dtype="date32[day][pyarrow]",
... ),
... pd.Series(
... data=[datetime.date(2022, 1, 1), datetime.date(2023, 12, 31)],
... dtype="date64[ms][pyarrow]",
... ),
... ]
>>> arrays = vectors_to_arrays(vectors)
>>> all(a.flags.c_contiguous for a in arrays)
True
>>> all(isinstance(a, np.ndarray) for a in arrays)
True
>>> all(isinstance(a.dtype, np.dtypes.DateTime64DType) for a in arrays)
>>> all(i.ndim == 1 for i in arrays)
True
"""
dtypes = {
Expand All @@ -229,7 +195,7 @@ def vectors_to_arrays(vectors: Sequence[Any]) -> list[np.ndarray]:


def sequence_to_ctypes_array(
sequence: Sequence | None, ctype, size: int
sequence: Sequence[int | float] | np.ndarray | None, ctype, size: int
) -> ctp.Array | None:
"""
Convert a sequence of numbers into a ctypes array variable.
Expand Down
Loading

0 comments on commit 21b36f7

Please sign in to comment.