Skip to content

Include higher-order functions in --dump-stan-math-signatures - #1694

Open
andrjohns wants to merge 1 commit into
stan-dev:masterfrom
andrjohns:print-variadic-sigs
Open

andrjohns wants to merge 1 commit into
stan-dev:masterfrom
andrjohns:print-variadic-sigs

Conversation

@andrjohns

Copy link
Copy Markdown
Contributor

Submission Checklist

  • Run unit tests
  • Documentation
    • [] If a user-facing facing change was made, the documentation PR is here:
    • [] OR, no user-facing changes were made

Updates the pretty-printing for the math signatures to include all higher-order functions, using ... for variadic functions. For example:

dae((real, vector, vector, ...) => vector, vector, vector, real, array[] real, ...) => array[] vector
laplace_latent_bernoulli_logit_rng(array[] int, array[] int, vector, int, function(...) => matrix, tuple(...)) => vector
reduce_sum(function(array[] real, data int, data int, ...) => real, array[] real, int, ...) => real
reduce_sum(function(array[,,,,,,] row_vector, data int, data int, ...) => real, array[,,,,,,] row_vector, int, ...) => real

Release notes

All higher-order function signatures now printed in --dump-stan-math-signatures

Copyright and Licensing

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)

@andrjohns

Copy link
Copy Markdown
Contributor Author

Ah the expression tests. I'll open a Math PR to conditionally add expression tests for the new signatures

let pp_variadic_sig name ppf
UnsizedType.{return_type; control_args; required_fn_rt; required_fn_args}
=
pf ppf "%s(@[<h>function(%a, ...) => %a, %a, ...@]) => %a" name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the few existing higher order functions that already get printed, we don't print the word function, e.g.
https://github.com/stan-dev/stanc3/blob/8e154ac3454790cb5427ae72106c859b3fb8d90a/test/integration/signatures/stan_math_signatures.t#L12745

I'm mostly ambivalent about what we do print, but it should be consistent.

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.

2 participants