File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,10 @@ def testBlkDiagMatrixApply(self):
145145 e [:, i ] = self .blk_a .apply (coeffm [:, i ])
146146 self .allallfunc (e , d )
147147
148+ # We can use syntactic sugar @ for apply as well
149+ f = self .blk_a @ coeffm
150+ self .allallfunc (f , d )
151+
148152 # Test the rapply is also functional
149153 coeffm = coeffm .T # matmul dimensions
150154 res = coeffm @ self .blk_a .dense ()
@@ -155,6 +159,17 @@ def testBlkDiagMatrixApply(self):
155159 d = coeffm @ self .blk_a
156160 self .allallfunc (res , d )
157161
162+ # And test some incorrrect invocations:
163+ # inplace not supported for matmul of mixed classes.
164+ with pytest .raises (RuntimeError , match = r".*method not supported.*" ):
165+ self .blk_a @= coeffm
166+
167+ # Test left operand of an __rmatmul__ must be an ndarray
168+ with pytest .raises (
169+ RuntimeError , match = r".*only defined for np.ndarray @ BlkDiagMatrix.*"
170+ ):
171+ _ = list (coeffm ) @ self .blk_a
172+
158173 def testBlkDiagMatrixMatMult (self ):
159174 result = [np .matmul (* tup ) for tup in zip (self .blk_a , self .blk_b )]
160175
You can’t perform that action at this time.
0 commit comments