Skip to content

Commit

Permalink
Fixing deprecationWarnings
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMeisrimelModelon committed Feb 13, 2024
1 parent c12c847 commit ca9db97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions src/pyfmi/master.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ cdef class Master:
index_end = index_start + self.models_dict[model]["local_output_len"]
local_output_vref_array = (<FMUModelCS2>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):
Expand All @@ -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):
Expand All @@ -784,7 +784,7 @@ cdef class Master:
index_end = index_start + self.models_dict[model]["local_derivative_len"]
local_derivative_vref_array = (<FMUModelCS2>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)

Expand All @@ -793,15 +793,15 @@ 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):
cdef int j = 0
cdef np.ndarray ytmp = (<FMUModelCS2>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):
Expand Down Expand Up @@ -1789,5 +1789,3 @@ cdef class Master:
last_has_outputs = has_outputs
"""
return order, blocks,compressed_blocks


2 changes: 1 addition & 1 deletion tests/test_fmi_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca9db97

Please sign in to comment.