Skip to content

Commit bfcec3a

Browse files
authored
Merge branch 'main' into python-3.13
2 parents 92d5945 + 054d148 commit bfcec3a

File tree

10 files changed

+12
-55
lines changed

10 files changed

+12
-55
lines changed

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
# Install Micromamba with conda-forge dependencies
4747
- name: Setup Micromamba
48-
uses: mamba-org/setup-micromamba@v1.9.0
48+
uses: mamba-org/setup-micromamba@v2.0.0
4949
with:
5050
environment-name: pygmt
5151
condarc: |

.github/workflows/cache_data.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343

4444
# Install Micromamba with conda-forge dependencies
4545
- name: Setup Micromamba
46-
uses: mamba-org/setup-micromamba@v1.9.0
46+
uses: mamba-org/setup-micromamba@v2.0.0
4747
with:
4848
environment-name: pygmt
4949
condarc: |

.github/workflows/ci_docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080

8181
# Install Micromamba with conda-forge dependencies
8282
- name: Setup Micromamba
83-
uses: mamba-org/setup-micromamba@v1.9.0
83+
uses: mamba-org/setup-micromamba@v2.0.0
8484
with:
8585
environment-name: pygmt
8686
condarc: |

.github/workflows/ci_doctests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
# Install Micromamba with conda-forge dependencies
4444
- name: Setup Micromamba
45-
uses: mamba-org/setup-micromamba@v1.9.0
45+
uses: mamba-org/setup-micromamba@v2.0.0
4646
with:
4747
environment-name: pygmt
4848
condarc: |

.github/workflows/ci_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114

115115
# Install Micromamba with conda-forge dependencies
116116
- name: Setup Micromamba
117-
uses: mamba-org/setup-micromamba@v1.9.0
117+
uses: mamba-org/setup-micromamba@v2.0.0
118118
with:
119119
environment-name: pygmt
120120
condarc: |

.github/workflows/ci_tests_dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757

5858
# Install Micromamba with conda-forge dependencies
5959
- name: Setup Micromamba
60-
uses: mamba-org/setup-micromamba@v1.9.0
60+
uses: mamba-org/setup-micromamba@v2.0.0
6161
with:
6262
environment-name: pygmt
6363
condarc: |

.github/workflows/ci_tests_legacy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151

5252
# Install Micromamba with conda-forge dependencies
5353
- name: Setup Micromamba
54-
uses: mamba-org/setup-micromamba@v1.9.0
54+
uses: mamba-org/setup-micromamba@v2.0.0
5555
with:
5656
environment-name: pygmt
5757
condarc: |

.github/workflows/publish-to-pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ jobs:
7575
ls -lh dist/
7676
7777
- name: Publish to Test PyPI
78-
uses: pypa/[email protected].2
78+
uses: pypa/[email protected].3
7979
with:
8080
repository-url: https://test.pypi.org/legacy/
8181

8282
- name: Publish to PyPI
8383
if: startsWith(github.ref, 'refs/tags')
84-
uses: pypa/[email protected].2
84+
uses: pypa/[email protected].3

pygmt/clib/conversion.py

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def dataarray_to_matrix(grid):
123123
inc = [abs(i) for i in inc]
124124
grid = grid.sortby(variables=list(grid.dims), ascending=True)
125125

126-
matrix = as_c_contiguous(grid[::-1].to_numpy())
126+
matrix = np.ascontiguousarray(grid[::-1].to_numpy())
127127
region = [float(i) for i in region]
128128
inc = [float(i) for i in inc]
129129
return matrix, region, inc
@@ -200,53 +200,11 @@ def vectors_to_arrays(vectors):
200200
for vector in vectors:
201201
vec_dtype = str(getattr(vector, "dtype", ""))
202202
array = np.asarray(a=vector, dtype=dtypes.get(vec_dtype))
203-
arrays.append(as_c_contiguous(array))
203+
arrays.append(np.ascontiguousarray(array))
204204

205205
return arrays
206206

207207

208-
def as_c_contiguous(array):
209-
"""
210-
Ensure a numpy array is C contiguous in memory.
211-
212-
If the array is not C contiguous, a copy will be necessary.
213-
214-
Parameters
215-
----------
216-
array : 1-D array
217-
The numpy array
218-
219-
Returns
220-
-------
221-
array : 1-D array
222-
Array is C contiguous order.
223-
224-
Examples
225-
--------
226-
227-
>>> import numpy as np
228-
>>> data = np.array([[1, 2], [3, 4], [5, 6]])
229-
>>> x = data[:, 0]
230-
>>> x
231-
array([1, 3, 5])
232-
>>> x.flags.c_contiguous
233-
False
234-
>>> new_x = as_c_contiguous(x)
235-
>>> new_x
236-
array([1, 3, 5])
237-
>>> new_x.flags.c_contiguous
238-
True
239-
>>> x = np.array([8, 9, 10])
240-
>>> x.flags.c_contiguous
241-
True
242-
>>> as_c_contiguous(x).flags.c_contiguous
243-
True
244-
"""
245-
if not array.flags.c_contiguous:
246-
return array.copy(order="C")
247-
return array
248-
249-
250208
def sequence_to_ctypes_array(
251209
sequence: Sequence | None, ctype, size: int
252210
) -> ctp.Array | None:

pygmt/clib/session.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import xarray as xr
2020
from pygmt.clib.conversion import (
2121
array_to_datetime,
22-
as_c_contiguous,
2322
dataarray_to_matrix,
2423
sequence_to_ctypes_array,
2524
strings_to_ctypes_array,
@@ -1499,7 +1498,7 @@ def virtualfile_from_matrix(self, matrix):
14991498
# collected and the memory freed. Creating it in this context manager
15001499
# guarantees that the copy will be around until the virtual file is
15011500
# closed.
1502-
matrix = as_c_contiguous(matrix)
1501+
matrix = np.ascontiguousarray(matrix)
15031502
rows, columns = matrix.shape
15041503

15051504
family = "GMT_IS_DATASET|GMT_VIA_MATRIX"

0 commit comments

Comments
 (0)