@@ -5464,15 +5464,30 @@ def test_vdot_uncontiguous_2(self):
5464
5464
np .vdot (a .flatten (), b .flatten ()))
5465
5465
5466
5466
5467
- @pytest .mark .xfail (reason = 'TODO' )
5468
5467
class TestDot :
5469
5468
def setup_method (self ):
5470
5469
np .random .seed (128 )
5471
- self .A = np .random .rand (4 , 2 )
5472
- self .b1 = np .random .rand (2 , 1 )
5473
- self .b2 = np .random .rand (2 )
5474
- self .b3 = np .random .rand (1 , 2 )
5475
- self .b4 = np .random .rand (4 )
5470
+
5471
+ # Numpy guarantees the random stream, and we don't. So inline the
5472
+ # values from numpy 1.24.1
5473
+ # self.A = np.random.rand(4, 2)
5474
+ self .A = np .array ([[0.86663704 , 0.26314485 ],
5475
+ [0.13140848 , 0.04159344 ],
5476
+ [0.23892433 , 0.6454746 ],
5477
+ [0.79059935 , 0.60144244 ]])
5478
+
5479
+ # self.b1 = np.random.rand(2, 1)
5480
+ self .b1 = np .array ([[0.33429937 ], [0.11942846 ]])
5481
+
5482
+ # self.b2 = np.random.rand(2)
5483
+ self .b2 = np .array ([0.30913305 , 0.10972379 ])
5484
+
5485
+ # self.b3 = np.random.rand(1, 2)
5486
+ self .b3 = np .array ([[0.60211331 , 0.25128496 ]])
5487
+
5488
+ # self.b4 = np.random.rand(4)
5489
+ self .b4 = np .array ([0.29968129 , 0.517116 , 0.71520252 , 0.9314494 ])
5490
+
5476
5491
self .N = 7
5477
5492
5478
5493
def test_dotmatmat (self ):
@@ -5541,16 +5556,26 @@ def test_dotcolumnvect2(self):
5541
5556
5542
5557
def test_dotvecscalar (self ):
5543
5558
np .random .seed (100 )
5544
- b1 = np .random .rand (1 , 1 )
5545
- b2 = np .random .rand (1 , 4 )
5559
+ # Numpy guarantees the random stream, and we don't. So inline the
5560
+ # values from numpy 1.24.1
5561
+ # b1 = np.random.rand(1, 1)
5562
+ b1 = np .array ([[0.54340494 ]])
5563
+
5564
+ # b2 = np.random.rand(1, 4)
5565
+ b2 = np .array ([[0.27836939 , 0.42451759 , 0.84477613 , 0.00471886 ]])
5566
+
5546
5567
res = np .dot (b1 , b2 )
5547
5568
tgt = np .array ([[0.15126730 , 0.23068496 , 0.45905553 , 0.00256425 ]])
5548
5569
assert_almost_equal (res , tgt , decimal = self .N )
5549
5570
5550
5571
def test_dotvecscalar2 (self ):
5551
5572
np .random .seed (100 )
5552
- b1 = np .random .rand (4 , 1 )
5553
- b2 = np .random .rand (1 , 1 )
5573
+ # b1 = np.random.rand(4, 1)
5574
+ b1 = np .array ([[0.54340494 ], [0.27836939 ], [0.42451759 ], [0.84477613 ]])
5575
+
5576
+ # b2 = np.random.rand(1, 1)
5577
+ b2 = np .array ([[0.00471886 ]])
5578
+
5554
5579
res = np .dot (b1 , b2 )
5555
5580
tgt = np .array ([[0.00256425 ],[0.00131359 ],[0.00200324 ],[ 0.00398638 ]])
5556
5581
assert_almost_equal (res , tgt , decimal = self .N )
@@ -5566,39 +5591,7 @@ def test_all(self):
5566
5591
assert_ (res .shape == tgt .shape )
5567
5592
assert_almost_equal (res , tgt , decimal = self .N )
5568
5593
5569
- def test_vecobject (self ):
5570
- class Vec :
5571
- def __init__ (self , sequence = None ):
5572
- if sequence is None :
5573
- sequence = []
5574
- self .array = np .array (sequence )
5575
-
5576
- def __add__ (self , other ):
5577
- out = Vec ()
5578
- out .array = self .array + other .array
5579
- return out
5580
-
5581
- def __sub__ (self , other ):
5582
- out = Vec ()
5583
- out .array = self .array - other .array
5584
- return out
5585
-
5586
- def __mul__ (self , other ): # with scalar
5587
- out = Vec (self .array .copy ())
5588
- out .array *= other
5589
- return out
5590
-
5591
- def __rmul__ (self , other ):
5592
- return self * other
5593
-
5594
- U_non_cont = np .transpose ([[1. , 1. ], [1. , 2. ]])
5595
- U_cont = np .ascontiguousarray (U_non_cont )
5596
- x = np .array ([Vec ([1. , 0. ]), Vec ([0. , 1. ])])
5597
- zeros = np .array ([Vec ([0. , 0. ]), Vec ([0. , 0. ])])
5598
- zeros_test = np .dot (U_cont , x ) - np .dot (U_non_cont , x )
5599
- assert_equal (zeros [0 ].array , zeros_test [0 ].array )
5600
- assert_equal (zeros [1 ].array , zeros_test [1 ].array )
5601
-
5594
+ @pytest .mark .skip (reason = 'numpy internals' )
5602
5595
def test_dot_2args (self ):
5603
5596
from numpy .core .multiarray import dot
5604
5597
@@ -5609,6 +5602,7 @@ def test_dot_2args(self):
5609
5602
d = dot (a , b )
5610
5603
assert_allclose (c , d )
5611
5604
5605
+ @pytest .mark .skip (reason = 'numpy internals' )
5612
5606
def test_dot_3args (self ):
5613
5607
from numpy .core .multiarray import dot
5614
5608
@@ -5631,6 +5625,7 @@ def test_dot_3args(self):
5631
5625
assert_ (r is dot (f , v , r ))
5632
5626
assert_array_equal (r2 , r )
5633
5627
5628
+ @pytest .mark .skip (reason = 'numpy internals' )
5634
5629
def test_dot_3args_errors (self ):
5635
5630
from numpy .core .multiarray import dot
5636
5631
@@ -5661,6 +5656,7 @@ def test_dot_3args_errors(self):
5661
5656
r = np .empty ((1024 , 32 ), dtype = int )
5662
5657
assert_raises (ValueError , dot , f , v , r )
5663
5658
5659
+ @pytest .mark .skip (reason = "TODO order='F'" )
5664
5660
def test_dot_array_order (self ):
5665
5661
a = np .array ([[1 , 2 ], [3 , 4 ]], order = 'C' )
5666
5662
b = np .array ([[1 , 2 ], [3 , 4 ]], order = 'F' )
@@ -5671,6 +5667,7 @@ def test_dot_array_order(self):
5671
5667
assert_equal (np .dot (b , a ), res )
5672
5668
assert_equal (np .dot (b , b ), res )
5673
5669
5670
+ @pytest .mark .skip (reason = 'TODO: nbytes, view' )
5674
5671
def test_accelerate_framework_sgemv_fix (self ):
5675
5672
5676
5673
def aligned_array (shape , align , dtype , order = 'C' ):
@@ -5745,26 +5742,14 @@ def test_huge_vectordot(self, dtype):
5745
5742
res = np .dot (data , data )
5746
5743
assert res == 2 ** 30 + 100
5747
5744
5748
- def test_dtype_discovery_fails (self ):
5749
- # See gh-14247, error checking was missing for failed dtype discovery
5750
- class BadObject (object ):
5751
- def __array__ (self ):
5752
- raise TypeError ("just this tiny mint leaf" )
5753
-
5754
- with pytest .raises (TypeError ):
5755
- np .dot (BadObject (), BadObject ())
5756
-
5757
- with pytest .raises (TypeError ):
5758
- np .dot (3.0 , BadObject ())
5759
-
5760
5745
5761
5746
class MatmulCommon :
5762
5747
"""Common tests for '@' operator and numpy.matmul.
5763
5748
5764
5749
"""
5765
5750
# Should work with these types. Will want to add
5766
5751
# "O" at some point
5767
- types = "?bhilqBHILQefdgFDGO "
5752
+ types = "?bhilqBefdFD "
5768
5753
5769
5754
def test_exceptions (self ):
5770
5755
dims = [
@@ -5975,7 +5960,7 @@ def test_matrix_matrix_values(self):
5975
5960
assert_equal (res , tgt12_21 )
5976
5961
5977
5962
5978
- @pytest .mark .xfail (reason = 'TODO' )
5963
+ @pytest .mark .xfail (reason = 'TODO: matmul (ufunc wrapping goes south?) ' )
5979
5964
class TestMatmul (MatmulCommon ):
5980
5965
matmul = np .matmul
5981
5966
0 commit comments