MCPcopy Index your code
hub / github.com/clips/pattern / insert

Method insert

pattern/db/__init__.py:1768–1787  ·  view source on GitHub ↗

Inserts the given row into the matrix. Missing columns at the end (right) will be filled with the default value.

(self, i, row, default=None)

Source from the content-addressed store, hash-verified

1766 self.extend(datasheet); return self
1767
1768 def insert(self, i, row, default=None):
1769 """ Inserts the given row into the matrix.
1770 Missing columns at the end (right) will be filled with the default value.
1771 """
1772 try:
1773 # Copy the row (fast + safe for generators and DatasheetColumns).
1774 row = [v for v in row]
1775 except:
1776 raise TypeError, "Datasheet.insert(x): x must be list"
1777 list.insert(self, i, row)
1778 m = max((len(self) > 1 and self._m or 0, len(row)))
1779 if len(row) < m:
1780 row.extend([default] * (m-len(row)))
1781 if self._m < m:
1782 # The given row might have more columns than the rows in the matrix.
1783 # Performance takes a hit when these rows have to be expanded:
1784 for row in self:
1785 if len(row) < m:
1786 row.extend([default] * (m-len(row)))
1787 self.__dict__["_m"] = m
1788
1789 def append(self, row, default=None, _m=None):
1790 self.insert(len(self), row, default)

Callers 3

__setitem__Method · 0.95
appendMethod · 0.95
extendMethod · 0.95

Calls 3

lenFunction · 0.85
insertMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected