Skip to content

Commit bd07967

Browse files
authored
Merge branch 'main' into doc/ecosystem
2 parents 40cb5bf + 054d148 commit bd07967

File tree

11 files changed

+13
-56
lines changed

11 files changed

+13
-56
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

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.6.0
5+
rev: v5.0.0
66
hooks:
77
- id: check-added-large-files
88
- id: check-yaml

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:

0 commit comments

Comments
 (0)