docs icon indicating copy to clipboard operation
docs copied to clipboard

length 0 array documentation

Open spinkney opened this issue 2 years ago • 5 comments

This issue stems from https://github.com/stan-dev/stanc3/issues/1286 where there was some confusion on length 0 arrays. It becomes apparent that there is ambiguity in the type of the array with length 0. I think we should add documentation around this and state clearly that {} is not a valid constructor.

I believe the relevant section that can be expanded is in the reference manual at https://mc-stan.org/docs/reference-manual/vector-matrix-array-expressions.html#array-expressions.

spinkney avatar Mar 08 '23 14:03 spinkney

Thanks for posting the issue, @spinkney. We should definitely fix this.

bob-carpenter avatar Mar 08 '23 21:03 bob-carpenter

I believe this is stated further down on the page you link, https://mc-stan.org/docs/reference-manual/vector-matrix-array-expressions.html#no-empty-array-expressions

WardBrian avatar Mar 08 '23 21:03 WardBrian

Ah, very nice!

spinkney avatar Mar 09 '23 12:03 spinkney

Is there anything more you think we should be saying in that section?

WardBrian avatar Mar 09 '23 13:03 WardBrian

Is there anything more you think we should be saying in that section?

I think I would've noticed this better if it was in the part Rectangular array expressions only instead of it's own section. Though this could just be how I read sections, finding the relevant part and then switching back to what I'm doing, instead of reading through the docs carefully.

The only other thing to add is @nhuurre's suggestion that it is also possible to create empty array's on the fly as rep_array({1.0}, 0).

spinkney avatar Mar 09 '23 19:03 spinkney