Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arraycontext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
arraycontext
Commits
1378c420
Commit
1378c420
authored
3 years ago
by
Andreas Klöckner
Committed by
Andreas Klöckner
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
with_container_arithmetic: Nix implementation of __eq__ if eq_comparison not requested
parent
ce936a7a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arraycontext/container/arithmetic.py
+14
-1
14 additions, 1 deletion
arraycontext/container/arithmetic.py
with
14 additions
and
1 deletion
arraycontext/container/arithmetic.py
+
14
−
1
View file @
1378c420
...
...
@@ -304,12 +304,25 @@ def with_container_arithmetic(
# {{{ binary operators
for
dunder_name
,
op_str
,
reversible
,
op_cls
in
_BINARY_OP_AND_DUNDER
:
fname
=
f
"
_
{
cls
.
__name__
.
lower
()
}
_
{
dunder_name
}
"
if
op_cls
not
in
desired_op_classes
:
# Leaving equality comparison at the default supplied by
# dataclasses is dangerous: Comparison of dataclass fields
# might return an array of truth values, and the dataclasses
# implementation of __eq__ might consider that 'truthy' enough,
# yielding bogus equality results.
if
op_cls
==
_OpClass
.
EQ_COMPARISON
:
gen
(
f
"
def
{
fname
}
(arg1, arg2):
"
)
with
Indentation
(
gen
):
gen
(
"
return NotImplemented
"
)
gen
(
f
"
cls.__
{
dunder_name
}
__ =
{
fname
}
"
)
gen
(
""
)
continue
# {{{ "forward" binary operators
fname
=
f
"
_
{
cls
.
__name__
.
lower
()
}
_
{
dunder_name
}
"
zip_init_args
=
cls
.
_deserialize_init_arrays_code
(
"
arg1
"
,
{
same_key
(
key_arg1
,
key_arg2
):
_format_binary_op_str
(
op_str
,
expr_arg1
,
expr_arg2
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment