Skip to content

Here's a table method #32

@LTLA

Description

@LTLA

plz add

# TODO: move to biocutils.
@singledispatch
def table(x: Sequence, sort: bool = True) -> biocutils.IntegerList:
    output = {}
    for v in x:
        if v in output:
            output[v] += 1
        else:
            output[v] = 1

    if sort:
        collected = sorted(output.keys())
        tmp = {}
        for y in collected:
            tmp[y] = output[y]
        output = tmp

    return biocutils.IntegerList.from_dict(output)

see also #31 to make sure the output is actually an IntegerList.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions