Skip to content

Commit 4cde775

Browse files
fix: filter non-numeric values when parsing item list (#4257)
* fix: filter non-numeric values when parsing item list * chore: adding changelog file 4257.fixed.md [dependabot-skip] * test: add test for creating a large component with many nodes * test: replace unnecessary f-string with plain string in test_big_component --------- Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent a726314 commit 4cde775

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

doc/changelog.d/4257.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Filter non-numeric values when parsing item list

src/ansys/mapdl/core/component.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
from ansys.mapdl.core import Mapdl
4545
from ansys.mapdl.core.errors import ComponentDoesNotExits, ComponentIsNotSelected
46+
from ansys.mapdl.core.misc import is_float
4647

4748
if TYPE_CHECKING: # pragma: no cover
4849
import logging
@@ -577,7 +578,7 @@ def _parse_cmlist_indiv(
577578

578579
# Joining them together and giving them format.
579580
items = items.replace("\n", " ").split()
580-
items = [int(each) for each in items]
581+
items = [int(each) for each in items if is_float(each)]
581582

582583
return items
583584

tests/test_component.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,19 @@ def test_dunder_methods_len(mapdl, basic_components):
392392
mapdl.nsel("s", vmin=1)
393393
mapdl.cm("asdf", "node")
394394
assert len(mapdl.components) == 4
395+
396+
397+
def test_big_component(mapdl, cleared):
398+
mapdl.prep7()
399+
400+
for i in range(1000):
401+
mapdl.n(i, i, 0, 0)
402+
403+
mapdl.allsel()
404+
mapdl.cm("many_nodes", "NODE")
405+
406+
print(mapdl.mesh) # This will trigger COMP parsing
407+
408+
assert "MANY_NODES" in str(mapdl.components)
409+
assert len(mapdl.components["many_nodes"]) == 999
410+
assert all(isinstance(item, int) for item in mapdl.components["many_nodes"])

0 commit comments

Comments
 (0)