Skip to content

test(consistent): replace Cartesian product with curated matrices for descriptor tests#5378

Open
njzjz-bot wants to merge 9 commits intodeepmodeling:masterfrom
njzjz-bothub:test/issue-5372-curated-consistent-matrix
Open

test(consistent): replace Cartesian product with curated matrices for descriptor tests#5378
njzjz-bot wants to merge 9 commits intodeepmodeling:masterfrom
njzjz-bothub:test/issue-5372-curated-consistent-matrix

Conversation

@njzjz-bot
Copy link
Copy Markdown
Contributor

@njzjz-bot njzjz-bot commented Apr 5, 2026

Problem

  • Several descriptor consistency suites use full Cartesian products over many feature toggles.
  • That creates large default PR-CI matrices whose cost is dominated by combinatorial expansion rather than a few isolated slow cases.
  • In this group alone, the main suite case counts go from 48 -> 7 for test_se_e2_a.py, 64 -> 9 for test_dpa1.py, and 512 -> 12 for test_dpa2.py.

Change

  • Add parameterized_cases(*cases) in source/tests/consistent/common.py for explicit curated matrices without changing existing parameterized(*attrs) semantics.
  • Replace Cartesian-product decorators with curated case lists in:
    • source/tests/consistent/descriptor/test_se_e2_a.py
    • source/tests/consistent/descriptor/test_dpa1.py
    • source/tests/consistent/descriptor/test_dpa2.py
  • Reuse the same curated matrices for descriptor API tests where applicable.
  • Keep existing skip logic unchanged; only the default generated case sets are reduced.

Validation

  • python -m pytest --collect-only source/tests/consistent/descriptor/test_se_e2_a.py source/tests/consistent/descriptor/test_dpa1.py source/tests/consistent/descriptor/test_dpa2.py
    • collected 488 tests after the reduction
  • python -m pytest source/tests/consistent/descriptor/test_se_e2_a.py source/tests/consistent/descriptor/test_dpa1.py source/tests/consistent/descriptor/test_dpa2.py -q
    • 91 passed, 397 skipped
  • python3 -m py_compile on the touched files

Related

Authored by OpenClaw (model: gpt-5.4)

Summary by CodeRabbit

  • New Features

    • Added a decorator to specify explicit test cases (no Cartesian-product expansion).
  • Tests

    • Refactored multiple test suites to use curated, explicit case sets for clearer, deterministic parametrization.
    • Added reusable case-construction helpers and baseline/curated case collections to simplify test definitions.
    • Improved deterministic test-class naming with robust sanitization and uniqueness handling.

… descriptor tests

Add an explicit parameterized_cases helper for heavy consistency suites and switch the descriptor DPA1, DPA2, and SeA tests to reviewable curated matrices.

This keeps the existing parameterized Cartesian-product helper unchanged while reducing the default PR CI matrix to baseline, OFAT, and selected interaction cases.

Authored by OpenClaw (model: gpt-5.4)
@github-actions github-actions bot added the Python label Apr 5, 2026
@dosubot dosubot bot added the enhancement label Apr 5, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 5, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a shared subclass generator _parameterized_with_cases and public parameterized_cases decorator, refactors parameterized to reuse it with sanitized deterministic subclass naming, and replaces Cartesian-product test parameterization with explicit curated case matrices in multiple descriptor test modules.

Changes

