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

clarify empty array expression #797

Merged
merged 4 commits into from
Aug 6, 2024
Merged

Conversation

avehtari
Copy link
Contributor

@avehtari avehtari commented Aug 5, 2024

Fixes #621

The restriction on empty array expression is mentioned later, but it is easy to miss, so clarified it now also earlier with link to the later section. Also added the suggested way to create an empty array.

Copy link
Contributor

@bob-carpenter bob-carpenter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested a more extensive subsection expanding on what was submitted.

rep_array(0, 0)
```
where the type of the first argument determines the type of the array
(e.g., real or int).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real and int should be escaped as real and int. (back ticks)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be worth pulling out a subsection and highlighting the empty array can be any type, not just a scalar.

Empty arrays {-}

The empty array expression ({ }) is not allowed. See more about restrictions on array expressions in subsection Restrictions on values.

If needed, it is also possible to create an empty array with the expression

rep_array(e, 0)

where the first expression e determines the type of the array. For example, rep_array(0.0, 0) returns an empty real array of type real[], whereas rep_array({123}, 0) returns an empty two dimensional integer array of type int[ , ]. Only the type of the first argument is used, so the integer arrays {123} and {0} produce equivalent values.


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github shows the markdown in the comment so, that I can't see how many # you used for the subsection "Empty arrays". Also I'm not certain where you would like to have that subsection.

@avehtari
Copy link
Contributor Author

avehtari commented Aug 5, 2024

Added also instruction how to create empty vectors and matrices

@bob-carpenter
Copy link
Contributor

Sorry about that---you can look at the source with the "edit" button. Three hashes.

The only reason I pulled it out into a section is to make it more noticeable and better indexed by Google (though I'm not sure the indexing is helped much any more by level 3 headers---it used to be).

Copy link
Contributor

@bob-carpenter bob-carpenter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks.

@bob-carpenter bob-carpenter merged commit 48e9943 into master Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

length 0 array documentation
2 participants