Skip to content

fix(thermoelastic2d): fix Config nelx/nely ClassVar issue#245

Merged
mkeeler43 merged 3 commits intomainfrom
update/thermoelastic2d
Apr 2, 2026
Merged

fix(thermoelastic2d): fix Config nelx/nely ClassVar issue#245
mkeeler43 merged 3 commits intomainfrom
update/thermoelastic2d

Conversation

@mkeeler43
Copy link
Copy Markdown
Contributor

Summary

  • Change nelx and nely from ClassVar to regular dataclass fields in thermoelastic2d's Config, matching the pattern used by beams2d. This fixes a TypeError when check_constraints calls rmin_bound, which requires nelx and nely as parameters but couldn't find them in dataclasses.asdict() output.
  • Fix nely being incorrectly assigned NELX instead of NELY.
  • Bump Hugging Face dataset version from v0 to v1.

Test plan

  • Verify check_constraints no longer raises TypeError for thermoelastic2d configs
  • Verify dataclasses.asdict(Config()) includes nelx and nely
  • Run existing thermoelastic2d tests

🤖 Generated with Claude Code

mkeeler43 and others added 2 commits April 2, 2026 14:46
…tead of ClassVar

nelx and nely were declared as ClassVar on Config, excluding them from
dataclasses.fields() and dataclasses.asdict(). This caused a TypeError
when check_constraints called rmin_bound, which requires nelx and nely
as parameters. Also fixes nely being incorrectly assigned NELX instead
of NELY.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

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

Fixes thermoelastic2d configuration serialization so constraint checking can access nelx/nely, corrects a nely default typo, and updates the Hugging Face dataset identifier.

Changes:

  • Convert ThermoElastic2D.Config.nelx/nely from ClassVar to dataclass fields so they appear in dataclasses.asdict().
  • Fix nely default to use NELY (was incorrectly set to NELX).
  • Bump dataset_id from IDEALLab/thermoelastic_2d_v0 to IDEALLab/thermoelastic_2d_v1.
Comments suppressed due to low confidence (1)

engibench/problems/thermoelastic2d/v0.py:95

  • The regression being fixed here (TypeError in check_constraints because nelx/nely were ClassVar and excluded from dataclasses.asdict()) isn’t covered by a test. Add a small unit/integration test that instantiates ThermoElastic2D, calls check_constraints with a valid design/config, and asserts it does not raise (and/or that dataclasses.asdict(ThermoElastic2D.Config()) includes nelx and nely) to prevent this from reappearing.
        nelx: Annotated[int, bounded(lower=1).category(THEORY)] = NELX
        nely: Annotated[int, bounded(lower=1).category(THEORY)] = NELY
        max_iter: int = fea_model.MAX_ITERATIONS
        """Maximal number of iterations for optimize."""

        @constraint
        @staticmethod
        def rmin_bound(rmin: float, nelx: int, nely: int) -> None:
            """Constraint for rmin ∈ (0.0, max{ nelx, nely }]."""
            assert 0.0 < rmin <= max(nelx, nely), f"Params.rmin: {rmin} ∉ (0, max(nelx, nely)]"

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

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 2 out of 2 changed files in this pull request and generated 1 comment.


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

@mkeeler43 mkeeler43 merged commit c7f2ed0 into main Apr 2, 2026
17 of 19 checks passed
@mkeeler43 mkeeler43 deleted the update/thermoelastic2d branch April 2, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants