@@ -402,6 +402,11 @@ def set_field_slice(arr):
402402 return arr
403403
404404
405+ def assign_array_to_nested (dest ):
406+ tmp = (np .arange (3 ) + 1 ).astype (np .int16 )
407+ dest ['array1' ] = tmp
408+
409+
405410recordtype = np .dtype ([('a' , np .float64 ),
406411 ('b' , np .int16 ),
407412 ('c' , np .complex64 ),
@@ -429,6 +434,8 @@ def set_field_slice(arr):
429434 ('p' , np .float32 , (3 , 2 , 5 , 7 )),
430435 ('q' , 'U10' ),])
431436
437+ nested_array1_dtype = np .dtype ([("array1" , np .int16 , (3 ,))], align = True )
438+
432439
433440class TestRecordDtypeMakeCStruct (unittest .TestCase ):
434441 def test_two_scalars (self ):
@@ -1623,6 +1630,42 @@ def test_broadcast_slice(self):
16231630 arr_res = cfunc (arg )
16241631 np .testing .assert_equal (arr_res , arr_expected )
16251632
1633+ def test_assign_array_to_nested (self ):
1634+ got = np .zeros (2 , dtype = nested_array1_dtype )
1635+ expected = np .zeros (2 , dtype = nested_array1_dtype )
1636+
1637+ cfunc = njit (assign_array_to_nested )
1638+ cfunc (got [0 ])
1639+ assign_array_to_nested (expected [0 ])
1640+
1641+ np .testing .assert_array_equal (expected , got )
1642+
1643+ def test_issue_7693 (self ):
1644+ src_dtype = np .dtype ([
1645+ ("user" , np .float64 ),
1646+ ("array" , np .int16 , (3 ,))],
1647+ align = True )
1648+
1649+ dest_dtype = np .dtype ([
1650+ ("user1" , np .float64 ),
1651+ ("array1" , np .int16 , (3 ,))],
1652+ align = True )
1653+
1654+ @njit
1655+ def copy (index , src , dest ):
1656+ dest ['user1' ] = src [index ]['user' ]
1657+ dest ['array1' ] = src [index ]['array' ]
1658+
1659+ source = np .zeros (2 , dtype = src_dtype )
1660+ got = np .zeros (2 , dtype = dest_dtype )
1661+ expected = np .zeros (2 , dtype = dest_dtype )
1662+
1663+ source [0 ] = (1.2 , [1 , 2 , 3 ])
1664+ copy (0 , source , got [0 ])
1665+ copy .py_func (0 , source , expected [0 ])
1666+
1667+ np .testing .assert_array_equal (expected , got )
1668+
16261669
16271670if __name__ == '__main__' :
16281671 unittest .main ()
0 commit comments