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
make_test_environ_builder
(app, path='/', base_url=None, *args, **kwargs)
Creates a new test builder with some application defaults thrown in.
Creates a new test builder with some application defaults thrown in.
def make_test_environ_builder(app, path='/', base_url=None, *args, **kwargs): """Creates a new test builder with some application defaults thrown in.""" http_host = app.config.get('SERVER_NAME') app_root = app.config.get('APPLICATION_ROOT') if base_url is None: url = url_parse(path) base...
[ "def", "make_test_environ_builder", "(", "app", ",", "path", "=", "'/'", ",", "base_url", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "http_host", "=", "app", ".", "config", ".", "get", "(", "'SERVER_NAME'", ")", "app_root", "=", ...
[ 23, 0 ]
[ 36, 58 ]
python
en
['en', 'en', 'en']
True
FlaskClient.session_transaction
(self, *args, **kwargs)
When used in combination with a ``with`` statement this opens a session transaction. This can be used to modify the session that the test client uses. Once the ``with`` block is left the session is stored back. :: with client.session_transaction() as session: ...
When used in combination with a ``with`` statement this opens a session transaction. This can be used to modify the session that the test client uses. Once the ``with`` block is left the session is stored back.
def session_transaction(self, *args, **kwargs): """When used in combination with a ``with`` statement this opens a session transaction. This can be used to modify the session that the test client uses. Once the ``with`` block is left the session is stored back. :: ...
[ "def", "session_transaction", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "cookie_jar", "is", "None", ":", "raise", "RuntimeError", "(", "'Session transactions only make sense '", "'with cookies enabled.'", ")", "app", "=...
[ 64, 4 ]
[ 111, 68 ]
python
en
['en', 'en', 'en']
True
install._called_from_setup
(run_frame)
Attempt to detect whether run() was called from setup() or by another command. If called by setup(), the parent caller will be the 'run_command' method in 'distutils.dist', and *its* caller will be the 'run_commands' method. If called any other way, the immediate caller *might...
Attempt to detect whether run() was called from setup() or by another command. If called by setup(), the parent caller will be the 'run_command' method in 'distutils.dist', and *its* caller will be the 'run_commands' method. If called any other way, the immediate caller *might...
def _called_from_setup(run_frame): """ Attempt to detect whether run() was called from setup() or by another command. If called by setup(), the parent caller will be the 'run_command' method in 'distutils.dist', and *its* caller will be the 'run_commands' method. If called any ...
[ "def", "_called_from_setup", "(", "run_frame", ")", ":", "if", "run_frame", "is", "None", ":", "msg", "=", "\"Call stack not available. bdist_* commands may fail.\"", "warnings", ".", "warn", "(", "msg", ")", "if", "platform", ".", "python_implementation", "(", ")",...
[ 69, 4 ]
[ 93, 9 ]
python
en
['en', 'error', 'th']
False
GenerateConfig
(context)
Generate configuration.
Generate configuration.
def GenerateConfig(context): """Generate configuration.""" name_prefix = context.env['deployment'] + '-' + context.env['name'] instance = { 'zone': context.properties['zone'], 'machineType': ZonalComputeUrl( context.env['project'], context.properties['zone'], 'machineTypes', 'f1-...
[ "def", "GenerateConfig", "(", "context", ")", ":", "name_prefix", "=", "context", ".", "env", "[", "'deployment'", "]", "+", "'-'", "+", "context", ".", "env", "[", "'name'", "]", "instance", "=", "{", "'zone'", ":", "context", ".", "properties", "[", ...
[ 30, 0 ]
[ 77, 18 ]
python
en
['en', 'la', 'en']
False
shortcut
(request, content_type_id, object_id)
Redirect to an object's page based on a content-type ID and an object ID.
Redirect to an object's page based on a content-type ID and an object ID.
def shortcut(request, content_type_id, object_id): """ Redirect to an object's page based on a content-type ID and an object ID. """ # Look up the object, making sure it's got a get_absolute_url() function. try: content_type = ContentType.objects.get(pk=content_type_id) if not conten...
[ "def", "shortcut", "(", "request", ",", "content_type_id", ",", "object_id", ")", ":", "# Look up the object, making sure it's got a get_absolute_url() function.", "try", ":", "content_type", "=", "ContentType", ".", "objects", ".", "get", "(", "pk", "=", "content_type_...
[ 8, 0 ]
[ 87, 43 ]
python
en
['en', 'error', 'th']
False
ogrinfo
(data_source, num_features=10)
Walk the available layers in the supplied `data_source`, displaying the fields for the first `num_features` features.
Walk the available layers in the supplied `data_source`, displaying the fields for the first `num_features` features.
def ogrinfo(data_source, num_features=10): """ Walk the available layers in the supplied `data_source`, displaying the fields for the first `num_features` features. """ # Checking the parameters. if isinstance(data_source, str): data_source = DataSource(data_source) elif isinstance(...
[ "def", "ogrinfo", "(", "data_source", ",", "num_features", "=", "10", ")", ":", "# Checking the parameters.", "if", "isinstance", "(", "data_source", ",", "str", ")", ":", "data_source", "=", "DataSource", "(", "data_source", ")", "elif", "isinstance", "(", "d...
[ 10, 0 ]
[ 50, 29 ]
python
en
['en', 'error', 'th']
False
rgb
(r, g, b, a=255)
(Internal) Turns an RGB color into a Qt compatible color integer.
(Internal) Turns an RGB color into a Qt compatible color integer.
def rgb(r, g, b, a=255): """(Internal) Turns an RGB color into a Qt compatible color integer.""" # use qRgb to pack the colors, and then turn the resulting long # into a negative integer with the same bitpattern. return qRgba(r, g, b, a) & 0xFFFFFFFF
[ "def", "rgb", "(", "r", ",", "g", ",", "b", ",", "a", "=", "255", ")", ":", "# use qRgb to pack the colors, and then turn the resulting long", "# into a negative integer with the same bitpattern.", "return", "qRgba", "(", "r", ",", "g", ",", "b", ",", "a", ")", ...
[ 56, 0 ]
[ 60, 41 ]
python
en
['en', 'ca', 'en']
True
fromqimage
(im)
:param im: QImage or PIL ImageQt object
:param im: QImage or PIL ImageQt object
def fromqimage(im): """ :param im: QImage or PIL ImageQt object """ buffer = QBuffer() qt_openmode = QIODevice.OpenMode if qt_version == "6" else QIODevice buffer.open(qt_openmode.ReadWrite) # preserve alpha channel with png # otherwise ppm is more friendly with Image.open if im.hasA...
[ "def", "fromqimage", "(", "im", ")", ":", "buffer", "=", "QBuffer", "(", ")", "qt_openmode", "=", "QIODevice", ".", "OpenMode", "if", "qt_version", "==", "\"6\"", "else", "QIODevice", "buffer", ".", "open", "(", "qt_openmode", ".", "ReadWrite", ")", "# pre...
[ 63, 0 ]
[ 82, 24 ]
python
en
['en', 'error', 'th']
False
align8to32
(bytes, width, mode)
converts each scanline of data from 8 bit to 32 bit aligned
converts each scanline of data from 8 bit to 32 bit aligned
def align8to32(bytes, width, mode): """ converts each scanline of data from 8 bit to 32 bit aligned """ bits_per_pixel = {"1": 1, "L": 8, "P": 8}[mode] # calculate bytes per line and the extra padding if needed bits_per_line = bits_per_pixel * width full_bytes_per_line, remaining_bits_per_...
[ "def", "align8to32", "(", "bytes", ",", "width", ",", "mode", ")", ":", "bits_per_pixel", "=", "{", "\"1\"", ":", "1", ",", "\"L\"", ":", "8", ",", "\"P\"", ":", "8", "}", "[", "mode", "]", "# calculate bytes per line and the extra padding if needed", "bits_...
[ 99, 0 ]
[ 124, 29 ]
python
en
['en', 'error', 'th']
False
incoming_sms
()
Send a dynamic reply to an incoming text message
Send a dynamic reply to an incoming text message
def incoming_sms(): """Send a dynamic reply to an incoming text message""" # Get the message the user sent our Twilio number body = request.values.get('Body', None) # Start our TwiML response resp = MessagingResponse() # Determine the right reply for this message if body == 'hello': ...
[ "def", "incoming_sms", "(", ")", ":", "# Get the message the user sent our Twilio number", "body", "=", "request", ".", "values", ".", "get", "(", "'Body'", ",", "None", ")", "# Start our TwiML response", "resp", "=", "MessagingResponse", "(", ")", "# Determine the ri...
[ 6, 0 ]
[ 20, 20 ]
python
en
['en', 'en', 'en']
True
_ConfigName
(context)
Return the short config name.
Return the short config name.
def _ConfigName(context): """Return the short config name.""" return '{}-config'.format(context.env['deployment'])
[ "def", "_ConfigName", "(", "context", ")", ":", "return", "'{}-config'", ".", "format", "(", "context", ".", "env", "[", "'deployment'", "]", ")" ]
[ 63, 0 ]
[ 65, 54 ]
python
en
['en', 'en', 'en']
True
_ConfigUrl
(context)
Returns the full URL to the config, including hostname.
Returns the full URL to the config, including hostname.
def _ConfigUrl(context): """Returns the full URL to the config, including hostname.""" return '{endpoint}/projects/{project}/configs/{config}'.format( endpoint=RTC_ENDPOINT, project=context.env['project'], config=_ConfigName(context))
[ "def", "_ConfigUrl", "(", "context", ")", ":", "return", "'{endpoint}/projects/{project}/configs/{config}'", ".", "format", "(", "endpoint", "=", "RTC_ENDPOINT", ",", "project", "=", "context", ".", "env", "[", "'project'", "]", ",", "config", "=", "_ConfigName", ...
[ 68, 0 ]
[ 73, 34 ]
python
en
['en', 'en', 'en']
True
_WaiterName
(context)
Returns the short waiter name.
Returns the short waiter name.
def _WaiterName(context): """Returns the short waiter name.""" # This name is only used for the DM manifest entry. The actual waiter name # within RuntimeConfig is static, as it is scoped to the config resource. return '{}-software'.format(context.env['deployment'])
[ "def", "_WaiterName", "(", "context", ")", ":", "# This name is only used for the DM manifest entry. The actual waiter name", "# within RuntimeConfig is static, as it is scoped to the config resource.", "return", "'{}-software'", ".", "format", "(", "context", ".", "env", "[", "'de...
[ 76, 0 ]
[ 80, 56 ]
python
en
['en', 'no', 'en']
True
_Timeout
(context)
Returns the timeout property or a default value if unspecified.
Returns the timeout property or a default value if unspecified.
def _Timeout(context): """Returns the timeout property or a default value if unspecified.""" timeout = context.properties.get('timeout', DEFAULT_TIMEOUT) try: return str(int(timeout)) except ValueError: raise PropertyError('Invalid timeout value: {}'.format(timeout))
[ "def", "_Timeout", "(", "context", ")", ":", "timeout", "=", "context", ".", "properties", ".", "get", "(", "'timeout'", ",", "DEFAULT_TIMEOUT", ")", "try", ":", "return", "str", "(", "int", "(", "timeout", ")", ")", "except", "ValueError", ":", "raise",...
[ 83, 0 ]
[ 89, 68 ]
python
en
['en', 'en', 'en']
True
_SuccessNumber
(context)
Returns the successNumber property or a default value if unspecified.
Returns the successNumber property or a default value if unspecified.
def _SuccessNumber(context): """Returns the successNumber property or a default value if unspecified.""" number = context.properties.get('successNumber', DEFAULT_SUCCESS_NUMBER) try: number = int(number) if number < 1: raise PropertyError('successNumber value must be greater than 0.') return num...
[ "def", "_SuccessNumber", "(", "context", ")", ":", "number", "=", "context", ".", "properties", ".", "get", "(", "'successNumber'", ",", "DEFAULT_SUCCESS_NUMBER", ")", "try", ":", "number", "=", "int", "(", "number", ")", "if", "number", "<", "1", ":", "...
[ 92, 0 ]
[ 101, 73 ]
python
en
['en', 'en', 'en']
True
_FailureNumber
(context)
Returns the failureNumber property or a default value if unspecified.
Returns the failureNumber property or a default value if unspecified.
def _FailureNumber(context): """Returns the failureNumber property or a default value if unspecified.""" number = context.properties.get('failureNumber', DEFAULT_FAILURE_NUMBER) try: number = int(number) if number < 1: raise PropertyError('failureNumber value must be greater than 0.') return num...
[ "def", "_FailureNumber", "(", "context", ")", ":", "number", "=", "context", ".", "properties", ".", "get", "(", "'failureNumber'", ",", "DEFAULT_FAILURE_NUMBER", ")", "try", ":", "number", "=", "int", "(", "number", ")", "if", "number", "<", "1", ":", "...
[ 104, 0 ]
[ 113, 73 ]
python
en
['en', 'en', 'en']
True
_WaiterDependsOn
(context)
Returns the waiterDependsOn property or an empty list if unspecified.
Returns the waiterDependsOn property or an empty list if unspecified.
def _WaiterDependsOn(context): """Returns the waiterDependsOn property or an empty list if unspecified.""" depends_on = context.properties.get('waiterDependsOn', []) if not isinstance(depends_on, list): raise PropertyError('waiterDependsOn must be a list: {}'.format(depends_on)) for item in depends_on: ...
[ "def", "_WaiterDependsOn", "(", "context", ")", ":", "depends_on", "=", "context", ".", "properties", ".", "get", "(", "'waiterDependsOn'", ",", "[", "]", ")", "if", "not", "isinstance", "(", "depends_on", ",", "list", ")", ":", "raise", "PropertyError", "...
[ 116, 0 ]
[ 127, 19 ]
python
en
['en', 'en', 'en']
True
_RuntimeConfig
(context)
Constructs a RuntimeConfig resource.
Constructs a RuntimeConfig resource.
def _RuntimeConfig(context): """Constructs a RuntimeConfig resource.""" deployment_name = context.env['deployment'] return { 'name': _ConfigName(context), 'type': 'runtimeconfig.v1beta1.config', 'properties': { 'config': _ConfigName(context), 'description': ('Holds software ...
[ "def", "_RuntimeConfig", "(", "context", ")", ":", "deployment_name", "=", "context", ".", "env", "[", "'deployment'", "]", "return", "{", "'name'", ":", "_ConfigName", "(", "context", ")", ",", "'type'", ":", "'runtimeconfig.v1beta1.config'", ",", "'properties'...
[ 130, 0 ]
[ 142, 3 ]
python
en
['en', 'en', 'en']
True
_Waiter
(context)
Constructs a waiter resource.
Constructs a waiter resource.
def _Waiter(context): """Constructs a waiter resource.""" waiter_timeout = _Timeout(context) return { 'name': _WaiterName(context), 'type': 'runtimeconfig.v1beta1.waiter', 'metadata': { 'dependsOn': _WaiterDependsOn(context), }, 'properties': { 'parent': '$(ref.{...
[ "def", "_Waiter", "(", "context", ")", ":", "waiter_timeout", "=", "_Timeout", "(", "context", ")", "return", "{", "'name'", ":", "_WaiterName", "(", "context", ")", ",", "'type'", ":", "'runtimeconfig.v1beta1.waiter'", ",", "'metadata'", ":", "{", "'dependsOn...
[ 145, 0 ]
[ 172, 3 ]
python
en
['en', 'en', 'en']
True
GenerateConfig
(context)
Entry function to generate the DM config.
Entry function to generate the DM config.
def GenerateConfig(context): """Entry function to generate the DM config.""" content = { 'resources': [ _RuntimeConfig(context), _Waiter(context), ], 'outputs': [ { 'name': 'config-url', 'value': _ConfigUrl(context) }, {...
[ "def", "GenerateConfig", "(", "context", ")", ":", "content", "=", "{", "'resources'", ":", "[", "_RuntimeConfig", "(", "context", ")", ",", "_Waiter", "(", "context", ")", ",", "]", ",", "'outputs'", ":", "[", "{", "'name'", ":", "'config-url'", ",", ...
[ 175, 0 ]
[ 193, 32 ]
python
en
['en', 'en', 'en']
True
user_data_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific data dir for this application.
def user_data_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of ...
[ "def", "user_data_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "ap...
[ 44, 0 ]
[ 96, 15 ]
python
en
['en', 'en', 'en']
True
site_data_dir
(appname=None, appauthor=None, version=None, multipath=False)
r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-shared data dir for this application.
def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of ...
[ "def", "site_data_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "multipath", "=", "False", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "...
[ 99, 0 ]
[ 162, 15 ]
python
en
['en', 'en', 'en']
True
user_config_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific config dir for this application.
def user_config_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name...
[ "def", "user_config_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "user_data_dir", ...
[ 165, 0 ]
[ 202, 15 ]
python
en
['en', 'en', 'en']
True
site_config_dir
(appname=None, appauthor=None, version=None, multipath=False)
r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-shared data dir for this application.
def site_config_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name o...
[ "def", "site_config_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "multipath", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "site_data_dir"...
[ 205, 0 ]
[ 253, 15 ]
python
en
['en', 'en', 'en']
True
user_cache_dir
(appname=None, appauthor=None, version=None, opinion=True)
r"""Return full path to the user-specific cache dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific cache dir for this application.
def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True): r"""Return full path to the user-specific cache dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of...
[ "def", "user_cache_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "opinion", "=", "True", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "ap...
[ 256, 0 ]
[ 310, 15 ]
python
en
['en', 'en', 'en']
True
user_log_dir
(appname=None, appauthor=None, version=None, opinion=True)
r"""Return full path to the user-specific log dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific log dir for this application.
def user_log_dir(appname=None, appauthor=None, version=None, opinion=True): r"""Return full path to the user-specific log dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the...
[ "def", "user_log_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "opinion", "=", "True", ")", ":", "if", "system", "==", "\"darwin\"", ":", "path", "=", "os", ".", "path", ".", "join", "(", "os", ...
[ 313, 0 ]
[ 361, 15 ]
python
en
['en', 'en', 'en']
True
_get_win_folder_from_registry
(csidl_name)
This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names.
This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names.
def _get_win_folder_from_registry(csidl_name): """This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names. """ import _winreg shell_folder_name = { "CSIDL_APPDATA": "AppData", "CSIDL_COMMON_APPDATA"...
[ "def", "_get_win_folder_from_registry", "(", "csidl_name", ")", ":", "import", "_winreg", "shell_folder_name", "=", "{", "\"CSIDL_APPDATA\"", ":", "\"AppData\"", ",", "\"CSIDL_COMMON_APPDATA\"", ":", "\"Common AppData\"", ",", "\"CSIDL_LOCAL_APPDATA\"", ":", "\"Local AppDat...
[ 407, 0 ]
[ 425, 14 ]
python
en
['en', 'en', 'en']
True
update_guessed_word
(guess, word, guessed_word)
Update guessed_word to reflect correctly guessed characters
Update guessed_word to reflect correctly guessed characters
def update_guessed_word(guess, word, guessed_word): "Update guessed_word to reflect correctly guessed characters" indices = [i for i, c in enumerate(word) if c == guess] guessed_word = list(guessed_word) for i in indices: guessed_word[i] = guess return "".join(guessed_word)
[ "def", "update_guessed_word", "(", "guess", ",", "word", ",", "guessed_word", ")", ":", "indices", "=", "[", "i", "for", "i", ",", "c", "in", "enumerate", "(", "word", ")", "if", "c", "==", "guess", "]", "guessed_word", "=", "list", "(", "guessed_word"...
[ 101, 0 ]
[ 107, 32 ]
python
en
['en', 'en', 'en']
True
create_pca_vars
(var_name, size)
Creates PCA variables. Given variable name and size, create and return PCA variables for count, mean, covariance, eigenvalues, eignvectors, and k principal components. Args: var_name: String denoting which set of variables to create. Values are "time" and "feat". size: The size of the variable, ei...
Creates PCA variables.
def create_pca_vars(var_name, size): """Creates PCA variables. Given variable name and size, create and return PCA variables for count, mean, covariance, eigenvalues, eignvectors, and k principal components. Args: var_name: String denoting which set of variables to create. Values are "time" and "fea...
[ "def", "create_pca_vars", "(", "var_name", ",", "size", ")", ":", "with", "tf", ".", "variable_scope", "(", "name_or_scope", "=", "\"pca_vars\"", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "count_var", "=", "tf", ".", "get_variable", "(", "name"...
[ 7, 0 ]
[ 61, 71 ]
python
en
['en', 'en', 'en']
True
create_both_pca_vars
(seq_len, num_feat)
Creates both time & feature major PCA variables. Given dimensions of inputs, create and return PCA variables for count, mean, covariance, eigenvalues, eigenvectors, and k principal components for both time and feature major representations. Args: seq_len: Number of timesteps in sequence. num_feat: Num...
Creates both time & feature major PCA variables.
def create_both_pca_vars(seq_len, num_feat): """Creates both time & feature major PCA variables. Given dimensions of inputs, create and return PCA variables for count, mean, covariance, eigenvalues, eigenvectors, and k principal components for both time and feature major representations. Args: seq_len: ...
[ "def", "create_both_pca_vars", "(", "seq_len", ",", "num_feat", ")", ":", "# Time based", "(", "pca_time_count_var", ",", "pca_time_mean_var", ",", "pca_time_cov_var", ",", "pca_time_eigval_var", ",", "pca_time_eigvec_var", ",", "pca_time_k_pc_var", ")", "=", "create_pc...
[ 64, 0 ]
[ 109, 28 ]
python
en
['en', 'en', 'en']
True
pca_reconstruction_k_pc
(X_cen, pca_eigvec_var, k_pc)
PCA reconstruction with k principal components. Given centered data matrix tensor X, variables for the column means and eigenvectors, and the number of principal components, returns the reconstruction of X centered. Args: X_cen: tf.float64 matrix tensor of centered input data. pca_eigvec_var: tf.float...
PCA reconstruction with k principal components.
def pca_reconstruction_k_pc(X_cen, pca_eigvec_var, k_pc): """PCA reconstruction with k principal components. Given centered data matrix tensor X, variables for the column means and eigenvectors, and the number of principal components, returns the reconstruction of X centered. Args: X_cen: tf.float64 mat...
[ "def", "pca_reconstruction_k_pc", "(", "X_cen", ",", "pca_eigvec_var", ",", "k_pc", ")", ":", "# time_shape = (num_feat, num_feat)", "# feat_shape = (seq_len, seq_len)", "projection_matrix", "=", "tf", ".", "matmul", "(", "a", "=", "pca_eigvec_var", "[", ":", ",", "-"...
[ 112, 0 ]
[ 140, 20 ]
python
en
['en', 'en', 'en']
True
pca_reconstruction_k_pc_mse
(X_cen, pca_eigvec_var, k_pc)
PCA reconstruction with k principal components. Given centered data matrix tensor X, variables for the column means and eigenvectors, and the number of principal components, returns reconstruction MSE. Args: X_cen: tf.float64 matrix tensor of centered input data. pca_eigvec_var: tf.float64 matrix vari...
PCA reconstruction with k principal components.
def pca_reconstruction_k_pc_mse(X_cen, pca_eigvec_var, k_pc): """PCA reconstruction with k principal components. Given centered data matrix tensor X, variables for the column means and eigenvectors, and the number of principal components, returns reconstruction MSE. Args: X_cen: tf.float64 matrix tensor...
[ "def", "pca_reconstruction_k_pc_mse", "(", "X_cen", ",", "pca_eigvec_var", ",", "k_pc", ")", ":", "# time_shape = (cur_batch_size * seq_len, num_feat)", "# feat_shape = (cur_batch_size * num_feat, seq_len)", "X_cen_recon", "=", "pca_reconstruction_k_pc", "(", "X_cen", ",", "pca_e...
[ 143, 0 ]
[ 172, 12 ]
python
en
['en', 'en', 'en']
True
find_best_k_principal_components
(X_recon_mse, pca_k_pc_var)
Find best k principal components from reconstruction MSE. Given reconstruction MSE, return number of principal components with lowest MSE in varible. Args: X_recon_mse: tf.float64 vector tensor of reconstruction mean squared error. pca_k_pc_var: tf.int64 scalar variable to hold best number of ...
Find best k principal components from reconstruction MSE.
def find_best_k_principal_components(X_recon_mse, pca_k_pc_var): """Find best k principal components from reconstruction MSE. Given reconstruction MSE, return number of principal components with lowest MSE in varible. Args: X_recon_mse: tf.float64 vector tensor of reconstruction mean squared error. ...
[ "def", "find_best_k_principal_components", "(", "X_recon_mse", ",", "pca_k_pc_var", ")", ":", "best_pca_k_pc", "=", "tf", ".", "argmin", "(", "input", "=", "X_recon_mse", ")", "+", "1", "with", "tf", ".", "control_dependencies", "(", "control_inputs", "=", "[", ...
[ 175, 0 ]
[ 197, 42 ]
python
en
['en', 'en', 'en']
True
set_k_principal_components
(user_k_pc, pca_k_pc_var)
Set k principal components from user-defined value. Given user-defined number of principal components, return variable set to this value. Args: user_k_pc: User-defined python integer for number of principal components. pca_k_pc_var: tf.int64 scalar variable to hold chosen number of principal...
Set k principal components from user-defined value.
def set_k_principal_components(user_k_pc, pca_k_pc_var): """Set k principal components from user-defined value. Given user-defined number of principal components, return variable set to this value. Args: user_k_pc: User-defined python integer for number of principal components. pca_k_pc_var: tf....
[ "def", "set_k_principal_components", "(", "user_k_pc", ",", "pca_k_pc_var", ")", ":", "with", "tf", ".", "control_dependencies", "(", "control_inputs", "=", "[", "tf", ".", "assign", "(", "ref", "=", "pca_k_pc_var", ",", "value", "=", "user_k_pc", ")", "]", ...
[ 200, 0 ]
[ 220, 42 ]
python
en
['en', 'en', 'en']
True
pca_model
(X, mode, params, cur_batch_size, dummy_var)
PCA to reconstruct inputs and minimize reconstruction error. Given data matrix tensor X, the current Estimator mode, the dictionary of parameters, current batch size, and the number of features, process through PCA model subgraph and return reconstructed inputs as output. Args: X: tf.float64 matrix tensor...
PCA to reconstruct inputs and minimize reconstruction error.
def pca_model(X, mode, params, cur_batch_size, dummy_var): """PCA to reconstruct inputs and minimize reconstruction error. Given data matrix tensor X, the current Estimator mode, the dictionary of parameters, current batch size, and the number of features, process through PCA model subgraph and return reconstr...
[ "def", "pca_model", "(", "X", ",", "mode", ",", "params", ",", "cur_batch_size", ",", "dummy_var", ")", ":", "# Reshape into 2-D tensors", "# Time based", "# shape = (cur_batch_size * seq_len, num_feat)", "X_time", "=", "tf", ".", "reshape", "(", "tensor", "=", "X",...
[ 223, 0 ]
[ 469, 73 ]
python
en
['en', 'en', 'en']
True
user_data_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific data dir for this application.
def user_data_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of ...
[ "def", "user_data_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "ap...
[ 48, 0 ]
[ 100, 15 ]
python
en
['en', 'en', 'en']
True
site_data_dir
(appname=None, appauthor=None, version=None, multipath=False)
r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-shared data dir for this application.
def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of ...
[ "def", "site_data_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "multipath", "=", "False", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "...
[ 103, 0 ]
[ 166, 15 ]
python
en
['en', 'en', 'en']
True
user_config_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific config dir for this application.
def user_config_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name...
[ "def", "user_config_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "user_data_dir", ...
[ 169, 0 ]
[ 206, 15 ]
python
en
['en', 'en', 'en']
True
site_config_dir
(appname=None, appauthor=None, version=None, multipath=False)
r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-shared data dir for this application.
def site_config_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name o...
[ "def", "site_config_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "multipath", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "site_data_dir"...
[ 211, 0 ]
[ 260, 15 ]
python
en
['en', 'en', 'en']
True
user_cache_dir
(appname=None, appauthor=None, version=None, opinion=True)
r"""Return full path to the user-specific cache dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific cache dir for this application.
def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True): r"""Return full path to the user-specific cache dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of...
[ "def", "user_cache_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "opinion", "=", "True", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "ap...
[ 263, 0 ]
[ 321, 15 ]
python
en
['en', 'en', 'en']
True
user_state_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific state dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific state dir for this application.
def user_state_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific state dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name o...
[ "def", "user_state_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "user_data_dir", ...
[ 324, 0 ]
[ 363, 15 ]
python
en
['en', 'en', 'en']
True
user_log_dir
(appname=None, appauthor=None, version=None, opinion=True)
r"""Return full path to the user-specific log dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific log dir for this application.
def user_log_dir(appname=None, appauthor=None, version=None, opinion=True): r"""Return full path to the user-specific log dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the...
[ "def", "user_log_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "opinion", "=", "True", ")", ":", "if", "system", "==", "\"darwin\"", ":", "path", "=", "os", ".", "path", ".", "join", "(", "os", ...
[ 366, 0 ]
[ 414, 15 ]
python
en
['en', 'en', 'en']
True
_get_win_folder_from_registry
(csidl_name)
This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names.
This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names.
def _get_win_folder_from_registry(csidl_name): """This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names. """ if PY3: import winreg as _winreg else: import _winreg shell_folder_name = { "CS...
[ "def", "_get_win_folder_from_registry", "(", "csidl_name", ")", ":", "if", "PY3", ":", "import", "winreg", "as", "_winreg", "else", ":", "import", "_winreg", "shell_folder_name", "=", "{", "\"CSIDL_APPDATA\"", ":", "\"AppData\"", ",", "\"CSIDL_COMMON_APPDATA\"", ":"...
[ 465, 0 ]
[ 486, 14 ]
python
en
['en', 'en', 'en']
True
_win_path_to_bytes
(path)
Encode Windows paths to bytes. Only used on Python 2. Motivation is to be consistent with other operating systems where paths are also returned as bytes. This avoids problems mixing bytes and Unicode elsewhere in the codebase. For more details and discussion see <https://github.com/pypa/pip/issues/3463...
Encode Windows paths to bytes. Only used on Python 2.
def _win_path_to_bytes(path): """Encode Windows paths to bytes. Only used on Python 2. Motivation is to be consistent with other operating systems where paths are also returned as bytes. This avoids problems mixing bytes and Unicode elsewhere in the codebase. For more details and discussion see <ht...
[ "def", "_win_path_to_bytes", "(", "path", ")", ":", "for", "encoding", "in", "(", "'ASCII'", ",", "'MBCS'", ")", ":", "try", ":", "return", "path", ".", "encode", "(", "encoding", ")", "except", "(", "UnicodeEncodeError", ",", "LookupError", ")", ":", "p...
[ 580, 0 ]
[ 595, 15 ]
python
en
['en', 'en', 'en']
True
DataHandling.get_builtup_data
(self,targets=[], not_targets=[], color_mode='grayscale')
画像のフルパスを受け取る :return: 正規化されたデータ、ラベル
画像のフルパスを受け取る :return: 正規化されたデータ、ラベル
def get_builtup_data(self,targets=[], not_targets=[], color_mode='grayscale'): """ 画像のフルパスを受け取る :return: 正規化されたデータ、ラベル """ train, valid = self.data_handling.split_train_test(targets=targets, not_targets=not_targets) return self.data_handling.preprocess(train=train, valid=...
[ "def", "get_builtup_data", "(", "self", ",", "targets", "=", "[", "]", ",", "not_targets", "=", "[", "]", ",", "color_mode", "=", "'grayscale'", ")", ":", "train", ",", "valid", "=", "self", ".", "data_handling", ".", "split_train_test", "(", "targets", ...
[ 11, 4 ]
[ 17, 93 ]
python
en
['en', 'error', 'th']
False
DataHandling.read_dirs
(self, target_label)
:return: target type=list ターゲット画像のリストをくるんだリスト target[0]で取り出す 0dimensionには基本的に1要素しか入らないがnot_targetの形状を考慮しそちらの形状で揃えた not_target type=list ターゲット以外の画像のリストをくるんだリスト not_target[index]で各ノイズにアクセスできる ...
:return: target type=list ターゲット画像のリストをくるんだリスト target[0]で取り出す 0dimensionには基本的に1要素しか入らないがnot_targetの形状を考慮しそちらの形状で揃えた
def read_dirs(self, target_label): """ :return: target type=list ターゲット画像のリストをくるんだリスト target[0]で取り出す 0dimensionには基本的に1要素しか入らないがnot_targetの形状を考慮しそちらの形状で揃えた not_target type=list ターゲット以外の画像のリストをくるんだリスト ...
[ "def", "read_dirs", "(", "self", ",", "target_label", ")", ":", "target_dir", ",", "not_target_dir", "=", "self", ".", "get_img_dir", "(", "target_label", "=", "target_label", ",", "split_tag", "=", "True", ")", "return", "self", ".", "read_datas_dir", "(", ...
[ 22, 4 ]
[ 36, 107 ]
python
en
['en', 'error', 'th']
False
DataHandling.get_builtup_data_include_noise
(self)
:return: tuple (self.x_train, self.x_test, self.y_train, self.y_test)
:return: tuple (self.x_train, self.x_test, self.y_train, self.y_test)
def get_builtup_data_include_noise(self): """ :return: tuple (self.x_train, self.x_test, self.y_train, self.y_test) """ return self.oppo.return_datafiles()
[ "def", "get_builtup_data_include_noise", "(", "self", ")", ":", "return", "self", ".", "oppo", ".", "return_datafiles", "(", ")" ]
[ 48, 4 ]
[ 52, 43 ]
python
en
['en', 'error', 'th']
False
define_filenames
(folder: Path)
Locates all relevant breseq files.
Locates all relevant breseq files.
def define_filenames(folder: Path) -> Dict[str, Path]: """ Locates all relevant breseq files.""" files = { 'index': folder / "output" / "index.html", 'gd': folder / "output" / "evidence" / "annotated.gd", 'vcf': folder / "data" / "output.vcf", 'summary': folder / "data" / "summary....
[ "def", "define_filenames", "(", "folder", ":", "Path", ")", "->", "Dict", "[", "str", ",", "Path", "]", ":", "files", "=", "{", "'index'", ":", "folder", "/", "\"output\"", "/", "\"index.html\"", ",", "'gd'", ":", "folder", "/", "\"output\"", "/", "\"e...
[ 11, 0 ]
[ 23, 13 ]
python
en
['en', 'it', 'en']
True
move_breseq_folder
(source_folder: Path, destination_folder: Path)
Moves the relevant breseq files into a new folder. Does not move any of the unneccessary files. Parameters ---------- source_folder: Source breseq folder. destination_folder: The parent folder where the files should be saved. The contents of the source folder will be added to a subfolder named after the linked...
Moves the relevant breseq files into a new folder. Does not move any of the unneccessary files. Parameters ---------- source_folder: Source breseq folder. destination_folder: The parent folder where the files should be saved. The contents of the source folder will be added to a subfolder named after the linked...
def move_breseq_folder(source_folder: Path, destination_folder: Path): """ Moves the relevant breseq files into a new folder. Does not move any of the unneccessary files. Parameters ---------- source_folder: Source breseq folder. destination_folder: The parent folder where the files should be saved. The contents...
[ "def", "move_breseq_folder", "(", "source_folder", ":", "Path", ",", "destination_folder", ":", "Path", ")", ":", "make_breseq_folders", "(", "destination_folder", ")", "files_source", "=", "define_filenames", "(", "source_folder", ")", "files_destination", "=", "defi...
[ 35, 0 ]
[ 52, 65 ]
python
en
['en', 'error', 'th']
False
ShapeBuilder.default_sizes
(cls, scale)
Convert single scale parameter to a dict of arguments for build.
Convert single scale parameter to a dict of arguments for build.
def default_sizes(cls, scale): """Convert single scale parameter to a dict of arguments for build.""" raise RuntimeError('Using "scale" is not supported for %s' % cls.__name__)
[ "def", "default_sizes", "(", "cls", ",", "scale", ")", ":", "raise", "RuntimeError", "(", "'Using \"scale\" is not supported for %s'", "%", "cls", ".", "__name__", ")" ]
[ 46, 4 ]
[ 49, 40 ]
python
en
['en', 'en', 'en']
True
ShapeBuilder.diameter_to_default_scale
(cls, diameter)
Convert diameter parameter to a default size scale.
Convert diameter parameter to a default size scale.
def diameter_to_default_scale(cls, diameter): """Convert diameter parameter to a default size scale.""" raise RuntimeError('Using "diameter" is not supported for %s' % cls.__name__)
[ "def", "diameter_to_default_scale", "(", "cls", ",", "diameter", ")", ":", "raise", "RuntimeError", "(", "'Using \"diameter\" is not supported for %s'", "%", "cls", ".", "__name__", ")" ]
[ 52, 4 ]
[ 55, 40 ]
python
en
['en', 'fr', 'en']
True
ShapeBuilder._build
(cls, **kwargs)
Build the shape with the parameters. Returns either shape_or_list_shapes or tuple (shape_or_list_shapes, phantom_vertices).
Build the shape with the parameters.
def _build(cls, **kwargs): """Build the shape with the parameters. Returns either shape_or_list_shapes or tuple (shape_or_list_shapes, phantom_vertices). """ pass
[ "def", "_build", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "pass" ]
[ 59, 4 ]
[ 67, 12 ]
python
en
['en', 'en', 'en']
True
ShapeBuilder.build
(cls, scale=None, diameter=None, **kwargs)
Build the shape either from scale, diameter, or kwargs. At least one of diameter or scale must be None. Returns tuple (list_of_shapes, phantom_vertices).
Build the shape either from scale, diameter, or kwargs.
def build(cls, scale=None, diameter=None, **kwargs): """Build the shape either from scale, diameter, or kwargs. At least one of diameter or scale must be None. Returns tuple (list_of_shapes, phantom_vertices). """ assert not (scale is not None and diameter is not None ...
[ "def", "build", "(", "cls", ",", "scale", "=", "None", ",", "diameter", "=", "None", ",", "*", "*", "kwargs", ")", ":", "assert", "not", "(", "scale", "is", "not", "None", "and", "diameter", "is", "not", "None", ")", ",", "'Cannot build shape from both...
[ 70, 4 ]
[ 93, 39 ]
python
en
['en', 'en', 'en']
True
strongly_connected_components
(G)
Adapted from networkx: http://networkx.github.io/ Parameters ---------- G : DiGraph Returns ------- comp : generator of sets A generator of sets of nodes, one for each strongly connected component of G.
Adapted from networkx: http://networkx.github.io/ Parameters ---------- G : DiGraph Returns ------- comp : generator of sets A generator of sets of nodes, one for each strongly connected component of G.
def strongly_connected_components(G): # noqa: C901 ''' Adapted from networkx: http://networkx.github.io/ Parameters ---------- G : DiGraph Returns ------- comp : generator of sets A generator of sets of nodes, one for each strongly connected component of G. ''' p...
[ "def", "strongly_connected_components", "(", "G", ")", ":", "# noqa: C901", "preorder", "=", "{", "}", "lowlink", "=", "{", "}", "scc_found", "=", "{", "}", "scc_queue", "=", "[", "]", "i", "=", "0", "# Preorder counter", "for", "source", "in", "G", ".",...
[ 87, 0 ]
[ 139, 43 ]
python
en
['en', 'error', 'th']
False
simple_cycles
(G)
Adapted from networkx: http://networkx.github.io/ Parameters ---------- G : DiGraph Returns ------- cycle_generator: generator A generator that produces elementary cycles of the graph. Each cycle is represented by a list of nodes along the cycle.
Adapted from networkx: http://networkx.github.io/ Parameters ---------- G : DiGraph Returns ------- cycle_generator: generator A generator that produces elementary cycles of the graph. Each cycle is represented by a list of nodes along the cycle.
def simple_cycles(G): # noqa: C901 ''' Adapted from networkx: http://networkx.github.io/ Parameters ---------- G : DiGraph Returns ------- cycle_generator: generator A generator that produces elementary cycles of the graph. Each cycle is represented by a list of nodes alon...
[ "def", "simple_cycles", "(", "G", ")", ":", "# noqa: C901", "def", "_unblock", "(", "thisnode", ",", "blocked", ",", "B", ")", ":", "stack", "=", "set", "(", "[", "thisnode", "]", ")", "while", "stack", ":", "node", "=", "stack", ".", "pop", "(", "...
[ 142, 0 ]
[ 209, 59 ]
python
en
['en', 'error', 'th']
False
find_cycle
(graph)
Looks for a cycle in the graph. If found, returns the first cycle. If nodes a1, a2, ..., an are in a cycle, then this returns: [(a1,a2), (a2,a3), ... (an-1,an), (an, a1)] Otherwise returns an empty list.
Looks for a cycle in the graph. If found, returns the first cycle. If nodes a1, a2, ..., an are in a cycle, then this returns: [(a1,a2), (a2,a3), ... (an-1,an), (an, a1)] Otherwise returns an empty list.
def find_cycle(graph): ''' Looks for a cycle in the graph. If found, returns the first cycle. If nodes a1, a2, ..., an are in a cycle, then this returns: [(a1,a2), (a2,a3), ... (an-1,an), (an, a1)] Otherwise returns an empty list. ''' cycles = list(simple_cycles(graph)) if cycles: ...
[ "def", "find_cycle", "(", "graph", ")", ":", "cycles", "=", "list", "(", "simple_cycles", "(", "graph", ")", ")", "if", "cycles", ":", "nodes", "=", "cycles", "[", "0", "]", "nodes", ".", "append", "(", "nodes", "[", "0", "]", ")", "edges", "=", ...
[ 212, 0 ]
[ 230, 17 ]
python
en
['en', 'error', 'th']
False
get_stacktrace
(thread_id)
Returns the stack trace for the thread id as a list of strings.
Returns the stack trace for the thread id as a list of strings.
def get_stacktrace(thread_id): ''' Returns the stack trace for the thread id as a list of strings. ''' gdb.execute('thread %d' % thread_id, from_tty=False, to_string=True) output = gdb.execute('bt', from_tty=False, to_string=True) stacktrace_lines = output.strip().split('\n') return stacktra...
[ "def", "get_stacktrace", "(", "thread_id", ")", ":", "gdb", ".", "execute", "(", "'thread %d'", "%", "thread_id", ",", "from_tty", "=", "False", ",", "to_string", "=", "True", ")", "output", "=", "gdb", ".", "execute", "(", "'bt'", ",", "from_tty", "=", ...
[ 233, 0 ]
[ 240, 27 ]
python
en
['en', 'error', 'th']
False
is_thread_blocked_with_frame
( thread_id, top_line, expected_top_line, expected_frame )
Returns True if we found expected_top_line in top_line, and we found the expected_frame in the thread's stack trace.
Returns True if we found expected_top_line in top_line, and we found the expected_frame in the thread's stack trace.
def is_thread_blocked_with_frame( thread_id, top_line, expected_top_line, expected_frame ): ''' Returns True if we found expected_top_line in top_line, and we found the expected_frame in the thread's stack trace. ''' if expected_top_line not in top_line: return False stacktrace_lines...
[ "def", "is_thread_blocked_with_frame", "(", "thread_id", ",", "top_line", ",", "expected_top_line", ",", "expected_frame", ")", ":", "if", "expected_top_line", "not", "in", "top_line", ":", "return", "False", "stacktrace_lines", "=", "get_stacktrace", "(", "thread_id"...
[ 243, 0 ]
[ 253, 67 ]
python
en
['en', 'error', 'th']
False
print_cycle
(graph, lwp_to_thread_id, cycle)
Prints the threads and mutexes involved in the deadlock.
Prints the threads and mutexes involved in the deadlock.
def print_cycle(graph, lwp_to_thread_id, cycle): '''Prints the threads and mutexes involved in the deadlock.''' for (m, n) in cycle: print( 'Thread %d (LWP %d) is waiting on %s (0x%016x) held by ' 'Thread %d (LWP %d)' % ( lwp_to_thread_id[m], m, gr...
[ "def", "print_cycle", "(", "graph", ",", "lwp_to_thread_id", ",", "cycle", ")", ":", "for", "(", "m", ",", "n", ")", "in", "cycle", ":", "print", "(", "'Thread %d (LWP %d) is waiting on %s (0x%016x) held by '", "'Thread %d (LWP %d)'", "%", "(", "lwp_to_thread_id", ...
[ 299, 0 ]
[ 309, 9 ]
python
en
['en', 'en', 'en']
True
get_thread_info
()
Returns a pair of: - map of LWP -> thread ID - map of blocked threads LWP -> potential mutex type
Returns a pair of: - map of LWP -> thread ID - map of blocked threads LWP -> potential mutex type
def get_thread_info(): ''' Returns a pair of: - map of LWP -> thread ID - map of blocked threads LWP -> potential mutex type ''' # LWP -> thread ID lwp_to_thread_id = {} # LWP -> potential mutex type it is blocked on blocked_threads = {} output = gdb.execute('info threads', fro...
[ "def", "get_thread_info", "(", ")", ":", "# LWP -> thread ID", "lwp_to_thread_id", "=", "{", "}", "# LWP -> potential mutex type it is blocked on", "blocked_threads", "=", "{", "}", "output", "=", "gdb", ".", "execute", "(", "'info threads'", ",", "from_tty", "=", "...
[ 312, 0 ]
[ 338, 46 ]
python
en
['en', 'error', 'th']
False
get_pthread_mutex_t_owner_and_address
(lwp_to_thread_id, thread_lwp)
Finds the thread holding the mutex that this thread is blocked on. Returns a pair of (lwp of thread owning mutex, mutex address), or (None, None) if not found.
Finds the thread holding the mutex that this thread is blocked on. Returns a pair of (lwp of thread owning mutex, mutex address), or (None, None) if not found.
def get_pthread_mutex_t_owner_and_address(lwp_to_thread_id, thread_lwp): ''' Finds the thread holding the mutex that this thread is blocked on. Returns a pair of (lwp of thread owning mutex, mutex address), or (None, None) if not found. ''' # Go up the stack to the pthread_mutex_lock frame g...
[ "def", "get_pthread_mutex_t_owner_and_address", "(", "lwp_to_thread_id", ",", "thread_lwp", ")", ":", "# Go up the stack to the pthread_mutex_lock frame", "gdb", ".", "execute", "(", "'thread %d'", "%", "lwp_to_thread_id", "[", "thread_lwp", "]", ",", "from_tty", "=", "Fa...
[ 341, 0 ]
[ 362, 27 ]
python
en
['en', 'error', 'th']
False
get_pthread_rwlock_t_owner_and_address
(lwp_to_thread_id, thread_lwp)
If the thread is waiting on a write-locked pthread_rwlock_t, this will return the pair of: (lwp of thread that is write-owning the mutex, mutex address) or (None, None) if not found, or if the mutex is read-locked.
If the thread is waiting on a write-locked pthread_rwlock_t, this will return the pair of: (lwp of thread that is write-owning the mutex, mutex address) or (None, None) if not found, or if the mutex is read-locked.
def get_pthread_rwlock_t_owner_and_address(lwp_to_thread_id, thread_lwp): ''' If the thread is waiting on a write-locked pthread_rwlock_t, this will return the pair of: (lwp of thread that is write-owning the mutex, mutex address) or (None, None) if not found, or if the mutex is read-locked. ...
[ "def", "get_pthread_rwlock_t_owner_and_address", "(", "lwp_to_thread_id", ",", "thread_lwp", ")", ":", "# Go up the stack to the pthread_rwlock_{rd|wr}lock frame", "gdb", ".", "execute", "(", "'thread %d'", "%", "lwp_to_thread_id", "[", "thread_lwp", "]", ",", "from_tty", "...
[ 365, 0 ]
[ 393, 27 ]
python
en
['en', 'error', 'th']
False
DiGraph.node_link_data
(self)
Returns the graph as a dictionary in a format that can be serialized.
Returns the graph as a dictionary in a format that can be serialized.
def node_link_data(self): ''' Returns the graph as a dictionary in a format that can be serialized. ''' data = { 'directed': True, 'multigraph': False, 'graph': {}, 'links': [], 'nodes': [], } # Do one p...
[ "def", "node_link_data", "(", "self", ")", ":", "data", "=", "{", "'directed'", ":", "True", ",", "'multigraph'", ":", "False", ",", "'graph'", ":", "{", "}", ",", "'links'", ":", "[", "]", ",", "'nodes'", ":", "[", "]", ",", "}", "# Do one pass to b...
[ 58, 4 ]
[ 84, 19 ]
python
en
['en', 'error', 'th']
False
MutexType.get_mutex_type
(thread_id, top_line)
Returns the probable mutex type, based on the first line of the thread's stack. Returns None if not found.
Returns the probable mutex type, based on the first line of the thread's stack. Returns None if not found.
def get_mutex_type(thread_id, top_line): ''' Returns the probable mutex type, based on the first line of the thread's stack. Returns None if not found. ''' if is_thread_blocked_with_frame( thread_id, top_line, '__lll_lock_wait', 'pthread_mutex' ): ...
[ "def", "get_mutex_type", "(", "thread_id", ",", "top_line", ")", ":", "if", "is_thread_blocked_with_frame", "(", "thread_id", ",", "top_line", ",", "'__lll_lock_wait'", ",", "'pthread_mutex'", ")", ":", "return", "MutexType", ".", "PTHREAD_MUTEX_T", "if", "is_thread...
[ 263, 4 ]
[ 277, 19 ]
python
en
['en', 'error', 'th']
False
MutexType.get_mutex_owner_and_address_func_for_type
(mutex_type)
Returns a function to resolve the mutex owner and address for the given type. The returned function f has the following signature: f: args: (map of thread lwp -> thread id), blocked thread lwp returns: (lwp of thread owning mutex, mutex address) ...
Returns a function to resolve the mutex owner and address for the given type. The returned function f has the following signature:
def get_mutex_owner_and_address_func_for_type(mutex_type): ''' Returns a function to resolve the mutex owner and address for the given type. The returned function f has the following signature: f: args: (map of thread lwp -> thread id), blocked thread lwp retu...
[ "def", "get_mutex_owner_and_address_func_for_type", "(", "mutex_type", ")", ":", "if", "mutex_type", "==", "MutexType", ".", "PTHREAD_MUTEX_T", ":", "return", "get_pthread_mutex_t_owner_and_address", "if", "mutex_type", "==", "MutexType", ".", "PTHREAD_RWLOCK_T", ":", "re...
[ 280, 4 ]
[ 296, 19 ]
python
en
['en', 'error', 'th']
False
Deadlock.invoke
(self, arg, from_tty)
Prints the threads and mutexes in a deadlock, if it exists.
Prints the threads and mutexes in a deadlock, if it exists.
def invoke(self, arg, from_tty): '''Prints the threads and mutexes in a deadlock, if it exists.''' lwp_to_thread_id, blocked_threads = get_thread_info() # Nodes represent threads. Edge (A,B) exists if thread A # is waiting on a mutex held by thread B. graph = DiGraph() ...
[ "def", "invoke", "(", "self", ",", "arg", ",", "from_tty", ")", ":", "lwp_to_thread_id", ",", "blocked_threads", "=", "get_thread_info", "(", ")", "# Nodes represent threads. Edge (A,B) exists if thread A", "# is waiting on a mutex held by thread B.", "graph", "=", "DiGraph...
[ 402, 4 ]
[ 437, 13 ]
python
en
['en', 'en', 'en']
True
no_append_slash
(view_func)
Mark a view function as excluded from CommonMiddleware's APPEND_SLASH redirection.
Mark a view function as excluded from CommonMiddleware's APPEND_SLASH redirection.
def no_append_slash(view_func): """ Mark a view function as excluded from CommonMiddleware's APPEND_SLASH redirection. """ # view_func.should_append_slash = False would also work, but decorators are # nicer if they don't have side effects, so return a new function. def wrapped_view(*args, **...
[ "def", "no_append_slash", "(", "view_func", ")", ":", "# view_func.should_append_slash = False would also work, but decorators are", "# nicer if they don't have side effects, so return a new function.", "def", "wrapped_view", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", ...
[ 3, 0 ]
[ 13, 41 ]
python
en
['en', 'error', 'th']
False
connection_requires_http_tunnel
( proxy_url=None, proxy_config=None, destination_scheme=None )
Returns True if the connection requires an HTTP CONNECT through the proxy. :param URL proxy_url: URL of the proxy. :param ProxyConfig proxy_config: Proxy configuration from poolmanager.py :param str destination_scheme: The scheme of the destination. (i.e https, http, etc)
Returns True if the connection requires an HTTP CONNECT through the proxy.
def connection_requires_http_tunnel( proxy_url=None, proxy_config=None, destination_scheme=None ): """ Returns True if the connection requires an HTTP CONNECT through the proxy. :param URL proxy_url: URL of the proxy. :param ProxyConfig proxy_config: Proxy configuration from poolman...
[ "def", "connection_requires_http_tunnel", "(", "proxy_url", "=", "None", ",", "proxy_config", "=", "None", ",", "destination_scheme", "=", "None", ")", ":", "# If we're not using a proxy, no way to use a tunnel.", "if", "proxy_url", "is", "None", ":", "return", "False",...
[ 3, 0 ]
[ 33, 15 ]
python
en
['en', 'error', 'th']
False
create_proxy_ssl_context
( ssl_version, cert_reqs, ca_certs=None, ca_cert_dir=None, ca_cert_data=None )
Generates a default proxy ssl context if one hasn't been provided by the user.
Generates a default proxy ssl context if one hasn't been provided by the user.
def create_proxy_ssl_context( ssl_version, cert_reqs, ca_certs=None, ca_cert_dir=None, ca_cert_data=None ): """ Generates a default proxy ssl context if one hasn't been provided by the user. """ ssl_context = create_urllib3_context( ssl_version=resolve_ssl_version(ssl_version), c...
[ "def", "create_proxy_ssl_context", "(", "ssl_version", ",", "cert_reqs", ",", "ca_certs", "=", "None", ",", "ca_cert_dir", "=", "None", ",", "ca_cert_data", "=", "None", ")", ":", "ssl_context", "=", "create_urllib3_context", "(", "ssl_version", "=", "resolve_ssl_...
[ 36, 0 ]
[ 55, 22 ]
python
en
['en', 'error', 'th']
False
run
(argv=None)
The main function which creates the pipeline and runs it
The main function which creates the pipeline and runs it
def run(argv=None): """The main function which creates the pipeline and runs it""" parser = argparse.ArgumentParser() parser.add_argument( '--input-bucket', dest='input_bucket', required=True, default='data-daimlr', help='GS bucket_name where the input files are pres...
[ "def", "run", "(", "argv", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'--input-bucket'", ",", "dest", "=", "'input_bucket'", ",", "required", "=", "True", ",", "default", "=", "...
[ 174, 0 ]
[ 251, 34 ]
python
en
['en', 'en', 'en']
True
get_args
()
Argument parser. Returns: Dictionary of arguments.
Argument parser. Returns: Dictionary of arguments.
def get_args(): """Argument parser. Returns: Dictionary of arguments. """ parser = argparse.ArgumentParser() parser.add_argument( '--job-dir', type=str, required=True, help='local or GCS location for writing checkpoints and exporting ' 'models') ...
[ "def", "get_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'--job-dir'", ",", "type", "=", "str", ",", "required", "=", "True", ",", "help", "=", "'local or GCS location for writing checkp...
[ 28, 0 ]
[ 75, 15 ]
python
da
['fr', 'da', 'pt']
False
train_and_evaluate
(args)
Trains and evaluates the Keras model. Uses the Keras model defined in model.py and trains on data loaded in model.py. Saves the trained model in TensorFlow SavedModel format to the path defined in part by the --job-dir argument. Args: args: dictionary of arguments - see get_args() for details ...
Trains and evaluates the Keras model. Uses the Keras model defined in model.py and trains on data loaded in model.py. Saves the trained model in TensorFlow SavedModel format to the path defined in part by the --job-dir argument. Args: args: dictionary of arguments - see get_args() for details ...
def train_and_evaluate(args): """Trains and evaluates the Keras model. Uses the Keras model defined in model.py and trains on data loaded in model.py. Saves the trained model in TensorFlow SavedModel format to the path defined in part by the --job-dir argument. Args: args: dictionary of ar...
[ "def", "train_and_evaluate", "(", "args", ")", ":", "ts", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "'%Y%m%d%H%M%S'", ")", "# Create the Keras Model", "keras_model", "=", "model", ".", "create_keras_model", "(", "learning_rate...
[ 78, 0 ]
[ 114, 54 ]
python
en
['en', 'en', 'en']
True
Storage.locked_get
(self)
Retrieve Credential from file. Returns: oauth2client.client.Credentials Raises: IOError if the file is a symbolic link.
Retrieve Credential from file.
def locked_get(self): """Retrieve Credential from file. Returns: oauth2client.client.Credentials Raises: IOError if the file is a symbolic link. """ credentials = None _helpers.validate_file(self._filename) try: f = open(self....
[ "def", "locked_get", "(", "self", ")", ":", "credentials", "=", "None", "_helpers", ".", "validate_file", "(", "self", ".", "_filename", ")", "try", ":", "f", "=", "open", "(", "self", ".", "_filename", ",", "'rb'", ")", "content", "=", "f", ".", "re...
[ 34, 4 ]
[ 58, 26 ]
python
en
['en', 'en', 'en']
True
Storage._create_file_if_needed
(self)
Create an empty file if necessary. This method will not initialize the file. Instead it implements a simple version of "touch" to ensure the file has been created.
Create an empty file if necessary.
def _create_file_if_needed(self): """Create an empty file if necessary. This method will not initialize the file. Instead it implements a simple version of "touch" to ensure the file has been created. """ if not os.path.exists(self._filename): old_umask = os.umask(0o...
[ "def", "_create_file_if_needed", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "_filename", ")", ":", "old_umask", "=", "os", ".", "umask", "(", "0o177", ")", "try", ":", "open", "(", "self", ".", "_filename"...
[ 60, 4 ]
[ 71, 35 ]
python
en
['en', 'en', 'en']
True
Storage.locked_put
(self, credentials)
Write Credentials to file. Args: credentials: Credentials, the credentials to store. Raises: IOError if the file is a symbolic link.
Write Credentials to file.
def locked_put(self, credentials): """Write Credentials to file. Args: credentials: Credentials, the credentials to store. Raises: IOError if the file is a symbolic link. """ self._create_file_if_needed() _helpers.validate_file(self._filename) ...
[ "def", "locked_put", "(", "self", ",", "credentials", ")", ":", "self", ".", "_create_file_if_needed", "(", ")", "_helpers", ".", "validate_file", "(", "self", ".", "_filename", ")", "f", "=", "open", "(", "self", ".", "_filename", ",", "'w'", ")", "f", ...
[ 73, 4 ]
[ 86, 17 ]
python
en
['en', 'en', 'en']
True
Storage.locked_delete
(self)
Delete Credentials file. Args: credentials: Credentials, the credentials to store.
Delete Credentials file.
def locked_delete(self): """Delete Credentials file. Args: credentials: Credentials, the credentials to store. """ os.unlink(self._filename)
[ "def", "locked_delete", "(", "self", ")", ":", "os", ".", "unlink", "(", "self", ".", "_filename", ")" ]
[ 88, 4 ]
[ 94, 33 ]
python
de
['de', 'it', 'en']
False
extract_resources
(taxonomy_filepath)
Reads a .json representing a taxonomy and returns a data structure representing their hierarchical relationship :param taxonomy_file: a string representing a path to a .json file :return: Node representing root of taxonomic tree
Reads a .json representing a taxonomy and returns a data structure representing their hierarchical relationship :param taxonomy_file: a string representing a path to a .json file :return: Node representing root of taxonomic tree
def extract_resources(taxonomy_filepath): """ Reads a .json representing a taxonomy and returns a data structure representing their hierarchical relationship :param taxonomy_file: a string representing a path to a .json file :return: Node representing root of taxonomic tree """ try: ...
[ "def", "extract_resources", "(", "taxonomy_filepath", ")", ":", "try", ":", "with", "open", "(", "taxonomy_filepath", ",", "'r'", ")", "as", "fp", ":", "json_str", "=", "fp", ".", "read", "(", ")", "json_data", "=", "json", ".", "loads", "(", "json_str",...
[ 48, 0 ]
[ 64, 15 ]
python
en
['en', 'error', 'th']
False
read_users
(users_fp)
Reads a .csv from @user_fp representing users into a list of dictionaries, each elt of which represents a user :param user_fp: a .csv file where each line represents a user :return: a list of dictionaries
Reads a .csv from
def read_users(users_fp): """ Reads a .csv from @user_fp representing users into a list of dictionaries, each elt of which represents a user :param user_fp: a .csv file where each line represents a user :return: a list of dictionaries """ users = [] with open(users_fp, 'r') as fp: ...
[ "def", "read_users", "(", "users_fp", ")", ":", "users", "=", "[", "]", "with", "open", "(", "users_fp", ",", "'r'", ")", "as", "fp", ":", "fields", "=", "fp", ".", "readline", "(", ")", ".", "rstrip", "(", ")", ".", "split", "(", "\",\"", ")", ...
[ 67, 0 ]
[ 80, 16 ]
python
en
['en', 'error', 'th']
False
publish_burst
(burst, num_events_counter, fp)
Publishes and prints each event :param burst: a list of dictionaries, each representing an event :param num_events_counter: an instance of Value shared by all processes to track the number of published events :param publisher: a PubSub publisher :param topic_path: a topic path for PubSub :r...
Publishes and prints each event :param burst: a list of dictionaries, each representing an event :param num_events_counter: an instance of Value shared by all processes to track the number of published events :param publisher: a PubSub publisher :param topic_path: a topic path for PubSub :r...
def publish_burst(burst, num_events_counter, fp): """ Publishes and prints each event :param burst: a list of dictionaries, each representing an event :param num_events_counter: an instance of Value shared by all processes to track the number of published events :param publisher: a PubSub publis...
[ "def", "publish_burst", "(", "burst", ",", "num_events_counter", ",", "fp", ")", ":", "for", "event_dict", "in", "burst", ":", "json_str", "=", "json", ".", "dumps", "(", "event_dict", ")", "num_events_counter", ".", "value", "+=", "1", "fp", ".", "write",...
[ 82, 0 ]
[ 95, 33 ]
python
en
['en', 'error', 'th']
False
create_user_process
(user, root, num_events_counter)
Code for continuously-running process representing a user publishing events to pubsub :param user: a dictionary representing characteristics of the user :param root: an instance of AnyNode representing the home page of a website :param num_events_counter: a variable shared among all processes used ...
Code for continuously-running process representing a user publishing events to pubsub :param user: a dictionary representing characteristics of the user :param root: an instance of AnyNode representing the home page of a website :param num_events_counter: a variable shared among all processes used ...
def create_user_process(user, root, num_events_counter): """ Code for continuously-running process representing a user publishing events to pubsub :param user: a dictionary representing characteristics of the user :param root: an instance of AnyNode representing the home page of a website :param...
[ "def", "create_user_process", "(", "user", ",", "root", ",", "num_events_counter", ")", ":", "user", "[", "'page'", "]", "=", "root", "user", "[", "'is_online'", "]", "=", "True", "user", "[", "'offline_events'", "]", "=", "[", "]", "user", "[", "'time'"...
[ 97, 0 ]
[ 129, 18 ]
python
en
['en', 'error', 'th']
False
generate_event
(user)
Returns a dictionary representing an event :param user: :return:
Returns a dictionary representing an event :param user: :return:
def generate_event(user): """ Returns a dictionary representing an event :param user: :return: """ user['page'] = get_next_page(user) uri = str(user['page'].name) event_time = user['time'] current_time_str = event_time.strftime('%Y-%m-%dT%H:%M:%S.%fZ') file_size_bytes = random.ch...
[ "def", "generate_event", "(", "user", ")", ":", "user", "[", "'page'", "]", "=", "get_next_page", "(", "user", ")", "uri", "=", "str", "(", "user", "[", "'page'", "]", ".", "name", ")", "event_time", "=", "user", "[", "'time'", "]", "current_time_str",...
[ 131, 0 ]
[ 147, 46 ]
python
en
['en', 'error', 'th']
False
get_next_page
(user)
Consults the user's representation of the web site taxonomy to determine the next page that they visit :param user: :return:
Consults the user's representation of the web site taxonomy to determine the next page that they visit :param user: :return:
def get_next_page(user): """ Consults the user's representation of the web site taxonomy to determine the next page that they visit :param user: :return: """ possible_next_pages = [user['page']] if not user['page'].is_leaf: possible_next_pages += list(user['page'].children) if (u...
[ "def", "get_next_page", "(", "user", ")", ":", "possible_next_pages", "=", "[", "user", "[", "'page'", "]", "]", "if", "not", "user", "[", "'page'", "]", ".", "is_leaf", ":", "possible_next_pages", "+=", "list", "(", "user", "[", "'page'", "]", ".", "c...
[ 149, 0 ]
[ 161, 20 ]
python
en
['en', 'error', 'th']
False
get_wsgi_application
()
The public interface to Django's WSGI support. Return a WSGI callable. Avoids making django.core.handlers.WSGIHandler a public API, in case the internal WSGI implementation changes or moves in the future.
The public interface to Django's WSGI support. Return a WSGI callable.
def get_wsgi_application(): """ The public interface to Django's WSGI support. Return a WSGI callable. Avoids making django.core.handlers.WSGIHandler a public API, in case the internal WSGI implementation changes or moves in the future. """ django.setup(set_prefix=False) return WSGIHandler(...
[ "def", "get_wsgi_application", "(", ")", ":", "django", ".", "setup", "(", "set_prefix", "=", "False", ")", "return", "WSGIHandler", "(", ")" ]
[ 4, 0 ]
[ 12, 24 ]
python
en
['en', 'error', 'th']
False
Command.run_from_argv
(self, argv)
Pre-parse the command line to extract the value of the --testrunner option. This allows a test runner to define additional command line arguments.
Pre-parse the command line to extract the value of the --testrunner option. This allows a test runner to define additional command line arguments.
def run_from_argv(self, argv): """ Pre-parse the command line to extract the value of the --testrunner option. This allows a test runner to define additional command line arguments. """ self.test_runner = get_command_line_option(argv, '--testrunner') super().run_f...
[ "def", "run_from_argv", "(", "self", ",", "argv", ")", ":", "self", ".", "test_runner", "=", "get_command_line_option", "(", "argv", ",", "'--testrunner'", ")", "super", "(", ")", ".", "run_from_argv", "(", "argv", ")" ]
[ 15, 4 ]
[ 22, 35 ]
python
en
['en', 'error', 'th']
False
UserProfileManager.create_user
(self, email, name, password=None)
Create a new user profile
Create a new user profile
def create_user(self, email, name, password=None): """Create a new user profile""" if not email: raise ValueError('User must have an email address') email = self.normalize_email(email) user = self.model(email=email, name=name) user.set_password(password) use...
[ "def", "create_user", "(", "self", ",", "email", ",", "name", ",", "password", "=", "None", ")", ":", "if", "not", "email", ":", "raise", "ValueError", "(", "'User must have an email address'", ")", "email", "=", "self", ".", "normalize_email", "(", "email",...
[ 10, 4 ]
[ 21, 19 ]
python
en
['en', 'it', 'en']
True
UserProfileManager.create_superuser
(self, email, name, password)
Create and save a new superuser with given details
Create and save a new superuser with given details
def create_superuser(self, email, name, password): """Create and save a new superuser with given details""" user = self.create_user(email, name, password) user.is_superuser = True user.is_staff = True user.save(using=self._db) return user
[ "def", "create_superuser", "(", "self", ",", "email", ",", "name", ",", "password", ")", ":", "user", "=", "self", ".", "create_user", "(", "email", ",", "name", ",", "password", ")", "user", ".", "is_superuser", "=", "True", "user", ".", "is_staff", "...
[ 23, 4 ]
[ 31, 19 ]
python
en
['en', 'en', 'en']
True
UserProfile.get_full_name
(self)
Retrieve full name for user
Retrieve full name for user
def get_full_name(self): """Retrieve full name for user""" return self.name
[ "def", "get_full_name", "(", "self", ")", ":", "return", "self", ".", "name" ]
[ 45, 4 ]
[ 47, 24 ]
python
en
['en', 'no', 'en']
True
UserProfile.get_short_name
(self)
Retrieve short name of user
Retrieve short name of user
def get_short_name(self): """Retrieve short name of user""" return self.name
[ "def", "get_short_name", "(", "self", ")", ":", "return", "self", ".", "name" ]
[ 49, 4 ]
[ 51, 24 ]
python
en
['en', 'pt', 'en']
True
UserProfile.__str__
(self)
Return string representation of user
Return string representation of user
def __str__(self): """Return string representation of user""" return self.email
[ "def", "__str__", "(", "self", ")", ":", "return", "self", ".", "email" ]
[ 53, 4 ]
[ 55, 25 ]
python
en
['en', 'no', 'en']
True
ProfileFeedItem.__str__
(self)
Return the model as a string
Return the model as a string
def __str__(self): """Return the model as a string""" return self.status_text
[ "def", "__str__", "(", "self", ")", ":", "return", "self", ".", "status_text" ]
[ 66, 4 ]
[ 68, 31 ]
python
en
['en', 'en', 'en']
True
register_handler
(handler)
Install application-specific HDF5 image handler. :param handler: Handler object.
Install application-specific HDF5 image handler.
def register_handler(handler): """ Install application-specific HDF5 image handler. :param handler: Handler object. """ global _handler _handler = handler
[ "def", "register_handler", "(", "handler", ")", ":", "global", "_handler", "_handler", "=", "handler" ]
[ 16, 0 ]
[ 23, 22 ]
python
en
['en', 'error', 'th']
False
split_first
(s, delims)
.. deprecated:: 1.25 Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter. If not found, then the first part is the full input string. Example:: >>> split_first('foo/bar?baz', '?/=') ('foo', 'bar?baz',...
.. deprecated:: 1.25
def split_first(s, delims): """ .. deprecated:: 1.25 Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter. If not found, then the first part is the full input string. Example:: >>> split_first('foo/bar?baz'...
[ "def", "split_first", "(", "s", ",", "delims", ")", ":", "min_idx", "=", "None", "min_delim", "=", "None", "for", "d", "in", "delims", ":", "idx", "=", "s", ".", "find", "(", "d", ")", "if", "idx", "<", "0", ":", "continue", "if", "min_idx", "is"...
[ 174, 0 ]
[ 206, 51 ]
python
en
['en', 'error', 'th']
False
_encode_invalid_chars
(component, allowed_chars, encoding="utf-8")
Percent-encodes a URI component without reapplying onto an already percent-encoded component.
Percent-encodes a URI component without reapplying onto an already percent-encoded component.
def _encode_invalid_chars(component, allowed_chars, encoding="utf-8"): """Percent-encodes a URI component without reapplying onto an already percent-encoded component. """ if component is None: return component component = six.ensure_text(component) # Normalize existing percent-encoded...
[ "def", "_encode_invalid_chars", "(", "component", ",", "allowed_chars", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "component", "is", "None", ":", "return", "component", "component", "=", "six", ".", "ensure_text", "(", "component", ")", "# Normalize exi...
[ 209, 0 ]
[ 240, 45 ]
python
en
['en', 'en', 'en']
True
_encode_target
(target)
Percent-encodes a request target so that there are no invalid characters
Percent-encodes a request target so that there are no invalid characters
def _encode_target(target): """Percent-encodes a request target so that there are no invalid characters""" path, query = TARGET_RE.match(target).groups() target = _encode_invalid_chars(path, PATH_CHARS) query = _encode_invalid_chars(query, QUERY_CHARS) if query is not None: target += "?" + q...
[ "def", "_encode_target", "(", "target", ")", ":", "path", ",", "query", "=", "TARGET_RE", ".", "match", "(", "target", ")", ".", "groups", "(", ")", "target", "=", "_encode_invalid_chars", "(", "path", ",", "PATH_CHARS", ")", "query", "=", "_encode_invalid...
[ 319, 0 ]
[ 326, 17 ]
python
en
['en', 'en', 'en']
True
parse_url
(url)
Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 compliant. The parser logic and helper functions are based heavily on work done in the ``rfc3986`` module. :param str url: URL to...
Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 compliant.
def parse_url(url): """ Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 compliant. The parser logic and helper functions are based heavily on work done in the ``rfc3986`` module. ...
[ "def", "parse_url", "(", "url", ")", ":", "if", "not", "url", ":", "# Empty", "return", "Url", "(", ")", "source_url", "=", "url", "if", "not", "SCHEME_RE", ".", "search", "(", "url", ")", ":", "url", "=", "\"//\"", "+", "url", "try", ":", "scheme"...
[ 329, 0 ]
[ 423, 5 ]
python
en
['en', 'error', 'th']
False
get_host
(url)
Deprecated. Use :func:`parse_url` instead.
Deprecated. Use :func:`parse_url` instead.
def get_host(url): """ Deprecated. Use :func:`parse_url` instead. """ p = parse_url(url) return p.scheme or "http", p.hostname, p.port
[ "def", "get_host", "(", "url", ")", ":", "p", "=", "parse_url", "(", "url", ")", "return", "p", ".", "scheme", "or", "\"http\"", ",", "p", ".", "hostname", ",", "p", ".", "port" ]
[ 426, 0 ]
[ 431, 49 ]
python
en
['en', 'error', 'th']
False
Url.hostname
(self)
For backwards-compatibility with urlparse. We're nice like that.
For backwards-compatibility with urlparse. We're nice like that.
def hostname(self): """For backwards-compatibility with urlparse. We're nice like that.""" return self.host
[ "def", "hostname", "(", "self", ")", ":", "return", "self", ".", "host" ]
[ 109, 4 ]
[ 111, 24 ]
python
en
['en', 'en', 'en']
True
Url.request_uri
(self)
Absolute path including the query string.
Absolute path including the query string.
def request_uri(self): """Absolute path including the query string.""" uri = self.path or "/" if self.query is not None: uri += "?" + self.query return uri
[ "def", "request_uri", "(", "self", ")", ":", "uri", "=", "self", ".", "path", "or", "\"/\"", "if", "self", ".", "query", "is", "not", "None", ":", "uri", "+=", "\"?\"", "+", "self", ".", "query", "return", "uri" ]
[ 114, 4 ]
[ 121, 18 ]
python
en
['en', 'en', 'en']
True
Url.netloc
(self)
Network location including host and port
Network location including host and port
def netloc(self): """Network location including host and port""" if self.port: return "%s:%d" % (self.host, self.port) return self.host
[ "def", "netloc", "(", "self", ")", ":", "if", "self", ".", "port", ":", "return", "\"%s:%d\"", "%", "(", "self", ".", "host", ",", "self", ".", "port", ")", "return", "self", ".", "host" ]
[ 124, 4 ]
[ 128, 24 ]
python
en
['en', 'en', 'en']
True
Url.url
(self)
Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port will have : removed). ...
Convert self into a url
def url(self): """ Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port w...
[ "def", "url", "(", "self", ")", ":", "scheme", ",", "auth", ",", "host", ",", "port", ",", "path", ",", "query", ",", "fragment", "=", "self", "url", "=", "u\"\"", "# We use \"is not None\" we want things to happen with empty strings (or 0 port)", "if", "scheme", ...
[ 131, 4 ]
[ 168, 18 ]
python
en
['en', 'error', 'th']
False