From ca9db97f1cc06aaaef3c74caaf6fe0c04bacfe39 Mon Sep 17 00:00:00 2001 From: PeterMeisrimelModelon <92585725+PeterMeisrimelModelon@users.noreply.github.com> Date: Tue, 13 Feb 2024 11:56:46 +0100 Subject: [PATCH] Fixing deprecationWarnings --- src/pyfmi/master.pyx | 12 +++++------- tests/test_fmi_master.py | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pyfmi/master.pyx b/src/pyfmi/master.pyx index 29e205d8..189c41aa 100644 --- a/src/pyfmi/master.pyx +++ b/src/pyfmi/master.pyx @@ -756,7 +756,7 @@ cdef class Master: index_end = index_start + self.models_dict[model]["local_output_len"] local_output_vref_array = (model).get_real(self.models_dict[model]["local_output_vref_array"]) for i, index in enumerate(range(index_start, index_end)): - y[index] = local_output_vref_array[i] + y[index] = local_output_vref_array[i].item() return y.reshape(-1,1) cpdef np.ndarray get_connection_outputs_discrete(self): @@ -768,7 +768,7 @@ cdef class Master: index_end = index_start + self.models_dict[model]["local_output_discrete_len"] local_output_discrete = model.get(self.models_dict[model]["local_output_discrete"]) for i, index in enumerate(range(index_start, index_end)): - y[index] = local_output_discrete[i] + y[index] = local_output_discrete[i].item() return y.reshape(-1,1) cpdef np.ndarray _get_derivatives(self): @@ -784,7 +784,7 @@ cdef class Master: index_end = index_start + self.models_dict[model]["local_derivative_len"] local_derivative_vref_array = (model).get_real(self.models_dict[model]["local_derivative_vref_array"]) for i, index in enumerate(range(index_start, index_end)): - xd[index] = local_derivative_vref_array[i] + xd[index] = local_derivative_vref_array[i].item() return xd.reshape(-1,1) @@ -793,7 +793,7 @@ cdef class Master: ytmp = model.get(np.array(self.models_dict[model]["local_output_discrete"])[mask]) for i, flag in enumerate(mask): if flag: - yout[i+self.models_dict[model]["global_index_outputs_discrete"]] = ytmp[j] + yout[i+self.models_dict[model]["global_index_outputs_discrete"]] = ytmp[j].item() j = j + 1 cpdef np.ndarray get_specific_connection_outputs(self, model, np.ndarray mask, np.ndarray yout): @@ -801,7 +801,7 @@ cdef class Master: cdef np.ndarray ytmp = (model).get_real(self.models_dict[model]["local_output_vref_array"][mask]) for i, flag in enumerate(mask): if flag: - yout[i+self.models_dict[model]["global_index_outputs"]] = ytmp[j] + yout[i+self.models_dict[model]["global_index_outputs"]] = ytmp[j].item() j = j + 1 cpdef get_connection_derivatives(self, np.ndarray y_cur): @@ -1789,5 +1789,3 @@ cdef class Master: last_has_outputs = has_outputs """ return order, blocks,compressed_blocks - - diff --git a/tests/test_fmi_master.py b/tests/test_fmi_master.py index a0c3f9ef..75e1f38b 100644 --- a/tests/test_fmi_master.py +++ b/tests/test_fmi_master.py @@ -222,7 +222,7 @@ def do_step2(current_t, step_size, new_step=True): models = [model_sub1, model_sub2] connections = [(model_sub1, 'y', model_sub2, 'u')] - master = Master(models,connections) + master = Master(models, connections) opts = master.simulate_options() opts["block_initialization"] = True