About acceptable types of dimension parameter for Base.reshape

I think the current behavior of Base.reshape function is a little strange.

a = zeros(100);

reshape(a, 10, 10)  # OK

reshape(a, UInt(10), UInt(10))  # MethodError
reshape(a, (UInt(10), UInt(10)))  # OK

reshape(a, Int128(10), Int128(10))  # MethodError
reshape(a, (Int128(10), Int128(10)))  # OK

Probably it would be ok if reshape() accepts those parameters in both cases. Or am I missing something?

Array indexing and dimensions are based on Int, thus it is a bit strange to use something else. But it would probably be ok to change the definition from

reshape(parent::AbstractArray, dims::Int...) = reshape(parent, dims)


reshape(parent::AbstractArray, dims::Integer...) = reshape(parent, dims)

Why don’t you do a PR to find out?

1 Like

Thank you! I will try.

1 Like