diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21cd6dc63921..6e9f526db0a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,9 @@ jobs: - name: CI configuration shell: bash - run: python3 kratos/python_scripts/testing/ci_utilities.py + run: | + python3 kratos/python_scripts/testing/ci_utilities.py + python3 -m pip install --upgrade numpy==1.26.4 - name: Build shell: bash diff --git a/applications/RomApplication/python_scripts/hrom_training_utility.py b/applications/RomApplication/python_scripts/hrom_training_utility.py index bd4870a6502a..e43961b65ddd 100644 --- a/applications/RomApplication/python_scripts/hrom_training_utility.py +++ b/applications/RomApplication/python_scripts/hrom_training_utility.py @@ -180,7 +180,7 @@ def AppendCurrentStepResiduals(self): err_msg = f"Projection strategy \'{self.projection_strategy}\' for HROM is not supported." raise Exception(err_msg) - np_res_mat = np.array(res_mat, copy=False) + np_res_mat = np.asarray(res_mat) self.time_step_residual_matrix_container.append(np_res_mat) def GetJacobianPhiMultiplication(self, computing_model_part): diff --git a/applications/RomApplication/python_scripts/petrov_galerkin_training_utility.py b/applications/RomApplication/python_scripts/petrov_galerkin_training_utility.py index 0cf528d1370c..6e0c907eb9d1 100644 --- a/applications/RomApplication/python_scripts/petrov_galerkin_training_utility.py +++ b/applications/RomApplication/python_scripts/petrov_galerkin_training_utility.py @@ -80,7 +80,7 @@ def AppendCurrentStepProjectedSystem(self): err_msg = "\'self.basis_strategy\' is not available. Select either 'jacobian' or 'residuals'." raise Exception(err_msg) - np_snapshots_matrix = np.array(snapshots_matrix, copy=False) + np_snapshots_matrix = np.asarray(snapshots_matrix) self.time_step_snapshots_matrix_container.append(np_snapshots_matrix) def GetJacobianPhiMultiplication(self, computing_model_part): diff --git a/applications/RomApplication/python_scripts/rom_analysis.py b/applications/RomApplication/python_scripts/rom_analysis.py index a78cc69d4a80..8afce059ab56 100644 --- a/applications/RomApplication/python_scripts/rom_analysis.py +++ b/applications/RomApplication/python_scripts/rom_analysis.py @@ -292,7 +292,7 @@ def ModifyInitialGeometry(self): print('Nodal variables: ', nodal_unknown_names) - s_default = np.array(s, copy=False) + s_default = np.asarray(s) print(s_default.shape) q, _ = nn_rom_interface.get_encode_function()(s_default) diff --git a/applications/RomApplication/python_scripts/rom_manager.py b/applications/RomApplication/python_scripts/rom_manager.py index d926a8191584..2ea4668e94d7 100644 --- a/applications/RomApplication/python_scripts/rom_manager.py +++ b/applications/RomApplication/python_scripts/rom_manager.py @@ -1008,7 +1008,7 @@ def Initialize(cls): def GetNonconvergedSolutions(cls): a,_ = cls._GetSolver()._GetSolutionStrategy().GetNonconvergedSolutions() - return np.array(a, copy=False) + return np.asarray(a) simulation.Initialize = types.MethodType(Initialize, simulation) simulation.GetNonconvergedSolutions = types.MethodType(GetNonconvergedSolutions, simulation) diff --git a/kratos/python_scripts/petsc_conversion_tools.py b/kratos/python_scripts/petsc_conversion_tools.py index 343de7d06012..03ebc36c7996 100644 --- a/kratos/python_scripts/petsc_conversion_tools.py +++ b/kratos/python_scripts/petsc_conversion_tools.py @@ -18,17 +18,17 @@ def __init__(self, A): #Kratos DistributedCsrMatrix N = A.GetColNumbering().Size() ##pointers to the kratos arrays of values - self.a = np.array(A.GetDiagonalBlock().value_data(), copy=False) - self.oa = np.array(A.GetOffDiagonalBlock().value_data(), copy=False) + self.a = np.asarray(A.GetDiagonalBlock().value_data()) + self.oa = np.asarray(A.GetOffDiagonalBlock().value_data()) if(type(m) == type(PETSc.IntType)): #we can avoid doing copies #indices of diagonal block - self.i = np.array(A.GetDiagonalBlock().index1_data(), copy=False) - self.j = np.array(A.GetDiagonalBlock().index2_data(), copy=False) + self.i = np.asarray(A.GetDiagonalBlock().index1_data()) + self.j = np.asarray(A.GetDiagonalBlock().index2_data()) #indices of offdiagonal block - self.oi = np.array(A.GetOffDiagonalBlock().index1_data(), copy=False) - self.oj = np.array(A.GetOffDiagonalIndex2DataInGlobalNumbering(), copy=False) + self.oi = np.asarray(A.GetOffDiagonalBlock().index1_data()) + self.oj = np.asarray(A.GetOffDiagonalIndex2DataInGlobalNumbering()) else: #WE NEED TO COPY INDICES! since the size of the IndexType is not compatible between Kratos and PETSc if(A.GetComm().Rank() == 0): diff --git a/kratos/tests/test_numpy_export_dense_matrix.py b/kratos/tests/test_numpy_export_dense_matrix.py index 8ff254f548ed..1e3012175f57 100644 --- a/kratos/tests/test_numpy_export_dense_matrix.py +++ b/kratos/tests/test_numpy_export_dense_matrix.py @@ -10,7 +10,7 @@ def test_numpy_export_dense_matrix_no_copying(self): KratosMatrix.fill(1.0) # Export it to numpy array (No copying is performed) - NumpyMatrix = np.array(KratosMatrix,copy=False) + NumpyMatrix = np.asarray(KratosMatrix) # Test correct creation for i in range(3): @@ -35,7 +35,7 @@ def test_numpy_export_complex_dense_matrix_no_copying(self): KratosMatrix.fill(1.0+1.0j) # Export it to numpy array (No copying is performed) - NumpyMatrix = np.array(KratosMatrix,copy=False) + NumpyMatrix = np.asarray(KratosMatrix) # Test correct creation for i in range(3): diff --git a/kratos/tests/test_vectorized_interpolation.py b/kratos/tests/test_vectorized_interpolation.py index c9f873987565..dec4a660201d 100644 --- a/kratos/tests/test_vectorized_interpolation.py +++ b/kratos/tests/test_vectorized_interpolation.py @@ -39,7 +39,7 @@ def testVectorizedInterpolation(self): #obtaining a copy of database onto numpy array, and reshaping it into matrices nnodes = len(self.mp.Nodes) - vdata = np.array(Kratos.VariableUtils().GetSolutionStepValuesVector(self.mp.Nodes, Kratos.VELOCITY, 0, 3),copy=False).reshape(nnodes,3) + vdata = np.asarray(Kratos.VariableUtils().GetSolutionStepValuesVector(self.mp.Nodes, Kratos.VELOCITY, 0, 3)).reshape(nnodes,3) coords = np.array(Kratos.VariableUtils().GetCurrentPositionsVector(self.mp.Nodes,3)).reshape(nnodes,3) ##coordinates to search for