Cohort / File(s) Summary
Parametrization framework
source/tests/consistent/common.py
Added _parameterized_with_cases(full_parameterized), new public decorator parameterized_cases(*cases), refactored parameterized to delegate to the shared generator, improved deterministic subclass name sanitization/uniqueness, updated __all__ (removed duplicate "CommonTest", added parameterize_func, parameterized, parameterized_cases).
DPA1 tests (curated matrix)
source/tests/consistent/descriptor/test_dpa1.py
Replaced @parameterized(...) with @parameterized_cases(*DPA1_CURATED_CASES). Added DPA1_CASE_FIELDS, DPA1_BASELINE_CASE, helper dpa1_case(**overrides), and explicit DPA1_CURATED_CASES tuples; updated imports.
DPA2 tests (curated matrix + param order change)
source/tests/consistent/descriptor/test_dpa2.py
Replaced @parameterized(...) with @parameterized_cases(*DPA2_CURATED_CASES). Added DPA2_CASE_FIELDS, DPA2_BASELINE_CASE, helper dpa2_case(**overrides), and explicit DPA2_CURATED_CASES; adjusted self.param unpacking to match new field ordering.
SE A tests (curated matrices)
source/tests/consistent/descriptor/test_se_e2_a.py
Replaced @parameterized(...) with @parameterized_cases(*...). Added SE_A_CASE_FIELDS, SE_A_BASELINE_CASE, helper se_a_case(**overrides), and curated SE_A_CURATED_CASES, SE_A_DESCRIPTOR_API_CASES, SE_A_STAT_CASES; updated decorators and parameter unpacking.

Sequence Diagram(s)

sequenceDiagram
    participant Author as Test Author
    participant OldDec as "@parameterized"
    participant NewDec as "@parameterized_cases"
    participant Gen as _parameterized_with_cases
    participant Module as Test Module Namespace

    rect rgba(100,150,255,0.5)
    Note over OldDec,Module: Old flow (computed Cartesian product)
    Author->>OldDec: provide per-argument lists
    OldDec->>Gen: compute Cartesian product -> list of tuples
    Gen->>Gen: create subclass per tuple, set ClassVar param
    Gen->>Module: inject subclass with sanitized name
    end

    rect rgba(100,200,100,0.5)
    Note over NewDec,Module: New flow (explicit curated tuples)
    Author->>NewDec: provide explicit case tuples (*CURATED_CASES)
    NewDec->>Gen: forward provided tuples
    Gen->>Gen: create subclass per tuple, set ClassVar param
    Gen->>Module: inject subclass with sanitized name
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main objective: replacing Cartesian product test matrices with curated ones for descriptor tests.
Linked Issues check ✅ Passed All code changes directly implement issue #5372 requirements: new parameterized_cases decorator for explicit case definitions [#5372] and replacement of Cartesian products with curated matrices in three descriptor test files [#5372].
Out of Scope Changes check ✅ Passed All changes are within scope: the helper refactoring in common.py directly enables the case-list switching, and all test file modifications replace decorators with curated cases as specified in #5372.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
source/tests/consistent/common.py (1)

684-696: Move import re to module level.

The re module is imported inside the loop on every iteration, which is inefficient and violates standard Python import conventions. Move the import to the top of the file with other standard library imports.

♻️ Proposed fix

Add at the top of the file (around line 2):

import re

Then update the function:

             # generate a safe name for the class
             parts = []
             for x in pp:
                 s = str(x)
                 # replace non-alnum with underscore, collapse multiple underscores
-                import re
                 s = re.sub(r'[^a-zA-Z0-9_]', '_', s)
                 s = re.sub(r'_+', '_', s)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@source/tests/consistent/common.py` around lines 684 - 696, The loop in which
pp is processed imports re on every iteration; move the import to module level
(add a single "import re" with the other standard imports at the top of the
file) and remove the inline "import re" inside the loop; update the block that
builds parts (variables: pp, s, parts, name, base_class) to use the module-level
re for re.sub calls and leave the rest of the logic unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@source/tests/consistent/common.py`:
- Around line 684-696: The loop in which pp is processed imports re on every
iteration; move the import to module level (add a single "import re" with the
other standard imports at the top of the file) and remove the inline "import re"
inside the loop; update the block that builds parts (variables: pp, s, parts,
name, base_class) to use the module-level re for re.sub calls and leave the rest
of the logic unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: aef3ec2d-e1af-44aa-ae63-415d691fa1a3

📥 Commits

Reviewing files that changed from the base of the PR and between b02fd91 and 64b7a5a.

📒 Files selected for processing (4)
  • source/tests/consistent/common.py
  • source/tests/consistent/descriptor/test_dpa1.py
  • source/tests/consistent/descriptor/test_dpa2.py
  • source/tests/consistent/descriptor/test_se_e2_a.py

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.39%. Comparing base (b02fd91) to head (bd4178e).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5378      +/-   ##
==========================================
- Coverage   82.37%   80.39%   -1.98%     
==========================================
  Files         812      812              
  Lines       83560    83476      -84     
  Branches     4091     4050      -41     
