Skip to content

Commit 9d047d6

Browse files
authored
Remove unnecessary set class (pyccel pyccel#2018) (pyccel#2034)
Remove the unnecessary class `SetRemove`. Fixes pyccel#2018 **Commit Summary** - Delete `SetRemove` class from `ast/builtin_methods/set_methods.py` - Replace `SetRemove` method with `SetDiscard` for `remove` keyword in `SetClass` methods in `ast/class_defs.py`
1 parent d88c20b commit 9d047d6

File tree

3 files changed

+3
-31
lines changed

3 files changed

+3
-31
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ Contributors
3535
* Shoaib Moeen
3636
* Kush Choudhary
3737
* Emmmanuel Ferdman
38+
* Amir Movassaghi

pyccel/ast/builtin_methods/set_methods.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
'SetDiscard',
2121
'SetMethod',
2222
'SetPop',
23-
'SetRemove',
2423
'SetUnion',
2524
'SetUpdate'
2625
)
@@ -148,34 +147,6 @@ def __init__(self, set_variable):
148147
self._class_type = set_variable.class_type.element_type
149148
super().__init__(set_variable)
150149

151-
#==============================================================================
152-
class SetRemove(SetMethod):
153-
"""
154-
Represents a call to the .remove() method.
155-
156-
The remove() method removes the specified item from
157-
the set and updates the set. It doesn't return any value.
158-
159-
Parameters
160-
----------
161-
set_variable : TypedAstNode
162-
The set on which the method will operate.
163-
164-
item : TypedAstNode
165-
The item to search for, and remove.
166-
"""
167-
__slots__ = ()
168-
_shape = None
169-
_class_type = VoidType()
170-
name = 'remove'
171-
172-
def __init__(self, set_variable, item) -> None:
173-
if not isinstance(item, TypedAstNode):
174-
raise TypeError(f"It is not possible to look for a {type(item).__name__} object in a set of {set_variable.dtype}")
175-
if item.class_type != set_variable.class_type.element_type:
176-
raise TypeError(f"Can't remove an element of type {item.dtype} from a set of {set_variable.dtype}")
177-
super().__init__(set_variable, item)
178-
179150
#==============================================================================
180151
class SetDiscard(SetMethod):
181152
"""

pyccel/ast/class_defs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
This module contains all types which define a python class which is automatically recognised by pyccel
77
"""
88

9-
from pyccel.ast.builtin_methods.set_methods import (SetAdd, SetClear, SetCopy, SetPop, SetRemove,
9+
from pyccel.ast.builtin_methods.set_methods import (SetAdd, SetClear, SetCopy, SetPop,
1010
SetDiscard, SetUpdate, SetUnion)
1111
from pyccel.ast.builtin_methods.list_methods import (ListAppend, ListInsert, ListPop,
1212
ListClear, ListExtend, ListRemove,
@@ -163,7 +163,7 @@
163163
PyccelFunctionDef('copy', func_class = SetCopy),
164164
PyccelFunctionDef('discard', func_class = SetDiscard),
165165
PyccelFunctionDef('pop', func_class = SetPop),
166-
PyccelFunctionDef('remove', func_class = SetRemove),
166+
PyccelFunctionDef('remove', func_class = SetDiscard),
167167
PyccelFunctionDef('union', func_class = SetUnion),
168168
PyccelFunctionDef('update', func_class = SetUpdate),
169169
PyccelFunctionDef('__or__', func_class = SetUnion),

0 commit comments

Comments
 (0)