Giter Club home page Giter Club logo

Comments (6)

MatthewFlamm avatar MatthewFlamm commented on June 9, 2024 1

This looks suspicious to me as well. It seems like it is a bug in higher level design to me since this function takes in an ndarray rather than a str, so it cannot figure out whether the data is originally point or cell data in this ambiguous case. I suspect we have to pass in a definitive use_points or similar and have logic in the calling function or a separate helper function to decide.

This bit of logic feels suspect to me:

if scalars.shape[0] == self.dataset.n_points and scalars.shape[0] == self.dataset.n_cells:
use_points = preference == 'point'
use_cells = not use_points
else:
use_points = scalars.shape[0] == self.dataset.n_points
use_cells = scalars.shape[0] == self.dataset.n_cells

from pyvista.

MatthewFlamm avatar MatthewFlamm commented on June 9, 2024 1

original_scalar_name = scalars
scalars = get_array(mesh, scalars, preference=preference, err=True)
scalar_bar_args.setdefault('title', original_scalar_name)
scalars_name = original_scalar_name
# Set the active scalars name here. If the name already exists in
# the input mesh, it may not be set as the active scalars within
# the mapper. This should be refactored by 0.36.0
field = get_array_association(mesh, original_scalar_name, preference=preference)
self.mapper.scalar_map_mode = field.name

This part of the code is executed before the _configure_scalar_mode in the mapper gets called in the example given in the issue. One potential solution might be to reset the preference in this part of the code based on the scalar array found. I'm also wary about the comment in this part of the code, so that is another avenue to explore

from pyvista.

banesullivan avatar banesullivan commented on June 9, 2024

I think the crux of this is that c.n_points == c.n_cells which is somewhat of an edge case.

It looks like there is a genuine bug here. After plotting, if we repr the mesh in a Jupyter cell it looks like something in the plotting routine got confused and set a new point_data array because the length matched (which is incorect):

Screenshot 2024-01-14 at 8 22 02 PM

As an aside, this feels related to #1897

from pyvista.

banesullivan avatar banesullivan commented on June 9, 2024

This bit of logic feels suspect to me:

if scalars.shape[0] == self.dataset.n_points and scalars.shape[0] == self.dataset.n_cells:
use_points = preference == 'point'
use_cells = not use_points
else:
use_points = scalars.shape[0] == self.dataset.n_points
use_cells = scalars.shape[0] == self.dataset.n_cells

I think preference defaults to 'point' and this bit of logic then thinks the scalars should be on the points... some further digging is needed

from pyvista.

banesullivan avatar banesullivan commented on June 9, 2024

"This should be refactored by 0.36.0"

🤣

from pyvista.

banesullivan avatar banesullivan commented on June 9, 2024

One potential solution might be to reset the preference in this part of the code based on the scalar array found.

I think this could work! Nice find!

from pyvista.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.