Skip to content

Loading…

ENH added arange(), zeros(), ones() #46

Merged
merged 6 commits into from

3 participants

@stroxler

Closes #15

@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
@@ -649,6 +650,279 @@ def intersection(axis, *args):
rc = list(rc)
rc.sort()
return rc
+# Instantiation shortcuts---------------------------------------------------
@kwgoodman Owner

Move this section to the bottom of the file to keep alignment and binary ops together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
((90 lines not shown))
+ start, step = 0, 1
+ if 'start' in kwargs:
+ start = kwargs['start']
+ del kwargs['start']
+ if 'step' in kwargs:
+ step = kwargs['step']
+ del kwargs['step']
+ # make the data, adjust, and put together
+ total = np.product(np.array(shape))
+ data = np.arange(total, **kwargs).reshape(shape)
+ data *= step; data += start
+ return larry(data, label)
+
+def ones(shape=None, label=None, **kwargs):
+ """
+ Array of sequential integers, filled where later axes have smaller spacing.
@kwgoodman Owner

Looks like a copy and paste error here. Copy first line of np.ones and replace array with larry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
((88 lines not shown))
+ label = [range(i) for i in shape]
+ # start and step
+ start, step = 0, 1
+ if 'start' in kwargs:
+ start = kwargs['start']
+ del kwargs['start']
+ if 'step' in kwargs:
+ step = kwargs['step']
+ del kwargs['step']
+ # make the data, adjust, and put together
+ total = np.product(np.array(shape))
+ data = np.arange(total, **kwargs).reshape(shape)
+ data *= step; data += start
+ return larry(data, label)
+
+def ones(shape=None, label=None, **kwargs):
@kwgoodman Owner

kwargs are confusing so we should avoid then whenever possible. Can we use the following (copied from np.ones) for the signature?

ones(shape=None, label=None, dtype=None, order='C')

Copy and paste the np.ones docstring and change what is necessary.

Same goes for zeros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
((206 lines not shown))
+ will be determined by looking at the given labels (if shape is
+ supplied, it will be overridden
+ arguments in `args` will be ignored in this case). Other kwargs are as
+ for np.arange.
+
+ Returns
+ -------
+ lar : larry
+ a ``(d1, ..., dn)``-shaped larry of zeros, labeled either by
+ integers or by the labels supplied.
+
+ Examples
+ --------
+ A basic, 1d arange using the 'dtype' argument:
+
+ >>> la.ones(5, dtype='i4')
@kwgoodman Owner

Maybe use a smaller example like la.ones(3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
((258 lines not shown))
+ b
+ x
+ array([0., 0.])
+
+ """
+ if shape is not None:
+ if isinstance(shape, list):
+ label = shape
+ if isinstance(shape, int):
+ shape = (shape,)
+ if label is not None:
+ shape = [len(lab) for lab in label]
+ else:
+ if shape is None:
+ raise ValueError("Either `label` or `shape` must be supplied.")
+ label = [range(i) for i in shape]
@kwgoodman Owner

I don't think this line is needed since the default is for larry to use range(n) labels. Same goes for la.ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
@@ -649,6 +650,279 @@ def intersection(axis, *args):
rc = list(rc)
rc.sort()
return rc
+# Instantiation shortcuts---------------------------------------------------
+
+def arange(*args, **kwargs):
@kwgoodman Owner

It does something too different from np.arange. Is there another name we could use for this function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
RELEASE.rst
@@ -16,6 +16,7 @@ la 0.6
- la.isaligned() returns True if two larrys are aligned along specified axis
- la.sortby() sorts a larry by a row or column specified by its label
- la.align_axis() aligns multiple larrys along (possibly) different axes
+- la.arange(), la.ones(), and la.zeros() provide quick ways to get test data
@kwgoodman Owner

Remove: "provide quick ways to get test data"

But that's what I'll use it for ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman
Owner

These functions will come in handy!

Can you add the .. autofunction:: la.ones etc to the sphinx doc?

@kwgoodman
Owner

I noticed that in numpy np.ones and np.zeros just call np.empty with fill values of 1 and 0, respectively.

Maybe we should go that way too? So if we made a la.empty then la.ones and la.zeros could use that and just fill the arrays. That would be cleaner (less duplicate code) plus it would give us a la.empty function.

@stroxler

I can do that. Empty() can't be tested easily, but that is no problem. I guess you could view the other tests as testing it.

