Skip to content

Commit 90b2cbf

Browse files
pyansys-ci-botChaiF1pre-commit-ci[bot]clatapiegerma89
committed
fix(migrated PR 4207): issue 4206 (#4279)
* Initial fix in interp_star_status function * Removed junk lines and fixed a typo * ci: auto fixes from pre-commit.com hooks. for more information, see https://pre-commit.ci * chore: adding changelog file 4279.fixed.md [dependabot-skip] * chore: adding changelog file 4279.fixed.md [dependabot-skip] * style: add type annotations to parameter parsing helpers in parameters.py Add explicit type hints for math_header, array_header, is_parameter_listing, is_math_listing, is_array_listing, and interp_star_status to improve clarity and support static analysis. * test: add tests for C_FullFile parameter handling in interp_star_status Add golden "c_fullfile status" sample and multiple tests to verify interp_star_status correctly parses C_FullFile entries. Cover mixed SMAT/C_FullFile outputs, single C_FullFile outputs, and various C_FullFile-like names; ensure only the "type" field is present for C_FullFile parameters and other fields (value, MemoryMB, workspace, shape) are not included. Also include the c_fullfile case in the parameterized status test. --------- Co-authored-by: Chai Fillerup <[email protected]> Co-authored-by: ChaiF1 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Camille Latapie <[email protected]> Co-authored-by: German <[email protected]>
1 parent d21050e commit 90b2cbf

File tree

3 files changed

+109
-6
lines changed

3 files changed

+109
-6
lines changed

doc/changelog.d/4279.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Issue 4206

src/ansys/mapdl/core/parameters.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -722,27 +722,27 @@ def parameter_header(line):
722722
return "NAME" in line and "VALUE" in line and "TYPE" in line
723723

724724

725-
def math_header(line):
725+
def math_header(line: str) -> bool:
726726
return "Name" in line and "Type" in line and "Dims" in line and "Workspace" in line
727727

728728

729-
def array_header(line):
729+
def array_header(line: str) -> bool:
730730
return "LOCATION" in line and "VALUE" in line
731731

732732

733-
def is_parameter_listing(status):
733+
def is_parameter_listing(status: str) -> bool:
734734
return any([parameter_header(each) for each in status.splitlines()])
735735

736736

737-
def is_math_listing(status):
737+
def is_math_listing(status: str) -> bool:
738738
return any([math_header(each) for each in status.splitlines()])
739739

740740

741-
def is_array_listing(status):
741+
def is_array_listing(status: str) -> bool:
742742
return any([array_header(each) for each in status.splitlines()])
743743

744744

745-
def interp_star_status(status):
745+
def interp_star_status(status: str) -> dict[str, str]:
746746
"""Interprets \\*STATUS command output from MAPDL
747747
748748
Parameters
@@ -853,6 +853,8 @@ def interp_star_status(status):
853853
"type": items[1],
854854
"workspace": int(items[4]),
855855
}
856+
elif items[1] in ["C_FullFile"]:
857+
parameters[name] = {"type": items[1]}
856858
else:
857859
shape = (int(items[2]), int(items[3]), int(items[4]))
858860
parameters[name] = {"type": items[1], "shape": shape}

tests/test_parameters.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@
104104
PGFZJK_ROWDIM 20.0000000 SCALAR
105105
PORT 50054.0000 SCALAR
106106
STRARRAY STRING ARRAY 96 1 1""",
107+
"c_fullfile status": """APDLMATH PARAMETER STATUS- ( 3 PARAMETERS DEFINED)
108+
109+
Name Type Mem. (MB) Dims Workspace
110+
111+
K SMAT 4.720 [19764:19764] 1
112+
M SMAT 2.728 [19764:19764] 1
113+
file.full C_FullFile -- -- --""",
107114
}
108115

109116

@@ -355,6 +362,7 @@ def test_parameter_delete_raise(mapdl, cleared):
355362
),
356363
("string array status", ["aqzzzxcv zx zxcv zxcv", "qwer wer qwer", "zxcv"]),
357364
("general status", None),
365+
("c_fullfile status", None),
358366
],
359367
)
360368
def test_interp_star_status(status_key, check):
@@ -364,8 +372,15 @@ def test_interp_star_status(status_key, check):
364372
name = list(output.keys())[0]
365373
if name == "MYARR" or name == "ASDF":
366374
assert np.all(output[name]["value"] == check)
375+
elif name == "file.full":
376+
assert output[name]["type"] == "C_FullFile"
377+
assert "value" not in output[name]
367378
else:
368379
assert output[name]["value"] == check
380+
elif status_key == "c_fullfile status":
381+
assert "file.full" in output
382+
assert output["file.full"]["type"] == "C_FullFile"
383+
assert "value" not in output["file.full"]
369384
else:
370385
assert "MYARR" in output
371386
assert "PGFZJK_COLDIM" in output
@@ -534,6 +549,91 @@ def test_parameter_types(mapdl, cleared, parameter):
534549
assert isinstance(mapdl.parameters["temp_arr"], type(parameter))
535550

