Skip to content

Commit

Permalink
Add a doctest for checking ndims when the input is a sequence of scal…
Browse files Browse the repository at this point in the history
…ars (#3497)
  • Loading branch information
seisman authored Oct 10, 2024
1 parent 0b59e2f commit 7e1fa00
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pygmt/clib/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ def vectors_to_arrays(vectors):
>>> 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]
>>> import datetime
>>> import pytest
>>> pa = pytest.importorskip("pyarrow")
Expand Down Expand Up @@ -199,9 +206,7 @@ def vectors_to_arrays(vectors):
arrays = []
for vector in vectors:
vec_dtype = str(getattr(vector, "dtype", ""))
array = np.asarray(a=vector, dtype=dtypes.get(vec_dtype))
arrays.append(np.ascontiguousarray(array))

arrays.append(np.ascontiguousarray(vector, dtype=dtypes.get(vec_dtype)))
return arrays


Expand Down

0 comments on commit 7e1fa00

Please sign in to comment.