Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
Reg.read_keys
(cls, base, key)
Return list of registry keys.
Return list of registry keys.
def read_keys(cls, base, key): """Return list of registry keys.""" try: handle = RegOpenKeyEx(base, key) except RegError: return None L = [] i = 0 while True: try: k = RegEnumKey(handle, i) except RegError: ...
[ "def", "read_keys", "(", "cls", ",", "base", ",", "key", ")", ":", "try", ":", "handle", "=", "RegOpenKeyEx", "(", "base", ",", "key", ")", "except", "RegError", ":", "return", "None", "L", "=", "[", "]", "i", "=", "0", "while", "True", ":", "try...
[ 70, 4 ]
[ 85, 16 ]
python
en
['en', 'no', 'en']
True
Reg.read_values
(cls, base, key)
Return dict of registry keys and values. All names are converted to lowercase.
Return dict of registry keys and values.
def read_values(cls, base, key): """Return dict of registry keys and values. All names are converted to lowercase. """ try: handle = RegOpenKeyEx(base, key) except RegError: return None d = {} i = 0 while True: try: ...
[ "def", "read_values", "(", "cls", ",", "base", ",", "key", ")", ":", "try", ":", "handle", "=", "RegOpenKeyEx", "(", "base", ",", "key", ")", "except", "RegError", ":", "return", "None", "d", "=", "{", "}", "i", "=", "0", "while", "True", ":", "t...
[ 88, 4 ]
[ 107, 16 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.find_exe
(self, exe)
Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute path that is known to exist. If none ...
Return path to an MSVC executable program.
def find_exe(self, exe): """Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute pa...
[ "def", "find_exe", "(", "self", ",", "exe", ")", ":", "for", "p", "in", "self", ".", "__paths", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "abspath", "(", "p", ")", ",", "exe", ")", "if", "os", ".", "path", ...
[ 767, 4 ]
[ 787, 18 ]
python
en
['en', 'en', 'en']
True
get_order_dir
(field, default='ASC')
Returns the field name and direction for an order specification. For example, '-foo' is returned as ('foo', 'DESC'). The 'default' param is used to indicate which way no prefix (or a '+' prefix) should sort. The '-' prefix always sorts the opposite way.
Returns the field name and direction for an order specification. For example, '-foo' is returned as ('foo', 'DESC').
def get_order_dir(field, default='ASC'): """ Returns the field name and direction for an order specification. For example, '-foo' is returned as ('foo', 'DESC'). The 'default' param is used to indicate which way no prefix (or a '+' prefix) should sort. The '-' prefix always sorts the opposite way. ...
[ "def", "get_order_dir", "(", "field", ",", "default", "=", "'ASC'", ")", ":", "dirn", "=", "ORDER_DIR", "[", "default", "]", "if", "field", "[", "0", "]", "==", "'-'", ":", "return", "field", "[", "1", ":", "]", ",", "dirn", "[", "1", "]", "retur...
[ 2039, 0 ]
[ 2050, 25 ]
python
en
['en', 'error', 'th']
False
add_to_dict
(data, key, value)
A helper function to add "value" to the set of values for "key", whether or not "key" already exists.
A helper function to add "value" to the set of values for "key", whether or not "key" already exists.
def add_to_dict(data, key, value): """ A helper function to add "value" to the set of values for "key", whether or not "key" already exists. """ if key in data: data[key].add(value) else: data[key] = {value}
[ "def", "add_to_dict", "(", "data", ",", "key", ",", "value", ")", ":", "if", "key", "in", "data", ":", "data", "[", "key", "]", ".", "add", "(", "value", ")", "else", ":", "data", "[", "key", "]", "=", "{", "value", "}" ]
[ 2053, 0 ]
[ 2061, 27 ]
python
en
['en', 'error', 'th']
False
is_reverse_o2o
(field)
A little helper to check if the given field is reverse-o2o. The field is expected to be some sort of relation field or related object.
A little helper to check if the given field is reverse-o2o. The field is expected to be some sort of relation field or related object.
def is_reverse_o2o(field): """ A little helper to check if the given field is reverse-o2o. The field is expected to be some sort of relation field or related object. """ return field.is_relation and field.one_to_one and not field.concrete
[ "def", "is_reverse_o2o", "(", "field", ")", ":", "return", "field", ".", "is_relation", "and", "field", ".", "one_to_one", "and", "not", "field", ".", "concrete" ]
[ 2064, 0 ]
[ 2069, 72 ]
python
en
['en', 'error', 'th']
False
Query.__str__
(self)
Returns the query as a string of SQL with the parameter values substituted in (use sql_with_params() to see the unsubstituted string). Parameter values won't necessarily be quoted correctly, since that is done by the database interface at execution time.
Returns the query as a string of SQL with the parameter values substituted in (use sql_with_params() to see the unsubstituted string).
def __str__(self): """ Returns the query as a string of SQL with the parameter values substituted in (use sql_with_params() to see the unsubstituted string). Parameter values won't necessarily be quoted correctly, since that is done by the database interface at execution time. ...
[ "def", "__str__", "(", "self", ")", ":", "sql", ",", "params", "=", "self", ".", "sql_with_params", "(", ")", "return", "sql", "%", "params" ]
[ 224, 4 ]
[ 233, 27 ]
python
en
['en', 'error', 'th']
False
Query.sql_with_params
(self)
Returns the query as an SQL string and the parameters that will be substituted into the query.
Returns the query as an SQL string and the parameters that will be substituted into the query.
def sql_with_params(self): """ Returns the query as an SQL string and the parameters that will be substituted into the query. """ return self.get_compiler(DEFAULT_DB_ALIAS).as_sql()
[ "def", "sql_with_params", "(", "self", ")", ":", "return", "self", ".", "get_compiler", "(", "DEFAULT_DB_ALIAS", ")", ".", "as_sql", "(", ")" ]
[ 235, 4 ]
[ 240, 59 ]
python
en
['en', 'error', 'th']
False
Query.get_meta
(self)
Returns the Options instance (the model._meta) from which to start processing. Normally, this is self.model._meta, but it can be changed by subclasses.
Returns the Options instance (the model._meta) from which to start processing. Normally, this is self.model._meta, but it can be changed by subclasses.
def get_meta(self): """ Returns the Options instance (the model._meta) from which to start processing. Normally, this is self.model._meta, but it can be changed by subclasses. """ return self.model._meta
[ "def", "get_meta", "(", "self", ")", ":", "return", "self", ".", "model", ".", "_meta" ]
[ 257, 4 ]
[ 263, 31 ]
python
en
['en', 'error', 'th']
False
Query.clone
(self, klass=None, memo=None, **kwargs)
Creates a copy of the current instance. The 'kwargs' parameter can be used by clients to update attributes after copying has taken place.
Creates a copy of the current instance. The 'kwargs' parameter can be used by clients to update attributes after copying has taken place.
def clone(self, klass=None, memo=None, **kwargs): """ Creates a copy of the current instance. The 'kwargs' parameter can be used by clients to update attributes after copying has taken place. """ obj = Empty() obj.__class__ = klass or self.__class__ obj.model = se...
[ "def", "clone", "(", "self", ",", "klass", "=", "None", ",", "memo", "=", "None", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "Empty", "(", ")", "obj", ".", "__class__", "=", "klass", "or", "self", ".", "__class__", "obj", ".", "model", "=", ...
[ 265, 4 ]
[ 341, 18 ]
python
en
['en', 'error', 'th']
False
Query.get_aggregation
(self, using, added_aggregate_names)
Returns the dictionary with the values of the existing aggregations.
Returns the dictionary with the values of the existing aggregations.
def get_aggregation(self, using, added_aggregate_names): """ Returns the dictionary with the values of the existing aggregations. """ if not self.annotation_select: return {} has_limit = self.low_mark != 0 or self.high_mark is not None has_existing_annotations...
[ "def", "get_aggregation", "(", "self", ",", "using", ",", "added_aggregate_names", ")", ":", "if", "not", "self", ".", "annotation_select", ":", "return", "{", "}", "has_limit", "=", "self", ".", "low_mark", "!=", "0", "or", "self", ".", "high_mark", "is",...
[ 398, 4 ]
[ 489, 9 ]
python
en
['en', 'error', 'th']
False
Query.get_count
(self, using)
Performs a COUNT() query using the current filter constraints.
Performs a COUNT() query using the current filter constraints.
def get_count(self, using): """ Performs a COUNT() query using the current filter constraints. """ obj = self.clone() obj.add_annotation(Count('*'), alias='__count', is_summary=True) number = obj.get_aggregation(using, ['__count'])['__count'] if number is None: ...
[ "def", "get_count", "(", "self", ",", "using", ")", ":", "obj", "=", "self", ".", "clone", "(", ")", "obj", ".", "add_annotation", "(", "Count", "(", "'*'", ")", ",", "alias", "=", "'__count'", ",", "is_summary", "=", "True", ")", "number", "=", "o...
[ 491, 4 ]
[ 500, 21 ]
python
en
['en', 'error', 'th']
False
Query.combine
(self, rhs, connector)
Merge the 'rhs' query into the current one (with any 'rhs' effects being applied *after* (that is, "to the right of") anything in the current query. 'rhs' is not modified during a call to this function. The 'connector' parameter describes how to connect filters from the 'rhs' q...
Merge the 'rhs' query into the current one (with any 'rhs' effects being applied *after* (that is, "to the right of") anything in the current query. 'rhs' is not modified during a call to this function.
def combine(self, rhs, connector): """ Merge the 'rhs' query into the current one (with any 'rhs' effects being applied *after* (that is, "to the right of") anything in the current query. 'rhs' is not modified during a call to this function. The 'connector' parameter describes h...
[ "def", "combine", "(", "self", ",", "rhs", ",", "connector", ")", ":", "assert", "self", ".", "model", "==", "rhs", ".", "model", ",", "\"Cannot combine queries on two different base models.\"", "assert", "self", ".", "can_filter", "(", ")", ",", "\"Cannot combi...
[ 517, 4 ]
[ 614, 71 ]
python
en
['en', 'error', 'th']
False
Query.deferred_to_data
(self, target, callback)
Converts the self.deferred_loading data structure to an alternate data structure, describing the field that *will* be loaded. This is used to compute the columns to select from the database and also by the QuerySet class to work out which fields are being initialized on each mod...
Converts the self.deferred_loading data structure to an alternate data structure, describing the field that *will* be loaded. This is used to compute the columns to select from the database and also by the QuerySet class to work out which fields are being initialized on each mod...
def deferred_to_data(self, target, callback): """ Converts the self.deferred_loading data structure to an alternate data structure, describing the field that *will* be loaded. This is used to compute the columns to select from the database and also by the QuerySet class to work o...
[ "def", "deferred_to_data", "(", "self", ",", "target", ",", "callback", ")", ":", "field_names", ",", "defer", "=", "self", ".", "deferred_loading", "if", "not", "field_names", ":", "return", "orig_opts", "=", "self", ".", "get_meta", "(", ")", "seen", "="...
[ 616, 4 ]
[ 700, 47 ]
python
en
['en', 'error', 'th']
False
Query.table_alias
(self, table_name, create=False)
Returns a table alias for the given table_name and whether this is a new alias or not. If 'create' is true, a new alias is always created. Otherwise, the most recently created alias for the table (if one exists) is reused.
Returns a table alias for the given table_name and whether this is a new alias or not.
def table_alias(self, table_name, create=False): """ Returns a table alias for the given table_name and whether this is a new alias or not. If 'create' is true, a new alias is always created. Otherwise, the most recently created alias for the table (if one exists) is reused. ...
[ "def", "table_alias", "(", "self", ",", "table_name", ",", "create", "=", "False", ")", ":", "alias_list", "=", "self", ".", "table_map", ".", "get", "(", "table_name", ")", "if", "not", "create", "and", "alias_list", ":", "alias", "=", "alias_list", "["...
[ 702, 4 ]
[ 726, 26 ]
python
en
['en', 'error', 'th']
False
Query.ref_alias
(self, alias)
Increases the reference count for this alias.
Increases the reference count for this alias.
def ref_alias(self, alias): """ Increases the reference count for this alias. """ self.alias_refcount[alias] += 1
[ "def", "ref_alias", "(", "self", ",", "alias", ")", ":", "self", ".", "alias_refcount", "[", "alias", "]", "+=", "1" ]
[ 728, 4 ]
[ 730, 39 ]
python
en
['en', 'en', 'en']
True
Query.unref_alias
(self, alias, amount=1)
Decreases the reference count for this alias.
Decreases the reference count for this alias.
def unref_alias(self, alias, amount=1): """ Decreases the reference count for this alias. """ self.alias_refcount[alias] -= amount
[ "def", "unref_alias", "(", "self", ",", "alias", ",", "amount", "=", "1", ")", ":", "self", ".", "alias_refcount", "[", "alias", "]", "-=", "amount" ]
[ 732, 4 ]
[ 734, 44 ]
python
en
['en', 'en', 'en']
True
Query.promote_joins
(self, aliases)
Promotes recursively the join type of given aliases and its children to an outer join. If 'unconditional' is False, the join is only promoted if it is nullable or the parent join is an outer join. The children promotion is done to avoid join chains that contain a LOUTER b INNER...
Promotes recursively the join type of given aliases and its children to an outer join. If 'unconditional' is False, the join is only promoted if it is nullable or the parent join is an outer join.
def promote_joins(self, aliases): """ Promotes recursively the join type of given aliases and its children to an outer join. If 'unconditional' is False, the join is only promoted if it is nullable or the parent join is an outer join. The children promotion is done to avoid join...
[ "def", "promote_joins", "(", "self", ",", "aliases", ")", ":", "aliases", "=", "list", "(", "aliases", ")", "while", "aliases", ":", "alias", "=", "aliases", ".", "pop", "(", "0", ")", "if", "self", ".", "alias_map", "[", "alias", "]", ".", "join_typ...
[ 736, 4 ]
[ 768, 17 ]
python
en
['en', 'error', 'th']
False
Query.demote_joins
(self, aliases)
Change join type from LOUTER to INNER for all joins in aliases. Similarly to promote_joins(), this method must ensure no join chains containing first an outer, then an inner join are generated. If we are demoting b->c join in chain a LOUTER b LOUTER c then we must demote a->b a...
Change join type from LOUTER to INNER for all joins in aliases.
def demote_joins(self, aliases): """ Change join type from LOUTER to INNER for all joins in aliases. Similarly to promote_joins(), this method must ensure no join chains containing first an outer, then an inner join are generated. If we are demoting b->c join in chain a LOUTER b...
[ "def", "demote_joins", "(", "self", ",", "aliases", ")", ":", "aliases", "=", "list", "(", "aliases", ")", "while", "aliases", ":", "alias", "=", "aliases", ".", "pop", "(", "0", ")", "if", "self", ".", "alias_map", "[", "alias", "]", ".", "join_type...
[ 770, 4 ]
[ 787, 48 ]
python
en
['en', 'error', 'th']
False
Query.reset_refcounts
(self, to_counts)
This method will reset reference counts for aliases so that they match the value passed in :param to_counts:.
This method will reset reference counts for aliases so that they match the value passed in :param to_counts:.
def reset_refcounts(self, to_counts): """ This method will reset reference counts for aliases so that they match the value passed in :param to_counts:. """ for alias, cur_refcount in self.alias_refcount.copy().items(): unref_amount = cur_refcount - to_counts.get(alias...
[ "def", "reset_refcounts", "(", "self", ",", "to_counts", ")", ":", "for", "alias", ",", "cur_refcount", "in", "self", ".", "alias_refcount", ".", "copy", "(", ")", ".", "items", "(", ")", ":", "unref_amount", "=", "cur_refcount", "-", "to_counts", ".", "...
[ 789, 4 ]
[ 796, 49 ]
python
en
['en', 'error', 'th']
False
Query.change_aliases
(self, change_map)
Changes the aliases in change_map (which maps old-alias -> new-alias), relabelling any references to them in select columns and the where clause.
Changes the aliases in change_map (which maps old-alias -> new-alias), relabelling any references to them in select columns and the where clause.
def change_aliases(self, change_map): """ Changes the aliases in change_map (which maps old-alias -> new-alias), relabelling any references to them in select columns and the where clause. """ assert set(change_map.keys()).intersection(set(change_map.values())) == set() ...
[ "def", "change_aliases", "(", "self", ",", "change_map", ")", ":", "assert", "set", "(", "change_map", ".", "keys", "(", ")", ")", ".", "intersection", "(", "set", "(", "change_map", ".", "values", "(", ")", ")", ")", "==", "set", "(", ")", "# 1. Upd...
[ 798, 4 ]
[ 832, 68 ]
python
en
['en', 'error', 'th']
False
Query.bump_prefix
(self, outer_query)
Changes the alias prefix to the next letter in the alphabet in a way that the outer query's aliases and this query's aliases will not conflict. Even tables that previously had no alias will get an alias after this call.
Changes the alias prefix to the next letter in the alphabet in a way that the outer query's aliases and this query's aliases will not conflict. Even tables that previously had no alias will get an alias after this call.
def bump_prefix(self, outer_query): """ Changes the alias prefix to the next letter in the alphabet in a way that the outer query's aliases and this query's aliases will not conflict. Even tables that previously had no alias will get an alias after this call. """ ...
[ "def", "bump_prefix", "(", "self", ",", "outer_query", ")", ":", "def", "prefix_gen", "(", ")", ":", "\"\"\"\n Generates a sequence of characters in alphabetical order:\n -> 'A', 'B', 'C', ...\n\n When the alphabet is finished, the sequence will continu...
[ 834, 4 ]
[ 879, 39 ]
python
en
['en', 'error', 'th']
False
Query.get_initial_alias
(self)
Returns the first alias for this query, after increasing its reference count.
Returns the first alias for this query, after increasing its reference count.
def get_initial_alias(self): """ Returns the first alias for this query, after increasing its reference count. """ if self.tables: alias = self.tables[0] self.ref_alias(alias) else: alias = self.join(BaseTable(self.get_meta().db_table, ...
[ "def", "get_initial_alias", "(", "self", ")", ":", "if", "self", ".", "tables", ":", "alias", "=", "self", ".", "tables", "[", "0", "]", "self", ".", "ref_alias", "(", "alias", ")", "else", ":", "alias", "=", "self", ".", "join", "(", "BaseTable", ...
[ 881, 4 ]
[ 891, 20 ]
python
en
['en', 'error', 'th']
False
Query.count_active_tables
(self)
Returns the number of tables in this query with a non-zero reference count. Note that after execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method.
Returns the number of tables in this query with a non-zero reference count. Note that after execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method.
def count_active_tables(self): """ Returns the number of tables in this query with a non-zero reference count. Note that after execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method. """ return len([1 for count in self.alia...
[ "def", "count_active_tables", "(", "self", ")", ":", "return", "len", "(", "[", "1", "for", "count", "in", "self", ".", "alias_refcount", ".", "values", "(", ")", "if", "count", "]", ")" ]
[ 893, 4 ]
[ 899, 74 ]
python
en
['en', 'error', 'th']
False
Query.join
(self, join, reuse=None)
Returns an alias for the join in 'connection', either reusing an existing alias for that join or creating a new one. 'connection' is a tuple (lhs, table, join_cols) where 'lhs' is either an existing table alias or a table name. 'join_cols' is a tuple of tuples containing columns...
Returns an alias for the join in 'connection', either reusing an existing alias for that join or creating a new one. 'connection' is a tuple (lhs, table, join_cols) where 'lhs' is either an existing table alias or a table name. 'join_cols' is a tuple of tuples containing columns...
def join(self, join, reuse=None): """ Returns an alias for the join in 'connection', either reusing an existing alias for that join or creating a new one. 'connection' is a tuple (lhs, table, join_cols) where 'lhs' is either an existing table alias or a table name. 'join_cols' is...
[ "def", "join", "(", "self", ",", "join", ",", "reuse", "=", "None", ")", ":", "reuse", "=", "[", "a", "for", "a", ",", "j", "in", "self", ".", "alias_map", ".", "items", "(", ")", "if", "(", "reuse", "is", "None", "or", "a", "in", "reuse", ")...
[ 901, 4 ]
[ 941, 20 ]
python
en
['en', 'error', 'th']
False
Query.join_parent_model
(self, opts, model, alias, seen)
Makes sure the given 'model' is joined in the query. If 'model' isn't a parent of 'opts' or if it is None this method is a no-op. The 'alias' is the root alias for starting the join, 'seen' is a dict of model -> alias of existing joins. It must also contain a mapping of None ->...
Makes sure the given 'model' is joined in the query. If 'model' isn't a parent of 'opts' or if it is None this method is a no-op.
def join_parent_model(self, opts, model, alias, seen): """ Makes sure the given 'model' is joined in the query. If 'model' isn't a parent of 'opts' or if it is None this method is a no-op. The 'alias' is the root alias for starting the join, 'seen' is a dict of model -> alias of...
[ "def", "join_parent_model", "(", "self", ",", "opts", ",", "model", ",", "alias", ",", "seen", ")", ":", "if", "model", "in", "seen", ":", "return", "seen", "[", "model", "]", "chain", "=", "opts", ".", "get_base_chain", "(", "model", ")", "if", "not...
[ 943, 4 ]
[ 975, 34 ]
python
en
['en', 'error', 'th']
False
Query.add_annotation
(self, annotation, alias, is_summary=False)
Adds a single annotation expression to the Query
Adds a single annotation expression to the Query
def add_annotation(self, annotation, alias, is_summary=False): """ Adds a single annotation expression to the Query """ annotation = annotation.resolve_expression(self, allow_joins=True, reuse=None, summarize=is_summary) self.app...
[ "def", "add_annotation", "(", "self", ",", "annotation", ",", "alias", ",", "is_summary", "=", "False", ")", ":", "annotation", "=", "annotation", ".", "resolve_expression", "(", "self", ",", "allow_joins", "=", "True", ",", "reuse", "=", "None", ",", "sum...
[ 977, 4 ]
[ 984, 44 ]
python
en
['en', 'error', 'th']
False
Query.solve_lookup_type
(self, lookup)
Solve the lookup type from the lookup (eg: 'foobar__id__icontains')
Solve the lookup type from the lookup (eg: 'foobar__id__icontains')
def solve_lookup_type(self, lookup): """ Solve the lookup type from the lookup (eg: 'foobar__id__icontains') """ lookup_splitted = lookup.split(LOOKUP_SEP) if self._annotations: expression, expression_lookups = refs_expression(lookup_splitted, self.annotations) ...
[ "def", "solve_lookup_type", "(", "self", ",", "lookup", ")", ":", "lookup_splitted", "=", "lookup", ".", "split", "(", "LOOKUP_SEP", ")", "if", "self", ".", "_annotations", ":", "expression", ",", "expression_lookups", "=", "refs_expression", "(", "lookup_splitt...
[ 1034, 4 ]
[ 1052, 47 ]
python
en
['en', 'error', 'th']
False
Query.check_query_object_type
(self, value, opts, field)
Checks whether the object passed while querying is of the correct type. If not, it raises a ValueError specifying the wrong object.
Checks whether the object passed while querying is of the correct type. If not, it raises a ValueError specifying the wrong object.
def check_query_object_type(self, value, opts, field): """ Checks whether the object passed while querying is of the correct type. If not, it raises a ValueError specifying the wrong object. """ if hasattr(value, '_meta'): if not check_rel_lookup_compatibility(value._...
[ "def", "check_query_object_type", "(", "self", ",", "value", ",", "opts", ",", "field", ")", ":", "if", "hasattr", "(", "value", ",", "'_meta'", ")", ":", "if", "not", "check_rel_lookup_compatibility", "(", "value", ".", "_meta", ".", "model", ",", "opts",...
[ 1054, 4 ]
[ 1063, 46 ]
python
en
['en', 'error', 'th']
False
Query.check_related_objects
(self, field, value, opts)
Checks the type of object passed to query relations.
Checks the type of object passed to query relations.
def check_related_objects(self, field, value, opts): """ Checks the type of object passed to query relations. """ if field.is_relation: # Check that the field and the queryset use the same model in a # query like .filter(author=Author.objects.all()). For example, ...
[ "def", "check_related_objects", "(", "self", ",", "field", ",", "value", ",", "opts", ")", ":", "if", "field", ".", "is_relation", ":", "# Check that the field and the queryset use the same model in a", "# query like .filter(author=Author.objects.all()). For example, the", "# o...
[ 1065, 4 ]
[ 1088, 64 ]
python
en
['en', 'error', 'th']
False
Query.build_lookup
(self, lookups, lhs, rhs)
Tries to extract transforms and lookup from given lhs. The lhs value is something that works like SQLExpression. The rhs value is what the lookup is going to compare against. The lookups is a list of names to extract using get_lookup() and get_transform().
Tries to extract transforms and lookup from given lhs.
def build_lookup(self, lookups, lhs, rhs): """ Tries to extract transforms and lookup from given lhs. The lhs value is something that works like SQLExpression. The rhs value is what the lookup is going to compare against. The lookups is a list of names to extract using get_looku...
[ "def", "build_lookup", "(", "self", ",", "lookups", ",", "lhs", ",", "rhs", ")", ":", "lookups", "=", "lookups", "[", ":", "]", "while", "lookups", ":", "name", "=", "lookups", "[", "0", "]", "# If there is just one part left, try first get_lookup() so", "# th...
[ 1090, 4 ]
[ 1115, 33 ]
python
en
['en', 'error', 'th']
False
Query.try_transform
(self, lhs, name, rest_of_lookups)
Helper method for build_lookup. Tries to fetch and initialize a transform for name parameter from lhs.
Helper method for build_lookup. Tries to fetch and initialize a transform for name parameter from lhs.
def try_transform(self, lhs, name, rest_of_lookups): """ Helper method for build_lookup. Tries to fetch and initialize a transform for name parameter from lhs. """ transform_class = lhs.get_transform(name) if transform_class: return transform_class(lhs) ...
[ "def", "try_transform", "(", "self", ",", "lhs", ",", "name", ",", "rest_of_lookups", ")", ":", "transform_class", "=", "lhs", ".", "get_transform", "(", "name", ")", "if", "transform_class", ":", "return", "transform_class", "(", "lhs", ")", "else", ":", ...
[ 1117, 4 ]
[ 1129, 60 ]
python
en
['en', 'error', 'th']
False
Query.build_filter
(self, filter_expr, branch_negated=False, current_negated=False, can_reuse=None, connector=AND, allow_joins=True, split_subq=True)
Builds a WhereNode for a single filter clause, but doesn't add it to this Query. Query.add_q() will then add this filter to the where Node. The 'branch_negated' tells us if the current branch contains any negations. This will be used to determine if subqueries are needed. ...
Builds a WhereNode for a single filter clause, but doesn't add it to this Query. Query.add_q() will then add this filter to the where Node.
def build_filter(self, filter_expr, branch_negated=False, current_negated=False, can_reuse=None, connector=AND, allow_joins=True, split_subq=True): """ Builds a WhereNode for a single filter clause, but doesn't add it to this Query. Query.add_q() will then add this filter to...
[ "def", "build_filter", "(", "self", ",", "filter_expr", ",", "branch_negated", "=", "False", ",", "current_negated", "=", "False", ",", "can_reuse", "=", "None", ",", "connector", "=", "AND", ",", "allow_joins", "=", "True", ",", "split_subq", "=", "True", ...
[ 1131, 4 ]
[ 1241, 62 ]
python
en
['en', 'error', 'th']
False
Query.add_q
(self, q_object)
A preprocessor for the internal _add_q(). Responsible for doing final join promotion.
A preprocessor for the internal _add_q(). Responsible for doing final join promotion.
def add_q(self, q_object): """ A preprocessor for the internal _add_q(). Responsible for doing final join promotion. """ # For join promotion this case is doing an AND for the added q_object # and existing conditions. So, any existing inner join forces the join # ...
[ "def", "add_q", "(", "self", ",", "q_object", ")", ":", "# For join promotion this case is doing an AND for the added q_object", "# and existing conditions. So, any existing inner join forces the join", "# type to remain inner. Existing outer joins can however be demoted.", "# (Consider case w...
[ 1246, 4 ]
[ 1262, 41 ]
python
en
['en', 'error', 'th']
False
Query._add_q
(self, q_object, used_aliases, branch_negated=False, current_negated=False, allow_joins=True, split_subq=True)
Adds a Q-object to the current filter.
Adds a Q-object to the current filter.
def _add_q(self, q_object, used_aliases, branch_negated=False, current_negated=False, allow_joins=True, split_subq=True): """ Adds a Q-object to the current filter. """ connector = q_object.connector current_negated = current_negated ^ q_object.negated bran...
[ "def", "_add_q", "(", "self", ",", "q_object", ",", "used_aliases", ",", "branch_negated", "=", "False", ",", "current_negated", "=", "False", ",", "allow_joins", "=", "True", ",", "split_subq", "=", "True", ")", ":", "connector", "=", "q_object", ".", "co...
[ 1264, 4 ]
[ 1291, 42 ]
python
en
['en', 'error', 'th']
False
Query.names_to_path
(self, names, opts, allow_many=True, fail_on_missing=False)
Walks the list of names and turns them into PathInfo tuples. Note that a single name in 'names' can generate multiple PathInfos (m2m for example). 'names' is the path of names to travel, 'opts' is the model Options we start the name resolving from, 'allow_many' is as for setup_...
Walks the list of names and turns them into PathInfo tuples. Note that a single name in 'names' can generate multiple PathInfos (m2m for example).
def names_to_path(self, names, opts, allow_many=True, fail_on_missing=False): """ Walks the list of names and turns them into PathInfo tuples. Note that a single name in 'names' can generate multiple PathInfos (m2m for example). 'names' is the path of names to travel, 'opts' is ...
[ "def", "names_to_path", "(", "self", ",", "names", ",", "opts", ",", "allow_many", "=", "True", ",", "fail_on_missing", "=", "False", ")", ":", "path", ",", "names_with_path", "=", "[", "]", ",", "[", "]", "for", "pos", ",", "name", "in", "enumerate", ...
[ 1293, 4 ]
[ 1396, 58 ]
python
en
['en', 'error', 'th']
False
Query.setup_joins
(self, names, opts, alias, can_reuse=None, allow_many=True)
Compute the necessary table joins for the passage through the fields given in 'names'. 'opts' is the Options class for the current model (which gives the table we are starting from), 'alias' is the alias for the table to start the joining from. The 'can_reuse' defines the rever...
Compute the necessary table joins for the passage through the fields given in 'names'. 'opts' is the Options class for the current model (which gives the table we are starting from), 'alias' is the alias for the table to start the joining from.
def setup_joins(self, names, opts, alias, can_reuse=None, allow_many=True): """ Compute the necessary table joins for the passage through the fields given in 'names'. 'opts' is the Options class for the current model (which gives the table we are starting from), 'alias' is the alias for ...
[ "def", "setup_joins", "(", "self", ",", "names", ",", "opts", ",", "alias", ",", "can_reuse", "=", "None", ",", "allow_many", "=", "True", ")", ":", "joins", "=", "[", "alias", "]", "# First, generate the path for the names", "path", ",", "final_field", ",",...
[ 1398, 4 ]
[ 1441, 54 ]
python
en
['en', 'error', 'th']
False
Query.trim_joins
(self, targets, joins, path)
The 'target' parameter is the final field being joined to, 'joins' is the full list of join aliases. The 'path' contain the PathInfos used to create the joins. Returns the final target field and table alias and the new active joins. We will always trim any direct join ...
The 'target' parameter is the final field being joined to, 'joins' is the full list of join aliases. The 'path' contain the PathInfos used to create the joins.
def trim_joins(self, targets, joins, path): """ The 'target' parameter is the final field being joined to, 'joins' is the full list of join aliases. The 'path' contain the PathInfos used to create the joins. Returns the final target field and table alias and the new active ...
[ "def", "trim_joins", "(", "self", ",", "targets", ",", "joins", ",", "path", ")", ":", "joins", "=", "joins", "[", ":", "]", "for", "pos", ",", "info", "in", "enumerate", "(", "reversed", "(", "path", ")", ")", ":", "if", "len", "(", "joins", ")"...
[ 1443, 4 ]
[ 1468, 40 ]
python
en
['en', 'error', 'th']
False
Query.split_exclude
(self, filter_expr, prefix, can_reuse, names_with_path)
When doing an exclude against any kind of N-to-many relation, we need to use a subquery. This method constructs the nested query, given the original exclude filter (filter_expr) and the portion up to the first N-to-many relation field. As an example we could have original filte...
When doing an exclude against any kind of N-to-many relation, we need to use a subquery. This method constructs the nested query, given the original exclude filter (filter_expr) and the portion up to the first N-to-many relation field.
def split_exclude(self, filter_expr, prefix, can_reuse, names_with_path): """ When doing an exclude against any kind of N-to-many relation, we need to use a subquery. This method constructs the nested query, given the original exclude filter (filter_expr) and the portion up to the first ...
[ "def", "split_exclude", "(", "self", ",", "filter_expr", ",", "prefix", ",", "can_reuse", ",", "names_with_path", ")", ":", "# Generate the inner query.", "query", "=", "Query", "(", "self", ".", "model", ")", "query", ".", "add_filter", "(", "filter_expr", ")...
[ 1496, 4 ]
[ 1561, 38 ]
python
en
['en', 'error', 'th']
False
Query.set_limits
(self, low=None, high=None)
Adjusts the limits on the rows retrieved. We use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, they are converted to the appropriate offset and limit values. Any limits passed in here are applied relative to the existing c...
Adjusts the limits on the rows retrieved. We use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, they are converted to the appropriate offset and limit values.
def set_limits(self, low=None, high=None): """ Adjusts the limits on the rows retrieved. We use low/high to set these, as it makes it more Pythonic to read and write. When the SQL query is created, they are converted to the appropriate offset and limit values. Any limits passed ...
[ "def", "set_limits", "(", "self", ",", "low", "=", "None", ",", "high", "=", "None", ")", ":", "if", "high", "is", "not", "None", ":", "if", "self", ".", "high_mark", "is", "not", "None", ":", "self", ".", "high_mark", "=", "min", "(", "self", "....
[ 1569, 4 ]
[ 1591, 28 ]
python
en
['en', 'error', 'th']
False
Query.clear_limits
(self)
Clears any existing limits.
Clears any existing limits.
def clear_limits(self): """ Clears any existing limits. """ self.low_mark, self.high_mark = 0, None
[ "def", "clear_limits", "(", "self", ")", ":", "self", ".", "low_mark", ",", "self", ".", "high_mark", "=", "0", ",", "None" ]
[ 1593, 4 ]
[ 1597, 47 ]
python
en
['en', 'error', 'th']
False
Query.can_filter
(self)
Returns True if adding filters to this instance is still possible. Typically, this means no limits or offsets have been put on the results.
Returns True if adding filters to this instance is still possible.
def can_filter(self): """ Returns True if adding filters to this instance is still possible. Typically, this means no limits or offsets have been put on the results. """ return not self.low_mark and self.high_mark is None
[ "def", "can_filter", "(", "self", ")", ":", "return", "not", "self", ".", "low_mark", "and", "self", ".", "high_mark", "is", "None" ]
[ 1599, 4 ]
[ 1605, 59 ]
python
en
['en', 'error', 'th']
False
Query.clear_select_clause
(self)
Removes all fields from SELECT clause.
Removes all fields from SELECT clause.
def clear_select_clause(self): """ Removes all fields from SELECT clause. """ self.select = [] self.default_cols = False self.select_related = False self.set_extra_mask(()) self.set_annotation_mask(())
[ "def", "clear_select_clause", "(", "self", ")", ":", "self", ".", "select", "=", "[", "]", "self", ".", "default_cols", "=", "False", "self", ".", "select_related", "=", "False", "self", ".", "set_extra_mask", "(", "(", ")", ")", "self", ".", "set_annota...
[ 1607, 4 ]
[ 1615, 36 ]
python
en
['en', 'error', 'th']
False
Query.clear_select_fields
(self)
Clears the list of fields to select (but not extra_select columns). Some queryset types completely replace any existing list of select columns.
Clears the list of fields to select (but not extra_select columns). Some queryset types completely replace any existing list of select columns.
def clear_select_fields(self): """ Clears the list of fields to select (but not extra_select columns). Some queryset types completely replace any existing list of select columns. """ self.select = [] self.values_select = []
[ "def", "clear_select_fields", "(", "self", ")", ":", "self", ".", "select", "=", "[", "]", "self", ".", "values_select", "=", "[", "]" ]
[ 1617, 4 ]
[ 1624, 31 ]
python
en
['en', 'error', 'th']
False
Query.add_distinct_fields
(self, *field_names)
Adds and resolves the given fields to the query's "distinct on" clause.
Adds and resolves the given fields to the query's "distinct on" clause.
def add_distinct_fields(self, *field_names): """ Adds and resolves the given fields to the query's "distinct on" clause. """ self.distinct_fields = field_names self.distinct = True
[ "def", "add_distinct_fields", "(", "self", ",", "*", "field_names", ")", ":", "self", ".", "distinct_fields", "=", "field_names", "self", ".", "distinct", "=", "True" ]
[ 1634, 4 ]
[ 1639, 28 ]
python
en
['en', 'error', 'th']
False
Query.add_fields
(self, field_names, allow_m2m=True)
Adds the given (model) fields to the select set. The field names are added in the order specified.
Adds the given (model) fields to the select set. The field names are added in the order specified.
def add_fields(self, field_names, allow_m2m=True): """ Adds the given (model) fields to the select set. The field names are added in the order specified. """ alias = self.get_initial_alias() opts = self.get_meta() try: for name in field_names: ...
[ "def", "add_fields", "(", "self", ",", "field_names", ",", "allow_m2m", "=", "True", ")", ":", "alias", "=", "self", ".", "get_initial_alias", "(", ")", "opts", "=", "self", ".", "get_meta", "(", ")", "try", ":", "for", "name", "in", "field_names", ":"...
[ 1641, 4 ]
[ 1668, 78 ]
python
en
['en', 'error', 'th']
False
Query.add_ordering
(self, *ordering)
Adds items from the 'ordering' sequence to the query's "order by" clause. These items are either field names (not column names) -- possibly with a direction prefix ('-' or '?') -- or OrderBy expressions. If 'ordering' is empty, all ordering is cleared from the query.
Adds items from the 'ordering' sequence to the query's "order by" clause. These items are either field names (not column names) -- possibly with a direction prefix ('-' or '?') -- or OrderBy expressions.
def add_ordering(self, *ordering): """ Adds items from the 'ordering' sequence to the query's "order by" clause. These items are either field names (not column names) -- possibly with a direction prefix ('-' or '?') -- or OrderBy expressions. If 'ordering' is empty, all ...
[ "def", "add_ordering", "(", "self", ",", "*", "ordering", ")", ":", "errors", "=", "[", "]", "for", "item", "in", "ordering", ":", "if", "not", "hasattr", "(", "item", ",", "'resolve_expression'", ")", "and", "not", "ORDER_PATTERN", ".", "match", "(", ...
[ 1670, 4 ]
[ 1693, 41 ]
python
en
['en', 'error', 'th']
False
Query.clear_ordering
(self, force_empty)
Removes any ordering settings. If 'force_empty' is True, there will be no ordering in the resulting query (not even the model's default).
Removes any ordering settings. If 'force_empty' is True, there will be no ordering in the resulting query (not even the model's default).
def clear_ordering(self, force_empty): """ Removes any ordering settings. If 'force_empty' is True, there will be no ordering in the resulting query (not even the model's default). """ self.order_by = [] self.extra_order_by = () if force_empty: self.de...
[ "def", "clear_ordering", "(", "self", ",", "force_empty", ")", ":", "self", ".", "order_by", "=", "[", "]", "self", ".", "extra_order_by", "=", "(", ")", "if", "force_empty", ":", "self", ".", "default_ordering", "=", "False" ]
[ 1695, 4 ]
[ 1703, 41 ]
python
en
['en', 'error', 'th']
False
Query.set_group_by
(self)
Expands the GROUP BY clause required by the query. This will usually be the set of all non-aggregate fields in the return data. If the database backend supports grouping by the primary key, and the query would be equivalent, the optimization will be made automatically.
Expands the GROUP BY clause required by the query.
def set_group_by(self): """ Expands the GROUP BY clause required by the query. This will usually be the set of all non-aggregate fields in the return data. If the database backend supports grouping by the primary key, and the query would be equivalent, the optimization w...
[ "def", "set_group_by", "(", "self", ")", ":", "self", ".", "group_by", "=", "[", "]", "for", "col", "in", "self", ".", "select", ":", "self", ".", "group_by", ".", "append", "(", "col", ")", "if", "self", ".", "annotation_select", ":", "for", "alias"...
[ 1705, 4 ]
[ 1722, 45 ]
python
en
['en', 'error', 'th']
False
Query.add_select_related
(self, fields)
Sets up the select_related data structure so that we only select certain related models (as opposed to all models, when self.select_related=True).
Sets up the select_related data structure so that we only select certain related models (as opposed to all models, when self.select_related=True).
def add_select_related(self, fields): """ Sets up the select_related data structure so that we only select certain related models (as opposed to all models, when self.select_related=True). """ if isinstance(self.select_related, bool): field_dict = {} e...
[ "def", "add_select_related", "(", "self", ",", "fields", ")", ":", "if", "isinstance", "(", "self", ".", "select_related", ",", "bool", ")", ":", "field_dict", "=", "{", "}", "else", ":", "field_dict", "=", "self", ".", "select_related", "for", "field", ...
[ 1724, 4 ]
[ 1738, 40 ]
python
en
['en', 'error', 'th']
False
Query.add_extra
(self, select, select_params, where, params, tables, order_by)
Adds data to the various extra_* attributes for user-created additions to the query.
Adds data to the various extra_* attributes for user-created additions to the query.
def add_extra(self, select, select_params, where, params, tables, order_by): """ Adds data to the various extra_* attributes for user-created additions to the query. """ if select: # We need to pair any placeholder markers in the 'select' # dictionary with...
[ "def", "add_extra", "(", "self", ",", "select", ",", "select_params", ",", "where", ",", "params", ",", "tables", ",", "order_by", ")", ":", "if", "select", ":", "# We need to pair any placeholder markers in the 'select'", "# dictionary with their parameters in 'select_pa...
[ 1740, 4 ]
[ 1771, 42 ]
python
en
['en', 'error', 'th']
False
Query.clear_deferred_loading
(self)
Remove any fields from the deferred loading set.
Remove any fields from the deferred loading set.
def clear_deferred_loading(self): """ Remove any fields from the deferred loading set. """ self.deferred_loading = (set(), True)
[ "def", "clear_deferred_loading", "(", "self", ")", ":", "self", ".", "deferred_loading", "=", "(", "set", "(", ")", ",", "True", ")" ]
[ 1773, 4 ]
[ 1777, 45 ]
python
en
['en', 'error', 'th']
False
Query.add_deferred_loading
(self, field_names)
Add the given list of model field names to the set of fields to exclude from loading from the database when automatic column selection is done. The new field names are added to any existing field names that are deferred (or removed from any existing field names that are marked a...
Add the given list of model field names to the set of fields to exclude from loading from the database when automatic column selection is done. The new field names are added to any existing field names that are deferred (or removed from any existing field names that are marked a...
def add_deferred_loading(self, field_names): """ Add the given list of model field names to the set of fields to exclude from loading from the database when automatic column selection is done. The new field names are added to any existing field names that are deferred (or removed...
[ "def", "add_deferred_loading", "(", "self", ",", "field_names", ")", ":", "# Fields on related models are stored in the literal double-underscore", "# format, so that we can use a set datastructure. We do the foo__bar", "# splitting and handling when computing the SQL column names (as part of", ...
[ 1779, 4 ]
[ 1797, 75 ]
python
en
['en', 'error', 'th']
False
Query.add_immediate_loading
(self, field_names)
Add the given list of model field names to the set of fields to retrieve when the SQL is executed ("immediate loading" fields). The field names replace any existing immediate loading field names. If there are field names already specified for deferred loading, those names are re...
Add the given list of model field names to the set of fields to retrieve when the SQL is executed ("immediate loading" fields). The field names replace any existing immediate loading field names. If there are field names already specified for deferred loading, those names are re...
def add_immediate_loading(self, field_names): """ Add the given list of model field names to the set of fields to retrieve when the SQL is executed ("immediate loading" fields). The field names replace any existing immediate loading field names. If there are field names already s...
[ "def", "add_immediate_loading", "(", "self", ",", "field_names", ")", ":", "existing", ",", "defer", "=", "self", ".", "deferred_loading", "field_names", "=", "set", "(", "field_names", ")", "if", "'pk'", "in", "field_names", ":", "field_names", ".", "remove",...
[ 1799, 4 ]
[ 1821, 54 ]
python
en
['en', 'error', 'th']
False
Query.get_loaded_field_names
(self)
If any fields are marked to be deferred, returns a dictionary mapping models to a set of names in those fields that will be loaded. If a model is not in the returned dictionary, none of its fields are deferred. If no fields are marked for deferral, returns an empty dictionary. ...
If any fields are marked to be deferred, returns a dictionary mapping models to a set of names in those fields that will be loaded. If a model is not in the returned dictionary, none of its fields are deferred.
def get_loaded_field_names(self): """ If any fields are marked to be deferred, returns a dictionary mapping models to a set of names in those fields that will be loaded. If a model is not in the returned dictionary, none of its fields are deferred. If no fields are marke...
[ "def", "get_loaded_field_names", "(", "self", ")", ":", "# We cache this because we call this function multiple times", "# (compiler.fill_related_selections, query.iterator)", "try", ":", "return", "self", ".", "_loaded_field_names_cache", "except", "AttributeError", ":", "collecti...
[ 1823, 4 ]
[ 1840, 29 ]
python
en
['en', 'error', 'th']
False
Query.get_loaded_field_names_cb
(self, target, model, fields)
Callback used by get_deferred_field_names().
Callback used by get_deferred_field_names().
def get_loaded_field_names_cb(self, target, model, fields): """ Callback used by get_deferred_field_names(). """ target[model] = {f.attname for f in fields}
[ "def", "get_loaded_field_names_cb", "(", "self", ",", "target", ",", "model", ",", "fields", ")", ":", "target", "[", "model", "]", "=", "{", "f", ".", "attname", "for", "f", "in", "fields", "}" ]
[ 1842, 4 ]
[ 1846, 51 ]
python
en
['en', 'error', 'th']
False
Query.set_annotation_mask
(self, names)
Set the mask of annotations that will actually be returned by the SELECT
Set the mask of annotations that will actually be returned by the SELECT
def set_annotation_mask(self, names): "Set the mask of annotations that will actually be returned by the SELECT" if names is None: self.annotation_select_mask = None else: self.annotation_select_mask = set(names) self._annotation_select_cache = None
[ "def", "set_annotation_mask", "(", "self", ",", "names", ")", ":", "if", "names", "is", "None", ":", "self", ".", "annotation_select_mask", "=", "None", "else", ":", "self", ".", "annotation_select_mask", "=", "set", "(", "names", ")", "self", ".", "_annot...
[ 1848, 4 ]
[ 1854, 44 ]
python
en
['en', 'en', 'en']
True
Query.set_extra_mask
(self, names)
Set the mask of extra select items that will be returned by SELECT, we don't actually remove them from the Query since they might be used later
Set the mask of extra select items that will be returned by SELECT, we don't actually remove them from the Query since they might be used later
def set_extra_mask(self, names): """ Set the mask of extra select items that will be returned by SELECT, we don't actually remove them from the Query since they might be used later """ if names is None: self.extra_select_mask = None else: s...
[ "def", "set_extra_mask", "(", "self", ",", "names", ")", ":", "if", "names", "is", "None", ":", "self", ".", "extra_select_mask", "=", "None", "else", ":", "self", ".", "extra_select_mask", "=", "set", "(", "names", ")", "self", ".", "_extra_select_cache",...
[ 1860, 4 ]
[ 1870, 39 ]
python
en
['en', 'error', 'th']
False
Query.annotation_select
(self)
The OrderedDict of aggregate columns that are not masked, and should be used in the SELECT clause. This result is cached for optimization purposes.
The OrderedDict of aggregate columns that are not masked, and should be used in the SELECT clause.
def annotation_select(self): """The OrderedDict of aggregate columns that are not masked, and should be used in the SELECT clause. This result is cached for optimization purposes. """ if self._annotation_select_cache is not None: return self._annotation_select_cache ...
[ "def", "annotation_select", "(", "self", ")", ":", "if", "self", ".", "_annotation_select_cache", "is", "not", "None", ":", "return", "self", ".", "_annotation_select_cache", "elif", "not", "self", ".", "_annotations", ":", "return", "{", "}", "elif", "self", ...
[ 1908, 4 ]
[ 1925, 35 ]
python
en
['en', 'en', 'en']
True
Query.trim_start
(self, names_with_path)
Trims joins from the start of the join path. The candidates for trim are the PathInfos in names_with_path structure that are m2m joins. Also sets the select column so the start matches the join. This method is meant to be used for generating the subquery joins & cols in split_...
Trims joins from the start of the join path. The candidates for trim are the PathInfos in names_with_path structure that are m2m joins.
def trim_start(self, names_with_path): """ Trims joins from the start of the join path. The candidates for trim are the PathInfos in names_with_path structure that are m2m joins. Also sets the select column so the start matches the join. This method is meant to be used for gene...
[ "def", "trim_start", "(", "self", ",", "names_with_path", ")", ":", "all_paths", "=", "[", "]", "for", "_", ",", "paths", "in", "names_with_path", ":", "all_paths", ".", "extend", "(", "paths", ")", "contains_louter", "=", "False", "# Trim and operate only on ...
[ 1942, 4 ]
[ 2007, 46 ]
python
en
['en', 'error', 'th']
False
Query.is_nullable
(self, field)
A helper to check if the given field should be treated as nullable. Some backends treat '' as null and Django treats such fields as nullable for those backends. In such situations field.null can be False even if we should treat the field as nullable.
A helper to check if the given field should be treated as nullable.
def is_nullable(self, field): """ A helper to check if the given field should be treated as nullable. Some backends treat '' as null and Django treats such fields as nullable for those backends. In such situations field.null can be False even if we should treat the field as null...
[ "def", "is_nullable", "(", "self", ",", "field", ")", ":", "# We need to use DEFAULT_DB_ALIAS here, as QuerySet does not have", "# (nor should it have) knowledge of which connection is going to be", "# used. The proper fix would be to defer all decisions where", "# is_nullable() is needed to t...
[ 2009, 4 ]
[ 2025, 29 ]
python
en
['en', 'error', 'th']
False
JoinPromoter.add_votes
(self, votes)
Add single vote per item to self.votes. Parameter can be any iterable.
Add single vote per item to self.votes. Parameter can be any iterable.
def add_votes(self, votes): """ Add single vote per item to self.votes. Parameter can be any iterable. """ self.votes.update(votes)
[ "def", "add_votes", "(", "self", ",", "votes", ")", ":", "self", ".", "votes", ".", "update", "(", "votes", ")" ]
[ 2093, 4 ]
[ 2098, 32 ]
python
en
['en', 'error', 'th']
False
JoinPromoter.update_join_types
(self, query)
Change join types so that the generated query is as efficient as possible, but still correct. So, change as many joins as possible to INNER, but don't make OUTER joins INNER if that could remove results from the query.
Change join types so that the generated query is as efficient as possible, but still correct. So, change as many joins as possible to INNER, but don't make OUTER joins INNER if that could remove results from the query.
def update_join_types(self, query): """ Change join types so that the generated query is as efficient as possible, but still correct. So, change as many joins as possible to INNER, but don't make OUTER joins INNER if that could remove results from the query. """ t...
[ "def", "update_join_types", "(", "self", ",", "query", ")", ":", "to_promote", "=", "set", "(", ")", "to_demote", "=", "set", "(", ")", "# The effective_connector is used so that NOT (a AND b) is treated", "# similarly to (a OR b) for join promotion.", "for", "table", ","...
[ 2100, 4 ]
[ 2154, 24 ]
python
en
['en', 'error', 'th']
False
Command.normalize_col_name
(self, col_name, used_column_names, is_relation)
Modify the column name to make it Python-compatible as a field name
Modify the column name to make it Python-compatible as a field name
def normalize_col_name(self, col_name, used_column_names, is_relation): """ Modify the column name to make it Python-compatible as a field name """ field_params = {} field_notes = [] new_name = col_name.lower() if new_name != col_name: field_notes.app...
[ "def", "normalize_col_name", "(", "self", ",", "col_name", ",", "used_column_names", ",", "is_relation", ")", ":", "field_params", "=", "{", "}", "field_notes", "=", "[", "]", "new_name", "=", "col_name", ".", "lower", "(", ")", "if", "new_name", "!=", "co...
[ 171, 4 ]
[ 225, 50 ]
python
en
['en', 'error', 'th']
False
Command.get_field_type
(self, connection, table_name, row)
Given the database connection, the table name, and the cursor row description, this routine will return the given field type name, as well as any additional keyword parameters and notes for the field.
Given the database connection, the table name, and the cursor row description, this routine will return the given field type name, as well as any additional keyword parameters and notes for the field.
def get_field_type(self, connection, table_name, row): """ Given the database connection, the table name, and the cursor row description, this routine will return the given field type name, as well as any additional keyword parameters and notes for the field. """ field_pa...
[ "def", "get_field_type", "(", "self", ",", "connection", ",", "table_name", ",", "row", ")", ":", "field_params", "=", "OrderedDict", "(", ")", "field_notes", "=", "[", "]", "try", ":", "field_type", "=", "connection", ".", "introspection", ".", "get_field_t...
[ 227, 4 ]
[ 263, 52 ]
python
en
['en', 'error', 'th']
False
Command.get_meta
(self, table_name, constraints, column_to_field_name)
Return a sequence comprising the lines of code necessary to construct the inner Meta class for the model corresponding to the given database table name.
Return a sequence comprising the lines of code necessary to construct the inner Meta class for the model corresponding to the given database table name.
def get_meta(self, table_name, constraints, column_to_field_name): """ Return a sequence comprising the lines of code necessary to construct the inner Meta class for the model corresponding to the given database table name. """ unique_together = [] for index, para...
[ "def", "get_meta", "(", "self", ",", "table_name", ",", "constraints", ",", "column_to_field_name", ")", ":", "unique_together", "=", "[", "]", "for", "index", ",", "params", "in", "constraints", ".", "items", "(", ")", ":", "if", "params", "[", "'unique'"...
[ 265, 4 ]
[ 287, 19 ]
python
en
['en', 'error', 'th']
False
Mercurial.export
(self, location, url)
Export the Hg repository at the url to the destination location
Export the Hg repository at the url to the destination location
def export(self, location, url): # type: (str, HiddenText) -> None """Export the Hg repository at the url to the destination location""" with TempDirectory(kind="export") as temp_dir: self.unpack(temp_dir.path, url=url) self.run_command( ['archive', locat...
[ "def", "export", "(", "self", ",", "location", ",", "url", ")", ":", "# type: (str, HiddenText) -> None", "with", "TempDirectory", "(", "kind", "=", "\"export\"", ")", "as", "temp_dir", ":", "self", ".", "unpack", "(", "temp_dir", ".", "path", ",", "url", ...
[ 42, 4 ]
[ 50, 13 ]
python
en
['en', 'en', 'en']
True
Mercurial.get_revision
(cls, location)
Return the repository-local changeset revision number, as an integer.
Return the repository-local changeset revision number, as an integer.
def get_revision(cls, location): """ Return the repository-local changeset revision number, as an integer. """ current_revision = cls.run_command( ['parents', '--template={rev}'], cwd=location).strip() return current_revision
[ "def", "get_revision", "(", "cls", ",", "location", ")", ":", "current_revision", "=", "cls", ".", "run_command", "(", "[", "'parents'", ",", "'--template={rev}'", "]", ",", "cwd", "=", "location", ")", ".", "strip", "(", ")", "return", "current_revision" ]
[ 100, 4 ]
[ 106, 31 ]
python
en
['en', 'error', 'th']
False
Mercurial.get_requirement_revision
(cls, location)
Return the changeset identification hash, as a 40-character hexadecimal string
Return the changeset identification hash, as a 40-character hexadecimal string
def get_requirement_revision(cls, location): """ Return the changeset identification hash, as a 40-character hexadecimal string """ current_rev_hash = cls.run_command( ['parents', '--template={node}'], cwd=location).strip() return current_rev_hash
[ "def", "get_requirement_revision", "(", "cls", ",", "location", ")", ":", "current_rev_hash", "=", "cls", ".", "run_command", "(", "[", "'parents'", ",", "'--template={node}'", "]", ",", "cwd", "=", "location", ")", ".", "strip", "(", ")", "return", "current...
[ 109, 4 ]
[ 117, 31 ]
python
en
['en', 'error', 'th']
False
Mercurial.is_commit_id_equal
(cls, dest, name)
Always assume the versions don't match
Always assume the versions don't match
def is_commit_id_equal(cls, dest, name): """Always assume the versions don't match""" return False
[ "def", "is_commit_id_equal", "(", "cls", ",", "dest", ",", "name", ")", ":", "return", "False" ]
[ 120, 4 ]
[ 122, 20 ]
python
en
['en', 'en', 'en']
True
Mercurial.get_subdirectory
(cls, location)
Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root.
Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root.
def get_subdirectory(cls, location): """ Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root. """ # find the repo root repo_root = cls.run_command( ['root'], cwd=location).strip() if not os.path.isabs(rep...
[ "def", "get_subdirectory", "(", "cls", ",", "location", ")", ":", "# find the repo root", "repo_root", "=", "cls", ".", "run_command", "(", "[", "'root'", "]", ",", "cwd", "=", "location", ")", ".", "strip", "(", ")", "if", "not", "os", ".", "path", "....
[ 125, 4 ]
[ 135, 69 ]
python
en
['en', 'error', 'th']
False
mean
(model, obj, **kwargs)
Compute model mean for Kriging believer pure exploitation. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about the domain. jitter : float Parameter which controls the degree of exploration. ...
Compute model mean for Kriging believer pure exploitation. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about the domain. jitter : float Parameter which controls the degree of exploration. ...
def mean(model, obj, **kwargs): """Compute model mean for Kriging believer pure exploitation. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about the domain. jitter : float Parameter which c...
[ "def", "mean", "(", "model", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "pred", "=", "np", ".", "array", "(", "model", ".", "predict", "(", "obj", ".", "domain", ")", ")", "return", "pred" ]
[ 211, 0 ]
[ 231, 15 ]
python
en
['en', 'en', 'en']
True
variance
(model, obj, **kwargs)
Compute model variance for Kriging believer pure exploration. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about the domain. jitter : float Parameter which controls the degree of exploration. ...
Compute model variance for Kriging believer pure exploration. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about the domain. jitter : float Parameter which controls the degree of exploration. ...
def variance(model, obj, **kwargs): """Compute model variance for Kriging believer pure exploration. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about the domain. jitter : float Parameter ...
[ "def", "variance", "(", "model", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "var", "=", "np", ".", "array", "(", "model", ".", "variance", "(", "obj", ".", "domain", ")", ")", "return", "var" ]
[ 288, 0 ]
[ 308, 14 ]
python
en
['en', 'en', 'en']
True
expected_improvement
(model, obj, jitter=0.01)
Compute expected improvement. EI attempts to balance exploration and exploitation by accounting for the amount of improvement over the best observed value. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing inf...
Compute expected improvement. EI attempts to balance exploration and exploitation by accounting for the amount of improvement over the best observed value. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing inf...
def expected_improvement(model, obj, jitter=0.01): """Compute expected improvement. EI attempts to balance exploration and exploitation by accounting for the amount of improvement over the best observed value. Parameters ---------- model : edbo.models Trained model. obj...
[ "def", "expected_improvement", "(", "model", ",", "obj", ",", "jitter", "=", "0.01", ")", ":", "# Domain", "domain", "=", "to_torch", "(", "obj", ".", "domain", ",", "gpu", "=", "obj", ".", "gpu", ")", "# Max obsereved objective value", "if", "len", "(", ...
[ 312, 0 ]
[ 354, 13 ]
python
en
['en', 'en', 'en']
True
probability_of_improvement
(model, obj, jitter=1e-2)
Compute probability of improvement. PI favors exploitation of exporation. Equally rewards any improvement over the best observed value. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about th...
Compute probability of improvement. PI favors exploitation of exporation. Equally rewards any improvement over the best observed value. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about th...
def probability_of_improvement(model, obj, jitter=1e-2): """Compute probability of improvement. PI favors exploitation of exporation. Equally rewards any improvement over the best observed value. Parameters ---------- model : edbo.models Trained model. obj : edbo.obj...
[ "def", "probability_of_improvement", "(", "model", ",", "obj", ",", "jitter", "=", "1e-2", ")", ":", "# Domain", "domain", "=", "to_torch", "(", "obj", ".", "domain", ",", "gpu", "=", "obj", ".", "gpu", ")", "# Max obsereved objective value", "if", "len", ...
[ 358, 0 ]
[ 399, 14 ]
python
en
['en', 'en', 'en']
True
upper_confidence_bound
(model, obj, jitter=1e-2, delta=0.5)
Computes upper confidence bound. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about the domain. jitter : float Parameter which controls the degree of exploration. delta : float UCB ...
Computes upper confidence bound. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about the domain. jitter : float Parameter which controls the degree of exploration. delta : float UCB ...
def upper_confidence_bound(model, obj, jitter=1e-2, delta=0.5): """Computes upper confidence bound. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containing information about the domain. jitter : float Parameter w...
[ "def", "upper_confidence_bound", "(", "model", ",", "obj", ",", "jitter", "=", "1e-2", ",", "delta", "=", "0.5", ")", ":", "# Domain", "domain", "=", "to_torch", "(", "obj", ".", "domain", ",", "gpu", "=", "obj", ".", "gpu", ")", "# Mean and standard dev...
[ 403, 0 ]
[ 435, 30 ]
python
en
['en', 'sr', 'en']
True
acquisition.__init__
(self, function, batch_size=1, duplicates=False)
Parameters ---------- function : str Acquisition function to be used. Options include: 'TS', 'EI', 'PI' 'UCB', 'EI-TS', 'PI-TS', 'UCB-TS', 'rand-TS', 'MeanMax-TS', 'VarMax-TS', 'MeanMax', 'VarMax', 'rand', and 'eps-greedy'. batch_size : int ...
Parameters ---------- function : str Acquisition function to be used. Options include: 'TS', 'EI', 'PI' 'UCB', 'EI-TS', 'PI-TS', 'UCB-TS', 'rand-TS', 'MeanMax-TS', 'VarMax-TS', 'MeanMax', 'VarMax', 'rand', and 'eps-greedy'. batch_size : int ...
def __init__(self, function, batch_size=1, duplicates=False): """ Parameters ---------- function : str Acquisition function to be used. Options include: 'TS', 'EI', 'PI' 'UCB', 'EI-TS', 'PI-TS', 'UCB-TS', 'rand-TS', 'MeanMax-TS', 'VarMax-TS', 'MeanMax'...
[ "def", "__init__", "(", "self", ",", "function", ",", "batch_size", "=", "1", ",", "duplicates", "=", "False", ")", ":", "if", "function", ".", "lower", "(", ")", "==", "'ts'", ":", "self", ".", "function", "=", "thompson_sampling", "(", "batch_size", ...
[ 21, 4 ]
[ 75, 68 ]
python
en
['en', 'error', 'th']
False
acquisition.evaluate
(self, model, obj)
Run the selected acquisition function. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containining data and scalers. Returns ---------- pandas.DataFrame Proposed...
Run the selected acquisition function. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containining data and scalers. Returns ---------- pandas.DataFrame Proposed...
def evaluate(self, model, obj): """Run the selected acquisition function. Parameters ---------- model : edbo.models Trained model. obj : edbo.objective Objective object containining data and scalers. Returns ---------- ...
[ "def", "evaluate", "(", "self", ",", "model", ",", "obj", ")", ":", "return", "self", ".", "function", ".", "run", "(", "model", ",", "obj", ")" ]
[ 77, 4 ]
[ 93, 44 ]
python
en
['en', 'en', 'en']
True
thompson_sampling.__init__
(self, batch_size, duplicates, chunk_size=20000)
Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points. chunk_size : int Sampling over large spaces can be very costly. Therefore when TS if len(domain) > chunk_size the...
Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points. chunk_size : int Sampling over large spaces can be very costly. Therefore when TS if len(domain) > chunk_size the...
def __init__(self, batch_size, duplicates, chunk_size=20000): """ Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points. chunk_size : int Sampling over large spaces can be ve...
[ "def", "__init__", "(", "self", ",", "batch_size", ",", "duplicates", ",", "chunk_size", "=", "20000", ")", ":", "self", ".", "batch_size", "=", "batch_size", "self", ".", "duplicates", "=", "duplicates", "self", ".", "chunk_size", "=", "chunk_size" ]
[ 104, 4 ]
[ 120, 36 ]
python
en
['en', 'error', 'th']
False
thompson_sampling.run
(self, model, obj)
Run Thompson sampling algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns ...
Run Thompson sampling algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns ...
def run(self, model, obj): """Run Thompson sampling algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about t...
[ "def", "run", "(", "self", ",", "model", ",", "obj", ")", ":", "# Draw samples from posterior", "domain", "=", "to_torch", "(", "obj", ".", "domain", ",", "gpu", "=", "obj", ".", "gpu", ")", "self", ".", "samples", "=", "sample", "(", "model", ",", "...
[ 122, 4 ]
[ 157, 46 ]
python
en
['en', 'en', 'en']
True
top_predicted.__init__
(self, batch_size, duplicates)
Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
def __init__(self, batch_size, duplicates): """ Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points. """ self.batch_size = batch_size self.duplicates ...
[ "def", "__init__", "(", "self", ",", "batch_size", ",", "duplicates", ")", ":", "self", ".", "batch_size", "=", "batch_size", "self", ".", "duplicates", "=", "duplicates" ]
[ 168, 4 ]
[ 180, 36 ]
python
en
['en', 'error', 'th']
False
top_predicted.run
(self, model, obj)
Run top_predicted on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns --------...
Run top_predicted on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns --------...
def run(self, model, obj): """Run top_predicted on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. ...
[ "def", "run", "(", "self", ",", "model", ",", "obj", ")", ":", "domain", "=", "to_torch", "(", "obj", ".", "domain", ",", "gpu", "=", "obj", ".", "gpu", ")", "pred", "=", "obj", ".", "domain", ".", "copy", "(", ")", "pred", "[", "'pred'", "]", ...
[ 182, 4 ]
[ 209, 44 ]
python
en
['en', 'en', 'en']
True
max_variance.__init__
(self, batch_size, duplicates)
Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
def __init__(self, batch_size, duplicates): """ Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points. """ self.batch_size = batch_size self.duplicates ...
[ "def", "__init__", "(", "self", ",", "batch_size", ",", "duplicates", ")", ":", "self", ".", "batch_size", "=", "batch_size", "self", ".", "duplicates", "=", "duplicates" ]
[ 242, 4 ]
[ 254, 36 ]
python
en
['en', 'error', 'th']
False
max_variance.run
(self, model, obj)
Run max_variance on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns ---------...
Run max_variance on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns ---------...
def run(self, model, obj): """Run max_variance on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. ...
[ "def", "run", "(", "self", ",", "model", ",", "obj", ")", ":", "domain", "=", "to_torch", "(", "obj", ".", "domain", ",", "gpu", "=", "obj", ".", "gpu", ")", "var", "=", "obj", ".", "domain", ".", "copy", "(", ")", "var", "[", "'var'", "]", "...
[ 256, 4 ]
[ 285, 43 ]
python
en
['en', 'en', 'en']
True
Kriging_believer.__init__
(self, acq_function, batch_size, duplicates)
Parameters ---------- acq_function : acq_func.function Base acquisition function to use with Kriging believer algorithm. batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
Parameters ---------- acq_function : acq_func.function Base acquisition function to use with Kriging believer algorithm. batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
def __init__(self, acq_function, batch_size, duplicates): """ Parameters ---------- acq_function : acq_func.function Base acquisition function to use with Kriging believer algorithm. batch_size : int Number of points to select. duplicates : bool ...
[ "def", "__init__", "(", "self", ",", "acq_function", ",", "batch_size", ",", "duplicates", ")", ":", "self", ".", "acq_function", "=", "acq_function", "self", ".", "batch_size", "=", "batch_size", "self", ".", "duplicates", "=", "duplicates", "self", ".", "j...
[ 446, 4 ]
[ 462, 26 ]
python
en
['en', 'error', 'th']
False
Kriging_believer.run
(self, model, obj)
Run Kriging believer algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns ...
Run Kriging believer algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns ...
def run(self, model, obj): """Run Kriging believer algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about th...
[ "def", "run", "(", "self", ",", "model", ",", "obj", ")", ":", "# Make a copy of model dictionary", "model_dict", "=", "model", ".", "__dict__", ".", "copy", "(", ")", "for", "entry", "in", "[", "'X'", ",", "'y'", "]", ":", "del", "(", "model_dict", "[...
[ 464, 4 ]
[ 589, 23 ]
python
en
['en', 'en', 'en']
True
hybrid_TS.__init__
(self, hybrid, batch_size, duplicates)
Parameters ---------- hybrid : edbo.acq_funcs: hybrid method to be used. batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
Parameters ---------- hybrid : edbo.acq_funcs: hybrid method to be used. batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
def __init__(self, hybrid, batch_size, duplicates): """ Parameters ---------- hybrid : edbo.acq_funcs: hybrid method to be used. batch_size : int Number of points to select. duplicates : bool Select duplicate domain points. ...
[ "def", "__init__", "(", "self", ",", "hybrid", ",", "batch_size", ",", "duplicates", ")", ":", "self", ".", "hybrid", "=", "hybrid", "self", ".", "batch_size", "=", "batch_size", "self", ".", "duplicates", "=", "duplicates" ]
[ 601, 4 ]
[ 616, 36 ]
python
en
['en', 'error', 'th']
False
hybrid_TS.run
(self, model, obj)
Run Hybrid-TS algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns --...
Run Hybrid-TS algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns --...
def run(self, model, obj): """Run Hybrid-TS algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domai...
[ "def", "run", "(", "self", ",", "model", ",", "obj", ")", ":", "# Hybrid for first sample", "if", "self", ".", "hybrid", "==", "'EI'", ":", "first", "=", "expected_improvement", "(", "model", ",", "obj", ")", "self", ".", "ei", "=", "first", "elif", "s...
[ 618, 4 ]
[ 707, 23 ]
python
en
['en', 'en', 'en']
True
eps_greedy.__init__
(self, batch_size, duplicates)
Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
def __init__(self, batch_size, duplicates): """ Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points. """ self.batch_size = batch_size self.duplicates ...
[ "def", "__init__", "(", "self", ",", "batch_size", ",", "duplicates", ")", ":", "self", ".", "batch_size", "=", "batch_size", "self", ".", "duplicates", "=", "duplicates", "self", ".", "eps", "=", "0.05" ]
[ 719, 4 ]
[ 732, 23 ]
python
en
['en', 'error', 'th']
False
eps_greedy.run
(self, model, obj)
Run eps-greedy algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns -...
Run eps-greedy algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns -...
def run(self, model, obj): """Run eps-greedy algorithm on a trained model and user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the doma...
[ "def", "run", "(", "self", ",", "model", ",", "obj", ")", ":", "# Get predictions", "domain", "=", "to_torch", "(", "obj", ".", "domain", ",", "gpu", "=", "obj", ".", "gpu", ")", "pred", "=", "obj", ".", "domain", ".", "copy", "(", ")", "pred", "...
[ 734, 4 ]
[ 790, 23 ]
python
en
['en', 'en', 'en']
True
random.__init__
(self, batch_size, duplicates)
Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points.
def __init__(self, batch_size, duplicates): """ Parameters ---------- batch_size : int Number of points to select. duplicates : bool Select duplicate domain points. """ self.batch_size = batch_size self.duplicates ...
[ "def", "__init__", "(", "self", ",", "batch_size", ",", "duplicates", ")", ":", "self", ".", "batch_size", "=", "batch_size", "self", ".", "duplicates", "=", "duplicates" ]
[ 801, 4 ]
[ 813, 36 ]
python
en
['en', 'error', 'th']
False
random.run
(self, model, obj)
Run random sampling on a user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns ---------- panda...
Run random sampling on a user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Returns ---------- panda...
def run(self, model, obj): """Run random sampling on a user defined domain. Parameters ---------- model : edbo.models Trained model to be sampled. obj : edbo.objective Objective object containing information about the domain. Re...
[ "def", "run", "(", "self", ",", "model", ",", "obj", ")", ":", "# De-duplication", "if", "self", ".", "duplicates", "==", "True", ":", "candidates", "=", "obj", ".", "domain", "else", ":", "candidates", "=", "complement", "(", "obj", ".", "domain", ","...
[ 815, 4 ]
[ 838, 49 ]
python
ca
['ca', 'sv', 'en']
False
BaseSettingsPanel.is_active
(self)
Returns True to display the panel.
Returns True to display the panel.
def is_active(self): """ Returns True to display the panel. """ return True
[ "def", "is_active", "(", "self", ")", ":", "return", "True" ]
[ 81, 4 ]
[ 85, 19 ]
python
en
['en', 'error', 'th']
False
BaseSettingsPanel.get_form
(self)
Returns an initialised form.
Returns an initialised form.
def get_form(self): """ Returns an initialised form. """ kwargs = { 'instance': self.profile if self.form_object == 'profile' else self.user, 'prefix': self.name } if self.request.method == 'POST': return self.form_class(self.request.P...
[ "def", "get_form", "(", "self", ")", ":", "kwargs", "=", "{", "'instance'", ":", "self", ".", "profile", "if", "self", ".", "form_object", "==", "'profile'", "else", "self", ".", "user", ",", "'prefix'", ":", "self", ".", "name", "}", "if", "self", "...
[ 87, 4 ]
[ 99, 44 ]
python
en
['en', 'error', 'th']
False
BaseSettingsPanel.get_context_data
(self)
Returns the template context to use when rendering the template.
Returns the template context to use when rendering the template.
def get_context_data(self): """ Returns the template context to use when rendering the template. """ return { 'form': self.get_form() }
[ "def", "get_context_data", "(", "self", ")", ":", "return", "{", "'form'", ":", "self", ".", "get_form", "(", ")", "}" ]
[ 101, 4 ]
[ 107, 9 ]
python
en
['en', 'error', 'th']
False
BaseSettingsPanel.render
(self)
Renders the panel using the template specified in .template_name and context from .get_context_data()
Renders the panel using the template specified in .template_name and context from .get_context_data()
def render(self): """ Renders the panel using the template specified in .template_name and context from .get_context_data() """ return render_to_string(self.template_name, self.get_context_data(), request=self.request)
[ "def", "render", "(", "self", ")", ":", "return", "render_to_string", "(", "self", ".", "template_name", ",", "self", ".", "get_context_data", "(", ")", ",", "request", "=", "self", ".", "request", ")" ]
[ 109, 4 ]
[ 113, 98 ]
python
en
['en', 'error', 'th']
False
LogFormatter.__init__
(self, color=True, datefmt=None)
r""" :arg bool color: Enables color support. :arg string fmt: Log message format. It will be applied to the attributes dict of log records. The text between ``%(color)s`` and ``%(end_color)s`` will be colored depending on the level if color support is on. :arg dict colors...
r""" :arg bool color: Enables color support. :arg string fmt: Log message format. It will be applied to the attributes dict of log records. The text between ``%(color)s`` and ``%(end_color)s`` will be colored depending on the level if color support is on. :arg dict colors...
def __init__(self, color=True, datefmt=None): r""" :arg bool color: Enables color support. :arg string fmt: Log message format. It will be applied to the attributes dict of log records. The text between ``%(color)s`` and ``%(end_color)s`` will be colored depending on the ...
[ "def", "__init__", "(", "self", ",", "color", "=", "True", ",", "datefmt", "=", "None", ")", ":", "logging", ".", "Formatter", ".", "__init__", "(", "self", ",", "datefmt", "=", "datefmt", ")", "self", ".", "_colors", "=", "{", "}", "if", "color", ...
[ 49, 4 ]
[ 90, 31 ]
python
cy
['en', 'cy', 'hi']
False
numpy_array_from_list_or_numpy_array
(vectors)
Returns numpy array representation of argument. Argument maybe numpy array (input is returned) or a list of numpy vectors.
Returns numpy array representation of argument.
def numpy_array_from_list_or_numpy_array(vectors): """ Returns numpy array representation of argument. Argument maybe numpy array (input is returned) or a list of numpy vectors. """ # If vectors is not a numpy matrix, create one if not isinstance(vectors, numpy.ndarray): V = numpy.z...
[ "def", "numpy_array_from_list_or_numpy_array", "(", "vectors", ")", ":", "# If vectors is not a numpy matrix, create one", "if", "not", "isinstance", "(", "vectors", ",", "numpy", ".", "ndarray", ")", ":", "V", "=", "numpy", ".", "zeros", "(", "(", "vectors", "[",...
[ 27, 0 ]
[ 42, 18 ]
python
en
['en', 'error', 'th']
False
unitvec
(vec)
Scale a vector to unit length. The only exception is the zero vector, which is returned back unchanged.
Scale a vector to unit length. The only exception is the zero vector, which is returned back unchanged.
def unitvec(vec): """ Scale a vector to unit length. The only exception is the zero vector, which is returned back unchanged. """ if scipy.sparse.issparse(vec): # convert scipy.sparse to standard numpy array vec = vec.tocsr() veclen = numpy.sqrt(numpy.sum(vec.data ** 2)) if v...
[ "def", "unitvec", "(", "vec", ")", ":", "if", "scipy", ".", "sparse", ".", "issparse", "(", "vec", ")", ":", "# convert scipy.sparse to standard numpy array", "vec", "=", "vec", ".", "tocsr", "(", ")", "veclen", "=", "numpy", ".", "sqrt", "(", "numpy", "...
[ 45, 0 ]
[ 64, 22 ]
python
en
['en', 'error', 'th']
False
perform_pca
(A)
Computes eigenvalues and eigenvectors of covariance matrix of A. The rows of a correspond to observations, the columns to variables.
Computes eigenvalues and eigenvectors of covariance matrix of A. The rows of a correspond to observations, the columns to variables.
def perform_pca(A): """ Computes eigenvalues and eigenvectors of covariance matrix of A. The rows of a correspond to observations, the columns to variables. """ # First subtract the mean M = (A-numpy.mean(A.T, axis=1)).T # Get eigenvectors and values of covariance matrix return numpy.lin...
[ "def", "perform_pca", "(", "A", ")", ":", "# First subtract the mean", "M", "=", "(", "A", "-", "numpy", ".", "mean", "(", "A", ".", "T", ",", "axis", "=", "1", ")", ")", ".", "T", "# Get eigenvectors and values of covariance matrix", "return", "numpy", "....
[ 67, 0 ]
[ 75, 41 ]
python
en
['en', 'error', 'th']
False