Julia: replace `size(A, d1, d2, ds...)` with `size(A, (dims...))`

Created on 19 Apr 2018  Â·  4Comments  Â·  Source: JuliaLang/julia

Right now the general signature size(A, dims...) does different things depending on whether there are zero, one or many dimensions provided. It seems like it would be better to separate this into: no dimension argument, scalar dimension argument, and tuple dimension argument.

arrays

Most helpful comment

Ah, so you'd want to still support size(A, 1) returning a single integer? Yes, that seems quite reasonable to me.

Note that the axes function doesn't support either varargs or tuples — it's either all or one. The two should probably match.

All 4 comments

Ah, so you'd want to still support size(A, 1) returning a single integer? Yes, that seems quite reasonable to me.

Note that the axes function doesn't support either varargs or tuples — it's either all or one. The two should probably match.

Yes, the proposal would be that these three forms are supported:

  1. size(A) --> (sizes[1], sizes[2], ...)
  2. size(A, d) --> sizes[d]
  3. size(A, (dims...)) --> (sizes[dims[1]], sizes[dims[2]], ...)

Or we could just deprecate it entirely...

Supporting a tuple argument would be a bigger change. Many size methods don't constrain the dimension argument at all, and I think that's just fine.

This was only used within tests of size itself within the entire testsuite. I think we'll be just fine without it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ararslan picture ararslan  Â·  3Comments

musm picture musm  Â·  3Comments

StefanKarpinski picture StefanKarpinski  Â·  3Comments

StefanKarpinski picture StefanKarpinski  Â·  3Comments

yurivish picture yurivish  Â·  3Comments