Skip to content

Commit 0f1e0ec

Browse files
fix: parsing components when too many (#3662)
* fix: parsing components when too many * chore: adding changelog file 3662.fixed.md [dependabot-skip] --------- Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent b76a176 commit 0f1e0ec

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

doc/changelog.d/3662.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix: parsing components when too many

src/ansys/mapdl/core/component.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,13 @@ def _parse_cmlist(cmlist: Optional[str] = None) -> Dict[str, Any]:
580580
# header
581581
# "NAME TYPE SUBCOMPONENTS"
582582
blocks = re.findall(
583-
r"(?s)NAME\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\Z)",
583+
r"(?s)NAME\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\*\*\*\*\*|\Z)",
584584
cmlist,
585585
flags=re.DOTALL,
586586
)
587587
elif re.search(r"NAME\s+SELE\s+TYPE\s+SUBCOMPONENTS", cmlist):
588588
blocks = re.findall(
589-
r"(?s)NAME\s+SELE\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\Z)",
589+
r"(?s)NAME\s+SELE\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\*\*\*\*\*|\Z)",
590590
cmlist,
591591
flags=re.DOTALL,
592592
)

tests/test_component.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,21 @@ def test__get_all_components_type(mapdl, cube_geom_and_mesh):
327327
assert comp_nodes == expected_output
328328
assert "CMELEM" not in comp_nodes
329329
assert "CMELEM2" not in comp_nodes
330+
331+
332+
def test_parsing_too_many_components(mapdl, cleared):
333+
mapdl.prep7()
334+
335+
for i in range(1, 100):
336+
mapdl.nsel("NONE")
337+
mapdl.n(i, i, 0, 0)
338+
mapdl.cm(f"node_{i:03.0f}", "NODE")
339+
340+
s = mapdl.components.__str__()
341+
assert len(mapdl.components._comp) == 99
342+
343+
assert "VERIFICATION" not in s
344+
assert "***" not in s
345+
assert "*****MAPDL" not in s
346+
for i in range(1, 100):
347+
assert re.search(f"NODE_{i:03.0f}\s+: NODE", s)

0 commit comments

Comments
 (0)