Skip to content

Commit 566516c

Browse files
committed
fixes #658
1 parent 17b02dc commit 566516c

File tree

3 files changed

+58
-12
lines changed

3 files changed

+58
-12
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
<!-- do not remove -->
44

5+
## 1.7.27
6+
7+
8+
9+
510
## 1.7.26
611

712

fastcore/foundation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def renumerate(self): return L(renumerate(self))
173173
def unique(self, sort=False, bidir=False, start=None): return L(uniqueify(self, sort=sort, bidir=bidir, start=start))
174174
def val2idx(self): return val2idx(self)
175175
def cycle(self): return cycle(self)
176-
def groupby(self, key, val=noop): return L(groupby(self, key, val=val))
176+
def groupby(self, key, val=noop): return groupby(self, key, val=val)
177177
def map_dict(self, f=noop, *args, **kwargs): return {k:f(k, *args,**kwargs) for k in self}
178178
def map_first(self, f=noop, g=noop, *args, **kwargs):
179179
return first(self.map(f, *args, **kwargs), g)
@@ -223,7 +223,7 @@ def setattrs(self, attr, val): [setattr(o,attr,val) for o in self]
223223
cycle="Same as `itertools.cycle`",
224224
enumerate="Same as `enumerate`",
225225
renumerate="Same as `renumerate`",
226-
groupby="Same as `groupby`",
226+
groupby="Same as `fastcore.basics.groupby`",
227227
zip="Create new `L` with `zip(*items)`",
228228
zipwith="Create new `L` with `self` zip with each of `*rest`",
229229
map_zip="Combine `zip` and `starmap`",

nbs/02_foundation.ipynb

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,6 @@
255255
"execution_count": null,
256256
"metadata": {},
257257
"outputs": [
258-
{
259-
"name": "stderr",
260-
"output_type": "stream",
261-
"text": [
262-
"/Users/jhoward/miniforge3/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
263-
" from .autonotebook import tqdm as notebook_tqdm\n"
264-
]
265-
},
266258
{
267259
"data": {
268260
"text/markdown": [
@@ -620,7 +612,7 @@
620612
" def unique(self, sort=False, bidir=False, start=None): return L(uniqueify(self, sort=sort, bidir=bidir, start=start))\n",
621613
" def val2idx(self): return val2idx(self)\n",
622614
" def cycle(self): return cycle(self)\n",
623-
" def groupby(self, key, val=noop): return L(groupby(self, key, val=val))\n",
615+
" def groupby(self, key, val=noop): return groupby(self, key, val=val)\n",
624616
" def map_dict(self, f=noop, *args, **kwargs): return {k:f(k, *args,**kwargs) for k in self}\n",
625617
" def map_first(self, f=noop, g=noop, *args, **kwargs):\n",
626618
" return first(self.map(f, *args, **kwargs), g)\n",
@@ -677,7 +669,7 @@
677669
" cycle=\"Same as `itertools.cycle`\",\n",
678670
" enumerate=\"Same as `enumerate`\",\n",
679671
" renumerate=\"Same as `renumerate`\",\n",
680-
" groupby=\"Same as `groupby`\",\n",
672+
" groupby=\"Same as `fastcore.basics.groupby`\",\n",
681673
" zip=\"Create new `L` with `zip(*items)`\",\n",
682674
" zipwith=\"Create new `L` with `self` zip with each of `*rest`\",\n",
683675
" map_zip=\"Combine `zip` and `starmap`\",\n",
@@ -1219,6 +1211,55 @@
12191211
"test_eq(L(1,2,3).val2idx(), {3:2,1:0,2:1})"
12201212
]
12211213
},
1214+
{
1215+
"cell_type": "code",
1216+
"execution_count": null,
1217+
"metadata": {},
1218+
"outputs": [
1219+
{
1220+
"data": {
1221+
"text/markdown": [
1222+
"---\n",
1223+
"\n",
1224+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/foundation.py#L176){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
1225+
"\n",
1226+
"### L.groupby\n",
1227+
"\n",
1228+
"> L.groupby (key, val=<function noop>)\n",
1229+
"\n",
1230+
"*Same as `groupby`*"
1231+
],
1232+
"text/plain": [
1233+
"---\n",
1234+
"\n",
1235+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/foundation.py#L176){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
1236+
"\n",
1237+
"### L.groupby\n",
1238+
"\n",
1239+
"> L.groupby (key, val=<function noop>)\n",
1240+
"\n",
1241+
"*Same as `groupby`*"
1242+
]
1243+
},
1244+
"execution_count": null,
1245+
"metadata": {},
1246+
"output_type": "execute_result"
1247+
}
1248+
],
1249+
"source": [
1250+
"show_doc(L.groupby)"
1251+
]
1252+
},
1253+
{
1254+
"cell_type": "code",
1255+
"execution_count": null,
1256+
"metadata": {},
1257+
"outputs": [],
1258+
"source": [
1259+
"words = L.split('aaa abc bba')\n",
1260+
"test_eq(words.groupby(0, (1,2)), {'a':[('a','a'),('b','c')], 'b':[('b','a')]})"
1261+
]
1262+
},
12221263
{
12231264
"cell_type": "code",
12241265
"execution_count": null,

0 commit comments

Comments
 (0)