utils_stream.py 516 Bytes
Newer Older
Leo Gao's avatar
Leo Gao committed
1
2
3
4
5
6
import os
from functools import reduce
import operator
from tqdm import tqdm
import json

7
# TODO: phase out utils_stream
Leo Gao's avatar
Leo Gao committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

class each:
    def __init__(self, f):
        self.f = f

    def __rrshift__(self, other):
        return list(map(self.f, other))

class filt:
    def __init__(self, f):
        self.f = f

    def __rrshift__(self, other):
        return list(filter(self.f, other))

class apply:
    def __init__(self, f):
        self.f = f

    def __rrshift__(self, other):
        return self.f(other)