MCPcopy Create free account
hub / github.com/DedalusProject/dedalus / __init__

Method __init__

dedalus/core/arithmetic.py:592–618  ·  view source on GitHub ↗
(self, arg0, arg1, indices=(-1,0), out=None, **kw)

Source from the content-addressed store, hash-verified

590 ncc_method = "dot_product_ncc"
591
592 def __init__(self, arg0, arg1, indices=(-1,0), out=None, **kw):
593 indices = self._check_indices(arg0, arg1, indices)
594 super().__init__(arg0, arg1, out=out)
595 arg0_ts_reduced = list(arg0.tensorsig)
596 arg0_ts_reduced.pop(indices[0])
597 arg1_ts_reduced = list(arg1.tensorsig)
598 arg1_ts_reduced.pop(indices[1])
599 self.indices = indices
600 self.gamma_args = [indices]
601 # FutureField requirements
602 dist = unify_attributes((arg0, arg1), 'dist')
603 self.domain = Domain(dist, self._build_bases(arg0, arg1, **kw))
604 self.tensorsig = tuple(arg0_ts_reduced + arg1_ts_reduced)
605 self.dtype = np.result_type(arg0.dtype, arg1.dtype)
606 # Setup ghost broadcasting
607 broadcast_dims = np.array(self.domain.nonconstant)
608 self.arg0_ghost_broadcaster = GhostBroadcaster(arg0.domain, self.dist.grid_layout, broadcast_dims)
609 self.arg1_ghost_broadcaster = GhostBroadcaster(arg1.domain, self.dist.grid_layout, broadcast_dims)
610 # Compose eigsum string
611 rank0 = len(arg0.tensorsig)
612 rank1 = len(arg1.tensorsig)
613 arg1_str = alphabet[:rank0]
614 arg2_str = alphabet[rank0:rank0+rank1]
615 arg1_str = arg1_str.replace(arg1_str[indices[0]], 'z')
616 arg2_str = arg2_str.replace(arg2_str[indices[1]], 'z')
617 out_str = (arg1_str + arg2_str).replace('z', '')
618 self.einsum_str = arg1_str + '...,' + arg2_str + '...->' + out_str + '...'
619
620 def _check_indices(self, arg0, arg1, indices):
621 if (not isinstance(arg0, Operand)) or (not isinstance(arg1, Operand)):

Callers

nothing calls this directly

Calls 8

_check_indicesMethod · 0.95
unify_attributesFunction · 0.85
DomainClass · 0.85
GhostBroadcasterClass · 0.85
arrayMethod · 0.80
__init__Method · 0.45
_build_basesMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected