Skip to content

Commit

Permalink
more cleanup of warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMeisrimelModelon committed Jan 24, 2024
1 parent 62afd1d commit 69f6e07
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/pyfmi/fmi.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5098,7 +5098,7 @@ cdef class FMUModelBase2(ModelBase):
filter_list = self._convert_filter(filter)
length_filter = len(filter_list)

for i in range(<int>variable_list_size):
for i in range(<size_t>variable_list_size):

variable = FMIL.fmi2_import_get_variable(variable_list, i)

Expand Down Expand Up @@ -5227,7 +5227,7 @@ cdef class FMUModelBase2(ModelBase):
filter_list = self._convert_filter(filter)
length_filter = len(filter_list)

for i in range(<int>variable_list_size):
for i in range(<size_t>variable_list_size):

variable = FMIL.fmi2_import_get_variable(variable_list, i)

Expand Down Expand Up @@ -7213,7 +7213,7 @@ cdef class FMUModelCS2(FMUModelBase2):
value_refs[0] = self.get_variable_valueref(variables)
elif isinstance(variables,list) and N.prod([int(isinstance(v,str)) for v in variables]): #prod equals 0 or 1
value_refs = N.array([0]*<size_t>nref, dtype=N.uint32,ndmin=1).ravel()
for i in range(<int>nref):
for i in range(<size_t>nref):
value_refs[i] = self.get_variable_valueref(variables[i])
orders[i] = order
else:
Expand Down Expand Up @@ -7279,7 +7279,7 @@ cdef class FMUModelCS2(FMUModelBase2):
nref = len(variables)
value_refs = N.array([0]*<size_t>nref, dtype=N.uint32, ndmin=1).ravel()
orders = N.array([0]*<size_t>nref, dtype=N.int32)
for i in range(<int>nref):
for i in range(<size_t>nref):
value_refs[i] = self.get_variable_valueref(variables[i])
orders[i] = order
else:
Expand Down
10 changes: 5 additions & 5 deletions src/pyfmi/fmi_extended.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ cdef class FMUModelME1Extended(FMUModelME1):
cdef N.ndarray[FMIL.fmi1_real_t, ndim=1,mode='c'] val = N.array(values, dtype=float, ndmin=1).flatten()

nref = len(val)
orders = N.array([0]*nref, dtype=N.int32)
orders = N.array([0]*<size_t>nref, dtype=N.int32)

if nref != len(np_orders):
if <size_t>nref != len(np_orders):
raise FMUException("The number of variables must be the same as the number of orders.")

for i in range(len(np_orders)):
Expand All @@ -308,13 +308,13 @@ cdef class FMUModelME1Extended(FMUModelME1):
value_refs = N.array([0], dtype=N.uint32,ndmin=1).flatten()
value_refs[0] = self.get_variable_valueref(variables)
elif isinstance(variables,list) and isinstance(variables[-1],str):
value_refs = N.array([0]*nref, dtype=N.uint32,ndmin=1).flatten()
for i in range(nref):
value_refs = N.array([0]*<size_t>nref, dtype=N.uint32,ndmin=1).flatten()
for i in range(<size_t>nref):
value_refs[i] = self.get_variable_valueref(variables[i])
else:
raise FMUException("The variables must either be a string or a list of strings")

for i in range(nref):
for i in range(<size_t>nref):
self._input_derivatives[value_refs[i]][np_orders[i]-1] = val[i]/self._input_factorials[np_orders[i]-1]

#Activate input
Expand Down
7 changes: 5 additions & 2 deletions src/pyfmi/fmi_util.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1105,11 +1105,14 @@ cdef class DumpData:
self.dump_data(np.array(float(self.model.time)))
self.dump_data(diag_data)

from libc.stdio cimport *
# from libc.stdio cimport *

cdef extern from "stdio.h":
FILE *fdopen(int, const char *)

FILE *fopen(const char *, const char *)
size_t fread(void*, size_t, size_t, FILE *)
int fseek(FILE *, long, int)
int fclose(FILE *)

@cython.boundscheck(False)
@cython.wraparound(False)
Expand Down
5 changes: 3 additions & 2 deletions src/pyfmi/master.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ cdef perform_do_step_parallel(list models, FMIL.fmi2_import_t** model_addresses,
Perform a do step on all the models.
"""
cdef int i, status = 0
cdef int num_threads, id
cdef double time
cdef int num_threads
# cdef int id
# cdef double time

for i in prange(n, nogil=True, schedule="dynamic", chunksize=1):
#for i in prange(n, nogil=True, schedule="dynamic"):
Expand Down

0 comments on commit 69f6e07

Please sign in to comment.