Skip to content

Commit af51ee3

Browse files
committed
Add documentation
1 parent 65ba65a commit af51ee3

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

stream/numbers.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,23 @@ def random():
7979

8080
@staticmethod
8181
def range(start, end, step=1):
82+
'''
83+
Returns a stream of numbers from start to end with specified step.
84+
85+
:param int start: the start value
86+
:param int end: the max value
87+
:param int step: the step
88+
:return: the new stream
89+
'''
8290
return NumberStream(Stream.iterate(start, lambda i: i + step).takeWhile(lambda x: x <= end))
8391

8492
@staticmethod
8593
def pi():
94+
'''
95+
Returns a stream with the digits of PI.
8696
97+
:return: the PI's digits stream
98+
'''
8799
def pi_digits():
88100
"Generate n digits of Pi."
89101
k, a, b, a1, b1 = 2, 4, 1, 12, 4
@@ -105,6 +117,11 @@ def __init__(self, _stream):
105117
self.iterable = _stream
106118

107119
def average(self):
120+
'''
121+
Get the average value of the element of the stream.
122+
123+
:return: the average value
124+
'''
108125
_sum = 0
109126
_count = 0
110127
for elem in self:

stream/stream.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@ def concat(*streams):
9999

100100
@staticmethod
101101
def constant(element):
102+
'''
103+
Return an infinite sequential stream where each element is the passed element
102104
105+
:param T elem: the element
106+
:return: the new stream made of @element
107+
'''
103108
return Stream.generate(lambda: element)
104109

105-
@staticmethod
106-
def booleans():
107-
return Stream.generate(lambda: random.randint(0, 1) == 1)
108-
109110
"""
110111
Normal Methods
111112
"""

0 commit comments

Comments
 (0)