diff options
author | cookedm <cookedm@localhost> | 2006-05-16 23:34:24 +0000 |
---|---|---|
committer | cookedm <cookedm@localhost> | 2006-05-16 23:34:24 +0000 |
commit | a1445160dea079dd0e1c82fcda7729d3809b13d7 (patch) | |
tree | 9d7bafd927e96d4bb3386affc5bd8463dbfa0756 /numpy/lib | |
parent | 38c83aba3369696b4d3053e2081dd490c7a18c66 (diff) | |
download | numpy-a1445160dea079dd0e1c82fcda7729d3809b13d7.tar.gz |
#118: linspace should always return floats
Patch from stefan; fix special case which could return an array of one int.
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/function_base.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 6f8df9b7b..dd5452723 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -38,7 +38,7 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False): return array([]) if endpoint: if num == 1: - return array([start]) + return array([float(start)]) step = (stop-start)/float((num-1)) else: step = (stop-start)/float(num) diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 3a603923a..372929447 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -87,6 +87,11 @@ class test_linspace(ScipyTestCase): y = list(linspace(0,1,2.5)) assert y == [0.0, 1.0] + def check_type(self): + t1 = linspace(0,1,0).dtype + t2 = linspace(0,1,1).dtype + assert_equal(t1, t2) + class test_amax(ScipyTestCase): def check_basic(self): a = [3,4,5,10,-3,-5,6.0] |