Skip to content

Commit

Permalink
Elemwise
Browse files Browse the repository at this point in the history
  • Loading branch information
soraros committed Jan 19, 2021
1 parent 27d4d95 commit 111eecd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nutils/evaluable.py
Original file line number Diff line number Diff line change
Expand Up @@ -2321,7 +2321,7 @@ def __init__(self, data:types.tuple[types.frozenarray], index:asarray, dtype:asd

def evalf(self, index):
assert index.ndim == 0
return self.data[index]
return self.data[index].astype(self.dtype, copy=False, casting='same_kind')

def _simplified(self):
if all(map(numeric.isint, self.shape)) and all(self.data[0] == data for data in self.data[1:]):
Expand All @@ -2339,7 +2339,7 @@ def __init__(self, func, index:asarray, shape:asshape, dtype:asdtype):

def evalf(self, index):
i = index.__index__()
return types.frozenarray(self._func(i))
return types.frozenarray(self._func(i), dtype=self.dtype)

class Eig(Evaluable):

Expand Down
1 change: 1 addition & 0 deletions nutils/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ def _sorted_index_mask(sorted_array, values):
values = numpy.asarray(values)
assert sorted_array.ndim == 1 and values.ndim == 1
if len(sorted_array):
# searchsorted always returns an array with dtype np.int64 regardless of its arguments
indices = numpy.searchsorted(sorted_array[:-1], values)
mask = numpy.equal(sorted_array[indices], values)
else:
Expand Down

0 comments on commit 111eecd

Please sign in to comment.