==========================================
- Hits        68832    67113    -1719     
- Misses      13507    15139    +1632     
- Partials     1221     1224       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces CI cost in the descriptor consistency suites by replacing large Cartesian-product parameter grids with explicit curated test matrices, enabled by a new parameterized_cases decorator helper.

Changes:

  • Added parameterized_cases(*cases) to support explicit curated parameter tuples without changing existing parameterized(*attrs) behavior.
  • Replaced Cartesian-product parametrization with curated case lists in test_se_e2_a.py, test_dpa1.py, and test_dpa2.py.
  • Reused the curated matrices for corresponding descriptor API consistency tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
source/tests/consistent/common.py Adds parameterized_cases and refactors shared parametrization implementation into _parameterized_with_cases.
source/tests/consistent/descriptor/test_se_e2_a.py Introduces curated matrices for SE_A descriptor and API tests to avoid full Cartesian expansion.
source/tests/consistent/descriptor/test_dpa1.py Replaces Cartesian parametrization with curated DPA1 case tuples for both descriptor and API tests.
source/tests/consistent/descriptor/test_dpa2.py Replaces a very large Cartesian grid with curated DPA2 case tuples for both descriptor and API tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Match the curated DPA2 case tuples with the unpack order used by the descriptor tests so direct_dist and update_g1_has_conv map to the intended fields.

Also move the regex import used for parameterized test-class name sanitization to module scope.

Authored by OpenClaw (model: gpt-5.4)
@njzjz-bot
Copy link
Copy Markdown
Contributor Author

Thanks — both comments were valid, and I pushed a follow-up fix.

What changed:

  • aligned the DPA2 curated-case unpack order with the existing parameter order used by the descriptor tests, so repformer_direct_dist and repformer_update_g1_has_conv map to the intended fields
  • moved the regex import used for test-class name sanitization to module scope

Validation:

  • python3 -m py_compile source/tests/consistent/common.py source/tests/consistent/descriptor/test_dpa2.py
  • python -m pytest source/tests/consistent/descriptor/test_dpa2.py -q
    • 36 passed, 156 skipped

— OpenClaw 2026.3.8 (model: gpt-5.4)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
source/tests/consistent/descriptor/test_dpa2.py (2)

423-451: Optional: Extract param unpacking to reduce duplication.

This 27-variable unpacking pattern is repeated 9 times across the file. For properties that only need a subset (e.g., skip_pd only uses precision), the full unpacking adds noise. Consider extracting frequently-needed fields as cached properties or using a helper dataclass.

💡 Example: Extract precision as a property
`@property`
def _precision(self) -> str:
    """Extract precision from param tuple (position 23)."""
    return self.param[23]

Then simplify skip_pd:

 `@property`
 def skip_pd(self) -> bool:
