|
610 | 610 | " @classmethod\n",
|
611 | 611 | " def range(cls, a, b=None, step=None): return cls(range_of(a, b=b, step=step))\n",
|
612 | 612 | "\n",
|
613 |
| - " def map(self, f, *args, gen=False, **kwargs): return self._new(map_ex(self, f, *args, gen=gen, **kwargs))\n", |
| 613 | + " def map(self, f, *args, **kwargs): return self._new(map_ex(self, f, *args, gen=False, **kwargs))\n", |
614 | 614 | " def argwhere(self, f, negate=False, **kwargs): return self._new(argwhere(self, f, negate, **kwargs))\n",
|
615 |
| - " def argfirst(self, f, negate=False): return first(i for i,o in self.enumerate() if f(o))\n", |
616 |
| - " def filter(self, f=noop, negate=False, gen=False, **kwargs):\n", |
617 |
| - " return self._new(filter_ex(self, f=f, negate=negate, gen=gen, **kwargs))\n", |
| 615 | + " def argfirst(self, f, negate=False): \n", |
| 616 | + " if negate: f = not_(f)\n", |
| 617 | + " return first(i for i,o in self.enumerate() if f(o))\n", |
| 618 | + " def filter(self, f=noop, negate=False, **kwargs):\n", |
| 619 | + " return self._new(filter_ex(self, f=f, negate=negate, gen=False, **kwargs))\n", |
618 | 620 | "\n",
|
619 | 621 | " def enumerate(self): return L(enumerate(self))\n",
|
620 | 622 | " def renumerate(self): return L(renumerate(self))\n",
|
621 | 623 | " def unique(self, sort=False, bidir=False, start=None): return L(uniqueify(self, sort=sort, bidir=bidir, start=start))\n",
|
622 | 624 | " def val2idx(self): return val2idx(self)\n",
|
623 | 625 | " def cycle(self): return cycle(self)\n",
|
624 |
| - " def map_dict(self, f=noop, *args, gen=False, **kwargs): return {k:f(k, *args,**kwargs) for k in self}\n", |
| 626 | + " def map_dict(self, f=noop, *args, **kwargs): return {k:f(k, *args,**kwargs) for k in self}\n", |
625 | 627 | " def map_first(self, f=noop, g=noop, *args, **kwargs):\n",
|
626 |
| - " return first(self.map(f, *args, gen=True, **kwargs), g)\n", |
| 628 | + " return first(self.map(f, *args, **kwargs), g)\n", |
627 | 629 | "\n",
|
628 | 630 | " def itemgot(self, *idxs):\n",
|
629 | 631 | " x = self\n",
|
|
1132 | 1134 | "text/markdown": [
|
1133 | 1135 | "---\n",
|
1134 | 1136 | "\n",
|
1135 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L164){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1137 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L166){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1136 | 1138 | "\n",
|
1137 | 1139 | "### L.unique\n",
|
1138 | 1140 | "\n",
|
|
1143 | 1145 | "text/plain": [
|
1144 | 1146 | "---\n",
|
1145 | 1147 | "\n",
|
1146 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L164){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1148 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L166){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1147 | 1149 | "\n",
|
1148 | 1150 | "### L.unique\n",
|
1149 | 1151 | "\n",
|
|
1180 | 1182 | "text/markdown": [
|
1181 | 1183 | "---\n",
|
1182 | 1184 | "\n",
|
1183 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L165){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1185 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L167){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1184 | 1186 | "\n",
|
1185 | 1187 | "### L.val2idx\n",
|
1186 | 1188 | "\n",
|
|
1191 | 1193 | "text/plain": [
|
1192 | 1194 | "---\n",
|
1193 | 1195 | "\n",
|
1194 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L165){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1196 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L167){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1195 | 1197 | "\n",
|
1196 | 1198 | "### L.val2idx\n",
|
1197 | 1199 | "\n",
|
|
1228 | 1230 | "text/markdown": [
|
1229 | 1231 | "---\n",
|
1230 | 1232 | "\n",
|
1231 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L159){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1233 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L161){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1232 | 1234 | "\n",
|
1233 | 1235 | "### L.filter\n",
|
1234 | 1236 | "\n",
|
|
1239 | 1241 | "text/plain": [
|
1240 | 1242 | "---\n",
|
1241 | 1243 | "\n",
|
1242 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L159){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1244 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L161){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1243 | 1245 | "\n",
|
1244 | 1246 | "### L.filter\n",
|
1245 | 1247 | "\n",
|
|
1380 | 1382 | "metadata": {},
|
1381 | 1383 | "outputs": [],
|
1382 | 1384 | "source": [
|
1383 |
| - "test_eq(t.argfirst(lambda o:o>4), 5)" |
| 1385 | + "test_eq(t.argfirst(lambda o:o>4), 5)\n", |
| 1386 | + "test_eq(t.argfirst(lambda o:o>4,negate=True),0)" |
1384 | 1387 | ]
|
1385 | 1388 | },
|
1386 | 1389 | {
|
|
1490 | 1493 | "text/markdown": [
|
1491 | 1494 | "---\n",
|
1492 | 1495 | "\n",
|
1493 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L167){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1496 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L169){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1494 | 1497 | "\n",
|
1495 | 1498 | "### L.map_dict\n",
|
1496 | 1499 | "\n",
|
|
1501 | 1504 | "text/plain": [
|
1502 | 1505 | "---\n",
|
1503 | 1506 | "\n",
|
1504 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L167){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1507 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L169){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1505 | 1508 | "\n",
|
1506 | 1509 | "### L.map_dict\n",
|
1507 | 1510 | "\n",
|
|
1539 | 1542 | "text/markdown": [
|
1540 | 1543 | "---\n",
|
1541 | 1544 | "\n",
|
1542 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L179){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1545 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L181){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1543 | 1546 | "\n",
|
1544 | 1547 | "### L.zip\n",
|
1545 | 1548 | "\n",
|
|
1550 | 1553 | "text/plain": [
|
1551 | 1554 | "---\n",
|
1552 | 1555 | "\n",
|
1553 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L179){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1556 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L181){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1554 | 1557 | "\n",
|
1555 | 1558 | "### L.zip\n",
|
1556 | 1559 | "\n",
|
|
1599 | 1602 | "text/markdown": [
|
1600 | 1603 | "---\n",
|
1601 | 1604 | "\n",
|
1602 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L181){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1605 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L183){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1603 | 1606 | "\n",
|
1604 | 1607 | "### L.map_zip\n",
|
1605 | 1608 | "\n",
|
|
1610 | 1613 | "text/plain": [
|
1611 | 1614 | "---\n",
|
1612 | 1615 | "\n",
|
1613 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L181){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1616 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L183){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1614 | 1617 | "\n",
|
1615 | 1618 | "### L.map_zip\n",
|
1616 | 1619 | "\n",
|
|
1648 | 1651 | "text/markdown": [
|
1649 | 1652 | "---\n",
|
1650 | 1653 | "\n",
|
1651 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L180){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1654 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L182){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1652 | 1655 | "\n",
|
1653 | 1656 | "### L.zipwith\n",
|
1654 | 1657 | "\n",
|
|
1659 | 1662 | "text/plain": [
|
1660 | 1663 | "---\n",
|
1661 | 1664 | "\n",
|
1662 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L180){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1665 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L182){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1663 | 1666 | "\n",
|
1664 | 1667 | "### L.zipwith\n",
|
1665 | 1668 | "\n",
|
|
1698 | 1701 | "text/markdown": [
|
1699 | 1702 | "---\n",
|
1700 | 1703 | "\n",
|
1701 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L182){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1704 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L184){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1702 | 1705 | "\n",
|
1703 | 1706 | "### L.map_zipwith\n",
|
1704 | 1707 | "\n",
|
|
1709 | 1712 | "text/plain": [
|
1710 | 1713 | "---\n",
|
1711 | 1714 | "\n",
|
1712 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L182){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1715 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L184){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1713 | 1716 | "\n",
|
1714 | 1717 | "### L.map_zipwith\n",
|
1715 | 1718 | "\n",
|
|
1746 | 1749 | "text/markdown": [
|
1747 | 1750 | "---\n",
|
1748 | 1751 | "\n",
|
1749 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L171){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1752 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L173){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1750 | 1753 | "\n",
|
1751 | 1754 | "### L.itemgot\n",
|
1752 | 1755 | "\n",
|
|
1757 | 1760 | "text/plain": [
|
1758 | 1761 | "---\n",
|
1759 | 1762 | "\n",
|
1760 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L171){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1763 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L173){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1761 | 1764 | "\n",
|
1762 | 1765 | "### L.itemgot\n",
|
1763 | 1766 | "\n",
|
|
1794 | 1797 | "text/markdown": [
|
1795 | 1798 | "---\n",
|
1796 | 1799 | "\n",
|
1797 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L175){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1800 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L177){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1798 | 1801 | "\n",
|
1799 | 1802 | "### L.attrgot\n",
|
1800 | 1803 | "\n",
|
|
1805 | 1808 | "text/plain": [
|
1806 | 1809 | "---\n",
|
1807 | 1810 | "\n",
|
1808 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L175){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1811 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L177){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1809 | 1812 | "\n",
|
1810 | 1813 | "### L.attrgot\n",
|
1811 | 1814 | "\n",
|
|
1993 | 1996 | "text/markdown": [
|
1994 | 1997 | "---\n",
|
1995 | 1998 | "\n",
|
1996 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L188){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 1999 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L190){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
1997 | 2000 | "\n",
|
1998 | 2001 | "### L.concat\n",
|
1999 | 2002 | "\n",
|
|
2004 | 2007 | "text/plain": [
|
2005 | 2008 | "---\n",
|
2006 | 2009 | "\n",
|
2007 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L188){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 2010 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L190){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
2008 | 2011 | "\n",
|
2009 | 2012 | "### L.concat\n",
|
2010 | 2013 | "\n",
|
|
2090 | 2093 | "text/markdown": [
|
2091 | 2094 | "---\n",
|
2092 | 2095 | "\n",
|
2093 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L168){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 2096 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L170){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
2094 | 2097 | "\n",
|
2095 | 2098 | "### L.map_first\n",
|
2096 | 2099 | "\n",
|
|
2101 | 2104 | "text/plain": [
|
2102 | 2105 | "---\n",
|
2103 | 2106 | "\n",
|
2104 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L168){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 2107 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L170){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
2105 | 2108 | "\n",
|
2106 | 2109 | "### L.map_first\n",
|
2107 | 2110 | "\n",
|
|
2139 | 2142 | "text/markdown": [
|
2140 | 2143 | "---\n",
|
2141 | 2144 | "\n",
|
2142 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L192){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 2145 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L194){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
2143 | 2146 | "\n",
|
2144 | 2147 | "### L.setattrs\n",
|
2145 | 2148 | "\n",
|
|
2150 | 2153 | "text/plain": [
|
2151 | 2154 | "---\n",
|
2152 | 2155 | "\n",
|
2153 |
| - "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L192){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 2156 | + "[source](https://github.com/fastai/fastcore/blob/master/fastcore/foundation.py#L194){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
2154 | 2157 | "\n",
|
2155 | 2158 | "### L.setattrs\n",
|
2156 | 2159 | "\n",
|
|
0 commit comments