From 13e2dc6498bfc69b96dbf2a4591eadef0f0721f8 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Mon, 3 Sep 2018 12:23:58 -0500 Subject: [PATCH 1/3] add unyt_array.argsort. Fixes #51 --- unyt/array.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/unyt/array.py b/unyt/array.py index 9e4ef409..e836c9fb 100644 --- a/unyt/array.py +++ b/unyt/array.py @@ -1099,6 +1099,24 @@ def to_ndarray(self): """ return np.array(self) + def argsort(self, axis=-1, kind='quicksort', order=None): + """ + Returns the indices that would sort the array. + + See the documentation of ndarray.argsort for details about the keyword + arguments. + + Example + ------- + >>> from unyt import km + >>> data = [3, 8, 7]*km + >>> np.argsort(data) + array([0, 2, 1]) + >>> data.argsort() + array([0, 2, 1]) + """ + return self.view(np.ndarray).argsort(axis, kind, order) + @classmethod def from_astropy(cls, arr, unit_registry=None): """ From 80a80367d58242127b7ac6dabef1b9872444ba29 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Mon, 3 Sep 2018 12:40:49 -0500 Subject: [PATCH 2/3] run windows tests on an x64 build --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 74ea6ef5..605bfcbf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,8 @@ environment: - TOXENV: py27 - TOXENV: py37 +platform: x64 + matrix: fast_finish: true From d36f980f25c5b18de31ccfc0ea45d3a33b8caa50 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Mon, 3 Sep 2018 14:38:34 -0500 Subject: [PATCH 3/3] paper over platform-specific issue --- appveyor.yml | 2 -- unyt/array.py | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 605bfcbf..74ea6ef5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,8 +4,6 @@ environment: - TOXENV: py27 - TOXENV: py37 -platform: x64 - matrix: fast_finish: true diff --git a/unyt/array.py b/unyt/array.py index e836c9fb..6cd924cc 100644 --- a/unyt/array.py +++ b/unyt/array.py @@ -1110,10 +1110,10 @@ def argsort(self, axis=-1, kind='quicksort', order=None): ------- >>> from unyt import km >>> data = [3, 8, 7]*km - >>> np.argsort(data) - array([0, 2, 1]) - >>> data.argsort() - array([0, 2, 1]) + >>> print(np.argsort(data)) + [0 2 1] + >>> print(data.argsort()) + [0 2 1] """ return self.view(np.ndarray).argsort(axis, kind, order)