Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions petl/util/materialise.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,47 @@
import operator
from collections import OrderedDict
from itertools import islice
from typing import Dict, Tuple, List, Any

from petl.compat import izip_longest, text_type, next


from petl.util.base import asindices, Table


def listoflists(tbl):
def listoflists(tbl) -> List[list]:
return [list(row) for row in tbl]


Table.listoflists = listoflists
Table.lol = listoflists


def tupleoftuples(tbl):
def tupleoftuples(tbl) -> Tuple[tuple, ...]:
return tuple(tuple(row) for row in tbl)


Table.tupleoftuples = tupleoftuples
Table.tot = tupleoftuples


def listoftuples(tbl):
def listoftuples(tbl) -> List[tuple]:
return [tuple(row) for row in tbl]


Table.listoftuples = listoftuples
Table.lot = listoftuples


def tupleoflists(tbl):
def tupleoflists(tbl) -> Tuple[list, ...]:
return tuple(list(row) for row in tbl)


Table.tupleoflists = tupleoflists
Table.tol = tupleoflists


def columns(table, missing=None):
def columns(table, missing=None) -> OrderedDict:
"""
Construct a :class:`dict` mapping field names to lists of values. E.g.::

Expand Down Expand Up @@ -74,7 +76,7 @@ def columns(table, missing=None):
Table.columns = columns


def facetcolumns(table, key, missing=None):
def facetcolumns(table, key, missing=None) -> Dict[Any, Dict[str, Any]]:
"""
Like :func:`petl.util.materialise.columns` but stratified by values of the
given key field. E.g.::
Expand Down Expand Up @@ -119,7 +121,7 @@ def facetcolumns(table, key, missing=None):
Table.facetcolumns = facetcolumns


def cache(table, n=None):
def cache(table, n=None) -> 'CacheView':
"""
Wrap the table with a cache that caches up to `n` rows as they are initially
requested via iteration (cache all rows be default).
Expand Down