536551

552+
def test_c_fullfile_parameter_handling_mixed():
553+
"""Test handling of C_FullFile parameter type in interp_star_status function.
554+
555+
This test covers issue #4206 where imported matrix/vector files from .full files
556+
are reported as C_FullFile parameters and need special handling.
557+
"""
558+
# Test status output representing a mix of SMAT and C_FullFile parameters
559+
status_mixed = """APDLMATH PARAMETER STATUS- ( 3 PARAMETERS DEFINED)
560+
561+
Name Type Mem. (MB) Dims Workspace
562+
563+
K SMAT 4.720 [19764:19764] 1
564+
M SMAT 2.728 [19764:19764] 1
565+
file.full C_FullFile -- -- --"""
566+
567+
# Test mixed status
568+
output_mixed = interp_star_status(status_mixed)
569+
570+
# Should have all 3 parameters
571+
assert len(output_mixed) == 3
572+
573+
# Check SMAT parameters
574+
assert "K" in output_mixed
575+
assert output_mixed["K"]["type"] == "SMAT"
576+
assert output_mixed["K"]["MemoryMB"] == 4.720
577+
assert output_mixed["K"]["workspace"] == 1
578+
579+
assert "M" in output_mixed
580+
assert output_mixed["M"]["type"] == "SMAT"
581+
assert output_mixed["M"]["MemoryMB"] == 2.728
582+
assert output_mixed["M"]["workspace"] == 1
583+
584+
# Check C_FullFile parameter - should only have type, no other fields
585+
assert "file.full" in output_mixed
586+
assert output_mixed["file.full"]["type"] == "C_FullFile"
587+
assert "MemoryMB" not in output_mixed["file.full"]
588+
assert "workspace" not in output_mixed["file.full"]
589+
assert "value" not in output_mixed["file.full"]
590+
assert "shape" not in output_mixed["file.full"]
591+
592+
593+
def test_c_fullfile_parameter_handling_single():
594+
# Test single C_FullFile status
595+
596+
# Test status output with only C_FullFile parameter
597+
status_single = """APDLMATH PARAMETER STATUS- ( 1 PARAMETERS DEFINED)
598+
599+
Name Type Mem. (MB) Dims Workspace
600+
601+
myfile.full C_FullFile -- -- --"""
602+
603+
output_single = interp_star_status(status_single)
604+
605+
assert len(output_single) == 1
606+
assert "myfile.full" in output_single
607+
assert output_single["myfile.full"]["type"] == "C_FullFile"
608+
assert len(output_single["myfile.full"]) == 1 # Only 'type' field should be present
609+
610+
611+
@pytest.mark.parametrize(
612+
"param_name,param_type",
613+
[
614+
("matrix.full", "C_FullFile"),
615+
("stiffness.full", "C_FullFile"),
616+
("mass.full", "C_FullFile"),
617+
("mydata.full", "C_FullFile"),
618+
],
619+
)
620+
def test_c_fullfile_parameter_types(param_name, param_type):
621+
"""Test various C_FullFile parameter names and ensure proper handling."""
622+
status = f"""APDLMATH PARAMETER STATUS- ( 1 PARAMETERS DEFINED)
623+
624+
Name Type Mem. (MB) Dims Workspace
625+
626+
{param_name:<20} {param_type:<15} -- -- --"""
627+
628+
output = interp_star_status(status)
629+
630+
assert len(output) == 1
631+
assert param_name in output
632+
assert output[param_name]["type"] == param_type
633+
# Ensure no other fields are present for C_FullFile parameters
634+
assert len(output[param_name]) == 1
635+
636+
537637
@pytest.mark.parametrize("use_load_table", [True, False])
538638
def test_table_interpolation(mapdl, use_load_table):
539639
file_name = "table.txt"

0 commit comments

Comments
 (0)