File tree 1 file changed +74
-0
lines changed
1 file changed +74
-0
lines changed Original file line number Diff line number Diff line change @@ -1409,6 +1409,33 @@ def test_tstack(self):
1409
1409
),
1410
1410
)
1411
1411
1412
+ # Ensuring that contiguity is maintained.
1413
+ a = np .array ([0 , 1 , 2 ], dtype = DTYPE_FLOAT_DEFAULT )
1414
+ b = tstack ([a , a , a ])
1415
+ assert b .flags .contiguous
1416
+
1417
+ # Ensuring that independence is maintained.
1418
+ a *= 2
1419
+ np .testing .assert_array_equal (
1420
+ b ,
1421
+ np .array (
1422
+ [
1423
+ [0 , 0 , 0 ],
1424
+ [1 , 1 , 1 ],
1425
+ [2 , 2 , 2 ],
1426
+ ],
1427
+ ),
1428
+ )
1429
+
1430
+ a = np .array ([0 , 1 , 2 ], dtype = DTYPE_FLOAT_DEFAULT )
1431
+ b = tstack ([a , a , a ])
1432
+
1433
+ b [1 ] *= 2
1434
+ np .testing .assert_array_equal (
1435
+ a ,
1436
+ np .array ([0 , 1 , 2 ]),
1437
+ )
1438
+
1412
1439
1413
1440
class TestTsplit (unittest .TestCase ):
1414
1441
"""
@@ -1484,6 +1511,53 @@ def test_tsplit(self):
1484
1511
),
1485
1512
)
1486
1513
1514
+ # Ensuring that contiguity is maintained.
1515
+ a = np .array (
1516
+ [
1517
+ [0 , 0 , 0 ],
1518
+ [1 , 1 , 1 ],
1519
+ [2 , 2 , 2 ],
1520
+ ],
1521
+ dtype = DTYPE_FLOAT_DEFAULT ,
1522
+ )
1523
+ b = tsplit (a )
1524
+ assert b .flags .contiguous
1525
+
1526
+ # Ensuring that independence is maintained.
1527
+ a *= 2
1528
+ np .testing .assert_array_equal (
1529
+ b ,
1530
+ np .array (
1531
+ [
1532
+ [0 , 1 , 2 ],
1533
+ [0 , 1 , 2 ],
1534
+ [0 , 1 , 2 ],
1535
+ ]
1536
+ ),
1537
+ )
1538
+
1539
+ a = np .array (
1540
+ [
1541
+ [0 , 0 , 0 ],
1542
+ [1 , 1 , 1 ],
1543
+ [2 , 2 , 2 ],
1544
+ ],
1545
+ dtype = DTYPE_FLOAT_DEFAULT ,
1546
+ )
1547
+ b = tsplit (a )
1548
+
1549
+ b [1 ] *= 2
1550
+ np .testing .assert_array_equal (
1551
+ a ,
1552
+ np .array (
1553
+ [
1554
+ [0 , 0 , 0 ],
1555
+ [1 , 1 , 1 ],
1556
+ [2 , 2 , 2 ],
1557
+ ]
1558
+ ),
1559
+ )
1560
+
1487
1561
1488
1562
class TestRowAsDiagonal (unittest .TestCase ):
1489
1563
"""
You can’t perform that action at this time.
0 commit comments