Skip to content

Fix PyVista n_faces deprecation

Summary

The codebase is using geometry.n_faces from PyVista.
In recent versions of PyVista, the non-strict behavior of n_faces has been removed, which now raises an AttributeError.

Steps to reproduce

  1. Install the latest version of PyVista (>0.44.1).
  2. Run example.py.
  3. The code fails inside light.py when calling geometry.n_faces.

What is the current bug behavior?

Execution stops with: AttributeError: The non-strict behavior of pv.PolyData.n_faces has been removed. Use pv.PolyData.n_cells or pv.PolyData.n_faces_strict instead.

What is the expected correct behavior?

Geometry should be checked using n_cells or n_faces_strict depending on the intended behavior.

Relevant logs and/or screenshots

File "ENVIRONMENT/light.py", line 452, in diffuse_map if geometry.n_faces == 0 : AttributeError: The non-strict behavior of pv.PolyData.n_faces has been removed.

Possible fixe

File "ENVIRONMENT/light.py", line 452

Replace:

if geometry.n_faces == 0:

with:

if geometry.n_cells == 0:

or:

if geometry.n_faces_strict == 0:
Edited by Grote Selim