diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d2d7d233..680defca 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: python-version: '3.9.x' - name: Setup Python run: | - python3 -m pip install Cython "numpy<2" scipy matplotlib nose-py3 setuptools==69.1.0 + python3 -m pip install Cython numpy scipy matplotlib nose-py3 setuptools==69.1.0 - name: Install system run: | sudo apt-get -y install cmake liblapack-dev libsuitesparse-dev libhypre-dev diff --git a/CHANGELOG b/CHANGELOG index 8e786927..20342d6a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,8 @@ --- CHANGELOG --- + +--- PyFMI-2.13.1 --- + * Numpy 2.x support + --- PyFMI-2.13.0 --- * Upgraded to Cython3. diff --git a/src/common/io.py b/src/common/io.py index 3da31f15..cf50369b 100644 --- a/src/common/io.py +++ b/src/common/io.py @@ -2442,7 +2442,7 @@ def __write_header(self, header, name): Dumps the header and name to file. """ self._file.write(header.tobytes(order="F")) - self._file.write(np.compat.asbytes(name +"\0")) + self._file.write(name.encode() + b"\0") def _write_header(self, name, nbr_rows, nbr_cols, data_type): """ diff --git a/src/pyfmi/fmi.pyx b/src/pyfmi/fmi.pyx index 48e45a3b..a0c94d97 100644 --- a/src/pyfmi/fmi.pyx +++ b/src/pyfmi/fmi.pyx @@ -1542,7 +1542,7 @@ cdef class FMUModelBase(ModelBase): Calls the low-level FMI function: fmiGetReal """ cdef int status - cdef np.ndarray[FMIL.fmi1_value_reference_t, ndim=1,mode='c'] val_ref = np.array(valueref, copy=False, dtype=np.uint32).ravel() + cdef np.ndarray[FMIL.fmi1_value_reference_t, ndim=1,mode='c'] val_ref = np.asarray(valueref, dtype=np.uint32).ravel() cdef FMIL.size_t nref = np.size(val_ref) cdef np.ndarray[FMIL.fmi1_real_t, ndim=1,mode='c'] val = np.array([0.0]*nref, dtype=float, ndmin=1) @@ -1575,8 +1575,8 @@ cdef class FMUModelBase(ModelBase): Calls the low-level FMI function: fmiSetReal """ cdef int status - cdef np.ndarray[FMIL.fmi1_value_reference_t, ndim=1,mode='c'] val_ref = np.array(valueref, copy=False, dtype=np.uint32).ravel() - cdef np.ndarray[FMIL.fmi1_real_t, ndim=1,mode='c'] val = np.array(values, copy=False, dtype=float).ravel() + cdef np.ndarray[FMIL.fmi1_value_reference_t, ndim=1,mode='c'] val_ref = np.asarray(valueref, dtype=np.uint32).ravel() + cdef np.ndarray[FMIL.fmi1_real_t, ndim=1,mode='c'] val = np.asarray(values, dtype=float).ravel() cdef FMIL.size_t nref = np.size(val_ref) if nref != np.size(val): @@ -4187,7 +4187,7 @@ cdef class FMUModelBase2(ModelBase): Calls the low-level FMI function: fmi2GetReal """ cdef int status - cdef np.ndarray[FMIL.fmi2_value_reference_t, ndim=1,mode='c'] input_valueref = np.array(valueref, copy=False, dtype=np.uint32).ravel() + cdef np.ndarray[FMIL.fmi2_value_reference_t, ndim=1,mode='c'] input_valueref = np.asarray(valueref, dtype=np.uint32).ravel() cdef FMIL.size_t nref = np.size(input_valueref) cdef np.ndarray[FMIL.fmi2_real_t, ndim=1,mode='c'] output_value = np.zeros(nref) @@ -4221,8 +4221,8 @@ cdef class FMUModelBase2(ModelBase): """ cdef int status - cdef np.ndarray[FMIL.fmi2_value_reference_t, ndim=1,mode='c'] input_valueref = np.array(valueref, copy=False, dtype=np.uint32).ravel() - cdef np.ndarray[FMIL.fmi2_real_t, ndim=1,mode='c'] set_value = np.array(values, copy=False, dtype=float).ravel() + cdef np.ndarray[FMIL.fmi2_value_reference_t, ndim=1,mode='c'] input_valueref = np.asarray(valueref, dtype=np.uint32).ravel() + cdef np.ndarray[FMIL.fmi2_real_t, ndim=1,mode='c'] set_value = np.asarray(values, dtype=float).ravel() if np.size(input_valueref) != np.size(set_value): raise FMUException('The length of valueref and values are inconsistent.') @@ -8237,8 +8237,8 @@ cdef class FMUModelME2(FMUModelBase2): cdef int method = FORWARD_DIFFERENCE if self.force_finite_differences is True or self.force_finite_differences == 0 else CENTRAL_DIFFERENCE cdef double RUROUND = FORWARD_DIFFERENCE_EPS if method == FORWARD_DIFFERENCE else CENTRAL_DIFFERENCE_EPS cdef np.ndarray[FMIL.fmi2_real_t, ndim=1, mode='c'] dfpert, df, eps, nominals - cdef np.ndarray[FMIL.fmi2_value_reference_t, ndim=1, mode='c'] v_ref = np.array(var_ref, copy=False, dtype = np.uint32) - cdef np.ndarray[FMIL.fmi2_value_reference_t, ndim=1, mode='c'] z_ref = np.array(func_ref, copy=False, dtype = np.uint32) + cdef np.ndarray[FMIL.fmi2_value_reference_t, ndim=1, mode='c'] v_ref = np.asarray(var_ref, dtype=np.uint32) + cdef np.ndarray[FMIL.fmi2_value_reference_t, ndim=1, mode='c'] z_ref = np.asarray(func_ref, dtype=np.uint32) cdef int ind_local = 5 if add_diag else 4 cdef list local_group