@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
((32 lines not shown))
+ Examples
+ --------
+ A basic, 1d arange using the 'dtype' argument:
+
+ >>> la.arange(5, dtype='f4')
+ label_0
+ 0
+ 1
+ 2
+ 3
+ 4
+ x
+ array([0.0, 1.0, 2.0, 3.0, 4.0], dtype=np.float32)
+
+ A multi-dimensional arange:
+ >>> la.arange(2,3,3)
@kwgoodman Owner

lrange is a good name. Change arange to lrange in several places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
@@ -1763,3 +1764,346 @@ def sortby(lar, element, axis, reverse=False):
if reverse:
idx = idx[::-1]
return lar[idx,:]
+
+# Instantiation shortcuts---------------------------------------------------
+
+def lrange(*args, **kwargs):
@kwgoodman Owner

Is there a way to get rid of args, *kwargs? Would this work:

lrange(shape=None, label=None, start=0, step=1, dtype=None)

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
((86 lines not shown))
+ shape = [len(lab) for lab in label]
+ else:
+ shape = args
+ label = [range(i) for i in shape]
+ # start and step
+ start, step = 0, 1
+ if 'start' in kwargs:
+ start = kwargs['start']
+ del kwargs['start']
+ if 'step' in kwargs:
+ step = kwargs['step']
+ del kwargs['step']
+ # make the data, adjust, and put together
+ total = np.product(np.array(shape))
+ data = np.arange(total, **kwargs).reshape(shape)
+ data *= step; data += start
@kwgoodman Owner

Can step and start be passed directly to np.arange?

@stroxler
stroxler added a note

Not as is, but I will adjust them so they can. It will lead to a small efficiency gain, at the price of very slightly worse readability.

@kwgoodman Owner

I think (assuming I coded it right)

data = np.arange(start=start, stop=step*total, step=step, dtype=dtype).reshape(shape)

is more readable than

data = np.arange(total, **kwargs).reshape(shape)
data *= step
data += start

And it is best not to re-implement what is already in numpy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
((153 lines not shown))
+ 2
+ label_2
+ 0
+ 1
+ 2
+ x
+ array([[[ 0e0, 0e0, 0e0],
+ [ 0e0, 0e0, 0e0],
+ [ 0e0, 0e0, 0e0]],
+ [[ 3.2e-254, 0e0, 0e0],
+ [ 0e0., 0e0, 0e0],
+ [ 0e0, 0e0, 0e0]]])
+
+ Using the 'label' argument:
+
+ >>> la.arange(label=[['a', 'b']])
@kwgoodman Owner

la.arange should be la.empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
((130 lines not shown))
+
+ Examples
+ --------
+ A basic, 1d arange using the 'dtype' argument:
+
+ >>> la.empty(5, dtype='i4')
+ label_0
+ 0
+ 1
+ 2
+ 3
+ 4
+ x
+ array([0, 0, 0, -7, 987], dtype=np.int32)
+
+ A multi-dimensional larry:
@kwgoodman Owner

