Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

length 0 array documentation #621

Closed
spinkney opened this issue Mar 8, 2023 · 5 comments · Fixed by #797
Closed

length 0 array documentation #621

spinkney opened this issue Mar 8, 2023 · 5 comments · Fixed by #797
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers

Comments

@spinkney
Copy link
Collaborator

spinkney commented Mar 8, 2023

This issue stems from stan-dev/stanc3#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.

@bob-carpenter bob-carpenter added bug Something isn't working enhancement New feature or request good first issue Good for newcomers labels Mar 8, 2023
@bob-carpenter
Copy link
Contributor

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

@WardBrian
Copy link
Member

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

@spinkney
Copy link
Collaborator Author

spinkney commented Mar 9, 2023

Ah, very nice!

@WardBrian
Copy link
Member

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

@spinkney
Copy link
Collaborator Author

spinkney commented Mar 9, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants