Skip to content

Commit

Permalink
various renaming of private variables
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMeisrimelModelon committed Jan 22, 2024
1 parent ea01cd4 commit 9c984d8
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ install_requires =
cython >= 3.0.7
nose-py3 >= 1.6.3
matplotlib > 3
assimulo >= 3.5.0
assimulo >= 3.5.0
16 changes: 8 additions & 8 deletions src/pyfmi/fmi.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ cdef class FMUModelME1(FMUModelBase):
cpdef _get_time(self)
cpdef _set_time(self, FMIL.fmi1_real_t t)
cpdef get_derivatives(self)
cdef int __get_nominal_continuous_states(self, FMIL.fmi1_real_t* xnominal, size_t nx)
cdef int _get_nominal_continuous_states_fmil(self, FMIL.fmi1_real_t* xnominal, size_t nx)
cdef public object _preinit_nominal_continuous_states

cdef class __ForTestingFMUModelME1(FMUModelME1):
cdef int __get_nominal_continuous_states(self, FMIL.fmi1_real_t* xnominal, size_t nx)
cdef class _ForTestingFMUModelME1(FMUModelME1):
cdef int _get_nominal_continuous_states_fmil(self, FMIL.fmi1_real_t* xnominal, size_t nx)
cpdef set_allocated_fmu(self, int value)

cdef class FMUModelBase2(ModelBase):
Expand Down Expand Up @@ -256,11 +256,11 @@ cdef class FMUModelME2(FMUModelBase2):
cpdef get_derivatives(self)
cdef public object force_finite_differences
cdef int _get_derivatives(self, FMIL.fmi2_real_t[:] values)
cdef int __get_continuous_states(self, FMIL.fmi2_real_t[:] ndx)
cdef int __set_continuous_states(self, FMIL.fmi2_real_t[:] ndx)
cdef int _get_continuous_states_fmil(self, FMIL.fmi2_real_t[:] ndx)
cdef int _set_continuous_states_fmil(self, FMIL.fmi2_real_t[:] ndx)
cdef int _get_event_indicators(self, FMIL.fmi2_real_t[:] values)
cdef int _completed_integrator_step(self, int* enter_event_mode, int* terminate_simulation)
cdef int __get_nominal_continuous_states(self, FMIL.fmi2_real_t* xnominal, size_t nx)
cdef int _get_nominal_continuous_states_fmil(self, FMIL.fmi2_real_t* xnominal, size_t nx)
cdef public object _preinit_nominal_continuous_states

cdef class WorkerClass2:
Expand All @@ -275,11 +275,11 @@ cdef class WorkerClass2:
cdef N.ndarray get_real_numpy_vector(self, int index)
cpdef verify_dimensions(self, int dim)

cdef class __ForTestingFMUModelME2(FMUModelME2):
cdef class _ForTestingFMUModelME2(FMUModelME2):
cdef int _get_real_by_ptr(self, FMIL.fmi2_value_reference_t* vrefs, size_t size, FMIL.fmi2_real_t* values)
cdef int _set_real(self, FMIL.fmi2_value_reference_t* vrefs, FMIL.fmi2_real_t* values, size_t size)
cdef int _get_real_by_list(self, FMIL.fmi2_value_reference_t[:] valueref, size_t size, FMIL.fmi2_real_t[:] values)
cdef int _get_integer(self, FMIL.fmi2_value_reference_t[:] valueref, size_t size, FMIL.fmi2_integer_t[:] values)
cdef int _get_boolean(self, FMIL.fmi2_value_reference_t[:] valueref, size_t size, FMIL.fmi2_real_t[:] values)
cdef int __get_nominal_continuous_states(self, FMIL.fmi2_real_t* xnominal, size_t nx)
cdef int _get_nominal_continuous_states_fmil(self, FMIL.fmi2_real_t* xnominal, size_t nx)
cpdef set_initialized_fmu(self, int value)
24 changes: 12 additions & 12 deletions src/pyfmi/fmi.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3445,7 +3445,7 @@ cdef class FMUModelME1(FMUModelBase):
""")


cdef int __get_nominal_continuous_states(self, FMIL.fmi1_real_t* xnominal, size_t nx):
cdef int _get_nominal_continuous_states_fmil(self, FMIL.fmi1_real_t* xnominal, size_t nx):
return FMIL.fmi1_import_get_nominal_continuous_states(self._fmu, xnominal, nx)

def _get_nominal_continuous_states(self):
Expand All @@ -3458,7 +3458,7 @@ cdef class FMUModelME1(FMUModelBase):
cdef int status
cdef N.ndarray[FMIL.fmi1_real_t, ndim=1, mode='c'] xn = N.zeros(self._nContinuousStates, dtype=N.double)

status = self.__get_nominal_continuous_states(<FMIL.fmi1_real_t*> xn.data, self._nContinuousStates)
status = self._get_nominal_continuous_states_fmil(<FMIL.fmi1_real_t*> xn.data, self._nContinuousStates)
if status != 0:
raise FMUException('Failed to get the nominal values.')

Expand Down Expand Up @@ -3955,9 +3955,9 @@ cdef class FMUModelME1(FMUModelBase):
self._instantiated_fmu = 0


cdef class __ForTestingFMUModelME1(FMUModelME1):
cdef class _ForTestingFMUModelME1(FMUModelME1):

cdef int __get_nominal_continuous_states(self, FMIL.fmi1_real_t* xnominal, size_t nx):
cdef int _get_nominal_continuous_states_fmil(self, FMIL.fmi1_real_t* xnominal, size_t nx):
for i in range(nx):
if self._allocated_fmu == 1: # If initialized
# Set new values to test that atol gets auto-corrected.
Expand Down Expand Up @@ -8014,7 +8014,7 @@ cdef class FMUModelME2(FMUModelBase2):

return enterEventMode==FMI2_TRUE, terminateSimulation==FMI2_TRUE

cdef int __get_continuous_states(self, FMIL.fmi2_real_t[:] ndx):
cdef int _get_continuous_states_fmil(self, FMIL.fmi2_real_t[:] ndx):
if self._nContinuousStates > 0:
return FMIL.fmi2_import_get_continuous_states(self._fmu, &ndx[0] ,self._nContinuousStates)
else:
Expand All @@ -8030,14 +8030,14 @@ cdef class FMUModelME2(FMUModelBase2):
"""
cdef int status
cdef N.ndarray[FMIL.fmi2_real_t, ndim=1, mode='c'] ndx = N.zeros(self._nContinuousStates, dtype=N.double)
status = self.__get_continuous_states(ndx)
status = self._get_continuous_states_fmil(ndx)

if status != 0:
raise FMUException('Failed to retrieve the continuous states.')

return ndx

cdef int __set_continuous_states(self, FMIL.fmi2_real_t[:] ndx):
cdef int _set_continuous_states_fmil(self, FMIL.fmi2_real_t[:] ndx):
if self._nContinuousStates > 0:
return FMIL.fmi2_import_set_continuous_states(self._fmu, &ndx[0] , self._nContinuousStates)
else:
Expand All @@ -8061,7 +8061,7 @@ cdef class FMUModelME2(FMUModelBase2):
'The number of values are not consistent with the number of '\
'continuous states.')

status = self.__set_continuous_states(ndx)
status = self._set_continuous_states_fmil(ndx)

if status >= 3:
raise FMUException('Failed to set the new continuous states.')
Expand All @@ -8073,7 +8073,7 @@ cdef class FMUModelME2(FMUModelBase2):
the low-level FMI function: fmi2SetContinuousStates/fmi2GetContinuousStates.
""")

cdef int __get_nominal_continuous_states(self, FMIL.fmi2_real_t* xnominal, size_t nx):
cdef int _get_nominal_continuous_states_fmil(self, FMIL.fmi2_real_t* xnominal, size_t nx):
return FMIL.fmi2_import_get_nominals_of_continuous_states(self._fmu, xnominal, nx)

def _get_nominal_continuous_states(self):
Expand All @@ -8086,7 +8086,7 @@ cdef class FMUModelME2(FMUModelBase2):
cdef int status
cdef N.ndarray[FMIL.fmi2_real_t, ndim=1, mode='c'] xn = N.zeros(self._nContinuousStates, dtype=N.double)

status = self.__get_nominal_continuous_states(<FMIL.fmi2_real_t*> xn.data, self._nContinuousStates)
status = self._get_nominal_continuous_states_fmil(<FMIL.fmi2_real_t*> xn.data, self._nContinuousStates)
if status != 0:
raise FMUException('Failed to get the nominal values.')

Expand Down Expand Up @@ -8517,7 +8517,7 @@ cdef class FMUModelME2(FMUModelBase2):

return A

cdef class __ForTestingFMUModelME2(FMUModelME2):
cdef class _ForTestingFMUModelME2(FMUModelME2):
cdef int _get_real_by_ptr(self, FMIL.fmi2_value_reference_t* vrefs, size_t size, FMIL.fmi2_real_t* values):
vr = N.zeros(size)
for i in range(size):
Expand Down Expand Up @@ -8574,7 +8574,7 @@ cdef class __ForTestingFMUModelME2(FMUModelME2):
return FMIL.fmi2_status_error
return FMIL.fmi2_status_ok

cdef int __get_nominal_continuous_states(self, FMIL.fmi2_real_t* xnominal, size_t nx):
cdef int _get_nominal_continuous_states_fmil(self, FMIL.fmi2_real_t* xnominal, size_t nx):
for i in range(nx):
if self._initialized_fmu == 1:
# Set new values to test that atol gets auto-corrected.
Expand Down
4 changes: 2 additions & 2 deletions src/pyfmi/simulation/assimulo_interface.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ cdef class FMIODE2(cExplicit_Problem):
self.model_me2._set_time(t)
#Check if there are any states
if self._f_nbr != 0:
self.model_me2.__set_continuous_states(y)
self.model_me2._set_continuous_states_fmil(y)
else:
#Moving data to the model
self._model.time = t
Expand All @@ -750,7 +750,7 @@ cdef class FMIODE2(cExplicit_Problem):
if self._f_nbr == 0:
return 0

self.model_me2.__get_continuous_states(self._state_temp_1)
self.model_me2._get_continuous_states_fmil(self._state_temp_1)
res = FMIL.memcmp(self._state_temp_1.data, y.data, self._f_nbr*sizeof(double))

if res == 0:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_fmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from io import StringIO

from pyfmi import testattr
from pyfmi.fmi import FMUException, InvalidOptionException, InvalidXMLException, InvalidBinaryException, InvalidVersionException, FMUModelME1, FMUModelCS1, load_fmu, FMUModelCS2, FMUModelME2, PyEventInfo
from pyfmi.fmi import FMUException, InvalidOptionException, InvalidXMLException, InvalidBinaryException, InvalidVersionException, FMUModelME1, FMUModelCS1, load_fmu, FMUModelCS2, FMUModelME2
import pyfmi.fmi as fmi
from pyfmi.fmi_algorithm_drivers import AssimuloFMIAlg, AssimuloFMIAlgOptions, \
PYFMI_JACOBIAN_LIMIT, PYFMI_JACOBIAN_SPARSE_SIZE_LIMIT
Expand Down Expand Up @@ -538,7 +538,7 @@ def test_get_erroneous_nominals_capi_fmi1(self):
logging.basicConfig(stream=log_stream, level=logging.WARNING)

model.states_vref = [114, 115, 116, 117, 118, 119, 120, 121]
# NOTE: Property 'nominal_continuous_states' is already overriden in Dummy_FMUModelME1, so just
# NOTE: Property 'nominal_continuous_states' is already overridden in Dummy_FMUModelME1, so just
# call the underlying function immediately.
xn = model._get_nominal_continuous_states()

Expand Down Expand Up @@ -1421,7 +1421,7 @@ def test_get_erroneous_nominals_capi(self):
log_stream = StringIO()
logging.basicConfig(stream=log_stream, level=logging.WARNING)

# NOTE: Property 'nominal_continuous_states' is already overriden in Dummy_FMUModelME2, so just
# NOTE: Property 'nominal_continuous_states' is already overridden in Dummy_FMUModelME2, so just
# call the underlying function immediately.
xn = model._get_nominal_continuous_states()

Expand Down
8 changes: 4 additions & 4 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import os
import numpy as np

from pyfmi.fmi import FMUException, FMUModelME1, __ForTestingFMUModelME1, FMUModelCS1, load_fmu, \
FMUModelCS2, FMUModelME2, __ForTestingFMUModelME2
from pyfmi.fmi import FMUException, FMUModelME1, _ForTestingFMUModelME1, FMUModelCS1, load_fmu, \
FMUModelCS2, FMUModelME2, _ForTestingFMUModelME2

def get_examples_folder():
return os.path.join(os.path.dirname(__file__), '..', 'examples')

class Dummy_FMUModelME1(__ForTestingFMUModelME1):
class Dummy_FMUModelME1(_ForTestingFMUModelME1):
# If true, makes use of the real __ForTesting implementation for nominal_continuous_states,
# else just returns 1.0 for each.
override_nominal_continuous_states = True
Expand Down Expand Up @@ -208,7 +208,7 @@ def set_integer(self, vref, values):
for i,v in enumerate(vref):
self.values[v] = values[i]

class Dummy_FMUModelME2(__ForTestingFMUModelME2):
class Dummy_FMUModelME2(_ForTestingFMUModelME2):

# -- Test options --

Expand Down

0 comments on commit 9c984d8

Please sign in to comment.