-
Notifications
You must be signed in to change notification settings - Fork 0
/
type-error.json
32 lines (32 loc) · 2.96 KB
/
type-error.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[
"t = []\nfor i in iterable:\n try:\n if cond(i):\n t.append(i)\n except Exception as e:\n pass",
"import numpy as np\nt = list(np.extract(cond, iterable))",
"import operator\ncond_func = operator.not_\nt = [x for x in iterable if cond_func(x)]",
"t = [x for x in iterable if not cond]",
"t = []\nfor x in iterable:\n if not cond:\n t.append(x)",
"import itertools\ncond_func = lambda x: not cond\nt = list(itertools.filterfalse(cond_func, iterable))",
"import numpy as np\ncond_func = np.logical_not(cond)\nt = list(np.extract(cond_func, iterable))",
"t = list((x for x in iterable if not cond))",
"import numpy as np\ncond_func = np.logical_not\niterable_np = np.array(iterable)\nt = list(iterable_np[cond_func(cond)])",
"t = []\nfor i in range(len(iterable)):\n if not cond:\n t.append(iterable[i])",
"t = []\nfor x in iterable:\n try:\n if cond(x):\n t.append(x)\n except:\n pass",
"t = filter(cond, iterable)",
"import itertools\nt = itertools.compress(iterable, (cond(i) for i in iterable))",
"t = list()\nfor i in iterable:\n try:\n if cond(i):\n t.append(i)\n except TypeError:\n pass",
"from itertools import compress\nt = compress(iterable, map(cond, iterable))",
"t = (x for x in iterable if cond(x))",
"import itertools\nt = filter(lambda i: cond(i), iterable)",
"t = []\nfor i in iterable:\n try:\n t.append(i if cond(i) else None)\n except Exception as e:\n pass",
"t = []\nfor i in iterable:\n try:\n if cond(i):\n t.append(i)\n else:\n continue\n except Exception as e:\n continue",
"import itertools\ncond = lambda x: x % 2 == 0\niterable = range(10)\nt = list(filter(cond, iterable))",
"import itertools\niterator = itertools.count(0, 2)\nt = list((next(iterator) for _ in range(10)))",
"iterable = list(range(10))\nt = [x for x in iterable if x % 2 == 0]",
"import functools\nreduced_iterable = functools.reduce(lambda a, b: a if b % 2 else a + [b], range(10), [])\nt = reduced_iterable",
"import math\ndef find_even(x):\n if math.remainder(x, 2) == 0:\n return True\n return False\nt = [x for x in range(10) if find_even(x)]",
"import numpy as np\ncond = np.vectorize(lambda x: x % 2 == 0)\niterable = np.arange(10)\nt = list(filter(cond, iterable))",
"from sympy import Symbol, N\niterable = range(10)\ncond = [Symbol('N') % 2 == 0 for N in iterable]\nt = list(filter(lambda x: x, cond))",
"iterable = range(10)\neven_numbers = [x for x in iterable if x % 2 == 0]\nt = even_numbers",
"iterable = range(10)\nprintable = map(str, iterable)\neven_ints_in_list = list(filter(lambda x: int(x) % 2 == 0, printable))\nt = even_ints_in_list",
"from typing import Iterable\niterable = range(10)\n\ndef create_generator(iterable: Iterable):\n for x in iterable:\n if x % 2 == 0:\n yield x\nt = list(create_generator(iterable))",
"t = filter(lambda x: cond(x), iterable)"
]