# Modification of array dimension using dataset\_adapter

**URL:** https://discourse.vtk.org/t/modification-of-array-dimension-using-dataset-adapter/4567
**Category:** Development
**Tags:** proposal
**Created:** [November 4, 2020, 6:58pm UTC](https://discourse.vtk.org/t/modification-of-array-dimension-using-dataset-adapter/4567 "2020-11-04T18:58:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ali.baba](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/eb8c5e/32.png) [@ali.baba](https://discourse.vtk.org/u/ali.baba)
#### Post date: [November 4, 2020, 6:58pm UTC](https://discourse.vtk.org/t/modification-of-array-dimension-using-dataset-adapter/4567/1 "2020-11-04T18:58:28Z")

</div>

Hi everyone,

While using the dataset\_adapter enabling numpy-like access to vtk dataset I have come across an unfortunate behavior. Here is the sequence :

```python
u_grid_vtk = vtk.vtkUnstructuredGrid()
u_grid = dsa.WrapDataObject(u_grid_vtk)
test_arr = np.zeros((2,9) dtype=np.int32)
print(load_arr.shape) # print (2, 9) as expected
u_grid.FieldData.append(test_arr 'TEST')
print(u_grid.FieldData['TEST'].shape) # print (2,3,3) not expected

```

I found that this behavior comes from the method “vtkDataArrayToVTKArray” in dataset\_adapter.py. In fact, if the vtk data array second dimension is of size 9, then the array is understood as a matrix and rearranged such that its shape is (2,3,3) (+ transposing for handling Fortran to C order). In my case it complety messed my array.

I understand that it can make sense to reshape it as a matrix, however I think that the transposition is unsafe. While appending the array with `u_grid.FieldData.append(test_arr 'TEST')`, could we treat the array such as it is understood as a matrix of shape (x, 3, 3), and handle the transposition (as it is already done if the array is of shape (x,3,3))?  
This way we make sure when getting the array that the data order is the same as the input data order.

Thanks in advance,

Ali
