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

**URL:** https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155
**Category:** ParaView Support
**Tags:** vtk
**Created:** [January 12, 2023, 9:08am UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155 "2023-01-12T09:08:25Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![wtfermi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/ec9cab/32.png) [@wtfermi](https://discourse.paraview.org/u/wtfermi)
#### Post date: [January 12, 2023, 9:08am UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/1 "2023-01-12T09:08:25Z")

</div>

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.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/3/38fb1acf886a89015033f73bc3eff875630bddf4.png)

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:

```auto
  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](https://discourse.paraview.org/uploads/short-url/xPnKnYmDNQw1rIpNW81iTKtmfuP.vtu) (2.1 KB)

Thanks! 🙂

---

<div class="post-metadata">

### Author: ![Francois\_Mazen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/francois_mazen/32/6483_2.png) [@Francois\_Mazen](https://discourse.paraview.org/u/Francois_Mazen)
#### Post date: [January 12, 2023, 3:00pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/2 "2023-01-12T15:00:44Z")

</div>

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](https://gitlab.kitware.com/paraview/paraview/-/issues)

Best,

François

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.paraview.org/user_avatar/discourse.paraview.org/spyridon97/32/11569_2.png) [@spyridon97](https://discourse.paraview.org/u/spyridon97)
#### Post date: [January 12, 2023, 3:11pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/3 "2023-01-12T15:11:10Z")

</div>

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

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

---

<div class="post-metadata">

### Author: ![Francois\_Mazen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/francois_mazen/32/6483_2.png) [@Francois\_Mazen](https://discourse.paraview.org/u/Francois_Mazen)
#### Post date: [January 12, 2023, 3:41pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/4 "2023-01-12T15:41:07Z")

</div>

> [@spyridon97](#):
>
> why do you think that the selection editor is relevant to 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):

```auto
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>                                                                                                                                 

```

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.paraview.org/user_avatar/discourse.paraview.org/spyridon97/32/11569_2.png) [@spyridon97](https://discourse.paraview.org/u/spyridon97)
#### Post date: [January 13, 2023, 6:22pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/5 "2023-01-13T18:22:51Z")

</div>

I see, i need to explore it then.

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.paraview.org/user_avatar/discourse.paraview.org/spyridon97/32/11569_2.png) [@spyridon97](https://discourse.paraview.org/u/spyridon97)
#### Post date: [January 16, 2023, 7:29pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/6 "2023-01-16T19:29:31Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.paraview.org/user_avatar/discourse.paraview.org/spyridon97/32/11569_2.png) [@spyridon97](https://discourse.paraview.org/u/spyridon97)
#### Post date: [January 16, 2023, 7:43pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/7 "2023-01-16T19:43:39Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Sankhesh\_Jhaveri](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sankhesh_jhaveri/32/3374_2.png) [@Sankhesh\_Jhaveri](https://discourse.paraview.org/u/Sankhesh_Jhaveri)
#### Post date: [February 8, 2023, 5:55pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/8 "2023-02-08T17:55:07Z")

</div>

The categorical colors issue is fixed by [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/9936](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9936)

---

<div class="post-metadata">

### Author: ![wtfermi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/ec9cab/32.png) [@wtfermi](https://discourse.paraview.org/u/wtfermi)
#### Post date: [February 16, 2023, 12:33pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/9 "2023-02-16T12:33:12Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Sankhesh\_Jhaveri](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sankhesh_jhaveri/32/3374_2.png) [@Sankhesh\_Jhaveri](https://discourse.paraview.org/u/Sankhesh_Jhaveri)
#### Post date: [February 16, 2023, 3:10pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/10 "2023-02-16T15:10:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![wtfermi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/ec9cab/32.png) [@wtfermi](https://discourse.paraview.org/u/wtfermi)
#### Post date: [February 16, 2023, 3:20pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/11 "2023-02-16T15:20:40Z")

</div>

Here is a test grid with one zone.  
[test.vtu](https://discourse.paraview.org/uploads/short-url/pPLnnf4vI9132mM8KUC8ZLtIRuS.vtu) (2.2 KB)  
and here is an image of the error and “find data” settings I tried:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/9/9906007fa9db9cd2a51eb440cab5f4565e368867.png)

Thanks a lot for looking into it. 🙂

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.paraview.org/user_avatar/discourse.paraview.org/spyridon97/32/11569_2.png) [@spyridon97](https://discourse.paraview.org/u/spyridon97)
#### Post date: [February 16, 2023, 4:23pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/12 "2023-02-16T16:23:45Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [February 16, 2023, 7:51pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/13 "2023-02-16T19:51:30Z")

</div>

@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.

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.paraview.org/user_avatar/discourse.paraview.org/spyridon97/32/11569_2.png) [@spyridon97](https://discourse.paraview.org/u/spyridon97)
#### Post date: [February 16, 2023, 8:01pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/14 "2023-02-16T20:01:41Z")

</div>

@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`

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [February 16, 2023, 8:03pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/15 "2023-02-16T20:03:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.paraview.org/user_avatar/discourse.paraview.org/spyridon97/32/11569_2.png) [@spyridon97](https://discourse.paraview.org/u/spyridon97)
#### Post date: [February 16, 2023, 8:53pm UTC](https://discourse.paraview.org/t/interpret-values-as-categories-not-working-for-string-properties-pv-5-11-0-rc2/11155/16 "2023-02-16T20:53:54Z")

</div>

[https://gitlab.kitware.com/paraview/paraview/-/issues/21775](https://gitlab.kitware.com/paraview/paraview/-/issues/21775)
