|
38 | 38 |
|
39 | 39 | from ansys.mapdl.core.errors import MapdlRuntimeError |
40 | 40 | from ansys.mapdl.core.mapdl import MapdlBase |
| 41 | +from ansys.mapdl.core.mapdl_core import MAX_PARAM_CHARS |
41 | 42 | from ansys.mapdl.core.misc import supress_logging |
42 | 43 |
|
43 | 44 | ROUTINE_MAP = { |
@@ -354,7 +355,7 @@ def __repr__(self): |
354 | 355 | value_str = str(info["value"]) |
355 | 356 | else: |
356 | 357 | continue |
357 | | - lines.append("%-32s : %s" % (key, value_str)) |
| 358 | + lines.append(f"%-{MAX_PARAM_CHARS}s : %s" % (key, value_str)) |
358 | 359 | return "\n".join(lines) |
359 | 360 |
|
360 | 361 | def __getitem__(self, key): |
@@ -493,22 +494,27 @@ def _set_parameter(self, name, value): |
493 | 494 | ---------- |
494 | 495 | name : str |
495 | 496 | An alphanumeric name used to identify this parameter. Name |
496 | | - may be up to 32 characters, beginning with a letter and |
497 | | - containing only letters, numbers, and underscores. |
| 497 | + may be up to 32 character or the value given in |
| 498 | + :attr:`ansys.mapdl.core.mapdl_core.MAX_PARAM_CHARS`, beginning with |
| 499 | + a letter and containing only letters, numbers, and underscores. |
498 | 500 | Examples: ``"ABC" "A3X" "TOP_END"``. |
499 | 501 |
|
500 | 502 | """ |
501 | | - if not isinstance(value, (str, int, float)): |
| 503 | + if not isinstance(value, (str, int, float, np.integer, np.floating)): |
502 | 504 | raise TypeError("``Parameter`` must be either a float, int, or string") |
503 | 505 |
|
504 | | - if isinstance(value, str) and len(value) >= 32: |
505 | | - raise ValueError("Length of ``value`` must be 32 characters or less") |
| 506 | + if isinstance(value, str) and len(value) > MAX_PARAM_CHARS: |
| 507 | + raise ValueError( |
| 508 | + f"Length of ``value`` must be {MAX_PARAM_CHARS} characters or less" |
| 509 | + ) |
506 | 510 |
|
507 | 511 | if not isinstance(name, str): |
508 | 512 | raise TypeError("``name`` must be a string") |
509 | 513 |
|
510 | | - if len(name) >= 32: |
511 | | - raise ValueError("Length of ``name`` must be 32 characters or less") |
| 514 | + if len(name) > MAX_PARAM_CHARS: |
| 515 | + raise ValueError( |
| 516 | + f"Length of ``name`` must be {MAX_PARAM_CHARS} characters or less" |
| 517 | + ) |
512 | 518 |
|
513 | 519 | # delete the parameter if it exists as an array |
514 | 520 | parm = self._parm |
@@ -830,8 +836,8 @@ def interp_star_status(status): |
830 | 836 | # line will contain either a character, scalar, or array |
831 | 837 | name = items[0] |
832 | 838 | if len(items) == 2 or "CHARACTER" in items[-1].upper(): |
833 | | - name = line[:32].strip() |
834 | | - value = line.replace(items[-1], "")[33:].strip() |
| 839 | + name = line[:MAX_PARAM_CHARS].strip() |
| 840 | + value = line.replace(items[-1], "")[(MAX_PARAM_CHARS + 1) :].strip() |
835 | 841 | parameters[name] = {"type": "CHARACTER", "value": value} |
836 | 842 |
|
837 | 843 | elif len(items) == 3: |
|
0 commit comments