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
AbstractTransport.read_byte
(self, address: int)
Reads a single byte :param address: the address to read
Reads a single byte :param address: the address to read
def read_byte(self, address: int) -> int: """Reads a single byte :param address: the address to read """ pass
[ "def", "read_byte", "(", "self", ",", "address", ":", "int", ")", "->", "int", ":", "pass" ]
[ 19, 4 ]
[ 23, 12 ]
python
en
['en', 'cs', 'en']
True
AbstractTransport.read_bytes
(self, address: int, length: int)
Reads 'length' bytes starting at 'address' :param address: the address to read :param length: number of bytes to read
Reads 'length' bytes starting at 'address' :param address: the address to read :param length: number of bytes to read
def read_bytes(self, address: int, length: int) -> List[int]: """ Reads 'length' bytes starting at 'address' :param address: the address to read :param length: number of bytes to read """ pass
[ "def", "read_bytes", "(", "self", ",", "address", ":", "int", ",", "length", ":", "int", ")", "->", "List", "[", "int", "]", ":", "pass" ]
[ 26, 4 ]
[ 32, 12 ]
python
en
['en', 'ja', 'th']
False
AbstractTransport.data_ready
(self, timeout: int)
Waits for data to be ready.
Waits for data to be ready.
def data_ready(self, timeout: int) -> bool: """Waits for data to be ready.""" pass
[ "def", "data_ready", "(", "self", ",", "timeout", ":", "int", ")", "->", "bool", ":", "pass" ]
[ 35, 4 ]
[ 37, 12 ]
python
en
['en', 'en', 'en']
True
MemoryMap.get_base
(self, region)
Gets the base address of a specified region :param region: The memory region to get the base address of :type region: str
Gets the base address of a specified region :param region: The memory region to get the base address of :type region: str
def get_base(self, region): """Gets the base address of a specified region :param region: The memory region to get the base address of :type region: str """ return self.get_attr(region,'base')
[ "def", "get_base", "(", "self", ",", "region", ")", ":", "return", "self", ".", "get_attr", "(", "region", ",", "'base'", ")" ]
[ 88, 4 ]
[ 94, 43 ]
python
en
['en', 'en', 'en']
True
MemoryMap.get_size
(self, region)
Gets the size (bytes) of a specified region :param region: The memory region to get the base address of :type region: str
Gets the size (bytes) of a specified region :param region: The memory region to get the base address of :type region: str
def get_size(self, region): """Gets the size (bytes) of a specified region :param region: The memory region to get the base address of :type region: str """ return self.get_attr(region,'size')
[ "def", "get_size", "(", "self", ",", "region", ")", ":", "return", "self", ".", "get_attr", "(", "region", ",", "'size'", ")" ]
[ 96, 4 ]
[ 102, 43 ]
python
en
['en', 'en', 'en']
True
MemoryMap.get_map_string
(self, data_base='hex')
Gets a string representation of the memory map :param data_base: Which number system based to use to represent the data (e.g. hex (hexadecimal), dec (decimal), bin (binary). :type data_base: str, optional
Gets a string representation of the memory map :param data_base: Which number system based to use to represent the data (e.g. hex (hexadecimal), dec (decimal), bin (binary). :type data_base: str, optional
def get_map_string(self, data_base='hex'): """Gets a string representation of the memory map :param data_base: Which number system based to use to represent the data (e.g. hex (hexadecimal), dec (decimal), bin (binary). :type data_base: str, optional """ hex_digits = in...
[ "def", "get_map_string", "(", "self", ",", "data_base", "=", "'hex'", ")", ":", "hex_digits", "=", "int", "(", "(", "self", ".", "_address_bits", "/", "4", ")", "+", "0.5", ")", "fmt", "=", "'0x{:0'", "+", "str", "(", "hex_digits", ")", "+", "'X}'", ...
[ 104, 4 ]
[ 121, 47 ]
python
en
['en', 'en', 'en']
True
find_header
(blockquote)
Find attributes in a blockquote if they are defined on a header that is the first thing in the block quote. Returns the attributes, a list [id, classes, kvs] where id = str, classes = list, kvs = list of key, value pairs
Find attributes in a blockquote if they are defined on a header that is the first thing in the block quote.
def find_header(blockquote): """Find attributes in a blockquote if they are defined on a header that is the first thing in the block quote. Returns the attributes, a list [id, classes, kvs] where id = str, classes = list, kvs = list of key, value pairs """ if blockquote[0]['t'] == 'Header': ...
[ "def", "find_header", "(", "blockquote", ")", ":", "if", "blockquote", "[", "0", "]", "[", "'t'", "]", "==", "'Header'", ":", "level", ",", "attr", ",", "inline", "=", "blockquote", "[", "0", "]", "[", "'c'", "]", "return", "level", ",", "attr", ",...
[ 59, 0 ]
[ 68, 34 ]
python
en
['en', 'en', 'en']
True
blockquote2div
(key, value, format, meta)
Convert a blockquote into a div if it begins with a header that has attributes containing a single class that is in the allowed classes. This function can be passed directly to toJSONFilter from pandocfilters.
Convert a blockquote into a div if it begins with a header that has attributes containing a single class that is in the allowed classes.
def blockquote2div(key, value, format, meta): """Convert a blockquote into a div if it begins with a header that has attributes containing a single class that is in the allowed classes. This function can be passed directly to toJSONFilter from pandocfilters. """ if key == 'BlockQuote': ...
[ "def", "blockquote2div", "(", "key", ",", "value", ",", "format", ",", "meta", ")", ":", "if", "key", "==", "'BlockQuote'", ":", "blockquote", "=", "value", "header", "=", "find_header", "(", "blockquote", ")", "if", "not", "header", ":", "return", "else...
[ 71, 0 ]
[ 121, 73 ]
python
en
['en', 'en', 'en']
True
AUC.update
(self, x: torch.Tensor, y: torch.Tensor)
Update state with predictions and targets. Args: x: Predictions from model (probabilities, or labels) y: Ground truth labels
Update state with predictions and targets.
def update(self, x: torch.Tensor, y: torch.Tensor): """ Update state with predictions and targets. Args: x: Predictions from model (probabilities, or labels) y: Ground truth labels """ x, y = _auc_update(x, y) self.x.append(x) self.y.appe...
[ "def", "update", "(", "self", ",", "x", ":", "torch", ".", "Tensor", ",", "y", ":", "torch", ".", "Tensor", ")", ":", "x", ",", "y", "=", "_auc_update", "(", "x", ",", "y", ")", "self", ".", "x", ".", "append", "(", "x", ")", "self", ".", "...
[ 70, 4 ]
[ 81, 24 ]
python
en
['en', 'error', 'th']
False
AUC.compute
(self)
Computes AUC based on inputs passed in to ``update`` previously.
Computes AUC based on inputs passed in to ``update`` previously.
def compute(self) -> torch.Tensor: """ Computes AUC based on inputs passed in to ``update`` previously. """ x = torch.cat(self.x, dim=0) y = torch.cat(self.y, dim=0) return _auc_compute(x, y, reorder=self.reorder)
[ "def", "compute", "(", "self", ")", "->", "torch", ".", "Tensor", ":", "x", "=", "torch", ".", "cat", "(", "self", ".", "x", ",", "dim", "=", "0", ")", "y", "=", "torch", ".", "cat", "(", "self", ".", "y", ",", "dim", "=", "0", ")", "return...
[ 83, 4 ]
[ 89, 55 ]
python
en
['en', 'error', 'th']
False
Hp3dSession.__init__
( self, device: str = "cuda:0", path_to_model: str = "human-pose-estimation-3d.pth", base_height: int = 256, path_to_extrinsics = 'hp3d/data/extrinsics.json', fx: np.float32 = -1)
device: str. E. g. cpu, cuda:0, cuda:1, ... path_to_model: Path to PyTorch pth file fx: Camera focal length.
device: str. E. g. cpu, cuda:0, cuda:1, ... path_to_model: Path to PyTorch pth file fx: Camera focal length.
def __init__( self, device: str = "cuda:0", path_to_model: str = "human-pose-estimation-3d.pth", base_height: int = 256, path_to_extrinsics = 'hp3d/data/extrinsics.json', fx: np.float32 = -1): """ device: str. E. g. cpu, cuda:0...
[ "def", "__init__", "(", "self", ",", "device", ":", "str", "=", "\"cuda:0\"", ",", "path_to_model", ":", "str", "=", "\"human-pose-estimation-3d.pth\"", ",", "base_height", ":", "int", "=", "256", ",", "path_to_extrinsics", "=", "'hp3d/data/extrinsics.json'", ",",...
[ 124, 4 ]
[ 153, 26 ]
python
en
['en', 'error', 'th']
False
Printer.print_report
(candidates, full_report=False)
Print AMI collection results
Print AMI collection results
def print_report(candidates, full_report=False): """ Print AMI collection results """ if not candidates: return groups_table = PrettyTable(["Group name", "candidates"]) for group_name, amis in candidates.items(): groups_table.add_row([group_name, len(amis)]) ...
[ "def", "print_report", "(", "candidates", ",", "full_report", "=", "False", ")", ":", "if", "not", "candidates", ":", "return", "groups_table", "=", "PrettyTable", "(", "[", "\"Group name\"", ",", "\"candidates\"", "]", ")", "for", "group_name", ",", "amis", ...
[ 17, 4 ]
[ 42, 59 ]
python
en
['en', 'en', 'en']
True
SCConv.forward
(self, x)
Forward function.
Forward function.
def forward(self, x): """Forward function.""" identity = x out = torch.sigmoid( torch.add(identity, F.interpolate(self.k2(x), identity.size()[2:]))) out = torch.mul(self.k3(x), out) out = self.k4(out) return out
[ "def", "forward", "(", "self", ",", "x", ")", ":", "identity", "=", "x", "out", "=", "torch", ".", "sigmoid", "(", "torch", ".", "add", "(", "identity", ",", "F", ".", "interpolate", "(", "self", ".", "k2", "(", "x", ")", ",", "identity", ".", ...
[ 75, 4 ]
[ 85, 18 ]
python
en
['en', 'cy', 'en']
False
SCBottleneck.forward
(self, x)
Forward function.
Forward function.
def forward(self, x): """Forward function.""" def _inner_forward(x): identity = x out_a = self.conv1(x) out_a = self.norm1(out_a) out_a = self.relu(out_a) out_a = self.k1(out_a) out_b = self.conv2(x) out_b = self.nor...
[ "def", "forward", "(", "self", ",", "x", ")", ":", "def", "_inner_forward", "(", "x", ")", ":", "identity", "=", "x", "out_a", "=", "self", ".", "conv1", "(", "x", ")", "out_a", "=", "self", ".", "norm1", "(", "out_a", ")", "out_a", "=", "self", ...
[ 151, 4 ]
[ 186, 18 ]
python
en
['en', 'cy', 'en']
False
CoverageRunner.cov_data
(self)
The path to a file to a file containing coverage data
The path to a file to a file containing coverage data
def cov_data(self): """The path to a file to a file containing coverage data""" return self.args.cov_data
[ "def", "cov_data", "(", "self", ")", ":", "return", "self", ".", "args", ".", "cov_data" ]
[ 25, 4 ]
[ 27, 33 ]
python
en
['en', 'en', 'en']
True
CoverageRunner.cov_html
(self)
The path to a file to a file containing coverage data
The path to a file to a file containing coverage data
def cov_html(self): """The path to a file to a file containing coverage data""" return self.args.cov_html
[ "def", "cov_html", "(", "self", ")", ":", "return", "self", ".", "args", ".", "cov_html" ]
[ 30, 4 ]
[ 32, 33 ]
python
en
['en', 'en', 'en']
True
CoverageRunner.add_arguments
(self, parser: argparse.ArgumentParser)
Add arguments to the arg parser
Add arguments to the arg parser
def add_arguments(self, parser: argparse.ArgumentParser) -> None: """Add arguments to the arg parser""" parser.add_argument("cov_data", help="Path to coverage data") parser.add_argument("cov_html", help="Path to coverage html")
[ "def", "add_arguments", "(", "self", ",", "parser", ":", "argparse", ".", "ArgumentParser", ")", "->", "None", ":", "parser", ".", "add_argument", "(", "\"cov_data\"", ",", "help", "=", "\"Path to coverage data\"", ")", "parser", ".", "add_argument", "(", "\"c...
[ 34, 4 ]
[ 37, 69 ]
python
en
['en', 'en', 'en']
True
subst_vars
(target, source, d)
Substitute any occurrence of @foo@ by d['foo'] from source file into target.
Substitute any occurrence of
def subst_vars(target, source, d): """Substitute any occurrence of @foo@ by d['foo'] from source file into target.""" var = re.compile('@([a-zA-Z_]+)@') with open(source, 'r') as fs: with open(target, 'w') as ft: for l in fs: m = var.search(l) if m: ...
[ "def", "subst_vars", "(", "target", ",", "source", ",", "d", ")", ":", "var", "=", "re", ".", "compile", "(", "'@([a-zA-Z_]+)@'", ")", "with", "open", "(", "source", ",", "'r'", ")", "as", "fs", ":", "with", "open", "(", "target", ",", "'w'", ")", ...
[ 26, 0 ]
[ 37, 31 ]
python
en
['en', 'en', 'en']
True
build_src.pyrex_sources
(self, sources, extension)
Pyrex not supported; this remains for Cython support (see below)
Pyrex not supported; this remains for Cython support (see below)
def pyrex_sources(self, sources, extension): """Pyrex not supported; this remains for Cython support (see below)""" new_sources = [] ext_name = extension.name.split('.')[-1] for source in sources: (base, ext) = os.path.splitext(source) if ext == '.pyx': ...
[ "def", "pyrex_sources", "(", "self", ",", "sources", ",", "extension", ")", ":", "new_sources", "=", "[", "]", "ext_name", "=", "extension", ".", "name", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", "for", "source", "in", "sources", ":", "(", ...
[ 433, 4 ]
[ 446, 26 ]
python
en
['en', 'en', 'en']
True
build_src.generate_a_pyrex_source
(self, base, ext_name, source, extension)
Pyrex is not supported, but some projects monkeypatch this method. That allows compiling Cython code, see gh-6955. This method will remain here for compatibility reasons.
Pyrex is not supported, but some projects monkeypatch this method.
def generate_a_pyrex_source(self, base, ext_name, source, extension): """Pyrex is not supported, but some projects monkeypatch this method. That allows compiling Cython code, see gh-6955. This method will remain here for compatibility reasons. """ return []
[ "def", "generate_a_pyrex_source", "(", "self", ",", "base", ",", "ext_name", ",", "source", ",", "extension", ")", ":", "return", "[", "]" ]
[ 448, 4 ]
[ 454, 17 ]
python
en
['en', 'en', 'en']
True
test_mesh_hmr_head
()
Test hmr mesh head.
Test hmr mesh head.
def test_mesh_hmr_head(): """Test hmr mesh head.""" head = MeshHMRHead(in_channels=512) head.init_weights() input_shape = (1, 512, 8, 8) inputs = _demo_inputs(input_shape) out = head(inputs) smpl_rotmat, smpl_shape, camera = out assert smpl_rotmat.shape == torch.Size([1, 24, 3, 3]) ...
[ "def", "test_mesh_hmr_head", "(", ")", ":", "head", "=", "MeshHMRHead", "(", "in_channels", "=", "512", ")", "head", ".", "init_weights", "(", ")", "input_shape", "=", "(", "1", ",", "512", ",", "8", ",", "8", ")", "inputs", "=", "_demo_inputs", "(", ...
[ 8, 0 ]
[ 60, 48 ]
python
en
['en', 'gd', 'hi']
False
_demo_inputs
(input_shape=(1, 3, 64, 64))
Create a superset of inputs needed to run mesh head. Args: input_shape (tuple): input batch dimensions. Default: (1, 3, 64, 64). Returns: Random input tensor with the size of input_shape.
Create a superset of inputs needed to run mesh head.
def _demo_inputs(input_shape=(1, 3, 64, 64)): """Create a superset of inputs needed to run mesh head. Args: input_shape (tuple): input batch dimensions. Default: (1, 3, 64, 64). Returns: Random input tensor with the size of input_shape. """ inps = np.random.random(input_...
[ "def", "_demo_inputs", "(", "input_shape", "=", "(", "1", ",", "3", ",", "64", ",", "64", ")", ")", ":", "inps", "=", "np", ".", "random", ".", "random", "(", "input_shape", ")", "inps", "=", "torch", ".", "FloatTensor", "(", "inps", ")", "return",...
[ 63, 0 ]
[ 74, 15 ]
python
en
['en', 'en', 'en']
True
test_root_page_successfully
(client)
Retrieve root page successfully.
Retrieve root page successfully.
def test_root_page_successfully(client): """Retrieve root page successfully.""" rv = client.get('/') assert '200' in rv.status
[ "def", "test_root_page_successfully", "(", "client", ")", ":", "rv", "=", "client", ".", "get", "(", "'/'", ")", "assert", "'200'", "in", "rv", ".", "status" ]
[ 14, 0 ]
[ 18, 29 ]
python
en
['en', 'en', 'en']
True
TestUserURLs.test_list_reverse
(self)
users:list should reverse to /users/.
users:list should reverse to /users/.
def test_list_reverse(self): """users:list should reverse to /users/.""" self.assertEqual(reverse('users:list'), '/users/')
[ "def", "test_list_reverse", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "reverse", "(", "'users:list'", ")", ",", "'/users/'", ")" ]
[ 11, 4 ]
[ 13, 58 ]
python
en
['en', 'en', 'en']
True
TestUserURLs.test_list_resolve
(self)
/users/ should resolve to users:list.
/users/ should resolve to users:list.
def test_list_resolve(self): """/users/ should resolve to users:list.""" self.assertEqual(resolve('/users/').view_name, 'users:list')
[ "def", "test_list_resolve", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "resolve", "(", "'/users/'", ")", ".", "view_name", ",", "'users:list'", ")" ]
[ 15, 4 ]
[ 17, 68 ]
python
en
['en', 'en', 'en']
True
TestUserURLs.test_redirect_reverse
(self)
users:redirect should reverse to /users/~redirect/.
users:redirect should reverse to /users/~redirect/.
def test_redirect_reverse(self): """users:redirect should reverse to /users/~redirect/.""" self.assertEqual(reverse('users:redirect'), '/users/~redirect/')
[ "def", "test_redirect_reverse", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "reverse", "(", "'users:redirect'", ")", ",", "'/users/~redirect/'", ")" ]
[ 19, 4 ]
[ 21, 72 ]
python
en
['en', 'en', 'en']
True
TestUserURLs.test_redirect_resolve
(self)
/users/~redirect/ should resolve to users:redirect.
/users/~redirect/ should resolve to users:redirect.
def test_redirect_resolve(self): """/users/~redirect/ should resolve to users:redirect.""" self.assertEqual( resolve('/users/~redirect/').view_name, 'users:redirect' )
[ "def", "test_redirect_resolve", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "resolve", "(", "'/users/~redirect/'", ")", ".", "view_name", ",", "'users:redirect'", ")" ]
[ 23, 4 ]
[ 28, 9 ]
python
en
['en', 'en', 'en']
True
TestUserURLs.test_detail_reverse
(self)
users:detail should reverse to /users/testuser/.
users:detail should reverse to /users/testuser/.
def test_detail_reverse(self): """users:detail should reverse to /users/testuser/.""" self.assertEqual( reverse('users:detail', kwargs={'username': 'testuser'}), '/users/testuser/' )
[ "def", "test_detail_reverse", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "reverse", "(", "'users:detail'", ",", "kwargs", "=", "{", "'username'", ":", "'testuser'", "}", ")", ",", "'/users/testuser/'", ")" ]
[ 30, 4 ]
[ 35, 9 ]
python
en
['en', 'en', 'en']
True
TestUserURLs.test_detail_resolve
(self)
/users/testuser/ should resolve to users:detail.
/users/testuser/ should resolve to users:detail.
def test_detail_resolve(self): """/users/testuser/ should resolve to users:detail.""" self.assertEqual(resolve('/users/testuser/').view_name, 'users:detail')
[ "def", "test_detail_resolve", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "resolve", "(", "'/users/testuser/'", ")", ".", "view_name", ",", "'users:detail'", ")" ]
[ 37, 4 ]
[ 39, 79 ]
python
en
['en', 'en', 'en']
True
TestUserURLs.test_update_reverse
(self)
users:update should reverse to /users/~update/.
users:update should reverse to /users/~update/.
def test_update_reverse(self): """users:update should reverse to /users/~update/.""" self.assertEqual(reverse('users:update'), '/users/~update/')
[ "def", "test_update_reverse", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "reverse", "(", "'users:update'", ")", ",", "'/users/~update/'", ")" ]
[ 41, 4 ]
[ 43, 68 ]
python
en
['en', 'en', 'en']
True
TestUserURLs.test_update_resolve
(self)
/users/~update/ should resolve to users:update.
/users/~update/ should resolve to users:update.
def test_update_resolve(self): """/users/~update/ should resolve to users:update.""" self.assertEqual( resolve('/users/~update/').view_name, 'users:update' )
[ "def", "test_update_resolve", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "resolve", "(", "'/users/~update/'", ")", ".", "view_name", ",", "'users:update'", ")" ]
[ 45, 4 ]
[ 50, 9 ]
python
en
['en', 'en', 'en']
True
search4
()
Returns the results of a call to 'search4letters' to the browser.
Returns the results of a call to 'search4letters' to the browser.
def search4() -> 'html': """Returns the results of a call to 'search4letters' to the browser.""" phrase = request.form['phrase'] letters = request.form['letters'] results = str(search4letters(phrase, letters)) return render_template('results.html', the_title='Here are your...
[ "def", "search4", "(", ")", "->", "'html'", ":", "phrase", "=", "request", ".", "form", "[", "'phrase'", "]", "letters", "=", "request", ".", "form", "[", "'letters'", "]", "results", "=", "str", "(", "search4letters", "(", "phrase", ",", "letters", ")...
[ 6, 0 ]
[ 15, 47 ]
python
en
['en', 'en', 'en']
True
entry_page
()
Returns the entry page to browser.
Returns the entry page to browser.
def entry_page() -> 'html': """Returns the entry page to browser.""" return render_template('entry.html', the_title='Welcome to search4letters on the web!', the_url='/search4')
[ "def", "entry_page", "(", ")", "->", "'html'", ":", "return", "render_template", "(", "'entry.html'", ",", "the_title", "=", "'Welcome to search4letters on the web!'", ",", "the_url", "=", "'/search4'", ")" ]
[ 18, 0 ]
[ 22, 48 ]
python
en
['en', 'en', 'en']
True
search4json
()
Returns the results of a call to 'search4letters' to the browser.
Returns the results of a call to 'search4letters' to the browser.
def search4json() -> 'json': """Returns the results of a call to 'search4letters' to the browser.""" phrase = request.form['phrase'] letters = request.form['letters'] results = str(search4letters(phrase, letters)) return jsonify(the_phrase=phrase, the_letters=letters, ...
[ "def", "search4json", "(", ")", "->", "'json'", ":", "phrase", "=", "request", ".", "form", "[", "'phrase'", "]", "letters", "=", "request", ".", "form", "[", "'letters'", "]", "results", "=", "str", "(", "search4letters", "(", "phrase", ",", "letters", ...
[ 25, 0 ]
[ 32, 39 ]
python
en
['en', 'en', 'en']
True
entry_json_page
()
Returns the JSON entry page to browser.
Returns the JSON entry page to browser.
def entry_json_page() -> 'html': """Returns the JSON entry page to browser.""" return render_template('entry.html', the_title='Welcome to search4letters JSON page', the_url='/searchjson')
[ "def", "entry_json_page", "(", ")", "->", "'html'", ":", "return", "render_template", "(", "'entry.html'", ",", "the_title", "=", "'Welcome to search4letters JSON page'", ",", "the_url", "=", "'/searchjson'", ")" ]
[ 35, 0 ]
[ 39, 49 ]
python
en
['en', 'en', 'en']
True
_generate_smpl_weight_file
(output_dir)
Generate a SMPL model weight file to initialize SMPL model, and generate a 3D joints regressor file.
Generate a SMPL model weight file to initialize SMPL model, and generate a 3D joints regressor file.
def _generate_smpl_weight_file(output_dir): """Generate a SMPL model weight file to initialize SMPL model, and generate a 3D joints regressor file.""" if not os.path.exists(output_dir): os.makedirs(output_dir) joint_regressor_file = os.path.join(output_dir, 'test_joint_regressor.npy') np.s...
[ "def", "_generate_smpl_weight_file", "(", "output_dir", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "output_dir", ")", ":", "os", ".", "makedirs", "(", "output_dir", ")", "joint_regressor_file", "=", "os", ".", "path", ".", "join", "(", ...
[ 11, 0 ]
[ 33, 10 ]
python
en
['en', 'en', 'en']
True
test_parametric_mesh_forward
()
Test parametric mesh forward.
Test parametric mesh forward.
def test_parametric_mesh_forward(): """Test parametric mesh forward.""" # generate weight file for SMPL model. _generate_smpl_weight_file('tests/data/smpl') # Test ParametricMesh without discriminator model_cfg = dict( pretrained=None, backbone=dict(type='ResNet', depth=50), ...
[ "def", "test_parametric_mesh_forward", "(", ")", ":", "# generate weight file for SMPL model.", "_generate_smpl_weight_file", "(", "'tests/data/smpl'", ")", "# Test ParametricMesh without discriminator", "model_cfg", "=", "dict", "(", "pretrained", "=", "None", ",", "backbone",...
[ 36, 0 ]
[ 125, 40 ]
python
en
['en', 'hi-Latn', 'en']
True
_demo_mm_inputs
(input_shape=(1, 3, 256, 256))
Create a superset of inputs needed to run test or train batches. Args: input_shape (tuple): input batch dimensions
Create a superset of inputs needed to run test or train batches.
def _demo_mm_inputs(input_shape=(1, 3, 256, 256)): """Create a superset of inputs needed to run test or train batches. Args: input_shape (tuple): input batch dimensions """ (N, C, H, W) = input_shape rng = np.random.RandomState(0) imgs = rng.rand(*input_shape) joints_2...
[ "def", "_demo_mm_inputs", "(", "input_shape", "=", "(", "1", ",", "3", ",", "256", ",", "256", ")", ")", ":", "(", "N", ",", "C", ",", "H", ",", "W", ")", "=", "input_shape", "rng", "=", "np", ".", "random", ".", "RandomState", "(", "0", ")", ...
[ 128, 0 ]
[ 172, 20 ]
python
en
['en', 'en', 'en']
True
precision
( preds: torch.Tensor, target: torch.Tensor, average: str = "micro", mdmc_average: Optional[str] = None, ignore_index: Optional[int] = None, num_classes: Optional[int] = None, threshold: float = 0.5, top_k: Optional[int] = None, is_multiclass: Optional[bool] = None, class_reducti...
r""" Computes `Precision <https://en.wikipedia.org/wiki/Precision_and_recall>`_: .. math:: \text{Precision} = \frac{\text{TP}}{\text{TP} + \text{FP}} Where :math:`\text{TP}` and :math:`\text{FP}` represent the number of true positives and false positives respecitively. With the use of ``top_k`` parame...
r""" Computes `Precision <https://en.wikipedia.org/wiki/Precision_and_recall>`_:
def precision( preds: torch.Tensor, target: torch.Tensor, average: str = "micro", mdmc_average: Optional[str] = None, ignore_index: Optional[int] = None, num_classes: Optional[int] = None, threshold: float = 0.5, top_k: Optional[int] = None, is_multiclass: Optional[bool] = None, ...
[ "def", "precision", "(", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "average", ":", "str", "=", "\"micro\"", ",", "mdmc_average", ":", "Optional", "[", "str", "]", "=", "None", ",", "ignore_index", ":", "Opti...
[ 39, 0 ]
[ 181, 68 ]
python
cy
['en', 'cy', 'hi']
False
recall
( preds: torch.Tensor, target: torch.Tensor, average: str = "micro", mdmc_average: Optional[str] = None, ignore_index: Optional[int] = None, num_classes: Optional[int] = None, threshold: float = 0.5, top_k: Optional[int] = None, is_multiclass: Optional[bool] = None, class_reducti...
r""" Computes `Recall <https://en.wikipedia.org/wiki/Precision_and_recall>`_: .. math:: \text{Recall} = \frac{\text{TP}}{\text{TP} + \text{FN}} Where :math:`\text{TP}` and :math:`\text{FN}` represent the number of true positives and false negatives respecitively. With the use of ``top_k`` parameter, t...
r""" Computes `Recall <https://en.wikipedia.org/wiki/Precision_and_recall>`_:
def recall( preds: torch.Tensor, target: torch.Tensor, average: str = "micro", mdmc_average: Optional[str] = None, ignore_index: Optional[int] = None, num_classes: Optional[int] = None, threshold: float = 0.5, top_k: Optional[int] = None, is_multiclass: Optional[bool] = None, cla...
[ "def", "recall", "(", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "average", ":", "str", "=", "\"micro\"", ",", "mdmc_average", ":", "Optional", "[", "str", "]", "=", "None", ",", "ignore_index", ":", "Optiona...
[ 201, 0 ]
[ 343, 65 ]
python
cy
['en', 'cy', 'hi']
False
precision_recall
( preds: torch.Tensor, target: torch.Tensor, average: str = "micro", mdmc_average: Optional[str] = None, ignore_index: Optional[int] = None, num_classes: Optional[int] = None, threshold: float = 0.5, top_k: Optional[int] = None, is_multiclass: Optional[bool] = None, class_reducti...
r""" Computes `Precision and Recall <https://en.wikipedia.org/wiki/Precision_and_recall>`_: .. math:: \text{Precision} = \frac{\text{TP}}{\text{TP} + \text{FP}} .. math:: \text{Recall} = \frac{\text{TP}}{\text{TP} + \text{FN}} Where :math:`\text{TP}`m :math:`\text{FN}` and :math:`\text{FP}` represen...
r""" Computes `Precision and Recall <https://en.wikipedia.org/wiki/Precision_and_recall>`_:
def precision_recall( preds: torch.Tensor, target: torch.Tensor, average: str = "micro", mdmc_average: Optional[str] = None, ignore_index: Optional[int] = None, num_classes: Optional[int] = None, threshold: float = 0.5, top_k: Optional[int] = None, is_multiclass: Optional[bool] = Non...
[ "def", "precision_recall", "(", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "average", ":", "str", "=", "\"micro\"", ",", "mdmc_average", ":", "Optional", "[", "str", "]", "=", "None", ",", "ignore_index", ":", ...
[ 346, 0 ]
[ 495, 28 ]
python
cy
['en', 'cy', 'hi']
False
main
(root)
Find deprecated escape sequences. Checks for deprecated escape sequences in ``*.py files``. If `root` is a file, that file is checked, if `root` is a directory all ``*.py`` files found in a recursive descent are checked. If a deprecated escape sequence is found, the file and line where found is pr...
Find deprecated escape sequences.
def main(root): """Find deprecated escape sequences. Checks for deprecated escape sequences in ``*.py files``. If `root` is a file, that file is checked, if `root` is a directory all ``*.py`` files found in a recursive descent are checked. If a deprecated escape sequence is found, the file and lin...
[ "def", "main", "(", "root", ")", ":", "import", "ast", "import", "tokenize", "import", "warnings", "from", "pathlib", "import", "Path", "count", "=", "0", "base", "=", "Path", "(", "root", ")", "paths", "=", "base", ".", "rglob", "(", "\"*.py\"", ")", ...
[ 13, 0 ]
[ 54, 32 ]
python
en
['en', 'en', 'en']
True
_aligned_zeros
(shape, dtype=float, order="C", align=None)
Allocate a new ndarray with aligned memory. The ndarray is guaranteed *not* aligned to twice the requested alignment. Eg, if align=4, guarantees it is not aligned to 8. If align=None uses dtype.alignment.
Allocate a new ndarray with aligned memory.
def _aligned_zeros(shape, dtype=float, order="C", align=None): """ Allocate a new ndarray with aligned memory. The ndarray is guaranteed *not* aligned to twice the requested alignment. Eg, if align=4, guarantees it is not aligned to 8. If align=None uses dtype.alignment.""" dtype = np.dtype(dty...
[ "def", "_aligned_zeros", "(", "shape", ",", "dtype", "=", "float", ",", "order", "=", "\"C\"", ",", "align", "=", "None", ")", ":", "dtype", "=", "np", ".", "dtype", "(", "dtype", ")", "if", "dtype", "==", "np", ".", "dtype", "(", "object", ")", ...
[ 63, 0 ]
[ 96, 15 ]
python
en
['en', 'error', 'th']
False
TestCreation.test_non_sequence_sequence
(self)
Should not segfault. Class Fail breaks the sequence protocol for new style classes, i.e., those derived from object. Class Map is a mapping type indicated by raising a ValueError. At some point we may raise a warning instead of an error in the Fail case.
Should not segfault.
def test_non_sequence_sequence(self): """Should not segfault. Class Fail breaks the sequence protocol for new style classes, i.e., those derived from object. Class Map is a mapping type indicated by raising a ValueError. At some point we may raise a warning instead of an error i...
[ "def", "test_non_sequence_sequence", "(", "self", ")", ":", "class", "Fail", "(", "object", ")", ":", "def", "__len__", "(", "self", ")", ":", "return", "1", "def", "__getitem__", "(", "self", ",", "index", ")", ":", "raise", "ValueError", "(", ")", "c...
[ 971, 4 ]
[ 997, 53 ]
python
en
['en', 'ca', 'en']
True
FizzBuzz.__init__
(self, fizz: Union[int, str, bool] = "Fizz", buzz: Union[int, str, bool] = "Buzz")
The general FizzBuzz object. Args: fizz (optional [int, str, bool]): The Fizz value. buzz (optional [int, str, bool]): The Buzz value. Params: current (list [int, str, bool]): A FizzBuzz
The general FizzBuzz object. Args: fizz (optional [int, str, bool]): The Fizz value. buzz (optional [int, str, bool]): The Buzz value. Params: current (list [int, str, bool]): A FizzBuzz
def __init__(self, fizz: Union[int, str, bool] = "Fizz", buzz: Union[int, str, bool] = "Buzz"): """The general FizzBuzz object. Args: fizz (optional [int, str, bool]): The Fizz value. buzz (optional [int, str, bool]): The Buzz value. ...
[ "def", "__init__", "(", "self", ",", "fizz", ":", "Union", "[", "int", ",", "str", ",", "bool", "]", "=", "\"Fizz\"", ",", "buzz", ":", "Union", "[", "int", ",", "str", ",", "bool", "]", "=", "\"Buzz\"", ")", ":", "self", ".", "fizz", "=", "fiz...
[ 10, 4 ]
[ 24, 47 ]
python
en
['en', 'en', 'en']
True
FizzBuzz.prep_collection
(collection: List[Union[int, str, bool]], delimiter: str = "\n")
Prepare your FizzBuzz collection for a string. Args: collection (list [int, str, bool]): Your FizzBuzz list. delimiter (optional str): The string delimiter. Default is \n (new line)
Prepare your FizzBuzz collection for a string. Args: collection (list [int, str, bool]): Your FizzBuzz list. delimiter (optional str): The string delimiter. Default is \n (new line)
def prep_collection(collection: List[Union[int, str, bool]], delimiter: str = "\n") -> str: """ Prepare your FizzBuzz collection for a string. Args: collection (list [int, str, bool]): Your FizzBuzz list. delimiter (optional str): The string delimiter. Default is \...
[ "def", "prep_collection", "(", "collection", ":", "List", "[", "Union", "[", "int", ",", "str", ",", "bool", "]", "]", ",", "delimiter", ":", "str", "=", "\"\\n\"", ")", "->", "str", ":", "return", "delimiter", ".", "join", "(", "[", "str", "(", "i...
[ 39, 4 ]
[ 47, 59 ]
python
en
['en', 'ja', 'th']
False
FizzBuzz.generate
(self, count: int = 100)
Generates the FizzBuzz array Args: count (int): The range for the FizzBuzz
Generates the FizzBuzz array Args: count (int): The range for the FizzBuzz
def generate(self, count: int = 100) -> Union[int, str, bool]: """ Generates the FizzBuzz array Args: count (int): The range for the FizzBuzz """ for i in range(1, count + 1): is_fizz = i % 3 == 0 is_buzz = i % 5 == 0 yie...
[ "def", "generate", "(", "self", ",", "count", ":", "int", "=", "100", ")", "->", "Union", "[", "int", ",", "str", ",", "bool", "]", ":", "for", "i", "in", "range", "(", "1", ",", "count", "+", "1", ")", ":", "is_fizz", "=", "i", "%", "3", "...
[ 49, 4 ]
[ 60, 69 ]
python
en
['en', 'ja', 'th']
False
DataConnector._with_is_last
(self, iterable)
Pass through values from the given iterable with an added boolean indicating if this is the last item. See `https://stackoverflow.com/a/1630350 <https://stackoverflow.com/a/1630350>`_
Pass through values from the given iterable with an added boolean indicating if this is the last item. See `https://stackoverflow.com/a/1630350 <https://stackoverflow.com/a/1630350>`_
def _with_is_last(self, iterable): """Pass through values from the given iterable with an added boolean indicating if this is the last item. See `https://stackoverflow.com/a/1630350 <https://stackoverflow.com/a/1630350>`_""" it = iter(iterable) last = next(it) for val in it: ...
[ "def", "_with_is_last", "(", "self", ",", "iterable", ")", ":", "it", "=", "iter", "(", "iterable", ")", "last", "=", "next", "(", "it", ")", "for", "val", "in", "it", ":", "# yield last and has next", "yield", "last", ",", "False", "last", "=", "val",...
[ 42, 4 ]
[ 52, 24 ]
python
en
['en', 'en', 'en']
True
check_submodules
()
verify that the submodules are checked out and clean use `git submodule update --init`; on failure
verify that the submodules are checked out and clean use `git submodule update --init`; on failure
def check_submodules(): """ verify that the submodules are checked out and clean use `git submodule update --init`; on failure """ if not os.path.exists('.git'): return with open('.gitmodules') as f: for l in f: if 'path' in l: p = l.split('=')[-1].str...
[ "def", "check_submodules", "(", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "'.git'", ")", ":", "return", "with", "open", "(", "'.gitmodules'", ")", "as", "f", ":", "for", "l", "in", "f", ":", "if", "'path'", "in", "l", ":", "p"...
[ 171, 0 ]
[ 191, 62 ]
python
en
['en', 'en', 'en']
True
parse_setuppy_commands
()
Check the commands and respond appropriately. Disable broken commands. Return a boolean value for whether or not to run the build or not (avoid parsing Cython and template files if False).
Check the commands and respond appropriately. Disable broken commands.
def parse_setuppy_commands(): """Check the commands and respond appropriately. Disable broken commands. Return a boolean value for whether or not to run the build or not (avoid parsing Cython and template files if False). """ args = sys.argv[1:] if not args: # User forgot to give an a...
[ "def", "parse_setuppy_commands", "(", ")", ":", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", "if", "not", "args", ":", "# User forgot to give an argument probably, let setuptools handle that.", "return", "True", "info_commands", "=", "[", "'--help-commands'", ...
[ 242, 0 ]
[ 368, 15 ]
python
en
['en', 'en', 'en']
True
concat_license_files.__enter__
(self)
Concatenate files and remove LICENSES_bundled.txt
Concatenate files and remove LICENSES_bundled.txt
def __enter__(self): """Concatenate files and remove LICENSES_bundled.txt""" with open(self.f1, 'r') as f1: self.bsd_text = f1.read() with open(self.f1, 'a') as f1: with open(self.f2, 'r') as f2: self.bundled_text = f2.read() f1.write('\n\...
[ "def", "__enter__", "(", "self", ")", ":", "with", "open", "(", "self", ".", "f1", ",", "'r'", ")", "as", "f1", ":", "self", ".", "bsd_text", "=", "f1", ".", "read", "(", ")", "with", "open", "(", "self", ".", "f1", ",", "'a'", ")", "as", "f1...
[ 204, 4 ]
[ 213, 43 ]
python
en
['en', 'en', 'en']
True
concat_license_files.__exit__
(self, exception_type, exception_value, traceback)
Restore content of both files
Restore content of both files
def __exit__(self, exception_type, exception_value, traceback): """Restore content of both files""" with open(self.f1, 'w') as f: f.write(self.bsd_text)
[ "def", "__exit__", "(", "self", ",", "exception_type", ",", "exception_value", ",", "traceback", ")", ":", "with", "open", "(", "self", ".", "f1", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "self", ".", "bsd_text", ")" ]
[ 215, 4 ]
[ 218, 34 ]
python
en
['en', 'en', 'en']
True
_sleep_generator
(durations)
the profile_iterable method needs an iterable in which we can ensure that we're properly timing how long it takes to call __next__
the profile_iterable method needs an iterable in which we can ensure that we're properly timing how long it takes to call __next__
def _sleep_generator(durations): """ the profile_iterable method needs an iterable in which we can ensure that we're properly timing how long it takes to call __next__ """ for duration in durations: time.sleep(duration) yield duration
[ "def", "_sleep_generator", "(", "durations", ")", ":", "for", "duration", "in", "durations", ":", "time", ".", "sleep", "(", "duration", ")", "yield", "duration" ]
[ 30, 0 ]
[ 37, 22 ]
python
en
['en', 'error', 'th']
False
test_simple_profiler_durations
(simple_profiler, action, expected)
Ensure the reported durations are reasonably accurate.
Ensure the reported durations are reasonably accurate.
def test_simple_profiler_durations(simple_profiler, action, expected): """Ensure the reported durations are reasonably accurate.""" for duration in expected: with simple_profiler.profile(action): time.sleep(duration) # different environments have different precision when it comes to ti...
[ "def", "test_simple_profiler_durations", "(", "simple_profiler", ",", "action", ",", "expected", ")", ":", "for", "duration", "in", "expected", ":", "with", "simple_profiler", ".", "profile", "(", "action", ")", ":", "time", ".", "sleep", "(", "duration", ")",...
[ 57, 0 ]
[ 66, 94 ]
python
en
['en', 'en', 'en']
True
test_simple_profiler_iterable_durations
(simple_profiler, action, expected)
Ensure the reported durations are reasonably accurate.
Ensure the reported durations are reasonably accurate.
def test_simple_profiler_iterable_durations(simple_profiler, action, expected): """Ensure the reported durations are reasonably accurate.""" iterable = _sleep_generator(expected) for _ in simple_profiler.profile_iterable(iterable, action): pass # we exclude the last item in the recorded durati...
[ "def", "test_simple_profiler_iterable_durations", "(", "simple_profiler", ",", "action", ",", "expected", ")", ":", "iterable", "=", "_sleep_generator", "(", "expected", ")", "for", "_", "in", "simple_profiler", ".", "profile_iterable", "(", "iterable", ",", "action...
[ 74, 0 ]
[ 82, 99 ]
python
en
['en', 'en', 'en']
True
test_simple_profiler_overhead
(simple_profiler, n_iter=5)
Ensure that the profiler doesn't introduce too much overhead during training.
Ensure that the profiler doesn't introduce too much overhead during training.
def test_simple_profiler_overhead(simple_profiler, n_iter=5): """Ensure that the profiler doesn't introduce too much overhead during training.""" for _ in range(n_iter): with simple_profiler.profile("no-op"): pass durations = np.array(simple_profiler.recorded_durations["no-op"]) ass...
[ "def", "test_simple_profiler_overhead", "(", "simple_profiler", ",", "n_iter", "=", "5", ")", ":", "for", "_", "in", "range", "(", "n_iter", ")", ":", "with", "simple_profiler", ".", "profile", "(", "\"no-op\"", ")", ":", "pass", "durations", "=", "np", "....
[ 85, 0 ]
[ 92, 59 ]
python
en
['en', 'en', 'en']
True
test_simple_profiler_describe
(caplog, simple_profiler)
Ensure the profiler won't fail when reporting the summary.
Ensure the profiler won't fail when reporting the summary.
def test_simple_profiler_describe(caplog, simple_profiler): """Ensure the profiler won't fail when reporting the summary.""" simple_profiler.describe() assert "Profiler Report" in caplog.text
[ "def", "test_simple_profiler_describe", "(", "caplog", ",", "simple_profiler", ")", ":", "simple_profiler", ".", "describe", "(", ")", "assert", "\"Profiler Report\"", "in", "caplog", ".", "text" ]
[ 95, 0 ]
[ 99, 43 ]
python
en
['en', 'en', 'en']
True
test_simple_profiler_value_errors
(simple_profiler)
Ensure errors are raised where expected.
Ensure errors are raised where expected.
def test_simple_profiler_value_errors(simple_profiler): """Ensure errors are raised where expected.""" action = "test" with pytest.raises(ValueError): simple_profiler.stop(action) simple_profiler.start(action) with pytest.raises(ValueError): simple_profiler.start(action) simp...
[ "def", "test_simple_profiler_value_errors", "(", "simple_profiler", ")", ":", "action", "=", "\"test\"", "with", "pytest", ".", "raises", "(", "ValueError", ")", ":", "simple_profiler", ".", "stop", "(", "action", ")", "simple_profiler", ".", "start", "(", "acti...
[ 102, 0 ]
[ 114, 32 ]
python
en
['en', 'en', 'en']
True
test_advanced_profiler_iterable_durations
(advanced_profiler, action, expected)
Ensure the reported durations are reasonably accurate.
Ensure the reported durations are reasonably accurate.
def test_advanced_profiler_iterable_durations(advanced_profiler, action, expected): """Ensure the reported durations are reasonably accurate.""" iterable = _sleep_generator(expected) for _ in advanced_profiler.profile_iterable(iterable, action): pass recored_total_duration = _get_python_cprofi...
[ "def", "test_advanced_profiler_iterable_durations", "(", "advanced_profiler", ",", "action", ",", "expected", ")", ":", "iterable", "=", "_sleep_generator", "(", "expected", ")", "for", "_", "in", "advanced_profiler", ".", "profile_iterable", "(", "iterable", ",", "...
[ 140, 0 ]
[ 149, 89 ]
python
en
['en', 'en', 'en']
True
test_advanced_profiler_overhead
(advanced_profiler, n_iter=5)
ensure that the profiler doesn't introduce too much overhead during training
ensure that the profiler doesn't introduce too much overhead during training
def test_advanced_profiler_overhead(advanced_profiler, n_iter=5): """ ensure that the profiler doesn't introduce too much overhead during training """ for _ in range(n_iter): with advanced_profiler.profile("no-op"): pass action_profile = advanced_profiler.profiled_actions["no-op...
[ "def", "test_advanced_profiler_overhead", "(", "advanced_profiler", ",", "n_iter", "=", "5", ")", ":", "for", "_", "in", "range", "(", "n_iter", ")", ":", "with", "advanced_profiler", ".", "profile", "(", "\"no-op\"", ")", ":", "pass", "action_profile", "=", ...
[ 152, 0 ]
[ 163, 61 ]
python
en
['en', 'error', 'th']
False
test_advanced_profiler_describe
(tmpdir, advanced_profiler)
ensure the profiler won't fail when reporting the summary
ensure the profiler won't fail when reporting the summary
def test_advanced_profiler_describe(tmpdir, advanced_profiler): """ ensure the profiler won't fail when reporting the summary """ # record at least one event with advanced_profiler.profile("test"): pass # log to stdout and print to file advanced_profiler.describe() data = Path(ad...
[ "def", "test_advanced_profiler_describe", "(", "tmpdir", ",", "advanced_profiler", ")", ":", "# record at least one event", "with", "advanced_profiler", ".", "profile", "(", "\"test\"", ")", ":", "pass", "# log to stdout and print to file", "advanced_profiler", ".", "descri...
[ 166, 0 ]
[ 176, 24 ]
python
en
['en', 'error', 'th']
False
test_advanced_profiler_value_errors
(advanced_profiler)
Ensure errors are raised where expected.
Ensure errors are raised where expected.
def test_advanced_profiler_value_errors(advanced_profiler): """Ensure errors are raised where expected.""" action = "test" with pytest.raises(ValueError): advanced_profiler.stop(action) advanced_profiler.start(action) advanced_profiler.stop(action)
[ "def", "test_advanced_profiler_value_errors", "(", "advanced_profiler", ")", ":", "action", "=", "\"test\"", "with", "pytest", ".", "raises", "(", "ValueError", ")", ":", "advanced_profiler", ".", "stop", "(", "action", ")", "advanced_profiler", ".", "start", "(",...
[ 179, 0 ]
[ 187, 34 ]
python
en
['en', 'en', 'en']
True
_validate_action_parameters
(func, params)
Verifies that the parameters specified are actual parameters for the function `func`, and that the field types are FIELD_* types in fields.
Verifies that the parameters specified are actual parameters for the function `func`, and that the field types are FIELD_* types in fields.
def _validate_action_parameters(func, params): """Verifies that the parameters specified are actual parameters for the function `func`, and that the field types are FIELD_* types in fields. """ if params is not None: # Verify field name is valid valid_fields = [getattr(fields, f) for f i...
[ "def", "_validate_action_parameters", "(", "func", ",", "params", ")", ":", "if", "params", "is", "not", "None", ":", "# Verify field name is valid", "valid_fields", "=", "[", "getattr", "(", "fields", ",", "f", ")", "for", "f", "in", "dir", "(", "fields", ...
[ 23, 0 ]
[ 41, 17 ]
python
en
['en', 'en', 'en']
True
rule_action
(label=None, params=None)
Decorator to make a function into a rule action
Decorator to make a function into a rule action
def rule_action(label=None, params=None): """Decorator to make a function into a rule action""" def wrapper(func): params_ = params if isinstance(params, dict): params_ = [ dict(label=fn_name_to_pretty_label(name), name=name, fieldType=field_type) for...
[ "def", "rule_action", "(", "label", "=", "None", ",", "params", "=", "None", ")", ":", "def", "wrapper", "(", "func", ")", ":", "params_", "=", "params", "if", "isinstance", "(", "params", ",", "dict", ")", ":", "params_", "=", "[", "dict", "(", "l...
[ 44, 0 ]
[ 60, 18 ]
python
en
['en', 'en', 'en']
True
test_ufunc_types
(ufunc)
Check all ufuncs that the correct type is returned. Avoid object and boolean types since many operations are not defined for for them. Choose the shape so even dot and matmul will succeed
Check all ufuncs that the correct type is returned. Avoid object and boolean types since many operations are not defined for for them.
def test_ufunc_types(ufunc): ''' Check all ufuncs that the correct type is returned. Avoid object and boolean types since many operations are not defined for for them. Choose the shape so even dot and matmul will succeed ''' for typ in ufunc.types: # types is a list of strings like ...
[ "def", "test_ufunc_types", "(", "ufunc", ")", ":", "for", "typ", "in", "ufunc", ".", "types", ":", "# types is a list of strings like ii->i", "if", "'O'", "in", "typ", "or", "'?'", "in", "typ", ":", "continue", "inp", ",", "out", "=", "typ", ".", "split", ...
[ 1887, 0 ]
[ 1910, 45 ]
python
en
['en', 'error', 'th']
False
test_ufunc_noncontiguous
(ufunc)
Check that contiguous and non-contiguous calls to ufuncs have the same results for values in range(9)
Check that contiguous and non-contiguous calls to ufuncs have the same results for values in range(9)
def test_ufunc_noncontiguous(ufunc): ''' Check that contiguous and non-contiguous calls to ufuncs have the same results for values in range(9) ''' for typ in ufunc.types: # types is a list of strings like ii->i if any(set('O?mM') & set(typ)): # bool, object, datetime are ...
[ "def", "test_ufunc_noncontiguous", "(", "ufunc", ")", ":", "for", "typ", "in", "ufunc", ".", "types", ":", "# types is a list of strings like ii->i", "if", "any", "(", "set", "(", "'O?mM'", ")", "&", "set", "(", "typ", ")", ")", ":", "# bool, object, datetime ...
[ 1914, 0 ]
[ 1948, 40 ]
python
en
['en', 'error', 'th']
False
TestUfunc.test_all_ufunc
(self)
Try to check presence and results of all ufuncs. The list of ufuncs comes from generate_umath.py and is as follows: ===== ==== ============= =============== ======================== done args function types notes ===== ==== ============= ===============...
Try to check presence and results of all ufuncs.
def test_all_ufunc(self): """Try to check presence and results of all ufuncs. The list of ufuncs comes from generate_umath.py and is as follows: ===== ==== ============= =============== ======================== done args function types notes ===== ...
[ "def", "test_all_ufunc", "(", "self", ")", ":", "pass" ]
[ 166, 4 ]
[ 247, 12 ]
python
en
['en', 'en', 'en']
True
TestUfunc.test_innerwt_empty
(self)
Test generalized ufunc with zero-sized operands
Test generalized ufunc with zero-sized operands
def test_innerwt_empty(self): """Test generalized ufunc with zero-sized operands""" a = np.array([], dtype='f8') b = np.array([], dtype='f8') w = np.array([], dtype='f8') assert_array_equal(umt.innerwt(a, b, w), np.sum(a*b*w, axis=-1))
[ "def", "test_innerwt_empty", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "]", ",", "dtype", "=", "'f8'", ")", "b", "=", "np", ".", "array", "(", "[", "]", ",", "dtype", "=", "'f8'", ")", "w", "=", "np", ".", "array", "(", ...
[ 891, 4 ]
[ 896, 72 ]
python
en
['en', 'pl', 'en']
True
TestUfunc.test_cross1d
(self)
Test with fixed-sized signature.
Test with fixed-sized signature.
def test_cross1d(self): """Test with fixed-sized signature.""" a = np.eye(3) assert_array_equal(umt.cross1d(a, a), np.zeros((3, 3))) out = np.zeros((3, 3)) result = umt.cross1d(a[0], a, out) assert_(result is out) assert_array_equal(result, np.vstack((np.zeros(3),...
[ "def", "test_cross1d", "(", "self", ")", ":", "a", "=", "np", ".", "eye", "(", "3", ")", "assert_array_equal", "(", "umt", ".", "cross1d", "(", "a", ",", "a", ")", ",", "np", ".", "zeros", "(", "(", "3", ",", "3", ")", ")", ")", "out", "=", ...
[ 898, 4 ]
[ 908, 82 ]
python
en
['en', 'en', 'en']
True
_from_ctypes_scalar
(t)
Return the dtype type with endianness included if it's the case
Return the dtype type with endianness included if it's the case
def _from_ctypes_scalar(t): """ Return the dtype type with endianness included if it's the case """ if getattr(t, '__ctype_be__', None) is t: return np.dtype('>' + t._type_) elif getattr(t, '__ctype_le__', None) is t: return np.dtype('<' + t._type_) else: return np.dtype(...
[ "def", "_from_ctypes_scalar", "(", "t", ")", ":", "if", "getattr", "(", "t", ",", "'__ctype_be__'", ",", "None", ")", "is", "t", ":", "return", "np", ".", "dtype", "(", "'>'", "+", "t", ".", "_type_", ")", "elif", "getattr", "(", "t", ",", "'__ctyp...
[ 68, 0 ]
[ 77, 33 ]
python
en
['en', 'error', 'th']
False
dtype_from_ctypes_type
(t)
Construct a dtype object from a ctypes type
Construct a dtype object from a ctypes type
def dtype_from_ctypes_type(t): """ Construct a dtype object from a ctypes type """ if issubclass(t, _ctypes.Array): return _from_ctypes_array(t) elif issubclass(t, _ctypes._Pointer): raise TypeError("ctypes pointers have no dtype equivalent") elif issubclass(t, _ctypes.Structure)...
[ "def", "dtype_from_ctypes_type", "(", "t", ")", ":", "if", "issubclass", "(", "t", ",", "_ctypes", ".", "Array", ")", ":", "return", "_from_ctypes_array", "(", "t", ")", "elif", "issubclass", "(", "t", ",", "_ctypes", ".", "_Pointer", ")", ":", "raise", ...
[ 96, 0 ]
[ 112, 56 ]
python
en
['en', 'error', 'th']
False
NameRegistry.__init__
(self, creator)
Create a new :class:`.NameRegistry`.
Create a new :class:`.NameRegistry`.
def __init__(self, creator): """Create a new :class:`.NameRegistry`. """ self._values = weakref.WeakValueDictionary() self._mutex = threading.RLock() self.creator = creator
[ "def", "__init__", "(", "self", ",", "creator", ")", ":", "self", ".", "_values", "=", "weakref", ".", "WeakValueDictionary", "(", ")", "self", ".", "_mutex", "=", "threading", ".", "RLock", "(", ")", "self", ".", "creator", "=", "creator" ]
[ 42, 4 ]
[ 49, 30 ]
python
en
['en', 'en', 'en']
True
NameRegistry.get
(self, identifier, *args, **kw)
r"""Get and possibly create the value. :param identifier: Hash key for the value. If the creation function is called, this identifier will also be passed to the creation function. :param \*args, \**kw: Additional arguments which will also be passed to the creation function if...
r"""Get and possibly create the value.
def get(self, identifier, *args, **kw): r"""Get and possibly create the value. :param identifier: Hash key for the value. If the creation function is called, this identifier will also be passed to the creation function. :param \*args, \**kw: Additional arguments which will ...
[ "def", "get", "(", "self", ",", "identifier", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "try", ":", "if", "identifier", "in", "self", ".", "_values", ":", "return", "self", ".", "_values", "[", "identifier", "]", "else", ":", "return", "self...
[ 51, 4 ]
[ 68, 58 ]
python
en
['en', 'en', 'en']
True
is_block
(modules)
Check if is ResNet building block.
Check if is ResNet building block.
def is_block(modules): """Check if is ResNet building block.""" if isinstance(modules, (ShuffleUnit, )): return True return False
[ "def", "is_block", "(", "modules", ")", ":", "if", "isinstance", "(", "modules", ",", "(", "ShuffleUnit", ",", ")", ")", ":", "return", "True", "return", "False" ]
[ 9, 0 ]
[ 13, 16 ]
python
en
['en', 'en', 'en']
True
is_norm
(modules)
Check if is one of the norms.
Check if is one of the norms.
def is_norm(modules): """Check if is one of the norms.""" if isinstance(modules, (GroupNorm, _BatchNorm)): return True return False
[ "def", "is_norm", "(", "modules", ")", ":", "if", "isinstance", "(", "modules", ",", "(", "GroupNorm", ",", "_BatchNorm", ")", ")", ":", "return", "True", "return", "False" ]
[ 16, 0 ]
[ 20, 16 ]
python
en
['en', 'en', 'en']
True
check_norm_state
(modules, train_state)
Check if norm layer is in correct train state.
Check if norm layer is in correct train state.
def check_norm_state(modules, train_state): """Check if norm layer is in correct train state.""" for mod in modules: if isinstance(mod, _BatchNorm): if mod.training != train_state: return False return True
[ "def", "check_norm_state", "(", "modules", ",", "train_state", ")", ":", "for", "mod", "in", "modules", ":", "if", "isinstance", "(", "mod", ",", "_BatchNorm", ")", ":", "if", "mod", ".", "training", "!=", "train_state", ":", "return", "False", "return", ...
[ 23, 0 ]
[ 29, 15 ]
python
en
['en', 'en', 'en']
True
TestMultiIndexingAutomated._get_multi_index
(self, arr, indices)
Mimic multi dimensional indexing. Parameters ---------- arr : ndarray Array to be indexed. indices : tuple of index objects Returns ------- out : ndarray An array equivalent to the indexing operation (but always a copy). `arr[...
Mimic multi dimensional indexing.
def _get_multi_index(self, arr, indices): """Mimic multi dimensional indexing. Parameters ---------- arr : ndarray Array to be indexed. indices : tuple of index objects Returns ------- out : ndarray An array equivalent to the inde...
[ "def", "_get_multi_index", "(", "self", ",", "arr", ",", "indices", ")", ":", "in_indices", "=", "list", "(", "indices", ")", "indices", "=", "[", "]", "# if False, this is a fancy or boolean index", "no_copy", "=", "True", "# number of fancy/scalar indexes that are n...
[ 822, 4 ]
[ 1059, 27 ]
python
id
['id', 'id', 'it']
True
TestMultiIndexingAutomated._check_multi_index
(self, arr, index)
Check a multi index item getting and simple setting. Parameters ---------- arr : ndarray Array to be indexed, must be a reshaped arange. index : tuple of indexing objects Index being tested.
Check a multi index item getting and simple setting.
def _check_multi_index(self, arr, index): """Check a multi index item getting and simple setting. Parameters ---------- arr : ndarray Array to be indexed, must be a reshaped arange. index : tuple of indexing objects Index being tested. """ ...
[ "def", "_check_multi_index", "(", "self", ",", "arr", ",", "index", ")", ":", "# Test item getting", "try", ":", "mimic_get", ",", "no_copy", "=", "self", ".", "_get_multi_index", "(", "arr", ",", "index", ")", "except", "Exception", "as", "e", ":", "if", ...
[ 1061, 4 ]
[ 1083, 66 ]
python
en
['en', 'en', 'en']
True
TestMultiIndexingAutomated._check_single_index
(self, arr, index)
Check a single index item getting and simple setting. Parameters ---------- arr : ndarray Array to be indexed, must be an arange. index : indexing object Index being tested. Must be a single index and not a tuple of indexing objects (see also `_check_...
Check a single index item getting and simple setting.
def _check_single_index(self, arr, index): """Check a single index item getting and simple setting. Parameters ---------- arr : ndarray Array to be indexed, must be an arange. index : indexing object Index being tested. Must be a single index and not a tu...
[ "def", "_check_single_index", "(", "self", ",", "arr", ",", "index", ")", ":", "try", ":", "mimic_get", ",", "no_copy", "=", "self", ".", "_get_multi_index", "(", "arr", ",", "(", "index", ",", ")", ")", "except", "Exception", "as", "e", ":", "if", "...
[ 1085, 4 ]
[ 1107, 66 ]
python
en
['en', 'en', 'en']
True
TestMultiIndexingAutomated._compare_index_result
(self, arr, index, mimic_get, no_copy)
Compare mimicked result to indexing result.
Compare mimicked result to indexing result.
def _compare_index_result(self, arr, index, mimic_get, no_copy): """Compare mimicked result to indexing result. """ arr = arr.copy() indexed_arr = arr[index] assert_array_equal(indexed_arr, mimic_get) # Check if we got a view, unless its a 0-sized or 0-d array. # ...
[ "def", "_compare_index_result", "(", "self", ",", "arr", ",", "index", ",", "mimic_get", ",", "no_copy", ")", ":", "arr", "=", "arr", ".", "copy", "(", ")", "indexed_arr", "=", "arr", "[", "index", "]", "assert_array_equal", "(", "indexed_arr", ",", "mim...
[ 1109, 4 ]
[ 1139, 34 ]
python
en
['en', 'en', 'en']
True
_command_line_ok
(_cache=None)
Return True if command line does not contain any help or display requests.
Return True if command line does not contain any help or display requests.
def _command_line_ok(_cache=None): """ Return True if command line does not contain any help or display requests. """ if _cache: return _cache[0] elif _cache is None: _cache = [] ok = True display_opts = ['--'+n for n in Distribution.display_option_names] for o in Distrib...
[ "def", "_command_line_ok", "(", "_cache", "=", "None", ")", ":", "if", "_cache", ":", "return", "_cache", "[", "0", "]", "elif", "_cache", "is", "None", ":", "_cache", "=", "[", "]", "ok", "=", "True", "display_opts", "=", "[", "'--'", "+", "n", "f...
[ 73, 0 ]
[ 91, 13 ]
python
en
['en', 'en', 'en']
True
atleast_1d
(*arys)
Convert inputs to arrays with at least one dimension. Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved. Parameters ---------- arys1, arys2, ... : array_like One or more input arrays. Returns ------- ret : ndarray ...
Convert inputs to arrays with at least one dimension.
def atleast_1d(*arys): """ Convert inputs to arrays with at least one dimension. Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved. Parameters ---------- arys1, arys2, ... : array_like One or more input arrays. Returns ----...
[ "def", "atleast_1d", "(", "*", "arys", ")", ":", "res", "=", "[", "]", "for", "ary", "in", "arys", ":", "ary", "=", "asanyarray", "(", "ary", ")", "if", "ary", ".", "ndim", "==", "0", ":", "result", "=", "ary", ".", "reshape", "(", "1", ")", ...
[ 24, 0 ]
[ 74, 18 ]
python
en
['en', 'error', 'th']
False
atleast_2d
(*arys)
View inputs as arrays with at least two dimensions. Parameters ---------- arys1, arys2, ... : array_like One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are preserved. Returns ------- res...
View inputs as arrays with at least two dimensions.
def atleast_2d(*arys): """ View inputs as arrays with at least two dimensions. Parameters ---------- arys1, arys2, ... : array_like One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have two or more dimensions are preserved. ...
[ "def", "atleast_2d", "(", "*", "arys", ")", ":", "res", "=", "[", "]", "for", "ary", "in", "arys", ":", "ary", "=", "asanyarray", "(", "ary", ")", "if", "ary", ".", "ndim", "==", "0", ":", "result", "=", "ary", ".", "reshape", "(", "1", ",", ...
[ 82, 0 ]
[ 132, 18 ]
python
en
['en', 'error', 'th']
False
atleast_3d
(*arys)
View inputs as arrays with at least three dimensions. Parameters ---------- arys1, arys2, ... : array_like One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved. Returns ------- ...
View inputs as arrays with at least three dimensions.
def atleast_3d(*arys): """ View inputs as arrays with at least three dimensions. Parameters ---------- arys1, arys2, ... : array_like One or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved...
[ "def", "atleast_3d", "(", "*", "arys", ")", ":", "res", "=", "[", "]", "for", "ary", "in", "arys", ":", "ary", "=", "asanyarray", "(", "ary", ")", "if", "ary", ".", "ndim", "==", "0", ":", "result", "=", "ary", ".", "reshape", "(", "1", ",", ...
[ 140, 0 ]
[ 204, 18 ]
python
en
['en', 'error', 'th']
False
vstack
(tup)
Stack arrays in sequence vertically (row wise). This is equivalent to concatenation along the first axis after 1-D arrays of shape `(N,)` have been reshaped to `(1,N)`. Rebuilds arrays divided by `vsplit`. This function makes most sense for arrays with up to 3 dimensions. For instance, for pi...
Stack arrays in sequence vertically (row wise).
def vstack(tup): """ Stack arrays in sequence vertically (row wise). This is equivalent to concatenation along the first axis after 1-D arrays of shape `(N,)` have been reshaped to `(1,N)`. Rebuilds arrays divided by `vsplit`. This function makes most sense for arrays with up to 3 dimensions. ...
[ "def", "vstack", "(", "tup", ")", ":", "if", "not", "overrides", ".", "ARRAY_FUNCTION_ENABLED", ":", "# raise warning if necessary", "_arrays_for_stack_dispatcher", "(", "tup", ",", "stacklevel", "=", "2", ")", "arrs", "=", "atleast_2d", "(", "*", "tup", ")", ...
[ 223, 0 ]
[ 281, 35 ]
python
en
['en', 'error', 'th']
False
hstack
(tup)
Stack arrays in sequence horizontally (column wise). This is equivalent to concatenation along the second axis, except for 1-D arrays where it concatenates along the first axis. Rebuilds arrays divided by `hsplit`. This function makes most sense for arrays with up to 3 dimensions. For instanc...
Stack arrays in sequence horizontally (column wise).
def hstack(tup): """ Stack arrays in sequence horizontally (column wise). This is equivalent to concatenation along the second axis, except for 1-D arrays where it concatenates along the first axis. Rebuilds arrays divided by `hsplit`. This function makes most sense for arrays with up to 3 dim...
[ "def", "hstack", "(", "tup", ")", ":", "if", "not", "overrides", ".", "ARRAY_FUNCTION_ENABLED", ":", "# raise warning if necessary", "_arrays_for_stack_dispatcher", "(", "tup", ",", "stacklevel", "=", "2", ")", "arrs", "=", "atleast_1d", "(", "*", "tup", ")", ...
[ 285, 0 ]
[ 343, 39 ]
python
en
['en', 'error', 'th']
False
stack
(arrays, axis=0, out=None)
Join a sequence of arrays along a new axis. The ``axis`` parameter specifies the index of the new axis in the dimensions of the result. For example, if ``axis=0`` it will be the first dimension and if ``axis=-1`` it will be the last dimension. .. versionadded:: 1.10.0 Parameters --------...
Join a sequence of arrays along a new axis.
def stack(arrays, axis=0, out=None): """ Join a sequence of arrays along a new axis. The ``axis`` parameter specifies the index of the new axis in the dimensions of the result. For example, if ``axis=0`` it will be the first dimension and if ``axis=-1`` it will be the last dimension. .. versio...
[ "def", "stack", "(", "arrays", ",", "axis", "=", "0", ",", "out", "=", "None", ")", ":", "if", "not", "overrides", ".", "ARRAY_FUNCTION_ENABLED", ":", "# raise warning if necessary", "_arrays_for_stack_dispatcher", "(", "arrays", ",", "stacklevel", "=", "2", "...
[ 356, 0 ]
[ 431, 63 ]
python
en
['en', 'error', 'th']
False
_block_format_index
(index)
Convert a list of indices ``[0, 1, 2]`` into ``"arrays[0][1][2]"``.
Convert a list of indices ``[0, 1, 2]`` into ``"arrays[0][1][2]"``.
def _block_format_index(index): """ Convert a list of indices ``[0, 1, 2]`` into ``"arrays[0][1][2]"``. """ idx_str = ''.join('[{}]'.format(i) for i in index if i is not None) return 'arrays' + idx_str
[ "def", "_block_format_index", "(", "index", ")", ":", "idx_str", "=", "''", ".", "join", "(", "'[{}]'", ".", "format", "(", "i", ")", "for", "i", "in", "index", "if", "i", "is", "not", "None", ")", "return", "'arrays'", "+", "idx_str" ]
[ 442, 0 ]
[ 447, 29 ]
python
en
['en', 'error', 'th']
False
_block_check_depths_match
(arrays, parent_index=[])
Recursive function checking that the depths of nested lists in `arrays` all match. Mismatch raises a ValueError as described in the block docstring below. The entire index (rather than just the depth) needs to be calculated for each innermost list, in case an error needs to be raised, so that ...
Recursive function checking that the depths of nested lists in `arrays` all match. Mismatch raises a ValueError as described in the block docstring below.
def _block_check_depths_match(arrays, parent_index=[]): """ Recursive function checking that the depths of nested lists in `arrays` all match. Mismatch raises a ValueError as described in the block docstring below. The entire index (rather than just the depth) needs to be calculated for each in...
[ "def", "_block_check_depths_match", "(", "arrays", ",", "parent_index", "=", "[", "]", ")", ":", "if", "type", "(", "arrays", ")", "is", "tuple", ":", "# not strictly necessary, but saves us from:", "# - more than one way to do things - no point treating tuples like", "# ...
[ 450, 0 ]
[ 523, 48 ]
python
en
['en', 'error', 'th']
False
_concatenate_shapes
(shapes, axis)
Given array shapes, return the resulting shape and slices prefixes. These help in nested concatation. Returns ------- shape: tuple of int This tuple satisfies: ``` shape, _ = _concatenate_shapes([arr.shape for shape in arrs], axis) shape == concatenate(arrs, axis).shape ...
Given array shapes, return the resulting shape and slices prefixes.
def _concatenate_shapes(shapes, axis): """Given array shapes, return the resulting shape and slices prefixes. These help in nested concatation. Returns ------- shape: tuple of int This tuple satisfies: ``` shape, _ = _concatenate_shapes([arr.shape for shape in arrs], axis) ...
[ "def", "_concatenate_shapes", "(", "shapes", ",", "axis", ")", ":", "# Cache a result that will be reused.", "shape_at_axis", "=", "[", "shape", "[", "axis", "]", "for", "shape", "in", "shapes", "]", "# Take a shape, any shape", "first_shape", "=", "shapes", "[", ...
[ 543, 0 ]
[ 598, 32 ]
python
en
['en', 'en', 'en']
True
_block_info_recursion
(arrays, max_depth, result_ndim, depth=0)
Returns the shape of the final array, along with a list of slices and a list of arrays that can be used for assignment inside the new array Parameters ---------- arrays : nested list of arrays The arrays to check max_depth : list of int The number of nested lists result...
Returns the shape of the final array, along with a list of slices and a list of arrays that can be used for assignment inside the new array
def _block_info_recursion(arrays, max_depth, result_ndim, depth=0): """ Returns the shape of the final array, along with a list of slices and a list of arrays that can be used for assignment inside the new array Parameters ---------- arrays : nested list of arrays The arrays to chec...
[ "def", "_block_info_recursion", "(", "arrays", ",", "max_depth", ",", "result_ndim", ",", "depth", "=", "0", ")", ":", "if", "depth", "<", "max_depth", ":", "shapes", ",", "slices", ",", "arrays", "=", "zip", "(", "*", "[", "_block_info_recursion", "(", ...
[ 601, 0 ]
[ 651, 37 ]
python
en
['en', 'error', 'th']
False
_block
(arrays, max_depth, result_ndim, depth=0)
Internal implementation of block based on repeated concatenation. `arrays` is the argument passed to block. `max_depth` is the depth of nested lists within `arrays` and `result_ndim` is the greatest of the dimensions of the arrays in `arrays` and the depth of the lists in `arrays` (see block docstr...
Internal implementation of block based on repeated concatenation. `arrays` is the argument passed to block. `max_depth` is the depth of nested lists within `arrays` and `result_ndim` is the greatest of the dimensions of the arrays in `arrays` and the depth of the lists in `arrays` (see block docstr...
def _block(arrays, max_depth, result_ndim, depth=0): """ Internal implementation of block based on repeated concatenation. `arrays` is the argument passed to block. `max_depth` is the depth of nested lists within `arrays` and `result_ndim` is the greatest of the dimensions of the arrays in `arra...
[ "def", "_block", "(", "arrays", ",", "max_depth", ",", "result_ndim", ",", "depth", "=", "0", ")", ":", "if", "depth", "<", "max_depth", ":", "arrs", "=", "[", "_block", "(", "arr", ",", "max_depth", ",", "result_ndim", ",", "depth", "+", "1", ")", ...
[ 654, 0 ]
[ 670, 47 ]
python
en
['en', 'error', 'th']
False
block
(arrays)
Assemble an nd-array from nested lists of blocks. Blocks in the innermost lists are concatenated (see `concatenate`) along the last dimension (-1), then these are concatenated along the second-last dimension (-2), and so on until the outermost list is reached. Blocks can be of any dimension, but ...
Assemble an nd-array from nested lists of blocks.
def block(arrays): """ Assemble an nd-array from nested lists of blocks. Blocks in the innermost lists are concatenated (see `concatenate`) along the last dimension (-1), then these are concatenated along the second-last dimension (-2), and so on until the outermost list is reached. Blocks can...
[ "def", "block", "(", "arrays", ")", ":", "arrays", ",", "list_ndim", ",", "result_ndim", ",", "final_size", "=", "_block_setup", "(", "arrays", ")", "# It was found through benchmarking that making an array of final size", "# around 256x256 was faster by straight concatenation ...
[ 686, 0 ]
[ 853, 65 ]
python
en
['en', 'error', 'th']
False
_block_setup
(arrays)
Returns (`arrays`, list_ndim, result_ndim, final_size)
Returns (`arrays`, list_ndim, result_ndim, final_size)
def _block_setup(arrays): """ Returns (`arrays`, list_ndim, result_ndim, final_size) """ bottom_index, arr_ndim, final_size = _block_check_depths_match(arrays) list_ndim = len(bottom_index) if bottom_index and bottom_index[-1] is None: raise ValueError( 'List at {} cannot...
[ "def", "_block_setup", "(", "arrays", ")", ":", "bottom_index", ",", "arr_ndim", ",", "final_size", "=", "_block_check_depths_match", "(", "arrays", ")", "list_ndim", "=", "len", "(", "bottom_index", ")", "if", "bottom_index", "and", "bottom_index", "[", "-", ...
[ 860, 0 ]
[ 874, 53 ]
python
en
['en', 'error', 'th']
False
DeepSpeedPrecisionPlugin.clip_gradients
(self, optimizer: Optimizer, clip_val: Union[int, float], norm_type: float = float(2.0))
DeepSpeed handles clipping gradients via the training type plugin.
DeepSpeed handles clipping gradients via the training type plugin.
def clip_gradients(self, optimizer: Optimizer, clip_val: Union[int, float], norm_type: float = float(2.0)): """ DeepSpeed handles clipping gradients via the training type plugin. """ pass
[ "def", "clip_gradients", "(", "self", ",", "optimizer", ":", "Optimizer", ",", "clip_val", ":", "Union", "[", "int", ",", "float", "]", ",", "norm_type", ":", "float", "=", "float", "(", "2.0", ")", ")", ":", "pass" ]
[ 56, 4 ]
[ 60, 12 ]
python
en
['en', 'error', 'th']
False
calculate_dose
(stack, pressurefield="pressure1", approx=1)
Maybe get rid of approx?.
Maybe get rid of approx?.
def calculate_dose(stack, pressurefield="pressure1", approx=1): """Maybe get rid of approx?.""" stack = stackify(stack) pressure = getattr(stack, pressurefield)[::approx] rel_time = stack.rel_time[::approx] approx_dose = np.cumsum(pressure * np.gradient(rel_time)) * 1e6 # scale up to original le...
[ "def", "calculate_dose", "(", "stack", ",", "pressurefield", "=", "\"pressure1\"", ",", "approx", "=", "1", ")", ":", "stack", "=", "stackify", "(", "stack", ")", "pressure", "=", "getattr", "(", "stack", ",", "pressurefield", ")", "[", ":", ":", "approx...
[ 24, 0 ]
[ 35, 60 ]
python
en
['en', 'en', 'en']
True
roify
(*args, **kwargs)
Takes either a single ROI, an iterable of ROIs or a set of arguments for the ROI constructor. Returns a list of ROIs (for the first and latter case, this list has length 1).
Takes either a single ROI, an iterable of ROIs or a set of arguments for the ROI constructor. Returns a list of ROIs (for the first and latter case, this list has length 1).
def roify(*args, **kwargs): """Takes either a single ROI, an iterable of ROIs or a set of arguments for the ROI constructor. Returns a list of ROIs (for the first and latter case, this list has length 1).""" if "rois" in kwargs: args = (*args, kwargs.pop("rois")) if args and isinstance(args[...
[ "def", "roify", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "\"rois\"", "in", "kwargs", ":", "args", "=", "(", "*", "args", ",", "kwargs", ".", "pop", "(", "\"rois\"", ")", ")", "if", "args", "and", "isinstance", "(", "args", "[", ...
[ 173, 0 ]
[ 188, 33 ]
python
en
['en', 'en', 'en']
True
Profile.xyC
(self)
xy "edge" values for pcolormesh
xy "edge" values for pcolormesh
def xyC(self): """xy "edge" values for pcolormesh""" x = np.linspace(self.endpoints[0, 0], self.endpoints[1, 0], self.length + 1) y = np.linspace(self.endpoints[0, 1], self.endpoints[1, 1], self.length + 1) return np.stack([x, y]).T
[ "def", "xyC", "(", "self", ")", ":", "x", "=", "np", ".", "linspace", "(", "self", ".", "endpoints", "[", "0", ",", "0", "]", ",", "self", ".", "endpoints", "[", "1", ",", "0", "]", ",", "self", ".", "length", "+", "1", ")", "y", "=", "np",...
[ 282, 4 ]
[ 286, 33 ]
python
en
['en', 'en', 'en']
True
FlatTestCase.testProcess1D
(self)
Test Process function 1D array
Test Process function 1D array
def testProcess1D(self): "Test Process function 1D array" print(self.typeStr, "... ", end=' ', file=sys.stderr) process = Flat.__dict__[self.typeStr + "Process"] pack_output = '' for i in range(10): pack_output += struct.pack(self.typeCode,i) x = np.frombuffer...
[ "def", "testProcess1D", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "process", "=", "Flat", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\...
[ 29, 4 ]
[ 39, 47 ]
python
en
['en', 'fr', 'en']
True
FlatTestCase.testProcess3D
(self)
Test Process function 3D array
Test Process function 3D array
def testProcess3D(self): "Test Process function 3D array" print(self.typeStr, "... ", end=' ', file=sys.stderr) process = Flat.__dict__[self.typeStr + "Process"] pack_output = '' for i in range(24): pack_output += struct.pack(self.typeCode,i) x = np.frombuffer...
[ "def", "testProcess3D", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "process", "=", "Flat", ".", "__dict__", "[", "self", ".", "typeStr", "+", "\...
[ 41, 4 ]
[ 52, 47 ]
python
en
['en', 'fr', 'en']
True