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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
DBObject._sync_with_database | (self) | Update object attributes from the database | Update object attributes from the database | def _sync_with_database(self):
"""Update object attributes from the database"""
results = columns_from_table(self.TABLE, keywords=None,
where={self.ID: self._id})
# Shallow copy, but that's ok: all database values are
# immutable (including dat... | [
"def",
"_sync_with_database",
"(",
"self",
")",
":",
"results",
"=",
"columns_from_table",
"(",
"self",
".",
"TABLE",
",",
"keywords",
"=",
"None",
",",
"where",
"=",
"{",
"self",
".",
"ID",
":",
"self",
".",
"_id",
"}",
")",
"# Shallow copy, but that's ok... | [
258,
4
] | [
268,
27
] | python | en | ['en', 'en', 'en'] | True |
DBObject._set_data | (self, **kwargs) | Update the database with the supplied **kwargs.
Supplied keywords that do not exist in the database will lead
to a database error.
| Update the database with the supplied **kwargs. | def _set_data(self, **kwargs):
"""Update the database with the supplied **kwargs.
Supplied keywords that do not exist in the database will lead
to a database error.
"""
if not kwargs:
return
set_columns_for_table(self.TABLE, data=kwargs,
... | [
"def",
"_set_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
":",
"return",
"set_columns_for_table",
"(",
"self",
".",
"TABLE",
",",
"data",
"=",
"kwargs",
",",
"where",
"=",
"{",
"self",
".",
"ID",
":",
"self",
".",
"... | [
270,
4
] | [
281,
33
] | python | en | ['en', 'en', 'en'] | True |
DataSet.__init__ | (self, data=None, database=None, id=None) | If id is supplied, the data and image arguments are ignored. | If id is supplied, the data and image arguments are ignored. | def __init__(self, data=None, database=None, id=None):
"""If id is supplied, the data and image arguments are ignored."""
super(DataSet, self).__init__(
data=data, database=database, id=id)
self.images = set()
if not self.database:
self.database = Database()
... | [
"def",
"__init__",
"(",
"self",
",",
"data",
"=",
"None",
",",
"database",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"super",
"(",
"DataSet",
",",
"self",
")",
".",
"__init__",
"(",
"data",
"=",
"data",
",",
"database",
"=",
"database",
",",
... | [
291,
4
] | [
298,
25
] | python | en | ['en', 'en', 'en'] | True |
DataSet.id | (self) | Add or obtain an id to/from the table
| Add or obtain an id to/from the table
| def id(self):
"""Add or obtain an id to/from the table
"""
if self._id is None:
try:
self._id = insert_dataset(self._data['description'])
except Exception as e:
logger.error("ORM: error inserting dataset, %s: %s" % (type(e).__name__, str(e... | [
"def",
"id",
"(",
"self",
")",
":",
"if",
"self",
".",
"_id",
"is",
"None",
":",
"try",
":",
"self",
".",
"_id",
"=",
"insert_dataset",
"(",
"self",
".",
"_data",
"[",
"'description'",
"]",
")",
"except",
"Exception",
"as",
"e",
":",
"logger",
".",... | [
307,
4
] | [
316,
23
] | python | en | ['en', 'en', 'en'] | True |
DataSet.update_images | (self) | Renew the set of images by getting the images for this
dataset from the database. Implemented separately from update(),
since normally this would be too much overhead | Renew the set of images by getting the images for this
dataset from the database. Implemented separately from update(),
since normally this would be too much overhead | def update_images(self):
"""Renew the set of images by getting the images for this
dataset from the database. Implemented separately from update(),
since normally this would be too much overhead"""
query = "SELECT id FROM image WHERE dataset = %s ORDER BY id" % self._id
cursor = ... | [
"def",
"update_images",
"(",
"self",
")",
":",
"query",
"=",
"\"SELECT id FROM image WHERE dataset = %s ORDER BY id\"",
"%",
"self",
".",
"_id",
"cursor",
"=",
"tkp",
".",
"db",
".",
"execute",
"(",
"query",
")",
"result",
"=",
"cursor",
".",
"fetchall",
"(",
... | [
318,
4
] | [
326,
80
] | python | en | ['en', 'en', 'en'] | True |
Image.__init__ | (self, data=None, dataset=None, database=None, id=None) | If id is supplied, the data and image arguments are ignored. | If id is supplied, the data and image arguments are ignored. | def __init__(self, data=None, dataset=None, database=None, id=None):
"""If id is supplied, the data and image arguments are ignored."""
super(Image, self).__init__(data=data, database=database, id=id)
# Special part to deal when a DataSet() is supplied
self.dataset = dataset
self... | [
"def",
"__init__",
"(",
"self",
",",
"data",
"=",
"None",
",",
"dataset",
"=",
"None",
",",
"database",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"super",
"(",
"Image",
",",
"self",
")",
".",
"__init__",
"(",
"data",
"=",
"data",
",",
"datab... | [
339,
4
] | [
355,
84
] | python | en | ['en', 'en', 'en'] | True |
Image.id | (self) | Add or obtain an id to/from the table
If the ID does not exist the image is inserted into the database
| Add or obtain an id to/from the table | def id(self):
"""Add or obtain an id to/from the table
If the ID does not exist the image is inserted into the database
"""
if self._id is None:
args = self._data.copy()
# somehow _data contains a garbage kwargs
args.pop('kwargs', None)
a... | [
"def",
"id",
"(",
"self",
")",
":",
"if",
"self",
".",
"_id",
"is",
"None",
":",
"args",
"=",
"self",
".",
"_data",
".",
"copy",
"(",
")",
"# somehow _data contains a garbage kwargs",
"args",
".",
"pop",
"(",
"'kwargs'",
",",
"None",
")",
"args",
"[",
... | [
358,
4
] | [
377,
23
] | python | en | ['en', 'en', 'en'] | True |
Image.update_sources | (self) | Renew the set of sources by getting the sources for this
image from the database
This method is separately implemented, because it's not always necessary
and potentially (for an image with dozens or more sources) time & memory
consuming.
| Renew the set of sources by getting the sources for this
image from the database | def update_sources(self):
"""Renew the set of sources by getting the sources for this
image from the database
This method is separately implemented, because it's not always necessary
and potentially (for an image with dozens or more sources) time & memory
consuming.
"""
... | [
"def",
"update_sources",
"(",
"self",
")",
":",
"query",
"=",
"\"SELECT id FROM extractedsource WHERE image = %s\"",
"try",
":",
"self",
".",
"database",
".",
"cursor",
".",
"execute",
"(",
"query",
",",
"(",
"self",
".",
"_id",
",",
")",
")",
"results",
"="... | [
379,
4
] | [
399,
30
] | python | en | ['en', 'en', 'en'] | True |
ExtractedSource.__init__ | (self, data=None, image=None, database=None, id=None) | If id is supplied, the data and image arguments are ignored. | If id is supplied, the data and image arguments are ignored. | def __init__(self, data=None, image=None, database=None, id=None):
"""If id is supplied, the data and image arguments are ignored."""
super(ExtractedSource, self).__init__(
data=data, database=database, id=id)
# Special part to deal when an Image() is supplied
self.image = im... | [
"def",
"__init__",
"(",
"self",
",",
"data",
"=",
"None",
",",
"image",
"=",
"None",
",",
"database",
"=",
"None",
",",
"id",
"=",
"None",
")",
":",
"super",
"(",
"ExtractedSource",
",",
"self",
")",
".",
"__init__",
"(",
"data",
"=",
"data",
",",
... | [
415,
4
] | [
429,
25
] | python | en | ['en', 'en', 'en'] | True |
add_consensus_thickness | (gdir, base_url=None) | Add the consensus thickness estimate to the gridded_data file.
varname: consensus_ice_thickness
Parameters
----------
gdir ::py:class:`oggm.GlacierDirectory`
the glacier directory to process
base_url : str
where to find the thickness data. Default is
https://cluster.klima.u... | Add the consensus thickness estimate to the gridded_data file. | def add_consensus_thickness(gdir, base_url=None):
"""Add the consensus thickness estimate to the gridded_data file.
varname: consensus_ice_thickness
Parameters
----------
gdir ::py:class:`oggm.GlacierDirectory`
the glacier directory to process
base_url : str
where to find the t... | [
"def",
"add_consensus_thickness",
"(",
"gdir",
",",
"base_url",
"=",
"None",
")",
":",
"if",
"base_url",
"is",
"None",
":",
"base_url",
"=",
"default_base_url",
"if",
"not",
"base_url",
".",
"endswith",
"(",
"'/'",
")",
":",
"base_url",
"+=",
"'/'",
"rgi_s... | [
18,
0
] | [
69,
20
] | python | en | ['en', 'en', 'en'] | True |
_hash_of_file | (path, algorithm) | Return the hash digest of a file. | Return the hash digest of a file. | def _hash_of_file(path, algorithm):
# type: (str, str) -> str
"""Return the hash digest of a file."""
with open(path, 'rb') as archive:
hash = hashlib.new(algorithm)
for chunk in read_chunks(archive):
hash.update(chunk)
return hash.hexdigest() | [
"def",
"_hash_of_file",
"(",
"path",
",",
"algorithm",
")",
":",
"# type: (str, str) -> str",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"archive",
":",
"hash",
"=",
"hashlib",
".",
"new",
"(",
"algorithm",
")",
"for",
"chunk",
"in",
"read_chunks... | [
55,
0
] | [
62,
27
] | python | en | ['en', 'en', 'en'] | True |
TestPotIterations.test_win_percentage | (self) |
Tests that the percentage of blocks won is proportional to the space of each farmer,
with the assumption that all farmers have access to the same VDF speed.
|
Tests that the percentage of blocks won is proportional to the space of each farmer,
with the assumption that all farmers have access to the same VDF speed.
| def test_win_percentage(self):
"""
Tests that the percentage of blocks won is proportional to the space of each farmer,
with the assumption that all farmers have access to the same VDF speed.
"""
farmer_ks = {
uint8(32): 100,
uint8(33): 100,
ui... | [
"def",
"test_win_percentage",
"(",
"self",
")",
":",
"farmer_ks",
"=",
"{",
"uint8",
"(",
"32",
")",
":",
"100",
",",
"uint8",
"(",
"33",
")",
":",
"100",
",",
"uint8",
"(",
"34",
")",
":",
"100",
",",
"uint8",
"(",
"35",
")",
":",
"100",
",",
... | [
78,
4
] | [
114,
70
] | python | en | ['en', 'error', 'th'] | False |
fix_help_options | (options) | Convert a 4-tuple 'help_options' list as found in various command
classes to the 3-tuple form required by FancyGetopt.
| Convert a 4-tuple 'help_options' list as found in various command
classes to the 3-tuple form required by FancyGetopt.
| def fix_help_options(options):
"""Convert a 4-tuple 'help_options' list as found in various command
classes to the 3-tuple form required by FancyGetopt.
"""
new_options = []
for help_tuple in options:
new_options.append(help_tuple[0:3])
return new_options | [
"def",
"fix_help_options",
"(",
"options",
")",
":",
"new_options",
"=",
"[",
"]",
"for",
"help_tuple",
"in",
"options",
":",
"new_options",
".",
"append",
"(",
"help_tuple",
"[",
"0",
":",
"3",
"]",
")",
"return",
"new_options"
] | [
1249,
0
] | [
1256,
22
] | python | en | ['en', 'en', 'en'] | True |
Distribution.__init__ | (self, attrs=None) | Construct a new Distribution instance: initialize all the
attributes of a Distribution, and then use 'attrs' (a dictionary
mapping attribute names to values) to assign some of those
attributes their "real" values. (Any attributes not mentioned in
'attrs' will be assigned to some null va... | Construct a new Distribution instance: initialize all the
attributes of a Distribution, and then use 'attrs' (a dictionary
mapping attribute names to values) to assign some of those
attributes their "real" values. (Any attributes not mentioned in
'attrs' will be assigned to some null va... | def __init__(self, attrs=None):
"""Construct a new Distribution instance: initialize all the
attributes of a Distribution, and then use 'attrs' (a dictionary
mapping attribute names to values) to assign some of those
attributes their "real" values. (Any attributes not mentioned in
... | [
"def",
"__init__",
"(",
"self",
",",
"attrs",
"=",
"None",
")",
":",
"# Default values for our command-line options",
"self",
".",
"verbose",
"=",
"1",
"self",
".",
"dry_run",
"=",
"0",
"self",
".",
"help",
"=",
"0",
"for",
"attr",
"in",
"self",
".",
"di... | [
136,
4
] | [
292,
31
] | python | en | ['en', 'en', 'en'] | True |
Distribution.get_option_dict | (self, command) | Get the option dictionary for a given command. If that
command's option dictionary hasn't been created yet, then create it
and return the new dictionary; otherwise, return the existing
option dictionary.
| Get the option dictionary for a given command. If that
command's option dictionary hasn't been created yet, then create it
and return the new dictionary; otherwise, return the existing
option dictionary.
| def get_option_dict(self, command):
"""Get the option dictionary for a given command. If that
command's option dictionary hasn't been created yet, then create it
and return the new dictionary; otherwise, return the existing
option dictionary.
"""
dict = self.command_opti... | [
"def",
"get_option_dict",
"(",
"self",
",",
"command",
")",
":",
"dict",
"=",
"self",
".",
"command_options",
".",
"get",
"(",
"command",
")",
"if",
"dict",
"is",
"None",
":",
"dict",
"=",
"self",
".",
"command_options",
"[",
"command",
"]",
"=",
"{",
... | [
294,
4
] | [
303,
19
] | python | en | ['en', 'en', 'en'] | True |
Distribution.find_config_files | (self) | Find as many configuration files as should be processed for this
platform, and return a list of filenames in the order in which they
should be parsed. The filenames returned are guaranteed to exist
(modulo nasty race conditions).
There are three possible config files: distutils.cfg in ... | Find as many configuration files as should be processed for this
platform, and return a list of filenames in the order in which they
should be parsed. The filenames returned are guaranteed to exist
(modulo nasty race conditions). | def find_config_files(self):
"""Find as many configuration files as should be processed for this
platform, and return a list of filenames in the order in which they
should be parsed. The filenames returned are guaranteed to exist
(modulo nasty race conditions).
There are three ... | [
"def",
"find_config_files",
"(",
"self",
")",
":",
"files",
"=",
"[",
"]",
"check_environ",
"(",
")",
"# Where to look for the system-wide Distutils config file",
"sys_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"sys",
".",
"modules",
"[",
"'distutils'",
... | [
333,
4
] | [
379,
20
] | python | en | ['en', 'en', 'en'] | True |
Distribution.parse_command_line | (self) | Parse the setup script's command line, taken from the
'script_args' instance attribute (which defaults to 'sys.argv[1:]'
-- see 'setup()' in core.py). This list is first processed for
"global options" -- options that set attributes of the Distribution
instance. Then, it is alternately ... | Parse the setup script's command line, taken from the
'script_args' instance attribute (which defaults to 'sys.argv[1:]'
-- see 'setup()' in core.py). This list is first processed for
"global options" -- options that set attributes of the Distribution
instance. Then, it is alternately ... | def parse_command_line(self):
"""Parse the setup script's command line, taken from the
'script_args' instance attribute (which defaults to 'sys.argv[1:]'
-- see 'setup()' in core.py). This list is first processed for
"global options" -- options that set attributes of the Distribution
... | [
"def",
"parse_command_line",
"(",
"self",
")",
":",
"#",
"# We now have enough information to show the Macintosh dialog",
"# that allows the user to interactively specify the \"command line\".",
"#",
"toplevel_options",
"=",
"self",
".",
"_get_toplevel_options",
"(",
")",
"# We hav... | [
439,
4
] | [
504,
19
] | python | en | ['en', 'en', 'en'] | True |
Distribution._get_toplevel_options | (self) | Return the non-display options recognized at the top level.
This includes options that are recognized *only* at the top
level as well as options recognized for commands.
| Return the non-display options recognized at the top level. | def _get_toplevel_options(self):
"""Return the non-display options recognized at the top level.
This includes options that are recognized *only* at the top
level as well as options recognized for commands.
"""
return self.global_options + [
("command-packages=", None... | [
"def",
"_get_toplevel_options",
"(",
"self",
")",
":",
"return",
"self",
".",
"global_options",
"+",
"[",
"(",
"\"command-packages=\"",
",",
"None",
",",
"\"list of packages that provide distutils commands\"",
")",
",",
"]"
] | [
506,
4
] | [
515,
13
] | python | en | ['en', 'en', 'en'] | True |
Distribution._parse_command_opts | (self, parser, args) | Parse the command-line options for a single command.
'parser' must be a FancyGetopt instance; 'args' must be the list
of arguments, starting with the current command (whose options
we are about to parse). Returns a new version of 'args' with
the next command at the front of the list; wi... | Parse the command-line options for a single command.
'parser' must be a FancyGetopt instance; 'args' must be the list
of arguments, starting with the current command (whose options
we are about to parse). Returns a new version of 'args' with
the next command at the front of the list; wi... | def _parse_command_opts(self, parser, args):
"""Parse the command-line options for a single command.
'parser' must be a FancyGetopt instance; 'args' must be the list
of arguments, starting with the current command (whose options
we are about to parse). Returns a new version of 'args' wi... | [
"def",
"_parse_command_opts",
"(",
"self",
",",
"parser",
",",
"args",
")",
":",
"# late import because of mutual dependence between these modules",
"from",
"distutils",
".",
"cmd",
"import",
"Command",
"# Pull the current command from the head of the command line",
"command",
... | [
517,
4
] | [
606,
19
] | python | en | ['en', 'en', 'en'] | True |
Distribution.finalize_options | (self) | Set final values for all the options on the Distribution
instance, analogous to the .finalize_options() method of Command
objects.
| Set final values for all the options on the Distribution
instance, analogous to the .finalize_options() method of Command
objects.
| def finalize_options(self):
"""Set final values for all the options on the Distribution
instance, analogous to the .finalize_options() method of Command
objects.
"""
for attr in ('keywords', 'platforms'):
value = getattr(self.metadata, attr)
if value is No... | [
"def",
"finalize_options",
"(",
"self",
")",
":",
"for",
"attr",
"in",
"(",
"'keywords'",
",",
"'platforms'",
")",
":",
"value",
"=",
"getattr",
"(",
"self",
".",
"metadata",
",",
"attr",
")",
"if",
"value",
"is",
"None",
":",
"continue",
"if",
"isinst... | [
608,
4
] | [
619,
51
] | python | en | ['en', 'en', 'en'] | True |
Distribution._show_help | (self, parser, global_options=1, display_options=1,
commands=[]) | Show help for the setup script command-line in the form of
several lists of command-line options. 'parser' should be a
FancyGetopt instance; do not expect it to be returned in the
same state, as its option table will be reset to make it
generate the correct help text.
If 'globa... | Show help for the setup script command-line in the form of
several lists of command-line options. 'parser' should be a
FancyGetopt instance; do not expect it to be returned in the
same state, as its option table will be reset to make it
generate the correct help text. | def _show_help(self, parser, global_options=1, display_options=1,
commands=[]):
"""Show help for the setup script command-line in the form of
several lists of command-line options. 'parser' should be a
FancyGetopt instance; do not expect it to be returned in the
same ... | [
"def",
"_show_help",
"(",
"self",
",",
"parser",
",",
"global_options",
"=",
"1",
",",
"display_options",
"=",
"1",
",",
"commands",
"=",
"[",
"]",
")",
":",
"# late import because of mutual dependence between these modules",
"from",
"distutils",
".",
"core",
"imp... | [
621,
4
] | [
669,
42
] | python | en | ['en', 'en', 'en'] | True |
Distribution.handle_display_options | (self, option_order) | If there were any non-global "display-only" options
(--help-commands or the metadata display options) on the command
line, display the requested info and return true; else return
false.
| If there were any non-global "display-only" options
(--help-commands or the metadata display options) on the command
line, display the requested info and return true; else return
false.
| def handle_display_options(self, option_order):
"""If there were any non-global "display-only" options
(--help-commands or the metadata display options) on the command
line, display the requested info and return true; else return
false.
"""
from distutils.core import gen_... | [
"def",
"handle_display_options",
"(",
"self",
",",
"option_order",
")",
":",
"from",
"distutils",
".",
"core",
"import",
"gen_usage",
"# User just wants a list of commands -- we'll print it out and stop",
"# processing now (ie. if they ran \"setup --help-commands foo bar\",",
"# we i... | [
671,
4
] | [
709,
34
] | python | en | ['en', 'en', 'en'] | True |
Distribution.print_command_list | (self, commands, header, max_length) | Print a subset of the list of all commands -- used by
'print_commands()'.
| Print a subset of the list of all commands -- used by
'print_commands()'.
| def print_command_list(self, commands, header, max_length):
"""Print a subset of the list of all commands -- used by
'print_commands()'.
"""
print(header + ":")
for cmd in commands:
klass = self.cmdclass.get(cmd)
if not klass:
klass = self... | [
"def",
"print_command_list",
"(",
"self",
",",
"commands",
",",
"header",
",",
"max_length",
")",
":",
"print",
"(",
"header",
"+",
"\":\"",
")",
"for",
"cmd",
"in",
"commands",
":",
"klass",
"=",
"self",
".",
"cmdclass",
".",
"get",
"(",
"cmd",
")",
... | [
711,
4
] | [
726,
64
] | python | en | ['en', 'en', 'en'] | True |
Distribution.print_commands | (self) | Print out a help message listing all available commands with a
description of each. The list is divided into "standard commands"
(listed in distutils.command.__all__) and "extra commands"
(mentioned in self.cmdclass, but not a standard command). The
descriptions come from the command c... | Print out a help message listing all available commands with a
description of each. The list is divided into "standard commands"
(listed in distutils.command.__all__) and "extra commands"
(mentioned in self.cmdclass, but not a standard command). The
descriptions come from the command c... | def print_commands(self):
"""Print out a help message listing all available commands with a
description of each. The list is divided into "standard commands"
(listed in distutils.command.__all__) and "extra commands"
(mentioned in self.cmdclass, but not a standard command). The
... | [
"def",
"print_commands",
"(",
"self",
")",
":",
"import",
"distutils",
".",
"command",
"std_commands",
"=",
"distutils",
".",
"command",
".",
"__all__",
"is_std",
"=",
"{",
"}",
"for",
"cmd",
"in",
"std_commands",
":",
"is_std",
"[",
"cmd",
"]",
"=",
"1"... | [
728,
4
] | [
759,
47
] | python | en | ['en', 'en', 'en'] | True |
Distribution.get_command_list | (self) | Get a list of (command, description) tuples.
The list is divided into "standard commands" (listed in
distutils.command.__all__) and "extra commands" (mentioned in
self.cmdclass, but not a standard command). The descriptions come
from the command class attribute 'description'.
| Get a list of (command, description) tuples.
The list is divided into "standard commands" (listed in
distutils.command.__all__) and "extra commands" (mentioned in
self.cmdclass, but not a standard command). The descriptions come
from the command class attribute 'description'.
| def get_command_list(self):
"""Get a list of (command, description) tuples.
The list is divided into "standard commands" (listed in
distutils.command.__all__) and "extra commands" (mentioned in
self.cmdclass, but not a standard command). The descriptions come
from the command cl... | [
"def",
"get_command_list",
"(",
"self",
")",
":",
"# Currently this is only used on Mac OS, for the Mac-only GUI",
"# Distutils interface (by Jack Jansen)",
"import",
"distutils",
".",
"command",
"std_commands",
"=",
"distutils",
".",
"command",
".",
"__all__",
"is_std",
"=",... | [
761,
4
] | [
791,
17
] | python | en | ['en', 'fr', 'en'] | True |
Distribution.get_command_packages | (self) | Return a list of packages from which commands are loaded. | Return a list of packages from which commands are loaded. | def get_command_packages(self):
"""Return a list of packages from which commands are loaded."""
pkgs = self.command_packages
if not isinstance(pkgs, list):
if pkgs is None:
pkgs = ''
pkgs = [pkg.strip() for pkg in pkgs.split(',') if pkg != '']
... | [
"def",
"get_command_packages",
"(",
"self",
")",
":",
"pkgs",
"=",
"self",
".",
"command_packages",
"if",
"not",
"isinstance",
"(",
"pkgs",
",",
"list",
")",
":",
"if",
"pkgs",
"is",
"None",
":",
"pkgs",
"=",
"''",
"pkgs",
"=",
"[",
"pkg",
".",
"stri... | [
795,
4
] | [
805,
19
] | python | en | ['en', 'en', 'en'] | True |
Distribution.get_command_class | (self, command) | Return the class that implements the Distutils command named by
'command'. First we check the 'cmdclass' dictionary; if the
command is mentioned there, we fetch the class object from the
dictionary and return it. Otherwise we load the command module
("distutils.command." + command) and... | Return the class that implements the Distutils command named by
'command'. First we check the 'cmdclass' dictionary; if the
command is mentioned there, we fetch the class object from the
dictionary and return it. Otherwise we load the command module
("distutils.command." + command) and... | def get_command_class(self, command):
"""Return the class that implements the Distutils command named by
'command'. First we check the 'cmdclass' dictionary; if the
command is mentioned there, we fetch the class object from the
dictionary and return it. Otherwise we load the command mo... | [
"def",
"get_command_class",
"(",
"self",
",",
"command",
")",
":",
"klass",
"=",
"self",
".",
"cmdclass",
".",
"get",
"(",
"command",
")",
"if",
"klass",
":",
"return",
"klass",
"for",
"pkgname",
"in",
"self",
".",
"get_command_packages",
"(",
")",
":",
... | [
807,
4
] | [
843,
68
] | python | en | ['en', 'en', 'en'] | True |
Distribution.get_command_obj | (self, command, create=1) | Return the command object for 'command'. Normally this object
is cached on a previous call to 'get_command_obj()'; if no command
object for 'command' is in the cache, then we either create and
return it (if 'create' is true) or return None.
| Return the command object for 'command'. Normally this object
is cached on a previous call to 'get_command_obj()'; if no command
object for 'command' is in the cache, then we either create and
return it (if 'create' is true) or return None.
| def get_command_obj(self, command, create=1):
"""Return the command object for 'command'. Normally this object
is cached on a previous call to 'get_command_obj()'; if no command
object for 'command' is in the cache, then we either create and
return it (if 'create' is true) or return Non... | [
"def",
"get_command_obj",
"(",
"self",
",",
"command",
",",
"create",
"=",
"1",
")",
":",
"cmd_obj",
"=",
"self",
".",
"command_obj",
".",
"get",
"(",
"command",
")",
"if",
"not",
"cmd_obj",
"and",
"create",
":",
"if",
"DEBUG",
":",
"self",
".",
"ann... | [
845,
4
] | [
870,
22
] | python | en | ['en', 'en', 'en'] | True |
Distribution._set_command_options | (self, command_obj, option_dict=None) | Set the options for 'command_obj' from 'option_dict'. Basically
this means copying elements of a dictionary ('option_dict') to
attributes of an instance ('command').
'command_obj' must be a Command instance. If 'option_dict' is not
supplied, uses the standard option dictionary for thi... | Set the options for 'command_obj' from 'option_dict'. Basically
this means copying elements of a dictionary ('option_dict') to
attributes of an instance ('command'). | def _set_command_options(self, command_obj, option_dict=None):
"""Set the options for 'command_obj' from 'option_dict'. Basically
this means copying elements of a dictionary ('option_dict') to
attributes of an instance ('command').
'command_obj' must be a Command instance. If 'option_... | [
"def",
"_set_command_options",
"(",
"self",
",",
"command_obj",
",",
"option_dict",
"=",
"None",
")",
":",
"command_name",
"=",
"command_obj",
".",
"get_command_name",
"(",
")",
"if",
"option_dict",
"is",
"None",
":",
"option_dict",
"=",
"self",
".",
"get_opti... | [
872,
4
] | [
914,
47
] | python | en | ['en', 'en', 'en'] | True |
Distribution.reinitialize_command | (self, command, reinit_subcommands=0) | Reinitializes a command to the state it was in when first
returned by 'get_command_obj()': ie., initialized but not yet
finalized. This provides the opportunity to sneak option
values in programmatically, overriding or supplementing
user-supplied values from the config files and command... | Reinitializes a command to the state it was in when first
returned by 'get_command_obj()': ie., initialized but not yet
finalized. This provides the opportunity to sneak option
values in programmatically, overriding or supplementing
user-supplied values from the config files and command... | def reinitialize_command(self, command, reinit_subcommands=0):
"""Reinitializes a command to the state it was in when first
returned by 'get_command_obj()': ie., initialized but not yet
finalized. This provides the opportunity to sneak option
values in programmatically, overriding or su... | [
"def",
"reinitialize_command",
"(",
"self",
",",
"command",
",",
"reinit_subcommands",
"=",
"0",
")",
":",
"from",
"distutils",
".",
"cmd",
"import",
"Command",
"if",
"not",
"isinstance",
"(",
"command",
",",
"Command",
")",
":",
"command_name",
"=",
"comman... | [
916,
4
] | [
953,
22
] | python | en | ['en', 'en', 'en'] | True |
Distribution.run_commands | (self) | Run each command that was seen on the setup script command line.
Uses the list of commands found and cache of command objects
created by 'get_command_obj()'.
| Run each command that was seen on the setup script command line.
Uses the list of commands found and cache of command objects
created by 'get_command_obj()'.
| def run_commands(self):
"""Run each command that was seen on the setup script command line.
Uses the list of commands found and cache of command objects
created by 'get_command_obj()'.
"""
for cmd in self.commands:
self.run_command(cmd) | [
"def",
"run_commands",
"(",
"self",
")",
":",
"for",
"cmd",
"in",
"self",
".",
"commands",
":",
"self",
".",
"run_command",
"(",
"cmd",
")"
] | [
960,
4
] | [
966,
33
] | python | en | ['en', 'en', 'en'] | True |
Distribution.run_command | (self, command) | Do whatever it takes to run a command (including nothing at all,
if the command has already been run). Specifically: if we have
already created and run the command named by 'command', return
silently without doing anything. If the command named by 'command'
doesn't even have a command ... | Do whatever it takes to run a command (including nothing at all,
if the command has already been run). Specifically: if we have
already created and run the command named by 'command', return
silently without doing anything. If the command named by 'command'
doesn't even have a command ... | def run_command(self, command):
"""Do whatever it takes to run a command (including nothing at all,
if the command has already been run). Specifically: if we have
already created and run the command named by 'command', return
silently without doing anything. If the command named by 'co... | [
"def",
"run_command",
"(",
"self",
",",
"command",
")",
":",
"# Already been here, done that? then return silently.",
"if",
"self",
".",
"have_run",
".",
"get",
"(",
"command",
")",
":",
"return",
"log",
".",
"info",
"(",
"\"running %s\"",
",",
"command",
")",
... | [
970,
4
] | [
986,
34
] | python | en | ['en', 'en', 'en'] | True |
DistributionMetadata.read_pkg_file | (self, file) | Reads the metadata values from a file object. | Reads the metadata values from a file object. | def read_pkg_file(self, file):
"""Reads the metadata values from a file object."""
msg = message_from_file(file)
def _read_field(name):
value = msg[name]
if value == 'UNKNOWN':
return None
return value
def _read_list(name):
... | [
"def",
"read_pkg_file",
"(",
"self",
",",
"file",
")",
":",
"msg",
"=",
"message_from_file",
"(",
"file",
")",
"def",
"_read_field",
"(",
"name",
")",
":",
"value",
"=",
"msg",
"[",
"name",
"]",
"if",
"value",
"==",
"'UNKNOWN'",
":",
"return",
"None",
... | [
1060,
4
] | [
1110,
33
] | python | en | ['en', 'en', 'en'] | True |
DistributionMetadata.write_pkg_info | (self, base_dir) | Write the PKG-INFO file into the release tree.
| Write the PKG-INFO file into the release tree.
| def write_pkg_info(self, base_dir):
"""Write the PKG-INFO file into the release tree.
"""
with open(os.path.join(base_dir, 'PKG-INFO'), 'w',
encoding='UTF-8') as pkg_info:
self.write_pkg_file(pkg_info) | [
"def",
"write_pkg_info",
"(",
"self",
",",
"base_dir",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"base_dir",
",",
"'PKG-INFO'",
")",
",",
"'w'",
",",
"encoding",
"=",
"'UTF-8'",
")",
"as",
"pkg_info",
":",
"self",
".",
"writ... | [
1112,
4
] | [
1117,
41
] | python | en | ['en', 'en', 'en'] | True |
DistributionMetadata.write_pkg_file | (self, file) | Write the PKG-INFO format data to a file object.
| Write the PKG-INFO format data to a file object.
| def write_pkg_file(self, file):
"""Write the PKG-INFO format data to a file object.
"""
version = '1.0'
if (self.provides or self.requires or self.obsoletes or
self.classifiers or self.download_url):
version = '1.1'
file.write('Metadata-Version: %s\n'... | [
"def",
"write_pkg_file",
"(",
"self",
",",
"file",
")",
":",
"version",
"=",
"'1.0'",
"if",
"(",
"self",
".",
"provides",
"or",
"self",
".",
"requires",
"or",
"self",
".",
"obsoletes",
"or",
"self",
".",
"classifiers",
"or",
"self",
".",
"download_url",
... | [
1119,
4
] | [
1151,
65
] | python | en | ['en', 'en', 'en'] | True |
requires_to_requires_dist | (requirement) | Return the version specifier for a requirement in PEP 345/566 fashion. | Return the version specifier for a requirement in PEP 345/566 fashion. | def requires_to_requires_dist(requirement):
"""Return the version specifier for a requirement in PEP 345/566 fashion."""
if getattr(requirement, 'url', None):
return " @ " + requirement.url
requires_dist = []
for op, ver in requirement.specs:
requires_dist.append(op + ver)
if not re... | [
"def",
"requires_to_requires_dist",
"(",
"requirement",
")",
":",
"if",
"getattr",
"(",
"requirement",
",",
"'url'",
",",
"None",
")",
":",
"return",
"\" @ \"",
"+",
"requirement",
".",
"url",
"requires_dist",
"=",
"[",
"]",
"for",
"op",
",",
"ver",
"in",
... | [
12,
0
] | [
22,
52
] | python | en | ['en', 'en', 'en'] | True |
convert_requirements | (requirements) | Yield Requires-Dist: strings for parsed requirements strings. | Yield Requires-Dist: strings for parsed requirements strings. | def convert_requirements(requirements):
"""Yield Requires-Dist: strings for parsed requirements strings."""
for req in requirements:
parsed_requirement = pkg_resources.Requirement.parse(req)
spec = requires_to_requires_dist(parsed_requirement)
extras = ",".join(sorted(parsed_requirement.... | [
"def",
"convert_requirements",
"(",
"requirements",
")",
":",
"for",
"req",
"in",
"requirements",
":",
"parsed_requirement",
"=",
"pkg_resources",
".",
"Requirement",
".",
"parse",
"(",
"req",
")",
"spec",
"=",
"requires_to_requires_dist",
"(",
"parsed_requirement",... | [
25,
0
] | [
33,
63
] | python | en | ['en', 'en', 'en'] | True |
generate_requirements | (extras_require) |
Convert requirements from a setup()-style dictionary to ('Requires-Dist', 'requirement')
and ('Provides-Extra', 'extra') tuples.
extras_require is a dictionary of {extra: [requirements]} as passed to setup(),
using the empty extra {'': [requirements]} to hold install_requires.
|
Convert requirements from a setup()-style dictionary to ('Requires-Dist', 'requirement')
and ('Provides-Extra', 'extra') tuples. | def generate_requirements(extras_require):
"""
Convert requirements from a setup()-style dictionary to ('Requires-Dist', 'requirement')
and ('Provides-Extra', 'extra') tuples.
extras_require is a dictionary of {extra: [requirements]} as passed to setup(),
using the empty extra {'': [requirements]} ... | [
"def",
"generate_requirements",
"(",
"extras_require",
")",
":",
"for",
"extra",
",",
"depends",
"in",
"extras_require",
".",
"items",
"(",
")",
":",
"condition",
"=",
"''",
"extra",
"=",
"extra",
"or",
"''",
"if",
"':'",
"in",
"extra",
":",
"# setuptools ... | [
36,
0
] | [
61,
54
] | python | en | ['en', 'error', 'th'] | False |
pkginfo_to_metadata | (egg_info_path, pkginfo_path) |
Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
|
Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
| def pkginfo_to_metadata(egg_info_path, pkginfo_path):
"""
Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format
"""
pkg_info = read_pkg_info(pkginfo_path)
pkg_info.replace_header('Metadata-Version', '2.1')
# Those will be regenerated from `requires.txt`.
del pkg_info['Provides... | [
"def",
"pkginfo_to_metadata",
"(",
"egg_info_path",
",",
"pkginfo_path",
")",
":",
"pkg_info",
"=",
"read_pkg_info",
"(",
"pkginfo_path",
")",
"pkg_info",
".",
"replace_header",
"(",
"'Metadata-Version'",
",",
"'2.1'",
")",
"# Those will be regenerated from `requires.txt`... | [
64,
0
] | [
90,
19
] | python | en | ['en', 'error', 'th'] | False |
pkginfo_unicode | (pkg_info, field) | Hack to coax Unicode out of an email Message() - Python 3.3+ | Hack to coax Unicode out of an email Message() - Python 3.3+ | def pkginfo_unicode(pkg_info, field):
"""Hack to coax Unicode out of an email Message() - Python 3.3+"""
text = pkg_info[field]
field = field.lower()
if not isinstance(text, str):
for item in pkg_info.raw_items():
if item[0].lower() == field:
text = item[1].encode('as... | [
"def",
"pkginfo_unicode",
"(",
"pkg_info",
",",
"field",
")",
":",
"text",
"=",
"pkg_info",
"[",
"field",
"]",
"field",
"=",
"field",
".",
"lower",
"(",
")",
"if",
"not",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"for",
"item",
"in",
"pkg_info... | [
93,
0
] | [
104,
15
] | python | en | ['en', 'en', 'en'] | True |
dedent_description | (pkg_info) |
Dedent and convert pkg_info['Description'] to Unicode.
|
Dedent and convert pkg_info['Description'] to Unicode.
| def dedent_description(pkg_info):
"""
Dedent and convert pkg_info['Description'] to Unicode.
"""
description = pkg_info['Description']
# Python 3 Unicode handling, sorta.
surrogates = False
if not isinstance(description, str):
surrogates = True
description = pkginfo_unicode(... | [
"def",
"dedent_description",
"(",
"pkg_info",
")",
":",
"description",
"=",
"pkg_info",
"[",
"'Description'",
"]",
"# Python 3 Unicode handling, sorta.",
"surrogates",
"=",
"False",
"if",
"not",
"isinstance",
"(",
"description",
",",
"str",
")",
":",
"surrogates",
... | [
107,
0
] | [
132,
29
] | python | en | ['en', 'error', 'th'] | False |
salted_hmac | (key_salt, value, secret=None) |
Returns the HMAC-SHA1 of 'value', using a key generated from key_salt and a
secret (which defaults to settings.SECRET_KEY).
A different key_salt should be passed in for every application of HMAC.
|
Returns the HMAC-SHA1 of 'value', using a key generated from key_salt and a
secret (which defaults to settings.SECRET_KEY). | def salted_hmac(key_salt, value, secret=None):
"""
Returns the HMAC-SHA1 of 'value', using a key generated from key_salt and a
secret (which defaults to settings.SECRET_KEY).
A different key_salt should be passed in for every application of HMAC.
"""
if secret is None:
secret = settings... | [
"def",
"salted_hmac",
"(",
"key_salt",
",",
"value",
",",
"secret",
"=",
"None",
")",
":",
"if",
"secret",
"is",
"None",
":",
"secret",
"=",
"settings",
".",
"SECRET_KEY",
"key_salt",
"=",
"force_bytes",
"(",
"key_salt",
")",
"secret",
"=",
"force_bytes",
... | [
28,
0
] | [
50,
72
] | python | en | ['en', 'error', 'th'] | False |
get_random_string | (length=12,
allowed_chars='abcdefghijklmnopqrstuvwxyz'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') |
Returns a securely generated random string.
The default length of 12 with the a-z, A-Z, 0-9 character set returns
a 71-bit value. log_2((26+26+10)^12) =~ 71 bits
|
Returns a securely generated random string. | def get_random_string(length=12,
allowed_chars='abcdefghijklmnopqrstuvwxyz'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'):
"""
Returns a securely generated random string.
The default length of 12 with the a-z, A-Z, 0-9 character set returns
a 71-bit v... | [
"def",
"get_random_string",
"(",
"length",
"=",
"12",
",",
"allowed_chars",
"=",
"'abcdefghijklmnopqrstuvwxyz'",
"'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'",
")",
":",
"if",
"not",
"using_sysrandom",
":",
"# This is ugly, and a hack, but it makes things better than",
"# the alternat... | [
53,
0
] | [
76,
71
] | python | en | ['en', 'error', 'th'] | False |
_bin_to_long | (x) |
Convert a binary string into a long integer
This is a clever optimization for fast xor vector math
|
Convert a binary string into a long integer | def _bin_to_long(x):
"""
Convert a binary string into a long integer
This is a clever optimization for fast xor vector math
"""
return int(binascii.hexlify(x), 16) | [
"def",
"_bin_to_long",
"(",
"x",
")",
":",
"return",
"int",
"(",
"binascii",
".",
"hexlify",
"(",
"x",
")",
",",
"16",
")"
] | [
107,
0
] | [
113,
39
] | python | en | ['en', 'error', 'th'] | False |
_long_to_bin | (x, hex_format_string) |
Convert a long integer into a binary string.
hex_format_string is like "%020x" for padding 10 characters.
|
Convert a long integer into a binary string.
hex_format_string is like "%020x" for padding 10 characters.
| def _long_to_bin(x, hex_format_string):
"""
Convert a long integer into a binary string.
hex_format_string is like "%020x" for padding 10 characters.
"""
return binascii.unhexlify((hex_format_string % x).encode('ascii')) | [
"def",
"_long_to_bin",
"(",
"x",
",",
"hex_format_string",
")",
":",
"return",
"binascii",
".",
"unhexlify",
"(",
"(",
"hex_format_string",
"%",
"x",
")",
".",
"encode",
"(",
"'ascii'",
")",
")"
] | [
116,
0
] | [
121,
70
] | python | en | ['en', 'error', 'th'] | False |
create_block_generator | (
generator: SerializedProgram, block_heights_list: List[uint32], generator_block_cache: GeneratorBlockCacheInterface
) | `create_block_generator` will returns None if it fails to look up any referenced block | `create_block_generator` will returns None if it fails to look up any referenced block | def create_block_generator(
generator: SerializedProgram, block_heights_list: List[uint32], generator_block_cache: GeneratorBlockCacheInterface
) -> Optional[BlockGenerator]:
""" `create_block_generator` will returns None if it fails to look up any referenced block """
generator_arg_list: List[GeneratorArg]... | [
"def",
"create_block_generator",
"(",
"generator",
":",
"SerializedProgram",
",",
"block_heights_list",
":",
"List",
"[",
"uint32",
"]",
",",
"generator_block_cache",
":",
"GeneratorBlockCacheInterface",
")",
"->",
"Optional",
"[",
"BlockGenerator",
"]",
":",
"generat... | [
20,
0
] | [
31,
56
] | python | en | ['en', 'en', 'en'] | True |
create_generator_args | (generator_ref_list: List[SerializedProgram]) |
`create_generator_args`: The format and contents of these arguments affect consensus.
|
`create_generator_args`: The format and contents of these arguments affect consensus.
| def create_generator_args(generator_ref_list: List[SerializedProgram]) -> Program:
"""
`create_generator_args`: The format and contents of these arguments affect consensus.
"""
gen_ref_list = [bytes(g) for g in generator_ref_list]
return Program.to([gen_ref_list]) | [
"def",
"create_generator_args",
"(",
"generator_ref_list",
":",
"List",
"[",
"SerializedProgram",
"]",
")",
"->",
"Program",
":",
"gen_ref_list",
"=",
"[",
"bytes",
"(",
"g",
")",
"for",
"g",
"in",
"generator_ref_list",
"]",
"return",
"Program",
".",
"to",
"... | [
34,
0
] | [
39,
37
] | python | en | ['en', 'error', 'th'] | False |
create_compressed_generator | (
original_generator: CompressorArg,
compressed_cse_list: List[List[Union[List[uint64], List[Union[bytes, None, Program]]]]],
) |
Bind the generator block program template to a particular reference block,
template bytes offsets, and SpendBundle.
|
Bind the generator block program template to a particular reference block,
template bytes offsets, and SpendBundle.
| def create_compressed_generator(
original_generator: CompressorArg,
compressed_cse_list: List[List[Union[List[uint64], List[Union[bytes, None, Program]]]]],
) -> BlockGenerator:
"""
Bind the generator block program template to a particular reference block,
template bytes offsets, and SpendBundle.
... | [
"def",
"create_compressed_generator",
"(",
"original_generator",
":",
"CompressorArg",
",",
"compressed_cse_list",
":",
"List",
"[",
"List",
"[",
"Union",
"[",
"List",
"[",
"uint64",
"]",
",",
"List",
"[",
"Union",
"[",
"bytes",
",",
"None",
",",
"Program",
... | [
42,
0
] | [
56,
51
] | python | en | ['en', 'error', 'th'] | False |
run_generator_unsafe | (self: BlockGenerator, max_cost: int) | This mode is meant for accepting possibly soft-forked transactions into the mempool | This mode is meant for accepting possibly soft-forked transactions into the mempool | def run_generator_unsafe(self: BlockGenerator, max_cost: int) -> Tuple[int, SerializedProgram]:
"""This mode is meant for accepting possibly soft-forked transactions into the mempool"""
program, args = setup_generator_args(self)
return GENERATOR_MOD.run_with_cost(max_cost, program, args) | [
"def",
"run_generator_unsafe",
"(",
"self",
":",
"BlockGenerator",
",",
"max_cost",
":",
"int",
")",
"->",
"Tuple",
"[",
"int",
",",
"SerializedProgram",
"]",
":",
"program",
",",
"args",
"=",
"setup_generator_args",
"(",
"self",
")",
"return",
"GENERATOR_MOD"... | [
69,
0
] | [
72,
63
] | python | en | ['en', 'en', 'en'] | True |
GaussianMixture.__init__ | (self, n_kernels=5, ndim_x=1, ndim_y=1, means_std=1.5, random_seed=None) | set parameters, calculate weights, means and covariances | set parameters, calculate weights, means and covariances | def __init__(self, n_kernels=5, ndim_x=1, ndim_y=1, means_std=1.5, random_seed=None):
self.random_state = np.random.RandomState(seed=random_seed) # random state for sampling data
self.random_state_params = np.random.RandomState(seed=20) # fixed random state for sampling GMM params
self.random_seed = random... | [
"def",
"__init__",
"(",
"self",
",",
"n_kernels",
"=",
"5",
",",
"ndim_x",
"=",
"1",
",",
"ndim_y",
"=",
"1",
",",
"means_std",
"=",
"1.5",
",",
"random_seed",
"=",
"None",
")",
":",
"self",
".",
"random_state",
"=",
"np",
".",
"random",
".",
"Rand... | [
22,
2
] | [
66,
61
] | python | en | ['en', 'en', 'en'] | True |
GaussianMixture.pdf | (self, X, Y) | conditional probability density function P(Y|X)
See "Conditional Gaussian Mixture Models for Environmental Risk Mapping" [Gilardi, Bengio] for the math.
Args:
X: the position/conditional variable for the distribution P(Y|X), array_like, shape:(n_samples, ndim_x)
Y: the on X conditioned variabl... | conditional probability density function P(Y|X)
See "Conditional Gaussian Mixture Models for Environmental Risk Mapping" [Gilardi, Bengio] for the math. | def pdf(self, X, Y):
""" conditional probability density function P(Y|X)
See "Conditional Gaussian Mixture Models for Environmental Risk Mapping" [Gilardi, Bengio] for the math.
Args:
X: the position/conditional variable for the distribution P(Y|X), array_like, shape:(n_samples, ndim_x)
Y: ... | [
"def",
"pdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"X",
",",
"Y",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
",",
"Y",
")",
"P_y",
"=",
"np",
".",
"stack",
"(",
"[",
"self",
".",
"gaussians_y",
"[",
"i",
"]",
".",
"pdf",
... | [
68,
2
] | [
87,
20
] | python | en | ['en', 'en', 'en'] | True |
GaussianMixture.cdf | (self, X, Y) | conditional cumulative probability density function P(Y<y|X=x).
See "Conditional Gaussian Mixture Models for Environmental Risk Mapping" [Gilardi, Bengio] for the math.
Args:
X: the position/conditional variable for the distribution P(Y<y|X=x), array_like, shape:(n_samples, ndim_x)
Y: the on X ... | conditional cumulative probability density function P(Y<y|X=x).
See "Conditional Gaussian Mixture Models for Environmental Risk Mapping" [Gilardi, Bengio] for the math. | def cdf(self, X, Y):
""" conditional cumulative probability density function P(Y<y|X=x).
See "Conditional Gaussian Mixture Models for Environmental Risk Mapping" [Gilardi, Bengio] for the math.
Args:
X: the position/conditional variable for the distribution P(Y<y|X=x), array_like, shape:(n_samples... | [
"def",
"cdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"X",
",",
"Y",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
",",
"Y",
")",
"P_y",
"=",
"np",
".",
"stack",
"(",
"[",
"self",
".",
"gaussians_y",
"[",
"i",
"]",
".",
"cdf",
... | [
89,
2
] | [
109,
20
] | python | en | ['en', 'es', 'en'] | True |
GaussianMixture.joint_pdf | (self, X, Y) | joint probability density function P(X, Y)
Args:
X: variable X for the distribution P(X, Y), array_like, shape:(n_samples, ndim_x)
Y: variable Y for the distribution P(X, Y) array_like, shape:(n_samples, ndim_y)
Returns:
the joint distribution of X and Y wih shape:(n_samples,)
| joint probability density function P(X, Y) | def joint_pdf(self, X, Y):
""" joint probability density function P(X, Y)
Args:
X: variable X for the distribution P(X, Y), array_like, shape:(n_samples, ndim_x)
Y: variable Y for the distribution P(X, Y) array_like, shape:(n_samples, ndim_y)
Returns:
the joint distribution of X and Y wi... | [
"def",
"joint_pdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"X",
",",
"Y",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
",",
"Y",
")",
"XY",
"=",
"np",
".",
"concatenate",
"(",
"[",
"X",
",",
"Y",
"]",
",",
"axis",
"=",
"1",
... | [
111,
2
] | [
126,
30
] | python | en | ['en', 'en', 'en'] | True |
GaussianMixture.simulate_conditional | (self, X) | Draws random samples from the conditional distribution
Args:
X: x to be conditioned on when drawing a sample from y ~ p(y|x) - numpy array of shape (n_samples, ndim_x)
Returns:
Conditional random samples y drawn from p(y|x) - numpy array of shape (n_samples, ndim_y)
| Draws random samples from the conditional distribution | def simulate_conditional(self, X):
""" Draws random samples from the conditional distribution
Args:
X: x to be conditioned on when drawing a sample from y ~ p(y|x) - numpy array of shape (n_samples, ndim_x)
Returns:
Conditional random samples y drawn from p(y|x) - numpy array of shape (n_sampl... | [
"def",
"simulate_conditional",
"(",
"self",
",",
"X",
")",
":",
"X",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"X",
")",
"if",
"np",
".",
"all",
"(",
"np",
".",
"all",
"(",
"X",
"==",
"X",
"[",
"0",
",",
":",
"]",
",",
"axis",
"=",
... | [
128,
2
] | [
143,
53
] | python | en | ['en', 'en', 'en'] | True |
GaussianMixture.simulate | (self, n_samples=1000) | Draws random samples from the unconditional distribution p(x,y)
Args:
n_samples: (int) number of samples to be drawn from the conditional distribution
Returns:
(X,Y) - random samples drawn from p(x,y) - numpy arrays of shape (n_samples, ndim_x) and (n_samples, ndim_y)
| Draws random samples from the unconditional distribution p(x,y) | def simulate(self, n_samples=1000):
""" Draws random samples from the unconditional distribution p(x,y)
Args:
n_samples: (int) number of samples to be drawn from the conditional distribution
Returns:
(X,Y) - random samples drawn from p(x,y) - numpy arrays of shape (n_samples, ndim_x) and (n_sa... | [
"def",
"simulate",
"(",
"self",
",",
"n_samples",
"=",
"1000",
")",
":",
"assert",
"n_samples",
">",
"0",
"n_samples_comp",
"=",
"self",
".",
"random_state",
".",
"multinomial",
"(",
"n_samples",
",",
"self",
".",
"weights",
")",
"samples",
"=",
"np",
".... | [
146,
2
] | [
171,
31
] | python | en | ['en', 'en', 'en'] | True |
GaussianMixture.mean_ | (self, x_cond, n_samples=None) | Conditional mean of the distribution
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y)
| Conditional mean of the distribution
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) | def mean_(self, x_cond, n_samples=None):
""" Conditional mean of the distribution
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y)
"""
assert x_cond.ndi... | [
"def",
"mean_",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"None",
")",
":",
"assert",
"x_cond",
".",
"ndim",
"==",
"2",
"and",
"x_cond",
".",
"shape",
"[",
"1",
"]",
"==",
"self",
".",
"ndim_x",
"W_x",
"=",
"self",
".",
"_W_x",
"(",
"x_c... | [
173,
2
] | [
185,
16
] | python | en | ['en', 'en', 'en'] | True |
GaussianMixture.covariance | (self, x_cond, n_samples=None) | Covariance of the distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y, ndim_y)
| Covariance of the distribution conditioned on x_cond | def covariance(self, x_cond, n_samples=None):
""" Covariance of the distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim... | [
"def",
"covariance",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"None",
")",
":",
"assert",
"x_cond",
".",
"ndim",
"==",
"2",
"and",
"x_cond",
".",
"shape",
"[",
"1",
"]",
"==",
"self",
".",
"ndim_x",
"W_x",
"=",
"self",
".",
"_W_x",
"(",
... | [
187,
2
] | [
213,
15
] | python | en | ['en', 'en', 'en'] | True |
GaussianMixture._sample_weights | (self, n_weights) | samples density weights -> sum up to one
Args:
n_weights: number of weights
Returns:
ndarray of weights with shape (n_weights,)
| samples density weights -> sum up to one
Args:
n_weights: number of weights
Returns:
ndarray of weights with shape (n_weights,)
| def _sample_weights(self, n_weights):
""" samples density weights -> sum up to one
Args:
n_weights: number of weights
Returns:
ndarray of weights with shape (n_weights,)
"""
weights = self.random_state_params.uniform(0, 1, size=[n_weights])
return weights / np.sum(weights) | [
"def",
"_sample_weights",
"(",
"self",
",",
"n_weights",
")",
":",
"weights",
"=",
"self",
".",
"random_state_params",
".",
"uniform",
"(",
"0",
",",
"1",
",",
"size",
"=",
"[",
"n_weights",
"]",
")",
"return",
"weights",
"/",
"np",
".",
"sum",
"(",
... | [
241,
2
] | [
249,
36
] | python | en | ['en', 'en', 'en'] | True |
GaussianMixture._W_x | (self, X) | Helper function to normalize the joint density P(Y,X) by the marginal density P(X)
Args:
X: conditional random variable, array_like, shape:(n_samples, ndim_x)
Return:
the normalized weighted marginal gaussian distributions P(X) for each n_kernel, shape:(n_samples,n_kernels)
| Helper function to normalize the joint density P(Y,X) by the marginal density P(X) | def _W_x(self, X):
""" Helper function to normalize the joint density P(Y,X) by the marginal density P(X)
Args:
X: conditional random variable, array_like, shape:(n_samples, ndim_x)
Return:
the normalized weighted marginal gaussian distributions P(X) for each n_kernel, shape:(n_samples,n_kerne... | [
"def",
"_W_x",
"(",
"self",
",",
"X",
")",
":",
"assert",
"X",
".",
"ndim",
"==",
"2",
"and",
"X",
".",
"shape",
"[",
"1",
"]",
"==",
"self",
".",
"ndim_x",
"if",
"X",
".",
"shape",
"[",
"0",
"]",
"==",
"1",
":",
"w_p",
"=",
"np",
".",
"s... | [
251,
2
] | [
267,
17
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.pdf | (self, X, Y) | Conditional probability density function p(y|x) of the underlying probability model
Args:
X: x to be conditioned on - numpy array of shape (n_points, ndim_x)
Y: y target values for witch the pdf shall be evaluated - numpy array of shape (n_points, ndim_y)
Returns:
p(X|Y) conditional density... | Conditional probability density function p(y|x) of the underlying probability model | def pdf(self, X, Y):
""" Conditional probability density function p(y|x) of the underlying probability model
Args:
X: x to be conditioned on - numpy array of shape (n_points, ndim_x)
Y: y target values for witch the pdf shall be evaluated - numpy array of shape (n_points, ndim_y)
Returns:
... | [
"def",
"pdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"raise",
"NotImplementedError"
] | [
12,
2
] | [
23,
29
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.log_pdf | (self, X, Y) | Conditional log-probability log p(y|x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
conditional log-probability log p(y|x) - numpy array of shape (... | Conditional log-probability log p(y|x). Requires the model to be fitted. | def log_pdf(self, X, Y):
""" Conditional log-probability log p(y|x). Requires the model to be fitted.
Args:
X: numpy array to be conditioned on - shape: (n_samples, n_dim_x)
Y: numpy array of y targets - shape: (n_samples, n_dim_y)
Returns:
conditional log-probability log... | [
"def",
"log_pdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"# This method is numerically unfavorable and should be overwritten with a numerically stable method",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\""... | [
25,
2
] | [
40,
19
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.cdf | (self, X, Y) | Conditional cumulated probability density function P(Y < y | x) of the underlying probability model
Args:
X: x to be conditioned on - numpy array of shape (n_points, ndim_x)
Y: y target values for witch the cdf shall be evaluated - numpy array of shape (n_points, ndim_y)
Returns:
P(Y < y | x... | Conditional cumulated probability density function P(Y < y | x) of the underlying probability model | def cdf(self, X, Y):
""" Conditional cumulated probability density function P(Y < y | x) of the underlying probability model
Args:
X: x to be conditioned on - numpy array of shape (n_points, ndim_x)
Y: y target values for witch the cdf shall be evaluated - numpy array of shape (n_points, ndim_y)
... | [
"def",
"cdf",
"(",
"self",
",",
"X",
",",
"Y",
")",
":",
"raise",
"NotImplementedError"
] | [
42,
2
] | [
53,
29
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.simulate_conditional | (self, X) | Draws random samples from the conditional distribution
Args:
X: x to be conditioned on when drawing a sample from y ~ p(y|x) - numpy array of shape (n_samples, ndim_x)
Returns:
Conditional random samples y drawn from p(y|x) - numpy array of shape (n_samples, ndim_y)
| Draws random samples from the conditional distribution | def simulate_conditional(self, X):
""" Draws random samples from the conditional distribution
Args:
X: x to be conditioned on when drawing a sample from y ~ p(y|x) - numpy array of shape (n_samples, ndim_x)
Returns:
Conditional random samples y drawn from p(y|x) - numpy array of shape (n_sampl... | [
"def",
"simulate_conditional",
"(",
"self",
",",
"X",
")",
":",
"raise",
"NotImplementedError"
] | [
55,
2
] | [
64,
29
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.simulate | (self, n_samples) | Draws random samples from the unconditional distribution p(x,y)
Args:
n_samples: (int) number of samples to be drawn from the conditional distribution
Returns:
(X,Y) - random samples drawn from p(x,y) - numpy arrays of shape (n_samples, ndim_x) and (n_samples, ndim_y)
| Draws random samples from the unconditional distribution p(x,y) | def simulate(self, n_samples):
""" Draws random samples from the unconditional distribution p(x,y)
Args:
n_samples: (int) number of samples to be drawn from the conditional distribution
Returns:
(X,Y) - random samples drawn from p(x,y) - numpy arrays of shape (n_samples, ndim_x) and (n_samples... | [
"def",
"simulate",
"(",
"self",
",",
"n_samples",
")",
":",
"raise",
"NotImplementedError"
] | [
66,
2
] | [
75,
29
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.plot | (self, xlim=(-5, 5), ylim=(-5, 5), resolution=100, mode="pdf", show=False, numpyfig=False) | Plots the distribution specified in mode if x and y are 1-dimensional each
Args:
xlim: 2-tuple specifying the x axis limits
ylim: 2-tuple specifying the y axis limits
resolution: integer specifying the resolution of plot
mode: spefify which dist to plot ["pdf", "cdf", "joint_pdf"]
| Plots the distribution specified in mode if x and y are 1-dimensional each | def plot(self, xlim=(-5, 5), ylim=(-5, 5), resolution=100, mode="pdf", show=False, numpyfig=False):
""" Plots the distribution specified in mode if x and y are 1-dimensional each
Args:
xlim: 2-tuple specifying the x axis limits
ylim: 2-tuple specifying the y axis limits
resolution: integer sp... | [
"def",
"plot",
"(",
"self",
",",
"xlim",
"=",
"(",
"-",
"5",
",",
"5",
")",
",",
"ylim",
"=",
"(",
"-",
"5",
",",
"5",
")",
",",
"resolution",
"=",
"100",
",",
"mode",
"=",
"\"pdf\"",
",",
"show",
"=",
"False",
",",
"numpyfig",
"=",
"False",
... | [
77,
2
] | [
127,
14
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.mean_ | (self, x_cond, n_samples=10**6) | Mean of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y)
| Mean of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x) | def mean_(self, x_cond, n_samples=10**6):
""" Mean of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Means E[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y)
"""
asse... | [
"def",
"mean_",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"10",
"**",
"6",
")",
":",
"assert",
"x_cond",
".",
"ndim",
"==",
"2",
"if",
"self",
".",
"can_sample",
":",
"return",
"self",
".",
"_mean_mc",
"(",
"x_cond",
",",
"n_samples",
"=",
... | [
129,
2
] | [
142,
35
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.std_ | (self, x_cond, n_samples=10 ** 6) | Standard deviation of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Standard deviations sqrt(Var[y|x]) corresponding to x_cond - numpy array of shape (n_values, ndim_y)
| Standard deviation of the fitted distribution conditioned on x_cond | def std_(self, x_cond, n_samples=10 ** 6):
""" Standard deviation of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Standard deviations sqrt(Var[y|x]) corresponding to x_cond - numpy array of sh... | [
"def",
"std_",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"10",
"**",
"6",
")",
":",
"x_cond",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"x_cond",
")",
"assert",
"x_cond",
".",
"ndim",
"==",
"2",
"return",
"self",
".",
"_std_pdf",
... | [
144,
2
] | [
155,
53
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.covariance | (self, x_cond, n_samples=10**6) | Covariance of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
n_samples: number of samples for monte carlo model_fitting
Returns:
Covariances Cov[y|x] corresponding to x_cond - numpy array of shape (n_v... | Covariance of the fitted distribution conditioned on x_cond | def covariance(self, x_cond, n_samples=10**6):
""" Covariance of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
n_samples: number of samples for monte carlo model_fitting
Returns:
Covariances Cov[y|... | [
"def",
"covariance",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"10",
"**",
"6",
")",
":",
"if",
"self",
".",
"has_pdf",
":",
"return",
"self",
".",
"_covariance_pdf",
"(",
"x_cond",
")",
"elif",
"self",
".",
"can_sample",
":",
"return",
"self"... | [
157,
2
] | [
172,
33
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.skewness | (self, x_cond, n_samples=10 ** 6) | Skewness of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Skewness Skew[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y, ndim_y)
| Skewness of the fitted distribution conditioned on x_cond | def skewness(self, x_cond, n_samples=10 ** 6):
""" Skewness of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Skewness Skew[y|x] corresponding to x_cond - numpy array of shape (n_valu... | [
"def",
"skewness",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"10",
"**",
"6",
")",
":",
"x_cond",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"x_cond",
")",
"assert",
"x_cond",
".",
"ndim",
"==",
"2",
"if",
"self",
".",
"has_pdf",
"... | [
174,
2
] | [
190,
33
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.kurtosis | (self, x_cond, n_samples=10 ** 6) | Kurtosis of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Kurtosis Kurt[y|x] corresponding to x_cond - numpy array of shape (n_values, ndim_y, ndim_y)
| Kurtosis of the fitted distribution conditioned on x_cond | def kurtosis(self, x_cond, n_samples=10 ** 6):
""" Kurtosis of the fitted distribution conditioned on x_cond
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
Returns:
Kurtosis Kurt[y|x] corresponding to x_cond - numpy array of shape (n_valu... | [
"def",
"kurtosis",
"(",
"self",
",",
"x_cond",
",",
"n_samples",
"=",
"10",
"**",
"6",
")",
":",
"x_cond",
"=",
"self",
".",
"_handle_input_dimensionality",
"(",
"x_cond",
")",
"assert",
"x_cond",
".",
"ndim",
"==",
"2",
"if",
"self",
".",
"has_pdf",
"... | [
192,
2
] | [
208,
33
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.value_at_risk | (self, x_cond, alpha=0.01, n_samples=10**6) | Computes the Value-at-Risk (VaR) of the fitted distribution. Only if ndim_y = 1
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
alpha: quantile percentage of the distribution
n_samples: number of samples for monte carlo model_fitting
Returns:
... | Computes the Value-at-Risk (VaR) of the fitted distribution. Only if ndim_y = 1 | def value_at_risk(self, x_cond, alpha=0.01, n_samples=10**6):
""" Computes the Value-at-Risk (VaR) of the fitted distribution. Only if ndim_y = 1
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
alpha: quantile percentage of the distribution
n_samples... | [
"def",
"value_at_risk",
"(",
"self",
",",
"x_cond",
",",
"alpha",
"=",
"0.01",
",",
"n_samples",
"=",
"10",
"**",
"6",
")",
":",
"assert",
"self",
".",
"ndim_y",
"==",
"1",
",",
"\"Value at Risk can only be computed when ndim_y = 1\"",
"assert",
"x_cond",
".",... | [
210,
2
] | [
229,
33
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.conditional_value_at_risk | (self, x_cond, alpha=0.01, n_samples=10**6) | Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of the fitted distribution. Only if ndim_y = 1
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
alpha: quantile percentage of the distribution
n_samples: number of samples for... | Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of the fitted distribution. Only if ndim_y = 1 | def conditional_value_at_risk(self, x_cond, alpha=0.01, n_samples=10**6):
""" Computes the Conditional Value-at-Risk (CVaR) / Expected Shortfall of the fitted distribution. Only if ndim_y = 1
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
alpha: ... | [
"def",
"conditional_value_at_risk",
"(",
"self",
",",
"x_cond",
",",
"alpha",
"=",
"0.01",
",",
"n_samples",
"=",
"10",
"**",
"6",
")",
":",
"assert",
"self",
".",
"ndim_y",
"==",
"1",
",",
"\"Value at Risk can only be computed when ndim_y = 1\"",
"x_cond",
"=",... | [
231,
2
] | [
253,
115
] | python | en | ['en', 'en', 'en'] | True |
BaseConditionalDensitySimulation.tail_risk_measures | (self, x_cond, alpha=0.01, n_samples=10**6) | Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR)
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
alpha: quantile percentage of the distribution
n_samples: number of samples for monte carlo model_fitting
Retu... | Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR) | def tail_risk_measures(self, x_cond, alpha=0.01, n_samples=10**6):
""" Computes the Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR)
Args:
x_cond: different x values to condition on - numpy array of shape (n_values, ndim_x)
alpha: quantile percentage of the distribution
... | [
"def",
"tail_risk_measures",
"(",
"self",
",",
"x_cond",
",",
"alpha",
"=",
"0.01",
",",
"n_samples",
"=",
"10",
"**",
"6",
")",
":",
"assert",
"self",
".",
"ndim_y",
"==",
"1",
",",
"\"Value at Risk can only be computed when ndim_y = 1\"",
"assert",
"x_cond",
... | [
255,
2
] | [
280,
22
] | python | en | ['en', 'en', 'en'] | True |
version_lt | (ver1: str, ver2: str) |
Compare two Zulip-style version strings.
Versions are dot-separated sequences of decimal integers,
followed by arbitrary trailing decoration. Comparison is
lexicographic on the integer sequences, and refuses to
guess how any trailing decoration compares to any other,
to further numerals, or t... |
Compare two Zulip-style version strings. | def version_lt(ver1: str, ver2: str) -> Optional[bool]:
"""
Compare two Zulip-style version strings.
Versions are dot-separated sequences of decimal integers,
followed by arbitrary trailing decoration. Comparison is
lexicographic on the integer sequences, and refuses to
guess how any trailing ... | [
"def",
"version_lt",
"(",
"ver1",
":",
"str",
",",
"ver2",
":",
"str",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"num1",
",",
"rest1",
"=",
"pop_numerals",
"(",
"ver1",
")",
"num2",
",",
"rest2",
"=",
"pop_numerals",
"(",
"ver2",
")",
"if",
"no... | [
58,
0
] | [
97,
15
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.get_redirect_location | (self) |
Should we redirect and where to?
:returns: Truthy redirect location string if we got a redirect status
code and valid location. ``None`` if redirect status and no
location. ``False`` if not a redirect status code.
|
Should we redirect and where to? | def get_redirect_location(self):
"""
Should we redirect and where to?
:returns: Truthy redirect location string if we got a redirect status
code and valid location. ``None`` if redirect status and no
location. ``False`` if not a redirect status code.
"""
... | [
"def",
"get_redirect_location",
"(",
"self",
")",
":",
"if",
"self",
".",
"status",
"in",
"self",
".",
"REDIRECT_STATUSES",
":",
"return",
"self",
".",
"headers",
".",
"get",
"(",
"\"location\"",
")",
"return",
"False"
] | [
261,
4
] | [
272,
20
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.drain_conn | (self) |
Read and discard any remaining HTTP response data in the response connection.
Unread data in the HTTPResponse connection blocks the connection from being released back to the pool.
|
Read and discard any remaining HTTP response data in the response connection. | def drain_conn(self):
"""
Read and discard any remaining HTTP response data in the response connection.
Unread data in the HTTPResponse connection blocks the connection from being released back to the pool.
"""
try:
self.read()
except (HTTPError, SocketError,... | [
"def",
"drain_conn",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"read",
"(",
")",
"except",
"(",
"HTTPError",
",",
"SocketError",
",",
"BaseSSLError",
",",
"HTTPException",
")",
":",
"pass"
] | [
281,
4
] | [
290,
16
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.tell | (self) |
Obtain the number of bytes pulled over the wire so far. May differ from
the amount of content returned by :meth:``urllib3.response.HTTPResponse.read``
if bytes are encoded on the wire (e.g, compressed).
|
Obtain the number of bytes pulled over the wire so far. May differ from
the amount of content returned by :meth:``urllib3.response.HTTPResponse.read``
if bytes are encoded on the wire (e.g, compressed).
| def tell(self):
"""
Obtain the number of bytes pulled over the wire so far. May differ from
the amount of content returned by :meth:``urllib3.response.HTTPResponse.read``
if bytes are encoded on the wire (e.g, compressed).
"""
return self._fp_bytes_read | [
"def",
"tell",
"(",
"self",
")",
":",
"return",
"self",
".",
"_fp_bytes_read"
] | [
308,
4
] | [
314,
34
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse._init_length | (self, request_method) |
Set initial length value for Response content if available.
|
Set initial length value for Response content if available.
| def _init_length(self, request_method):
"""
Set initial length value for Response content if available.
"""
length = self.headers.get("content-length")
if length is not None:
if self.chunked:
# This Response will fail with an IncompleteRead if it can'... | [
"def",
"_init_length",
"(",
"self",
",",
"request_method",
")",
":",
"length",
"=",
"self",
".",
"headers",
".",
"get",
"(",
"\"content-length\"",
")",
"if",
"length",
"is",
"not",
"None",
":",
"if",
"self",
".",
"chunked",
":",
"# This Response will fail wi... | [
316,
4
] | [
366,
21
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse._init_decoder | (self) |
Set-up the _decoder attribute if necessary.
|
Set-up the _decoder attribute if necessary.
| def _init_decoder(self):
"""
Set-up the _decoder attribute if necessary.
"""
# Note: content-encoding value should be case-insensitive, per RFC 7230
# Section 3.2
content_encoding = self.headers.get("content-encoding", "").lower()
if self._decoder is None:
... | [
"def",
"_init_decoder",
"(",
"self",
")",
":",
"# Note: content-encoding value should be case-insensitive, per RFC 7230",
"# Section 3.2",
"content_encoding",
"=",
"self",
".",
"headers",
".",
"get",
"(",
"\"content-encoding\"",
",",
"\"\"",
")",
".",
"lower",
"(",
")",... | [
368,
4
] | [
385,
66
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse._decode | (self, data, decode_content, flush_decoder) |
Decode the data passed in and potentially flush the decoder.
|
Decode the data passed in and potentially flush the decoder.
| def _decode(self, data, decode_content, flush_decoder):
"""
Decode the data passed in and potentially flush the decoder.
"""
if not decode_content:
return data
try:
if self._decoder:
data = self._decoder.decompress(data)
except sel... | [
"def",
"_decode",
"(",
"self",
",",
"data",
",",
"decode_content",
",",
"flush_decoder",
")",
":",
"if",
"not",
"decode_content",
":",
"return",
"data",
"try",
":",
"if",
"self",
".",
"_decoder",
":",
"data",
"=",
"self",
".",
"_decoder",
".",
"decompres... | [
391,
4
] | [
411,
19
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse._flush_decoder | (self) |
Flushes the decoder. Should only be called if the decoder is actually
being used.
|
Flushes the decoder. Should only be called if the decoder is actually
being used.
| def _flush_decoder(self):
"""
Flushes the decoder. Should only be called if the decoder is actually
being used.
"""
if self._decoder:
buf = self._decoder.decompress(b"")
return buf + self._decoder.flush()
return b"" | [
"def",
"_flush_decoder",
"(",
"self",
")",
":",
"if",
"self",
".",
"_decoder",
":",
"buf",
"=",
"self",
".",
"_decoder",
".",
"decompress",
"(",
"b\"\"",
")",
"return",
"buf",
"+",
"self",
".",
"_decoder",
".",
"flush",
"(",
")",
"return",
"b\"\""
] | [
413,
4
] | [
422,
18
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse._error_catcher | (self) |
Catch low-level python exceptions, instead re-raising urllib3
variants, so that low-level exceptions are not leaked in the
high-level api.
On exit, release the connection back to the pool.
|
Catch low-level python exceptions, instead re-raising urllib3
variants, so that low-level exceptions are not leaked in the
high-level api. | def _error_catcher(self):
"""
Catch low-level python exceptions, instead re-raising urllib3
variants, so that low-level exceptions are not leaked in the
high-level api.
On exit, release the connection back to the pool.
"""
clean_exit = False
try:
... | [
"def",
"_error_catcher",
"(",
"self",
")",
":",
"clean_exit",
"=",
"False",
"try",
":",
"try",
":",
"yield",
"except",
"SocketTimeout",
":",
"# FIXME: Ideally we'd like to include the url in the ReadTimeoutError but",
"# there is yet no clean way to get at it from this context.",... | [
425,
4
] | [
478,
35
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.read | (self, amt=None, decode_content=None, cache_content=False) |
Similar to :meth:`http.client.HTTPResponse.read`, but with two additional
parameters: ``decode_content`` and ``cache_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
because it doesn't make sense to cache partial content as the fu... |
Similar to :meth:`http.client.HTTPResponse.read`, but with two additional
parameters: ``decode_content`` and ``cache_content``. | def read(self, amt=None, decode_content=None, cache_content=False):
"""
Similar to :meth:`http.client.HTTPResponse.read`, but with two additional
parameters: ``decode_content`` and ``cache_content``.
:param amt:
How much of the content to read. If specified, caching is skipp... | [
"def",
"read",
"(",
"self",
",",
"amt",
"=",
"None",
",",
"decode_content",
"=",
"None",
",",
"cache_content",
"=",
"False",
")",
":",
"self",
".",
"_init_decoder",
"(",
")",
"if",
"decode_content",
"is",
"None",
":",
"decode_content",
"=",
"self",
".",
... | [
480,
4
] | [
552,
19
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.stream | (self, amt=2 ** 16, decode_content=None) |
A generator wrapper for the read() method. A call will block until
``amt`` bytes have been read from the connection or until the
connection is closed.
:param amt:
How much of the content to read. The generator will return up to
much data per iteration, but may r... |
A generator wrapper for the read() method. A call will block until
``amt`` bytes have been read from the connection or until the
connection is closed. | def stream(self, amt=2 ** 16, decode_content=None):
"""
A generator wrapper for the read() method. A call will block until
``amt`` bytes have been read from the connection or until the
connection is closed.
:param amt:
How much of the content to read. The generator w... | [
"def",
"stream",
"(",
"self",
",",
"amt",
"=",
"2",
"**",
"16",
",",
"decode_content",
"=",
"None",
")",
":",
"if",
"self",
".",
"chunked",
"and",
"self",
".",
"supports_chunked_reads",
"(",
")",
":",
"for",
"line",
"in",
"self",
".",
"read_chunked",
... | [
554,
4
] | [
578,
30
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.from_httplib | (ResponseCls, r, **response_kw) |
Given an :class:`http.client.HTTPResponse` instance ``r``, return a
corresponding :class:`urllib3.response.HTTPResponse` object.
Remaining parameters are passed to the HTTPResponse constructor, along
with ``original_response=r``.
|
Given an :class:`http.client.HTTPResponse` instance ``r``, return a
corresponding :class:`urllib3.response.HTTPResponse` object. | def from_httplib(ResponseCls, r, **response_kw):
"""
Given an :class:`http.client.HTTPResponse` instance ``r``, return a
corresponding :class:`urllib3.response.HTTPResponse` object.
Remaining parameters are passed to the HTTPResponse constructor, along
with ``original_response=r... | [
"def",
"from_httplib",
"(",
"ResponseCls",
",",
"r",
",",
"*",
"*",
"response_kw",
")",
":",
"headers",
"=",
"r",
".",
"msg",
"if",
"not",
"isinstance",
"(",
"headers",
",",
"HTTPHeaderDict",
")",
":",
"if",
"six",
".",
"PY2",
":",
"# Python 2.7",
"hea... | [
581,
4
] | [
610,
19
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.supports_chunked_reads | (self) |
Checks if the underlying file-like object looks like a
:class:`http.client.HTTPResponse` object. We do this by testing for
the fp attribute. If it is present we assume it returns raw chunks as
processed by read_chunked().
|
Checks if the underlying file-like object looks like a
:class:`http.client.HTTPResponse` object. We do this by testing for
the fp attribute. If it is present we assume it returns raw chunks as
processed by read_chunked().
| def supports_chunked_reads(self):
"""
Checks if the underlying file-like object looks like a
:class:`http.client.HTTPResponse` object. We do this by testing for
the fp attribute. If it is present we assume it returns raw chunks as
processed by read_chunked().
"""
... | [
"def",
"supports_chunked_reads",
"(",
"self",
")",
":",
"return",
"hasattr",
"(",
"self",
".",
"_fp",
",",
"\"fp\"",
")"
] | [
679,
4
] | [
686,
38
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.read_chunked | (self, amt=None, decode_content=None) |
Similar to :meth:`HTTPResponse.read`, but with an additional
parameter: ``decode_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
because it doesn't make sense to cache partial content as the full
response.
:p... |
Similar to :meth:`HTTPResponse.read`, but with an additional
parameter: ``decode_content``. | def read_chunked(self, amt=None, decode_content=None):
"""
Similar to :meth:`HTTPResponse.read`, but with an additional
parameter: ``decode_content``.
:param amt:
How much of the content to read. If specified, caching is skipped
because it doesn't make sense to c... | [
"def",
"read_chunked",
"(",
"self",
",",
"amt",
"=",
"None",
",",
"decode_content",
"=",
"None",
")",
":",
"self",
".",
"_init_decoder",
"(",
")",
"# FIXME: Rewrite this method and make it a class with a better structured logic.",
"if",
"not",
"self",
".",
"chunked",
... | [
724,
4
] | [
792,
47
] | python | en | ['en', 'error', 'th'] | False |
HTTPResponse.geturl | (self) |
Returns the URL that was the source of this response.
If the request that generated this response redirected, this method
will return the final redirect location.
|
Returns the URL that was the source of this response.
If the request that generated this response redirected, this method
will return the final redirect location.
| def geturl(self):
"""
Returns the URL that was the source of this response.
If the request that generated this response redirected, this method
will return the final redirect location.
"""
if self.retries is not None and len(self.retries.history):
return self.... | [
"def",
"geturl",
"(",
"self",
")",
":",
"if",
"self",
".",
"retries",
"is",
"not",
"None",
"and",
"len",
"(",
"self",
".",
"retries",
".",
"history",
")",
":",
"return",
"self",
".",
"retries",
".",
"history",
"[",
"-",
"1",
"]",
".",
"redirect_loc... | [
794,
4
] | [
803,
36
] | python | en | ['en', 'error', 'th'] | False |
KaleServer.my_id | (self) | If node has public cert use that one for id, if not use private. | If node has public cert use that one for id, if not use private. | def my_id(self) -> bytes32:
"""If node has public cert use that one for id, if not use private."""
if self.p2p_crt_path is not None:
pem_cert = x509.load_pem_x509_certificate(self.p2p_crt_path.read_bytes(), default_backend())
else:
pem_cert = x509.load_pem_x509_certificat... | [
"def",
"my_id",
"(",
"self",
")",
"->",
"bytes32",
":",
"if",
"self",
".",
"p2p_crt_path",
"is",
"not",
"None",
":",
"pem_cert",
"=",
"x509",
".",
"load_pem_x509_certificate",
"(",
"self",
".",
"p2p_crt_path",
".",
"read_bytes",
"(",
")",
",",
"default_bac... | [
151,
4
] | [
159,
61
] | python | en | ['en', 'en', 'en'] | True |
KaleServer.garbage_collect_connections_task | (self) |
Periodically checks for connections with no activity (have not sent us any data), and removes them,
to allow room for other peers.
|
Periodically checks for connections with no activity (have not sent us any data), and removes them,
to allow room for other peers.
| async def garbage_collect_connections_task(self) -> None:
"""
Periodically checks for connections with no activity (have not sent us any data), and removes them,
to allow room for other peers.
"""
while True:
await asyncio.sleep(600)
to_remove: List[WSKale... | [
"async",
"def",
"garbage_collect_connections_task",
"(",
"self",
")",
"->",
"None",
":",
"while",
"True",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"600",
")",
"to_remove",
":",
"List",
"[",
"WSKaleConnection",
"]",
"=",
"[",
"]",
"for",
"connection",
"i... | [
164,
4
] | [
186,
46
] | python | en | ['en', 'error', 'th'] | False |
KaleServer.start_client | (
self,
target_node: PeerInfo,
on_connect: Callable = None,
auth: bool = False,
is_feeler: bool = False,
) |
Tries to connect to the target node, adding one connection into the pipeline, if successful.
An on connect method can also be specified, and this will be saved into the instance variables.
|
Tries to connect to the target node, adding one connection into the pipeline, if successful.
An on connect method can also be specified, and this will be saved into the instance variables.
| async def start_client(
self,
target_node: PeerInfo,
on_connect: Callable = None,
auth: bool = False,
is_feeler: bool = False,
) -> bool:
"""
Tries to connect to the target node, adding one connection into the pipeline, if successful.
An on connect met... | [
"async",
"def",
"start_client",
"(",
"self",
",",
"target_node",
":",
"PeerInfo",
",",
"on_connect",
":",
"Callable",
"=",
"None",
",",
"auth",
":",
"bool",
"=",
"False",
",",
"is_feeler",
":",
"bool",
"=",
"False",
",",
")",
"->",
"bool",
":",
"if",
... | [
318,
4
] | [
435,
20
] | python | en | ['en', 'error', 'th'] | False |
inventory_source_vars_forward | (apps, schema_editor) |
The Django app registry does not keep track of model inheritance. The
source_vars_dict property comes from InventorySourceOptions via inheritance.
This adds that property. Luckily, other properteries and functionality from
InventorySourceOptions is not needed by the injector logic.
|
The Django app registry does not keep track of model inheritance. The
source_vars_dict property comes from InventorySourceOptions via inheritance.
This adds that property. Luckily, other properteries and functionality from
InventorySourceOptions is not needed by the injector logic.
| def inventory_source_vars_forward(apps, schema_editor):
InventorySource = apps.get_model("main", "InventorySource")
'''
The Django app registry does not keep track of model inheritance. The
source_vars_dict property comes from InventorySourceOptions via inheritance.
This adds that property. Luckily,... | [
"def",
"inventory_source_vars_forward",
"(",
"apps",
",",
"schema_editor",
")",
":",
"InventorySource",
"=",
"apps",
".",
"get_model",
"(",
"\"main\"",
",",
"\"InventorySource\"",
")",
"setattr",
"(",
"InventorySource",
",",
"'source_vars_dict'",
",",
"VarsDictPropert... | [
19,
0
] | [
38,
33
] | python | en | ['en', 'error', 'th'] | False |
TestRuleList.test_paths_in_rules | (self) | Verifies that the paths mentioned in linter rules actually exist | Verifies that the paths mentioned in linter rules actually exist | def test_paths_in_rules(self) -> None:
"""Verifies that the paths mentioned in linter rules actually exist"""
for rule in self.all_rules:
for path in rule.get("exclude", {}):
abs_path = os.path.abspath(os.path.join(ROOT_DIR, path))
self.assertTrue(
... | [
"def",
"test_paths_in_rules",
"(",
"self",
")",
"->",
"None",
":",
"for",
"rule",
"in",
"self",
".",
"all_rules",
":",
"for",
"path",
"in",
"rule",
".",
"get",
"(",
"\"exclude\"",
",",
"{",
"}",
")",
":",
"abs_path",
"=",
"os",
".",
"path",
".",
"a... | [
19,
4
] | [
41,
21
] | python | en | ['en', 'en', 'en'] | True |
TestRuleList.test_rule_patterns | (self) | Verifies that the search regex specified in a custom rule actually matches
the expectation and doesn't throw false positives. | Verifies that the search regex specified in a custom rule actually matches
the expectation and doesn't throw false positives. | def test_rule_patterns(self) -> None:
"""Verifies that the search regex specified in a custom rule actually matches
the expectation and doesn't throw false positives."""
for rule in self.all_rules:
pattern = rule["pattern"]
for line in rule.get("good_lines", []):
... | [
"def",
"test_rule_patterns",
"(",
"self",
")",
"->",
"None",
":",
"for",
"rule",
"in",
"self",
".",
"all_rules",
":",
"pattern",
"=",
"rule",
"[",
"\"pattern\"",
"]",
"for",
"line",
"in",
"rule",
".",
"get",
"(",
"\"good_lines\"",
",",
"[",
"]",
")",
... | [
43,
4
] | [
73,
21
] | python | en | ['en', 'en', 'en'] | True |
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_... | [
10,
0
] | [
91,
48
] | python | en | ['en', 'error', 'th'] | False |
IndexView.get_filename | (self) | Get filename for exported spreadsheet, without extension | Get filename for exported spreadsheet, without extension | def get_filename(self):
""" Get filename for exported spreadsheet, without extension """
return getattr(self.model_admin, 'export_filename', super().get_filename()) | [
"def",
"get_filename",
"(",
"self",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"model_admin",
",",
"'export_filename'",
",",
"super",
"(",
")",
".",
"get_filename",
"(",
")",
")"
] | [
294,
4
] | [
296,
83
] | python | en | ['en', 'en', 'en'] | True |
IndexView.get_heading | (self, queryset, field) | Get headings for exported spreadsheet column for the relevant field | Get headings for exported spreadsheet column for the relevant field | def get_heading(self, queryset, field):
""" Get headings for exported spreadsheet column for the relevant field """
heading_override = self.export_headings.get(field)
if heading_override:
return force_str(heading_override)
return force_str(label_for_field(field, model=self.mo... | [
"def",
"get_heading",
"(",
"self",
",",
"queryset",
",",
"field",
")",
":",
"heading_override",
"=",
"self",
".",
"export_headings",
".",
"get",
"(",
"field",
")",
"if",
"heading_override",
":",
"return",
"force_str",
"(",
"heading_override",
")",
"return",
... | [
298,
4
] | [
303,
104
] | python | en | ['en', 'en', 'en'] | True |
IndexView.to_row_dict | (self, item) | Returns an OrderedDict (in the order given by list_export) of the exportable information for a model instance | Returns an OrderedDict (in the order given by list_export) of the exportable information for a model instance | def to_row_dict(self, item):
""" Returns an OrderedDict (in the order given by list_export) of the exportable information for a model instance"""
row_dict = OrderedDict()
for field in self.list_export:
f, attr, value = lookup_field(field, item, self.model_admin)
if not va... | [
"def",
"to_row_dict",
"(",
"self",
",",
"item",
")",
":",
"row_dict",
"=",
"OrderedDict",
"(",
")",
"for",
"field",
"in",
"self",
".",
"list_export",
":",
"f",
",",
"attr",
",",
"value",
"=",
"lookup_field",
"(",
"field",
",",
"item",
",",
"self",
".... | [
305,
4
] | [
314,
23
] | python | en | ['en', 'en', 'en'] | True |
IndexView.get_filters_params | (self, params=None) |
Returns all params except IGNORED_PARAMS
|
Returns all params except IGNORED_PARAMS
| def get_filters_params(self, params=None):
"""
Returns all params except IGNORED_PARAMS
"""
if not params:
params = self.params
lookup_params = params.copy() # a dictionary of the query string
# Remove all the parameters that are globally and systematically
... | [
"def",
"get_filters_params",
"(",
"self",
",",
"params",
"=",
"None",
")",
":",
"if",
"not",
"params",
":",
"params",
"=",
"self",
".",
"params",
"lookup_params",
"=",
"params",
".",
"copy",
"(",
")",
"# a dictionary of the query string",
"# Remove all the param... | [
332,
4
] | [
344,
28
] | python | en | ['en', 'error', 'th'] | False |
IndexView.get_ordering_field | (self, field_name) |
Returns the proper model field name corresponding to the given
field_name to use for ordering. field_name may either be the name of a
proper model field or the name of a method (on the admin or model) or a
callable with the 'admin_order_field' attribute. Returns None if no
prope... |
Returns the proper model field name corresponding to the given
field_name to use for ordering. field_name may either be the name of a
proper model field or the name of a method (on the admin or model) or a
callable with the 'admin_order_field' attribute. Returns None if no
prope... | def get_ordering_field(self, field_name):
"""
Returns the proper model field name corresponding to the given
field_name to use for ordering. field_name may either be the name of a
proper model field or the name of a method (on the admin or model) or a
callable with the 'admin_ord... | [
"def",
"get_ordering_field",
"(",
"self",
",",
"field_name",
")",
":",
"try",
":",
"field",
"=",
"self",
".",
"opts",
".",
"get_field",
"(",
"field_name",
")",
"return",
"field",
".",
"name",
"except",
"FieldDoesNotExist",
":",
"# See whether field_name is a nam... | [
441,
4
] | [
461,
59
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.