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
BaseDatabaseWrapper.temporary_connection
(self)
Context manager that ensures that a connection is established, and if it opened one, closes it to avoid leaving a dangling connection. This is useful for operations outside of the request-response cycle. Provides a cursor: with self.temporary_connection() as cursor: ...
Context manager that ensures that a connection is established, and if it opened one, closes it to avoid leaving a dangling connection. This is useful for operations outside of the request-response cycle.
def temporary_connection(self): """ Context manager that ensures that a connection is established, and if it opened one, closes it to avoid leaving a dangling connection. This is useful for operations outside of the request-response cycle. Provides a cursor: with self.temporary_...
[ "def", "temporary_connection", "(", "self", ")", ":", "must_close", "=", "self", ".", "connection", "is", "None", "cursor", "=", "self", ".", "cursor", "(", ")", "try", ":", "yield", "cursor", "finally", ":", "cursor", ".", "close", "(", ")", "if", "mu...
[ 455, 4 ]
[ 470, 28 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper._start_transaction_under_autocommit
(self)
Only required when autocommits_when_autocommit_is_off = True.
Only required when autocommits_when_autocommit_is_off = True.
def _start_transaction_under_autocommit(self): """ Only required when autocommits_when_autocommit_is_off = True. """ raise NotImplementedError( 'subclasses of BaseDatabaseWrapper may require a ' '_start_transaction_under_autocommit() method' )
[ "def", "_start_transaction_under_autocommit", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseWrapper may require a '", "'_start_transaction_under_autocommit() method'", ")" ]
[ 472, 4 ]
[ 479, 9 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseWrapper.schema_editor
(self, *args, **kwargs)
Returns a new instance of this backend's SchemaEditor.
Returns a new instance of this backend's SchemaEditor.
def schema_editor(self, *args, **kwargs): """ Returns a new instance of this backend's SchemaEditor. """ if self.SchemaEditorClass is None: raise NotImplementedError( 'The SchemaEditorClass attribute of this database wrapper is still None') return self...
[ "def", "schema_editor", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "SchemaEditorClass", "is", "None", ":", "raise", "NotImplementedError", "(", "'The SchemaEditorClass attribute of this database wrapper is still None'", ")", ...
[ 481, 4 ]
[ 488, 60 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseFeatures.supports_transactions
(self)
Confirm support for transactions.
Confirm support for transactions.
def supports_transactions(self): """Confirm support for transactions.""" with self.connection.cursor() as cursor: cursor.execute('CREATE TABLE ROLLBACK_TEST (X INT)') self.connection.set_autocommit(False) cursor.execute('INSERT INTO ROLLBACK_TEST (X) VALUES (8)') ...
[ "def", "supports_transactions", "(", "self", ")", ":", "with", "self", ".", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "'CREATE TABLE ROLLBACK_TEST (X INT)'", ")", "self", ".", "connection", ".", "set_autocommit", ...
[ 689, 4 ]
[ 700, 25 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseFeatures.supports_stddev
(self)
Confirm support for STDDEV and related stats functions.
Confirm support for STDDEV and related stats functions.
def supports_stddev(self): """Confirm support for STDDEV and related stats functions.""" class StdDevPop(object): sql_function = 'STDDEV_POP' try: self.connection.ops.check_aggregate_support(StdDevPop()) return True except NotImplementedError: ...
[ "def", "supports_stddev", "(", "self", ")", ":", "class", "StdDevPop", "(", "object", ")", ":", "sql_function", "=", "'STDDEV_POP'", "try", ":", "self", ".", "connection", ".", "ops", ".", "check_aggregate_support", "(", "StdDevPop", "(", ")", ")", "return",...
[ 703, 4 ]
[ 712, 24 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseFeatures.introspected_boolean_field_type
(self, field=None, created_separately=False)
What is the type returned when the backend introspects a BooleanField? The optional arguments may be used to give further details of the field to be introspected; in particular, they are provided by Django's test suite: field -- the field definition created_separately -- True if...
What is the type returned when the backend introspects a BooleanField? The optional arguments may be used to give further details of the field to be introspected; in particular, they are provided by Django's test suite: field -- the field definition created_separately -- True if...
def introspected_boolean_field_type(self, field=None, created_separately=False): """ What is the type returned when the backend introspects a BooleanField? The optional arguments may be used to give further details of the field to be introspected; in particular, they are provided by Djan...
[ "def", "introspected_boolean_field_type", "(", "self", ",", "field", "=", "None", ",", "created_separately", "=", "False", ")", ":", "if", "self", ".", "can_introspect_null", "and", "field", "and", "field", ".", "null", ":", "return", "'NullBooleanField'", "retu...
[ 714, 4 ]
[ 729, 29 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.autoinc_sql
(self, table, column)
Returns any SQL needed to support auto-incrementing primary keys, or None if no SQL is necessary. This SQL is executed when a table is created.
Returns any SQL needed to support auto-incrementing primary keys, or None if no SQL is necessary.
def autoinc_sql(self, table, column): """ Returns any SQL needed to support auto-incrementing primary keys, or None if no SQL is necessary. This SQL is executed when a table is created. """ return None
[ "def", "autoinc_sql", "(", "self", ",", "table", ",", "column", ")", ":", "return", "None" ]
[ 754, 4 ]
[ 761, 19 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.bulk_batch_size
(self, fields, objs)
Returns the maximum allowed batch size for the backend. The fields are the fields going to be inserted in the batch, the objs contains all the objects to be inserted.
Returns the maximum allowed batch size for the backend. The fields are the fields going to be inserted in the batch, the objs contains all the objects to be inserted.
def bulk_batch_size(self, fields, objs): """ Returns the maximum allowed batch size for the backend. The fields are the fields going to be inserted in the batch, the objs contains all the objects to be inserted. """ return len(objs)
[ "def", "bulk_batch_size", "(", "self", ",", "fields", ",", "objs", ")", ":", "return", "len", "(", "objs", ")" ]
[ 763, 4 ]
[ 769, 24 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.cache_key_culling_sql
(self)
Returns an SQL query that retrieves the first cache key greater than the n smallest. This is used by the 'db' cache backend to determine where to start culling.
Returns an SQL query that retrieves the first cache key greater than the n smallest.
def cache_key_culling_sql(self): """ Returns an SQL query that retrieves the first cache key greater than the n smallest. This is used by the 'db' cache backend to determine where to start culling. """ return "SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 O...
[ "def", "cache_key_culling_sql", "(", "self", ")", ":", "return", "\"SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OFFSET %%s\"" ]
[ 771, 4 ]
[ 779, 79 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.date_extract_sql
(self, lookup_type, field_name)
Given a lookup_type of 'year', 'month' or 'day', returns the SQL that extracts a value from the given date field field_name.
Given a lookup_type of 'year', 'month' or 'day', returns the SQL that extracts a value from the given date field field_name.
def date_extract_sql(self, lookup_type, field_name): """ Given a lookup_type of 'year', 'month' or 'day', returns the SQL that extracts a value from the given date field field_name. """ raise NotImplementedError('subclasses of BaseDatabaseOperations may require a date_extract_sql...
[ "def", "date_extract_sql", "(", "self", ",", "lookup_type", ",", "field_name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseOperations may require a date_extract_sql() method'", ")" ]
[ 781, 4 ]
[ 786, 113 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.date_interval_sql
(self, sql, connector, timedelta)
Implements the date interval functionality for expressions
Implements the date interval functionality for expressions
def date_interval_sql(self, sql, connector, timedelta): """ Implements the date interval functionality for expressions """ raise NotImplementedError('subclasses of BaseDatabaseOperations may require a date_interval_sql() method')
[ "def", "date_interval_sql", "(", "self", ",", "sql", ",", "connector", ",", "timedelta", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseOperations may require a date_interval_sql() method'", ")" ]
[ 788, 4 ]
[ 792, 114 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.date_trunc_sql
(self, lookup_type, field_name)
Given a lookup_type of 'year', 'month' or 'day', returns the SQL that truncates the given date field field_name to a date object with only the given specificity.
Given a lookup_type of 'year', 'month' or 'day', returns the SQL that truncates the given date field field_name to a date object with only the given specificity.
def date_trunc_sql(self, lookup_type, field_name): """ Given a lookup_type of 'year', 'month' or 'day', returns the SQL that truncates the given date field field_name to a date object with only the given specificity. """ raise NotImplementedError('subclasses of BaseDataba...
[ "def", "date_trunc_sql", "(", "self", ",", "lookup_type", ",", "field_name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseOperations may require a datetrunc_sql() method'", ")" ]
[ 794, 4 ]
[ 800, 110 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.datetime_cast_sql
(self)
Returns the SQL necessary to cast a datetime value so that it will be retrieved as a Python datetime object instead of a string. This SQL should include a '%s' in place of the field's name.
Returns the SQL necessary to cast a datetime value so that it will be retrieved as a Python datetime object instead of a string.
def datetime_cast_sql(self): """ Returns the SQL necessary to cast a datetime value so that it will be retrieved as a Python datetime object instead of a string. This SQL should include a '%s' in place of the field's name. """ return "%s"
[ "def", "datetime_cast_sql", "(", "self", ")", ":", "return", "\"%s\"" ]
[ 802, 4 ]
[ 809, 19 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.datetime_extract_sql
(self, lookup_type, field_name, tzname)
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or 'second', returns the SQL that extracts a value from the given datetime field field_name, and a tuple of parameters.
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or 'second', returns the SQL that extracts a value from the given datetime field field_name, and a tuple of parameters.
def datetime_extract_sql(self, lookup_type, field_name, tzname): """ Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or 'second', returns the SQL that extracts a value from the given datetime field field_name, and a tuple of parameters. """ raise NotImplem...
[ "def", "datetime_extract_sql", "(", "self", ",", "lookup_type", ",", "field_name", ",", "tzname", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseOperations may require a datetime_extract_sql() method'", ")" ]
[ 811, 4 ]
[ 817, 117 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.datetime_trunc_sql
(self, lookup_type, field_name, tzname)
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or 'second', returns the SQL that truncates the given datetime field field_name to a datetime object with only the given specificity, and a tuple of parameters.
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or 'second', returns the SQL that truncates the given datetime field field_name to a datetime object with only the given specificity, and a tuple of parameters.
def datetime_trunc_sql(self, lookup_type, field_name, tzname): """ Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or 'second', returns the SQL that truncates the given datetime field field_name to a datetime object with only the given specificity, and a tuple of ...
[ "def", "datetime_trunc_sql", "(", "self", ",", "lookup_type", ",", "field_name", ",", "tzname", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseOperations may require a datetime_trunk_sql() method'", ")" ]
[ 819, 4 ]
[ 826, 115 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.deferrable_sql
(self)
Returns the SQL necessary to make a constraint "initially deferred" during a CREATE TABLE statement.
Returns the SQL necessary to make a constraint "initially deferred" during a CREATE TABLE statement.
def deferrable_sql(self): """ Returns the SQL necessary to make a constraint "initially deferred" during a CREATE TABLE statement. """ return ''
[ "def", "deferrable_sql", "(", "self", ")", ":", "return", "''" ]
[ 828, 4 ]
[ 833, 17 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.distinct_sql
(self, fields)
Returns an SQL DISTINCT clause which removes duplicate rows from the result set. If any fields are given, only the given fields are being checked for duplicates.
Returns an SQL DISTINCT clause which removes duplicate rows from the result set. If any fields are given, only the given fields are being checked for duplicates.
def distinct_sql(self, fields): """ Returns an SQL DISTINCT clause which removes duplicate rows from the result set. If any fields are given, only the given fields are being checked for duplicates. """ if fields: raise NotImplementedError('DISTINCT ON fields i...
[ "def", "distinct_sql", "(", "self", ",", "fields", ")", ":", "if", "fields", ":", "raise", "NotImplementedError", "(", "'DISTINCT ON fields is not supported by this database backend'", ")", "else", ":", "return", "'DISTINCT'" ]
[ 835, 4 ]
[ 844, 29 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.drop_foreignkey_sql
(self)
Returns the SQL command that drops a foreign key.
Returns the SQL command that drops a foreign key.
def drop_foreignkey_sql(self): """ Returns the SQL command that drops a foreign key. """ return "DROP CONSTRAINT"
[ "def", "drop_foreignkey_sql", "(", "self", ")", ":", "return", "\"DROP CONSTRAINT\"" ]
[ 846, 4 ]
[ 850, 32 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.drop_sequence_sql
(self, table)
Returns any SQL necessary to drop the sequence for the given table. Returns None if no SQL is necessary.
Returns any SQL necessary to drop the sequence for the given table. Returns None if no SQL is necessary.
def drop_sequence_sql(self, table): """ Returns any SQL necessary to drop the sequence for the given table. Returns None if no SQL is necessary. """ return None
[ "def", "drop_sequence_sql", "(", "self", ",", "table", ")", ":", "return", "None" ]
[ 852, 4 ]
[ 857, 19 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.fetch_returned_insert_id
(self, cursor)
Given a cursor object that has just performed an INSERT...RETURNING statement into a table that has an auto-incrementing ID, returns the newly created ID.
Given a cursor object that has just performed an INSERT...RETURNING statement into a table that has an auto-incrementing ID, returns the newly created ID.
def fetch_returned_insert_id(self, cursor): """ Given a cursor object that has just performed an INSERT...RETURNING statement into a table that has an auto-incrementing ID, returns the newly created ID. """ return cursor.fetchone()[0]
[ "def", "fetch_returned_insert_id", "(", "self", ",", "cursor", ")", ":", "return", "cursor", ".", "fetchone", "(", ")", "[", "0", "]" ]
[ 859, 4 ]
[ 865, 35 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.field_cast_sql
(self, db_type, internal_type)
Given a column type (e.g. 'BLOB', 'VARCHAR'), and an internal type (e.g. 'GenericIPAddressField'), returns the SQL necessary to cast it before using it in a WHERE statement. Note that the resulting string should contain a '%s' placeholder for the column being searched against.
Given a column type (e.g. 'BLOB', 'VARCHAR'), and an internal type (e.g. 'GenericIPAddressField'), returns the SQL necessary to cast it before using it in a WHERE statement. Note that the resulting string should contain a '%s' placeholder for the column being searched against.
def field_cast_sql(self, db_type, internal_type): """ Given a column type (e.g. 'BLOB', 'VARCHAR'), and an internal type (e.g. 'GenericIPAddressField'), returns the SQL necessary to cast it before using it in a WHERE statement. Note that the resulting string should contain a '%s'...
[ "def", "field_cast_sql", "(", "self", ",", "db_type", ",", "internal_type", ")", ":", "return", "'%s'" ]
[ 867, 4 ]
[ 874, 19 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.force_no_ordering
(self)
Returns a list used in the "ORDER BY" clause to force no ordering at all. Returning an empty list means that nothing will be included in the ordering.
Returns a list used in the "ORDER BY" clause to force no ordering at all. Returning an empty list means that nothing will be included in the ordering.
def force_no_ordering(self): """ Returns a list used in the "ORDER BY" clause to force no ordering at all. Returning an empty list means that nothing will be included in the ordering. """ return []
[ "def", "force_no_ordering", "(", "self", ")", ":", "return", "[", "]" ]
[ 876, 4 ]
[ 882, 17 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.for_update_sql
(self, nowait=False)
Returns the FOR UPDATE SQL clause to lock rows for an update operation.
Returns the FOR UPDATE SQL clause to lock rows for an update operation.
def for_update_sql(self, nowait=False): """ Returns the FOR UPDATE SQL clause to lock rows for an update operation. """ if nowait: return 'FOR UPDATE NOWAIT' else: return 'FOR UPDATE'
[ "def", "for_update_sql", "(", "self", ",", "nowait", "=", "False", ")", ":", "if", "nowait", ":", "return", "'FOR UPDATE NOWAIT'", "else", ":", "return", "'FOR UPDATE'" ]
[ 884, 4 ]
[ 891, 31 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.fulltext_search_sql
(self, field_name)
Returns the SQL WHERE clause to use in order to perform a full-text search of the given field_name. Note that the resulting string should contain a '%s' placeholder for the value being searched against.
Returns the SQL WHERE clause to use in order to perform a full-text search of the given field_name. Note that the resulting string should contain a '%s' placeholder for the value being searched against.
def fulltext_search_sql(self, field_name): """ Returns the SQL WHERE clause to use in order to perform a full-text search of the given field_name. Note that the resulting string should contain a '%s' placeholder for the value being searched against. """ raise NotImplement...
[ "def", "fulltext_search_sql", "(", "self", ",", "field_name", ")", ":", "raise", "NotImplementedError", "(", "'Full-text search is not implemented for this database backend'", ")" ]
[ 893, 4 ]
[ 899, 98 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.last_executed_query
(self, cursor, sql, params)
Returns a string of the query last executed by the given cursor, with placeholders replaced with actual values. `sql` is the raw query containing placeholders, and `params` is the sequence of parameters. These are used by default, but this method exists for database backends to...
Returns a string of the query last executed by the given cursor, with placeholders replaced with actual values.
def last_executed_query(self, cursor, sql, params): """ Returns a string of the query last executed by the given cursor, with placeholders replaced with actual values. `sql` is the raw query containing placeholders, and `params` is the sequence of parameters. These are used by d...
[ "def", "last_executed_query", "(", "self", ",", "cursor", ",", "sql", ",", "params", ")", ":", "from", "django", ".", "utils", ".", "encoding", "import", "force_text", "# Convert params to contain Unicode values.", "to_unicode", "=", "lambda", "s", ":", "force_tex...
[ 901, 4 ]
[ 922, 74 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.last_insert_id
(self, cursor, table_name, pk_name)
Given a cursor object that has just performed an INSERT statement into a table that has an auto-incrementing ID, returns the newly created ID. This method also receives the table name and the name of the primary-key column.
Given a cursor object that has just performed an INSERT statement into a table that has an auto-incrementing ID, returns the newly created ID.
def last_insert_id(self, cursor, table_name, pk_name): """ Given a cursor object that has just performed an INSERT statement into a table that has an auto-incrementing ID, returns the newly created ID. This method also receives the table name and the name of the primary-key colu...
[ "def", "last_insert_id", "(", "self", ",", "cursor", ",", "table_name", ",", "pk_name", ")", ":", "return", "cursor", ".", "lastrowid" ]
[ 924, 4 ]
[ 932, 31 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.lookup_cast
(self, lookup_type)
Returns the string to use in a query when performing lookups ("contains", "like", etc). The resulting string should contain a '%s' placeholder for the column being searched against.
Returns the string to use in a query when performing lookups ("contains", "like", etc). The resulting string should contain a '%s' placeholder for the column being searched against.
def lookup_cast(self, lookup_type): """ Returns the string to use in a query when performing lookups ("contains", "like", etc). The resulting string should contain a '%s' placeholder for the column being searched against. """ return "%s"
[ "def", "lookup_cast", "(", "self", ",", "lookup_type", ")", ":", "return", "\"%s\"" ]
[ 934, 4 ]
[ 940, 19 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.max_in_list_size
(self)
Returns the maximum number of items that can be passed in a single 'IN' list condition, or None if the backend does not impose a limit.
Returns the maximum number of items that can be passed in a single 'IN' list condition, or None if the backend does not impose a limit.
def max_in_list_size(self): """ Returns the maximum number of items that can be passed in a single 'IN' list condition, or None if the backend does not impose a limit. """ return None
[ "def", "max_in_list_size", "(", "self", ")", ":", "return", "None" ]
[ 942, 4 ]
[ 947, 19 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.max_name_length
(self)
Returns the maximum length of table and column names, or None if there is no limit.
Returns the maximum length of table and column names, or None if there is no limit.
def max_name_length(self): """ Returns the maximum length of table and column names, or None if there is no limit. """ return None
[ "def", "max_name_length", "(", "self", ")", ":", "return", "None" ]
[ 949, 4 ]
[ 954, 19 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.no_limit_value
(self)
Returns the value to use for the LIMIT when we are wanting "LIMIT infinity". Returns None if the limit clause can be omitted in this case.
Returns the value to use for the LIMIT when we are wanting "LIMIT infinity". Returns None if the limit clause can be omitted in this case.
def no_limit_value(self): """ Returns the value to use for the LIMIT when we are wanting "LIMIT infinity". Returns None if the limit clause can be omitted in this case. """ raise NotImplementedError('subclasses of BaseDatabaseOperations may require a no_limit_value() method')
[ "def", "no_limit_value", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseOperations may require a no_limit_value() method'", ")" ]
[ 956, 4 ]
[ 961, 111 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.pk_default_value
(self)
Returns the value to use during an INSERT statement to specify that the field should use its default value.
Returns the value to use during an INSERT statement to specify that the field should use its default value.
def pk_default_value(self): """ Returns the value to use during an INSERT statement to specify that the field should use its default value. """ return 'DEFAULT'
[ "def", "pk_default_value", "(", "self", ")", ":", "return", "'DEFAULT'" ]
[ 963, 4 ]
[ 968, 24 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.prepare_sql_script
(self, sql, _allow_fallback=False)
Takes a SQL script that may contain multiple lines and returns a list of statements to feed to successive cursor.execute() calls. Since few databases are able to process raw SQL scripts in a single cursor.execute() call and PEP 249 doesn't talk about this use case, the default ...
Takes a SQL script that may contain multiple lines and returns a list of statements to feed to successive cursor.execute() calls.
def prepare_sql_script(self, sql, _allow_fallback=False): """ Takes a SQL script that may contain multiple lines and returns a list of statements to feed to successive cursor.execute() calls. Since few databases are able to process raw SQL scripts in a single cursor.execute() ca...
[ "def", "prepare_sql_script", "(", "self", ",", "sql", ",", "_allow_fallback", "=", "False", ")", ":", "# Remove _allow_fallback and keep only 'return ...' in Django 1.9.", "try", ":", "# This import must stay inside the method because it's optional.", "import", "sqlparse", "excep...
[ 970, 4 ]
[ 996, 70 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.process_clob
(self, value)
Returns the value of a CLOB column, for backends that return a locator object that requires additional processing.
Returns the value of a CLOB column, for backends that return a locator object that requires additional processing.
def process_clob(self, value): """ Returns the value of a CLOB column, for backends that return a locator object that requires additional processing. """ return value
[ "def", "process_clob", "(", "self", ",", "value", ")", ":", "return", "value" ]
[ 998, 4 ]
[ 1003, 20 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.return_insert_id
(self)
For backends that support returning the last insert ID as part of an insert query, this method returns the SQL and params to append to the INSERT query. The returned fragment should contain a format string to hold the appropriate column.
For backends that support returning the last insert ID as part of an insert query, this method returns the SQL and params to append to the INSERT query. The returned fragment should contain a format string to hold the appropriate column.
def return_insert_id(self): """ For backends that support returning the last insert ID as part of an insert query, this method returns the SQL and params to append to the INSERT query. The returned fragment should contain a format string to hold the appropriate column. ""...
[ "def", "return_insert_id", "(", "self", ")", ":", "pass" ]
[ 1005, 4 ]
[ 1012, 12 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.compiler
(self, compiler_name)
Returns the SQLCompiler class corresponding to the given name, in the namespace corresponding to the `compiler_module` attribute on this backend.
Returns the SQLCompiler class corresponding to the given name, in the namespace corresponding to the `compiler_module` attribute on this backend.
def compiler(self, compiler_name): """ Returns the SQLCompiler class corresponding to the given name, in the namespace corresponding to the `compiler_module` attribute on this backend. """ if self._cache is None: self._cache = import_module(self.compiler_modul...
[ "def", "compiler", "(", "self", ",", "compiler_name", ")", ":", "if", "self", ".", "_cache", "is", "None", ":", "self", ".", "_cache", "=", "import_module", "(", "self", ".", "compiler_module", ")", "return", "getattr", "(", "self", ".", "_cache", ",", ...
[ 1014, 4 ]
[ 1022, 50 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.quote_name
(self, name)
Returns a quoted version of the given table, index or column name. Does not quote the given name if it's already been quoted.
Returns a quoted version of the given table, index or column name. Does not quote the given name if it's already been quoted.
def quote_name(self, name): """ Returns a quoted version of the given table, index or column name. Does not quote the given name if it's already been quoted. """ raise NotImplementedError('subclasses of BaseDatabaseOperations may require a quote_name() method')
[ "def", "quote_name", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseOperations may require a quote_name() method'", ")" ]
[ 1024, 4 ]
[ 1029, 107 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.random_function_sql
(self)
Returns an SQL expression that returns a random value.
Returns an SQL expression that returns a random value.
def random_function_sql(self): """ Returns an SQL expression that returns a random value. """ return 'RANDOM()'
[ "def", "random_function_sql", "(", "self", ")", ":", "return", "'RANDOM()'" ]
[ 1031, 4 ]
[ 1035, 25 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.regex_lookup
(self, lookup_type)
Returns the string to use in a query when performing regular expression lookups (using "regex" or "iregex"). The resulting string should contain a '%s' placeholder for the column being searched against. If the feature is not supported (or part of it is not supported), a NotImpl...
Returns the string to use in a query when performing regular expression lookups (using "regex" or "iregex"). The resulting string should contain a '%s' placeholder for the column being searched against.
def regex_lookup(self, lookup_type): """ Returns the string to use in a query when performing regular expression lookups (using "regex" or "iregex"). The resulting string should contain a '%s' placeholder for the column being searched against. If the feature is not supported (or...
[ "def", "regex_lookup", "(", "self", ",", "lookup_type", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseOperations may require a regex_lookup() method'", ")" ]
[ 1037, 4 ]
[ 1046, 109 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.savepoint_create_sql
(self, sid)
Returns the SQL for starting a new savepoint. Only required if the "uses_savepoints" feature is True. The "sid" parameter is a string for the savepoint id.
Returns the SQL for starting a new savepoint. Only required if the "uses_savepoints" feature is True. The "sid" parameter is a string for the savepoint id.
def savepoint_create_sql(self, sid): """ Returns the SQL for starting a new savepoint. Only required if the "uses_savepoints" feature is True. The "sid" parameter is a string for the savepoint id. """ return "SAVEPOINT %s" % self.quote_name(sid)
[ "def", "savepoint_create_sql", "(", "self", ",", "sid", ")", ":", "return", "\"SAVEPOINT %s\"", "%", "self", ".", "quote_name", "(", "sid", ")" ]
[ 1048, 4 ]
[ 1054, 52 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.savepoint_commit_sql
(self, sid)
Returns the SQL for committing the given savepoint.
Returns the SQL for committing the given savepoint.
def savepoint_commit_sql(self, sid): """ Returns the SQL for committing the given savepoint. """ return "RELEASE SAVEPOINT %s" % self.quote_name(sid)
[ "def", "savepoint_commit_sql", "(", "self", ",", "sid", ")", ":", "return", "\"RELEASE SAVEPOINT %s\"", "%", "self", ".", "quote_name", "(", "sid", ")" ]
[ 1056, 4 ]
[ 1060, 60 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.savepoint_rollback_sql
(self, sid)
Returns the SQL for rolling back the given savepoint.
Returns the SQL for rolling back the given savepoint.
def savepoint_rollback_sql(self, sid): """ Returns the SQL for rolling back the given savepoint. """ return "ROLLBACK TO SAVEPOINT %s" % self.quote_name(sid)
[ "def", "savepoint_rollback_sql", "(", "self", ",", "sid", ")", ":", "return", "\"ROLLBACK TO SAVEPOINT %s\"", "%", "self", ".", "quote_name", "(", "sid", ")" ]
[ 1062, 4 ]
[ 1066, 64 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.set_time_zone_sql
(self)
Returns the SQL that will set the connection's time zone. Returns '' if the backend doesn't support time zones.
Returns the SQL that will set the connection's time zone.
def set_time_zone_sql(self): """ Returns the SQL that will set the connection's time zone. Returns '' if the backend doesn't support time zones. """ return ''
[ "def", "set_time_zone_sql", "(", "self", ")", ":", "return", "''" ]
[ 1068, 4 ]
[ 1074, 17 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.sql_flush
(self, style, tables, sequences, allow_cascade=False)
Returns a list of SQL statements required to remove all data from the given database tables (without actually removing the tables themselves). The returned value also includes SQL statements required to reset DB sequences passed in :param sequences:. The `style` argume...
Returns a list of SQL statements required to remove all data from the given database tables (without actually removing the tables themselves).
def sql_flush(self, style, tables, sequences, allow_cascade=False): """ Returns a list of SQL statements required to remove all data from the given database tables (without actually removing the tables themselves). The returned value also includes SQL statements required to rese...
[ "def", "sql_flush", "(", "self", ",", "style", ",", "tables", ",", "sequences", ",", "allow_cascade", "=", "False", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseOperations must provide a sql_flush() method'", ")" ]
[ 1076, 4 ]
[ 1092, 107 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.sequence_reset_by_name_sql
(self, style, sequences)
Returns a list of the SQL statements required to reset sequences passed in :param sequences:. The `style` argument is a Style object as returned by either color_style() or no_style() in django.core.management.color.
Returns a list of the SQL statements required to reset sequences passed in :param sequences:.
def sequence_reset_by_name_sql(self, style, sequences): """ Returns a list of the SQL statements required to reset sequences passed in :param sequences:. The `style` argument is a Style object as returned by either color_style() or no_style() in django.core.management.color. ...
[ "def", "sequence_reset_by_name_sql", "(", "self", ",", "style", ",", "sequences", ")", ":", "return", "[", "]" ]
[ 1094, 4 ]
[ 1102, 17 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.sequence_reset_sql
(self, style, model_list)
Returns a list of the SQL statements required to reset sequences for the given models. The `style` argument is a Style object as returned by either color_style() or no_style() in django.core.management.color.
Returns a list of the SQL statements required to reset sequences for the given models.
def sequence_reset_sql(self, style, model_list): """ Returns a list of the SQL statements required to reset sequences for the given models. The `style` argument is a Style object as returned by either color_style() or no_style() in django.core.management.color. """ ...
[ "def", "sequence_reset_sql", "(", "self", ",", "style", ",", "model_list", ")", ":", "return", "[", "]" ]
[ 1104, 4 ]
[ 1112, 17 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.start_transaction_sql
(self)
Returns the SQL statement required to start a transaction.
Returns the SQL statement required to start a transaction.
def start_transaction_sql(self): """ Returns the SQL statement required to start a transaction. """ return "BEGIN;"
[ "def", "start_transaction_sql", "(", "self", ")", ":", "return", "\"BEGIN;\"" ]
[ 1114, 4 ]
[ 1118, 23 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.end_transaction_sql
(self, success=True)
Returns the SQL statement required to end a transaction.
Returns the SQL statement required to end a transaction.
def end_transaction_sql(self, success=True): """ Returns the SQL statement required to end a transaction. """ if not success: return "ROLLBACK;" return "COMMIT;"
[ "def", "end_transaction_sql", "(", "self", ",", "success", "=", "True", ")", ":", "if", "not", "success", ":", "return", "\"ROLLBACK;\"", "return", "\"COMMIT;\"" ]
[ 1120, 4 ]
[ 1126, 24 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.tablespace_sql
(self, tablespace, inline=False)
Returns the SQL that will be used in a query to define the tablespace. Returns '' if the backend doesn't support tablespaces. If inline is True, the SQL is appended to a row; otherwise it's appended to the entire CREATE TABLE or CREATE INDEX statement.
Returns the SQL that will be used in a query to define the tablespace.
def tablespace_sql(self, tablespace, inline=False): """ Returns the SQL that will be used in a query to define the tablespace. Returns '' if the backend doesn't support tablespaces. If inline is True, the SQL is appended to a row; otherwise it's appended to the entire CREATE TA...
[ "def", "tablespace_sql", "(", "self", ",", "tablespace", ",", "inline", "=", "False", ")", ":", "return", "''" ]
[ 1128, 4 ]
[ 1137, 17 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.prep_for_like_query
(self, x)
Prepares a value for use in a LIKE query.
Prepares a value for use in a LIKE query.
def prep_for_like_query(self, x): """Prepares a value for use in a LIKE query.""" from django.utils.encoding import force_text return force_text(x).replace("\\", "\\\\").replace("%", "\%").replace("_", "\_")
[ "def", "prep_for_like_query", "(", "self", ",", "x", ")", ":", "from", "django", ".", "utils", ".", "encoding", "import", "force_text", "return", "force_text", "(", "x", ")", ".", "replace", "(", "\"\\\\\"", ",", "\"\\\\\\\\\"", ")", ".", "replace", "(", ...
[ 1139, 4 ]
[ 1142, 88 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseOperations.validate_autopk_value
(self, value)
Certain backends do not accept some values for "serial" fields (for example zero in MySQL). This method will raise a ValueError if the value is invalid, otherwise returns validated value.
Certain backends do not accept some values for "serial" fields (for example zero in MySQL). This method will raise a ValueError if the value is invalid, otherwise returns validated value.
def validate_autopk_value(self, value): """ Certain backends do not accept some values for "serial" fields (for example zero in MySQL). This method will raise a ValueError if the value is invalid, otherwise returns validated value. """ return value
[ "def", "validate_autopk_value", "(", "self", ",", "value", ")", ":", "return", "value" ]
[ 1148, 4 ]
[ 1154, 20 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.value_to_db_date
(self, value)
Transform a date value to an object compatible with what is expected by the backend driver for date columns.
Transform a date value to an object compatible with what is expected by the backend driver for date columns.
def value_to_db_date(self, value): """ Transform a date value to an object compatible with what is expected by the backend driver for date columns. """ if value is None: return None return six.text_type(value)
[ "def", "value_to_db_date", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "return", "six", ".", "text_type", "(", "value", ")" ]
[ 1156, 4 ]
[ 1163, 35 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.value_to_db_datetime
(self, value)
Transform a datetime value to an object compatible with what is expected by the backend driver for datetime columns.
Transform a datetime value to an object compatible with what is expected by the backend driver for datetime columns.
def value_to_db_datetime(self, value): """ Transform a datetime value to an object compatible with what is expected by the backend driver for datetime columns. """ if value is None: return None return six.text_type(value)
[ "def", "value_to_db_datetime", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "return", "six", ".", "text_type", "(", "value", ")" ]
[ 1165, 4 ]
[ 1172, 35 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.value_to_db_time
(self, value)
Transform a time value to an object compatible with what is expected by the backend driver for time columns.
Transform a time value to an object compatible with what is expected by the backend driver for time columns.
def value_to_db_time(self, value): """ Transform a time value to an object compatible with what is expected by the backend driver for time columns. """ if value is None: return None if timezone.is_aware(value): raise ValueError("Django does not sup...
[ "def", "value_to_db_time", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "if", "timezone", ".", "is_aware", "(", "value", ")", ":", "raise", "ValueError", "(", "\"Django does not support timezone-aware times.\"", ")", ...
[ 1174, 4 ]
[ 1183, 35 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.value_to_db_decimal
(self, value, max_digits, decimal_places)
Transform a decimal.Decimal value to an object compatible with what is expected by the backend driver for decimal (numeric) columns.
Transform a decimal.Decimal value to an object compatible with what is expected by the backend driver for decimal (numeric) columns.
def value_to_db_decimal(self, value, max_digits, decimal_places): """ Transform a decimal.Decimal value to an object compatible with what is expected by the backend driver for decimal (numeric) columns. """ if value is None: return None return utils.format_num...
[ "def", "value_to_db_decimal", "(", "self", ",", "value", ",", "max_digits", ",", "decimal_places", ")", ":", "if", "value", "is", "None", ":", "return", "None", "return", "utils", ".", "format_number", "(", "value", ",", "max_digits", ",", "decimal_places", ...
[ 1185, 4 ]
[ 1192, 69 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.year_lookup_bounds_for_date_field
(self, value)
Returns a two-elements list with the lower and upper bound to be used with a BETWEEN operator to query a DateField value using a year lookup. `value` is an int, containing the looked-up year.
Returns a two-elements list with the lower and upper bound to be used with a BETWEEN operator to query a DateField value using a year lookup.
def year_lookup_bounds_for_date_field(self, value): """ Returns a two-elements list with the lower and upper bound to be used with a BETWEEN operator to query a DateField value using a year lookup. `value` is an int, containing the looked-up year. """ first = dat...
[ "def", "year_lookup_bounds_for_date_field", "(", "self", ",", "value", ")", ":", "first", "=", "datetime", ".", "date", "(", "value", ",", "1", ",", "1", ")", "second", "=", "datetime", ".", "date", "(", "value", ",", "12", ",", "31", ")", "return", ...
[ 1194, 4 ]
[ 1204, 30 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.year_lookup_bounds_for_datetime_field
(self, value)
Returns a two-elements list with the lower and upper bound to be used with a BETWEEN operator to query a DateTimeField value using a year lookup. `value` is an int, containing the looked-up year.
Returns a two-elements list with the lower and upper bound to be used with a BETWEEN operator to query a DateTimeField value using a year lookup.
def year_lookup_bounds_for_datetime_field(self, value): """ Returns a two-elements list with the lower and upper bound to be used with a BETWEEN operator to query a DateTimeField value using a year lookup. `value` is an int, containing the looked-up year. """ fir...
[ "def", "year_lookup_bounds_for_datetime_field", "(", "self", ",", "value", ")", ":", "first", "=", "datetime", ".", "datetime", "(", "value", ",", "1", ",", "1", ")", "second", "=", "datetime", ".", "datetime", "(", "value", ",", "12", ",", "31", ",", ...
[ 1206, 4 ]
[ 1220, 30 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseOperations.get_db_converters
(self, internal_type)
Get a list of functions needed to convert field data. Some field types on some backends do not provide data in the correct format, this is the hook for coverter functions.
Get a list of functions needed to convert field data.
def get_db_converters(self, internal_type): """Get a list of functions needed to convert field data. Some field types on some backends do not provide data in the correct format, this is the hook for coverter functions. """ return []
[ "def", "get_db_converters", "(", "self", ",", "internal_type", ")", ":", "return", "[", "]" ]
[ 1222, 4 ]
[ 1228, 17 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseOperations.check_aggregate_support
(self, aggregate_func)
Check that the backend supports the provided aggregate This is used on specific backends to rule out known aggregates that are known to have faulty implementations. If the named aggregate function has a known problem, the backend should raise NotImplementedError.
Check that the backend supports the provided aggregate
def check_aggregate_support(self, aggregate_func): """Check that the backend supports the provided aggregate This is used on specific backends to rule out known aggregates that are known to have faulty implementations. If the named aggregate function has a known problem, the backend sho...
[ "def", "check_aggregate_support", "(", "self", ",", "aggregate_func", ")", ":", "pass" ]
[ 1230, 4 ]
[ 1238, 12 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseOperations.combine_expression
(self, connector, sub_expressions)
Combine a list of subexpressions into a single expression, using the provided connecting operator. This is required because operators can vary between backends (e.g., Oracle with %% and &) and between subexpression types (e.g., date expressions)
Combine a list of subexpressions into a single expression, using the provided connecting operator. This is required because operators can vary between backends (e.g., Oracle with %% and &) and between subexpression types (e.g., date expressions)
def combine_expression(self, connector, sub_expressions): """Combine a list of subexpressions into a single expression, using the provided connecting operator. This is required because operators can vary between backends (e.g., Oracle with %% and &) and between subexpression types (e.g.,...
[ "def", "combine_expression", "(", "self", ",", "connector", ",", "sub_expressions", ")", ":", "conn", "=", "' %s '", "%", "connector", "return", "conn", ".", "join", "(", "sub_expressions", ")" ]
[ 1240, 4 ]
[ 1247, 41 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseOperations.modify_insert_params
(self, placeholders, params)
Allow modification of insert parameters. Needed for Oracle Spatial backend due to #10888.
Allow modification of insert parameters. Needed for Oracle Spatial backend due to #10888.
def modify_insert_params(self, placeholders, params): """Allow modification of insert parameters. Needed for Oracle Spatial backend due to #10888. """ return params
[ "def", "modify_insert_params", "(", "self", ",", "placeholders", ",", "params", ")", ":", "return", "params" ]
[ 1249, 4 ]
[ 1253, 21 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseOperations.integer_field_range
(self, internal_type)
Given an integer field internal type (e.g. 'PositiveIntegerField'), returns a tuple of the (min_value, max_value) form representing the range of the column type bound to the field.
Given an integer field internal type (e.g. 'PositiveIntegerField'), returns a tuple of the (min_value, max_value) form representing the range of the column type bound to the field.
def integer_field_range(self, internal_type): """ Given an integer field internal type (e.g. 'PositiveIntegerField'), returns a tuple of the (min_value, max_value) form representing the range of the column type bound to the field. """ return self.integer_field_ranges[inte...
[ "def", "integer_field_range", "(", "self", ",", "internal_type", ")", ":", "return", "self", ".", "integer_field_ranges", "[", "internal_type", "]" ]
[ 1255, 4 ]
[ 1261, 55 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.get_field_type
(self, data_type, description)
Hook for a database backend to use the cursor description to match a Django field type to a database column. For Oracle, the column data_type on its own is insufficient to distinguish between a FloatField and IntegerField, for example.
Hook for a database backend to use the cursor description to match a Django field type to a database column.
def get_field_type(self, data_type, description): """Hook for a database backend to use the cursor description to match a Django field type to a database column. For Oracle, the column data_type on its own is insufficient to distinguish between a FloatField and IntegerField, for example...
[ "def", "get_field_type", "(", "self", ",", "data_type", ",", "description", ")", ":", "return", "self", ".", "data_types_reverse", "[", "data_type", "]" ]
[ 1273, 4 ]
[ 1279, 49 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseIntrospection.table_name_converter
(self, name)
Apply a conversion to the name for the purposes of comparison. The default table name converter is for case sensitive comparison.
Apply a conversion to the name for the purposes of comparison.
def table_name_converter(self, name): """Apply a conversion to the name for the purposes of comparison. The default table name converter is for case sensitive comparison. """ return name
[ "def", "table_name_converter", "(", "self", ",", "name", ")", ":", "return", "name" ]
[ 1281, 4 ]
[ 1286, 19 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseIntrospection.column_name_converter
(self, name)
Apply a conversion to the column name for the purposes of comparison. Uses table_name_converter() by default.
Apply a conversion to the column name for the purposes of comparison.
def column_name_converter(self, name): """ Apply a conversion to the column name for the purposes of comparison. Uses table_name_converter() by default. """ return self.table_name_converter(name)
[ "def", "column_name_converter", "(", "self", ",", "name", ")", ":", "return", "self", ".", "table_name_converter", "(", "name", ")" ]
[ 1288, 4 ]
[ 1294, 46 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.table_names
(self, cursor=None, include_views=False)
Returns a list of names of all tables that exist in the database. The returned table list is sorted by Python's default sorting. We do NOT use database's ORDER BY here to avoid subtle differences in sorting order between databases.
Returns a list of names of all tables that exist in the database. The returned table list is sorted by Python's default sorting. We do NOT use database's ORDER BY here to avoid subtle differences in sorting order between databases.
def table_names(self, cursor=None, include_views=False): """ Returns a list of names of all tables that exist in the database. The returned table list is sorted by Python's default sorting. We do NOT use database's ORDER BY here to avoid subtle differences in sorting order betwee...
[ "def", "table_names", "(", "self", ",", "cursor", "=", "None", ",", "include_views", "=", "False", ")", ":", "def", "get_names", "(", "cursor", ")", ":", "return", "sorted", "(", "[", "ti", ".", "name", "for", "ti", "in", "self", ".", "get_table_list",...
[ 1296, 4 ]
[ 1309, 32 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.get_table_list
(self, cursor)
Returns an unsorted list of TableInfo named tuples of all tables and views that exist in the database.
Returns an unsorted list of TableInfo named tuples of all tables and views that exist in the database.
def get_table_list(self, cursor): """ Returns an unsorted list of TableInfo named tuples of all tables and views that exist in the database. """ raise NotImplementedError('subclasses of BaseDatabaseIntrospection may require a get_table_list() method')
[ "def", "get_table_list", "(", "self", ",", "cursor", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseIntrospection may require a get_table_list() method'", ")" ]
[ 1311, 4 ]
[ 1316, 114 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.django_table_names
(self, only_existing=False, include_views=True)
Returns a list of all table names that have associated Django models and are in INSTALLED_APPS. If only_existing is True, the resulting list will only include the tables that actually exist in the database.
Returns a list of all table names that have associated Django models and are in INSTALLED_APPS.
def django_table_names(self, only_existing=False, include_views=True): """ Returns a list of all table names that have associated Django models and are in INSTALLED_APPS. If only_existing is True, the resulting list will only include the tables that actually exist in the databas...
[ "def", "django_table_names", "(", "self", ",", "only_existing", "=", "False", ",", "include_views", "=", "True", ")", ":", "from", "django", ".", "apps", "import", "apps", "from", "django", ".", "db", "import", "router", "tables", "=", "set", "(", ")", "...
[ 1318, 4 ]
[ 1343, 21 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.installed_models
(self, tables)
Returns a set of all models represented by the provided list of table names.
Returns a set of all models represented by the provided list of table names.
def installed_models(self, tables): "Returns a set of all models represented by the provided list of table names." from django.apps import apps from django.db import router all_models = [] for app_config in apps.get_app_configs(): all_models.extend(router.get_migratab...
[ "def", "installed_models", "(", "self", ",", "tables", ")", ":", "from", "django", ".", "apps", "import", "apps", "from", "django", ".", "db", "import", "router", "all_models", "=", "[", "]", "for", "app_config", "in", "apps", ".", "get_app_configs", "(", ...
[ 1345, 4 ]
[ 1356, 9 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseIntrospection.sequence_list
(self)
Returns a list of information about all DB sequences for all models in all apps.
Returns a list of information about all DB sequences for all models in all apps.
def sequence_list(self): "Returns a list of information about all DB sequences for all models in all apps." from django.apps import apps from django.db import models, router sequence_list = [] for app_config in apps.get_app_configs(): for model in router.get_migrata...
[ "def", "sequence_list", "(", "self", ")", ":", "from", "django", ".", "apps", "import", "apps", "from", "django", ".", "db", "import", "models", ",", "router", "sequence_list", "=", "[", "]", "for", "app_config", "in", "apps", ".", "get_app_configs", "(", ...
[ 1358, 4 ]
[ 1382, 28 ]
python
en
['en', 'en', 'en']
True
BaseDatabaseIntrospection.get_key_columns
(self, cursor, table_name)
Backends can override this to return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table.
Backends can override this to return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table.
def get_key_columns(self, cursor, table_name): """ Backends can override this to return a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table. """ raise NotImplementedError('subclasses of BaseDatabaseIntrospection may require a ...
[ "def", "get_key_columns", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseIntrospection may require a get_key_columns() method'", ")" ]
[ 1384, 4 ]
[ 1389, 115 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.get_primary_key_column
(self, cursor, table_name)
Returns the name of the primary key column for the given table.
Returns the name of the primary key column for the given table.
def get_primary_key_column(self, cursor, table_name): """ Returns the name of the primary key column for the given table. """ for column in six.iteritems(self.get_indexes(cursor, table_name)): if column[1]['primary_key']: return column[0] return None
[ "def", "get_primary_key_column", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "for", "column", "in", "six", ".", "iteritems", "(", "self", ".", "get_indexes", "(", "cursor", ",", "table_name", ")", ")", ":", "if", "column", "[", "1", "]", "...
[ 1391, 4 ]
[ 1398, 19 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.get_indexes
(self, cursor, table_name)
Returns a dictionary of indexed fieldname -> infodict for the given table, where each infodict is in the format: {'primary_key': boolean representing whether it's the primary key, 'unique': boolean representing whether it's a unique index} Only single-column indexes ar...
Returns a dictionary of indexed fieldname -> infodict for the given table, where each infodict is in the format: {'primary_key': boolean representing whether it's the primary key, 'unique': boolean representing whether it's a unique index}
def get_indexes(self, cursor, table_name): """ Returns a dictionary of indexed fieldname -> infodict for the given table, where each infodict is in the format: {'primary_key': boolean representing whether it's the primary key, 'unique': boolean representing whether it's ...
[ "def", "get_indexes", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseIntrospection may require a get_indexes() method'", ")" ]
[ 1400, 4 ]
[ 1409, 111 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseIntrospection.get_constraints
(self, cursor, table_name)
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns. Returns a dict mapping constraint names to their attributes, where attributes is a dict with keys: * columns: List of columns this covers * primary_key: True if primary key, F...
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
def get_constraints(self, cursor, table_name): """ Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns. Returns a dict mapping constraint names to their attributes, where attributes is a dict with keys: * columns: List of columns ...
[ "def", "get_constraints", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BaseDatabaseIntrospection may require a get_constraints() method'", ")" ]
[ 1411, 4 ]
[ 1428, 115 ]
python
en
['en', 'error', 'th']
False
BaseDatabaseValidation.validate_field
(self, errors, opts, f)
By default, there is no backend-specific validation. This method has been deprecated by the new checks framework. New backends should implement check_field instead.
By default, there is no backend-specific validation.
def validate_field(self, errors, opts, f): """ By default, there is no backend-specific validation. This method has been deprecated by the new checks framework. New backends should implement check_field instead. """ # This is deliberately commented out. It exists as a ma...
[ "def", "validate_field", "(", "self", ",", "errors", ",", "opts", ",", "f", ")", ":", "# This is deliberately commented out. It exists as a marker to", "# remind us to remove this method, and the check_field() shim,", "# when the time comes.", "# warnings.warn('\"validate_field\" has b...
[ 1455, 4 ]
[ 1466, 12 ]
python
en
['en', 'error', 'th']
False
make_confidence_report_bundled
( filepath, train_start=TRAIN_START, train_end=TRAIN_END, test_start=TEST_START, test_end=TEST_END, which_set=WHICH_SET, recipe=RECIPE, report_path=REPORT_PATH, nb_iter=NB_ITER, base_eps=None, base_eps_iter=None, base_eps_iter_small=None, batch_size=BATCH_SIZE, )
Load a saved model, gather its predictions, and save a confidence report. :param filepath: path to model to evaluate :param train_start: index of first training set example to use :param train_end: index of last training set example to use :param test_start: index of first test set example to use ...
Load a saved model, gather its predictions, and save a confidence report. :param filepath: path to model to evaluate :param train_start: index of first training set example to use :param train_end: index of last training set example to use :param test_start: index of first test set example to use ...
def make_confidence_report_bundled( filepath, train_start=TRAIN_START, train_end=TRAIN_END, test_start=TEST_START, test_end=TEST_END, which_set=WHICH_SET, recipe=RECIPE, report_path=REPORT_PATH, nb_iter=NB_ITER, base_eps=None, base_eps_iter=None, base_eps_iter_small=None,...
[ "def", "make_confidence_report_bundled", "(", "filepath", ",", "train_start", "=", "TRAIN_START", ",", "train_end", "=", "TRAIN_END", ",", "test_start", "=", "TEST_START", ",", "test_end", "=", "TEST_END", ",", "which_set", "=", "WHICH_SET", ",", "recipe", "=", ...
[ 134, 0 ]
[ 275, 9 ]
python
en
['en', 'error', 'th']
False
print_stats
(correctness, confidence, name)
Prints out accuracy, coverage, etc. statistics :param correctness: ndarray One bool per example specifying whether it was correctly classified :param confidence: ndarray The probability associated with each prediction :param name: str The name of this type of data (e.g. "clean", "MaxC...
Prints out accuracy, coverage, etc. statistics :param correctness: ndarray One bool per example specifying whether it was correctly classified :param confidence: ndarray The probability associated with each prediction :param name: str The name of this type of data (e.g. "clean", "MaxC...
def print_stats(correctness, confidence, name): """ Prints out accuracy, coverage, etc. statistics :param correctness: ndarray One bool per example specifying whether it was correctly classified :param confidence: ndarray The probability associated with each prediction :param name: str ...
[ "def", "print_stats", "(", "correctness", ",", "confidence", ",", "name", ")", ":", "accuracy", "=", "correctness", ".", "mean", "(", ")", "wrongness", "=", "1", "-", "correctness", "denom1", "=", "np", ".", "maximum", "(", "1", ",", "wrongness", ".", ...
[ 278, 0 ]
[ 310, 11 ]
python
en
['en', 'error', 'th']
False
make_confidence_report
( filepath, train_start=TRAIN_START, train_end=TRAIN_END, test_start=TEST_START, test_end=TEST_END, batch_size=BATCH_SIZE, which_set=WHICH_SET, mc_batch_size=MC_BATCH_SIZE, report_path=REPORT_PATH, base_eps_iter=BASE_EPS_ITER, nb_iter=NB_ITER, save_advx=SAVE_ADVX, )
Load a saved model, gather its predictions, and save a confidence report. This function works by running a single MaxConfidence attack on each example. This provides a reasonable estimate of the true failure rate quickly, so long as the model does not suffer from gradient masking. However, this e...
Load a saved model, gather its predictions, and save a confidence report.
def make_confidence_report( filepath, train_start=TRAIN_START, train_end=TRAIN_END, test_start=TEST_START, test_end=TEST_END, batch_size=BATCH_SIZE, which_set=WHICH_SET, mc_batch_size=MC_BATCH_SIZE, report_path=REPORT_PATH, base_eps_iter=BASE_EPS_ITER, nb_iter=NB_ITER, sa...
[ "def", "make_confidence_report", "(", "filepath", ",", "train_start", "=", "TRAIN_START", ",", "train_end", "=", "TRAIN_END", ",", "test_start", "=", "TEST_START", ",", "test_end", "=", "TEST_END", ",", "batch_size", "=", "BATCH_SIZE", ",", "which_set", "=", "WH...
[ 313, 0 ]
[ 468, 29 ]
python
en
['en', 'error', 'th']
False
DateField._check_fix_default_value
(self)
Warn that using an actual date or datetime value is probably wrong; it's only evaluated on server startup.
Warn that using an actual date or datetime value is probably wrong; it's only evaluated on server startup.
def _check_fix_default_value(self): """ Warn that using an actual date or datetime value is probably wrong; it's only evaluated on server startup. """ if not self.has_default(): return [] now = timezone.now() if not timezone.is_naive(now): ...
[ "def", "_check_fix_default_value", "(", "self", ")", ":", "if", "not", "self", ".", "has_default", "(", ")", ":", "return", "[", "]", "now", "=", "timezone", ".", "now", "(", ")", "if", "not", "timezone", ".", "is_naive", "(", "now", ")", ":", "now",...
[ 1108, 4 ]
[ 1146, 17 ]
python
en
['en', 'error', 'th']
False
DateTimeField._check_fix_default_value
(self)
Warn that using an actual date or datetime value is probably wrong; it's only evaluated on server startup.
Warn that using an actual date or datetime value is probably wrong; it's only evaluated on server startup.
def _check_fix_default_value(self): """ Warn that using an actual date or datetime value is probably wrong; it's only evaluated on server startup. """ if not self.has_default(): return [] now = timezone.now() if not timezone.is_naive(now): ...
[ "def", "_check_fix_default_value", "(", "self", ")", ":", "if", "not", "self", ".", "has_default", "(", ")", ":", "return", "[", "]", "now", "=", "timezone", ".", "now", "(", ")", "if", "not", "timezone", ".", "is_naive", "(", "now", ")", ":", "now",...
[ 1248, 4 ]
[ 1289, 17 ]
python
en
['en', 'error', 'th']
False
PositiveIntegerRelDbTypeMixin.rel_db_type
(self, connection)
Return the data type that a related field pointing to this field should use. In most cases, a foreign key pointing to a positive integer primary key will have an integer column data type but some databases (e.g. MySQL) have an unsigned integer type. In that case (related_fields_...
Return the data type that a related field pointing to this field should use. In most cases, a foreign key pointing to a positive integer primary key will have an integer column data type but some databases (e.g. MySQL) have an unsigned integer type. In that case (related_fields_...
def rel_db_type(self, connection): """ Return the data type that a related field pointing to this field should use. In most cases, a foreign key pointing to a positive integer primary key will have an integer column data type but some databases (e.g. MySQL) have an unsigned integ...
[ "def", "rel_db_type", "(", "self", ",", "connection", ")", ":", "if", "connection", ".", "features", ".", "related_fields_match_type", ":", "return", "self", ".", "db_type", "(", "connection", ")", "else", ":", "return", "IntegerField", "(", ")", ".", "db_ty...
[ 1949, 4 ]
[ 1961, 64 ]
python
en
['en', 'error', 'th']
False
TimeField._check_fix_default_value
(self)
Warn that using an actual date or datetime value is probably wrong; it's only evaluated on server startup.
Warn that using an actual date or datetime value is probably wrong; it's only evaluated on server startup.
def _check_fix_default_value(self): """ Warn that using an actual date or datetime value is probably wrong; it's only evaluated on server startup. """ if not self.has_default(): return [] now = timezone.now() if not timezone.is_naive(now): ...
[ "def", "_check_fix_default_value", "(", "self", ")", ":", "if", "not", "self", ".", "has_default", "(", ")", ":", "return", "[", "]", "now", "=", "timezone", ".", "now", "(", ")", "if", "not", "timezone", ".", "is_naive", "(", "now", ")", ":", "now",...
[ 2074, 4 ]
[ 2115, 17 ]
python
en
['en', 'error', 'th']
False
BinaryField.value_to_string
(self, obj)
Binary data is serialized as base64
Binary data is serialized as base64
def value_to_string(self, obj): """Binary data is serialized as base64""" return b64encode(self.value_from_object(obj)).decode('ascii')
[ "def", "value_to_string", "(", "self", ",", "obj", ")", ":", "return", "b64encode", "(", "self", ".", "value_from_object", "(", "obj", ")", ")", ".", "decode", "(", "'ascii'", ")" ]
[ 2264, 4 ]
[ 2266, 69 ]
python
en
['en', 'en', 'en']
True
ListFiltersTests.test_fieldlistfilter_underscorelookup_tuple
(self)
Ensure ('fieldpath', ClassName ) lookups pass lookup_allowed checks when fieldpath contains double underscore in value. Refs #19182
Ensure ('fieldpath', ClassName ) lookups pass lookup_allowed checks when fieldpath contains double underscore in value. Refs #19182
def test_fieldlistfilter_underscorelookup_tuple(self): """ Ensure ('fieldpath', ClassName ) lookups pass lookup_allowed checks when fieldpath contains double underscore in value. Refs #19182 """ modeladmin = BookAdminWithUnderscoreLookupAndTuple(Book, site) reques...
[ "def", "test_fieldlistfilter_underscorelookup_tuple", "(", "self", ")", ":", "modeladmin", "=", "BookAdminWithUnderscoreLookupAndTuple", "(", "Book", ",", "site", ")", "request", "=", "self", ".", "request_factory", ".", "get", "(", "'/'", ")", "changelist", "=", ...
[ 595, 4 ]
[ 610, 79 ]
python
en
['en', 'error', 'th']
False
ListFiltersTests.test_listfilter_without_title
(self)
Any filter must define a title.
Any filter must define a title.
def test_listfilter_without_title(self): """ Any filter must define a title. """ modeladmin = DecadeFilterBookAdminWithoutTitle(Book, site) request = self.request_factory.get('/', {}) six.assertRaisesRegex(self, ImproperlyConfigured, "The list filter 'DecadeLi...
[ "def", "test_listfilter_without_title", "(", "self", ")", ":", "modeladmin", "=", "DecadeFilterBookAdminWithoutTitle", "(", "Book", ",", "site", ")", "request", "=", "self", ".", "request_factory", ".", "get", "(", "'/'", ",", "{", "}", ")", "six", ".", "ass...
[ 706, 4 ]
[ 714, 59 ]
python
en
['en', 'error', 'th']
False
ListFiltersTests.test_simplelistfilter_without_parameter
(self)
Any SimpleListFilter must define a parameter_name.
Any SimpleListFilter must define a parameter_name.
def test_simplelistfilter_without_parameter(self): """ Any SimpleListFilter must define a parameter_name. """ modeladmin = DecadeFilterBookAdminWithoutParameter(Book, site) request = self.request_factory.get('/', {}) six.assertRaisesRegex(self, ImproperlyConfigured, ...
[ "def", "test_simplelistfilter_without_parameter", "(", "self", ")", ":", "modeladmin", "=", "DecadeFilterBookAdminWithoutParameter", "(", "Book", ",", "site", ")", "request", "=", "self", ".", "request_factory", ".", "get", "(", "'/'", ",", "{", "}", ")", "six",...
[ 716, 4 ]
[ 724, 59 ]
python
en
['en', 'error', 'th']
False
ListFiltersTests.test_simplelistfilter_with_none_returning_lookups
(self)
A SimpleListFilter lookups method can return None but disables the filter completely.
A SimpleListFilter lookups method can return None but disables the filter completely.
def test_simplelistfilter_with_none_returning_lookups(self): """ A SimpleListFilter lookups method can return None but disables the filter completely. """ modeladmin = DecadeFilterBookAdminWithNoneReturningLookups(Book, site) request = self.request_factory.get('/', {}) ...
[ "def", "test_simplelistfilter_with_none_returning_lookups", "(", "self", ")", ":", "modeladmin", "=", "DecadeFilterBookAdminWithNoneReturningLookups", "(", "Book", ",", "site", ")", "request", "=", "self", ".", "request_factory", ".", "get", "(", "'/'", ",", "{", "}...
[ 726, 4 ]
[ 735, 44 ]
python
en
['en', 'error', 'th']
False
ListFiltersTests.test_filter_with_failing_queryset
(self)
Ensure that when a filter's queryset method fails, it fails loudly and the corresponding exception doesn't get swallowed. Refs #17828.
Ensure that when a filter's queryset method fails, it fails loudly and the corresponding exception doesn't get swallowed. Refs #17828.
def test_filter_with_failing_queryset(self): """ Ensure that when a filter's queryset method fails, it fails loudly and the corresponding exception doesn't get swallowed. Refs #17828. """ modeladmin = DecadeFilterBookAdminWithFailingQueryset(Book, site) request = ...
[ "def", "test_filter_with_failing_queryset", "(", "self", ")", ":", "modeladmin", "=", "DecadeFilterBookAdminWithFailingQueryset", "(", "Book", ",", "site", ")", "request", "=", "self", ".", "request_factory", ".", "get", "(", "'/'", ",", "{", "}", ")", "self", ...
[ 737, 4 ]
[ 745, 92 ]
python
en
['en', 'error', 'th']
False
ListFiltersTests.test_two_characters_long_field
(self)
Ensure that list_filter works with two-characters long field names. Refs #16080.
Ensure that list_filter works with two-characters long field names. Refs #16080.
def test_two_characters_long_field(self): """ Ensure that list_filter works with two-characters long field names. Refs #16080. """ modeladmin = BookAdmin(Book, site) request = self.request_factory.get('/', {'no': '207'}) changelist = self.get_changelist(request, B...
[ "def", "test_two_characters_long_field", "(", "self", ")", ":", "modeladmin", "=", "BookAdmin", "(", "Book", ",", "site", ")", "request", "=", "self", ".", "request_factory", ".", "get", "(", "'/'", ",", "{", "'no'", ":", "'207'", "}", ")", "changelist", ...
[ 769, 4 ]
[ 786, 63 ]
python
en
['en', 'error', 'th']
False
ListFiltersTests.test_parameter_ends_with__in__or__isnull
(self)
Ensure that a SimpleListFilter's parameter name is not mistaken for a model field if it ends with '__isnull' or '__in'. Refs #17091.
Ensure that a SimpleListFilter's parameter name is not mistaken for a model field if it ends with '__isnull' or '__in'. Refs #17091.
def test_parameter_ends_with__in__or__isnull(self): """ Ensure that a SimpleListFilter's parameter name is not mistaken for a model field if it ends with '__isnull' or '__in'. Refs #17091. """ # When it ends with '__in' ----------------------------------------- m...
[ "def", "test_parameter_ends_with__in__or__isnull", "(", "self", ")", ":", "# When it ends with '__in' -----------------------------------------", "modeladmin", "=", "DecadeFilterBookAdminParameterEndsWith__In", "(", "Book", ",", "site", ")", "request", "=", "self", ".", "reques...
[ 788, 4 ]
[ 827, 79 ]
python
en
['en', 'error', 'th']
False
ListFiltersTests.test_lookup_with_non_string_value
(self)
Ensure choices are set the selected class when using non-string values for lookups in SimpleListFilters. Refs #19318
Ensure choices are set the selected class when using non-string values for lookups in SimpleListFilters. Refs #19318
def test_lookup_with_non_string_value(self): """ Ensure choices are set the selected class when using non-string values for lookups in SimpleListFilters. Refs #19318 """ modeladmin = DepartmentFilterEmployeeAdmin(Employee, site) request = self.request_factory.get...
[ "def", "test_lookup_with_non_string_value", "(", "self", ")", ":", "modeladmin", "=", "DepartmentFilterEmployeeAdmin", "(", "Employee", ",", "site", ")", "request", "=", "self", ".", "request_factory", ".", "get", "(", "'/'", ",", "{", "'department'", ":", "self...
[ 829, 4 ]
[ 849, 85 ]
python
en
['en', 'error', 'th']
False
ListFiltersTests.test_lookup_with_non_string_value_underscored
(self)
Ensure SimpleListFilter lookups pass lookup_allowed checks when parameter_name attribute contains double-underscore value. Refs #19182
Ensure SimpleListFilter lookups pass lookup_allowed checks when parameter_name attribute contains double-underscore value. Refs #19182
def test_lookup_with_non_string_value_underscored(self): """ Ensure SimpleListFilter lookups pass lookup_allowed checks when parameter_name attribute contains double-underscore value. Refs #19182 """ modeladmin = DepartmentFilterUnderscoredEmployeeAdmin(Employee, site) ...
[ "def", "test_lookup_with_non_string_value_underscored", "(", "self", ")", ":", "modeladmin", "=", "DepartmentFilterUnderscoredEmployeeAdmin", "(", "Employee", ",", "site", ")", "request", "=", "self", ".", "request_factory", ".", "get", "(", "'/'", ",", "{", "'depar...
[ 851, 4 ]
[ 870, 95 ]
python
en
['en', 'error', 'th']
False
ListFiltersTests.test_fk_with_to_field
(self)
Ensure that a filter on a FK respects the FK's to_field attribute. Refs #17972.
Ensure that a filter on a FK respects the FK's to_field attribute. Refs #17972.
def test_fk_with_to_field(self): """ Ensure that a filter on a FK respects the FK's to_field attribute. Refs #17972. """ modeladmin = EmployeeAdmin(Employee, site) request = self.request_factory.get('/', {}) changelist = self.get_changelist(request, Employee, mod...
[ "def", "test_fk_with_to_field", "(", "self", ")", ":", "modeladmin", "=", "EmployeeAdmin", "(", "Employee", ",", "site", ")", "request", "=", "self", ".", "request_factory", ".", "get", "(", "'/'", ",", "{", "}", ")", "changelist", "=", "self", ".", "get...
[ 872, 4 ]
[ 925, 84 ]
python
en
['en', 'error', 'th']
False
ListFiltersTests.test_lookup_with_dynamic_value
(self)
Ensure SimpleListFilter can access self.value() inside the lookup.
Ensure SimpleListFilter can access self.value() inside the lookup.
def test_lookup_with_dynamic_value(self): """ Ensure SimpleListFilter can access self.value() inside the lookup. """ modeladmin = DepartmentFilterDynamicValueBookAdmin(Book, site) def _test_choices(request, expected_displays): changelist = self.get_changelist(request...
[ "def", "test_lookup_with_dynamic_value", "(", "self", ")", ":", "modeladmin", "=", "DepartmentFilterDynamicValueBookAdmin", "(", "Book", ",", "site", ")", "def", "_test_choices", "(", "request", ",", "expected_displays", ")", ":", "changelist", "=", "self", ".", "...
[ 927, 4 ]
[ 947, 44 ]
python
en
['en', 'error', 'th']
False
get_size_in_original_px_space_list
()
Create list of pixels in original pixel space when each child is reduced to 80% of its parent's size (by cropping or resolution reduction). Returns: size_in_real_pixels_list: list with pixel sizes
Create list of pixels in original pixel space when each child is reduced to 80% of its parent's size (by cropping or resolution reduction).
def get_size_in_original_px_space_list(): """Create list of pixels in original pixel space when each child is reduced to 80% of its parent's size (by cropping or resolution reduction). Returns: size_in_real_pixels_list: list with pixel sizes """ cur_px_size = 224 # image size after pr...
[ "def", "get_size_in_original_px_space_list", "(", ")", ":", "cur_px_size", "=", "224", "# image size after preprocessing", "size_in_original_px_space_list", "=", "[", "cur_px_size", "]", "for", "i", "in", "range", "(", "20", ")", ":", "cur_px_size", "=", "round", "(...
[ 10, 0 ]
[ 25, 41 ]
python
en
['en', 'af', 'en']
True
extract_crops
(image, size, stride=1)
Extract crops of size size from image using stride. Careful! This function only works for a batch_size = 1. Args: image: torch tensor, dtype = torch.float32. expected dimensions: C X W X H, e.g. torch.Size([3, 224, 224]) size: size of the retu...
Extract crops of size size from image using stride. Careful! This function only works for a batch_size = 1.
def extract_crops(image, size, stride=1): """Extract crops of size size from image using stride. Careful! This function only works for a batch_size = 1. Args: image: torch tensor, dtype = torch.float32. expected dimensions: C X W X H, e.g. torch.Siz...
[ "def", "extract_crops", "(", "image", ",", "size", ",", "stride", "=", "1", ")", ":", "image_permuted", "=", "image", ".", "permute", "(", "1", ",", "2", ",", "0", ")", "crops_unfolded", "=", "image_permuted", ".", "unfold", "(", "0", ",", "size", ",...
[ 28, 0 ]
[ 50, 16 ]
python
en
['en', 'en', 'en']
True
get_logits_for_patches
(patches, rf, model, DEVICE)
For each of the 1000 ImageNet classes, compute the logit of each patch. Args: patches: tensor, dtype = torch.float32. expected dimensions: n_patches x C X W X H, e.g. torch.Size([36864, 3, 33, 33]) where 33 is th...
For each of the 1000 ImageNet classes, compute the logit of each patch.
def get_logits_for_patches(patches, rf, model, DEVICE): """For each of the 1000 ImageNet classes, compute the logit of each patch. Args: patches: tensor, dtype = torch.float32. expected dimensions: n_patches x C X W X H, e.g. torch.Size...
[ "def", "get_logits_for_patches", "(", "patches", ",", "rf", ",", "model", ",", "DEVICE", ")", ":", "# check that patches are of correct dimensions", "if", "not", "(", "patches", ".", "shape", "[", "1", "]", "==", "3", "and", "patches", ".", "shape", "[", "2"...
[ 53, 0 ]
[ 96, 29 ]
python
en
['en', 'en', 'en']
True
get_prob_for_correct_classes_of_whole_img
(logits_for_patches, target_list)
determine probability for whole image by adding up the individual probabilities for each true_label in the target_list Args: logits_for_patches: logit predictions for each patch torch tensor, dtype = torch.float32 ...
determine probability for whole image by adding up the individual probabilities for each true_label in the target_list
def get_prob_for_correct_classes_of_whole_img(logits_for_patches, target_list): """determine probability for whole image by adding up the individual probabilities for each true_label in the target_list Args: logits_for_patches: logit predictions for each patch ...
[ "def", "get_prob_for_correct_classes_of_whole_img", "(", "logits_for_patches", ",", "target_list", ")", ":", "logit_avg_whole_image", "=", "torch", ".", "mean", "(", "logits_for_patches", ",", "dim", "=", "0", ")", "prob_for_whole_image_targets_summed", "=", "get_prob_for...
[ 99, 0 ]
[ 120, 46 ]
python
en
['en', 'en', 'en']
True
get_prob_and_custom_prob_per_crops
( logits_for_patches, img_size_work_px_space, n_pixels_in_crop, descendent_specifier, target_list, rf, DEVICE, )
Determine the probability and the custom probability (i.e. the non-Deep-Learning "logit", cf. Appendix C.2) for crops according to the descendent_specifier, i.e. either each crop or only the four corner crops. Note that for the grouping of patches into one crop, each directly neighboring patch is considered (strid...
Determine the probability and the custom probability (i.e. the non-Deep-Learning "logit", cf. Appendix C.2) for crops according to the descendent_specifier, i.e. either each crop or only the four corner crops.
def get_prob_and_custom_prob_per_crops( logits_for_patches, img_size_work_px_space, n_pixels_in_crop, descendent_specifier, target_list, rf, DEVICE, ): """Determine the probability and the custom probability (i.e. the non-Deep-Learning "logit", cf. Appendix C.2) for crops according to th...
[ "def", "get_prob_and_custom_prob_per_crops", "(", "logits_for_patches", ",", "img_size_work_px_space", ",", "n_pixels_in_crop", ",", "descendent_specifier", ",", "target_list", ",", "rf", ",", "DEVICE", ",", ")", ":", "# When the crop is larger than 33x33 (or in fact 37x37 beca...
[ 123, 0 ]
[ 219, 46 ]
python
en
['en', 'en', 'en']
True
get_prob_for_logits
(logits_n_patches_x_n_classes, target_list)
Calculate the probability for the given logits (which are possibly an average over patches, hence representing a crop and only giving n_patches = 1). Args: logits_n_patches_x_n_classes: logits dimensions: n_patches x 1000 for whole...
Calculate the probability for the given logits (which are possibly an average over patches, hence representing a crop and only giving n_patches = 1).
def get_prob_for_logits(logits_n_patches_x_n_classes, target_list): """Calculate the probability for the given logits (which are possibly an average over patches, hence representing a crop and only giving n_patches = 1). Args: logits_n_patches_x_n_classes: logits d...
[ "def", "get_prob_for_logits", "(", "logits_n_patches_x_n_classes", ",", "target_list", ")", ":", "prob_for_targets_separately", "=", "torch", ".", "nn", ".", "functional", ".", "softmax", "(", "logits_n_patches_x_n_classes", ",", "dim", "=", "1", ")", "[", ":", ",...
[ 222, 0 ]
[ 239, 34 ]
python
en
['en', 'en', 'en']
True
get_custom_prob
(logits_for_patches, target_list, DEVICE)
Calculate the custom probability (i.e. the non-Deep-Learning "logit", cf. Appendix C.2) for n_patches patches based on the logit predictions and the true classes Args: logits_for_patches: logit predictions for each patch of BagNet torch tensor, dtype = torch.float32 ...
Calculate the custom probability (i.e. the non-Deep-Learning "logit", cf. Appendix C.2) for n_patches patches based on the logit predictions and the true classes
def get_custom_prob(logits_for_patches, target_list, DEVICE): """Calculate the custom probability (i.e. the non-Deep-Learning "logit", cf. Appendix C.2) for n_patches patches based on the logit predictions and the true classes Args: logits_for_patches: logit predictions for each patch of BagNet ...
[ "def", "get_custom_prob", "(", "logits_for_patches", ",", "target_list", ",", "DEVICE", ")", ":", "logits_for_patches_true_label", "=", "logits_for_patches", "[", ":", ",", "target_list", "]", "logits_for_patches_non_correct", "=", "torch", ".", "empty", "(", "[", "...
[ 242, 0 ]
[ 290, 37 ]
python
en
['en', 'en', 'en']
True