Skip to content

Commit f1e22d4

Browse files
Merge pull request #81 from LAMPSPUC/fix_empty_estimated_stochastic
fix empty estimated_stochastic
2 parents c458ed0 + edcdcac commit f1e22d4

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "StateSpaceLearning"
22
uuid = "971c4b7c-2c4e-4bac-8525-e842df3cde7b"
33
authors = ["andreramosfc <[email protected]>"]
4-
version = "2.0.10"
4+
version = "2.0.11"
55

66
[deps]
77
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"

src/utils.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,13 @@ function get_stochastic_values(
153153
valid_indices = filter(idx -> start_idx <= idx <= final_idx, seasonal_indices)
154154

155155
# Sample with randomness and sign flip
156-
stochastic_term[t, :] =
157-
rand(estimated_stochastic[valid_indices], N_scenarios) .*
158-
rand([1, -1], N_scenarios)
156+
if !isempty(estimated_stochastic[valid_indices])
157+
stochastic_term[t, :] =
158+
rand(estimated_stochastic[valid_indices], N_scenarios) .*
159+
rand([1, -1], N_scenarios)
160+
else
161+
stochastic_term[t, :] .= 0.0
162+
end
159163
end
160164
else
161165
stochastic_term =

0 commit comments

Comments
 (0)