@@ -597,7 +597,10 @@ def test_getitem(self):
597
597
# la[[1, 5, 9], age['1,5,9']]
598
598
self .assertRaises (ValueError , la .__getitem__ , ([1 , 5 ], age ['1,5' ]))
599
599
600
- def test_setitem (self ):
600
+ def test_setitem_larray (self ):
601
+ """
602
+ tests LArray.__setitem__(key, value) where value is an LArray
603
+ """
601
604
age , geo , sex , lipro = self .larray .axes
602
605
603
606
# 1) using a ValueGroup key
@@ -611,7 +614,7 @@ def test_setitem(self):
611
614
raw [[1 , 5 , 9 ]] = raw [[1 , 5 , 9 ]] + 25.0
612
615
self ._assert_equal_raw (la , raw )
613
616
614
- # b) same size but a different shape ( extra length-1 axis)
617
+ # b) value has an extra length-1 axis
615
618
la = self .larray .copy ()
616
619
raw = self .array .copy ()
617
620
@@ -624,16 +627,17 @@ def test_setitem(self):
624
627
raw [[1 , 5 , 9 ]] = raw [[1 , 5 , 9 ]] + 26.0
625
628
self ._assert_equal_raw (la , raw )
626
629
627
- # dimension of length 1
630
+ # c) value has the same axes than target but one has length 1
628
631
la = self .larray .copy ()
629
632
raw = self .array .copy ()
630
633
raw [[1 , 5 , 9 ]] = np .sum (raw [[1 , 5 , 9 ]], axis = 1 , keepdims = True )
631
634
la [ages1_5_9 ] = la [ages1_5_9 ].sum (geo = (geo .all (),))
632
635
self ._assert_equal_raw (la , raw )
633
636
634
- # c) missing dimension
637
+ # d) value has a missing dimension
635
638
la = self .larray .copy ()
636
639
la [ages1_5_9 ] = la [ages1_5_9 ].sum (geo )
640
+ # we use "raw" from previous test
637
641
self ._assert_equal_raw (la , raw )
638
642
639
643
# 2) using a string key
0 commit comments