Skip to content

Cannot assign data with array view #2546

@WawrzJa00

Description

@WawrzJa00

Before submitting the issue

  • I have checked for Compatibility issues
  • I have searched among the existing issues
  • I am using a Python virtual environment

Description of the bug

When assigning data to field with numpy arrays transposed view (or any view probably) it doesn't change the data arrangement. Arrays need to be copied. If that's intentional I'd appreciate the docs note

Steps To Reproduce

import ansys.dpf.core as dpf
import numpy as np

points = np.array([[1,2,3],[4,5,6], [7,8,9]])
points_T = points.T
points_T_copy = points_T.copy()

coordinates_field = dpf.fields_factory.create_3d_vector_field(len(points))
coordinates_field.data = points
coordinates_field.unit = "mm"
coordinates_field.scoping.ids = range(1, len(coordinates_field.data) + 1)
print("Original", coordinates_field)

coordinates_field = dpf.fields_factory.create_3d_vector_field(len(points_T))
coordinates_field.data = points_T
coordinates_field.scoping.ids = range(1, len(coordinates_field.data) + 1)
print("Transposed view", coordinates_field)

coordinates_field = dpf.fields_factory.create_3d_vector_field(len(points_T_copy))
coordinates_field.data = points_T_copy
coordinates_field.unit = "mm"
coordinates_field.scoping.ids = range(1, len(coordinates_field.data) + 1)
print("Transposed copy", coordinates_field)

Which Operating System causes the issue?

Windows

Which DPF/Ansys version are you using?

DPF Server 2025.1.pre0

Which Python version causes the issue?

3.12

Installed packages

python = "^3.12"
numpy = "<2"
pandas = "^2.2.3"
scipy = "^1.15.1"
pyvista = "^0.44.2"
ipykernel = "^6.29.5"
nbformat = "^5.10.4"
plotly = "^6.0.0"
xarray = "^2025.1.2"
scikit-guess = "^0.0.1a0"
scikit-learn = "^1.6.1"
ansys-dpf-core = "0.13.8"
netcdf4 = "^1.7.2"

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions