# Potential bug in vtkDataAssembly?

**URL:** https://discourse.vtk.org/t/potential-bug-in-vtkdataassembly/7216
**Category:** Support
**Created:** [November 18, 2021, 9:50pm UTC](https://discourse.vtk.org/t/potential-bug-in-vtkdataassembly/7216 "2021-11-18T21:50:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [November 18, 2021, 9:50pm UTC](https://discourse.vtk.org/t/potential-bug-in-vtkdataassembly/7216/1 "2021-11-18T21:50:40Z")

</div>

I’m using Python 3.9 and vtk 9.1.0 on Windows.

vtkDataAssembly.SelectNodes() selects nodes in the vtkDataAssembly using a ‘/’ sperated path of the node names.

This method is supposed to return an empty vector/tuple if no nodes match the path,  
however I find that the method always returns the root node if the supplied path has a ‘/’ in it.

In the snippet below I create a data asssembly and then call SelectNodes using two different paths. Since the data assembly is empty, I expect both calls to return an empty tuple.

In fact the first call, using the path ‘test’ does return an empty tuple but the second one returns the index of the root node. Any path that includes a leading ‘/’ returns the root node.

Am I missing something, or is this a bug?

```auto
data_assembly = vtk.vtkDataAssembly()
print('test', data_assembly.SelectNodes('test'))
print('/test', data_assembly.SelectNodes('/test'))

```

Output :

```auto
test ()
/test (0,)

```

Thanks,

Doug

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [November 18, 2021, 9:58pm UTC](https://discourse.vtk.org/t/potential-bug-in-vtkdataassembly/7216/2 "2021-11-18T21:58:09Z")

</div>

If I use the GetFirstNodeByPath() method instead of SelectNodes() I get the behavior I expect, so I’m not blocked.

But I’m now more certain this is a bug…

```auto
data_assembly = vtk.vtkDataAssembly()
print('SelectNodes')
print('test', data_assembly.SelectNodes('test'))
print('/test', data_assembly.SelectNodes('/test'))
print('/', data_assembly.SelectNodes('/'))

print('\nGetFirstNodeByPath')
print('test', data_assembly.GetFirstNodeByPath('test'))
print('/test', data_assembly.GetFirstNodeByPath('/test'))
print('/', data_assembly.GetFirstNodeByPath('/'))

```

Output

```auto
SelectNodes
test ()
/test (0,)
/ (0,)

GetFirstNodeByPath
test -1
/test -1
/ 0

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [December 4, 2021, 4:15pm UTC](https://discourse.vtk.org/t/potential-bug-in-vtkdataassembly/7216/3 "2021-12-04T16:15:33Z")

</div>

@utkarshayachit ?

---

<div class="post-metadata">

### Author: ![untereiner](https://discourse.vtk.org/user_avatar/discourse.vtk.org/untereiner/32/7561_2.png) [@untereiner](https://discourse.vtk.org/u/untereiner)
#### Post date: [January 5, 2024, 10:43am UTC](https://discourse.vtk.org/t/potential-bug-in-vtkdataassembly/7216/4 "2024-01-05T10:43:50Z")

</div>

Hello everyone. I think this bug is still relevant (vtk 9.3.0)  
It seems that the XPath are not searched

```auto
print('SelectNodes')
print('/', data_assembly.SelectNodes('/'))
print('//test/subtest', data_assembly.SelectNodes('//test/subtest'))
print('//test/subtest/Element4', data_assembly.SelectNodes('//test/subtest/Element4'))

print('\nGetFirstNodeByPath')
print(' /', data_assembly.GetFirstNodeByPath('/'))
print('//test/subtest ', data_assembly.GetFirstNodeByPath('//test/subtest'))
print('//test/subtest/Element4 ', data_assembly.GetFirstNodeByPath('//test/subtest/Element4'))

```

That prints out:

```auto
SelectNodes
/ (0,)
//test/subtest (0,)
//test/subtest/Element4 (0,)

GetFirstNodeByPath
/ 0
//test/subtest 2
//test/subtest/Element4 7

```

---

<div class="post-metadata">

### Author: ![untereiner](https://discourse.vtk.org/user_avatar/discourse.vtk.org/untereiner/32/7561_2.png) [@untereiner](https://discourse.vtk.org/u/untereiner)
#### Post date: [January 11, 2024, 4:00pm UTC](https://discourse.vtk.org/t/potential-bug-in-vtkdataassembly/7216/5 "2024-01-11T16:00:32Z")

</div>

@Charles_Gueunet Could you point me someone able to take a look ?

---

<div class="post-metadata">

### Author: ![Charles\_Gueunet](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charles_gueunet/32/239_2.png) [@Charles\_Gueunet](https://discourse.vtk.org/u/Charles_Gueunet)
#### Post date: [January 18, 2024, 8:38am UTC](https://discourse.vtk.org/t/potential-bug-in-vtkdataassembly/7216/6 "2024-01-18T08:38:23Z")

</div>

Hello @untereiner ,

The person who designed those classes intially is @utkarshayachit . He does not works at Kitware anymore so I am not sure he will be able to get the time to dive on this unfortunately
