Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parsing components when too many #3662

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading