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.

array dimensional mismatch is confusing

See original GitHub issue

Describe the bug, what’s wrong, and what you expected.

I am trying to run the marching cubes algorithm on a 3D binary array, but I get the following error: Number of scalars (47448064) must match either the number of points (47448064) or the number of cells (47001780). Funny part is, that the number of scalars actually matches the number of points.

Steps to reproduce the bug.

dims=(181, 512, 512)
spacing=(2.5, 1.25, 1.25)
grid = pv.UniformGrid(
    dims=dims,
    spacing=spacing,
    origin=(0,0,0),
)
x, y, z = grid.points.T
mesh = grid.contour([0.5], np.random.randn(dims[0], dims[1], dims[2]), method='marching_cubes')

System Information

--------------------------------------------------------------------------------
  Date: Fri Sep 30 10:30:43 2022 EEST

                OS : Linux
            CPU(s) : 8
           Machine : x86_64
      Architecture : 64bit
               RAM : 11.7 GiB
       Environment : Jupyter
       File system : ext4
        GPU Vendor : Microsoft Corporation
      GPU Renderer : D3D12 (NVIDIA GeForce RTX 3060 Laptop GPU)
       GPU Version : 3.3 (Core Profile) Mesa 21.2.6

  Python 3.9.12 (main, Apr  5 2022, 06:56:58)  [GCC 7.5.0]

           pyvista : 0.36.1
               vtk : 9.1.0
             numpy : 1.22.4
           imageio : 2.9.0
           appdirs : 1.4.4
            scooby : 0.5.12
        matplotlib : 3.5.1
             PyQt5 : 5.15.7
           IPython : 8.2.0
          colorcet : 1.0.0
           cmocean : 2.0
        ipyvtklink : 0.2.2
             scipy : 1.7.3
              tqdm : 4.64.0
            meshio : 5.3.4
        jupyterlab : 3.3.2
         pythreejs : Version unknown

  Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904
  for Intel(R) 64 architecture applications
--------------------------------------------------------------------------------

Screenshots

image

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
akaszynskicommented, Oct 5, 2022

I believe @akaszynski was working on this recently?

Yep, that’s part of the textures PR #2729. Really want that merged before next release.

2reactions
MatthewFlammcommented, Sep 30, 2022

I’m going to put this as a good-first-issue. I think we are suggesting that we could check for multidimensional data and then provide a more helpful error message in the case where provided_array.size == mesh.n_points or provided_array.size == mesh.n_cells with some suggestions to consider np.ravel or ndarray.flatten.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Confused about Dimension Mismatch - New to Julia
I have the following code snip: a = Matrix(dR') b = W @show size(a),size(b) @show typeof(a), typeof(b) G = a*b. This is the...
Read more >
Dimension mismatch when initalizing an array (JAGS)
My initial values for this array are plausible locations within suitable habitat, and is an array with dimensions 64, 2, 21. Yet, JAGS...
Read more >
Unclear as to why I'm getting a dimension mismatch?
Subscripted assignment dimension mismatch. Only thing I can think of is that matlab believes I'm attempting to assign a matrix into a string....
Read more >
Documentation: 15: 8.15. Arrays - PostgreSQL
Multidimensional arrays must have matching extents for each dimension. A mismatch causes an error, for example: INSERT INTO sal_emp VALUES ('Bill', '{10000, ...
Read more >
Rstan error: Mismatched array dimensions.Base type ...
Rstan error: Mismatched array dimensions.Base type mismatch. Returned expression does not match return type LHS type = real; RHS type = real[ ,...
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