-    (
-        repinit_tebd_input_mode,
-        ...  # 27 variables
-    ) = self.param
-    return not INSTALLED_PD or precision == "bfloat16"
+    return not INSTALLED_PD or self._precision == "bfloat16"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@source/tests/consistent/descriptor/test_dpa2.py` around lines 423 - 451, The
test file repeatedly unpacks a 27-element tuple from self.param (e.g., the large
unpack in the shown block) which is duplicated across many tests; extract
frequently-used fields into small cached properties (for example add properties
like _precision -> return self.param[23], _repformer_update_style -> return
self.param[12], etc.) or define a small dataclass mapping tuple positions to
named attributes and instantiate it once (e.g., self.params =
Params.from_tuple(self.param)); then replace the repeated full unpacking and
uses in methods like skip_pd and other helpers to reference these
properties/attributes (self._precision or self.params.precision) to reduce
duplication and improve readability. Ensure tests that relied on tuple order
still pass by mapping the same indices when creating the properties/dataclass.

67-96: Consider documenting the tuple field order for maintainability.

The curated cases use bare positional tuples with 27 elements each. Without inline documentation, maintainers must cross-reference the unpacking code (e.g., lines 423-451) to understand what each position represents. A comment header above the tuple would clarify the field ordering.

📝 Suggested documentation
+# DPA2_CURATED_CASES field order:
+# (repinit_tebd_input_mode, repinit_set_davg_zero, repinit_type_one_side,
+#  repinit_use_three_body, repformer_direct_dist, repformer_update_g1_has_conv,
+#  repformer_update_g1_has_drrd, repformer_update_g1_has_grrg, repformer_update_g1_has_attn,
+#  repformer_update_g2_has_g1g1, repformer_update_g2_has_attn, repformer_update_h2,
+#  repformer_attn2_has_gate, repformer_update_style, repformer_update_residual_init,
+#  repformer_set_davg_zero, repformer_trainable_ln, repformer_ln_eps,
+#  repformer_use_sqrt_nnei, repformer_g1_out_conv, repformer_g1_out_mlp,
+#  smooth, exclude_types, precision, add_tebd_to_repinit_out, use_econf_tebd, use_tebd_bias)
 DPA2_CURATED_CASES = (
     (
         "concat",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@source/tests/consistent/descriptor/test_dpa2.py` around lines 67 - 96, Add an
inline comment header above DPA2_CURATED_CASES that documents the field order
for the 27-tuple (e.g., list each index with the corresponding semantic name
used when the tuple is unpacked in the test — reference the unpacking variables
in the test at lines ~423-451) so future maintainers can read the mapping
without cross-referencing code; include each position number and its name/type
(e.g., 0: "mode"/"concat", 1: booleanFlagX, ... 26: booleanFlagY) and mention
expected types like "str", "bool", "float", "list" to make the tuple structure
explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@source/tests/consistent/descriptor/test_dpa2.py`:
- Around line 423-451: The test file repeatedly unpacks a 27-element tuple from
self.param (e.g., the large unpack in the shown block) which is duplicated
across many tests; extract frequently-used fields into small cached properties
(for example add properties like _precision -> return self.param[23],
_repformer_update_style -> return self.param[12], etc.) or define a small
dataclass mapping tuple positions to named attributes and instantiate it once
(e.g., self.params = Params.from_tuple(self.param)); then replace the repeated
full unpacking and uses in methods like skip_pd and other helpers to reference
these properties/attributes (self._precision or self.params.precision) to reduce
duplication and improve readability. Ensure tests that relied on tuple order
still pass by mapping the same indices when creating the properties/dataclass.
- Around line 67-96: Add an inline comment header above DPA2_CURATED_CASES that
documents the field order for the 27-tuple (e.g., list each index with the
corresponding semantic name used when the tuple is unpacked in the test —
reference the unpacking variables in the test at lines ~423-451) so future
maintainers can read the mapping without cross-referencing code; include each
position number and its name/type (e.g., 0: "mode"/"concat", 1: booleanFlagX,
... 26: booleanFlagY) and mention expected types like "str", "bool", "float",
"list" to make the tuple structure explicit.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b55ab950-4d03-4269-a5eb-85b4b608f888

📥 Commits

Reviewing files that changed from the base of the PR and between 64b7a5a and bc54f07.

📒 Files selected for processing (2)
  • source/tests/consistent/common.py
  • source/tests/consistent/descriptor/test_dpa2.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • source/tests/consistent/common.py

Run pre-commit on the PR branch and apply the resulting formatting-only
changes from isort and ruff-format.

Authored by OpenClaw (model: gpt-5.4)
Replace anonymous curated tuple lists in the heavy consistency descriptor
suites with named baseline dictionaries plus explicit override helpers.

This keeps the reduced-matrix strategy while making each curated case
reviewable and documenting the intended coverage. It also makes the DPA2
case ordering explicit so repformer_direct_dist and
repformer_update_g1_has_conv cannot be silently confused when editing
boolean-heavy cases.

Authored by OpenClaw (model: gpt-5.4)
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
source/tests/consistent/descriptor/test_se_e2_a.py (1)

14-23: ⚠️ Potential issue | 🔴 Critical

Keep importing parameterized here.

TestSeAStat still uses @parameterized(...) at Line 382, so removing that symbol makes this module fail during import before any tests are collected.

🛠️ Proposed fix
 from ..common import (
     INSTALLED_ARRAY_API_STRICT,
     INSTALLED_JAX,
     INSTALLED_PD,
     INSTALLED_PT,
     INSTALLED_PT_EXPT,
     INSTALLED_TF,
     CommonTest,
+    parameterized,
     parameterized_cases,
 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@source/tests/consistent/descriptor/test_se_e2_a.py` around lines 14 - 23, The
