From b70b8648294961a5e6a34b3362eb07214276ad8a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 12 Apr 2022 15:50:50 +0200
Subject: [PATCH] perfect_foresight_with_expectation_errors_setup: move
 terminal condition to last line of CSV file

---
 .../perfect_foresight_with_expectation_errors_setup.m       | 6 +++---
 tests/deterministic_simulations/pfwee.csv                   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m
index 88b784f6c5..6724545c64 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m
@@ -1,6 +1,6 @@
 function perfect_foresight_with_expectation_errors_setup
 
-% Copyright (C) 2021 Dynare Team
+% Copyright © 2021-2022 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -58,9 +58,9 @@ oo_.pfwee.shocks_info = NaN(M_.exo_nbr, periods, periods); % 2nd dimension is re
 for i = 1:size(raw_csv, 2)
     exo_id = strmatch(exo_header_names{i}, M_.exo_names, 'exact');
     period_id = raw_csv(1, i);
-    oo_.pfwee.terminal_info(exo_id, period_id) = raw_csv(2, i);
     % Ignore irrelevant periods when copying shocks information
-    oo_.pfwee.shocks_info(exo_id, period_id:end, period_id) = raw_csv(2+period_id:end, i);
+    oo_.pfwee.shocks_info(exo_id, period_id:end, period_id) = raw_csv(1+period_id:end-1, i);
+    oo_.pfwee.terminal_info(exo_id, period_id) = raw_csv(end, i);
 end
 
 % Build initial paths for endos and exos (only initial conditions are set, the rest is NaN)
diff --git a/tests/deterministic_simulations/pfwee.csv b/tests/deterministic_simulations/pfwee.csv
index 4e0614a09b..1865e5780e 100644
--- a/tests/deterministic_simulations/pfwee.csv
+++ b/tests/deterministic_simulations/pfwee.csv
@@ -1,6 +1,5 @@
 Exo,x,x,x,x,x,x,x
 Period (info),1,2,3,4,5,6,7
-Terminal,1,1.1,1.2,1.2,1.2,1.1,1.1
 Period 1 (real),1.2,,,,,,
 Period 2 (real),1,1.3,,,,,
 Period 3 (real),1,1,1.4,,,,
@@ -8,3 +7,4 @@ Period 4 (real),1,1,1,1,,,
 Period 5 (real),1,1,1,1,1,,
 Period 6 (real),1,1,1,1,1,1.1,
 Period 7 (real),1,1,1,1,1,1.1,1.1
+Terminal,1,1.1,1.2,1.2,1.2,1.1,1.1
-- 
GitLab