• Levin Zimmermann's avatar
    BigArray: Fix API deviation with ndarray (shape) · adffe247
    Levin Zimmermann authored
    The 'shape' argument of 'numpy.ndarray's initialization method accepts
    integer and sequences of integers. But the 'shape' property of
    'numpy.ndarray' always returns tuple[int, ...], so numpy manually
    casts any legal argument into tuple[int, ...].
    
    In 'BigArray' and 'ZBigArray' this internal casting didn't exist yet.
    This patch adds the casting.
    
    Before:
    
      ZBigArray(shape=[1, 2, 3], dtype=float).shape == [1, 2, 3]
    
    After:
    
      ZBigArray(shape=[1, 2, 3], dtype=float).shape == (1, 2, 3)
    
    In this way BigArray and ZBigArray API behaves closer to numpy.ndaray,
    which should help avoiding confusion when people are using BigArray /
    ZBigArray.
    
    -----
    
    See issue #9 and
    MR !14
    for additional context.
    
    /reviewed-by @kirr
    /reviewed-on !14
    adffe247
__init__.py 28 KB