From c8a30811d61ea0b45d82903d0049770d50a3b24c Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Tue, 2 Jun 2020 11:59:42 +0200 Subject: [PATCH 01/15] add ndims property --- heat/core/dndarray.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/heat/core/dndarray.py b/heat/core/dndarray.py index 02b2c4261f..d6cd33bb0c 100644 --- a/heat/core/dndarray.py +++ b/heat/core/dndarray.py @@ -119,6 +119,17 @@ def numdims(self): """ return len(self.__gshape) + @property + def ndims(self): + """ + + Returns + ------- + number_of_dimensions : int + the number of dimensions of the DNDarray + """ + return self.numdims + @property def size(self): """ From 63f349d33604f5ace3ec7bdafef6a3563a0c8c59 Mon Sep 17 00:00:00 2001 From: mtar Date: Tue, 2 Jun 2020 12:12:06 +0200 Subject: [PATCH 02/15] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75cfeb0a5e..1f260a3cea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - [#573](https://github.com/helmholtz-analytics/heat/pull/573) Bugfix: matmul fixes: early out for 2 vectors, remainders not added if inner block is 1 for split 10 case - [#580](https://github.com/helmholtz-analytics/heat/pull/580) New feature: fliplr() +- [#577](https://github.com/helmholtz-analytics/heat/pull/577) Add ndims property in dndarray # v0.4.0 From e54ce0a6885c3b6b29cd41667ced2b8ce4920003 Mon Sep 17 00:00:00 2001 From: mtar Date: Tue, 2 Jun 2020 14:21:17 +0200 Subject: [PATCH 03/15] Update dndarray.py --- heat/core/dndarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heat/core/dndarray.py b/heat/core/dndarray.py index d6cd33bb0c..c21f521d84 100644 --- a/heat/core/dndarray.py +++ b/heat/core/dndarray.py @@ -120,7 +120,7 @@ def numdims(self): return len(self.__gshape) @property - def ndims(self): + def ndim(self): """ Returns From fbf45f9a0acfb767d6a9bffb6bebf496934058cd Mon Sep 17 00:00:00 2001 From: mtar Date: Tue, 2 Jun 2020 14:21:37 +0200 Subject: [PATCH 04/15] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f260a3cea..f93e247674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - [#573](https://github.com/helmholtz-analytics/heat/pull/573) Bugfix: matmul fixes: early out for 2 vectors, remainders not added if inner block is 1 for split 10 case - [#580](https://github.com/helmholtz-analytics/heat/pull/580) New feature: fliplr() - [#577](https://github.com/helmholtz-analytics/heat/pull/577) Add ndims property in dndarray +- [#577](https://github.com/helmholtz-analytics/heat/pull/577) Add ndim property in dndarray # v0.4.0 From c74cc31114418ce92af7d868c5ec4bf7f98cbd8a Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Wed, 3 Jun 2020 15:45:30 +0200 Subject: [PATCH 05/15] add function --- heat/core/manipulations.py | 79 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/heat/core/manipulations.py b/heat/core/manipulations.py index 739b1b27f7..1144b67f00 100644 --- a/heat/core/manipulations.py +++ b/heat/core/manipulations.py @@ -9,6 +9,7 @@ from . import stride_tricks from . import tiling from . import types +from. import linalg __all__ = [ @@ -23,6 +24,7 @@ "hstack", "reshape", "resplit", + "rot90", "sort", "squeeze", "unique", @@ -936,6 +938,83 @@ def reshape_argsort_counts_displs( return factories.array(data, dtype=a.dtype, is_split=axis, device=a.device, comm=a.comm) +def rot90(m, k=1, axes=(0,1)): + """ + Rotate an array by 90 degrees in the plane specified by axes. + Rotation direction is from the first towards the second axis. + Parameters + ---------- + m : array_like + Array of two or more dimensions. + k : integer + Number of times the array is rotated by 90 degrees. + axes: (2,) array_like + The array is rotated in the plane defined by the axes. + Axes must be different. + .. versionadded:: 1.12.0 + + Returns + ------- + y : ndarray + A rotated view of `m`. + + Notes + ----- + rot90(m, k=1, axes=(1,0)) is the reverse of rot90(m, k=1, axes=(0,1)) + rot90(m, k=1, axes=(1,0)) is equivalent to rot90(m, k=-1, axes=(0,1)) + + Examples + -------- + >>> m = np.array([[1,2],[3,4]], int) + >>> m + array([[1, 2], + [3, 4]]) + >>> np.rot90(m) + array([[2, 4], + [1, 3]]) + >>> np.rot90(m, 2) + array([[4, 3], + [2, 1]]) + >>> m = np.arange(8).reshape((2,2,2)) + >>> np.rot90(m, 1, (1,2)) + array([[[1, 3], + [0, 2]], + [[5, 7], + [4, 6]]]) + """ + axes = tuple(axes) + if len(axes) != 2: + raise ValueError("len(axes) must be 2.") + + if not isinstance(m, dndarray.DNDarray): + raise TypeError("expected m to be a ht.DNDarray, but was {}".format(type(m))) + + if axes[0] == axes[1] or np.absolute(axes[0] - axes[1]) == m.ndim: + raise ValueError("Axes must be different.") + + if (axes[0] >= m.ndim or axes[0] < -m.ndim + or axes[1] >= m.ndim or axes[1] < -m.ndim): + raise ValueError("Axes={} out of range for array of ndim={}." + .format(axes, m.ndim)) + + k %= 4 + + if k == 0: + return m[:] + if k == 2: + return flip(flip(m, axes[0]), axes[1]) + + axes_list = np.arange(0, m.ndim).tolist() + (axes_list[axes[0]], axes_list[axes[1]]) = (axes_list[axes[1]], + axes_list[axes[0]]) + + if k == 1: + return linalg.transpose(flip(m,axes[1]), axes_list) + else: + # k == 3 + return flip(linalg.transpose(m, axes_list), axes[1]) + + def sort(a, axis=None, descending=False, out=None): """ Sorts the elements of the DNDarray a along the given dimension (by default in ascending order) by their value. From ceca3c31637e2f8d3d5da4e9c614a1ecfe5c1d43 Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Fri, 5 Jun 2020 08:03:22 +0200 Subject: [PATCH 06/15] modify docstring --- heat/core/manipulations.py | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/heat/core/manipulations.py b/heat/core/manipulations.py index 1144b67f00..9e5af2eab8 100644 --- a/heat/core/manipulations.py +++ b/heat/core/manipulations.py @@ -944,18 +944,17 @@ def rot90(m, k=1, axes=(0,1)): Rotation direction is from the first towards the second axis. Parameters ---------- - m : array_like + m : DNDarray Array of two or more dimensions. k : integer Number of times the array is rotated by 90 degrees. - axes: (2,) array_like + axes: (2,) integer The array is rotated in the plane defined by the axes. Axes must be different. - .. versionadded:: 1.12.0 Returns ------- - y : ndarray + y : DNDarray A rotated view of `m`. Notes @@ -965,22 +964,22 @@ def rot90(m, k=1, axes=(0,1)): Examples -------- - >>> m = np.array([[1,2],[3,4]], int) + >>> m = ht.array([[1,2],[3,4]], dtype=ht.int) >>> m - array([[1, 2], - [3, 4]]) - >>> np.rot90(m) - array([[2, 4], - [1, 3]]) - >>> np.rot90(m, 2) - array([[4, 3], - [2, 1]]) - >>> m = np.arange(8).reshape((2,2,2)) - >>> np.rot90(m, 1, (1,2)) - array([[[1, 3], - [0, 2]], - [[5, 7], - [4, 6]]]) + tensor([[1, 2], + [3, 4]], dtype=torch.int32) + >>> ht.rot90(m) + tensor([[2, 4], + [1, 3]], dtype=torch.int32) + >>> ht.rot90(m, 2) + tensor([[4, 3], + [2, 1]], dtype=torch.int32) + >>> m = ht.arange(8).reshape((2,2,2)) + >>> ht.rot90(m, 1, (1,2)) + tensor([[[1, 3], + [0, 2]], + [[5, 7], + [4, 6]]], dtype=torch.int32) """ axes = tuple(axes) if len(axes) != 2: From 089beaa8386ffe6011ab297061b906e087cdfb53 Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Fri, 5 Jun 2020 10:47:10 +0200 Subject: [PATCH 07/15] add tests --- heat/core/manipulations.py | 28 ++++++++++-------- heat/core/tests/test_manipulations.py | 42 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/heat/core/manipulations.py b/heat/core/manipulations.py index 9e5af2eab8..8e3048a3f0 100644 --- a/heat/core/manipulations.py +++ b/heat/core/manipulations.py @@ -9,7 +9,7 @@ from . import stride_tricks from . import tiling from . import types -from. import linalg +from . import linalg __all__ = [ @@ -938,7 +938,7 @@ def reshape_argsort_counts_displs( return factories.array(data, dtype=a.dtype, is_split=axis, device=a.device, comm=a.comm) -def rot90(m, k=1, axes=(0,1)): +def rot90(m, k=1, axes=(0, 1)): """ Rotate an array by 90 degrees in the plane specified by axes. Rotation direction is from the first towards the second axis. @@ -948,10 +948,10 @@ def rot90(m, k=1, axes=(0,1)): Array of two or more dimensions. k : integer Number of times the array is rotated by 90 degrees. - axes: (2,) integer + axes: (2,) int list or tuple The array is rotated in the plane defined by the axes. Axes must be different. - + Returns ------- y : DNDarray @@ -961,7 +961,9 @@ def rot90(m, k=1, axes=(0,1)): ----- rot90(m, k=1, axes=(1,0)) is the reverse of rot90(m, k=1, axes=(0,1)) rot90(m, k=1, axes=(1,0)) is equivalent to rot90(m, k=-1, axes=(0,1)) - + + May change the split axis on distributed tensors + Examples -------- >>> m = ht.array([[1,2],[3,4]], dtype=ht.int) @@ -991,10 +993,13 @@ def rot90(m, k=1, axes=(0,1)): if axes[0] == axes[1] or np.absolute(axes[0] - axes[1]) == m.ndim: raise ValueError("Axes must be different.") - if (axes[0] >= m.ndim or axes[0] < -m.ndim - or axes[1] >= m.ndim or axes[1] < -m.ndim): - raise ValueError("Axes={} out of range for array of ndim={}." - .format(axes, m.ndim)) + if axes[0] >= m.ndim or axes[0] < -m.ndim or axes[1] >= m.ndim or axes[1] < -m.ndim: + raise ValueError("Axes={} out of range for array of ndim={}.".format(axes, m.ndim)) + + if m.split is None: + return factories.array( + torch.rot90(m._DNDarray__array, k, axes), dtype=m.dtype, device=m.device, comm=m.comm + ) k %= 4 @@ -1004,11 +1009,10 @@ def rot90(m, k=1, axes=(0,1)): return flip(flip(m, axes[0]), axes[1]) axes_list = np.arange(0, m.ndim).tolist() - (axes_list[axes[0]], axes_list[axes[1]]) = (axes_list[axes[1]], - axes_list[axes[0]]) + (axes_list[axes[0]], axes_list[axes[1]]) = (axes_list[axes[1]], axes_list[axes[0]]) if k == 1: - return linalg.transpose(flip(m,axes[1]), axes_list) + return linalg.transpose(flip(m, axes[1]), axes_list) else: # k == 3 return flip(linalg.transpose(m, axes_list), axes[1]) diff --git a/heat/core/tests/test_manipulations.py b/heat/core/tests/test_manipulations.py index 5778d4a567..b86a7691ff 100644 --- a/heat/core/tests/test_manipulations.py +++ b/heat/core/tests/test_manipulations.py @@ -1058,6 +1058,48 @@ def test_reshape(self): with self.assertRaises(TypeError): ht.reshape(ht.zeros((4, 3)), "(5, 7)") + def test_rot90(self): + size = ht.MPI_WORLD.size + m = ht.arange(size ** 3, dtype=ht.int).reshape((size, size, size)) + + self.assertTrue(ht.equal(ht.rot90(m, 0), m)) + self.assertTrue(ht.equal(ht.rot90(m, 4), m)) + self.assertTrue(ht.equal(ht.rot90(ht.rot90(m, 1), 1, (1, 0)), m)) + + a = ht.resplit(m, 0) + + self.assertTrue(ht.equal(ht.rot90(a), ht.resplit(ht.rot90(m), 1))) + self.assertTrue(ht.equal(ht.rot90(a, 2), ht.resplit(ht.rot90(m, 2), 0))) + self.assertTrue(ht.equal(ht.rot90(a, 3, (1, 2)), ht.resplit(ht.rot90(m, 3, (1, 2)), 0))) + + m = ht.arange(size ** 3, dtype=ht.float).reshape((size, size, size)) + a = ht.resplit(m, 1) + + self.assertTrue(ht.equal(ht.rot90(a), ht.resplit(ht.rot90(m), 0))) + self.assertTrue(ht.equal(ht.rot90(a, 2), ht.resplit(ht.rot90(m, 2), 1))) + self.assertTrue(ht.equal(ht.rot90(a, 3, (1, 2)), ht.resplit(ht.rot90(m, 3, (1, 2)), 2))) + + a = ht.resplit(m, 2) + + self.assertTrue(ht.equal(ht.rot90(a), ht.resplit(ht.rot90(m), 2))) + self.assertTrue(ht.equal(ht.rot90(a, 2), ht.resplit(ht.rot90(m, 2), 2))) + self.assertTrue(ht.equal(ht.rot90(a, 3, (1, 2)), ht.resplit(ht.rot90(m, 3, (1, 2)), 1))) + + with self.assertRaises(ValueError): + ht.rot90(ht.ones((2, 3)), 1, (0, 1, 2)) + with self.assertRaises(TypeError): + ht.rot90(torch.tensor((2, 3))) + with self.assertRaises(ValueError): + ht.rot90(ht.zeros((2, 2)), 1, (0, 0)) + with self.assertRaises(ValueError): + ht.rot90(ht.zeros((2, 2)), 1, (-3, 1)) + with self.assertRaises(ValueError): + ht.rot90(ht.zeros((2, 2)), 1, (4, 1)) + with self.assertRaises(ValueError): + ht.rot90(ht.zeros((2, 2)), 1, (0, -2)) + with self.assertRaises(ValueError): + ht.rot90(ht.zeros((2, 2)), 1, (0, 3)) + def test_sort(self): size = ht.MPI_WORLD.size rank = ht.MPI_WORLD.rank From 0b428e5406877df0c4c11cb5ac59e949c444b546 Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Fri, 5 Jun 2020 10:57:46 +0200 Subject: [PATCH 08/15] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f93e247674..9dbe253a7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#580](https://github.com/helmholtz-analytics/heat/pull/580) New feature: fliplr() - [#577](https://github.com/helmholtz-analytics/heat/pull/577) Add ndims property in dndarray - [#577](https://github.com/helmholtz-analytics/heat/pull/577) Add ndim property in dndarray +- [#582](https://github.com/helmholtz-analytics/heat/pull/582) New feature: rot90 # v0.4.0 From 055618c44f77c4e6b0ccba3cb94a23e40bb7f689 Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Fri, 5 Jun 2020 11:08:48 +0200 Subject: [PATCH 09/15] update changelog --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dbe253a7f..0ea6cc7a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,9 @@ # Pending Additions - [#573](https://github.com/helmholtz-analytics/heat/pull/573) Bugfix: matmul fixes: early out for 2 vectors, remainders not added if inner block is 1 for split 10 case -- [#580](https://github.com/helmholtz-analytics/heat/pull/580) New feature: fliplr() -- [#577](https://github.com/helmholtz-analytics/heat/pull/577) Add ndims property in dndarray - [#577](https://github.com/helmholtz-analytics/heat/pull/577) Add ndim property in dndarray -- [#582](https://github.com/helmholtz-analytics/heat/pull/582) New feature: rot90 +- [#580](https://github.com/helmholtz-analytics/heat/pull/580) New feature: fliplr() +- [#582](https://github.com/helmholtz-analytics/heat/pull/582) New feature: rot90() # v0.4.0 From 338bbb97c9843b23c9aa695700bb26a9012be96a Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Fri, 5 Jun 2020 11:14:02 +0200 Subject: [PATCH 10/15] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ea6cc7a6a..b0e4f3360e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ - [#573](https://github.com/helmholtz-analytics/heat/pull/573) Bugfix: matmul fixes: early out for 2 vectors, remainders not added if inner block is 1 for split 10 case - [#577](https://github.com/helmholtz-analytics/heat/pull/577) Add ndim property in dndarray - [#580](https://github.com/helmholtz-analytics/heat/pull/580) New feature: fliplr() -- [#582](https://github.com/helmholtz-analytics/heat/pull/582) New feature: rot90() +- [#583](https://github.com/helmholtz-analytics/heat/pull/583) New feature: rot90() # v0.4.0 From 387d8d0c1c7f54db1d39abfd9beed4032e8fb809 Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Fri, 5 Jun 2020 11:16:57 +0200 Subject: [PATCH 11/15] update dndarray --- heat/core/dndarray.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/heat/core/dndarray.py b/heat/core/dndarray.py index 461f5ba02b..f4db26cb2e 100644 --- a/heat/core/dndarray.py +++ b/heat/core/dndarray.py @@ -132,17 +132,6 @@ def ndim(self): """ return len(self.__gshape) - @property - def ndim(self): - """ - - Returns - ------- - number_of_dimensions : int - the number of dimensions of the DNDarray - """ - return self.numdims - @property def size(self): """ From c6fd0ec46cb071e01388d05b30a376fae4f3151e Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Fri, 5 Jun 2020 11:20:29 +0200 Subject: [PATCH 12/15] increase coverage --- heat/core/tests/test_manipulations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/heat/core/tests/test_manipulations.py b/heat/core/tests/test_manipulations.py index b86a7691ff..bd77f50f92 100644 --- a/heat/core/tests/test_manipulations.py +++ b/heat/core/tests/test_manipulations.py @@ -1068,6 +1068,7 @@ def test_rot90(self): a = ht.resplit(m, 0) + self.assertTrue(ht.equal(ht.rot90(a, 0), a)) self.assertTrue(ht.equal(ht.rot90(a), ht.resplit(ht.rot90(m), 1))) self.assertTrue(ht.equal(ht.rot90(a, 2), ht.resplit(ht.rot90(m, 2), 0))) self.assertTrue(ht.equal(ht.rot90(a, 3, (1, 2)), ht.resplit(ht.rot90(m, 3, (1, 2)), 0))) @@ -1075,12 +1076,14 @@ def test_rot90(self): m = ht.arange(size ** 3, dtype=ht.float).reshape((size, size, size)) a = ht.resplit(m, 1) + self.assertTrue(ht.equal(ht.rot90(a, 0), a)) self.assertTrue(ht.equal(ht.rot90(a), ht.resplit(ht.rot90(m), 0))) self.assertTrue(ht.equal(ht.rot90(a, 2), ht.resplit(ht.rot90(m, 2), 1))) self.assertTrue(ht.equal(ht.rot90(a, 3, (1, 2)), ht.resplit(ht.rot90(m, 3, (1, 2)), 2))) a = ht.resplit(m, 2) + self.assertTrue(ht.equal(ht.rot90(a, 0), a)) self.assertTrue(ht.equal(ht.rot90(a), ht.resplit(ht.rot90(m), 2))) self.assertTrue(ht.equal(ht.rot90(a, 2), ht.resplit(ht.rot90(m, 2), 2))) self.assertTrue(ht.equal(ht.rot90(a, 3, (1, 2)), ht.resplit(ht.rot90(m, 3, (1, 2)), 1))) From ff7892d97a0312f725e0f578f1b118aa8bf9e3ae Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Thu, 18 Jun 2020 13:39:13 +0200 Subject: [PATCH 13/15] docstring and int casting --- heat/core/manipulations.py | 23 +++++++++++++++++++---- heat/core/tests/test_manipulations.py | 2 ++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/heat/core/manipulations.py b/heat/core/manipulations.py index 82f082ef1a..3297b7f9c8 100644 --- a/heat/core/manipulations.py +++ b/heat/core/manipulations.py @@ -6,10 +6,10 @@ from . import dndarray from . import factories +from . import linalg from . import stride_tricks from . import tiling from . import types -from . import linalg __all__ = [ @@ -942,6 +942,7 @@ def rot90(m, k=1, axes=(0, 1)): """ Rotate an array by 90 degrees in the plane specified by axes. Rotation direction is from the first towards the second axis. + Parameters ---------- m : DNDarray @@ -954,8 +955,7 @@ def rot90(m, k=1, axes=(0, 1)): Returns ------- - y : DNDarray - A rotated view of `m`. + DNDarray Notes ----- @@ -964,6 +964,16 @@ def rot90(m, k=1, axes=(0, 1)): May change the split axis on distributed tensors + Raises + ------ + TypeError + If first parameter is not a :class:DNDarray + If parameter ``k`` is not castable to integer + ValueError + If ``len(axis)!=2`` + If the axes are the same + If axes are out of range + Examples -------- >>> m = ht.array([[1,2],[3,4]], dtype=ht.int) @@ -1001,10 +1011,15 @@ def rot90(m, k=1, axes=(0, 1)): torch.rot90(m._DNDarray__array, k, axes), dtype=m.dtype, device=m.device, comm=m.comm ) + try: + k = int(k) + except (TypeError, ValueError): + raise TypeError("Unknown type, must be castable to integer") + k %= 4 if k == 0: - return m[:] + return m.copy() if k == 2: return flip(flip(m, axes[0]), axes[1]) diff --git a/heat/core/tests/test_manipulations.py b/heat/core/tests/test_manipulations.py index bd77f50f92..7f837a5e97 100644 --- a/heat/core/tests/test_manipulations.py +++ b/heat/core/tests/test_manipulations.py @@ -1102,6 +1102,8 @@ def test_rot90(self): ht.rot90(ht.zeros((2, 2)), 1, (0, -2)) with self.assertRaises(ValueError): ht.rot90(ht.zeros((2, 2)), 1, (0, 3)) + with self.assertRaises(TypeError): + ht.rot90(ht.zeros((2, 3)), "k", (0, 1)) def test_sort(self): size = ht.MPI_WORLD.size From cf639bf592a64a890641f417e8ef92b868eae33c Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Tue, 30 Jun 2020 16:01:08 +0200 Subject: [PATCH 14/15] doctring formatting raises section --- heat/core/manipulations.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/heat/core/manipulations.py b/heat/core/manipulations.py index 228ab70127..eea5833245 100644 --- a/heat/core/manipulations.py +++ b/heat/core/manipulations.py @@ -967,12 +967,15 @@ def rot90(m, k=1, axes=(0, 1)): Raises ------ TypeError - If first parameter is not a :class:DNDarray - If parameter ``k`` is not castable to integer + If first parameter is not a :class:DNDarray. + TypeError + If parameter ``k`` is not castable to integer. + ValueError + If ``len(axis)!=2``. + ValueError + If the axes are the same. ValueError - If ``len(axis)!=2`` - If the axes are the same - If axes are out of range + If axes are out of range. Examples -------- From 42a1f0d98336e1627ee1c2adcee6e40445638c93 Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Wed, 1 Jul 2020 16:03:15 +0200 Subject: [PATCH 15/15] black formatting --- heat/core/manipulations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heat/core/manipulations.py b/heat/core/manipulations.py index 47ce868e7d..175c11afc3 100644 --- a/heat/core/manipulations.py +++ b/heat/core/manipulations.py @@ -1039,7 +1039,7 @@ def rot90(m, k=1, axes=(0, 1)): # k == 3 return flip(linalg.transpose(m, axes_list), axes[1]) - + def shape(a): """ Returns the shape of a DNDarray `a`.