module removed the imported symbol parameterized but TestSeAStat still uses the
`@parameterized` decorator, causing import-time failure; restore parameterized in
the import list (alongside INSTALLED_ARRAY_API_STRICT, INSTALLED_JAX, etc.) so
that the TestSeAStat decorator resolves correctly during module import and tests
can be collected.
♻️ Duplicate comments (1)
source/tests/consistent/descriptor/test_dpa2.py (1)

67-161: ⚠️ Potential issue | 🟠 Major

Stop encoding DPA2 cases as anonymous 27-slot tuples.

This helper forces every consumer to destructure the full case just to read one field. In the current patch, skip_pt, skip_dp, skip_tf, and setUp do not use any of those locals, while skip_pd, rtol, and atol only need precision; Ruff is already flagging that as RUF059 at Lines 274, 307, 340, 373, 450, 556, and 595. Returning a keyed case object here would make the field-order fix local, remove the current lint failures, and make future boolean reorder mistakes much harder. As per coding guidelines **/*.py: Always run ruff check . and ruff format . before committing changes or CI will fail.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@source/tests/consistent/descriptor/test_dpa2.py` around lines 67 - 161, The
test currently encodes DPA2 cases as 27-slot tuples (DPA2_CASE_FIELDS,
DPA2_BASELINE_CASE, dpa2_case, DPA2_CURATED_CASES) which forces callers to
destructure and is causing RUF059 lint failures for unused tuple slots; change
dpa2_case to return a keyed mapping (e.g., a dict or lightweight dataclass)
instead of a tuple, keep DPA2_BASELINE_CASE as the canonical dict, update
DPA2_CURATED_CASES to call dpa2_case(...) and yield dicts, and update all
consumers to access fields by name (e.g., case["precision"] or case.precision)
rather than positional unpacking; after making these changes run ruff check .
and ruff format . to clear the lint errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@source/tests/consistent/common.py`:
- Around line 676-699: The generated test-class names in
_parameterized_with_cases can collide after sanitization and silently overwrite
earlier TestClass entries in class_module; update the decorator to detect name
collisions and avoid silent overwrites by either appending a stable unique
suffix (e.g., an incrementing counter or a hash derived from pp) to the computed
name or by raising a clear error when the target name already exists in
class_module; implement the check around the assignment to class_module[name] so
that TestClass instances are preserved and collisions are handled
deterministically (refer to symbols _parameterized_with_cases, TestClass,
class_module, name, and pp).

---

Outside diff comments:
In `@source/tests/consistent/descriptor/test_se_e2_a.py`:
- Around line 14-23: The module removed the imported symbol parameterized but
TestSeAStat still uses the `@parameterized` decorator, causing import-time
failure; restore parameterized in the import list (alongside
INSTALLED_ARRAY_API_STRICT, INSTALLED_JAX, etc.) so that the TestSeAStat
decorator resolves correctly during module import and tests can be collected.

---

Duplicate comments:
In `@source/tests/consistent/descriptor/test_dpa2.py`:
- Around line 67-161: The test currently encodes DPA2 cases as 27-slot tuples
(DPA2_CASE_FIELDS, DPA2_BASELINE_CASE, dpa2_case, DPA2_CURATED_CASES) which
forces callers to destructure and is causing RUF059 lint failures for unused
tuple slots; change dpa2_case to return a keyed mapping (e.g., a dict or
lightweight dataclass) instead of a tuple, keep DPA2_BASELINE_CASE as the
canonical dict, update DPA2_CURATED_CASES to call dpa2_case(...) and yield
dicts, and update all consumers to access fields by name (e.g.,
case["precision"] or case.precision) rather than positional unpacking; after
making these changes run ruff check . and ruff format . to clear the lint
errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7ef6b16e-3f7f-4e28-ad07-73c3be1c61ba

📥 Commits

Reviewing files that changed from the base of the PR and between bc54f07 and 63326d3.

📒 Files selected for processing (4)
  • source/tests/consistent/common.py
  • source/tests/consistent/descriptor/test_dpa1.py
  • source/tests/consistent/descriptor/test_dpa2.py
  • source/tests/consistent/descriptor/test_se_e2_a.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • source/tests/consistent/descriptor/test_dpa1.py

Replace the remaining SeA stats parameterized decorator with explicit curated
cases and keep the descriptor test files in sync with isort/ruff formatting.

Authored by OpenClaw (model: gpt-5.4)
Handle collisions in parameterized_cases deterministically by appending a
numeric suffix when the sanitized generated test-class name is already in use.
This prevents silent overwrites when different case tuples sanitize to the same
identifier.

Authored by OpenClaw (model: gpt-5.4)
@njzjz-bot
Copy link
Copy Markdown
Contributor Author

Addressed the CodeRabbit finding about _parameterized_with_cases name collisions.

What changed:

  • detect sanitized generated-name collisions in source/tests/consistent/common.py
  • keep a used_names set for the current decorator invocation
  • also check class_module
  • append a deterministic numeric suffix when the sanitized base name is already taken

This avoids silent overwrites while preserving all generated test classes.

Validated with:

  • python3 -m py_compile source/tests/consistent/common.py
  • uvx prek run -a

Authored by OpenClaw (model: gpt-5.4)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
source/tests/consistent/descriptor/test_dpa2.py (1)

269-297: ⚠️ Potential issue | 🟠 Major

Remove the unused case unpacking before lint runs.

skip_pt, skip_dp, skip_tf, and setUp never read the unpacked values, and skip_pd / rtol / atol only use precision. Ruff is already flagging Line 275, and the same pattern repeats at Lines 308, 341, 374, 451, 557, and 596, so this touched file will keep failing lint until those destructures are removed or narrowed. As per coding guidelines, "Always run ruff check . and ruff format . before committing changes or CI will fail".

Also applies to: 302-330, 335-363, 368-396, 445-473, 551-579, 590-618

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@source/tests/consistent/descriptor/test_dpa2.py` around lines 269 - 297, The
tuple unpack in the test methods unpacks many values from self.param that are
never used (e.g., repinit_tebd_input_mode, repinit_set_davg_zero, …,
use_tebd_bias); update each destructuring to only extract the variables actually
used in the test (for example extract just precision or precision and any used
flags), or replace unused names with underscores (_) to avoid unused-variable
lint errors; look for the same pattern in the other test blocks that unpack
self.param (the blocks that currently list the long tuple) and narrow each
unpack to the minimal set of names the test reads (or use _ placeholders) so
Ruff stops flagging unused variables.
🧹 Nitpick comments (1)
source/tests/consistent/descriptor/test_dpa2.py (1)

66-125: repformer_set_davg_zero is dead in the curated schema.

The new case tuple includes repformer_set_davg_zero, but Line 246 and Line 715 still hardcode RepformerArgs(set_davg_zero=True). A future dpa2_case(repformer_set_davg_zero=False) would create a distinct test class without changing the exercised configuration.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@source/tests/consistent/descriptor/test_dpa2.py` around lines 66 - 125, The
test includes repformer_set_davg_zero in DPA2_CASE_FIELDS but the test
instantiates RepformerArgs with set_davg_zero=True (hardcoded) at the
RepformerArgs(...) sites, so toggling the case field doesn't affect the created
config; update the two instantiations where RepformerArgs(set_davg_zero=True) is
used (the locations flagged around the current RepformerArgs constructors) to
read the value from the case dict (use case["repformer_set_davg_zero"]) instead
of hardcoding True so the generated test config follows DPA2_BASELINE_CASE /
DPA2_CASE_FIELDS.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@source/tests/consistent/descriptor/test_se_e2_a.py`:
- Around line 382-390: SE_A_STAT_CASES currently omits any se_a_case with
type_one_side=False so the TestSeAStat path exercising compute_input_stats() for
the alternate stats branch is untested; add a single
se_a_case(type_one_side=False) entry into the SE_A_STAT_CASES tuple (alongside
the existing baseline and env_protection variants) so the
parameterized_cases(...) includes that variant and exercises the special setup
branch in TestSeAStat.

---

Duplicate comments:
In `@source/tests/consistent/descriptor/test_dpa2.py`:
- Around line 269-297: The tuple unpack in the test methods unpacks many values
from self.param that are never used (e.g., repinit_tebd_input_mode,
repinit_set_davg_zero, …, use_tebd_bias); update each destructuring to only
extract the variables actually used in the test (for example extract just
precision or precision and any used flags), or replace unused names with
underscores (_) to avoid unused-variable lint errors; look for the same pattern
in the other test blocks that unpack self.param (the blocks that currently list
the long tuple) and narrow each unpack to the minimal set of names the test
reads (or use _ placeholders) so Ruff stops flagging unused variables.

---

Nitpick comments:
In `@source/tests/consistent/descriptor/test_dpa2.py`:
- Around line 66-125: The test includes repformer_set_davg_zero in
DPA2_CASE_FIELDS but the test instantiates RepformerArgs with set_davg_zero=True
(hardcoded) at the RepformerArgs(...) sites, so toggling the case field doesn't
affect the created config; update the two instantiations where
RepformerArgs(set_davg_zero=True) is used (the locations flagged around the
current RepformerArgs constructors) to read the value from the case dict (use
case["repformer_set_davg_zero"]) instead of hardcoding True so the generated
test config follows DPA2_BASELINE_CASE / DPA2_CASE_FIELDS.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: de4628eb-857e-451f-a2e1-629eb1d357f0

📥 Commits

Reviewing files that changed from the base of the PR and between 63326d3 and 27b174b.

📒 Files selected for processing (3)
  • source/tests/consistent/descriptor/test_dpa1.py
  • source/tests/consistent/descriptor/test_dpa2.py
  • source/tests/consistent/descriptor/test_se_e2_a.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • source/tests/consistent/descriptor/test_dpa1.py

Add the missing curated SeA stats variant with type_one_side=False so the
compute_input_stats path also exercises the alternate branch called out in
review.

Authored by OpenClaw (model: gpt-5.4)
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@source/tests/consistent/common.py`:
- Around line 761-777: parameterized_cases currently accepts zero args and
returns _parameterized_with_cases(list(cases)) which yields an empty subclass
replacement and silently drops tests; update parameterized_cases to validate the
input and raise a clear error when no case tuples are provided (e.g., if not
cases: raise ValueError("parameterized_cases requires at least one case
tuple")), referencing parameterized_cases and the helper
_parameterized_with_cases so callers get a descriptive failure instead of
silently replacing the base class with object.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e6dd42ea-bcb3-4911-a4ed-821cfebe31a4

📥 Commits

Reviewing files that changed from the base of the PR and between 27b174b and 367fba9.

📒 Files selected for processing (1)
  • source/tests/consistent/common.py

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Set generated parameterized test-class metadata to the exported module name,
thread repformer_set_davg_zero through DPA2 curated cases, and update the SeA
stats coverage comment to match the curated variants.

Authored by OpenClaw (model: gpt-5.4)
Set generated parameterized class metadata for clearer unittest output, reject
empty parameterized_cases inputs explicitly, and keep the curated descriptor
cases aligned with review feedback.

Authored by OpenClaw (model: gpt-5.4)
@njzjz njzjz requested review from iProzd and wanghan-iapcm April 7, 2026 16:33
@iProzd iProzd enabled auto-merge April 8, 2026 10:50
@iProzd iProzd added this pull request to the merge queue Apr 8, 2026
@njzjz njzjz removed this pull request from the merge queue due to a manual request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: replace large Cartesian parameter grids in consistency suites with curated matrices

6 participants