RobinHankin / hyper2

https://robinhankin.github.io/hyper2/
5 stars 3 forks source link

`setweight()` infelicity #231

Open RobinHankin opened 5 months ago

RobinHankin commented 5 months ago
library("hyper2")
#> Loading required package: cubature
dirichlet(powers=c(x=3,y=2,z=4)) |> setweight('y',1.888)
#> log( (x=1)^3 * (x=1, y=1.888, z=1)^-9 * (y=1.888)^2 * (z=1)^4)
dirichlet(powers=c(x=3,y=2,z=4)) |> setweight(y=1.888)
#> Error in setweight(dirichlet(powers = c(x = 3, y = 2, z = 4)), y = 1.888): unused argument (y = 1.888)

Above, the first call to setweight() works fine. I would expect the second call to return the same value, but it fails.

RobinHankin commented 5 months ago

In the mvp package, subs() has this functionality:

suppressMessages(library("mvp"))
set.seed(0)
p <- rmvp()
p
#> mvp object algebraically equal to
#> 3 + 6 a + 3 a b e f^2 + 4 a d^2 e f^2 + 5 a^3 b^2 c + 4 b c^2 d e^2 + 6 b^3 d e
p |> subs(a=17)
#> mvp object algebraically equal to
#> 105 + 4 b c^2 d e^2 + 51 b e f^2 + 24565 b^2 c + 6 b^3 d e + 68 d^2 e f^2

Created on 2024-05-15 with reprex v2.1.0