Skip to content

Commit

Permalink
[rename] PipeArgs -> StarArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
tandav committed Sep 4, 2023
1 parent e5b82d3 commit c6ef397
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,19 @@ False

```

## PipeArgs
## StarArgs

```py
>>> (1, 2) | PipeArgs(operator.add)
>>> (1, 2) | StarArgs(operator.add)
3

>>> ('FF', 16) | PipeArgs(int)
>>> ('FF', 16) | StarArgs(int)
255

>>> ([1, 2], 'A') | PipeArgs(dict.fromkeys)
>>> ([1, 2], 'A') | StarArgs(dict.fromkeys)
{1: 'A', 2: 'A'}

>>> ({1, 2}, {3, 4, 5}) | PipeArgs(set.union)
>>> ({1, 2}, {3, 4, 5}) | StarArgs(set.union)
{1, 2, 3, 4, 5}

```
Expand Down
6 changes: 3 additions & 3 deletions pipe21.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class GroupBy (B): __ror__ = lambda self, it: it | Sorted(key=self.f) | Pip
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 PipeArgs (B): __ror__ = lambda self, x: self.f(*x)
class StarMap (B): __ror__ = lambda self, x: x | Map(lambda y: y | PipeArgs(self.f))
class StarFlatMap (B): __ror__ = lambda self, x: x | FlatMap(lambda y: y | PipeArgs(self.f))
class StarArgs (B): __ror__ = lambda self, x: self.f(*x)
class StarMap (B): __ror__ = lambda self, x: x | Map(lambda y: y | StarArgs(self.f))
class StarFlatMap (B): __ror__ = lambda self, x: x | FlatMap(lambda y: y | StarArgs(self.f))
class MapApply (B): __ror__ = lambda self, it: it | Map(lambda x: x | Apply(self.f))
class Switch (B): __ror__ = lambda self, x: self.f | FilterKeys(lambda p: p(x)) | Values() | Map(lambda f: f(x)) | Pipe(next, x)
class MapSwitch (B): __ror__ = lambda self, it: it | Map(lambda x: x | Switch(self.f))
Expand Down
4 changes: 2 additions & 2 deletions tests/pipe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ def test_groupby(it, f, expected):
(({1, 2}, {3, 4, 5}), set.union, {1, 2, 3, 4, 5}),
],
)
def test_pipe_args(it, f, expected):
assert it | PipeArgs(f) == expected
def test_star_args(it, f, expected):
assert it | StarArgs(f) == expected


@pytest.mark.parametrize(
Expand Down

0 comments on commit c6ef397

Please sign in to comment.