Return the subset of `kwargs` values (not keys!) matching
        a `meta` column name
333538
def _discover_meta_cols(self, **kwargs):
        """"""
        cols = set(['exclude'])
        for arg, value in kwargs.items():
            if isstr(value) and value in self.meta.columns:
                cols.add(value)
        return list(cols)
866859
def meta(cls):
        """"""
        if getattr(cls, '__from_class__', None) is not None:
            cls = cls.__from_class__
        attribute_info = {}
        for name, value in cls.__table__.columns.items():
            attribute_info[name] = str(value.type).lower()

        return {cls.__name__: attribute_info}
176504
def get_nested_relation_kwargs(field_name, relation_info):
    
    kwargs = get_relation_kwargs(field_name, relation_info)
    kwargs.pop('queryset')
    kwargs.pop('required')
    kwargs['read_only'] = True
    return kwargs
376708
def _kwargs_from_dict(cls, a_dict: dict) -> dict:
        
        from .binnings import BinningBase
        kwargs = {
            "binnings": [BinningBase.from_dict(binning_data) for binning_data in a_dict["binnings"]],
            "dtype": np.dtype(a_dict["dtype"]),
            "frequencies": a_dict.get("frequencies"),
            "errors2": a_dict.get("errors2"),
        }
        if "missed" in a_dict:
            kwargs["missed"] = a_dict["missed"]
        kwargs.update(a_dict.get("meta_data", {}))
        if len(kwargs["binnings"]) > 2:
            kwargs["dimension"] = len(kwargs["binnings"])
        return kwargs
1215897
def widget_kwargs_for_field(self, field_name):
        
        if self._meta.widgets:
            return self._meta.widgets.get(field_name, {})
        return {}
1242899
def kwargs(self):
        
        keywords = self.keywords or []
        return [keyword for keyword in keywords if keyword.arg is None]
1366617
def filter_match_kwargs(kwargs, children=False):
    
    kwargs = kwargs.copy()
    for key in ('pattern', 'start', 'end', 'parent', 'formatter', 'value'):
        if key in kwargs:
            del kwargs[key]
    if children:
        for key in ('name',):
            if key in kwargs:
                del kwargs[key]
    return kwargs
445776
def kwargstr(self):
		''''''
		temp = [' [--' + k + (' ' + str(v) if v is not False else '') + ']' for k, v in self.defaults.items()]
		return ''.join(temp)
193342
def get_values(self, set, selected_meta):
        
        warnings.warn("\n\nThis method assumes that the last level of the index is the sample_id.\n"
                      "In case of single index, the index itself should be the sample_id")
        sample_ids = set.index.get_level_values(-1)
        corresponding_meta = self.meta.loc[sample_ids]
        values = corresponding_meta[selected_meta]

        try:
            values = values.astype(float)
        except ValueError:
            print("the values should be numeric")
        return values
782338
def _system_parameters(**kwargs):
    
    return {key: value for key, value in kwargs.items()
            if (value is not None or value == {})}
