Comments (2)
Thanks! Of course, I forgot the binding order!
from posterior.
The short answer is: all of these behaviors are correct, but the errors for the second cases could probably be better.
Long answer:
The first behavior is consistent with rvar
broadcasting rules because you have:
- arg 1:
as_rvar(c(0,1,2))
: a constant (1-draw)rvar
of length 3. - arg 2:
rdo(rnorm(1))
: anrvar
with the default number of draws (4000) and length 1.
The draws of arg 1 can be broadcast to 4000 (constant rvars can be used with other rvars of any number of draws) and the dims of both args (c(3)
and c(1)
) can both be broadcast to a common shape (c(3)
).
What you're seeing in the second two examples is a result of the fact that |>
binds more tightly than *
, so the function being piped into is only being applied to the second arg. Since |>
is translated into function application at the parser level you can check this with quote()
:
quote(as_rvar(c(0,1,2)) * rdo(rnorm(1)) |> str())
##as_rvar(c(0, 1, 2)) * str(rdo(rnorm(1)))
quote(as_rvar(c(0,1,2)) * rdo(rnorm(1)) |> draws_of())
## as_rvar(c(0, 1, 2)) * draws_of(rdo(rnorm(1)))
Thus in the first case, the output of str(rdo(rnorm(1))
(which is NULL
) is cast to an rvar (giving rvar()
), which does not have a compatible shape with as_rvar(c(0,1,2))
.
In the second case, the output of draws_of(rdo(rnorm(1))
is cast to an rvar (giving a constant rvar of dim c(4000,1)
), which also does not have a compatible shape with as_rvar(c(0,1,2))
.
These errors could definitely be better... perhaps at least they should output the underlying expressions and also put the shapes in the same order as the arguments to make it easier to figure out what's going on.
from posterior.
Related Issues (20)
- should remove_variables be exported? HOT 4
- Dealing with chains of different length HOT 1
- Add functions for PIT and LOO-PIT HOT 6
- Add a function to extract single draw of multidimensional variable HOT 4
- .args in summarise draws incompatible with summary functions without ellipses HOT 10
- `pareto_khat(..., tail="both")` returns NA if just one tail is constant
- pareto diagnostics return named values, preventing renaming
- validate_weights allows NaN and NA weights
- [FR] Allow as_draws_dt for data.table HOT 9
- New draws_tensor format? HOT 4
- Applying a function to each chain HOT 1
- In summarise draws, a function that returns a character changes all columns to character HOT 4
- export ps_khat_threshold HOT 4
- pareto_khat should always return the same data structure
- `ps_khat_threshold` can return values greater than 0.7 HOT 2
- Errors when `rvar` is made from a data frame HOT 3
- subset_draws duplicates variables if `variables` argument contains `NA` HOT 4
- New CRAN release? HOT 6
- default for `r_eff` in `pareto_smooth()` and `pareto_khat()` differ
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from posterior.