The version of the carray package.
The minimum version of numexpr needed (numexpr is optional).
The number of cores detected.
Whether minimum version of numexpr has been detected.
Class to host parameters for compression and other filters.
Return a string representation of a carray/ctable object.
This is the same function than in NumPy. Please refer to NumPy documentation for more info.
Return evenly spaced values within a given interval.
Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). For integer arguments the function is equivalent to the Python built-in range function, but returns a carray rather than a list.
Array of evenly spaced values.
For floating point arguments, the length of the result is ceil((stop - start)/step). Because of floating point overflow, this rule may result in the last element of out being greater than stop.
Evaluate an expression and return the result.
Return a new carray object of given shape and type, filled with dflt.
Create a carray/ctable from an iterable object.
Return a new carray object of given shape and type, filled with ones.
Return the current print options.
This is the same function than in NumPy. For more info, please refer to the NumPy documentation.
Open a disk-based carray/ctable.
Specifies the mode in which the object is opened. The supported values are:
- ‘r’ for read-only
- ‘w’ for emptying the previous underlying data
- ‘a’ for allowing read/write on top of existing data
Set printing options.
These options determine the way floating point numbers in carray objects are displayed. This is the same function than in NumPy. For more info, please refer to the NumPy documentation.
Return a new carray object of given shape and type, filled with zeros.
Recursively iterate over carray/ctable objects hanging from dir.
Sets the number of threads that Blosc can use.
Return the version of the Blosc library.
Return the number of cores on a system.
Sets the number of threads to be used during carray operation.
This affects to both Blosc and Numexpr (if available).
Run all the tests in the test suite.
If verbose is set, the test suite will emit messages with full verbosity (not recommended unless you are looking into a certain problem).
If heavy is set, the test suite will be run in heavy mode (you should be careful with this because it can take a lot of time and resources from your computer).
A compressed and enlargeable in-memory data container.
carray exposes a series of methods for dealing with the compressed container in a NumPy-like way.
The mode that a persistent carray should be created/opened. The values can be:
- ‘r’ for read-only
- ‘w’ for read/write. During carray creation, the rootdir will be removed if it exists. During carray opening, the carray will be resized to 0.
- ‘a’ for append (possible data inside rootdir will not be removed).
- attrs¶
Accessor for attributes in carray objects.
This class behaves very similarly to a dictionary, and attributes can be appended in the typical way:
attrs['myattr'] = valueAnd can be retrieved similarly:
value = attrs['myattr']Attributes can be removed with:
del attrs['myattr']This class also honors the __iter__ and __len__ special functions. Moreover, a getall() method returns all the attributes as a dictionary.
CAVEAT: The values should be able to be serialized with JSON for persistence.
- cbytes¶
The compressed size of this object (in bytes).
- chunklen¶
The number of items that fits into a chunk.
- cparams
The compression parameters for this object.
- dflt¶
The value to be used when enlarging the carray.
- dtype¶
The NumPy dtype for this object.
- len¶
The length of this object.
- nbytes¶
The original (uncompressed) size of this object (in bytes).
- ndim¶
The number of dimensions of this object (in bytes).
- shape¶
The shape of this object.
- size¶
The size of this object.
- append(array)¶
Append a numpy array to this instance.
- Parameters:
- array : NumPy-like object
- The array to be appended. Must be compatible with shape and type of the carray.
- copy(**kwargs)¶
Return a copy of this object.
- Parameters:
- kwargs : list of parameters or dictionary
- Any parameter supported by the carray constructor.
- Returns:
- out : carray object
- The copy of this object.
- flush()¶
Flush data in internal buffers to disk.
This call should typically be done after performing modifications (__settitem__(), append()) in persistence mode. If you don’t do this, you risk loosing part of your modifications.
- iter(start=0, stop=None, step=1, limit=None, skip=0)¶
Iterator with start, stop and step bounds.
- Parameters:
- start : int
- The starting item.
- stop : int
- The item after which the iterator stops.
- step : int
- The number of items incremented during each iteration. Cannot be negative.
- limit : int
- A maximum number of elements to return. The default is return everything.
- skip : int
- An initial number of elements to skip. The default is 0.
- Returns:
- out : iterator
- See Also:
- where(), wheretrue()
- reshape(newshape)¶
Returns a new carray containing the same data with a new shape.
- Parameters:
- newshape : int or tuple of ints
- The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.
- Returns:
- reshaped_array : carray
- A copy of the original carray.
- resize(nitems)¶
Resize the instance to have nitems.
- Parameters:
- nitems : int
- The final length of the object. If nitems is larger than the actual length, new items will appended using self.dflt as filling values.
- sum(dtype=None)¶
Return the sum of the array elements.
- Parameters:
- dtype : NumPy dtype
- The desired type of the output. If None, the dtype of self is used. An exception is when self has an integer type with less precision than the default platform integer. In that case, the default platform integer is used instead (NumPy convention).
- Return value:
- out : NumPy scalar with dtype
- trim(nitems)¶
Remove the trailing nitems from this instance.
- Parameters:
- nitems : int
- The number of trailing items to be trimmed.
- See Also:
- append()
- where(boolarr, limit=None, skip=0)¶
Iterator that returns values of this object where boolarr is true.
This is currently only useful for boolean carrays that are unidimensional.
- Parameters:
- boolarr : a carray or NumPy array of boolean type
- The boolean values.
- limit : int
- A maximum number of elements to return. The default is return everything.
- skip : int
- An initial number of elements to skip. The default is 0.
- Returns:
- out : iterator
- See Also:
- iter(), wheretrue()
- wheretrue(limit=None, skip=0)¶
Iterator that returns indices where this object is true.
This is currently only useful for boolean carrays that are unidimensional.
- __getitem__(key):
x.__getitem__(key) <==> x[key]
Returns values based on key. All the functionality of ndarray.__getitem__() is supported (including fancy indexing), plus a special support for expressions:
- Parameters:
- key : string
- It will be interpret as a boolean expression (computed via eval) and the elements where these values are true will be returned as a NumPy array.
- See Also:
- eval
- __setitem__(key, value):
x.__setitem__(key, value) <==> x[key] = value
Sets values based on key. All the functionality of ndarray.__setitem__() is supported (including fancy indexing), plus a special support for expressions:
- Parameters:
- key : string
- It will be interpret as a boolean expression (computed via eval) and the elements where these values are true will be set to value.
- See Also:
- eval
This class represents a compressed, column-wise, in-memory table.
Create a new ctable from columns with optional names.
- attrs
Accessor for attributes in ctable objects.
See carray.attrs for a full description.
- cbytes
The compressed size of this object (in bytes).
- cols¶
The ctable columns accessor.
- cparams
The compression parameters for this object.
- dtype
The NumPy dtype for this object.
- len
The length of this object.
- names¶
The names of the columns (list).
- nbytes
The original (uncompressed) size of this object (in bytes).
- ndim
The number of dimensions of this object (in bytes).
- shape
The shape of this object.
- size
The size of this object.
- addcol(newcol, name=None, pos=None, **kwargs)¶
Add a new newcol object as column.
- Parameters:
- newcol : carray, ndarray, list or tuple
- If a carray is passed, no conversion will be carried out. If conversion to a carray has to be done, kwargs will apply.
- name : string, optional
- The name for the new column. If not passed, it will receive an automatic name.
- pos : int, optional
- The column position. If not passed, it will be appended at the end.
- kwargs : list of parameters or dictionary
- Any parameter supported by the carray constructor.
- Notes:
- You should not specify both name and pos arguments, unless they are compatible.
- See Also:
- delcol()
- append(rows)
Append rows to this ctable.
- Parameters:
- rows : list/tuple of scalar values, NumPy arrays or carrays
- It also can be a NumPy record, a NumPy recarray, or another ctable.
- copy(**kwargs)
Return a copy of this ctable.
- Parameters:
- kwargs : list of parameters or dictionary
- Any parameter supported by the carray/ctable constructor.
- Returns:
- out : ctable object
- The copy of this ctable.
- delcol(name=None, pos=None)¶
Remove the column named name or in position pos.
- Parameters:
- name: string, optional
- The name of the column to remove.
- pos: int, optional
- The position of the column to remove.
- Notes:
- You must specify at least a name or a pos. You should not specify both name and pos arguments, unless they are compatible.
- See Also:
- addcol()
- eval(expression, **kwargs)
Evaluate the expression on columns and return the result.
- Parameters:
- expression : string
- A string forming an expression, like ‘2*a+3*b’. The values for ‘a’ and ‘b’ are variable names to be taken from the calling function’s frame. These variables may be column names in this table, scalars, carrays or NumPy arrays.
- kwargs : list of parameters or dictionary
- Any parameter supported by the eval() top level function.
- Returns:
- out : carray object
- The outcome of the expression. You can tailor the properties of this carray by passing additional arguments supported by carray constructor in kwargs.
- See Also:
- eval() (top level function)
- flush()
Flush data in internal buffers to disk.
This call should typically be done after performing modifications (__settitem__(), append()) in persistence mode. If you don’t do this, you risk loosing part of your modifications.
- iter(start=0, stop=None, step=1, outcols=None, limit=None, skip=0)
Iterator with start, stop and step bounds.
- Parameters:
- start : int
- The starting item.
- stop : int
- The item after which the iterator stops.
- step : int
- The number of items incremented during each iteration. Cannot be negative.
- outcols : list of strings or string
- The list of column names that you want to get back in results. Alternatively, it can be specified as a string such as ‘f0 f1’ or ‘f0, f1’. If None, all the columns are returned. If the special name ‘nrow__‘ is present, the number of row will be included in output.
- limit : int
- A maximum number of elements to return. The default is return everything.
- skip : int
- An initial number of elements to skip. The default is 0.
- Returns:
- out : iterable
- See Also:
- ctable.where()
- resize(nitems)
Resize the instance to have nitems.
- Parameters:
- nitems : int
- The final length of the instance. If nitems is larger than the actual length, new items will appended using self.dflt as filling values.
- trim(nitems)
Remove the trailing nitems from this instance.
- Parameters:
- nitems : int
- The number of trailing items to be trimmed.
- See Also:
- ctable.append()
- where(expression, outcols=None, limit=None, skip=0)
Iterate over rows where expression is true.
- Parameters:
- expression : string or carray
- A boolean Numexpr expression or a boolean carray.
- outcols : list of strings or string
- The list of column names that you want to get back in results. Alternatively, it can be specified as a string such as ‘f0 f1’ or ‘f0, f1’. If None, all the columns are returned. If the special name ‘nrow__‘ is present, the number of row will be included in output.
- limit : int
- A maximum number of elements to return. The default is return everything.
- skip : int
- An initial number of elements to skip. The default is 0.
- Returns:
- out : iterable
- This iterable returns rows as NumPy structured types (i.e. they support being mapped either by position or by name).
- See Also:
- ctable.iter()
- __getitem__(key):
x.__getitem__(y) <==> x[y]
Returns values based on key. All the functionality of ndarray.__getitem__() is supported (including fancy indexing), plus a special support for expressions:
- Parameters:
- key : string
- The corresponding ctable column name will be returned. If not a column name, it will be interpret as a boolean expression (computed via ctable.eval) and the rows where these values are true will be returned as a NumPy structured array.
- See Also:
- ctable.eval()
- __setitem__(key, value):
x.__setitem__(key, value) <==> x[key] = value
Sets values based on key. All the functionality of ndarray.__setitem__() is supported (including fancy indexing), plus a special support for expressions:
- Parameters:
- key : string
- The corresponding ctable column name will be set to value. If not a column name, it will be interpret as a boolean expression (computed via ctable.eval) and the rows where these values are true will be set to value.
- See Also:
- ctable.eval()