How to use the varname.varname function in varname

To help you get started, we’ve selected a few varname 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 pwwang / PyPPL / pyppl / procset.py View on Github external
def copy(self, id=None, tag=None, depends=True):
        """@API
        Like `proc`'s `copy` function, copy a procset.
        Each processes will be copied.
        @params:
            id (str): Use a different id if you don't
                want to use the variant name
            tag (str): The new tag of all copied processes
            depends (bool): Whether to copy the dependencies or not.
                Default: True
                - dependences for processes in starts will not be copied
        @returns:
            (ProcSet): The new procset
        """
        id = id or varname()
        ret = self.__class__(*self.procs.values(),
                             id=id,
                             tag=tag,
                             copy=True,
                             depends=False)

        if depends:
            for proc in ret.procs.values():
                proc.depends = [
                    ret.procs[dep.id] if dep is self.procs[dep.id] else dep
                    for dep in self.procs[proc.id].depends
                ]

            ret.starts.add(Proxy(ret.procs[proc.id] for proc in self.starts))
            ret.ends.add(Proxy(ret.procs[proc.id] for proc in self.ends))
github pwwang / PyPPL / pyppl / procset.py View on Github external
def __init__(self, *procs, id=None, tag=None, copy=True, depends=True):
        """@API
        Constructor
        @params:
            *procs (Proc) : the set of processes
            **kwargs: Other arguments to instantiate a `ProcSet`
                depends (bool): Whether auto deduce depends.
                    Default: `True`
                id (str): The id of the procset.
                    Default: `None` (the variable name)
                tag (str): The tag of the processes. Default: `None`
                copy (bool): Whether copy the processes or just use them.
                    Default: `True`
        """

        self.__dict__['id'] = id or varname()
        self.__dict__['tag'] = tag
        self.__dict__['starts'] = Proxy()
        self.__dict__['ends'] = Proxy()
        self.__dict__['delegates'] = OrderedDiot(diot_nest=False)
        self.__dict__['procs'] = OrderedDiot(diot_nest=False)
        self.__dict__['modules'] = Diot(diot_nest=False)
        # save initial states before a module is called
        # states will be resumed before each module is called
        self.__dict__['initials'] = Diot(diot_nest=False)

        prevproc = None
        for proc in procs:
            assert hasattr(proc, 'id') and hasattr(proc, 'tag'), (
                'Argument has to be a Proc object: %r.' % proc
            )
            if copy:
github pwwang / PyPPL / pyppl / proc.py View on Github external
def copy(self, id=None, **kwargs):  # pylint: disable=redefined-builtin, invalid-name
        """@API
        Copy a process to a new one
        Depends and nexts will be copied
        @params:
            id: The id of the new process
            kwargs: Other arguments for constructing a process
        """
        newid = id or varname()
        raw_attrs = {key: try_deepcopy(value)
                     for key, value in self.__attrs_property_raw__.items()
                     if key not in ('input', 'id', 'channel', 'jobs',
                                    'runtime_config', 'depends', 'nexts')}
        # attr.ib not in __attrs_property_raw__
        raw_attrs.update({
            # only keep the keys of input
            'input': (','.join(self._input)
                      if isinstance(self._input, list)
                      else ','.join(self._input.keys())
                      if isinstance(self._input, dict)
                      else self._input),
            'desc': self.desc,
            'envs': try_deepcopy(self.envs),
            'nthread': self.nthread,
        })
github pwwang / PyPPL / pyppl / proc.py View on Github external
        default=attr.Factory(lambda: varname(caller=2)),
        repr=False,

varname

Dark magics about variable names in python.

MIT
Latest version published 2 months ago

Package Health Score

71 / 100
Full package analysis

Popular varname functions

Similar packages