stanc3 icon indicating copy to clipboard operation
stanc3 copied to clipboard

Prohibition on length-1 tuples can make laplace functions annoying to use

Open WardBrian opened this issue 8 months ago • 10 comments

@avehtari ran into this today, where he wanted to define a covariance function that takes only a single argument.

The prohibition is purely syntactic, because (1.0) is already equivalent to 1.0 (e.g. a real).

Some options:

  • Allow length 1 tuples with a required trailing comma (this is what e.g. Python does): (1.0, )
  • Add a helper function that creates length one tuples (e.g. singleton_tuple(1.0))
  • Allow a non-tuple tuple type as the forwarded arguments, in which case it looks for functions of only 1 argument.

All of these have a bit of a "magic" feel that makes me uneasy. The first is the most general, but we specifically avoided allowing this in the original tuples PR

WardBrian avatar Jun 09 '25 14:06 WardBrian