1156652
def tables_for_meta(meta):
    
    allegedb.alchemy.tables_for_meta(meta)

    # Table for global variables that are not sensitive to sim-time.
    Table(
        'universals', meta,
        Column('key', TEXT, primary_key=True),
        Column(
            'branch', TEXT, primary_key=True, default='trunk'
        ),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT, primary_key=True, default=0),
        Column('value', TEXT)
    )

    Table(
        'rules', meta,
        Column('rule', TEXT, primary_key=True)
    )

    # Table grouping rules into lists called rulebooks.
    Table(
        'rulebooks', meta,
        Column('rulebook', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT, primary_key=True, default=0),
        Column('rules', TEXT, default='[]')
    )

    # Table for rules' triggers, those functions that return True only
    # when their rule should run (or at least check its prereqs).
    Table(
        'rule_triggers', meta,
        Column('rule', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT, primary_key=True, default=0),
        Column('triggers', TEXT, default='[]'),
        ForeignKeyConstraint(
            ['rule'], ['rules.rule']
        )
    )

    # Table for rules' prereqs, functions with veto power over a rule
    # being followed
    Table(
        'rule_prereqs', meta,
        Column('rule', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT, primary_key=True, default=0),
        Column('prereqs', TEXT, default='[]'),
        ForeignKeyConstraint(
            ['rule'], ['rules.rule']
        )
    )

    # Table for rules' actions, the functions that do what the rule
    # does.
    Table(
        'rule_actions', meta,
        Column('rule', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT, primary_key=True, default=0),
        Column('actions', TEXT, default='[]'),
        ForeignKeyConstraint(
            ['rule'], ['rules.rule']
        )
    )

    # The top level of the LiSE world model, the character. Includes
    # rulebooks for the character itself, its avatars, and all the things,
    # places, and portals it contains--though those may have their own
    # rulebooks as well.

    for name in (
        'character_rulebook',
        'avatar_rulebook',
        'character_thing_rulebook',
        'character_place_rulebook',
        'character_portal_rulebook'
    ):
        Table(
            name, meta,
            Column('character', TEXT, primary_key=True),
            Column('branch', TEXT, primary_key=True, default='trunk'),
            Column('turn', INT, primary_key=True, default=0),
            Column('tick', INT, primary_key=True, default=0),
            Column('rulebook', TEXT),
            ForeignKeyConstraint(
                ['character'], ['graphs.graph']
            ),
            ForeignKeyConstraint(
                ['rulebook'], ['rulebooks.rulebook']
            )
        )

    # Rules handled within the rulebook associated with one node in
    # particular.
    nrh = Table(
        'node_rules_handled', meta,
        Column('character', TEXT, primary_key=True),
        Column('node', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT),
        ForeignKeyConstraint(
            ['character', 'node'], ['nodes.graph', 'nodes.node']
        )
    )

    Table(
        'node_rules_changes', meta,
        Column('character', TEXT, primary_key=True),
        Column('node', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True),
        Column('turn', INT, primary_key=True),
        Column('tick', INT, primary_key=True),
        Column('handled_branch', TEXT),
        Column('handled_turn', INT),
        ForeignKeyConstraint(
            ['character', 'node', 'rulebook', 'rule', 'handled_branch', 'handled_turn'],
            [nrh.c.character, nrh.c.node, nrh.c.rulebook, nrh.c.rule, nrh.c.branch, nrh.c.turn]
        )
    )

    # Rules handled within the rulebook associated with one portal in
    # particular.
    porh = Table(
        'portal_rules_handled', meta,
        Column('character', TEXT, primary_key=True),
        Column('orig', TEXT, primary_key=True),
        Column('dest', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT),
        ForeignKeyConstraint(
            ['character', 'orig', 'dest'], ['edges.graph', 'edges.orig', 'edges.dest']
        )
    )

    Table(
        'portal_rules_changes', meta,
        Column('character', TEXT, primary_key=True),
        Column('orig', TEXT, primary_key=True),
        Column('dest', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True),
        Column('turn', INT, primary_key=True),
        Column('tick', INT, primary_key=True),
        Column('handled_branch', TEXT),
        Column('handled_turn', INT),
        ForeignKeyConstraint(
            ['character', 'orig', 'dest', 'rulebook', 'rule', 'handled_branch', 'handled_turn'],
            [porh.c.character, porh.c.orig, porh.c.dest, porh.c.rulebook, porh.c.rule, porh.c.branch, porh.c.turn]
        )
    )

    # The function to use for a given sense.
    #
    # Characters use senses to look at other characters. To model this,
    # sense functions are called with a facade representing the
    # character under observation; the function munges this facade to
    # make it look as it does through the sense in question, and returns
    # that.
    Table(
        'senses', meta,
        # null character field means all characters have this sense
        Column(
            'character', TEXT, primary_key=True, nullable=True
        ),
        Column('sense', TEXT, primary_key=True),
        Column(
            'branch', TEXT, primary_key=True, default='trunk'
        ),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT, primary_key=True, default=0),
        Column('function', TEXT, nullable=True),
        ForeignKeyConstraint(['character'], ['graphs.graph'])
    )

    # Table for Things, being those nodes in a Character graph that have
    # locations.
    #
    # A Thing's location can be either a Place or another Thing, as long
    # as it's in the same Character.
    Table(
        'things', meta,
        Column('character', TEXT, primary_key=True),
        Column('thing', TEXT, primary_key=True),
        Column(
            'branch', TEXT, primary_key=True, default='trunk'
        ),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT, primary_key=True, default=0),
        # when location is null, this node is not a thing, but a place
        Column('location', TEXT),
        ForeignKeyConstraint(
            ['character', 'thing'], ['nodes.graph', 'nodes.node']
        ),
        ForeignKeyConstraint(
            ['character', 'location'], ['nodes.graph', 'nodes.node']
        )
    )

    # The rulebook followed by a given node.
    Table(
        'node_rulebook', meta,
        Column('character', TEXT, primary_key=True),
        Column('node', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT, primary_key=True, default=0),
        Column('rulebook', TEXT),
        ForeignKeyConstraint(
            ['character', 'node'], ['nodes.graph', 'nodes.node']
        )
    )

    # The rulebook followed by a given Portal.
    #
    # "Portal" is LiSE's term for an edge in any of the directed
    # graphs it uses. The name is different to distinguish them from
    # Edge objects, which exist in an underlying object-relational
    # mapper called allegedb, and have a different API.
    Table(
        'portal_rulebook', meta,
        Column('character', TEXT, primary_key=True),
        Column('orig', TEXT, primary_key=True),
        Column('dest', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT, primary_key=True, default=0),
        Column('rulebook', TEXT),
        ForeignKeyConstraint(
            ['character', 'orig', 'dest'],
            ['edges.graph', 'edges.orig', 'edges.dest']
        )
    )

    # The avatars representing one Character in another.
    #
    # In the common situation where a Character, let's say Alice has her
    # own stats and skill tree and social graph, and also has a location
    # in physical space, you can represent this by creating a Thing in
    # the Character that represents physical space, and then making that
    # Thing an avatar of Alice. On its own this doesn't do anything,
    # it's just a convenient way of indicating the relation -- but if
    # you like, you can make rules that affect all avatars of some
    # Character, irrespective of what Character the avatar is actually
    # *in*.
    Table(
        'avatars', meta,
        Column('character_graph', TEXT, primary_key=True),
        Column('avatar_graph', TEXT, primary_key=True),
        Column('avatar_node', TEXT, primary_key=True),
        Column(
            'branch', TEXT, primary_key=True, default='trunk'
        ),
        Column('turn', INT, primary_key=True, default=0),
        Column('tick', INT, primary_key=True, default=0),
        Column('is_avatar', BOOLEAN),
        ForeignKeyConstraint(['character_graph'], ['graphs.graph']),
        ForeignKeyConstraint(
            ['avatar_graph', 'avatar_node'],
            ['nodes.graph', 'nodes.node']
        )
    )

    crh = Table(
        'character_rules_handled', meta,
        Column('character', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True),
        Column('tick', INT),
        ForeignKeyConstraint(
            ['character', 'rulebook'], ['character_rulebook.character', 'character_rulebook.rulebook']
        )
    )

    Table(
        'character_rules_changes', meta,
        Column('character', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True),
        Column('turn', INT, primary_key=True),
        Column('tick', INT, primary_key=True),
        Column('handled_branch', TEXT),
        Column('handled_turn', TEXT),
        ForeignKeyConstraint(
            ['character', 'rulebook', 'rule', 'handled_branch', 'handled_turn'],
            [crh.c.character, crh.c.rulebook, crh.c.rule, crh.c.branch, crh.c.turn]
        )
    )

    arh = Table(
        'avatar_rules_handled', meta,
        Column('character', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('graph', TEXT, primary_key=True),
        Column('avatar', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True),
        Column('tick', INT),
        ForeignKeyConstraint(
            ['character', 'rulebook'], ['avatar_rulebook.character', 'avatar_rulebook.rulebook']
        )
    )

    Table(
        'avatar_rules_changes', meta,
        Column('character', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('graph', TEXT, primary_key=True),
        Column('avatar', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True),
        Column('turn', INT, primary_key=True),
        Column('tick', INT, primary_key=True),
        Column('handled_branch', TEXT),
        Column('handled_turn', TEXT),
        ForeignKeyConstraint(
            ['character', 'rulebook', 'rule', 'graph', 'avatar', 'handled_branch', 'handled_turn'],
            [arh.c.character, arh.c.rulebook, arh.c.rule, arh.c.graph, arh.c.avatar, arh.c.branch, arh.c.turn]
        )
    )

    ctrh = Table(
        'character_thing_rules_handled', meta,
        Column('character', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('thing', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True),
        Column('tick', INT),
        ForeignKeyConstraint(
            ['character', 'rulebook'], ['character_thing_rulebook.character', 'character_thing_rulebook.rulebook']
        ),
        ForeignKeyConstraint(
            ['character', 'thing'], ['things.character', 'things.thing']
        )
    )

    Table(
        'character_thing_rules_changes', meta,
        Column('character', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('thing', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True),
        Column('turn', INT, primary_key=True),
        Column('tick', INT, primary_key=True),
        Column('handled_branch', TEXT),
        Column('handled_turn', INT),
        ForeignKeyConstraint(
            ['character', 'rulebook', 'rule', 'thing', 'handled_branch', 'handled_turn'],
            [ctrh.c.character, ctrh.c.rulebook, ctrh.c.rule, ctrh.c.thing, ctrh.c.branch, ctrh.c.turn]
        )
    )

    cprh = Table(
        'character_place_rules_handled', meta,
        Column('character', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('place', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True),
        Column('tick', INT),
        ForeignKeyConstraint(
            ['character', 'rulebook'], ['character_place_rulebook.character', 'character_place_rulebook.rulebook']
        ),
        ForeignKeyConstraint(
            ['character', 'place'], ['nodes.graph', 'nodes.node']
        )
    )

    Table(
        'character_place_rules_changes', meta,
        Column('character', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('place', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True),
        Column('turn', INT, primary_key=True),
        Column('tick', INT, primary_key=True),
        Column('handled_branch', TEXT),
        Column('handled_turn', INT),
        ForeignKeyConstraint(
            ['character', 'rulebook', 'rule', 'place', 'handled_branch', 'handled_turn'],
            [cprh.c.character, cprh.c.rulebook, cprh.c.rule, cprh.c.place, cprh.c.branch, cprh.c.turn]
        )
    )

    cporh = Table(
        'character_portal_rules_handled', meta,
        Column('character', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('orig', TEXT, primary_key=True),
        Column('dest', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True, default='trunk'),
        Column('turn', INT, primary_key=True),
        Column('tick', INT),
        ForeignKeyConstraint(
            ['character', 'rulebook'], ['character_portal_rulebook.character', 'character_portal_rulebook.rulebook']
        ),
        ForeignKeyConstraint(
            ['character', 'orig', 'dest'], ['edges.graph', 'edges.orig', 'edges.dest']
        )
    )

    Table(
        'character_portal_rules_changes', meta,
        Column('character', TEXT, primary_key=True),
        Column('rulebook', TEXT, primary_key=True),
        Column('rule', TEXT, primary_key=True),
        Column('orig', TEXT, primary_key=True),
        Column('dest', TEXT, primary_key=True),
        Column('branch', TEXT, primary_key=True),
        Column('turn', INT, primary_key=True),
        Column('tick', INT, primary_key=True),
        Column('handled_branch', TEXT),
        Column('handled_turn', INT),
        ForeignKeyConstraint(
            ['character', 'rulebook', 'rule', 'orig', 'dest', 'handled_branch', 'handled_turn'],
            [cporh.c.character, cporh.c.rulebook, cporh.c.rule, cporh.c.orig, cporh.c.dest, cporh.c.branch, cporh.c.turn]
        )
    )

    Table(
        'turns_completed', meta,
        Column('branch', TEXT, primary_key=True),
        Column('turn', INT)
    )

    return meta.tables
1329025
def _get_kwarg(self, name, kwargs):
        
        at_name = '@{}'.format(name)

        if name in kwargs:
            if at_name in kwargs:
                raise ValueError('Both {!r} and {!r} specified in kwargs'.format(name, at_name))
            return kwargs[name]

        if at_name in kwargs:
            return kwargs[at_name]

        return not_set
276398
def kv(d):
        
        return ((key, value) for key, value in iteritems(d) if key != _meta)
725599
function getMeta(key) {
  return baseQuery(key)
    .select('meta')
    .where('id', key)
    .then(pullValFromRows(key, 'meta'));
}
555730
def _get_clean_parameters(kwargs):
        
        return dict((k, v) for k, v in kwargs.items() if v is not None)
595789
def get_kwargs(args, exp_keys, exp_elems):
    """"""
    arg_dict = {}    # For arguments that have values
    for key, val in args.items():
        if exp_keys is not None and key in exp_keys and val:
            if isinstance(val, str):
                val = val.strip()
            arg_dict[key] = val
        elif exp_elems is not None and key in exp_elems and val:
            arg_dict[key] = True
    return arg_dict
648298
def map_column(self, keys, func):
        
        return [[func(v) for v in self[key]] for key in keys]