Skip to content

Commit 090fa62

Browse files
authored
Avoid calling maximum(...; dims) with empty arrays
There's a proposed "minor change" to Julia v1.13 that would make `maximum([], dims=2)` (and other such reductions) an error, akin to how `maximum([])` is an error when `init` is not specified. This package was flagged as having (at least) one such usage here; it errored in [PkgEval](https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/813bcf3_vs_c3e7b1b/report.html). See JuliaLang/julia#55628 for more details.
1 parent ba52642 commit 090fa62

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Algos/TPPT.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ function p̂ₜ₊₁func(kₜ::AbstractMatrix, p::AbstractMatrix, w::Integer,
4343
idx_under_zero = vec(sum(kₜ, dims=2)).<0.
4444
idx_equal_zero = vec(sum(kₜ, dims=2)).==0.
4545
p̂ₜ₊₁ = similar(kₜ, n_assets)
46-
p̂ₜ₊₁[idx_under_zero] .= maximum(p[idx_under_zero, :], dims=2)
46+
if any(idx_under_zero)
47+
p̂ₜ₊₁[idx_under_zero] .= maximum(p[idx_under_zero, :], dims=2)
48+
end
4749
p̂ₜ₊₁[idx_equal_zero] .= p[idx_equal_zero, end]
4850
p̂ₜ₊₁[idx_over_zero] .= sum*(1-α)^(w-i) *p[idx_over_zero, w-i] for i=0:w-1)
4951
return p̂ₜ₊₁

0 commit comments

Comments
 (0)