docs: clarify preserve_order descriptions and fix comma typo in string utils#6016
docs: clarify preserve_order descriptions and fix comma typo in string utils#6016Ottohere-Mourn wants to merge 2 commits into
Conversation
…g utils Fixes isaac-sim#4493 The preserve_order parameter descriptions in resolve_matching_names and resolve_matching_names_values were technically correct but the wording "the ordering is the same as the order of" could be misread. Clarified that False returns results in target string iteration order and True reorders them to follow query key order. Also removed a redundant "the matched strings," phrase in the second function's example text. Signed-off-by: Ottohere-Mourn <3311436628@qq.com>
There was a problem hiding this comment.
📝 Review Summary
Verdict: Minor suggestion — the docstring clarifications for preserve_order are a clear improvement. One small note below about the example description in resolve_matching_names_values.
Overall: The rewording from "the ordering is the same as the order of" to explicit "returned in iteration order" / "reordered to follow the order of" is much clearer and easier to parse. Good fix for #4493.
| For example, consider the dictionary is {"a|d|e": 1, "b|c": 2}, the list of strings is ['a', 'b', 'c', 'd', 'e']. | ||
| If :attr:`preserve_order` is False, then the function will return the indices of the matched strings, the | ||
| matched strings, and the values as: ([0, 1, 2, 3, 4], ['a', 'b', 'c', 'd', 'e'], [1, 2, 2, 1, 1]). When | ||
| If :attr:`preserve_order` is False, then the function will return the indices of the matched strings and the values as: ([0, 1, 2, 3, 4], ['a', 'b', 'c', 'd', 'e'], [1, 2, 2, 1, 1]). When |
There was a problem hiding this comment.
Nitpick (non-blocking): This line removes the mention of "the matched strings" (the second return element) from the example description — the original read: "the indices of the matched strings, the matched strings, and the values as".
The 3-tuple in the example still clearly shows all three return elements (indices, names, values), so it's understandable in context, but mentioning all three keeps the text perfectly aligned with the return structure.
Also, this single line is now quite long (~160 chars). Consider wrapping it for readability:
| If :attr:`preserve_order` is False, then the function will return the indices of the matched strings and the values as: ([0, 1, 2, 3, 4], ['a', 'b', 'c', 'd', 'e'], [1, 2, 2, 1, 1]). When | |
| If :attr:`preserve_order` is False, then the function will return the indices of the matched strings, | |
| the matched strings, and the values as: ([0, 1, 2, 3, 4], ['a', 'b', 'c', 'd', 'e'], [1, 2, 2, 1, 1]). When |
This restores the description of all three return elements and keeps the line length reasonable.
Greptile SummaryThis PR rewrites the
Confidence Score: 3/5The preserve_order clarifications are an improvement, but the sentence edit in resolve_matching_names_values introduces a prose/example mismatch that leaves the docstring self-contradictory. The updated sentence omits the middle return value (names) while the example tuple immediately below still shows all three — indices, names, and values — making the documentation actively misleading. source/isaaclab/isaaclab/utils/string.py line 293, where the example sentence now conflicts with the example tuple. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Input: keys / data dict + list_of_strings] --> B[Loop: match each target string against each regex key]
B --> C{Match found?}
C -- Yes --> D[Append to index_list, names_list, key_idx_list]
C -- No --> B
D --> E{preserve_order?}
E -- False --> F[Return in target-string iteration order]
E -- True --> G[Reorder by regex-key order]
G --> F
F --> H[Return tuple: indices, names, values]
Reviews (1): Last reviewed commit: "docs: clarify preserve_order description..." | Re-trigger Greptile |
| For example, consider the dictionary is {"a|d|e": 1, "b|c": 2}, the list of strings is ['a', 'b', 'c', 'd', 'e']. | ||
| If :attr:`preserve_order` is False, then the function will return the indices of the matched strings, the | ||
| matched strings, and the values as: ([0, 1, 2, 3, 4], ['a', 'b', 'c', 'd', 'e'], [1, 2, 2, 1, 1]). When | ||
| If :attr:`preserve_order` is False, then the function will return the indices of the matched strings and the values as: ([0, 1, 2, 3, 4], ['a', 'b', 'c', 'd', 'e'], [1, 2, 2, 1, 1]). When |
There was a problem hiding this comment.
The edit intended to remove a redundant phrase but accidentally dropped the second return value from the prose description. The sentence now says the function returns "the indices … and the values," but the return type is a three-tuple
(indices, names, values) — names (['a', 'b', 'c', 'd', 'e'] in the example) is silently omitted. Readers will see a mismatch between the prose (two things) and the immediately following example tuple (three things).
| If :attr:`preserve_order` is False, then the function will return the indices of the matched strings and the values as: ([0, 1, 2, 3, 4], ['a', 'b', 'c', 'd', 'e'], [1, 2, 2, 1, 1]). When | |
| If :attr:`preserve_order` is False, then the function will return the indices of the matched strings, the matched names, and the values as: ([0, 1, 2, 3, 4], ['a', 'b', 'c', 'd', 'e'], [1, 2, 2, 1, 1]). When |
…ues docstring The edited sentence dropped "the matched strings" when consolidating the example text, making the prose describe only two return values (indices, values) while the example tuple shows three (indices, names, values). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
preserve_orderparameter descriptions inresolve_matching_namesandresolve_matching_names_valuesFixes #4493
Test Plan
🤖 Generated with Claude Code