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.

PolyData is not hashable anymore

See original GitHub issue

Describe the bug, what’s wrong, and what you expect:

I use pyvista to visulize FE-Results. Therefore I create shapes (PolyData-Objects) and store them to interact later with them. I used dictionarys to store relations between my shapes and other Instancecs, like the corresponding Actor. Since version 0.32 the PolyData object is not hashable anymore and I can not use them as keys. Is this a feature or a bug? I can’t elaborate which change exactly cause this issue.

A clear and concise description of what you expected to happen. I expect the Polydata object able to be used as key for a dictionary.


To Reproduce

Please include a code snippet to reproduce the bug in the block below:

import pyvista as pv

shape = pv.PolyData([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]])
a = {shape, 'a'}

TypeError: unhashable type: 'PolyData'

System Information: Please run the following code wherever you are experiencing the bug and paste the output below. This report helps us track down bugs and it is critical to addressing your bug:

# Get system info
import pyvista as pv
print(pv.Report())
--------------------------------------------------------------------------------
  Date: Tue Oct 26 14:08:36 2021 Mitteleuropäische Sommerzeit
                OS : Windows
            CPU(s) : 8
           Machine : AMD64
      Architecture : 64bit
               RAM : 15.9 GiB
       Environment : IPython
        GPU Vendor : Intel
      GPU Renderer : Intel(R) HD Graphics 4600
       GPU Version : 4.3.0 - Build 20.19.15.5063
  Python 3.7.10 | packaged by conda-forge | (default, Oct  5 2021, 16:32:37)
  [MSC v.1916 64 bit (AMD64)]
           pyvista : 0.32.1
               vtk : 9.0.3
             numpy : 1.20.3
           imageio : 2.9.0
           appdirs : 1.4.4
            scooby : 0.5.7
            meshio : 4.4.6
        matplotlib : 3.4.3
         pyvistaqt : 0.5.0
             PyQt5 : 5.15.4
           IPython : 7.28.0
             scipy : 1.7.1
--------------------------------------------------------------------------------

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
akaszynskicommented, Nov 5, 2021

Interesting discussion.

Agree with @adeak, a hash should be only for immutable objects and a pyvista DataSet is absolutely mutable.

I’d recommend using the == operator until we implement a pyvista.allclose.

1reaction
MatthewFlammcommented, Nov 2, 2021

I like the idea of a separate pyvista.allclose function to be used when we want to check for almost equality, but not as the equality comparison.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In Python, why is a tuple hashable but not a list?
If you store the hash value somewhere (as part of a dict for example) and then you modify the list then it's not...
Read more >
https://public.kitware.com/pipermail/vtkusers/2016...
I have a VTK legacy file format POLYDATA that opens properly in Paraview. It has cell data with multiple ... Or that file...
Read more >
2009-February.txt - VTK - The Visualization Toolkit
Add each contour polygon to the PolyData in sort order, ... (Since you do not have the linker error anymore, but this is...
Read more >
CadQuery Class Summary
Note the Location of the resulting plane may not equal the center of this face, ... Return hash(self). Return type ... Convert shape...
Read more >
TYPE SAFETY IN THE LINUX KERNEL A DISSERTATION ...
A program which is not type safe can exhibit corruption and crashes. ... For the polydata analysis we need to correlate the f...
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