Skip to content

Instantly share code, notes, and snippets.

@altendky
Forked from AlecTaylor/ex.py
Last active June 6, 2018 14:57
Show Gist options
  • Select an option

  • Save altendky/df74405c0f6d58fa2ca15bfcc7a3fe20 to your computer and use it in GitHub Desktop.

Select an option

Save altendky/df74405c0f6d58fa2ca15bfcc7a3fe20 to your computer and use it in GitHub Desktop.

Revisions

  1. altendky revised this gist Jun 6, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ex.py
    Original file line number Diff line number Diff line change
    @@ -90,4 +90,4 @@ def b(grouped):
    yield (k, v)


    epoch2stat = b(a())
    epoch2stat = dict(b(a()))
  2. altendky revised this gist Jun 6, 2018. 1 changed file with 50 additions and 1 deletion.
    51 changes: 50 additions & 1 deletion ex.py
    Original file line number Diff line number Diff line change
    @@ -41,4 +41,53 @@
    ))
    })
    if val and len(val) == 2
    }
    }



    # -----

    def a():
    return groupby(sorted(
    imap(
    lambda l: (l[0], l[1]),
    ifilter(
    None,
    imap(
    lambda l: (
    lambda fst: (
    lambda three: (
    (
    int(three),
    l.rstrip()[l.rfind(':') + 2:],
    )
    if (
    three is not None
    and three.isdigit()
    and int(three[0]) < 4
    else None
    )
    )(
    l[fst - 3:fst]
    if fst > -1
    else None
    )
    )(l.rfind(']')),
    infile,
    ),
    ),
    ),
    key=itemgetter(0),
    ),
    itemgetter(0),
    ))


    def b(grouped):
    for k, v in grouped:
    v = tuple(imap(itemgetter(1), v))
    if len(v) == 2:
    yield (k, v)


    epoch2stat = b(a())
  3. altendky revised this gist Jun 6, 2018. 1 changed file with 18 additions and 19 deletions.
    37 changes: 18 additions & 19 deletions ex.py
    Original file line number Diff line number Diff line change
    @@ -7,23 +7,22 @@
    )
    )
    for k, v in groupby(sorted(
    imap(
    lambda l: (l[0], l[1]),
    ifilter(
    None,
    imap(
    lambda l: (
    lambda fst: (
    lambda three: (
    (
    int(three),
    l.rstrip()[l.rfind(':') + 2:],
    )
    if (
    three is not None
    and three.isdigit()
    and int(three[0]
    ) < 4
    imap(
    lambda l: (l[0], l[1]),
    ifilter(
    None,
    imap(
    lambda l: (
    lambda fst: (
    lambda three: (
    (
    int(three),
    l.rstrip()[l.rfind(':') + 2:],
    )
    if (
    three is not None
    and three.isdigit()
    and int(three[0]) < 4
    else None
    )
    )(
    @@ -32,14 +31,14 @@
    else None
    )
    )(l.rfind(']')),
    infile
    infile,
    ),
    ),
    ),
    key=itemgetter(0),
    ),
    itemgetter(0),
    )
    ))
    })
    if val and len(val) == 2
    }
  4. altendky revised this gist Jun 6, 2018. 1 changed file with 40 additions and 12 deletions.
    52 changes: 40 additions & 12 deletions ex.py
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,45 @@
    epoch2stat = {
    key: val
    for key, val in iteritems(
    {
    k: tuple((lambda stats: stats)(tuple(imap(itemgetter(1), v))))
    for k, v in groupby(sorted(imap(lambda l: (l[0], l[1]),
    ifilter(None, imap(
    lambda l: (lambda fst: (
    lambda three: (int(three), l.rstrip()[l.rfind(':') + 2:])
    if three is not None and three.isdigit() and int(
    three[0]) < 4 else None)(
    l[fst - 3:fst] if fst > -1 else None))(l.rfind(']')), infile)
    )), key=itemgetter(0)),
    itemgetter(0))
    for key, val in iteritems({
    k: tuple(
    (lambda stats: stats)(
    tuple(imap(itemgetter(1), v))
    )
    )
    for k, v in groupby(sorted(
    imap(
    lambda l: (l[0], l[1]),
    ifilter(
    None,
    imap(
    lambda l: (
    lambda fst: (
    lambda three: (
    (
    int(three),
    l.rstrip()[l.rfind(':') + 2:],
    )
    if (
    three is not None
    and three.isdigit()
    and int(three[0]
    ) < 4
    else None
    )
    )(
    l[fst - 3:fst]
    if fst > -1
    else None
    )
    )(l.rfind(']')),
    infile
    ),
    ),
    ),
    key=itemgetter(0),
    ),
    itemgetter(0),
    )
    })
    if val and len(val) == 2
    }
  5. @AlecTaylor AlecTaylor created this gist Jun 6, 2018.
    17 changes: 17 additions & 0 deletions ex.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    epoch2stat = {
    key: val
    for key, val in iteritems(
    {
    k: tuple((lambda stats: stats)(tuple(imap(itemgetter(1), v))))
    for k, v in groupby(sorted(imap(lambda l: (l[0], l[1]),
    ifilter(None, imap(
    lambda l: (lambda fst: (
    lambda three: (int(three), l.rstrip()[l.rfind(':') + 2:])
    if three is not None and three.isdigit() and int(
    three[0]) < 4 else None)(
    l[fst - 3:fst] if fst > -1 else None))(l.rfind(']')), infile)
    )), key=itemgetter(0)),
    itemgetter(0))
    })
    if val and len(val) == 2
    }