Skip to content

Commit

Permalink
Merge b7fb2ed into 613efdb
Browse files Browse the repository at this point in the history
  • Loading branch information
hekaisheng committed Jul 22, 2019
2 parents 613efdb + b7fb2ed commit bd19fd3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions mars/tensor/execution/tests/test_arithmetic_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ def testAddWithOutExecution(self):
expected = np.add(data1, 1, where=data1 > .5)
self.assertTrue(np.array_equal(res[data1 > .5], expected[data1 > .5]))

arr1 = tensor(data2.copy(), chunk_size=3)

arr3 = add(arr1[:5, :], 1, out=arr1[-5:, :])
res = self.executor.execute_tensor(arr3, concat=True)[0]
expected = np.add(data2[:5, :], 1)
self.assertTrue(np.array_equal(res, expected))

def testFrexpExecution(self):
data1 = np.random.random((5, 9, 4))

Expand Down
4 changes: 4 additions & 0 deletions mars/tensor/execution/tests/test_index_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def testSliceExecution(self):

self.assertTrue(np.array_equal(res[0], raw[2:9:2, 3:7, -1:-9:-2, 12:-11:-4]))

arr3 = arr[-4, 2:]
res = self.executor.execute_tensor(arr3, concat=True)
np.testing.assert_equal(res[0], raw[-4, 2:])

raw = sps.random(12, 14, density=.1)
arr = tensor(raw, chunk_size=3)

Expand Down
5 changes: 3 additions & 2 deletions mars/tensor/expressions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def slice_split(index, sizes):
size = sum(sizes)

if isinstance(index, Integral):
index = index if index >= 0 else size + index
i = 0
ind = index
lens = list(sizes)
Expand Down Expand Up @@ -329,8 +330,8 @@ def unify_nsplits(*tensor_axes):
from .rechunk import rechunk

tensor_splits = [dict((a, split) for a, split in izip(axes, t.nsplits) if split != (1,))
for t, axes in tensor_axes]
common_axes = reduce(operator.and_, [set(lkeys(ts)) for ts in tensor_splits])
for t, axes in tensor_axes if t.nsplits]
common_axes = reduce(operator.and_, [set(lkeys(ts)) for ts in tensor_splits]) if tensor_splits else set()
axes_unified_splits = dict((ax, decide_unify_split(*(t[ax] for t in tensor_splits)))
for ax in common_axes)

Expand Down

0 comments on commit bd19fd3

Please sign in to comment.