Repository navigation
fix: select the newest file in last_created - #4932
Closed
Tonylo-lab wants to merge 1 commit into
Closed
Tonylo-lab wants to merge 1 commit into
Tonylo-lab wants to merge 1 commit into
Conversation
germa89
approved these changes
Nov 18, 2026
germa89
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Thank you @Tonylo-lab !
| if len(set(ctimes)) == 1: | ||
| return filenames[-1] | ||
|
|
||
| return filenames[idx] |
Collaborator
There was a problem hiding this comment.
It probably makes more sense to get the idx after checking the length.
ctimes = [creation_time(filename) for filename in filenames]
if len(set(ctimes)) == 1:
return filenames[-1]
idx = np.argmax(ctimes)
return filenames[idx]
Collaborator
|
@pyansys-ci-bot migrate |
Contributor
🚀 Migration completed!The pull request #4967 has been created successfully. Thank you @Tonylo-lab for your contribution! Please review the new PR and make any necessary changes. This PR will be closed by the admins soon. You can now start to work in the new pull request by cloning this pull request branch in a new repository by doing: If you have GitHub CLI installed, you can also use the following command to check out the pull request: Thank you again for your contribution @Tonylo-lab! |
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
last_created()currently returns the last filename for every nonempty input, regardless of creation times.len(set(ctimes))is always nonzero for such inputs, so the already-computednp.argmaxresult is never used.Change this condition to
len(set(ctimes)) == 1. This selects the newest file when times differ while preserving the documented rule of returning the last filename when all creation times are equal.Add 10 parameterized/edge cases in
tests/test_misc.py: all six orders of three files with distinct times, three equal-time/single-file cases, and the existing empty-input error behavior.Issue linked
This addresses a locally reproduced defect on
mainat154828f; no new issue was opened. The helper is used by result-file selection, includingMapdlGrpc._distributed_result_file. With a newerfile0.rthand an olderfile0.rst, that getter currently chooses the older.rstfile.Validation
Tested on Windows, Python 3.12.15, PyMAPDL 0.74.dev0, pytest 9.1.1 and NumPy 2.5.4.
tests/test_misc.pygives 4 failed / 7 passed before the fix and 11 passed after it (40 unrelated cases deselected). This includes the existing real-file creation-time test._distributed_result_filegetter with a minimal local context and real files: it selects the older.rstbefore the fix and the newer.rthafterward. These are synthetic files, with no MAPDL connection or solver-generated contents.last_created()has 100% line and branch coverage (5 statements and 2 branches).git diff --checkpasses, and the final patch matches the reviewed draft exactly.Known baseline check failure: full
pre-commit run --all-filesstops atsrc/ansys/mapdl/core/errors.py:601:Module has no attribute "SIGKILL". Windows does not providesignal.SIGKILL. The same single error reproduces on unmodified154828f(325 source files checked); it is tracked separately in #4903 / #4904. This PR does not change that code.Not run: MAPDL live-server/solver tests or the full test suite. No MAPDL process was launched.
Checklist
Prepared and verified with assistance from Codex.