3
3
import numeric as _nx
4
4
from numeric import array
5
5
6
- def linspace (start , stop , num = 50 , endpoint = True , retstep = False ):
6
+ def linspace (start , stop , num = 50 , endpoint = True , retstep = False , maskna = False ):
7
7
"""
8
8
Return evenly spaced numbers over a specified interval.
9
9
@@ -29,6 +29,8 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False):
29
29
retstep : bool, optional
30
30
If True, return (`samples`, `step`), where `step` is the spacing
31
31
between samples.
32
+ maskna : boolean
33
+ If this is true, the returned array will have an NA mask.
32
34
33
35
Returns
34
36
-------
@@ -73,22 +75,22 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False):
73
75
"""
74
76
num = int (num )
75
77
if num <= 0 :
76
- return array ([], float )
78
+ return array ([], float , maskna = maskna )
77
79
if endpoint :
78
80
if num == 1 :
79
- return array ([float (start )])
81
+ return array ([float (start )], maskna = maskna )
80
82
step = (stop - start )/ float ((num - 1 ))
81
- y = _nx .arange (0 , num ) * step + start
83
+ y = _nx .arange (0 , num , maskna = maskna ) * step + start
82
84
y [- 1 ] = stop
83
85
else :
84
86
step = (stop - start )/ float (num )
85
- y = _nx .arange (0 , num ) * step + start
87
+ y = _nx .arange (0 , num , maskna = maskna ) * step + start
86
88
if retstep :
87
89
return y , step
88
90
else :
89
91
return y
90
92
91
- def logspace (start ,stop ,num = 50 ,endpoint = True ,base = 10.0 ):
93
+ def logspace (start ,stop ,num = 50 ,endpoint = True ,base = 10.0 , maskna = False ):
92
94
"""
93
95
Return numbers spaced evenly on a log scale.
94
96
@@ -114,6 +116,8 @@ def logspace(start,stop,num=50,endpoint=True,base=10.0):
114
116
The base of the log space. The step size between the elements in
115
117
``ln(samples) / ln(base)`` (or ``log_base(samples)``) is uniform.
116
118
Default is 10.0.
119
+ maskna : boolean
120
+ If this is true, the returned array will have an NA mask.
117
121
118
122
Returns
119
123
-------
@@ -162,6 +166,6 @@ def logspace(start,stop,num=50,endpoint=True,base=10.0):
162
166
>>> plt.show()
163
167
164
168
"""
165
- y = linspace (start ,stop ,num = num ,endpoint = endpoint )
169
+ y = linspace (start ,stop ,num = num ,endpoint = endpoint , maskna = maskna )
166
170
return _nx .power (base ,y )
167
171
0 commit comments