How to use the ganga.GangaCore.GPIDev.Lib.GangaList.GangaList.GangaList function in ganga

To help you get started, we’ve selected a few ganga examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / GangaList / GangaList.py View on Github external
def makeGangaListByRef(_list, preparable=False):
    """Faster version of makeGangaList. Does not make a copy of _list but use it by reference.
    Args:
        _list (list): List of objects to add to a new Ganga list
        preparable (bool): Is the new object preparable?
    """
    result = GangaList()
    # Subvert tests and modify the ._list here ourselves
    # This is potentially DANGEROUS is proxies aren't correctly stripped
    result._list.extend(_list)
    result._is_a_ref = True
    result._is_preparable = preparable
    return result
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / GangaList / GangaList.py View on Github external
def _getParent(self):
        return super(GangaList, self)._getParent()
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / GangaList / GangaList.py View on Github external
def __deepcopy__(self, memo=None):
        """Bypass any checking when making the copy"""
        #logger.info("memo: %s" % str(memo))
        #logger.info("self.len: %s" % str(len(self._list)))
        if self._list != []:
            return makeGangaListByRef(_list=copy.deepcopy(self._list, memo), preparable=self._is_preparable)
        else:
            new_list = GangaList()
            new_list._is_preparable = self._is_preparable
            return new_list
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / GangaList / GangaList.py View on Github external
def makeGangaList(_list, mapfunction=None, parent=None, preparable=False, extra_args=None):
    """Should be used for makeing full gangalists
    Args:
        _list (list): This is the iterable list object which
        mapfunction (function): This is a function used to construct new elements based upon the elements in _list
        parent (GangaObject): This is the object to assign as the parent of the new GangaList (still needed)
        preparable (bool): Is the GangaList preparable?
        extra_args (dict): When defined this contains extra args to pass to mapfunction
    """

    # work with a simple list always
    if isinstance(_list, list):
        _list = _list
    elif isinstance(_list, GangaList):
        _list = getProxyAttr(_list, '_list')
    else:
        _list = [_list]

    if mapfunction is not None:
        if extra_args is None:
            _list = [mapfunction(l) for l in _list]
        else:
            new_mapfunction = partial(mapfunction, extra_args=extra_args)
            _list = [new_mapfunction(l) for l in _list]

    result = GangaList()
    # Subvert tests and modify the ._list here ourselves
    # This is potentially DANGEROUS if proxies aren't correctly stripped
    result._list.extend([stripProxy(l) for l in _list])
    result._is_preparable = preparable
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / GangaList / GangaList.py View on Github external
def strip_proxy_list(self, obj_list, filter=False):

        if isType(obj_list, GangaList):
            return getProxyAttr(obj_list, '_list')
        result = [self.strip_proxy(l, filter=filter) for l in obj_list]
        return result
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / GangaList / GangaList.py View on Github external
def is_list(obj):
        """
        This returns a boolean as to if this object is a list or not
        Args:
            obj (object): object to be tested against known list types
        """
        result = (obj is not None) and isType(obj, (GangaList, list, tuple))
        return result
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / GangaList / GangaList.py View on Github external
# work with a simple list always
    if isinstance(_list, list):
        _list = _list
    elif isinstance(_list, GangaList):
        _list = getProxyAttr(_list, '_list')
    else:
        _list = [_list]

    if mapfunction is not None:
        if extra_args is None:
            _list = [mapfunction(l) for l in _list]
        else:
            new_mapfunction = partial(mapfunction, extra_args=extra_args)
            _list = [new_mapfunction(l) for l in _list]

    result = GangaList()
    # Subvert tests and modify the ._list here ourselves
    # This is potentially DANGEROUS if proxies aren't correctly stripped
    result._list.extend([stripProxy(l) for l in _list])
    result._is_preparable = preparable
    result._is_a_ref = False

    # set the parent if possible
    if parent is not None:
        result._setParent(parent)

    return result