Permalink
Browse files

Merge branch 'stroxler-creation'

  • Loading branch information...
2 parents b819f2c + 4ea1ea4 commit a950ff135bb4b1be80d3962f52d860e327d41b50 @kwgoodman committed Feb 8, 2012
Showing with 24 additions and 42 deletions.
  1. +2 −2 README.rst
  2. +12 −36 la/flarry.py
  3. +10 −4 la/tests/flarry_test.py
View
@@ -118,9 +118,9 @@ After you have installed ``la``, run the suite of unit tests::
>>> import la
>>> la.test()
<snip>
- Ran 3059 tests in 1.408s
+ Ran 3061 tests in 1.408s
OK
- <nose.result.TextTestResult run=3059 errors=0 failures=0>
+ <nose.result.TextTestResult run=3061 errors=0 failures=0>
The ``la`` package contains C extensions that speed up common alignment
operations such as adding two unaligned larrys. If the C extensions don't
View
@@ -1774,13 +1774,10 @@ def lrange(shape=None, label=None, start=0, step=1, dtype=None):
Parameters
----------
shape : {int, tuple}, optional
- If shape is not given, then a label must be supplied. If both
- are supplied, then `shape` is ignored. If `shape` is an int, output
- will be one-dimensional.
+ If `shape` is not given, then `label` must be supplied. If `shape` is
+ an int, output will be one-dimensional.
label : list, optional
- List of lists, a label for the larry produced. For convenience, if no
- keywords are supplied but the first argument is a list of lists, then
- that argument will be assumed to be `label` rather than `shape`.
+ List of lists, a label for the larry produced.
start : int, optional
First integer appearing. Defaults to 0
step : int, optional
@@ -1845,12 +1842,6 @@ def lrange(shape=None, label=None, start=0, step=1, dtype=None):
array([0, 1])
"""
- if shape is not None:
- if isinstance(shape, list):
- if isinstance(shape[0], list):
- label = shape
- if isinstance(shape, int):
- shape = (shape,)
if label is not None:
shape = [len(lab) for lab in label]
else:
@@ -1868,13 +1859,10 @@ def empty(shape=None, label=None, dtype=None, order='C'):
Parameters
----------
shape : {int, tuple}, optional
- If shape is not given, then a label must be supplied. If both
- are supplied, then `shape` is ignored. If `shape` is an int, output
- will be one-dimensional.
+ If `shape` is not given, then `label` must be supplied. If `shape` is
+ an int, output will be one-dimensional.
label : list, optional
- List of lists, a label for the larry produced. For convenience, if no
- keywords are supplied but the first argument list of lists, then
- that argument will be assumed to be `label` rather than `shape`.
+ List of lists, a label for the larry produced.
dtype : data-type, optional
The desired data-type for the array, e.g., `numpy.int8`. Default is
`numpy.float64`.
@@ -1938,12 +1926,6 @@ def empty(shape=None, label=None, dtype=None, order='C'):
array([0e0, -3.2e-256])
"""
- if shape is not None:
- if isinstance(shape, list):
- if isinstance(shape[0], list):
- label = shape
- if isinstance(shape, int):
- shape = (shape,)
if label is not None:
shape = [len(lab) for lab in label]
else:
@@ -1959,13 +1941,10 @@ def ones(shape=None, label=None, dtype=None, order='C'):
Parameters
----------
shape : {int, tuple}, optional
- If shape is not given, then a label must be supplied. If both
- are supplied, then `shape` is ignored. If `shape` is an int, output
- will be one-dimensional.
+ If `shape` is not given, then `label` must be supplied. If `shape` is
+ an int, output will be one-dimensional.
label : list, optional
- List of lists, a label for the larry produced. For convenience, if no
- keywords are supplied but the first argument list of lists, then
- that argument will be assumed to be `label` rather than `shape`.
+ List of lists, a label for the larry produced.
dtype : data-type, optional
The desired data-type for the array, e.g., `numpy.int8`. Default is
`numpy.float64`.
@@ -2039,13 +2018,10 @@ def zeros(shape=None, label=None, dtype=None, order='C'):
Parameters
----------
shape : {int, tuple}, optional
- If shape is not given, then a label must be supplied. If both
- are supplied, then `shape` is ignored. If `shape` is an int, output
- will be one-dimensional.
+ If `shape` is not given, then `label` must be supplied. If `shape` is
+ an int, output will be one-dimensional.
label : list, optional
- List of lists, a label for the larry produced. For convenience, if no
- keywords are supplied but the first argument list of lists, then
- that argument will be assumed to be `label` rather than `shape`.
+ List of lists, a label for the larry produced.
dtype : data-type, optional
The desired data-type for the array, e.g., `numpy.int8`. Default is
`numpy.float64`.
@@ -10,7 +10,7 @@
from la import larry, rand
from la import (union, intersection, panel, stack, cov, align, isaligned,
binaryop, add, subtract, multiply, divide, unique, sortby,
- align_axis, lrange, ones, zeros)
+ align_axis, lrange, ones, zeros, empty)
from la.util.testing import assert_larry_equal as ale
@@ -680,10 +680,16 @@ def test_lrange_3(self):
ale(a, d, "lrange failed.")
def test_lrange_4(self):
- a = lrange([['a', 'b'], ['c', 'd']])
+ a = lrange(label=[['a', 'b'], ['c', 'd']])
d = larry([[0, 1], [2, 3]], [['a', 'b'], ['c', 'd']])
ale(a, d, "lrange failed.")
+ def test_lrange_5(self):
+ self.failUnlessRaises(ValueError, lrange, (2,), ['a', 'b', 'c'])
+
+ def test_empty_1(self):
+ self.failUnlessRaises(ValueError, empty, (2,), ['a', 'b', 'c'])
+
def test_ones_1(self):
a = ones(5)
d = larry([1., 1., 1., 1., 1.])
@@ -700,7 +706,7 @@ def test_ones_3(self):
ale(a, d, "ones failed.")
def test_ones_4(self):
- a = ones([['a', 'b'], ['c', 'd']])
+ a = ones(label=[['a', 'b'], ['c', 'd']])
d = larry([[1., 1.], [1., 1.]], [['a', 'b'], ['c', 'd']])
ale(a, d, "ones failed.")
@@ -720,7 +726,7 @@ def test_zeros_3(self):
ale(a, d, "zeros failed.")
def test_zeros_4(self):
- a = zeros([['a', 'b'], ['c', 'd']])
+ a = zeros(label=[['a', 'b'], ['c', 'd']])
d = larry([[0., 0.], [0., 0.]], [['a', 'b'], ['c', 'd']])
ale(a, d, "zeros failed.")

0 comments on commit a950ff1

Please sign in to comment.