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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_args | (tmpdir) | Test for inheritance: super class takes positional arg, subclass takes varargs. | Test for inheritance: super class takes positional arg, subclass takes varargs. | def test_args(tmpdir):
""" Test for inheritance: super class takes positional arg, subclass takes varargs. """
hparams = dict(test=1)
model = SubClassVarArgs(hparams)
trainer = Trainer(default_root_dir=tmpdir, max_epochs=1)
trainer.fit(model)
raw_checkpoint_path = _raw_checkpoint_path(trainer)
... | [
"def",
"test_args",
"(",
"tmpdir",
")",
":",
"hparams",
"=",
"dict",
"(",
"test",
"=",
"1",
")",
"model",
"=",
"SubClassVarArgs",
"(",
"hparams",
")",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"max_epochs",
"=",
"1",
")",
... | [
593,
0
] | [
602,
65
] | python | en | ['en', 'en', 'en'] | True |
test_init_arg_with_runtime_change | (tmpdir, cls) | Test that we save/export only the initial hparams, no other runtime change allowed | Test that we save/export only the initial hparams, no other runtime change allowed | def test_init_arg_with_runtime_change(tmpdir, cls):
"""Test that we save/export only the initial hparams, no other runtime change allowed"""
model = cls(running_arg=123)
assert model.hparams.running_arg == 123
model.hparams.running_arg = -1
assert model.hparams.running_arg == -1
model.hparams = ... | [
"def",
"test_init_arg_with_runtime_change",
"(",
"tmpdir",
",",
"cls",
")",
":",
"model",
"=",
"cls",
"(",
"running_arg",
"=",
"123",
")",
"assert",
"model",
".",
"hparams",
".",
"running_arg",
"==",
"123",
"model",
".",
"hparams",
".",
"running_arg",
"=",
... | [
613,
0
] | [
633,
44
] | python | en | ['en', 'en', 'en'] | True |
test_model_save_hyper_parameters_interpolation_with_hydra | (tmpdir) |
This test relies on configuration saved under tests/models/conf/config.yaml
|
This test relies on configuration saved under tests/models/conf/config.yaml
| def test_model_save_hyper_parameters_interpolation_with_hydra(tmpdir):
"""
This test relies on configuration saved under tests/models/conf/config.yaml
"""
class TestHydraModel(BoringModel):
def __init__(self, args_0, args_1, args_2, kwarg_1=None):
self.save_hyperparameters()
... | [
"def",
"test_model_save_hyper_parameters_interpolation_with_hydra",
"(",
"tmpdir",
")",
":",
"class",
"TestHydraModel",
"(",
"BoringModel",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"args_0",
",",
"args_1",
",",
"args_2",
",",
"kwarg_1",
"=",
"None",
")",
"... | [
657,
0
] | [
696,
84
] | python | en | ['en', 'error', 'th'] | False |
log_request | (req: 'flask_request', res: str) | Log details of the web request and the results. | Log details of the web request and the results. | def log_request(req: 'flask_request', res: str) -> None:
"""Log details of the web request and the results."""
# raise Exception("Something awful just happened.")
sleep(15) # This makes log_request really slow...
with UseDatabase(app.config['dbconfig']) as cursor:
_SQL = """insert into l... | [
"def",
"log_request",
"(",
"req",
":",
"'flask_request'",
",",
"res",
":",
"str",
")",
"->",
"None",
":",
"# raise Exception(\"Something awful just happened.\")",
"sleep",
"(",
"15",
")",
"# This makes log_request really slow...",
"with",
"UseDatabase",
"(",
"app",
".... | [
28,
0
] | [
44,
37
] | python | en | ['en', 'en', 'en'] | True |
do_search | () | Extract the posted data; perform the search; return results. | Extract the posted data; perform the search; return results. | def do_search() -> 'html':
"""Extract the posted data; perform the search; return results."""
phrase = request.form['phrase']
letters = request.form['letters']
title = 'Here are your results:'
results = str(search4letters(phrase, letters))
try:
log_request(request, results)
except Ex... | [
"def",
"do_search",
"(",
")",
"->",
"'html'",
":",
"phrase",
"=",
"request",
".",
"form",
"[",
"'phrase'",
"]",
"letters",
"=",
"request",
".",
"form",
"[",
"'letters'",
"]",
"title",
"=",
"'Here are your results:'",
"results",
"=",
"str",
"(",
"search4let... | [
48,
0
] | [
62,
48
] | python | en | ['en', 'en', 'en'] | True |
entry_page | () | Display this webapp's HTML form. | Display this webapp's HTML form. | def entry_page() -> 'html':
"""Display this webapp's HTML form."""
return render_template('entry.html',
the_title='Welcome to search4letters on the web!') | [
"def",
"entry_page",
"(",
")",
"->",
"'html'",
":",
"return",
"render_template",
"(",
"'entry.html'",
",",
"the_title",
"=",
"'Welcome to search4letters on the web!'",
")"
] | [
67,
0
] | [
70,
77
] | python | en | ['en', 'en', 'en'] | True |
view_the_log | () | Display the contents of the log file as a HTML table. | Display the contents of the log file as a HTML table. | def view_the_log() -> 'html':
"""Display the contents of the log file as a HTML table."""
try:
with UseDatabase(app.config['dbconfig']) as cursor:
_SQL = """select phrase, letters, ip, browser_string, results
from log"""
cursor.execute(_SQL)
conten... | [
"def",
"view_the_log",
"(",
")",
"->",
"'html'",
":",
"try",
":",
"with",
"UseDatabase",
"(",
"app",
".",
"config",
"[",
"'dbconfig'",
"]",
")",
"as",
"cursor",
":",
"_SQL",
"=",
"\"\"\"select phrase, letters, ip, browser_string, results\n from log\... | [
75,
0
] | [
97,
18
] | python | en | ['en', 'en', 'en'] | True |
get_confirmation | () | Obtain stdin confirmation to create issues in GH. | Obtain stdin confirmation to create issues in GH. | def get_confirmation():
"""Obtain stdin confirmation to create issues in GH."""
return input('Creates issues? [yN] ').strip().lower() in ('y', 'yes') | [
"def",
"get_confirmation",
"(",
")",
":",
"return",
"input",
"(",
"'Creates issues? [yN] '",
")",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"in",
"(",
"'y'",
",",
"'yes'",
")"
] | [
47,
0
] | [
49,
73
] | python | en | ['en', 'en', 'en'] | True |
create_issues | (access_token, runtime_and_pr) | Create issues in GitHub for code to clean up old runtime guarded features.
Args:
access_token: GitHub access token (see comment at top of file).
runtime_and_pr: a list of runtime guards and the PRs and commits they were added.
| Create issues in GitHub for code to clean up old runtime guarded features. | def create_issues(access_token, runtime_and_pr):
"""Create issues in GitHub for code to clean up old runtime guarded features.
Args:
access_token: GitHub access token (see comment at top of file).
runtime_and_pr: a list of runtime guards and the PRs and commits they were added.
"""
git ... | [
"def",
"create_issues",
"(",
"access_token",
",",
"runtime_and_pr",
")",
":",
"git",
"=",
"github",
".",
"Github",
"(",
"access_token",
")",
"repo",
"=",
"git",
".",
"get_repo",
"(",
"'envoyproxy/envoy'",
")",
"# Find GitHub label objects for LABELS.",
"labels",
"... | [
52,
0
] | [
130,
25
] | python | en | ['en', 'en', 'en'] | True |
get_runtime_and_pr | () | Returns a list of tuples of [runtime features to deprecate, PR, commit the feature was added]
| Returns a list of tuples of [runtime features to deprecate, PR, commit the feature was added]
| def get_runtime_and_pr():
"""Returns a list of tuples of [runtime features to deprecate, PR, commit the feature was added]
"""
repo = Repo(os.getcwd())
# grep source code looking for reloadable features which are true to find the
# PR they were added.
features_to_flip = []
runtime_features... | [
"def",
"get_runtime_and_pr",
"(",
")",
":",
"repo",
"=",
"Repo",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
"# grep source code looking for reloadable features which are true to find the",
"# PR they were added.",
"features_to_flip",
"=",
"[",
"]",
"runtime_features",
"=",
... | [
133,
0
] | [
176,
15
] | python | en | ['en', 'en', 'en'] | True |
perspective_projection | (points, rotation, translation, focal_length,
camera_center) | This function computes the perspective projection of a set of 3D points.
Notes:
batch size: B
point number: N
Args:
points (Tensor([B, N, 3])): A set of 3D points
rotation (Tensor([B, 3, 3])): Camera rotation matrix
translation (Tensor([B, 3])): Camera translation
... | This function computes the perspective projection of a set of 3D points. | def perspective_projection(points, rotation, translation, focal_length,
camera_center):
"""This function computes the perspective projection of a set of 3D points.
Notes:
batch size: B
point number: N
Args:
points (Tensor([B, N, 3])): A set of 3D points
... | [
"def",
"perspective_projection",
"(",
"points",
",",
"rotation",
",",
"translation",
",",
"focal_length",
",",
"camera_center",
")",
":",
"batch_size",
"=",
"points",
".",
"shape",
"[",
"0",
"]",
"K",
"=",
"torch",
".",
"zeros",
"(",
"[",
"batch_size",
","... | [
7,
0
] | [
44,
27
] | python | en | ['en', 'en', 'en'] | True |
test__training_step__flow_scalar | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test__training_step__flow_scalar(tmpdir):
"""
Tests that only training_step can be used
"""
class TestModel(DeterministicModel):
def training_step(self, batch, batch_idx):
acc = self.step(batch, batch_idx)
acc = acc + batch_idx
self.training_step_called ... | [
"def",
"test__training_step__flow_scalar",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"DeterministicModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"acc",
"=",
"self",
".",
"step",
"(",
"batch",
",",
... | [
29,
0
] | [
61,
46
] | python | en | ['en', 'error', 'th'] | False |
test__training_step__tr_step_end__flow_scalar | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test__training_step__tr_step_end__flow_scalar(tmpdir):
"""
Tests that only training_step can be used
"""
class TestModel(DeterministicModel):
def training_step(self, batch, batch_idx):
acc = self.step(batch, batch_idx)
acc = acc + batch_idx
self.training... | [
"def",
"test__training_step__tr_step_end__flow_scalar",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"DeterministicModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"acc",
"=",
"self",
".",
"step",
"(",
"ba... | [
65,
0
] | [
104,
46
] | python | en | ['en', 'error', 'th'] | False |
test__training_step__epoch_end__flow_scalar | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test__training_step__epoch_end__flow_scalar(tmpdir):
"""
Tests that only training_step can be used
"""
class TestModel(DeterministicModel):
def training_step(self, batch, batch_idx):
acc = self.step(batch, batch_idx)
acc = acc + batch_idx
self.training_... | [
"def",
"test__training_step__epoch_end__flow_scalar",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"DeterministicModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"acc",
"=",
"self",
".",
"step",
"(",
"batc... | [
108,
0
] | [
153,
42
] | python | en | ['en', 'error', 'th'] | False |
test__training_step__step_end__epoch_end__flow_scalar | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test__training_step__step_end__epoch_end__flow_scalar(tmpdir):
"""
Tests that only training_step can be used
"""
class TestModel(DeterministicModel):
def training_step(self, batch, batch_idx):
acc = self.step(batch, batch_idx)
acc = acc + batch_idx
self... | [
"def",
"test__training_step__step_end__epoch_end__flow_scalar",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"DeterministicModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"acc",
"=",
"self",
".",
"step",
"(... | [
157,
0
] | [
208,
42
] | python | en | ['en', 'error', 'th'] | False |
test_train_step_no_return | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test_train_step_no_return(tmpdir):
"""
Tests that only training_step can be used
"""
class TestModel(BoringModel):
def training_step(self, batch, batch_idx):
self.training_step_called = True
loss = self.step(batch[0])
self.log('a', loss, on_step=True, on... | [
"def",
"test_train_step_no_return",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"self",
".",
"training_step_called",
"=",
"True",
"loss",
"=",
"se... | [
211,
0
] | [
245,
39
] | python | en | ['en', 'error', 'th'] | False |
test_training_step_no_return_when_even | (tmpdir) |
Tests correctness when some training steps have been skipped
|
Tests correctness when some training steps have been skipped
| def test_training_step_no_return_when_even(tmpdir):
"""
Tests correctness when some training steps have been skipped
"""
class TestModel(BoringModel):
def training_step(self, batch, batch_idx):
self.training_step_called = True
loss = self.step(batch[0])
self... | [
"def",
"test_training_step_no_return_when_even",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"self",
".",
"training_step_called",
"=",
"True",
"loss",... | [
248,
0
] | [
280,
30
] | python | en | ['en', 'error', 'th'] | False |
parse_spectrum_file | (fname) | Checks file extension and calls appropriate parsing method. | Checks file extension and calls appropriate parsing method. | def parse_spectrum_file(fname):
"""Checks file extension and calls appropriate parsing method."""
specdicts = []
with Path(fname).open("r") as sfile:
firstline = sfile.readline()
if fname.split(".")[-1] == "txt":
if "Region" in firstline:
for specdict in parse_eistxt(fname):
... | [
"def",
"parse_spectrum_file",
"(",
"fname",
")",
":",
"specdicts",
"=",
"[",
"]",
"with",
"Path",
"(",
"fname",
")",
".",
"open",
"(",
"\"r\"",
")",
"as",
"sfile",
":",
"firstline",
"=",
"sfile",
".",
"readline",
"(",
")",
"if",
"fname",
".",
"split"... | [
12,
0
] | [
33,
20
] | python | en | ['en', 'en', 'en'] | True |
parse_simple_xy | (fname, delimiter=None) |
Parses the most simple x, y file with no header.
|
Parses the most simple x, y file with no header.
| def parse_simple_xy(fname, delimiter=None):
"""
Parses the most simple x, y file with no header.
"""
energy, intensity = np.genfromtxt(
fname,
delimiter=delimiter,
unpack=True
)
specdict = {
"energy": energy,
"intensity": intensity,
"energy_scale":... | [
"def",
"parse_simple_xy",
"(",
"fname",
",",
"delimiter",
"=",
"None",
")",
":",
"energy",
",",
"intensity",
"=",
"np",
".",
"genfromtxt",
"(",
"fname",
",",
"delimiter",
"=",
"delimiter",
",",
"unpack",
"=",
"True",
")",
"specdict",
"=",
"{",
"\"energy\... | [
35,
0
] | [
49,
19
] | python | en | ['en', 'error', 'th'] | False |
parse_eistxt | (fname) | Splits Omicron EIS txt file. | Splits Omicron EIS txt file. | def parse_eistxt(fname):
"""Splits Omicron EIS txt file."""
splitregex = re.compile(r"^Region.*")
skip_once_regex = re.compile(r"Layer.*")
skip_regex = re.compile(r"^[0-9]+\s*False.*")
split_eislines = []
with Path(fname).open("br") as eisfile:
for line in eisfile:
line = lin... | [
"def",
"parse_eistxt",
"(",
"fname",
")",
":",
"splitregex",
"=",
"re",
".",
"compile",
"(",
"r\"^Region.*\"",
")",
"skip_once_regex",
"=",
"re",
".",
"compile",
"(",
"r\"Layer.*\"",
")",
"skip_regex",
"=",
"re",
".",
"compile",
"(",
"r\"^[0-9]+\\s*False.*\"",... | [
51,
0
] | [
87,
22
] | python | en | ['en', 'ht', 'pt'] | False |
parse_arpestxt | (fname) | Reads a txt file obtained from Elettra's VUV beamline. | Reads a txt file obtained from Elettra's VUV beamline. | def parse_arpestxt(fname):
"""Reads a txt file obtained from Elettra's VUV beamline."""
properties = {}
energy = []
intensity = []
is_data = False
databegin_regex = re.compile(r"^\[Data [0-9]+\]")
datarow_regex = re.compile(
r"^\s[0-9]+\.?[0-9]*(E\+)?[0-9]*\s*[0-9]+\.?[0-9]*(E\+)?[0-... | [
"def",
"parse_arpestxt",
"(",
"fname",
")",
":",
"properties",
"=",
"{",
"}",
"energy",
"=",
"[",
"]",
"intensity",
"=",
"[",
"]",
"is_data",
"=",
"False",
"databegin_regex",
"=",
"re",
".",
"compile",
"(",
"r\"^\\[Data [0-9]+\\]\"",
")",
"datarow_regex",
... | [
90,
0
] | [
127,
19
] | python | en | ['en', 'en', 'en'] | True |
get_element_info | (element, source) | Yields tuples containing the element name, orbital, its binding energy and rsf.
For Auger peaks, RSF is zero. | Yields tuples containing the element name, orbital, its binding energy and rsf.
For Auger peaks, RSF is zero. | def get_element_info(element, source):
"""Yields tuples containing the element name, orbital, its binding energy and rsf.
For Auger peaks, RSF is zero."""
try:
photon_energy = float(source)
except ValueError:
photon_energy = PHOTON_ENERGIES.get(source, 0)
dbfname = os.path.dirname(__... | [
"def",
"get_element_info",
"(",
"element",
",",
"source",
")",
":",
"try",
":",
"photon_energy",
"=",
"float",
"(",
"source",
")",
"except",
"ValueError",
":",
"photon_energy",
"=",
"PHOTON_ENERGIES",
".",
"get",
"(",
"source",
",",
"0",
")",
"dbfname",
"=... | [
134,
0
] | [
157,
63
] | python | en | ['en', 'en', 'en'] | True |
export_txt | (fname, spectrum) | Export given spectra and everything that belongs to it as txt. | Export given spectra and everything that belongs to it as txt. | def export_txt(fname, spectrum):
"""Export given spectra and everything that belongs to it as txt."""
column_stack = [
spectrum.energy,
spectrum.intensity,
]
name = re.sub(r"\s+", "_", spectrum.name)
header = "{:_<15}_Energy\t{:_<14}_intensity\t".format(name, name)
if spectrum.ba... | [
"def",
"export_txt",
"(",
"fname",
",",
"spectrum",
")",
":",
"column_stack",
"=",
"[",
"spectrum",
".",
"energy",
",",
"spectrum",
".",
"intensity",
",",
"]",
"name",
"=",
"re",
".",
"sub",
"(",
"r\"\\s+\"",
",",
"\"_\"",
",",
"spectrum",
".",
"name",... | [
160,
0
] | [
179,
58
] | python | en | ['en', 'en', 'en'] | True |
export_params | (fname, spectrum) | Export given spectra and everything that belongs to it as txt. | Export given spectra and everything that belongs to it as txt. | def export_params(fname, spectrum):
"""Export given spectra and everything that belongs to it as txt."""
params = ("area", "fwhm", "position", "alpha", "beta", "gamma")
header = "\t".join(params)
data = []
for peak in spectrum.peaks:
row = []
row.append(peak.label)
row.append... | [
"def",
"export_params",
"(",
"fname",
",",
"spectrum",
")",
":",
"params",
"=",
"(",
"\"area\"",
",",
"\"fwhm\"",
",",
"\"position\"",
",",
"\"alpha\"",
",",
"\"beta\"",
",",
"\"gamma\"",
")",
"header",
"=",
"\"\\t\"",
".",
"join",
"(",
"params",
")",
"d... | [
182,
0
] | [
195,
68
] | python | en | ['en', 'en', 'en'] | True |
UseDatabase.__init__ | (self, config: dict) | Add the database configuration parameters to the object.
This class expects a single dictionary argument which needs to assign
the appropriate values to (at least) the following keys:
host - the IP address of the host running MySQL/MariaDB.
user - the MySQL/MariaDB username to ... | Add the database configuration parameters to the object. | def __init__(self, config: dict):
"""Add the database configuration parameters to the object.
This class expects a single dictionary argument which needs to assign
the appropriate values to (at least) the following keys:
host - the IP address of the host running MySQL/MariaDB.
... | [
"def",
"__init__",
"(",
"self",
",",
"config",
":",
"dict",
")",
":",
"self",
".",
"configuration",
"=",
"config"
] | [
30,
4
] | [
43,
35
] | python | en | ['en', 'en', 'en'] | True |
UseDatabase.__enter__ | (self) | Connect to database and create a DB cursor.
Return the database cursor to the context manager.
| Connect to database and create a DB cursor. | def __enter__(self) -> 'cursor':
"""Connect to database and create a DB cursor.
Return the database cursor to the context manager.
"""
self.conn = mysql.connector.connect(**self.configuration)
self.cursor = self.conn.cursor()
return self.cursor | [
"def",
"__enter__",
"(",
"self",
")",
"->",
"'cursor'",
":",
"self",
".",
"conn",
"=",
"mysql",
".",
"connector",
".",
"connect",
"(",
"*",
"*",
"self",
".",
"configuration",
")",
"self",
".",
"cursor",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
... | [
45,
4
] | [
52,
26
] | python | en | ['en', 'en', 'en'] | True |
UseDatabase.__exit__ | (self, exc_type, exc_value, exc_traceback) | Destroy the cursor as well as the connection (after committing).
| Destroy the cursor as well as the connection (after committing).
| def __exit__(self, exc_type, exc_value, exc_traceback):
"""Destroy the cursor as well as the connection (after committing).
"""
self.conn.commit()
self.cursor.close()
self.conn.close() | [
"def",
"__exit__",
"(",
"self",
",",
"exc_type",
",",
"exc_value",
",",
"exc_traceback",
")",
":",
"self",
".",
"conn",
".",
"commit",
"(",
")",
"self",
".",
"cursor",
".",
"close",
"(",
")",
"self",
".",
"conn",
".",
"close",
"(",
")"
] | [
54,
4
] | [
59,
25
] | python | en | ['en', 'en', 'en'] | True |
nms | (dets, thr) | Greedily select boxes with high confidence and overlap <= thr.
Args:
dets: [[x1, y1, x2, y2, score]].
thr: Retain overlap < thr.
Returns:
list: Indexes to keep.
| Greedily select boxes with high confidence and overlap <= thr. | def nms(dets, thr):
"""Greedily select boxes with high confidence and overlap <= thr.
Args:
dets: [[x1, y1, x2, y2, score]].
thr: Retain overlap < thr.
Returns:
list: Indexes to keep.
"""
if len(dets) == 0:
return []
x1 = dets[:, 0]
y1 = dets[:, 1]
x2 ... | [
"def",
"nms",
"(",
"dets",
",",
"thr",
")",
":",
"if",
"len",
"(",
"dets",
")",
"==",
"0",
":",
"return",
"[",
"]",
"x1",
"=",
"dets",
"[",
":",
",",
"0",
"]",
"y1",
"=",
"dets",
"[",
":",
",",
"1",
"]",
"x2",
"=",
"dets",
"[",
":",
","... | [
8,
0
] | [
47,
15
] | python | en | ['en', 'en', 'en'] | True |
oks_iou | (g, d, a_g, a_d, sigmas=None, vis_thr=None) | Calculate oks ious.
Args:
g: Ground truth keypoints.
d: Detected keypoints.
a_g: Area of the ground truth object.
a_d: Area of the detected object.
sigmas: standard deviation of keypoint labelling.
vis_thr: threshold of the keypoint visibility.
Returns:
... | Calculate oks ious. | def oks_iou(g, d, a_g, a_d, sigmas=None, vis_thr=None):
"""Calculate oks ious.
Args:
g: Ground truth keypoints.
d: Detected keypoints.
a_g: Area of the ground truth object.
a_d: Area of the detected object.
sigmas: standard deviation of keypoint labelling.
vis_th... | [
"def",
"oks_iou",
"(",
"g",
",",
"d",
",",
"a_g",
",",
"a_d",
",",
"sigmas",
"=",
"None",
",",
"vis_thr",
"=",
"None",
")",
":",
"if",
"sigmas",
"is",
"None",
":",
"sigmas",
"=",
"np",
".",
"array",
"(",
"[",
".26",
",",
".25",
",",
".25",
",... | [
50,
0
] | [
85,
15
] | python | en | ['en', 'ga', 'en'] | True |
oks_nms | (kpts_db, thr, sigmas=None, vis_thr=None) | OKS NMS implementations.
Args:
kpts_db: keypoints.
thr: Retain overlap < thr.
sigmas: standard deviation of keypoint labelling.
vis_thr: threshold of the keypoint visibility.
Returns:
np.ndarray: indexes to keep.
| OKS NMS implementations. | def oks_nms(kpts_db, thr, sigmas=None, vis_thr=None):
"""OKS NMS implementations.
Args:
kpts_db: keypoints.
thr: Retain overlap < thr.
sigmas: standard deviation of keypoint labelling.
vis_thr: threshold of the keypoint visibility.
Returns:
np.ndarray: indexes to ke... | [
"def",
"oks_nms",
"(",
"kpts_db",
",",
"thr",
",",
"sigmas",
"=",
"None",
",",
"vis_thr",
"=",
"None",
")",
":",
"if",
"len",
"(",
"kpts_db",
")",
"==",
"0",
":",
"return",
"[",
"]",
"scores",
"=",
"np",
".",
"array",
"(",
"[",
"k",
"[",
"'scor... | [
88,
0
] | [
122,
15
] | python | en | ['en', 'en', 'en'] | True |
_rescore | (overlap, scores, thr, type='gaussian') | Rescoring mechanism gaussian or linear.
Args:
overlap: calculated ious
scores: target scores.
thr: retain oks overlap < thr.
type: 'gaussian' or 'linear'
Returns:
np.ndarray: indexes to keep
| Rescoring mechanism gaussian or linear. | def _rescore(overlap, scores, thr, type='gaussian'):
"""Rescoring mechanism gaussian or linear.
Args:
overlap: calculated ious
scores: target scores.
thr: retain oks overlap < thr.
type: 'gaussian' or 'linear'
Returns:
np.ndarray: indexes to keep
"""
assert ... | [
"def",
"_rescore",
"(",
"overlap",
",",
"scores",
",",
"thr",
",",
"type",
"=",
"'gaussian'",
")",
":",
"assert",
"len",
"(",
"overlap",
")",
"==",
"len",
"(",
"scores",
")",
"assert",
"type",
"in",
"[",
"'gaussian'",
",",
"'linear'",
"]",
"if",
"typ... | [
125,
0
] | [
146,
17
] | python | en | ['en', 'lb', 'en'] | True |
soft_oks_nms | (kpts_db, thr, max_dets=20, sigmas=None, vis_thr=None) | Soft OKS NMS implementations.
Args:
kpts_db
thr: retain oks overlap < thr.
max_dets: max number of detections to keep.
sigmas: Keypoint labelling uncertainty.
Returns:
np.ndarray: indexes to keep.
| Soft OKS NMS implementations. | def soft_oks_nms(kpts_db, thr, max_dets=20, sigmas=None, vis_thr=None):
"""Soft OKS NMS implementations.
Args:
kpts_db
thr: retain oks overlap < thr.
max_dets: max number of detections to keep.
sigmas: Keypoint labelling uncertainty.
Returns:
np.ndarray: indexes to ... | [
"def",
"soft_oks_nms",
"(",
"kpts_db",
",",
"thr",
",",
"max_dets",
"=",
"20",
",",
"sigmas",
"=",
"None",
",",
"vis_thr",
"=",
"None",
")",
":",
"if",
"len",
"(",
"kpts_db",
")",
"==",
"0",
":",
"return",
"[",
"]",
"scores",
"=",
"np",
".",
"arr... | [
149,
0
] | [
191,
15
] | python | en | ['en', 'en', 'en'] | True |
MagnetometerStatus.overrun | (self) | data overrun on all axes | data overrun on all axes | def overrun(self) -> bool:
"""data overrun on all axes"""
return (self.status & 0x80) != 0 | [
"def",
"overrun",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"(",
"self",
".",
"status",
"&",
"0x80",
")",
"!=",
"0"
] | [
5,
4
] | [
7,
40
] | python | en | ['en', 'fi', 'en'] | True |
MagnetometerStatus.z_overrun | (self) | Z axis data overrun | Z axis data overrun | def z_overrun(self) -> bool:
"""Z axis data overrun"""
return (self.status & 0x40) != 0 | [
"def",
"z_overrun",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"(",
"self",
".",
"status",
"&",
"0x40",
")",
"!=",
"0"
] | [
10,
4
] | [
12,
40
] | python | en | ['en', 'fi', 'nl'] | False |
MagnetometerStatus.y_overrun | (self) | Y axis data overrun | Y axis data overrun | def y_overrun(self) -> bool:
"""Y axis data overrun"""
return (self.status & 0x20) != 0 | [
"def",
"y_overrun",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"(",
"self",
".",
"status",
"&",
"0x20",
")",
"!=",
"0"
] | [
15,
4
] | [
17,
40
] | python | en | ['en', 'so', 'en'] | True |
MagnetometerStatus.x_overrun | (self) | X axis data overrun | X axis data overrun | def x_overrun(self) -> bool:
"""X axis data overrun"""
return (self.status & 0x10) != 0 | [
"def",
"x_overrun",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"(",
"self",
".",
"status",
"&",
"0x10",
")",
"!=",
"0"
] | [
20,
4
] | [
22,
40
] | python | en | ['en', 'fi', 'en'] | True |
MagnetometerStatus.data_available | (self) | There's new data available for all axes. | There's new data available for all axes. | def data_available(self) -> bool:
"""There's new data available for all axes."""
return (self.status & 0x08) != 0 | [
"def",
"data_available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"(",
"self",
".",
"status",
"&",
"0x08",
")",
"!=",
"0"
] | [
25,
4
] | [
27,
40
] | python | en | ['en', 'en', 'en'] | True |
to_classname | (filename: str) |
maps divided mock class file name to class names
inverse function of headersplit.to_filename
e.g. map "test/mocks/server/admin_stream.h" to "MockAdminStream"
Args:
filename: string, mock class header file name (might be the whole path instead of the base name)
Returns:
correspondi... |
maps divided mock class file name to class names
inverse function of headersplit.to_filename
e.g. map "test/mocks/server/admin_stream.h" to "MockAdminStream" | def to_classname(filename: str) -> str:
"""
maps divided mock class file name to class names
inverse function of headersplit.to_filename
e.g. map "test/mocks/server/admin_stream.h" to "MockAdminStream"
Args:
filename: string, mock class header file name (might be the whole path instead of t... | [
"def",
"to_classname",
"(",
"filename",
":",
"str",
")",
"->",
"str",
":",
"classname_tokens",
"=",
"filename",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
".",
"replace",
"(",
"'.h'",
",",
"''",
")",
".",
"split",
"(",
"'_'",
")",
"classnam... | [
20,
0
] | [
34,
20
] | python | en | ['en', 'error', 'th'] | False |
to_bazelname | (filename: str, mockname: str) |
maps divided mock class file name to bazel target name
e.g. map "test/mocks/server/admin_stream.h" to "//test/mocks/server:admin_stream_mocks"
Args:
filename: string, mock class header file name (might be the whole path instead of the base name)
mockname: string, mock directory name
R... |
maps divided mock class file name to bazel target name
e.g. map "test/mocks/server/admin_stream.h" to "//test/mocks/server:admin_stream_mocks" | def to_bazelname(filename: str, mockname: str) -> str:
"""
maps divided mock class file name to bazel target name
e.g. map "test/mocks/server/admin_stream.h" to "//test/mocks/server:admin_stream_mocks"
Args:
filename: string, mock class header file name (might be the whole path instead of the b... | [
"def",
"to_bazelname",
"(",
"filename",
":",
"str",
",",
"mockname",
":",
"str",
")",
"->",
"str",
":",
"bazelname",
"=",
"\"//test/mocks/{}:\"",
".",
"format",
"(",
"mockname",
")",
"bazelname",
"+=",
"filename",
".",
"split",
"(",
"'/'",
")",
"[",
"-",... | [
37,
0
] | [
51,
20
] | python | en | ['en', 'error', 'th'] | False |
get_filenames | (mockname: str) |
scans all headers in test/mocks/{mockname}, return corresponding file names
Args:
mockname: string, mock directory name
Returns:
List of file name for the headers in test/mock/{mocksname}
|
scans all headers in test/mocks/{mockname}, return corresponding file names | def get_filenames(mockname: str) -> List[str]:
"""
scans all headers in test/mocks/{mockname}, return corresponding file names
Args:
mockname: string, mock directory name
Returns:
List of file name for the headers in test/mock/{mocksname}
"""
dir = Path("test/mocks/{}/".format(... | [
"def",
"get_filenames",
"(",
"mockname",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"dir",
"=",
"Path",
"(",
"\"test/mocks/{}/\"",
".",
"format",
"(",
"mockname",
")",
")",
"filenames",
"=",
"list",
"(",
"map",
"(",
"str",
",",
"dir",
".",
... | [
54,
0
] | [
66,
20
] | python | en | ['en', 'error', 'th'] | False |
test__training_step__log | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test__training_step__log(tmpdir):
"""
Tests that only training_step can be used
"""
class TestModel(DeterministicModel):
def training_step(self, batch, batch_idx):
acc = self.step(batch, batch_idx)
acc = acc + batch_idx
# -----------
# defau... | [
"def",
"test__training_step__log",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"DeterministicModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"acc",
"=",
"self",
".",
"step",
"(",
"batch",
",",
"batch... | [
36,
0
] | [
129,
56
] | python | en | ['en', 'error', 'th'] | False |
test__training_step__epoch_end__log | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test__training_step__epoch_end__log(tmpdir):
"""
Tests that only training_step can be used
"""
class TestModel(DeterministicModel):
def training_step(self, batch, batch_idx):
self.training_step_called = True
acc = self.step(batch, batch_idx)
acc = acc + ... | [
"def",
"test__training_step__epoch_end__log",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"DeterministicModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"self",
".",
"training_step_called",
"=",
"True",
"ac... | [
133,
0
] | [
190,
56
] | python | en | ['en', 'error', 'th'] | False |
test__training_step__step_end__epoch_end__log | (tmpdir, batches, log_interval, max_epochs) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test__training_step__step_end__epoch_end__log(tmpdir, batches, log_interval, max_epochs):
"""
Tests that only training_step can be used
"""
class TestModel(BoringModel):
def training_step(self, batch, batch_idx):
self.training_step_called = True
loss = self.step(bat... | [
"def",
"test__training_step__step_end__epoch_end__log",
"(",
"tmpdir",
",",
"batches",
",",
"log_interval",
",",
"max_epochs",
")",
":",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
... | [
195,
0
] | [
255,
107
] | python | en | ['en', 'error', 'th'] | False |
test__training_step__log_max_reduce_fx | (tmpdir, batches, fx, result) |
Tests that log works correctly with different tensor types
|
Tests that log works correctly with different tensor types
| def test__training_step__log_max_reduce_fx(tmpdir, batches, fx, result):
"""
Tests that log works correctly with different tensor types
"""
class TestModel(BoringModel):
def training_step(self, batch, batch_idx):
acc = self.step(batch[0])
self.log('foo', torch.tensor(ba... | [
"def",
"test__training_step__log_max_reduce_fx",
"(",
"tmpdir",
",",
"batches",
",",
"fx",
",",
"result",
")",
":",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"acc",
"=",... | [
259,
0
] | [
289,
50
] | python | en | ['en', 'error', 'th'] | False |
test_tbptt_log | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test_tbptt_log(tmpdir):
"""
Tests that only training_step can be used
"""
truncated_bptt_steps = 2
sequence_size = 30
batch_size = 30
x_seq = torch.rand(batch_size, sequence_size, 1)
y_seq_list = torch.rand(batch_size, sequence_size, 1).tolist()
class MockSeq2SeqDataset(torch.u... | [
"def",
"test_tbptt_log",
"(",
"tmpdir",
")",
":",
"truncated_bptt_steps",
"=",
"2",
"sequence_size",
"=",
"30",
"batch_size",
"=",
"30",
"x_seq",
"=",
"torch",
".",
"rand",
"(",
"batch_size",
",",
"sequence_size",
",",
"1",
")",
"y_seq_list",
"=",
"torch",
... | [
292,
0
] | [
368,
32
] | python | en | ['en', 'error', 'th'] | False |
test_log_works_in_train_callback | (tmpdir) |
Tests that log can be called within callback
|
Tests that log can be called within callback
| def test_log_works_in_train_callback(tmpdir):
"""
Tests that log can be called within callback
"""
class TestCallback(callbacks.Callback):
# helpers
count = 1
choices = [False, True]
# used to compute expected values
callback_funcs_called = collections.defaultdi... | [
"def",
"test_log_works_in_train_callback",
"(",
"tmpdir",
")",
":",
"class",
"TestCallback",
"(",
"callbacks",
".",
"Callback",
")",
":",
"# helpers",
"count",
"=",
"1",
"choices",
"=",
"[",
"False",
",",
"True",
"]",
"# used to compute expected values",
"callback... | [
502,
0
] | [
695,
81
] | python | en | ['en', 'error', 'th'] | False |
test_logging_sync_dist_true_cpu | (tmpdir) |
Tests to ensure that the sync_dist flag works with CPU (should just return the original value)
|
Tests to ensure that the sync_dist flag works with CPU (should just return the original value)
| def test_logging_sync_dist_true_cpu(tmpdir):
"""
Tests to ensure that the sync_dist flag works with CPU (should just return the original value)
"""
fake_result = 1
class TestModel(BoringModel):
def training_step(self, batch, batch_idx):
acc = self.step(batch[0])
sel... | [
"def",
"test_logging_sync_dist_true_cpu",
"(",
"tmpdir",
")",
":",
"fake_result",
"=",
"1",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"acc",
"=",
"self",
".",
"step",
... | [
698,
0
] | [
730,
55
] | python | en | ['en', 'error', 'th'] | False |
test_logging_sync_dist_true_ddp | (tmpdir) |
Tests to ensure that the sync_dist flag works with ddp
|
Tests to ensure that the sync_dist flag works with ddp
| def test_logging_sync_dist_true_ddp(tmpdir):
"""
Tests to ensure that the sync_dist flag works with ddp
"""
class TestLoggingSyncDistModel(BoringModel):
def training_step(self, batch, batch_idx):
acc = self.step(batch[0])
self.log('foo', 1, on_step=False, on_epoch=True,... | [
"def",
"test_logging_sync_dist_true_ddp",
"(",
"tmpdir",
")",
":",
"class",
"TestLoggingSyncDistModel",
"(",
"BoringModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"acc",
"=",
"self",
".",
"step",
"(",
"batch",
... | [
737,
0
] | [
770,
45
] | python | en | ['en', 'error', 'th'] | False |
test_logging_sync_dist_true_gpu | (tmpdir) |
Tests to ensure that the sync_dist flag works with GPU (should just return the original value)
|
Tests to ensure that the sync_dist flag works with GPU (should just return the original value)
| def test_logging_sync_dist_true_gpu(tmpdir):
"""
Tests to ensure that the sync_dist flag works with GPU (should just return the original value)
"""
fake_result = 1
class TestModel(BoringModel):
def training_step(self, batch, batch_idx):
acc = self.step(batch[0])
sel... | [
"def",
"test_logging_sync_dist_true_gpu",
"(",
"tmpdir",
")",
":",
"fake_result",
"=",
"1",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"acc",
"=",
"self",
".",
"step",
... | [
774,
0
] | [
805,
55
] | python | en | ['en', 'error', 'th'] | False |
test_logging_in_callbacks_with_log_function | (tmpdir) |
Tests ensure self.log can be used directly in callbacks.
|
Tests ensure self.log can be used directly in callbacks.
| def test_logging_in_callbacks_with_log_function(tmpdir):
"""
Tests ensure self.log can be used directly in callbacks.
"""
class LoggingCallback(callbacks.Callback):
def on_train_start(self, trainer, pl_module):
self.log("on_train_start", 1)
def on_train_epoch_start(self, t... | [
"def",
"test_logging_in_callbacks_with_log_function",
"(",
"tmpdir",
")",
":",
"class",
"LoggingCallback",
"(",
"callbacks",
".",
"Callback",
")",
":",
"def",
"on_train_start",
"(",
"self",
",",
"trainer",
",",
"pl_module",
")",
":",
"self",
".",
"log",
"(",
"... | [
849,
0
] | [
894,
47
] | python | en | ['en', 'error', 'th'] | False |
VariablesClassTests.test_get_all_variables | (self) | Returns a dictionary listing all the functions on the class that
have been decorated as variables, with some of the data about them.
| Returns a dictionary listing all the functions on the class that
have been decorated as variables, with some of the data about them.
| def test_get_all_variables(self):
"""Returns a dictionary listing all the functions on the class that
have been decorated as variables, with some of the data about them.
"""
class SomeVariables(BaseVariables):
@rule_variable(StringType)
def this_is_rule_1(self):
... | [
"def",
"test_get_all_variables",
"(",
"self",
")",
":",
"class",
"SomeVariables",
"(",
"BaseVariables",
")",
":",
"@",
"rule_variable",
"(",
"StringType",
")",
"def",
"this_is_rule_1",
"(",
"self",
")",
":",
"return",
"\"blah\"",
"def",
"non_rule",
"(",
"self"... | [
12,
4
] | [
33,
69
] | python | en | ['en', 'en', 'en'] | True |
run_main | (comline_list) |
Equivalent to running::
f2py <args>
where ``<args>=string.join(<list>,' ')``, but in Python. Unless
``-h`` is used, this function returns a dictionary containing
information on generated modules and their dependencies on source
files. For example, the command ``f2py -m scalar scalar.f``... |
Equivalent to running:: | def run_main(comline_list):
"""
Equivalent to running::
f2py <args>
where ``<args>=string.join(<list>,' ')``, but in Python. Unless
``-h`` is used, this function returns a dictionary containing
information on generated modules and their dependencies on source
files. For example, the ... | [
"def",
"run_main",
"(",
"comline_list",
")",
":",
"crackfortran",
".",
"reset_global_f2py_vars",
"(",
")",
"f2pydir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"cfuncs",
".",
"__file__",
")",
")",
"fobjhsrc",
"=... | [
397,
0
] | [
460,
14
] | python | en | ['en', 'error', 'th'] | False |
filter_files | (prefix, suffix, files, remove_prefix=None) |
Filter files by prefix and suffix.
|
Filter files by prefix and suffix.
| def filter_files(prefix, suffix, files, remove_prefix=None):
"""
Filter files by prefix and suffix.
"""
filtered, rest = [], []
match = re.compile(prefix + r'.*' + suffix + r'\Z').match
if remove_prefix:
ind = len(prefix)
else:
ind = 0
for file in [x.strip() for x in file... | [
"def",
"filter_files",
"(",
"prefix",
",",
"suffix",
",",
"files",
",",
"remove_prefix",
"=",
"None",
")",
":",
"filtered",
",",
"rest",
"=",
"[",
"]",
",",
"[",
"]",
"match",
"=",
"re",
".",
"compile",
"(",
"prefix",
"+",
"r'.*'",
"+",
"suffix",
"... | [
463,
0
] | [
478,
25
] | python | en | ['en', 'error', 'th'] | False |
run_compile | () |
Do it all in one call!
|
Do it all in one call!
| def run_compile():
"""
Do it all in one call!
"""
import tempfile
i = sys.argv.index('-c')
del sys.argv[i]
remove_build_dir = 0
try:
i = sys.argv.index('--build-dir')
except ValueError:
i = None
if i is not None:
build_dir = sys.argv[i + 1]
del s... | [
"def",
"run_compile",
"(",
")",
":",
"import",
"tempfile",
"i",
"=",
"sys",
".",
"argv",
".",
"index",
"(",
"'-c'",
")",
"del",
"sys",
".",
"argv",
"[",
"i",
"]",
"remove_build_dir",
"=",
"0",
"try",
":",
"i",
"=",
"sys",
".",
"argv",
".",
"index... | [
486,
0
] | [
654,
32
] | python | en | ['en', 'error', 'th'] | False |
UnixCCompiler__compile | (self, obj, src, ext, cc_args, extra_postargs, pp_opts) | Compile a single source files with a Unix-style compiler. | Compile a single source files with a Unix-style compiler. | def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
"""Compile a single source files with a Unix-style compiler."""
# HP ad-hoc fix, see ticket 1383
ccomp = self.compiler_so
if ccomp[0] == 'aCC':
# remove flags that will trigger ANSI-C mode for aCC
if '-Ae'... | [
"def",
"UnixCCompiler__compile",
"(",
"self",
",",
"obj",
",",
"src",
",",
"ext",
",",
"cc_args",
",",
"extra_postargs",
",",
"pp_opts",
")",
":",
"# HP ad-hoc fix, see ticket 1383",
"ccomp",
"=",
"self",
".",
"compiler_so",
"if",
"ccomp",
"[",
"0",
"]",
"==... | [
20,
0
] | [
65,
78
] | python | en | ['en', 'en', 'en'] | True |
UnixCCompiler_create_static_lib | (self, objects, output_libname,
output_dir=None, debug=0, target_lang=None) |
Build a static library in a separate sub-process.
Parameters
----------
objects : list or tuple of str
List of paths to object files used to build the static library.
output_libname : str
The library name as an absolute or relative (if `output_dir` is used)
path.
output... |
Build a static library in a separate sub-process. | def UnixCCompiler_create_static_lib(self, objects, output_libname,
output_dir=None, debug=0, target_lang=None):
"""
Build a static library in a separate sub-process.
Parameters
----------
objects : list or tuple of str
List of paths to object files used t... | [
"def",
"UnixCCompiler_create_static_lib",
"(",
"self",
",",
"objects",
",",
"output_libname",
",",
"output_dir",
"=",
"None",
",",
"debug",
"=",
"0",
",",
"target_lang",
"=",
"None",
")",
":",
"objects",
",",
"output_dir",
"=",
"self",
".",
"_fix_object_args",... | [
70,
0
] | [
135,
10
] | python | en | ['en', 'error', 'th'] | False |
HourglassModule.forward | (self, x) | Model forward function. | Model forward function. | def forward(self, x):
"""Model forward function."""
up1 = self.up1(x)
low1 = self.low1(x)
low2 = self.low2(low1)
low3 = self.low3(low2)
up2 = self.up2(low3)
return up1 + up2 | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"up1",
"=",
"self",
".",
"up1",
"(",
"x",
")",
"low1",
"=",
"self",
".",
"low1",
"(",
"x",
")",
"low2",
"=",
"self",
".",
"low2",
"(",
"low1",
")",
"low3",
"=",
"self",
".",
"low3",
"(",
"l... | [
76,
4
] | [
83,
24
] | python | en | ['en', 'no', 'en'] | True |
_needs_build | (obj, cc_args, extra_postargs, pp_opts) |
Check if an objects needs to be rebuild based on its dependencies
Parameters
----------
obj : str
object file
Returns
-------
bool
|
Check if an objects needs to be rebuild based on its dependencies | def _needs_build(obj, cc_args, extra_postargs, pp_opts):
"""
Check if an objects needs to be rebuild based on its dependencies
Parameters
----------
obj : str
object file
Returns
-------
bool
"""
# defined in unixcompiler.py
dep_file = obj + '.d'
if not os.path.... | [
"def",
"_needs_build",
"(",
"obj",
",",
"cc_args",
",",
"extra_postargs",
",",
"pp_opts",
")",
":",
"# defined in unixcompiler.py",
"dep_file",
"=",
"obj",
"+",
"'.d'",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dep_file",
")",
":",
"return",
"Tr... | [
36,
0
] | [
83,
16
] | python | en | ['en', 'error', 'th'] | False |
CCompiler_find_executables | (self) |
Does nothing here, but is called by the get_version method and can be
overridden by subclasses. In particular it is redefined in the `FCompiler`
class where more documentation can be found.
|
Does nothing here, but is called by the get_version method and can be
overridden by subclasses. In particular it is redefined in the `FCompiler`
class where more documentation can be found. | def CCompiler_find_executables(self):
"""
Does nothing here, but is called by the get_version method and can be
overridden by subclasses. In particular it is redefined in the `FCompiler`
class where more documentation can be found.
"""
pass | [
"def",
"CCompiler_find_executables",
"(",
"self",
")",
":",
"pass"
] | [
100,
0
] | [
107,
8
] | python | en | ['en', 'error', 'th'] | False |
CCompiler_spawn | (self, cmd, display=None) |
Execute a command in a sub-process.
Parameters
----------
cmd : str
The command to execute.
display : str or sequence of str, optional
The text to add to the log file kept by `numpy.distutils`.
If not given, `display` is equal to `cmd`.
Returns
-------
None
... |
Execute a command in a sub-process. | def CCompiler_spawn(self, cmd, display=None):
"""
Execute a command in a sub-process.
Parameters
----------
cmd : str
The command to execute.
display : str or sequence of str, optional
The text to add to the log file kept by `numpy.distutils`.
If not given, `display` is ... | [
"def",
"CCompiler_spawn",
"(",
"self",
",",
"cmd",
",",
"display",
"=",
"None",
")",
":",
"if",
"display",
"is",
"None",
":",
"display",
"=",
"cmd",
"if",
"is_sequence",
"(",
"display",
")",
":",
"display",
"=",
"' '",
".",
"join",
"(",
"list",
"(",
... | [
114,
0
] | [
171,
42
] | python | en | ['en', 'error', 'th'] | False |
CCompiler_object_filenames | (self, source_filenames, strip_dir=0, output_dir='') |
Return the name of the object files for the given source files.
Parameters
----------
source_filenames : list of str
The list of paths to source files. Paths can be either relative or
absolute, this is handled transparently.
strip_dir : bool, optional
Whether to strip the d... |
Return the name of the object files for the given source files. | def CCompiler_object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
"""
Return the name of the object files for the given source files.
Parameters
----------
source_filenames : list of str
The list of paths to source files. Paths can be either relative or
absolute, t... | [
"def",
"CCompiler_object_filenames",
"(",
"self",
",",
"source_filenames",
",",
"strip_dir",
"=",
"0",
",",
"output_dir",
"=",
"''",
")",
":",
"if",
"output_dir",
"is",
"None",
":",
"output_dir",
"=",
"''",
"obj_names",
"=",
"[",
"]",
"for",
"src_name",
"i... | [
175,
0
] | [
218,
20
] | python | en | ['en', 'error', 'th'] | False |
CCompiler_compile | (self, sources, output_dir=None, macros=None,
include_dirs=None, debug=0, extra_preargs=None,
extra_postargs=None, depends=None) |
Compile one or more source files.
Please refer to the Python distutils API reference for more details.
Parameters
----------
sources : list of str
A list of filenames
output_dir : str, optional
Path to the output directory.
macros : list of tuples
A list of macro d... |
Compile one or more source files. | def CCompiler_compile(self, sources, output_dir=None, macros=None,
include_dirs=None, debug=0, extra_preargs=None,
extra_postargs=None, depends=None):
"""
Compile one or more source files.
Please refer to the Python distutils API reference for more details.
... | [
"def",
"CCompiler_compile",
"(",
"self",
",",
"sources",
",",
"output_dir",
"=",
"None",
",",
"macros",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"debug",
"=",
"0",
",",
"extra_preargs",
"=",
"None",
",",
"extra_postargs",
"=",
"None",
",",
"de... | [
222,
0
] | [
365,
18
] | python | en | ['en', 'error', 'th'] | False |
CCompiler_customize_cmd | (self, cmd, ignore=()) |
Customize compiler using distutils command.
Parameters
----------
cmd : class instance
An instance inheriting from `distutils.cmd.Command`.
ignore : sequence of str, optional
List of `CCompiler` commands (without ``'set_'``) that should not be
altered. Strings that are chec... |
Customize compiler using distutils command. | def CCompiler_customize_cmd(self, cmd, ignore=()):
"""
Customize compiler using distutils command.
Parameters
----------
cmd : class instance
An instance inheriting from `distutils.cmd.Command`.
ignore : sequence of str, optional
List of `CCompiler` commands (without ``'set_'``)... | [
"def",
"CCompiler_customize_cmd",
"(",
"self",
",",
"cmd",
",",
"ignore",
"=",
"(",
")",
")",
":",
"log",
".",
"info",
"(",
"'customize %s using %s'",
"%",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"cmd",
".",
"__class__",
".",
"__name__",
")"... | [
369,
0
] | [
408,
47
] | python | en | ['en', 'error', 'th'] | False |
CCompiler_show_customization | (self) |
Print the compiler customizations to stdout.
Parameters
----------
None
Returns
-------
None
Notes
-----
Printing is only done if the distutils log threshold is < 2.
|
Print the compiler customizations to stdout. | def CCompiler_show_customization(self):
"""
Print the compiler customizations to stdout.
Parameters
----------
None
Returns
-------
None
Notes
-----
Printing is only done if the distutils log threshold is < 2.
"""
if 0:
for attrname in ['include_dirs', 'de... | [
"def",
"CCompiler_show_customization",
"(",
"self",
")",
":",
"if",
"0",
":",
"for",
"attrname",
"in",
"[",
"'include_dirs'",
",",
"'define'",
",",
"'undef'",
",",
"'libraries'",
",",
"'library_dirs'",
",",
"'rpath'",
",",
"'link_objects'",
"]",
":",
"attr",
... | [
430,
0
] | [
463,
21
] | python | en | ['en', 'error', 'th'] | False |
CCompiler_customize | (self, dist, need_cxx=0) |
Do any platform-specific customization of a compiler instance.
This method calls `distutils.sysconfig.customize_compiler` for
platform-specific customization, as well as optionally remove a flag
to suppress spurious warnings in case C++ code is being compiled.
Parameters
----------
dist :... |
Do any platform-specific customization of a compiler instance. | def CCompiler_customize(self, dist, need_cxx=0):
"""
Do any platform-specific customization of a compiler instance.
This method calls `distutils.sysconfig.customize_compiler` for
platform-specific customization, as well as optionally remove a flag
to suppress spurious warnings in case C++ code is b... | [
"def",
"CCompiler_customize",
"(",
"self",
",",
"dist",
",",
"need_cxx",
"=",
"0",
")",
":",
"# See FCompiler.customize for suggested usage.",
"log",
".",
"info",
"(",
"'customize %s'",
"%",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
")",
"customize_co... | [
467,
0
] | [
546,
10
] | python | en | ['en', 'error', 'th'] | False |
simple_version_match | (pat=r'[-.\d]+', ignore='', start='') |
Simple matching of version numbers, for use in CCompiler and FCompiler.
Parameters
----------
pat : str, optional
A regular expression matching version numbers.
Default is ``r'[-.\\d]+'``.
ignore : str, optional
A regular expression matching patterns to skip.
Defaul... |
Simple matching of version numbers, for use in CCompiler and FCompiler. | def simple_version_match(pat=r'[-.\d]+', ignore='', start=''):
"""
Simple matching of version numbers, for use in CCompiler and FCompiler.
Parameters
----------
pat : str, optional
A regular expression matching version numbers.
Default is ``r'[-.\\d]+'``.
ignore : str, optional
... | [
"def",
"simple_version_match",
"(",
"pat",
"=",
"r'[-.\\d]+'",
",",
"ignore",
"=",
"''",
",",
"start",
"=",
"''",
")",
":",
"def",
"matcher",
"(",
"self",
",",
"version_string",
")",
":",
"# version string may appear in the second line, so getting rid",
"# of new li... | [
550,
0
] | [
595,
18
] | python | en | ['en', 'error', 'th'] | False |
CCompiler_get_version | (self, force=False, ok_status=[0]) |
Return compiler version, or None if compiler is not available.
Parameters
----------
force : bool, optional
If True, force a new determination of the version, even if the
compiler already has a version attribute. Default is False.
ok_status : list of int, optional
The list ... |
Return compiler version, or None if compiler is not available. | def CCompiler_get_version(self, force=False, ok_status=[0]):
"""
Return compiler version, or None if compiler is not available.
Parameters
----------
force : bool, optional
If True, force a new determination of the version, even if the
compiler already has a version attribute. Defau... | [
"def",
"CCompiler_get_version",
"(",
"self",
",",
"force",
"=",
"False",
",",
"ok_status",
"=",
"[",
"0",
"]",
")",
":",
"if",
"not",
"force",
"and",
"hasattr",
"(",
"self",
",",
"'version'",
")",
":",
"return",
"self",
".",
"version",
"self",
".",
"... | [
597,
0
] | [
662,
18
] | python | en | ['en', 'error', 'th'] | False |
CCompiler_cxx_compiler | (self) |
Return the C++ compiler.
Parameters
----------
None
Returns
-------
cxx : class instance
The C++ compiler, as a `CCompiler` instance.
|
Return the C++ compiler. | def CCompiler_cxx_compiler(self):
"""
Return the C++ compiler.
Parameters
----------
None
Returns
-------
cxx : class instance
The C++ compiler, as a `CCompiler` instance.
"""
if self.compiler_type in ('msvc', 'intelw', 'intelemw'):
return self
cxx = copy(... | [
"def",
"CCompiler_cxx_compiler",
"(",
"self",
")",
":",
"if",
"self",
".",
"compiler_type",
"in",
"(",
"'msvc'",
",",
"'intelw'",
",",
"'intelemw'",
")",
":",
"return",
"self",
"cxx",
"=",
"copy",
"(",
"self",
")",
"cxx",
".",
"compiler_so",
"=",
"[",
... | [
666,
0
] | [
691,
14
] | python | en | ['en', 'error', 'th'] | False |
ProxyBackend.wrap | (self, backend) | Take a backend as an argument and setup the self.proxied property.
Return an object that be used as a backend by a :class:`.CacheRegion`
object.
| Take a backend as an argument and setup the self.proxied property.
Return an object that be used as a backend by a :class:`.CacheRegion`
object.
| def wrap(self, backend):
''' Take a backend as an argument and setup the self.proxied property.
Return an object that be used as a backend by a :class:`.CacheRegion`
object.
'''
assert(
isinstance(backend, CacheBackend) or
isinstance(backend, ProxyBackend)... | [
"def",
"wrap",
"(",
"self",
",",
"backend",
")",
":",
"assert",
"(",
"isinstance",
"(",
"backend",
",",
"CacheBackend",
")",
"or",
"isinstance",
"(",
"backend",
",",
"ProxyBackend",
")",
")",
"self",
".",
"proxied",
"=",
"backend",
"return",
"self"
] | [
60,
4
] | [
69,
19
] | python | en | ['en', 'en', 'en'] | True |
TrainerLoggingMixin.process_dict_result | (self, output, train=False) | Reduces output according to the training mode.
Separates loss from logging and progress bar metrics
| Reduces output according to the training mode. | def process_dict_result(self, output, train=False):
"""Reduces output according to the training mode.
Separates loss from logging and progress bar metrics
"""
# --------------------
# WARN DEPRECATED KEYS
# --------------------
# TODO: 1.0.0 remove
if isi... | [
"def",
"process_dict_result",
"(",
"self",
",",
"output",
",",
"train",
"=",
"False",
")",
":",
"# --------------------",
"# WARN DEPRECATED KEYS",
"# --------------------",
"# TODO: 1.0.0 remove",
"if",
"isinstance",
"(",
"output",
",",
"dict",
")",
":",
"for",
"k"... | [
55,
4
] | [
171,
81
] | python | en | ['en', 'en', 'en'] | True |
_calc_distances | (preds, targets, mask, normalize) | Calculate the normalized distances between preds and target.
Note:
batch_size: N
num_keypoints: K
Args:
preds (np.ndarray[N, K, 2]): Predicted keypoint location.
targets (np.ndarray[N, K, 2]): Groundtruth keypoint location.
mask (np.ndarray[N, K]): Visibility of the tar... | Calculate the normalized distances between preds and target. | def _calc_distances(preds, targets, mask, normalize):
"""Calculate the normalized distances between preds and target.
Note:
batch_size: N
num_keypoints: K
Args:
preds (np.ndarray[N, K, 2]): Predicted keypoint location.
targets (np.ndarray[N, K, 2]): Groundtruth keypoint loc... | [
"def",
"_calc_distances",
"(",
"preds",
",",
"targets",
",",
"mask",
",",
"normalize",
")",
":",
"N",
",",
"K",
",",
"_",
"=",
"preds",
".",
"shape",
"distances",
"=",
"np",
".",
"full",
"(",
"(",
"N",
",",
"K",
")",
",",
"-",
"1",
",",
"dtype"... | [
8,
0
] | [
31,
22
] | python | en | ['en', 'en', 'en'] | True |
_distance_acc | (distances, thr=0.5) | Return the percentage below the distance threshold, while ignoring
distances values with -1.
Note:
batch_size: N
Args:
distances (np.ndarray[N, ]): The normalized distances.
thr (float): Threshold of the distances.
Returns:
float: Percentage of distances below the thres... | Return the percentage below the distance threshold, while ignoring
distances values with -1. | def _distance_acc(distances, thr=0.5):
"""Return the percentage below the distance threshold, while ignoring
distances values with -1.
Note:
batch_size: N
Args:
distances (np.ndarray[N, ]): The normalized distances.
thr (float): Threshold of the distances.
Returns:
... | [
"def",
"_distance_acc",
"(",
"distances",
",",
"thr",
"=",
"0.5",
")",
":",
"distance_valid",
"=",
"distances",
"!=",
"-",
"1",
"num_distance_valid",
"=",
"distance_valid",
".",
"sum",
"(",
")",
"if",
"num_distance_valid",
">",
"0",
":",
"return",
"(",
"di... | [
34,
0
] | [
52,
13
] | python | en | ['en', 'en', 'en'] | True |
_get_max_preds | (heatmaps) | Get keypoint predictions from score maps.
Note:
batch_size: N
num_keypoints: K
heatmap height: H
heatmap width: W
Args:
heatmaps (np.ndarray[N, K, H, W]): model predicted heatmaps.
Returns:
tuple: A tuple containing aggregated results.
- preds (np.... | Get keypoint predictions from score maps. | def _get_max_preds(heatmaps):
"""Get keypoint predictions from score maps.
Note:
batch_size: N
num_keypoints: K
heatmap height: H
heatmap width: W
Args:
heatmaps (np.ndarray[N, K, H, W]): model predicted heatmaps.
Returns:
tuple: A tuple containing aggr... | [
"def",
"_get_max_preds",
"(",
"heatmaps",
")",
":",
"assert",
"isinstance",
"(",
"heatmaps",
",",
"np",
".",
"ndarray",
")",
",",
"(",
"'heatmaps should be numpy.ndarray'",
")",
"assert",
"heatmaps",
".",
"ndim",
"==",
"4",
",",
"'batch_images should be 4-ndim'",
... | [
55,
0
] | [
87,
25
] | python | en | ['en', 'en', 'en'] | True |
pose_pck_accuracy | (output, target, mask, thr=0.05, normalize=None) | Calculate the pose accuracy of PCK for each individual keypoint and the
averaged accuracy across all keypoints from heatmaps.
Note:
PCK metric measures accuracy of the localization of the body joints.
The distances between predicted positions and the ground-truth ones
are typically norm... | Calculate the pose accuracy of PCK for each individual keypoint and the
averaged accuracy across all keypoints from heatmaps. | def pose_pck_accuracy(output, target, mask, thr=0.05, normalize=None):
"""Calculate the pose accuracy of PCK for each individual keypoint and the
averaged accuracy across all keypoints from heatmaps.
Note:
PCK metric measures accuracy of the localization of the body joints.
The distances be... | [
"def",
"pose_pck_accuracy",
"(",
"output",
",",
"target",
",",
"mask",
",",
"thr",
"=",
"0.05",
",",
"normalize",
"=",
"None",
")",
":",
"N",
",",
"K",
",",
"H",
",",
"W",
"=",
"output",
".",
"shape",
"if",
"K",
"==",
"0",
":",
"return",
"None",
... | [
90,
0
] | [
130,
64
] | python | en | ['en', 'en', 'en'] | True |
keypoint_pck_accuracy | (pred, gt, mask, thr, normalize) | Calculate the pose accuracy of PCK for each individual keypoint and the
averaged accuracy across all keypoints for coordinates.
Note:
PCK metric measures accuracy of the localization of the body joints.
The distances between predicted positions and the ground-truth ones
are typically no... | Calculate the pose accuracy of PCK for each individual keypoint and the
averaged accuracy across all keypoints for coordinates. | def keypoint_pck_accuracy(pred, gt, mask, thr, normalize):
"""Calculate the pose accuracy of PCK for each individual keypoint and the
averaged accuracy across all keypoints for coordinates.
Note:
PCK metric measures accuracy of the localization of the body joints.
The distances between pred... | [
"def",
"keypoint_pck_accuracy",
"(",
"pred",
",",
"gt",
",",
"mask",
",",
"thr",
",",
"normalize",
")",
":",
"distances",
"=",
"_calc_distances",
"(",
"pred",
",",
"gt",
",",
"mask",
",",
"normalize",
")",
"acc",
"=",
"np",
".",
"array",
"(",
"[",
"_... | [
133,
0
] | [
169,
28
] | python | en | ['en', 'en', 'en'] | True |
keypoint_auc | (pred, gt, mask, normalize, num_step=20) | Calculate the pose accuracy of PCK for each individual keypoint and the
averaged accuracy across all keypoints for coordinates.
Note:
batch_size: N
num_keypoints: K
Args:
pred (np.ndarray[N, K, 2]): Predicted keypoint location.
gt (np.ndarray[N, K, 2]): Groundtruth keypoint... | Calculate the pose accuracy of PCK for each individual keypoint and the
averaged accuracy across all keypoints for coordinates. | def keypoint_auc(pred, gt, mask, normalize, num_step=20):
"""Calculate the pose accuracy of PCK for each individual keypoint and the
averaged accuracy across all keypoints for coordinates.
Note:
batch_size: N
num_keypoints: K
Args:
pred (np.ndarray[N, K, 2]): Predicted keypoint... | [
"def",
"keypoint_auc",
"(",
"pred",
",",
"gt",
",",
"mask",
",",
"normalize",
",",
"num_step",
"=",
"20",
")",
":",
"nor",
"=",
"np",
".",
"tile",
"(",
"np",
".",
"array",
"(",
"[",
"[",
"normalize",
",",
"normalize",
"]",
"]",
")",
",",
"(",
"... | [
172,
0
] | [
201,
14
] | python | en | ['en', 'en', 'en'] | True |
keypoint_epe | (pred, gt, mask) | Calculate the end-point error.
Note:
batch_size: N
num_keypoints: K
Args:
pred (np.ndarray[N, K, 2]): Predicted keypoint location.
gt (np.ndarray[N, K, 2]): Groundtruth keypoint location.
mask (np.ndarray[N, K]): Visibility of the target. False for invisible
... | Calculate the end-point error. | def keypoint_epe(pred, gt, mask):
"""Calculate the end-point error.
Note:
batch_size: N
num_keypoints: K
Args:
pred (np.ndarray[N, K, 2]): Predicted keypoint location.
gt (np.ndarray[N, K, 2]): Groundtruth keypoint location.
mask (np.ndarray[N, K]): Visibility of th... | [
"def",
"keypoint_epe",
"(",
"pred",
",",
"gt",
",",
"mask",
")",
":",
"distances",
"=",
"_calc_distances",
"(",
"pred",
",",
"gt",
",",
"mask",
",",
"np",
".",
"tile",
"(",
"np",
".",
"array",
"(",
"[",
"[",
"1",
",",
"1",
"]",
"]",
")",
",",
... | [
204,
0
] | [
225,
43
] | python | en | ['en', 'en', 'en'] | True |
_taylor | (heatmap, coord) | Distribution aware coordinate decoding method.
Note:
heatmap height: H
heatmap width: W
Args:
heatmap (np.ndarray[H, W]): Heatmap of a particular joint type.
coord (np.ndarray[2,]): Coordinates of the predicted keypoints.
Returns:
np.ndarray[2,]: Updated coordinate... | Distribution aware coordinate decoding method. | def _taylor(heatmap, coord):
"""Distribution aware coordinate decoding method.
Note:
heatmap height: H
heatmap width: W
Args:
heatmap (np.ndarray[H, W]): Heatmap of a particular joint type.
coord (np.ndarray[2,]): Coordinates of the predicted keypoints.
Returns:
... | [
"def",
"_taylor",
"(",
"heatmap",
",",
"coord",
")",
":",
"H",
",",
"W",
"=",
"heatmap",
".",
"shape",
"[",
":",
"2",
"]",
"px",
",",
"py",
"=",
"int",
"(",
"coord",
"[",
"0",
"]",
")",
",",
"int",
"(",
"coord",
"[",
"1",
"]",
")",
"if",
... | [
228,
0
] | [
262,
16
] | python | en | ['it', 'jv', 'en'] | False |
post_dark_udp | (coords, batch_heatmaps, kernel=3) | DARK post-pocessing. Implemented by udp. Paper ref: Huang et al. The
Devil is in the Details: Delving into Unbiased Data Processing for Human
Pose Estimation (CVPR 2020). Zhang et al. Distribution-Aware Coordinate
Representation for Human Pose Estimation (CVPR 2020).
Note:
batch size: B
... | DARK post-pocessing. Implemented by udp. Paper ref: Huang et al. The
Devil is in the Details: Delving into Unbiased Data Processing for Human
Pose Estimation (CVPR 2020). Zhang et al. Distribution-Aware Coordinate
Representation for Human Pose Estimation (CVPR 2020). | def post_dark_udp(coords, batch_heatmaps, kernel=3):
"""DARK post-pocessing. Implemented by udp. Paper ref: Huang et al. The
Devil is in the Details: Delving into Unbiased Data Processing for Human
Pose Estimation (CVPR 2020). Zhang et al. Distribution-Aware Coordinate
Representation for Human Pose Esti... | [
"def",
"post_dark_udp",
"(",
"coords",
",",
"batch_heatmaps",
",",
"kernel",
"=",
"3",
")",
":",
"if",
"not",
"isinstance",
"(",
"batch_heatmaps",
",",
"np",
".",
"ndarray",
")",
":",
"batch_heatmaps",
"=",
"batch_heatmaps",
".",
"cpu",
"(",
")",
".",
"n... | [
265,
0
] | [
328,
17
] | python | en | ['en', 'da', 'en'] | True |
_gaussian_blur | (heatmaps, kernel=11) | Modulate heatmap distribution with Gaussian.
sigma = 0.3*((kernel_size-1)*0.5-1)+0.8
sigma~=3 if k=17
sigma=2 if k=11;
sigma~=1.5 if k=7;
sigma~=1 if k=3;
Note:
batch_size: N
num_keypoints: K
heatmap height: H
heatmap width: W
Args:
heatmaps (np... | Modulate heatmap distribution with Gaussian.
sigma = 0.3*((kernel_size-1)*0.5-1)+0.8
sigma~=3 if k=17
sigma=2 if k=11;
sigma~=1.5 if k=7;
sigma~=1 if k=3; | def _gaussian_blur(heatmaps, kernel=11):
"""Modulate heatmap distribution with Gaussian.
sigma = 0.3*((kernel_size-1)*0.5-1)+0.8
sigma~=3 if k=17
sigma=2 if k=11;
sigma~=1.5 if k=7;
sigma~=1 if k=3;
Note:
batch_size: N
num_keypoints: K
heatmap height: H
... | [
"def",
"_gaussian_blur",
"(",
"heatmaps",
",",
"kernel",
"=",
"11",
")",
":",
"assert",
"kernel",
"%",
"2",
"==",
"1",
"border",
"=",
"(",
"kernel",
"-",
"1",
")",
"//",
"2",
"batch_size",
"=",
"heatmaps",
".",
"shape",
"[",
"0",
"]",
"num_joints",
... | [
331,
0
] | [
370,
19
] | python | en | ['en', 'zh-Latn', 'en'] | True |
keypoints_from_heatmaps | (heatmaps,
center,
scale,
unbiased=False,
post_process='default',
kernel=11,
valid_radius_factor=0.0546875,
use_udp=False,
... | Get final keypoint predictions from heatmaps and transform them back to
the image.
Note:
batch size: N
num keypoints: K
heatmap height: H
heatmap width: W
Args:
heatmaps (np.ndarray[N, K, H, W]): model predicted heatmaps.
center (np.ndarray[N, 2]): Center of... | Get final keypoint predictions from heatmaps and transform them back to
the image. | def keypoints_from_heatmaps(heatmaps,
center,
scale,
unbiased=False,
post_process='default',
kernel=11,
valid_radius_factor=0.0546875,
... | [
"def",
"keypoints_from_heatmaps",
"(",
"heatmaps",
",",
"center",
",",
"scale",
",",
"unbiased",
"=",
"False",
",",
"post_process",
"=",
"'default'",
",",
"kernel",
"=",
"11",
",",
"valid_radius_factor",
"=",
"0.0546875",
",",
"use_udp",
"=",
"False",
",",
"... | [
373,
0
] | [
516,
25
] | python | en | ['en', 'en', 'en'] | True |
DistributedType.interactive_compatible_types | () | Returns a list containing interactive compatible DistributeTypes | Returns a list containing interactive compatible DistributeTypes | def interactive_compatible_types() -> List['DistributedType']:
"""Returns a list containing interactive compatible DistributeTypes"""
return [DistributedType.DP, DistributedType.DDP_SPAWN, DistributedType.DDP_SHARDED_SPAWN] | [
"def",
"interactive_compatible_types",
"(",
")",
"->",
"List",
"[",
"'DistributedType'",
"]",
":",
"return",
"[",
"DistributedType",
".",
"DP",
",",
"DistributedType",
".",
"DDP_SPAWN",
",",
"DistributedType",
".",
"DDP_SHARDED_SPAWN",
"]"
] | [
62,
4
] | [
64,
97
] | python | en | ['en', 'en', 'en'] | True |
DistributedType.is_interactive_compatible | (self) | Returns whether self is interactive compatible | Returns whether self is interactive compatible | def is_interactive_compatible(self) -> bool:
"""Returns whether self is interactive compatible"""
return self in DistributedType.interactive_compatible_types() | [
"def",
"is_interactive_compatible",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
"in",
"DistributedType",
".",
"interactive_compatible_types",
"(",
")"
] | [
66,
4
] | [
68,
69
] | python | en | ['en', 'en', 'en'] | True |
_check_flip | (origin_imgs, result_imgs) | Check if the origin_imgs are flipped correctly. | Check if the origin_imgs are flipped correctly. | def _check_flip(origin_imgs, result_imgs):
"""Check if the origin_imgs are flipped correctly."""
h, w, c = origin_imgs.shape
for i in range(h):
for j in range(w):
for k in range(c):
if result_imgs[i, j, k] != origin_imgs[i, w - 1 - j, k]:
return False
... | [
"def",
"_check_flip",
"(",
"origin_imgs",
",",
"result_imgs",
")",
":",
"h",
",",
"w",
",",
"c",
"=",
"origin_imgs",
".",
"shape",
"for",
"i",
"in",
"range",
"(",
"h",
")",
":",
"for",
"j",
"in",
"range",
"(",
"w",
")",
":",
"for",
"k",
"in",
"... | [
62,
0
] | [
70,
15
] | python | en | ['en', 'en', 'en'] | True |
function_key_generator | (namespace, fn, to_str=compat.string_type) | Return a function that generates a string
key, based on a given function as well as
arguments to the returned function itself.
This is used by :meth:`.CacheRegion.cache_on_arguments`
to generate a cache key from a decorated function.
An alternate function may be used by specifying
the :paramre... | Return a function that generates a string
key, based on a given function as well as
arguments to the returned function itself. | def function_key_generator(namespace, fn, to_str=compat.string_type):
"""Return a function that generates a string
key, based on a given function as well as
arguments to the returned function itself.
This is used by :meth:`.CacheRegion.cache_on_arguments`
to generate a cache key from a decorated fu... | [
"def",
"function_key_generator",
"(",
"namespace",
",",
"fn",
",",
"to_str",
"=",
"compat",
".",
"string_type",
")",
":",
"if",
"namespace",
"is",
"None",
":",
"namespace",
"=",
"'%s:%s'",
"%",
"(",
"fn",
".",
"__module__",
",",
"fn",
".",
"__name__",
")... | [
5,
0
] | [
41,
23
] | python | en | ['en', 'en', 'en'] | True |
kwarg_function_key_generator | (namespace, fn, to_str=compat.string_type) | Return a function that generates a string
key, based on a given function as well as
arguments to the returned function itself.
For kwargs passed in, we will build a dict of
all argname (key) argvalue (values) including
default args from the argspec and then
alphabetize the list before generatin... | Return a function that generates a string
key, based on a given function as well as
arguments to the returned function itself. | def kwarg_function_key_generator(namespace, fn, to_str=compat.string_type):
"""Return a function that generates a string
key, based on a given function as well as
arguments to the returned function itself.
For kwargs passed in, we will build a dict of
all argname (key) argvalue (values) including
... | [
"def",
"kwarg_function_key_generator",
"(",
"namespace",
",",
"fn",
",",
"to_str",
"=",
"compat",
".",
"string_type",
")",
":",
"if",
"namespace",
"is",
"None",
":",
"namespace",
"=",
"'%s:%s'",
"%",
"(",
"fn",
".",
"__module__",
",",
"fn",
".",
"__name__"... | [
65,
0
] | [
116,
23
] | python | en | ['en', 'en', 'en'] | True |
sha1_mangle_key | (key) | a SHA1 key mangler. | a SHA1 key mangler. | def sha1_mangle_key(key):
"""a SHA1 key mangler."""
return sha1(key).hexdigest() | [
"def",
"sha1_mangle_key",
"(",
"key",
")",
":",
"return",
"sha1",
"(",
"key",
")",
".",
"hexdigest",
"(",
")"
] | [
119,
0
] | [
122,
32
] | python | en | ['en', 'mg', 'ur'] | False |
length_conditional_mangler | (length, mangler) | a key mangler that mangles if the length of the key is
past a certain threshold.
| a key mangler that mangles if the length of the key is
past a certain threshold. | def length_conditional_mangler(length, mangler):
"""a key mangler that mangles if the length of the key is
past a certain threshold.
"""
def mangle(key):
if len(key) >= length:
return mangler(key)
else:
return key
return mangle | [
"def",
"length_conditional_mangler",
"(",
"length",
",",
"mangler",
")",
":",
"def",
"mangle",
"(",
"key",
")",
":",
"if",
"len",
"(",
"key",
")",
">=",
"length",
":",
"return",
"mangler",
"(",
"key",
")",
"else",
":",
"return",
"key",
"return",
"mangl... | [
125,
0
] | [
135,
17
] | python | en | ['en', 'en', 'en'] | True |
HammingDistance.update | (self, preds: torch.Tensor, target: torch.Tensor) |
Update state with predictions and targets. See :ref:`extensions/metrics:input types` for more information
on input types.
Args:
preds: Predictions from model (probabilities, or labels)
target: Ground truth labels
|
Update state with predictions and targets. See :ref:`extensions/metrics:input types` for more information
on input types. | def update(self, preds: torch.Tensor, target: torch.Tensor):
"""
Update state with predictions and targets. See :ref:`extensions/metrics:input types` for more information
on input types.
Args:
preds: Predictions from model (probabilities, or labels)
target: Groun... | [
"def",
"update",
"(",
"self",
",",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
")",
":",
"correct",
",",
"total",
"=",
"_hamming_distance_update",
"(",
"preds",
",",
"target",
",",
"self",
".",
"threshold",
")",
"s... | [
88,
4
] | [
100,
27
] | python | en | ['en', 'error', 'th'] | False |
HammingDistance.compute | (self) |
Computes hamming distance based on inputs passed in to ``update`` previously.
|
Computes hamming distance based on inputs passed in to ``update`` previously.
| def compute(self) -> torch.Tensor:
"""
Computes hamming distance based on inputs passed in to ``update`` previously.
"""
return _hamming_distance_compute(self.correct, self.total) | [
"def",
"compute",
"(",
"self",
")",
"->",
"torch",
".",
"Tensor",
":",
"return",
"_hamming_distance_compute",
"(",
"self",
".",
"correct",
",",
"self",
".",
"total",
")"
] | [
102,
4
] | [
106,
66
] | python | en | ['en', 'error', 'th'] | False |
test_property_current_epoch | () | Test that the current_epoch in LightningModule is accessible via the Trainer. | Test that the current_epoch in LightningModule is accessible via the Trainer. | def test_property_current_epoch():
""" Test that the current_epoch in LightningModule is accessible via the Trainer. """
model = BoringModel()
assert model.current_epoch == 0
trainer = Mock(current_epoch=123)
model.trainer = trainer
assert model.current_epoch == 123 | [
"def",
"test_property_current_epoch",
"(",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"assert",
"model",
".",
"current_epoch",
"==",
"0",
"trainer",
"=",
"Mock",
"(",
"current_epoch",
"=",
"123",
")",
"model",
".",
"trainer",
"=",
"trainer",
"assert",
... | [
25,
0
] | [
32,
37
] | python | en | ['en', 'en', 'en'] | True |
test_property_global_step | () | Test that the global_step in LightningModule is accessible via the Trainer. | Test that the global_step in LightningModule is accessible via the Trainer. | def test_property_global_step():
""" Test that the global_step in LightningModule is accessible via the Trainer. """
model = BoringModel()
assert model.global_step == 0
trainer = Mock(global_step=123)
model.trainer = trainer
assert model.global_step == 123 | [
"def",
"test_property_global_step",
"(",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"assert",
"model",
".",
"global_step",
"==",
"0",
"trainer",
"=",
"Mock",
"(",
"global_step",
"=",
"123",
")",
"model",
".",
"trainer",
"=",
"trainer",
"assert",
"mod... | [
35,
0
] | [
42,
35
] | python | en | ['en', 'en', 'en'] | True |
test_property_global_rank | () | Test that the global rank in LightningModule is accessible via the Trainer. | Test that the global rank in LightningModule is accessible via the Trainer. | def test_property_global_rank():
""" Test that the global rank in LightningModule is accessible via the Trainer. """
model = BoringModel()
assert model.global_rank == 0
trainer = Mock(global_rank=123)
model.trainer = trainer
assert model.global_rank == 123 | [
"def",
"test_property_global_rank",
"(",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"assert",
"model",
".",
"global_rank",
"==",
"0",
"trainer",
"=",
"Mock",
"(",
"global_rank",
"=",
"123",
")",
"model",
".",
"trainer",
"=",
"trainer",
"assert",
"mod... | [
45,
0
] | [
52,
35
] | python | en | ['en', 'en', 'en'] | True |
test_property_local_rank | () | Test that the local rank in LightningModule is accessible via the Trainer. | Test that the local rank in LightningModule is accessible via the Trainer. | def test_property_local_rank():
""" Test that the local rank in LightningModule is accessible via the Trainer. """
model = BoringModel()
assert model.local_rank == 0
trainer = Mock(local_rank=123)
model.trainer = trainer
assert model.local_rank == 123 | [
"def",
"test_property_local_rank",
"(",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"assert",
"model",
".",
"local_rank",
"==",
"0",
"trainer",
"=",
"Mock",
"(",
"local_rank",
"=",
"123",
")",
"model",
".",
"trainer",
"=",
"trainer",
"assert",
"model"... | [
55,
0
] | [
62,
34
] | python | en | ['en', 'en', 'en'] | True |
test_property_logger | (tmpdir) | Test that the logger in LightningModule is accessible via the Trainer. | Test that the logger in LightningModule is accessible via the Trainer. | def test_property_logger(tmpdir):
""" Test that the logger in LightningModule is accessible via the Trainer. """
model = BoringModel()
assert model.logger is None
logger = TensorBoardLogger(tmpdir)
trainer = Mock(logger=logger)
model.trainer = trainer
assert model.logger == logger | [
"def",
"test_property_logger",
"(",
"tmpdir",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"assert",
"model",
".",
"logger",
"is",
"None",
"logger",
"=",
"TensorBoardLogger",
"(",
"tmpdir",
")",
"trainer",
"=",
"Mock",
"(",
"logger",
"=",
"logger",
")"... | [
65,
0
] | [
73,
33
] | python | en | ['en', 'en', 'en'] | True |
trainer_state | (*, entering: Optional[TrainerState] = None, exiting: Optional[TrainerState] = None) | Decorator for :class:`~pytorch_lightning.trainer.trainer.Trainer` methods
which changes state to `entering` before the function execution and `exiting`
after the function is executed. If `None` is passed to `entering`, the state is not changed.
If `None` is passed to `exiting`, the state is restored to the... | Decorator for :class:`~pytorch_lightning.trainer.trainer.Trainer` methods
which changes state to `entering` before the function execution and `exiting`
after the function is executed. If `None` is passed to `entering`, the state is not changed.
If `None` is passed to `exiting`, the state is restored to the... | def trainer_state(*, entering: Optional[TrainerState] = None, exiting: Optional[TrainerState] = None) -> Callable:
""" Decorator for :class:`~pytorch_lightning.trainer.trainer.Trainer` methods
which changes state to `entering` before the function execution and `exiting`
after the function is executed. If `N... | [
"def",
"trainer_state",
"(",
"*",
",",
"entering",
":",
"Optional",
"[",
"TrainerState",
"]",
"=",
"None",
",",
"exiting",
":",
"Optional",
"[",
"TrainerState",
"]",
"=",
"None",
")",
"->",
"Callable",
":",
"def",
"wrapper",
"(",
"fn",
")",
"->",
"Call... | [
52,
0
] | [
82,
18
] | python | en | ['da', 'en', 'en'] | True |
test_result_reduce_ddp | (result_cls) | Make sure result logging works with DDP | Make sure result logging works with DDP | def test_result_reduce_ddp(result_cls):
"""Make sure result logging works with DDP"""
tutils.reset_seed()
tutils.set_random_master_port()
worldsize = 2
mp.spawn(_ddp_test_fn, args=(worldsize, result_cls), nprocs=worldsize) | [
"def",
"test_result_reduce_ddp",
"(",
"result_cls",
")",
":",
"tutils",
".",
"reset_seed",
"(",
")",
"tutils",
".",
"set_random_master_port",
"(",
")",
"worldsize",
"=",
"2",
"mp",
".",
"spawn",
"(",
"_ddp_test_fn",
",",
"args",
"=",
"(",
"worldsize",
",",
... | [
52,
0
] | [
58,
74
] | python | en | ['en', 'da', 'en'] | True |
test_result_gather_stack | () | Test that tensors get concatenated when they all have the same shape. | Test that tensors get concatenated when they all have the same shape. | def test_result_gather_stack():
""" Test that tensors get concatenated when they all have the same shape. """
outputs = [
{
"foo": torch.zeros(4, 5)
},
{
"foo": torch.zeros(4, 5)
},
{
"foo": torch.zeros(4, 5)
},
]
result... | [
"def",
"test_result_gather_stack",
"(",
")",
":",
"outputs",
"=",
"[",
"{",
"\"foo\"",
":",
"torch",
".",
"zeros",
"(",
"4",
",",
"5",
")",
"}",
",",
"{",
"\"foo\"",
":",
"torch",
".",
"zeros",
"(",
"4",
",",
"5",
")",
"}",
",",
"{",
"\"foo\"",
... | [
190,
0
] | [
205,
47
] | python | en | ['en', 'en', 'en'] | True |
test_result_gather_concatenate | () | Test that tensors get concatenated when they have varying size in first dimension. | Test that tensors get concatenated when they have varying size in first dimension. | def test_result_gather_concatenate():
""" Test that tensors get concatenated when they have varying size in first dimension. """
outputs = [
{
"foo": torch.zeros(4, 5)
},
{
"foo": torch.zeros(8, 5)
},
{
"foo": torch.zeros(3, 5)
... | [
"def",
"test_result_gather_concatenate",
"(",
")",
":",
"outputs",
"=",
"[",
"{",
"\"foo\"",
":",
"torch",
".",
"zeros",
"(",
"4",
",",
"5",
")",
"}",
",",
"{",
"\"foo\"",
":",
"torch",
".",
"zeros",
"(",
"8",
",",
"5",
")",
"}",
",",
"{",
"\"foo... | [
208,
0
] | [
223,
47
] | python | en | ['en', 'en', 'en'] | True |
test_result_gather_scalar | () | Test that 0-dim tensors get gathered and stacked correctly. | Test that 0-dim tensors get gathered and stacked correctly. | def test_result_gather_scalar():
""" Test that 0-dim tensors get gathered and stacked correctly. """
outputs = [
{
"foo": torch.tensor(1)
},
{
"foo": torch.tensor(2)
},
{
"foo": torch.tensor(3)
},
]
result = Result.gathe... | [
"def",
"test_result_gather_scalar",
"(",
")",
":",
"outputs",
"=",
"[",
"{",
"\"foo\"",
":",
"torch",
".",
"tensor",
"(",
"1",
")",
"}",
",",
"{",
"\"foo\"",
":",
"torch",
".",
"tensor",
"(",
"2",
")",
"}",
",",
"{",
"\"foo\"",
":",
"torch",
".",
... | [
226,
0
] | [
241,
43
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.