Skip to content

Commit

Permalink
refactor: Iterate over the dictionary directly instead of using .keys…
Browse files Browse the repository at this point in the history
…(). (#3631)

* Iterate over the dictionay directly instead of using .keys().

* chore: adding changelog file 3631.added.md [dependabot-skip]

* chore: adding changelog file 3631.added.md [dependabot-skip]

* chore: update src/ansys/mapdl/core/pool.py

* ci: auto fixes from pre-commit.com hooks.

for more information, see https://pre-commit.ci

* ci: auto fixes from pre-commit.com hooks.

for more information, see https://pre-commit.ci

* chore: empty commit to trigger CICD

---------

Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
Co-authored-by: German <28149841+germa89@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 7, 2025
1 parent 38d51a1 commit 841313d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/3631.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
refactor: Iterate over the dictionary directly instead of using .keys().
4 changes: 2 additions & 2 deletions src/ansys/mapdl/core/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,8 @@ def bc_colnames(self) -> Optional[List[str]]:

title = self._get_body()[0]

_bcType = [i for i in bc_type.keys() if i in title]
_entity = [i for i in entity.keys() if i in title]
_bcType = [i for i in bc_type if i in title]
_entity = [i for i in entity if i in title]

if _bcType and _entity:

Expand Down
12 changes: 5 additions & 7 deletions src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2941,7 +2941,7 @@ def _mat_data(self, pname, raw=False):

@property
def locked(self):
"""Instance is in use within a pool"""
"""Instance is in use within a pool."""
return self._locked

@locked.setter
Expand Down Expand Up @@ -2987,7 +2987,7 @@ def _generate_iges(self):

@property
def _distributed_result_file(self):
"""Path of the distributed result file"""
"""Path of the distributed result file."""
if not self._distributed:
return

Expand Down Expand Up @@ -3022,7 +3022,7 @@ def _distributed_result_file(self):

@property
def thermal_result(self):
"""The thermal result object"""
"""The thermal result object."""
self._prioritize_thermal = True
result = self.result
self._prioritize_thermal = False
Expand All @@ -3045,7 +3045,7 @@ def list_error_file(self):
return open(os.path.join(self.directory, error_file)).read()
elif self._exited:
raise MapdlExitedError(
"Cannot list error file when MAPDL Service has " "exited"
"Cannot list error file when MAPDL Service has exited"
)

return self._download_as_raw(error_file).decode("latin-1")
Expand All @@ -3060,9 +3060,7 @@ def cmatrix(
capname="",
**kwargs,
):
"""Run CMATRIX in non-interactive mode and return the response
from file.
"""
"""Run CMATRIX in non-interactive mode and return the response from file."""

# The CMATRIX command needs to run in non-interactive mode
if not self._store_commands:
Expand Down
6 changes: 4 additions & 2 deletions src/ansys/mapdl/core/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,10 @@ def run():
try:
self._exiting_i += 1
instance.exit()
except Exception as e:
LOG.error("Failed to close instance", exc_info=True)
except Exception:
LOG.error(
f"Failed to close instance due to:\n{e}", exc_info=True
)
self._exiting_i -= 1

else:
Expand Down

0 comments on commit 841313d

Please sign in to comment.