Skip to content

Use dataclasses.replace to simplify coding. - #16

Merged
hzhangxyz merged 1 commit into
mainfrom
dev/use-replace-function
Jul 31, 2025
Merged

Use dataclasses.replace to simplify coding.#16
hzhangxyz merged 1 commit into
mainfrom
dev/use-replace-function

Conversation

@hzhangxyz

Copy link
Copy Markdown
Member

No description provided.

@hzhangxyz
hzhangxyz requested a review from Copilot July 31, 2025 01:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 simplifies the code by replacing manual ParityTensor constructor calls with dataclasses.replace(). This change reduces code duplication and makes the intent clearer when creating new instances with only specific fields modified.

  • Replaces verbose ParityTensor constructor calls with more concise dataclasses.replace() calls
  • Eliminates redundant field assignments by leveraging the default copying behavior of dataclasses.replace()
  • Maintains the same functionality while improving code readability and maintainability

"""
return ParityTensor(
_edges=self._edges,
return dataclasses.replace(

Copilot AI Jul 31, 2025

Copy link

Choose a reason for hiding this comment

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

The dataclasses module is not imported. You need to add import dataclasses at the top of the file to use dataclasses.replace().

Copilot uses AI. Check for mistakes.
@hzhangxyz
hzhangxyz merged commit a0ad401 into main Jul 31, 2025
6 checks passed
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