Add blank line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
((174 lines not shown))
+
+ """
+ if shape is not None:
+ if isinstance(shape, list):
+ label = shape
+ if isinstance(shape, int):
+ shape = (shape,)
+ if label is not None:
+ shape = [len(lab) for lab in label]
+ else:
+ if shape is None:
+ raise ValueError("Either `label` or `shape` must be supplied.")
+ label = [range(i) for i in shape]
+ data = np.empty(shape, dtype, order)
+ return larry(data, label)
+
@kwgoodman Owner

Two extra blank lines crept in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman kwgoodman commented on an outdated diff
la/flarry.py
((274 lines not shown))
+ ----------
+ shape : {int, tuple}, optional
+ If shape is 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.
+ 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, then
+ that argument will be assumed to be `label` rather than `shape`.
+ dtype : data-type, optional
+ The desired data-type for the array, e.g., `numpy.int8`. Default is
+ `numpy.float64`.
+ order : {'C', 'F'}, optional
+ Whether to store multidimensional data in C- or Fortran-contiguous
+ (row- or column-wise) order in memory.
+
@kwgoodman Owner

Remove extra blank line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kwgoodman
Owner

Could you add See Also sections? ones, zeros, empty, lrange could all be in each others docstrings.

@stroxler

The args and *kwargs cannot be dropped if we want the function to behave the way we had initially decided. But we could make it follow the same rules that the others follow, in which case they can be.

The issue is that without args, you can't get something like la.lrange(5,4,3) to work. It would have to be la.lrange((5,4,3)). That's why all these functions had *args and *kwargs in the first place. But I don't see a strong reason to prefer the current call. It is more convenient, but if the docstring is confusing does that matter?

@kwgoodman
Owner

Good point. Let's go with the shape input so that lrange matches la.ones, zeros and empty instead la.rand, randn.

@kwgoodman

Is this a typo? Should be possible to do la.lrange((2,3)) without supplying a label.

@kwgoodman

I keep marking this line as not needed. Is there a reason to keep it?

@stroxler

That was a typo. Should be fixed now.

@kwgoodman kwgoodman merged commit c94ffef into kwgoodman:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 445 additions and 6 deletions.
  1. +2 −2 README.rst
  2. +1 −0 RELEASE.rst
  3. +22 −0 doc/source/ref_flarry.rst
  4. +356 −3 la/flarry.py
  5. +64 −1 la/tests/flarry_test.py
View
4 README.rst
@@ -118,9 +118,9 @@ After you have installed ``la``, run the suite of unit tests::
>>> import la
>>> la.test()
<snip>
- Ran 3047 tests in 1.408s
+ Ran 3059 tests in 1.408s
OK
- <nose.result.TextTestResult run=3047 errors=0 failures=0>
+ <nose.result.TextTestResult run=3059 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
1 RELEASE.rst
@@ -16,6 +16,7 @@ la 0.6
- la.isaligned() returns True if two larrys are aligned along specified axis
- la.sortby() sorts a larry by a row or column specified by its label
- la.align_axis() aligns multiple larrys along (possibly) different axes
+- la.lrange(), la.empty(), la.ones(), and la.zeros() generate larrys
**Enhancements**
View
22 doc/source/ref_flarry.rst
@@ -75,6 +75,28 @@ The binary functions combine two larrys into one.
.. autofunction:: la.divide
+Quick Instantiation
+-------------------
+
+Functions that quickly generate larrys.
+
+------------
+
+.. autofunction:: la.empty
+
+------------
+
+.. autofunction:: la.zeros
+
+------------
+
+.. autofunction:: la.ones
+
+------------
+
+.. autofunction:: la.lrange
+
+
Random
------
View
359 la/flarry.py
@@ -7,9 +7,10 @@
from la.farray import covMissing
from la.missing import missing_marker, ismissing
-__all__ = ['align', 'align_axis', 'align_raw', 'isaligned', 'union',
- 'intersection', 'binaryop', 'add', 'sortby', 'subtract', 'multiply',
- 'divide', 'unique', 'stack', 'panel', 'cov', 'rand', 'randn']
+__all__ = ['align', 'align_axis', 'align_raw', 'lrange', 'empty', 'ones',
+ 'zeros', 'isaligned', 'union', 'intersection', 'binaryop', 'add',
+ 'sortby', 'subtract', 'multiply', 'divide', 'unique', 'stack',
+ 'panel', 'cov', 'rand', 'randn']
# Alignment -----------------------------------------------------------------
@@ -1763,3 +1764,355 @@ def sortby(lar, element, axis, reverse=False):
if reverse:
idx = idx[::-1]
return lar[idx,:]
+
+# Instantiation shortcuts---------------------------------------------------
+
+def lrange(shape=None, label=None, start=0, step=1, dtype=None):
+ """
+ Make larry of sequential integers, shaped according to input.
+
+ 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.
+ 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`.
+ start : int, optional
+ First integer appearing. Defaults to 0
+ step : int, optional
+ Difference between successive integers. Defaults to 1.
+ dtype : data-type, optional
+ The desired data-type for the array, e.g., `numpy.int8`. Default is
+ `numpy.float64`.
+
+ Returns
+ -------
+ lar : larry
+ a ``(d1, ..., dn)``-shaped larry of consecutive integers (or spaced
+ `step` apart if such a keyword argument is used), labeled either by
+ integers or by the labels supplied.
+
+ See Also
+ --------
+ empty, ones, zeros
+
+ Examples
+ --------
+ A basic, 1d lrange using the 'dtype' argument:
+
+ >>> la.lrange(3, dtype='f4')
+ label_0
+ 0
+ 1
+ 2
+ 3
+ 4
+ x
+ array([0.0, 1.0, 2.0], dtype=np.float32)
+
+ A multi-dimensional lrange:
+ >>> la.lrange((2,3,3))
+ label_0
+ 0
+ 1
+ label_1
+ 0
+ 1
+ 2
+ label_2
+ 0
+ 1
+ 2
+ x
+ array([[[ 0, 1, 2],
+ [ 3, 4, 5],
+ [ 6, 7, 8]],
+
+ [[ 9, 10, 11],
+ [12, 13, 14],
+ [15, 16, 17]]])
+
+ Using the 'label' keword:
+
+ >>> la.lrange(label=[['a', 'b']])
+ label_0
+ a
+ b
+ x
+ 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:
+ if shape is None:
+ raise ValueError("Either `label` or `shape` must be supplied.")
+ total = np.product(shape)
+ data = np.arange(start=start, stop=step*total+start, step=step,
+ dtype=dtype).reshape(shape)
+ return larry(data, label)
+
+def empty(shape=None, label=None, dtype=None, order='C'):
+ """
+ Makes an empty larry.
+
+ 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.
+ 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`.
+ dtype : data-type, optional
+ The desired data-type for the array, e.g., `numpy.int8`. Default is
+ `numpy.float64`.
+ order : {'C', 'F'}, optional
+ Whether to store multidimensional data in C- or Fortran-contiguous
+ (row- or column-wise) order in memory.
+
+ Returns
+ -------
+ lar : larry
+ a ``(d1, ..., dn)``-shaped larry of ones, labeled either by
+ integers or by the labels supplied.
+
+ See Also
+ --------
+ zeros, ones, lrange
+
+ Examples
+ --------
+ A basic, 1d larry using the 'dtype' argument:
+
+ >>> la.empty(3, dtype='i4')
+ label_0
+ 0
+ 1
+ 2
+ 3
+ 4
+ x
+ array([0, -7, 987], dtype=np.int32)
+
+ A multi-dimensional larry:
+
+ >>> la.empty(2,3,3)
+ label_0
+ 0
+ 1
+ label_1
+ 0
+ 1
+ 2
+ label_2
+ 0
+ 1
+ 2
+ x
+ array([[[ 0e0, 0e0, 0e0],
+ [ 0e0, 0e0, 0e0],
+ [ 0e0, 0e0, 0e0]],
+ [[ 3.2e-254, 0e0, 0e0],
+ [ 0e0., 0e0, 0e0],
+ [ 0e0, 0e0, 0e0]]])
+
+ Using the 'label' argument:
+
+ >>> la.empty(label=[['a', 'b']])
+ label_0
+ a
+ b
+ x
+ 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:
+ if shape is None:
+ raise ValueError("Either `label` or `shape` must be supplied.")
+ data = np.empty(shape, dtype, order)
+ return larry(data, label)
+
+def ones(shape=None, label=None, dtype=None, order='C'):
+ """
+ Makes a larry of all ones.
+
+ 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.
+ 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`.
+ dtype : data-type, optional
+ The desired data-type for the array, e.g., `numpy.int8`. Default is
+ `numpy.float64`.
+ order : {'C', 'F'}, optional
+ Whether to store multidimensional data in C- or Fortran-contiguous
+ (row- or column-wise) order in memory.
+
+ Returns
+ -------
+ lar : larry
+ a ``(d1, ..., dn)``-shaped larry of ones, labeled either by
+ integers or by the labels supplied.
+
+ See Also
+ --------
+ empty, zeros, lrange
+
+ Examples
+ --------
+ A basic, 1d larry using the 'dtype' argument:
+
+ >>> la.ones(3, dtype='i4')
+ label_0
+ 0
+ 1
+ 2
+ 3
+ 4
+ x
+ array([1, 1, 1], dtype=np.int32)
+
+ A multi-dimensional larry:
+
+ >>> la.ones(2,3,3)
+ label_0
+ 0
+ 1
+ label_1
+ 0
+ 1
+ 2
+ label_2
+ 0
+ 1
+ 2
+ x
+ array([[[ 1., 1., 1.],
+ [ 1., 1., 1.],
+ [ 1., 1., 1.]],
+
+ [[ 1., 1., 1.],
+ [ 1., 1., 1.],
+ [ 1., 1., 1.]]])
+
+ Using the 'label' argument:
+
+ >>> la.ones(label=[['a', 'b']])
+ label_0
+ a
+ b
+ x
+ array([1., 1.])
+
+ """
+ lar = empty(shape, label, dtype, order)
+ lar.x.fill(1)
+ return lar
+
+def zeros(shape=None, label=None, dtype=None, order='C'):
+ """
+ Makes a larry of zeros.
+
+ 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.
+ 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`.
+ dtype : data-type, optional
+ The desired data-type for the array, e.g., `numpy.int8`. Default is
+ `numpy.float64`.
+ order : {'C', 'F'}, optional
+ Whether to store multidimensional data in C- or Fortran-contiguous
+ (row- or column-wise) order in memory.
+
+ Returns
+ -------
+ lar : larry
+ a ``(d1, ..., dn)``-shaped larry of zeros, labeled either by
+ integers or by the labels supplied.
+
+ See Also
+ --------
+ empty, ones, lrange
+
+ Examples
+ --------
+ A basic, 1d larry using the 'dtype' argument:
+
+ >>> la.zeros(3, dtype='i4')
+ label_0
+ 0
+ 1
+ 2
+ 3
+ 4
+ x
+ array([0, 0, 0], dtype=np.int32)
+
+ A multi-dimensional larry:
+
+ >>> la.zeros(2,3,3)
+ label_0
+ 0
+ 1
+ label_1
+ 0
+ 1
+ 2
+ label_2
+ 0
+ 1
+ 2
+ x
+ array([[[ 0., 0., 0.],
+ [ 0., 0., 0.],
+ [ 0., 0., 0.]],
+
+ [[ 0., 0., 0.],
+ [ 0., 0., 0.],
+ [ 0., 0., 0.]]])
+
+ Using the 'label' argument:
+
+ >>> la.ones(label=[['a', 'b']])
+ label_0
+ a
+ b
+ x
+ array([0., 0.])
+
+ """
+ lar = empty(shape, label, dtype, order)
+ lar.x.fill(0)
+ return lar
View
65 la/tests/flarry_test.py
@@ -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)
+ align_axis, lrange, ones, zeros)
from la.util.testing import assert_larry_equal as ale
@@ -661,6 +661,69 @@ def test_align_axis_9(self):
ale(a2, d2, msg % '2nd', original=y2)
ale(a3, d3, msg % '3rd', original=y3)
+class Test_quick_inst(unittest.TestCase):
+ "Test quick larry-creation functions."
+
+ def test_lrange_1(self):
+ a = lrange(5)
+ d = larry([0, 1, 2, 3, 4])
+ ale(a, d, "lrange failed.")
+
+ def test_lrange_2(self):
+ 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_3(self):
+ a = lrange((2, 2), dtype='f8')
+ d = larry(np.array([0, 1, 2, 3], dtype='f8').reshape(2,2))
+ ale(a, d, "lrange failed.")
+
+ def test_lrange_4(self):
+ a = lrange([['a', 'b'], ['c', 'd']])
+ d = larry([[0, 1], [2, 3]], [['a', 'b'], ['c', 'd']])
+ ale(a, d, "lrange failed.")
+
+ def test_ones_1(self):
+ a = ones(5)
+ d = larry([1., 1., 1., 1., 1.])
+ ale(a, d, "ones failed.")
+
+ def test_ones_2(self):
+ a = ones(label=[['a', 'b', 'c', 'd']])
+ d = larry([1., 1., 1., 1.], [['a', 'b', 'c', 'd']])
+ ale(a, d, "ones failed.")
+
+ def test_ones_3(self):
+ a = ones((2, 2), dtype='i8')
+ d = larry(np.array([1., 1., 1., 1.], dtype='i8').reshape(2,2))
+ ale(a, d, "ones failed.")
+
+ def test_ones_4(self):
+ a = ones([['a', 'b'], ['c', 'd']])
+ d = larry([[1., 1.], [1., 1.]], [['a', 'b'], ['c', 'd']])
+ ale(a, d, "ones failed.")
+
+ def test_zeros_1(self):
+ a = zeros(5)
+ d = larry([0., 0., 0., 0., 0.])
+ ale(a, d, "zeros failed.")
+
+ def test_zeros_2(self):
+ a = zeros(label=[['a', 'b', 'c', 'd']])
+ d = larry([0., 0., 0., 0.], [['a', 'b', 'c', 'd']])
+ ale(a, d, "zeros failed.")
+
+ def test_zeros_3(self):
+ a = zeros((2, 2), dtype='i8')
+ d = larry(np.array([0., 0., 0., 0.], dtype='i8').reshape(2,2))
+ ale(a, d, "zeros failed.")
+
+ def test_zeros_4(self):
+ a = zeros([['a', 'b'], ['c', 'd']])
+ d = larry([[0., 0.], [0., 0.]], [['a', 'b'], ['c', 'd']])
+ ale(a, d, "zeros failed.")
+
class Test_binaryop(unittest.TestCase):
"Test la.binaryop()"
Something went wrong with that request. Please try again.