Skip to content

Commit

Permalink
change isinstance(..., frozenset) to isinstace(..., Set)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Feb 12, 2024
1 parent d873e95 commit b3d68a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 8 additions & 7 deletions loopy/kernel/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from loopy.diagnostic import LoopyError
from loopy.tools import Optional
from collections.abc import Set as abc_Set


# {{{ instruction tags
Expand Down Expand Up @@ -186,7 +187,7 @@ class InstructionBase(ImmutableRecord, Taggable):
A :class:`frozenset` of subclasses of :class:`pytools.tag.Tag` used to
provide metadata on this object. Legacy string tags are converted to
:class:`LegacyStringInstructionTag` or, if they used to carry
a functional meaning, the tag carrying that same fucntional meaning
a functional meaning, the tag carrying that same functional meaning
(e.g. :class:`UseStreamingStoreTag`).
.. automethod:: __init__
Expand Down Expand Up @@ -267,7 +268,7 @@ def __init__(self, id, depends_on, depends_on_is_final,
if depends_on_is_final is None:
depends_on_is_final = False

if depends_on_is_final and not isinstance(depends_on, frozenset):
if depends_on_is_final and not isinstance(depends_on, abc_Set):
raise LoopyError("Setting depends_on_is_final to True requires "
"actually specifying depends_on")

Expand All @@ -277,7 +278,7 @@ def __init__(self, id, depends_on, depends_on_is_final,
if priority is None:
priority = 0

if not isinstance(tags, frozenset):
if not isinstance(tags, abc_Set):
# was previously allowed to be tuple
tags = frozenset(tags)

Expand All @@ -292,10 +293,10 @@ def __init__(self, id, depends_on, depends_on_is_final,
# assert all(is_interned(iname) for iname in within_inames)
# assert all(is_interned(pred) for pred in predicates)

assert isinstance(within_inames, frozenset)
assert isinstance(depends_on, frozenset) or depends_on is None
assert isinstance(groups, frozenset)
assert isinstance(conflicts_with_groups, frozenset)
assert isinstance(within_inames, abc_Set)
assert isinstance(depends_on, abc_Set) or depends_on is None
assert isinstance(groups, abc_Set)
assert isinstance(conflicts_with_groups, abc_Set)

ImmutableRecord.__init__(self,
id=id,
Expand Down
5 changes: 3 additions & 2 deletions loopy/schedule/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from functools import reduce
from pytools import memoize_method, memoize_on_first_arg
from pyrsistent import pmap
from collections.abc import Set as abc_Set


# {{{ block boundary finder
Expand Down Expand Up @@ -653,7 +654,7 @@ def _pull_out_loop_nest(tree, loop_nests, inames_to_pull_out):
*outer_loop_nest*: frozenset({'k'})
*inner_loop_nest*: frozenset({'l'})
"""
assert all(isinstance(loop_nest, frozenset) for loop_nest in loop_nests)
assert all(isinstance(loop_nest, abc_Set) for loop_nest in loop_nests)
assert inames_to_pull_out <= reduce(frozenset.union, loop_nests, frozenset())

# {{{ sanity check to ensure the loop nest *inames_to_pull_out* is possible
Expand Down Expand Up @@ -955,7 +956,7 @@ def _get_iname_to_tree_node_id_from_partial_loop_nest_tree(tree):
"""
iname_to_tree_node_id = {}
for node in tree.nodes():
assert isinstance(node, frozenset)
assert isinstance(node, abc_Set)
for iname in node:
iname_to_tree_node_id[iname] = node

Expand Down

0 comments on commit b3d68a0

Please sign in to comment.