From a4840e0a16da2888552e349b862d92ae17c62369 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 1 Aug 2023 00:51:10 -0500 Subject: [PATCH] Fix flake8 complaint: use 'is' for type comarisons --- loopy/kernel/array.py | 2 +- loopy/kernel/instruction.py | 2 +- loopy/library/reduction.py | 6 +++--- loopy/match.py | 16 ++++++++-------- loopy/target/__init__.py | 2 +- loopy/tools.py | 2 +- loopy/types.py | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/loopy/kernel/array.py b/loopy/kernel/array.py index a3dcd8812..165727e6b 100644 --- a/loopy/kernel/array.py +++ b/loopy/kernel/array.py @@ -920,7 +920,7 @@ def __eq__(self, other): is_tuple_of_expressions_equal as istoee, is_expression_equal as isee) return ( - type(self) == type(other) + type(self) is type(other) and self.name == other.name and self.dtype == other.dtype and istoee(self.shape, other.shape) diff --git a/loopy/kernel/instruction.py b/loopy/kernel/instruction.py index 0972bea69..5c28247ad 100644 --- a/loopy/kernel/instruction.py +++ b/loopy/kernel/instruction.py @@ -605,7 +605,7 @@ def update_persistent_hash(self, key_hash, key_builder): key_builder.rec(key_hash, self.var_name) def __eq__(self, other): - return (type(self) == type(other) + return (type(self) is type(other) and self.var_name == other.var_name) def __ne__(self, other): diff --git a/loopy/library/reduction.py b/loopy/library/reduction.py index 190e6bd9a..85cf452b9 100644 --- a/loopy/library/reduction.py +++ b/loopy/library/reduction.py @@ -118,7 +118,7 @@ def __hash__(self): return hash((type(self),)) def __eq__(self, other): - return type(self) == type(other) + return type(self) is type(other) def __str__(self): result = type(self).__name__.replace("ReductionOperation", "").lower() @@ -359,7 +359,7 @@ def __hash__(self): return hash(type(self)) def __eq__(self, other): - return type(self) == type(other) and (self.inner_reduction == + return type(self) is type(other) and (self.inner_reduction == other.inner_reduction) def __call__(self, dtypes, operand1, operand2, callables_table, target): @@ -461,7 +461,7 @@ def __hash__(self): return hash(type(self)) def __eq__(self, other): - return type(self) == type(other) + return type(self) is type(other) @property def arg_count(self): diff --git a/loopy/match.py b/loopy/match.py index 624276dce..63879c911 100644 --- a/loopy/match.py +++ b/loopy/match.py @@ -148,7 +148,7 @@ def update_persistent_hash(self, key_hash, key_builder): key_builder.rec(key_hash, "all_match_expr") def __eq__(self, other): - return (type(self) == type(other)) + return type(self) is type(other) def __hash__(self): return hash(type(self)) @@ -172,7 +172,7 @@ def update_persistent_hash(self, key_hash, key_builder): key_builder.rec(key_hash, self.children) def __eq__(self, other): - return (type(self) == type(other) + return (type(self) is type(other) and self.children == other.children) def __hash__(self): @@ -207,7 +207,7 @@ def update_persistent_hash(self, key_hash, key_builder): key_builder.rec(key_hash, self.child) def __eq__(self, other): - return (type(self) == type(other) + return (type(self) is type(other) and self.child == other.child) def __hash__(self): @@ -253,7 +253,7 @@ def update_persistent_hash(self, key_hash, key_builder): key_builder.rec(key_hash, self.glob) def __eq__(self, other): - return (type(self) == type(other) + return (type(self) is type(other) and self.glob == other.glob) def __hash__(self): @@ -434,7 +434,7 @@ def update_persistent_hash(self, key_hash, key_builder): key_builder.rec(key_hash, "all_match") def __eq__(self, other): - return (type(self) == type(other)) + return type(self) is type(other) class StackBottomMatchComponent(StackMatchComponent): @@ -445,7 +445,7 @@ def update_persistent_hash(self, key_hash, key_builder): key_builder.rec(key_hash, "bottom_match") def __eq__(self, other): - return (type(self) == type(other)) + return type(self) is type(other) class StackItemMatchComponent(StackMatchComponent): @@ -469,7 +469,7 @@ def update_persistent_hash(self, key_hash, key_builder): key_builder.rec(key_hash, self.inner_match) def __eq__(self, other): - return (type(self) == type(other) + return (type(self) is type(other) and self.match_expr == other.match_expr and self.inner_match == other.inner_match) @@ -514,7 +514,7 @@ def update_persistent_hash(self, key_hash, key_builder): def __eq__(self, other): return ( - type(self) == type(other) + type(self) is type(other) and self.root_component == other.root_component) diff --git a/loopy/target/__init__.py b/loopy/target/__init__.py index 34bd18a13..be04d1008 100644 --- a/loopy/target/__init__.py +++ b/loopy/target/__init__.py @@ -88,7 +88,7 @@ def update_persistent_hash(self, key_hash, key_builder): key_builder.rec(key_hash, getattr(self, field_name)) def __eq__(self, other): - if type(self) != type(other): + if type(self) is not type(other): return False for field_name in self.comparison_fields: diff --git a/loopy/tools.py b/loopy/tools.py index 35c58f0c8..24f8dcc75 100644 --- a/loopy/tools.py +++ b/loopy/tools.py @@ -136,7 +136,7 @@ def __init__(self, expression): self.expression = expression def __eq__(self, other): - return (type(self) == type(other) + return (type(self) is type(other) and self.expression == other.expression) def __ne__(self, other): diff --git a/loopy/types.py b/loopy/types.py index 57b9548bb..a6824a225 100644 --- a/loopy/types.py +++ b/loopy/types.py @@ -101,7 +101,7 @@ def update_persistent_hash(self, key_hash, key_builder): def __eq__(self, other): return ( - type(self) == type(other) + type(self) is type(other) and self.dtype == other.dtype) def __ne__(self, other): @@ -192,7 +192,7 @@ def __hash__(self): def __eq__(self, other): return ( - type(self) == type(other) + type(self) is type(other) and self.name == other.name) def __ne__(self, other):