We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
seq()
pseq()
1 parent 56ff25b commit d757a90Copy full SHA for d757a90
CHANGELOG.md
@@ -1,5 +1,6 @@
1
# Changelog
2
## Next Release
3
+* Allow empty sequence expressions `seq()`, `pseq()` (#159)
4
5
## Release 1.3.0
6
* added precompute attribute to reverse transformation (#137)
functional/streams.py
@@ -41,13 +41,11 @@ def __call__(self, *args, **kwargs):
41
"""
42
# pylint: disable=no-self-use
43
engine = ExecutionEngine()
44
- return self._parse_args(
45
- args, engine, "seq() takes at least 1 argument ({0} given)"
46
- )
+ return self._parse_args(args, engine)
47
48
- def _parse_args(self, args, engine, error_message):
+ def _parse_args(self, args, engine):
49
if len(args) == 0:
50
- raise TypeError(error_message.format(len(args)))
+ return Sequence([], engine=engine, max_repr_items=self.max_repr_items)
51
if len(args) == 1:
52
try:
53
if type(args[0]).__name__ == "DataFrame":
@@ -304,9 +302,7 @@ def __call__(self, *args, **kwargs):
304
302
engine = ParallelExecutionEngine(
305
303
processes=processes, partition_size=partition_size
306
)
307
308
- args, engine, "pseq() takes at least 1 argument ({0} given)"
309
310
311
312
# pylint: disable=invalid-name
functional/test/test_functional.py
@@ -663,6 +663,7 @@ def test_sliding(self):
663
664
def test_empty(self):
665
self.assertTrue(self.seq([]).empty())
666
+ self.assertEqual(self.seq(), self.seq([]))
667
668
def test_non_empty(self):
669
self.assertTrue(self.seq([1]).non_empty())
@@ -920,8 +921,7 @@ def test_seq(self):
920
921
self.assertIteratorEqual(self.seq(1, 2, 3), [1, 2, 3])
922
self.assertIteratorEqual(self.seq(1), [1])
923
self.assertIteratorEqual(self.seq(iter([1, 2, 3])), [1, 2, 3])
- with self.assertRaises(TypeError):
924
- self.seq()
+ self.assertIteratorEqual(self.seq(), [])
925
926
def test_lineage_repr(self):
927
s = self.seq(1).map(lambda x: x).filter(lambda x: True)
0 commit comments