"Interpret values as categories" not working for string properties (PV 5.11.0 RC2)

Hi there,

I have a unstructured vtk mesh with certain “group” labels as strings for the cells. When I try to color the plot by these labels using the “Interpret values as categories”, the legend shows the correct categories in the model, but the whole model has the “NaN”-color.

If I am not hallucinating, this used to work in earlier versions (pre 5.10). I also cannot extract these cells based on the group property:

  File "C:\Program Files\ParaView 5.11.0\bin\Lib\site-packages\paraview\detail\python_selector.py", line 90, in execute
    raise RuntimeError(
RuntimeError: Expression '(Group == "Brick1")' did not produce a valid mask array. The value produced is of the type '<class 'bool'>'. This typically implies a malformed expression. Verify that the expression is valid

Here is an attached simplified vtk file with this problem:
test.vtu (2.1 KB)

Thanks! :slight_smile:

Hi @wtfermi !

The selection editor have changed a lot between 5.10 and 5.11. So there is perhaps a regression here.

Maybe @spyridon97 would have time to look at it?

Otherwise, you can open an issue at: https://gitlab.kitware.com/paraview/paraview/-/issues

Best,

François

@Francois_Mazen why do you think that the selection editor is relevant to this?

@cory.quammen would you like me to look into this?

The second part of the message with the extract selection triggers a crash in vtkSelection, so it reminded me your expertise with the selection editor (sorry if I am wrong):

1   ??                                                                                                                      0x7ffff7e6364c 
2   raise                                                                                                                   0x7ffff7e13958 
3   abort                                                                                                                   0x7ffff7dfd53d 
4   ??                                                                                                                      0x7ffff7dfd45c 
5   __assert_fail                                                                                                           0x7ffff7e0c486 
6   vtkGenericDataArray<vtkAOSDataArrayTemplate<signed char>, signed char>::Resize vtkGenericDataArray.txx              432 0x7fffedf7b950 
7   vtkAbstractArray::SetNumberOfValues                                            vtkAbstractArray.cxx                 211 0x7fffedf9876b 
8   vtkSelection::Evaluate                                                         vtkSelection.cxx                     753 0x7fffefdf63c6 
9   vtkSelection::Evaluate<std::map<std::string, vtkSignedCharArray *>>            vtkSelection.h                       257 0x7fffdd224d4f 
10  vtkExtractSelection::EvaluateSelection                                         vtkExtractSelection.cxx              506 0x7fffdd20bd69 
11  vtkExtractSelection::RequestData                                               vtkExtractSelection.cxx              427 0x7fffdd20b678 
12  vtkPVExtractSelection::RequestData                                             vtkPVExtractSelection.cxx            127 0x7fffdc870067 
13  vtkDataObjectAlgorithm::ProcessRequest                                         vtkDataObjectAlgorithm.cxx           87  0x7ffff067dde2 
14  vtkExecutive::CallAlgorithm                                                    vtkExecutive.cxx                     735 0x7ffff068a63d 
15  vtkDemandDrivenPipeline::ExecuteData                                           vtkDemandDrivenPipeline.cxx          462 0x7ffff06809ca 
16  vtkCompositeDataPipeline::ExecuteData                                          vtkCompositeDataPipeline.cxx         163 0x7ffff0673bc9 
17  vtkDemandDrivenPipeline::ProcessRequest                                        vtkDemandDrivenPipeline.cxx          261 0x7ffff067ff77 
18  vtkStreamingDemandDrivenPipeline::ProcessRequest                               vtkStreamingDemandDrivenPipeline.cxx 344 0x7ffff07d6aee 
19  vtkCompositeDataPipeline::ForwardUpstream                                      vtkCompositeDataPipeline.cxx         733 0x7ffff0676e95 
20  vtkDemandDrivenPipeline::ProcessRequest                                        vtkDemandDrivenPipeline.cxx          247 0x7ffff067fe6d 
... <plus>                                                                                                                                 

I see, i need to explore it then.

The second issue can not be resolved, because a vtkStringArray can not be mapped to a numpy array which is used by the python selector which is used by the Find Data Panel. But i will make it not crash.

The first issue seems to have been introduced on 5.11. I checked 5.10 and 5.9 and it was working just fine. I will explore what happened.

The categorical colors issue is fixed by https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9936

1 Like

Thank you very much for adressing the issue. It is now possible to color the model based on those categorical strings, however there still seems to be an issue related to the original problem, because it is not possible to select cells based on these string values (e.g. to hide certain named regions from view).

For example, given a cell with the property name of “Slot : slot1”, when I want to extract those zones where the values is targetvalue (also a string), the following error occurs:

Error: Failed to evaluate Expression ‘(Slotslot1== targetvalue)’. The following exception stack should provide additional developer specific information. This typically implies a malformed expression. Verify that the expression is valid.

When I put targetvalue in quotation marks, the following occurs:

RuntimeError: Expression ‘(Slotslot1== “targetvalue”)’ did not produce a valid mask array.

In both cases the string property seems to be trimmed somehow.
Please let me know if I should flag this as a separate issue.

@wtfermi Can you share a test case? It seems to work on my end but our test workflow might be different.

Here is a test grid with one zone.
test.vtu (2.2 KB)
and here is an image of the error and “find data” settings I tried:

Thanks a lot for looking into it. :slight_smile:

As i said before the second issue originates from the fact that a vtkStringArray can not be mapped to a numpy array which is used by the python selector, which is then used by the Find Data Panel. This mapping can not be performed (as of now) because a vtkStringArray is a special array where the memory size of each value is dynamic.

@cory.quammen do you think that anybody would be interested in supporting such functionality?

@cory.quammen If you think this is important, please give me a paragraph explaining the problem, and why it would impact my users. If so and if it is important, I will fund a fix.

@wascott The problem is that people can not search cell or points based on an array that has string values. E.g. if can.ex2 had a point array named names and each point had a name, you can not use the find data panel to extract all the points that have their names value is red

Got it. Please write it up, add priority and schedule that you think is appropriate, and add the Sandia project to it.

https://gitlab.kitware.com/paraview/paraview/-/issues/21775