Skip to content

Commit

Permalink
delete IsUnique
Browse files Browse the repository at this point in the history
  • Loading branch information
tandav committed Oct 4, 2023
1 parent af25fd2 commit 38e1de7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 27 deletions.
14 changes: 0 additions & 14 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,20 +326,6 @@ Note: `GroupBy` sorts iterable before grouping. If you pass key function, eg `Gr

```

## IsUnique

```py
>>> [0, 1, 2, 3] | IsUnique()
True
>>> [0, 1, 1, 3] | IsUnique()
False
>>> '0123' | IsUnique(int)
True
>>> '0113' | IsUnique(int)
False

```

## ReduceByKey

```py
Expand Down
1 change: 0 additions & 1 deletion pipe21.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class Take (B): __ror__ = lambda self, it: it | Slice(self.f) | Pipe(tup
class Chunked (B): __ror__ = lambda self, it: iter(functools.partial(lambda n, i: i | Take(n), self.f, iter(it)), ())
class Sorted (B): __ror__ = lambda self, it: sorted(it, **self.kw)
class GroupBy (B): __ror__ = lambda self, it: it | Sorted(key=self.f) | Pipe(itertools.groupby, key=self.f)
class IsUnique (B): __ror__ = lambda self, seq: len(seq) == len(set(seq if self.f is None else map(self.f, seq)))
class ReduceByKey (B): __ror__ = lambda self, it: it | GroupBy(lambda kv: kv[0]) | MapValues(lambda kv: kv | Values() | Reduce(self.f)) | Pipe(list)
class Apply (B): __ror__ = lambda self, x: x | Exec(self.f, x)
class StarPipe (B): __ror__ = lambda self, x: self.f(*x)
Expand Down
12 changes: 0 additions & 12 deletions tests/pipe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,18 +300,6 @@ def test_star_flatmap(it, f, expected):
assert it | StarFlatMap(f) | Pipe(list) == expected


@pytest.mark.parametrize(
('seq', 'key', 'expected'), [
([0, 1, 2, 3], None, True),
([0, 1, 1, 3], None, False),
('0123', int, True),
('0113', int, False),
],
)
def test_is_unique(seq, key, expected):
assert seq | IsUnique(key) == expected


@pytest.mark.parametrize(
('it', 'kw'), [
([3, 5, 1, 0], {}),
Expand Down

0 comments on commit 38e1de7

Please sign in to comment.