Skip to content
Snippets Groups Projects
Commit 541ed528 authored by Stephan Seitz's avatar Stephan Seitz
Browse files

Make Block.insert_front accept iterables for multiple insertions

parent 2259867d
Branches
Tags release/0.2.2
No related merge requests found
import uuid import collections
from typing import Any, List, Optional, Sequence, Set, Union from typing import Any, List, Optional, Sequence, Set, Union
import sympy as sp import sympy as sp
...@@ -279,8 +279,15 @@ class Block(Node): ...@@ -279,8 +279,15 @@ class Block(Node):
a.subs(subs_dict) a.subs(subs_dict)
def insert_front(self, node): def insert_front(self, node):
node.parent = self if isinstance(node, collections.Iterable):
self._nodes.insert(0, node) node = list(node)
for n in node:
n.parent = self
self._nodes = node + self._nodes
else:
node.parent = self
self._nodes.insert(0, node)
def insert_before(self, new_node, insert_before): def insert_before(self, new_node, insert_before):
new_node.parent = self new_node.parent = self
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment