question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

to_vtk is too lenient with model array sizes

See original GitHub issue

@thast pointed out to me that there is an issue when passing non-vectorized data arrays to the to_vtk() method.

import pyvista as pv
import numpy as np
import discretize

mesh = discretize.TensorMesh.readUBC('Mesh_model/mesh3d.msh')

model3d = np.load('Mesh_model/model.npy')
print(model3d.shape, model3d.size)

((10000, 28), 280000)

Then this:

mesh.to_vtk({'model3d': model3d})

works fine but as soon as you try to use that PyVista mesh, the VTK backend will segfault.

The reason you are able to create the PyVista object has to do with this check:

https://github.com/simpeg/discretize/blob/c16e34c93fd0b0b2848751ddde5cccbaadb5b82f/discretize/mixins/vtkModule.py#L88-L89

Should we change this to check the first axes of the model array? This way users could pass arrays containing vector data (nc by 3):

...
if mod.shape[0] != nc: 
     raise RuntimeError(...

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thastcommented, May 15, 2019

Thanks @banesullivan.

I think changing the test from size to shape is a good idea.

My issue when not vectorizing the model was that it did not throw me an error. Later, trying to use the pyvista object, I still did not get an error but my whole Python kernel died. This can be annoying if your script is long to run, and you do not know what went wrong. Getting an error earlier, without killing the whole kernel, would be very beneficial.

In most cases in SimPEG, we use order='F'. Non vectorized model are not common. In this case, it was just me making a silly oversight, while interpolating from multiple 1D mesh to a global 3D mesh.

0reactions
banesullivancommented, May 15, 2019

Okay awesome! Then I think #163 is an appropriate fix for this issue and it should prevent kernel crashes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TTK is too short, and/or the action is too compressed. - Reddit
I'm curious how the game would play if the health of all players and vehicles was doubled. I think infantry combat would be...
Read more >
TTK/hMPS1 Is an Attractive Therapeutic Target for Triple ...
We confirmed by immunohistochemistry and reverse phase protein array that TNBC expressed higher levels of TTK protein compared to the other ...
Read more >
Overexpression of ASPM, CDC20, and TTK Confer a Poorer ...
TTK inhibitors increased the efficacy of taxane chemotherapy in patient-derived xenograft models and in an immunocompetent mouse model of triple ...
Read more >
Ttk tracheal expression and requirements. (A) Late-stage ttk ...
Ttk tracheal expression and requirements. (A) Late-stage ttk mutant embryo showing an absence of branch fusion in the dorsal trunk (DT) (arrows).
Read more >
DIC package — spam 0.6.1.3 documentation
'imagette2mask': 3D numpy array of same size as imagette2 or None,. 'returnStatus': int,. Describes success in extracting imagette1 and imagette2. If == 1 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found