@@ -2595,8 +2595,33 @@ cdef class NDArray:
2595
2595
2596
2596
2597
2597
cdef b2nd_context_t* create_b2nd_context(shape, chunks, blocks, dtype, kwargs):
2598
- # This is used only in constructors, dtype will always have NumPy format
2599
- dtype = np.dtype(dtype)
2598
+ if isinstance (dtype, list ) and len (dtype) > 0 and isinstance (dtype[0 ], tuple ):
2599
+ # Extract just the field names and basic dtype info
2600
+ fields = []
2601
+ for field in dtype:
2602
+ name = field[0 ]
2603
+ field_dtype = field[1 ]
2604
+
2605
+ # Handle different field formats:
2606
+ # 1. ('name', ('|S10', {'h5py_encoding': 'ascii'})) - h5py style
2607
+ # 2. ('name', '<i4') - standard NumPy style
2608
+ # 3. ('name', '<i4', (shape,)) - NumPy with shape info
2609
+
2610
+ if isinstance (field_dtype, tuple ) and len (field_dtype) > 0 :
2611
+ # h5py nested representation with metadata dict
2612
+ field_dtype = field_dtype[0 ]
2613
+
2614
+ # Check if we have shape information as third element
2615
+ if len (field) > 2 and field[2 ] is not None :
2616
+ # Include the shape information
2617
+ fields.append((name, field_dtype, field[2 ]))
2618
+ else :
2619
+ fields.append((name, field_dtype))
2620
+
2621
+ dtype = np.dtype(fields)
2622
+ else :
2623
+ dtype = np.dtype(dtype)
2624
+
2600
2625
typesize = dtype.itemsize
2601
2626
if ' cparams' in kwargs:
2602
2627
kwargs[' cparams' ][' typesize' ] = typesize
0 commit comments