larray.Session

class larray.Session(*args, meta=None, **kwargs)[source]

Groups several objects together.

Parameters
*argsstr or dict of {str: object} or iterable of tuples (str, object)

Path to the file containing the session to load or list/tuple/dictionary containing couples (name, object).

**kwargsdict of {str: object}
  • Objects to add written as name=object

  • metalist of pairs or dict or Metadata

    Metadata (title, description, author, creation_date, …) associated with the array. Keys must be strings. Values must be of type string, int, float, date, time or datetime.

Warning

Metadata is not kept when actions or methods are applied on a session except for operations modifying a specific array, such as: s[‘arr1’] = 0. Do not add metadata to a session if you know you will apply actions or methods on it before dumping it.

Examples

>>> # scalars
>>> i, s = 5, 'string'
>>> # axes
>>> a, b = Axis("a=a0..a2"), Axis("b=b0..b2")
>>> # groups
>>> a01 = a['a0,a1'] >> 'a01'
>>> # arrays
>>> arr1, arr2 = ndtest((a, b)), ndtest(a)

create a Session by passing a list of pairs (name, object)

>>> ses = Session([('i', i), ('s', s), ('a', a), ('b', b), ('a01', a01),
...                ('arr1', arr1), ('arr2', arr2)])

create a Session using keyword arguments

>>> ses = Session(i=i, s=s, a=a, b=b, a01=a01, arr1=arr1, arr2=arr2)

create a Session by passing a dictionary

>>> ses = Session({'i': i, 's': s, 'a': a, 'b': b, 'a01': a01, 'arr1': arr1, 'arr2': arr2})

load Session from file

>>> ses = Session('my_session.h5')  

create a session with metadata

>>> ses = Session(arr1=arr1, arr2=arr2, meta=Metadata(title='my title', author='John Smith'))
>>> ses.meta
title: my title
author: John Smith
__init__(*args, meta=None, **kwargs)[source]

Methods

__init__(*args[, meta])

add(*args, **kwargs)

Deprecated.

apply(func, *args[, kind])

Apply function func on elements of the session and return a new session.

array_equals(**kwargs)

compact([display])

Detect and remove "useless" axes (ie axes for which values are constant over the whole axis) for all array objects in session.

copy()

Return a copy of the session.

dump(**kwargs)

dump_csv(**kwargs)

dump_excel(**kwargs)

dump_hdf(**kwargs)

element_equals(other[, rtol, atol, nans_equal])

Test if each element (group, axis and array) of the current session equals the corresponding element of another session.

equals(other[, rtol, atol, nans_equal])

Test if all elements (groups, axes and arrays) of the current session are equal to those of another session.

filter([pattern, kind])

Return a new session with objects which match some criteria.

get(key[, default])

Return the object corresponding to the key.

items()

Return a view of the session's items ((key, value) pairs).

keys()

Return a view on the session's keys.

load(fname[, names, engine, display])

Load objects from a file, or several .csv files.

save(fname[, names, engine, overwrite, display])

Dump objects from the current session to a file, or several .csv files.

summary([template])

Return a summary of the content of the session.

to_csv(fname[, names, display])

Dump Array objects from the current session to CSV files.

to_excel(fname[, names, overwrite, display])

Dump Array objects from the current session to an Excel file.

to_globals([names, depth, warn, inplace])

Create global variables out of objects in the session.

to_hdf(fname[, names, overwrite, display])

Dump objects from the current session to an HDF file.

to_pickle(fname[, names, overwrite, display])

Dump objects from the current session to a file using pickle.

transpose(*args)

Reorder axes of arrays in session, ignoring missing axes for each array.

update([other])

Update the session with the key/value pairs from other or passed keyword arguments, overwriting existing keys.

values()

Return a view on the session's values.

Attributes

memory_used

Return the memory consumed by the session in human readable form.

meta

Return metadata of the session.

names

Return the list of names of the objects in the session.

nbytes

Return the memory in bytes consumed by the session.