Skip to content

Commit 66afff5

Browse files
authored
Finalize fixes on WIndows test suite for v0.1.1 (#441)
Fixes 3 tests failing on Windows Azure Pipelines: 1) Set TempDirectory using os.getcwd() as pygmtscraper was unable to handle different mount paths on WIndows; 2) Removed _as_array function and tests since np.asarray does the same job; 3) Change to ctypes.c_long from ctypes.c_int in kwargs_to_ctypes_array since they're the same (aliases).
1 parent ce5de0e commit 66afff5

File tree

2 files changed

+4
-46
lines changed

2 files changed

+4
-46
lines changed

pygmt/clib/conversion.py

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def vectors_to_arrays(vectors):
156156
True
157157
158158
"""
159-
arrays = [as_c_contiguous(_as_array(i)) for i in vectors]
159+
arrays = [as_c_contiguous(np.asarray(i)) for i in vectors]
160160
return arrays
161161

162162

@@ -203,48 +203,6 @@ def as_c_contiguous(array):
203203
return array
204204

205205

206-
def _as_array(vector):
207-
"""
208-
Convert a vector (pandas.Series, tuple, list or numpy array) to a numpy
209-
array.
210-
211-
If vector is already an array, do nothing.
212-
213-
Parameters
214-
----------
215-
vector : tuple, list, pandas.Series or numpy 1d array
216-
The vector to convert.
217-
218-
Returns
219-
-------
220-
array : numpy array
221-
222-
Examples
223-
--------
224-
225-
>>> import pandas as pd
226-
>>> x_series = pd.Series(data=[1, 2, 3, 4])
227-
>>> x_array = _as_array(x_series)
228-
>>> type(x_array)
229-
<class 'numpy.ndarray'>
230-
>>> x_array
231-
array([1, 2, 3, 4])
232-
>>> import numpy as np
233-
>>> type(_as_array(np.array([5, 6, 7])))
234-
<class 'numpy.ndarray'>
235-
>>> type(_as_array([3, 4, 5]))
236-
<class 'numpy.ndarray'>
237-
>>> type(_as_array((6, 7, 8)))
238-
<class 'numpy.ndarray'>
239-
>>> type(_as_array(range(15)))
240-
<class 'numpy.ndarray'>
241-
242-
"""
243-
if isinstance(vector, pandas.Series):
244-
return vector.values
245-
return np.asarray(vector)
246-
247-
248206
def kwargs_to_ctypes_array(argument, kwargs, dtype):
249207
"""
250208
Convert an iterable argument from kwargs into a ctypes array variable.
@@ -268,9 +226,9 @@ def kwargs_to_ctypes_array(argument, kwargs, dtype):
268226
--------
269227
270228
>>> import ctypes as ct
271-
>>> value = kwargs_to_ctypes_array('bla', {'bla': [10, 10]}, ct.c_int*2)
229+
>>> value = kwargs_to_ctypes_array('bla', {'bla': [10, 10]}, ct.c_long*2)
272230
>>> type(value)
273-
<class 'pygmt.clib.conversion.c_int_Array_2'>
231+
<class 'pygmt.clib.conversion.c_long_Array_2'>
274232
>>> should_be_none = kwargs_to_ctypes_array(
275233
... 'swallow', {'bla': 1, 'foo': [20, 30]}, ct.c_int*2)
276234
>>> print(should_be_none)

pygmt/tests/test_sphinx_gallery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_pygmtscraper():
2828
assert len(SHOWED_FIGURES) == 1
2929
assert SHOWED_FIGURES[0] is fig
3030
scraper = PyGMTScraper()
31-
with TemporaryDirectory() as tmpdir:
31+
with TemporaryDirectory(dir=os.getcwd()) as tmpdir:
3232
conf = {"src_dir": "meh"}
3333
fname = os.path.join(tmpdir, "meh.png")
3434
block_vars = {"image_path_iterator": (i for i in [fname])}

0 commit comments

Comments
 (0)