text stringlengths 0 828 |
|---|
:param oldList: [[paramList, paramList, ...], ...] |
:returns: [[paramTuple, paramTuple, ...], ...] |
"""""" |
newList = list() |
for oldParamList in oldList: |
newParamLIst = [tuple(param) for param in oldParamList] |
newList.append(newParamLIst) |
return newList" |
1923,"def addMsrunContainers(mainContainer, subContainer): |
""""""Adds the complete content of all specfile entries from the subContainer |
to the mainContainer. However if a specfile of ``subContainer.info`` is |
already present in ``mainContainer.info`` its contents are not added to the |
mainContainer. |
:param mainContainer: :class:`MsrunContainer` |
:param subContainer: :class:`MsrunContainer` |
.. warning:: does not generate new items, all items added to the |
``mainContainer`` are still present in the ``subContainer`` and changes |
made to elements of one container also affects the elements of the other |
one (ie elements share same memory location). |
"""""" |
typeToContainer = {'rm': 'rmc', 'ci': 'cic', 'smi': 'smic', |
'sai': 'saic', 'si': 'sic' |
} |
for specfile in subContainer.info: |
if specfile in mainContainer.info: |
continue |
mainContainer.addSpecfile(specfile, subContainer.info[specfile]['path']) |
for datatype, status in listitems(subContainer.info[specfile]['status']): |
if not status: |
continue |
datatypeContainer = typeToContainer[datatype] |
dataTypeContainer = getattr(mainContainer, datatypeContainer) |
subContainerData = getattr(subContainer, |
datatypeContainer |
)[specfile] |
dataTypeContainer[specfile] = subContainerData |
mainContainer.info[specfile]['status'][datatype] = True" |
1924,"def getArrays(self, attr=None, specfiles=None, sort=False, reverse=False, |
selector=None, defaultValue=None): |
""""""Return a condensed array of data selected from :class:`Si` instances |
from ``self.sic`` for fast and convenient data processing. |
:param attr: list of :class:`Si` item attributes that should be added to |
the returned array. The attributes ""id"" and ""specfile"" are always |
included, in combination they serve as a unique id. |
:param defaultValue: if an item is missing an attribute, the |
""defaultValue"" is added to the array instead. |
:param specfiles: filenames of ms-run files, if specified return only |
items from those files |
:type specfiles: str or [str, str, ...] |
:param sort: if ""sort"" is specified the returned list of items is sorted |
according to the :class:`Si` attribute specified by ""sort"", if the |
attribute is not present the item is skipped. |
:param reverse: bool, set True to reverse sort order |
:param selector: a function which is called with each :class:`Si` item |
and has to return True (include item) or False (discard item). |
Default function is: ``lambda si: True`` |
:returns: {'attribute1': numpy.array(), |
'attribute2': numpy.array(), |
... |
} |
"""""" |
selector = (lambda si: True) if selector is None else selector |
attr = attr if attr is not None else [] |
attr = set(['id', 'specfile'] + aux.toList(attr)) |
items = self.getItems(specfiles, sort, reverse, selector) |
return _getArrays(items, attr, defaultValue)" |
1925,"def getItems(self, specfiles=None, sort=False, reverse=False, |
selector=None): |
""""""Generator that yields filtered and/or sorted :class:`Si` instances |
from ``self.sic``. |
:param specfiles: filenames of ms-run files - if specified return only |
items from those files |
:type specfiles: str or [str, str, ...] |
:param sort: if ""sort"" is specified the returned list of items is sorted |
according to the :class:`Si` attribute specified by ""sort"", if the |
attribute is not present the item is skipped. |
:param reverse: bool, ``True`` reverses the sort order |
:param selector: a function which is called with each ``Si`` item |
and returns True (include item) or False (discard item). Default |
function is: ``lambda si: True`` |
:returns: items from container that passed the selector function |
"""""" |
selector = (lambda si: True) if selector is None else selector |
if specfiles is None: |
specfiles = [_ for _ in viewkeys(self.info)] |
else: |
specfiles = aux.toList(specfiles) |
return _getItems(self.sic, specfiles, sort, reverse, selector)" |
1926,"def addSpecfile(self, specfiles, path): |
""""""Prepares the container for loading ``mrc`` files by adding specfile |
entries to ``self.info``. Use :func:`MsrunContainer.load()` afterwards |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.