Skip to content

Commit

Permalink
fix: parsing components when too many (#3662)
Browse files Browse the repository at this point in the history
* fix: parsing components when too many

* chore: adding changelog file 3662.fixed.md [dependabot-skip]

---------

Co-authored-by: pyansys-ci-bot <[email protected]>
  • Loading branch information
germa89 and pyansys-ci-bot authored Jan 17, 2025
1 parent b76a176 commit 0f1e0ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/3662.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: parsing components when too many
4 changes: 2 additions & 2 deletions src/ansys/mapdl/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,13 @@ def _parse_cmlist(cmlist: Optional[str] = None) -> Dict[str, Any]:
# header
# "NAME TYPE SUBCOMPONENTS"
blocks = re.findall(
r"(?s)NAME\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\Z)",
r"(?s)NAME\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\*\*\*\*\*|\Z)",
cmlist,
flags=re.DOTALL,
)
elif re.search(r"NAME\s+SELE\s+TYPE\s+SUBCOMPONENTS", cmlist):
blocks = re.findall(
r"(?s)NAME\s+SELE\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\Z)",
r"(?s)NAME\s+SELE\s+TYPE\s+SUBCOMPONENTS\s+(.*?)\s*(?=\n\s*\n|\*\*\*\*\*|\Z)",
cmlist,
flags=re.DOTALL,
)
Expand Down
18 changes: 18 additions & 0 deletions tests/test_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,21 @@ def test__get_all_components_type(mapdl, cube_geom_and_mesh):
assert comp_nodes == expected_output
assert "CMELEM" not in comp_nodes
assert "CMELEM2" not in comp_nodes


def test_parsing_too_many_components(mapdl, cleared):
mapdl.prep7()

for i in range(1, 100):
mapdl.nsel("NONE")
mapdl.n(i, i, 0, 0)
mapdl.cm(f"node_{i:03.0f}", "NODE")

s = mapdl.components.__str__()
assert len(mapdl.components._comp) == 99

assert "VERIFICATION" not in s
assert "***" not in s
assert "*****MAPDL" not in s
for i in range(1, 100):
assert re.search(f"NODE_{i:03.0f}\s+: NODE", s)

0 comments on commit 0f1e0ec

Please sign in to comment.