Fix pyvista doc export - #123
Conversation
|
@user27182 that would be the one to test. |
d87bb58 to
8174b4c
Compare
|
Tested against 8174b4c with build outputs here https://github.com/pyvista/pyvista/actions/runs/30313669088
|
|
I've tested it locally and it is not related to the trame side of thing but the vtk version instead. |
|
Hmm... if it was a vtk issue I would have expected two test failures, with both the static render and interactive render failing. But only the vtksz screenshot is in the failure report... |
|
Right, the rendering using vtk C++ is indeed correct... The export seems to have messed up the order of the scalar arrays... EDIT: not an ordering issue, just 64 decoded as 32 bits. |
|
Difference output is that with 9.6 the generated array is |
|
9.6 report |
|
Test code... import pyvista as pv
from pyvista import examples
pl = pv.Plotter()
grid = examples.load_explicit_structured()
grid = grid.compute_connections()
pl.add_mesh(grid, show_edges=True)
pl.trame.export_vtksz("grid.vtksz")
pl.trame.export_html("grid.html") |
|
@user27182 we should be all good now. (9.7 and older version) |
|
Thanks, I built docs again with the updates. I also updated the baselines based on the previous commit. Here's the new report. Everything looks good, except you'll notice the So, this fix as-is is fine with no regressions for 9.6 -> 9.7. But, maybe you want to see if you can keep the fix that was there? Can also raise it as a separate issue if you prefer and keep this as-is. This is the specific example that I'm talking about: # Plot using RGB on a single cell. Note that since the number of
# points and the number of cells are identical, we have to pass
# `preference='cell'`.
import pyvista as pv
import numpy as np
vertices = np.array(
[
[0, 0, 0],
[1, 0, 0],
[0.5, 0.667, 0],
[0.5, 0.33, 0.667],
]
)
faces = np.hstack([[3, 0, 1, 2], [3, 0, 3, 2], [3, 0, 1, 3], [3, 1, 2, 3]])
mesh = pv.PolyData(vertices, faces)
mesh.cell_data['colors'] = [
[255, 255, 255],
[0, 255, 0],
[0, 0, 255],
[255, 0, 0],
]
pl = pv.Plotter()
_ = pl.add_mesh(
mesh,
scalars='colors',
lighting=False,
rgb=True,
preference='cell',
)
pl.camera_position = 'xy'
pl.show() |
|
Thanks for the pointer, so the last commit ensure that any (u)int64 get converted to 32 bits so it can properly be managed by JS without weird type that don't behave like a standard typed array. |
|
Great. I'll push another commit and check the output again. LGTM here otherwise. Though I wonder if there should be regression tests for these...? Or maybe there already are elsewhere. Seems pretty finicky to get all the dtype conversions right. On our end a full PyVista docs build is really one of the best regression tests we have. But this test doesn't run with |
|
Well before we were allowing some arrays to stay in (u)int64 which works in some cases (very little) on the JS side. The finicky part is about the strategy, not the conversion per say. Before we were trying to be as true as possible to the original data, while now we prefer compatibility for the client side. The last thing is that before we were using the reported type from VTK (UNSIGNED_LONG, UNSIGNED_LONG_LONG, ...) to figure out the actual data representation. The problem is that *_LONG has a different meaning across platforms (32/64). By using the numpy dtype, we now have an homogeneous meaning across platform. |
|
For context, on mac, VTK_UNSIGNED_LONG and VTK_UNSIGNED_LONG_LONG are both 64 bits. In my mapping I was assuming VTK_UNSIGNED_LONG to be 32 bits. Which is true on Windows but not on Mac/Linux. |
|
Also I'm not expecting trame-vtk to evolve much. It will be replaced by trame-vtklocal (vtk-wasm / local rendering) and trame-rca (remote rendering). I'm in the process to add wasm support for PyVista which should fix all the issue reported and linked to vtk.js limitation... |
|
Okay. Sounds like things are (mostly) sorted then? Indeed the various C/C++ types, NumPy types, and variations across OS is all pretty confusing. Seems like this is more of a compatibility shim then, and limited testing is fine. Thanks for all the investigating! LGTM |

No description provided.