From cabaf4be6180c2c3b8e71e52dcec5a18668e76c1 Mon Sep 17 00:00:00 2001
From: lthiele <leonard.thiele@cern.ch>
Date: Mon, 17 Jun 2024 20:36:58 +0200
Subject: [PATCH] changed import statement to include encoding informations due
 to change in numpy 2.0

---
 __EXAMPLES/main_files/EX_02_Main_long_ps_booster.py     | 7 ++++---
 __EXAMPLES/mpi_main_files/EX_02_Main_long_ps_booster.py | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/__EXAMPLES/main_files/EX_02_Main_long_ps_booster.py b/__EXAMPLES/main_files/EX_02_Main_long_ps_booster.py
index 95e49599..b5f935f8 100644
--- a/__EXAMPLES/main_files/EX_02_Main_long_ps_booster.py
+++ b/__EXAMPLES/main_files/EX_02_Main_long_ps_booster.py
@@ -102,9 +102,10 @@ bunchmonitor = BunchMonitor(ring, RF_sct_par, my_beam,
 var = str(kin_beam_energy / 1e9)
 
 # ejection kicker
-Ekicker = np.loadtxt(this_directory + '../input_files/EX_02_Ekicker_1.4GeV.txt', skiprows=1, dtype=complex, converters={0: lambda s:
-                                                                                                                        complex(bytes(s).decode('UTF-8').replace('i', 'j')),
-                                                                                                                        1: lambda s: complex(bytes(s).decode('UTF-8').replace('i', 'j'))})
+Ekicker = np.loadtxt(this_directory + '../input_files/EX_02_Ekicker_1.4GeV.txt', skiprows=1, dtype=complex,
+                     encoding="utf-8",
+                     converters={0: lambda s: complex(bytes(s, encoding="utf-8").decode('UTF-8').replace('i', 'j')),
+                                 1: lambda y: complex(bytes(y, encoding="utf-8").decode('UTF-8').replace('i', 'j'))})
 
 Ekicker_table = InputTable(Ekicker[:, 0].real, Ekicker[:, 1].real, Ekicker[:, 1].imag)
 
diff --git a/__EXAMPLES/mpi_main_files/EX_02_Main_long_ps_booster.py b/__EXAMPLES/mpi_main_files/EX_02_Main_long_ps_booster.py
index a3b147df..0a391d52 100644
--- a/__EXAMPLES/mpi_main_files/EX_02_Main_long_ps_booster.py
+++ b/__EXAMPLES/mpi_main_files/EX_02_Main_long_ps_booster.py
@@ -104,9 +104,10 @@ slice_beam = Profile(my_beam, CutOptions(cut_left=-5.72984173562e-7,
 var = str(kin_beam_energy / 1e9)
 
 # ejection kicker
-Ekicker = np.loadtxt(this_directory + '../input_files/EX_02_Ekicker_1.4GeV.txt', skiprows=1, dtype=complex, converters={0: lambda s:
-                                                                                                                        complex(bytes(s).decode('UTF-8').replace('i', 'j')),
-                                                                                                                        1: lambda s: complex(bytes(s).decode('UTF-8').replace('i', 'j'))})
+Ekicker = np.loadtxt(this_directory + '../input_files/EX_02_Ekicker_1.4GeV.txt', skiprows=1, dtype=complex,
+                     encoding="utf-8",
+                     converters={0: lambda s: complex(bytes(s, encoding="utf-8").decode('UTF-8').replace('i', 'j')),
+                                 1: lambda y: complex(bytes(y, encoding="utf-8").decode('UTF-8').replace('i', 'j'))})
 
 Ekicker_table = InputTable(Ekicker[:, 0].real, Ekicker[:, 1].real, Ekicker[:, 1].imag)
 
-- 
GitLab