Skip to content

Commit 2a72cd5

Browse files
authored
Merge pull request #1314 from mathics/tidy-has_form-use
Use has_form() more effectively in a couple of places
2 parents 5ff7b43 + 2752aeb commit 2a72cd5

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

mathics/builtin/algebra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def find_vars(e, e_sympy):
205205
return
206206
elif e.is_symbol():
207207
variables.add(e)
208-
elif e.has_form("Plus", None) or e.has_form("Times", None):
208+
elif e.has_form(("Plus", "Times"), None):
209209
for l in e.leaves:
210210
l_sympy = l.to_sympy()
211211
if l_sympy is not None:

mathics/builtin/files.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,9 +2479,7 @@ class Close(Builtin):
24792479
def apply(self, channel, evaluation):
24802480
"Close[channel_]"
24812481

2482-
if channel.has_form("InputStream", 2) or channel.has_form( # noqa
2483-
"OutputStream", 2
2484-
):
2482+
if channel.has_form(("InputStream", "OutputStream"), 2):
24852483
[name, n] = channel.get_leaves()
24862484
stream = stream_manager.lookup_stream(n.get_int_value())
24872485
else:

0 commit comments

Comments
 (0)