Package parsimony :: Package utils :: Module check_arrays'
[hide private]
[frames] | no frames]

Module check_arrays'

source code

Created on Mon Jul 29 17:37:17 2013

Copyright (c) 2013-2014, CEA/DSV/I2BM/Neurospin. All rights reserved.


Author: Edouard Duchesnay

License: BSD 3-clause.

Functions [hide private]
 
check_arrays(*arrays)
Checks that: - Lists are converted to numpy arrays.
source code
Variables [hide private]
  __package__ = 'parsimony.utils'
Function Details [hide private]

check_arrays(*arrays)

source code 
Checks that:
    - Lists are converted to numpy arrays.
    - All arrays are cast to float.
    - All arrays have consistent first dimensions.
    - Arrays are at least 2D arrays, if not they are reshaped.

Parameters
----------
*arrays: Sequence of arrays or scipy.sparse matrices with same shape[0]
        Python lists or tuples occurring in arrays are converted to 2D
        numpy arrays.

Examples
--------
>>> import numpy as np
>>> check_arrays([1, 2], np.array([3, 4]), np.array([[1., 2.], [3., 4.]]))
[array([[ 1.],
       [ 2.]]), array([[ 3.],
       [ 4.]]), array([[ 1.,  2.],
       [ 3.,  4.]])]