Skip to content

Commit bf70f07

Browse files
authored
Merge pull request #3260 from stan-dev/wiener-expr-tests
Fix expression tests for new Wiener functions
2 parents 062d304 + 3d7f67c commit bf70f07

File tree

5 files changed

+36
-35
lines changed

5 files changed

+36
-35
lines changed

stan/math/prim/prob/wiener4_lccdf_defective.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ inline auto wiener_prob_derivative_term(const T_a& a, const T_v& v,
7575
if (neg_v < 0) {
7676
ans = LOG_TWO + exponent_with_1mw - log1m_exp(exponent_with_1mw);
7777
diff_term = log1m_exp(exponent_with_w) - log1m_exp(exponent);
78-
} else if (neg_v > 0) {
78+
} else /* neg_v > 0 */ {
7979
ans = LOG_TWO - log1m_exp(exponent_with_1mw);
8080
diff_term = log_diff_exp(exponent_with_1mw, exponent) - log1m_exp(exponent);
8181
}
@@ -226,14 +226,14 @@ template <bool propto = false, typename T_y, typename T_a, typename T_t0,
226226
typename T_w, typename T_v>
227227
inline auto wiener_lccdf_defective(const T_y& y, const T_a& a, const T_t0& t0,
228228
const T_w& w, const T_v& v,
229-
const double& precision_derivatives) {
229+
const double& precision_derivatives = 1e-4) {
230230
using T_partials_return = partials_return_t<T_y, T_a, T_t0, T_w, T_v>;
231231
using ret_t = return_type_t<T_y, T_a, T_t0, T_w, T_v>;
232-
using T_y_ref = ref_type_if_t<!is_constant<T_y>::value, T_y>;
233-
using T_a_ref = ref_type_if_t<!is_constant<T_a>::value, T_a>;
234-
using T_t0_ref = ref_type_if_t<!is_constant<T_t0>::value, T_t0>;
235-
using T_w_ref = ref_type_if_t<!is_constant<T_w>::value, T_w>;
236-
using T_v_ref = ref_type_if_t<!is_constant<T_v>::value, T_v>;
232+
using T_y_ref = ref_type_t<T_y>;
233+
using T_a_ref = ref_type_t<T_a>;
234+
using T_t0_ref = ref_type_t<T_t0>;
235+
using T_w_ref = ref_type_t<T_w>;
236+
using T_v_ref = ref_type_t<T_v>;
237237
using internal::GradientCalc;
238238

239239
T_y_ref y_ref = y;

stan/math/prim/prob/wiener4_lcdf_defective.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,11 +590,11 @@ inline auto wiener_lcdf_defective(const T_y& y, const T_a& a, const T_t0& t0,
590590
const T_w& w, const T_v& v,
591591
const double& precision_derivatives = 1e-4) {
592592
using T_partials_return = partials_return_t<T_y, T_a, T_t0, T_w, T_v>;
593-
using T_y_ref = ref_type_if_t<!is_constant<T_y>::value, T_y>;
594-
using T_a_ref = ref_type_if_t<!is_constant<T_a>::value, T_a>;
595-
using T_t0_ref = ref_type_if_t<!is_constant<T_t0>::value, T_t0>;
596-
using T_w_ref = ref_type_if_t<!is_constant<T_w>::value, T_w>;
597-
using T_v_ref = ref_type_if_t<!is_constant<T_v>::value, T_v>;
593+
using T_y_ref = ref_type_t<T_y>;
594+
using T_a_ref = ref_type_t<T_a>;
595+
using T_t0_ref = ref_type_t<T_t0>;
596+
using T_w_ref = ref_type_t<T_w>;
597+
using T_v_ref = ref_type_t<T_v>;
598598
using internal::GradientCalc;
599599
using ret_t = return_type_t<T_y, T_a, T_t0, T_w, T_v>;
600600

stan/math/prim/prob/wiener_full_lccdf_defective.hpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ inline auto wiener_lccdf_defective(const T_y& y, const T_a& a, const T_t0& t0,
8989
const T_sw& sw, const T_st0& st0,
9090
const double& precision_derivatives = 1e-8) {
9191
using ret_t = return_type_t<T_y, T_a, T_t0, T_w, T_v, T_sv, T_sw, T_st0>;
92-
using T_y_ref = ref_type_if_t<!is_constant<T_y>::value, T_y>;
93-
using T_a_ref = ref_type_if_t<!is_constant<T_a>::value, T_a>;
94-
using T_v_ref = ref_type_if_t<!is_constant<T_v>::value, T_v>;
95-
using T_w_ref = ref_type_if_t<!is_constant<T_w>::value, T_w>;
96-
using T_t0_ref = ref_type_if_t<!is_constant<T_t0>::value, T_t0>;
97-
using T_sv_ref = ref_type_if_t<!is_constant<T_sv>::value, T_sv>;
98-
using T_sw_ref = ref_type_if_t<!is_constant<T_sw>::value, T_sw>;
99-
using T_st0_ref = ref_type_if_t<!is_constant<T_st0>::value, T_st0>;
92+
using T_y_ref = ref_type_t<T_y>;
93+
using T_a_ref = ref_type_t<T_a>;
94+
using T_v_ref = ref_type_t<T_v>;
95+
using T_w_ref = ref_type_t<T_w>;
96+
using T_t0_ref = ref_type_t<T_t0>;
97+
using T_sv_ref = ref_type_t<T_sv>;
98+
using T_sw_ref = ref_type_t<T_sw>;
99+
using T_st0_ref = ref_type_t<T_st0>;
100100
using internal::GradientCalc;
101101
using T_partials_return
102102
= partials_return_t<T_y, T_a, T_t0, T_w, T_v, T_sv, T_sw, T_st0>;
@@ -267,9 +267,7 @@ inline auto wiener_lccdf_defective(const T_y& y, const T_a& a, const T_t0& t0,
267267

268268
// computation of derivative for t and precision check in order to give
269269
// the value as deriv_t to edge1 and as -deriv_t to edge5
270-
const auto params_dt7 = std::make_tuple(
271-
y_value, a_value, v_value, w_value, t0_value, sv_value, sw_value,
272-
st0_value, log_error_absolute - LOG_TWO - 9 * LOG_TWO);
270+
273271
// computation of derivatives and precision checks
274272
if (!is_constant_all<T_y>::value || !is_constant_all<T_t0>::value) {
275273
const T_partials_return deriv_t_7

stan/math/prim/prob/wiener_full_lcdf_defective.hpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,14 @@ inline auto wiener_lcdf_defective(const T_y& y, const T_a& a, const T_t0& t0,
265265
const T_sw& sw, const T_st0& st0,
266266
const double& precision_derivatives = 1e-8) {
267267
using ret_t = return_type_t<T_y, T_a, T_t0, T_w, T_v, T_sv, T_sw, T_st0>;
268-
using T_y_ref = ref_type_if_t<!is_constant<T_y>::value, T_y>;
269-
using T_a_ref = ref_type_if_t<!is_constant<T_a>::value, T_a>;
270-
using T_v_ref = ref_type_if_t<!is_constant<T_v>::value, T_v>;
271-
using T_w_ref = ref_type_if_t<!is_constant<T_w>::value, T_w>;
272-
using T_t0_ref = ref_type_if_t<!is_constant<T_t0>::value, T_t0>;
273-
using T_sv_ref = ref_type_if_t<!is_constant<T_sv>::value, T_sv>;
274-
using T_sw_ref = ref_type_if_t<!is_constant<T_sw>::value, T_sw>;
275-
using T_st0_ref = ref_type_if_t<!is_constant<T_st0>::value, T_st0>;
268+
using T_y_ref = ref_type_t<T_y>;
269+
using T_a_ref = ref_type_t<T_a>;
270+
using T_v_ref = ref_type_t<T_v>;
271+
using T_w_ref = ref_type_t<T_w>;
272+
using T_t0_ref = ref_type_t<T_t0>;
273+
using T_sv_ref = ref_type_t<T_sv>;
274+
using T_sw_ref = ref_type_t<T_sw>;
275+
using T_st0_ref = ref_type_t<T_st0>;
276276
using internal::GradientCalc;
277277
using T_partials_return
278278
= partials_return_t<T_y, T_a, T_t0, T_w, T_v, T_sv, T_sw, T_st0>;
@@ -445,9 +445,7 @@ inline auto wiener_lcdf_defective(const T_y& y, const T_a& a, const T_t0& t0,
445445

446446
// computation of derivative for t and precision check in order to give
447447
// the value as deriv_t to edge1 and as -deriv_t to edge5
448-
const auto params_dt7 = std::make_tuple(
449-
y_value, a_value, v_value, w_value, t0_value, sv_value, sw_value,
450-
st0_value, log_error_absolute - LOG_TWO - 9 * LOG_TWO);
448+
451449
if (!is_constant_all<T_y>::value || !is_constant_all<T_t0>::value) {
452450
T_partials_return deriv_t_7
453451
= internal::wiener7_integrate_cdf<

test/sig_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ def get_cpp_type(stan_type):
145145
"uniform_lcdf": [None, 0.2, 0.9],
146146
"uniform_lpdf": [None, 0.2, 0.9],
147147
"uniform_rng": [0.2, 1.9, None],
148-
"wiener_lpdf": [0.8, None, 0.4, None, None, None, None, None],
148+
"wiener_lpdf": [0.8, None, 0.4, None, None, None, None, None, 1e-4],
149+
"wiener_lccdf_defective": [0.8, None, 0.4, None, None, None, None, None, 1e-4],
150+
"wiener_lcdf_defective": [0.8, None, 0.4, None, None, None, None, None, 1e-4],
149151
}
150152

151153
# list of functions we do not test. These are mainly functions implemented in compiler
@@ -180,6 +182,9 @@ def get_cpp_type(stan_type):
180182
"ode_adams_tol": [4, 5, 6],
181183
"ode_bdf_tol": [4, 5, 6],
182184
"ode_rk45_tol": [4, 5, 6],
185+
"wiener_lpdf": [6, 8],
186+
"wiener_lccdf_defective": [5, 8],
187+
"wiener_lcdf_defective": [5, 8],
183188
}
184189

185190
# lists of functions that do not support fwd or rev autodiff

0 commit comments

Comments
 (0)