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
TransferLearningModel.forward
(self, x)
Forward pass. Returns logits.
Forward pass. Returns logits.
def forward(self, x): """Forward pass. Returns logits.""" # 1. Feature extraction: x = self.feature_extractor(x) x = x.squeeze(-1).squeeze(-1) # 2. Classifier (returns logits): x = self.fc(x) return torch.sigmoid(x)
[ "def", "forward", "(", "self", ",", "x", ")", ":", "# 1. Feature extraction:", "x", "=", "self", ".", "feature_extractor", "(", "x", ")", "x", "=", "x", ".", "squeeze", "(", "-", "1", ")", ".", "squeeze", "(", "-", "1", ")", "# 2. Classifier (returns l...
[ 215, 4 ]
[ 225, 31 ]
python
en
['fr', 'lb', 'en']
False
enabled_only
(fn: Callable)
Decorate a logger method to run it only on the process with rank 0. Args: fn: Function to decorate
Decorate a logger method to run it only on the process with rank 0.
def enabled_only(fn: Callable): """Decorate a logger method to run it only on the process with rank 0. Args: fn: Function to decorate """ @wraps(fn) def wrapped_fn(self, *args, **kwargs): if self.enabled: fn(self, *args, **kwargs) return wrapped_fn
[ "def", "enabled_only", "(", "fn", ":", "Callable", ")", ":", "@", "wraps", "(", "fn", ")", "def", "wrapped_fn", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "enabled", ":", "fn", "(", "self", ",", "*", "a...
[ 21, 0 ]
[ 33, 21 ]
python
en
['en', 'en', 'en']
True
TestFFTShift.test_uneven_dims
(self)
Test 2D input, which has uneven dimension sizes
Test 2D input, which has uneven dimension sizes
def test_uneven_dims(self): """ Test 2D input, which has uneven dimension sizes """ freqs = [ [0, 1], [2, 3], [4, 5] ] # shift in dimension 0 shift_dim0 = [ [4, 5], [0, 1], [2, 3] ] assert_ar...
[ "def", "test_uneven_dims", "(", "self", ")", ":", "freqs", "=", "[", "[", "0", ",", "1", "]", ",", "[", "2", ",", "3", "]", ",", "[", "4", ",", "5", "]", "]", "# shift in dimension 0", "shift_dim0", "=", "[", "[", "4", ",", "5", "]", ",", "["...
[ 41, 4 ]
[ 84, 71 ]
python
en
['en', 'en', 'en']
True
TestFFTShift.test_equal_to_original
(self)
Test that the new (>=v1.15) implementation (see #10073) is equal to the original (<=v1.14)
Test that the new (>=v1.15) implementation (see #10073) is equal to the original (<=v1.14)
def test_equal_to_original(self): """ Test that the new (>=v1.15) implementation (see #10073) is equal to the original (<=v1.14) """ from numpy.compat import integer_types from numpy.core import asarray, concatenate, arange, take def original_fftshift(x, axes=None): """ How ...
[ "def", "test_equal_to_original", "(", "self", ")", ":", "from", "numpy", ".", "compat", "import", "integer_types", "from", "numpy", ".", "core", "import", "asarray", ",", "concatenate", ",", "arange", ",", "take", "def", "original_fftshift", "(", "x", ",", "...
[ 86, 4 ]
[ 134, 84 ]
python
en
['en', 'en', 'en']
True
populate_example_meetings
( config: RecurringMeetingTestConfig, mock_now: datetime = None )
Test helper that populates mock data for meetings Creates 60 minute meetings between 1/1/2018 - 1/15/2018 that occur: * Monday + Friday * Each meeting lasts 60 minutes * Each matching Weekday has 3 times: - 19:00 UTC - 20:30 UTC - 22:00 UTC NOTE: When creating mock me...
Test helper that populates mock data for meetings
def populate_example_meetings( config: RecurringMeetingTestConfig, mock_now: datetime = None ): """Test helper that populates mock data for meetings Creates 60 minute meetings between 1/1/2018 - 1/15/2018 that occur: * Monday + Friday * Each meeting lasts 60 minutes * Each matching Weekda...
[ "def", "populate_example_meetings", "(", "config", ":", "RecurringMeetingTestConfig", ",", "mock_now", ":", "datetime", "=", "None", ")", ":", "now", "=", "timezone", ".", "now", "(", ")", "if", "mock_now", "is", "None", "else", "mock_now", "name", "=", "con...
[ 105, 0 ]
[ 138, 5 ]
python
en
['en', 'en', 'en']
True
mean_absolute_error
(preds: torch.Tensor, target: torch.Tensor)
Computes mean absolute error Args: pred: estimated labels target: ground truth labels Return: Tensor with MAE Example: >>> from pytorch_lightning.metrics.functional import mean_absolute_error >>> x = torch.tensor([0., 1, 2, 3]) >>> y = torch.tensor([0....
Computes mean absolute error
def mean_absolute_error(preds: torch.Tensor, target: torch.Tensor) -> torch.Tensor: """ Computes mean absolute error Args: pred: estimated labels target: ground truth labels Return: Tensor with MAE Example: >>> from pytorch_lightning.metrics.functional import mean_...
[ "def", "mean_absolute_error", "(", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ")", "->", "torch", ".", "Tensor", ":", "sum_abs_error", ",", "n_obs", "=", "_mean_absolute_error_update", "(", "preds", ",", "target", ")", ...
[ 31, 0 ]
[ 50, 61 ]
python
en
['en', 'error', 'th']
False
test_movielens_both_accuracy
()
Accuracy with both genre metadata and item-specific features shoul be no worse than with just item-specific features (though more training may be necessary).
Accuracy with both genre metadata and item-specific features shoul be no worse than with just item-specific features (though more training may be necessary).
def test_movielens_both_accuracy(): """ Accuracy with both genre metadata and item-specific features shoul be no worse than with just item-specific features (though more training may be necessary). """ item_features = fetch_movielens(indicator_features=True, ...
[ "def", "test_movielens_both_accuracy", "(", ")", ":", "item_features", "=", "fetch_movielens", "(", "indicator_features", "=", "True", ",", "genre_features", "=", "True", ")", "[", "'item_features'", "]", "model", "=", "LightFM", "(", "random_state", "=", "SEED", ...
[ 410, 0 ]
[ 427, 60 ]
python
en
['en', 'error', 'th']
False
GenericMemcachedBackend._imports
(self)
client library imports go here.
client library imports go here.
def _imports(self): """client library imports go here.""" raise NotImplementedError()
[ "def", "_imports", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 122, 4 ]
[ 124, 35 ]
python
en
['en', 'en', 'en']
True
GenericMemcachedBackend._create_client
(self)
Creation of a Client instance goes here.
Creation of a Client instance goes here.
def _create_client(self): """Creation of a Client instance goes here.""" raise NotImplementedError()
[ "def", "_create_client", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 126, 4 ]
[ 128, 35 ]
python
en
['en', 'en', 'en']
True
GenericMemcachedBackend.client
(self)
Return the memcached client. This uses a threading.local by default as it appears most modern memcached libs aren't inherently threadsafe.
Return the memcached client.
def client(self): """Return the memcached client. This uses a threading.local by default as it appears most modern memcached libs aren't inherently threadsafe. """ return self._clients.memcached
[ "def", "client", "(", "self", ")", ":", "return", "self", ".", "_clients", ".", "memcached" ]
[ 141, 4 ]
[ 150, 38 ]
python
en
['en', 'en', 'en']
True
BMemcachedBackend.delete_multi
(self, keys)
python-binary-memcached api does not implements delete_multi
python-binary-memcached api does not implements delete_multi
def delete_multi(self, keys): """python-binary-memcached api does not implements delete_multi""" for key in keys: self.delete(key)
[ "def", "delete_multi", "(", "self", ",", "keys", ")", ":", "for", "key", "in", "keys", ":", "self", ".", "delete", "(", "key", ")" ]
[ 360, 4 ]
[ 363, 28 ]
python
en
['en', 'en', 'en']
True
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.""" with open('vsearch.log', 'a') as log: print(req.form, req.remote_addr, req.user_agent, res, file=log, sep='|')
[ "def", "log_request", "(", "req", ":", "'flask_request'", ",", "res", ":", "str", ")", "->", "None", ":", "with", "open", "(", "'vsearch.log'", ",", "'a'", ")", "as", "log", ":", "print", "(", "req", ".", "form", ",", "req", ".", "remote_addr", ",", ...
[ 6, 0 ]
[ 9, 80 ]
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)) log_request(request, results) return render_template...
[ "def", "do_search", "(", ")", "->", "'html'", ":", "phrase", "=", "request", ".", "form", "[", "'phrase'", "]", "letters", "=", "request", ".", "form", "[", "'letters'", "]", "title", "=", "'Here are your results:'", "results", "=", "str", "(", "search4let...
[ 13, 0 ]
[ 24, 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!'", ")" ]
[ 29, 0 ]
[ 32, 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.""" contents = [] with open('vsearch.log') as log: for line in log: contents.append([]) for item in line.split('|'): contents[-1].append(escape(item)) titles = ('Form Dat...
[ "def", "view_the_log", "(", ")", "->", "'html'", ":", "contents", "=", "[", "]", "with", "open", "(", "'vsearch.log'", ")", "as", "log", ":", "for", "line", "in", "log", ":", "contents", ".", "append", "(", "[", "]", ")", "for", "item", "in", "line...
[ 36, 0 ]
[ 48, 46 ]
python
en
['en', 'en', 'en']
True
main
()
Kafka test generator script ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generates tests from Kafka protocol specification. Usage: launcher.py MESSAGE_TYPE OUTPUT_FILES INPUT_FILES where: MESSAGE_TYPE : 'request' or 'response' OUTPUT_FILES : location of 'requests_test.cc'/'responses_test.cc', 'reque...
Kafka test generator script ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generates tests from Kafka protocol specification.
def main(): """ Kafka test generator script ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generates tests from Kafka protocol specification. Usage: launcher.py MESSAGE_TYPE OUTPUT_FILES INPUT_FILES where: MESSAGE_TYPE : 'request' or 'response' OUTPUT_FILES : location of 'requests_test.cc'/'responses_test.cc', ...
[ "def", "main", "(", ")", ":", "type", "=", "sys", ".", "argv", "[", "1", "]", "header_test_cc_file", "=", "os", ".", "path", ".", "abspath", "(", "sys", ".", "argv", "[", "2", "]", ")", "codec_test_cc_file", "=", "os", ".", "path", ".", "abspath", ...
[ 9, 0 ]
[ 44, 86 ]
python
en
['en', 'error', 'th']
False
coverage_with_data_file
(data_file: str)
This context manager takes the path of a data file and creates a custom coveragerc with the data file path included. The context is yielded the path to the custom rc file.
This context manager takes the path of a data file and creates a custom coveragerc with the data file path included.
def coverage_with_data_file(data_file: str) -> Iterator[str]: """This context manager takes the path of a data file and creates a custom coveragerc with the data file path included. The context is yielded the path to the custom rc file. """ parser = ConfigParser() parser.read(".coveragerc") ...
[ "def", "coverage_with_data_file", "(", "data_file", ":", "str", ")", "->", "Iterator", "[", "str", "]", ":", "parser", "=", "ConfigParser", "(", ")", "parser", ".", "read", "(", "\".coveragerc\"", ")", "parser", "[", "\"run\"", "]", "[", "\"data_file\"", "...
[ 14, 0 ]
[ 28, 19 ]
python
en
['en', 'en', 'en']
True
buffered
( stdout: list = None, stderr: list = None, mangle: Optional[Callable[[list], list]] = None)
Captures stdout and stderr and feeds lines to supplied lists
Captures stdout and stderr and feeds lines to supplied lists
def buffered( stdout: list = None, stderr: list = None, mangle: Optional[Callable[[list], list]] = None) -> Iterator[None]: """Captures stdout and stderr and feeds lines to supplied lists""" mangle = mangle or (lambda lines: lines) if stdout is None and stderr is None: rais...
[ "def", "buffered", "(", "stdout", ":", "list", "=", "None", ",", "stderr", ":", "list", "=", "None", ",", "mangle", ":", "Optional", "[", "Callable", "[", "[", "list", "]", ",", "list", "]", "]", "=", "None", ")", "->", "Iterator", "[", "None", "...
[ 42, 0 ]
[ 70, 65 ]
python
en
['en', 'en', 'en']
True
TPUSpawnPlugin.load_spawn_weights
(self, original_model: LightningModule)
Load the temp weights saved in the process To recover the trained model from the ddp process we load the saved weights
Load the temp weights saved in the process To recover the trained model from the ddp process we load the saved weights
def load_spawn_weights(self, original_model: LightningModule) -> LightningModule: """ Load the temp weights saved in the process To recover the trained model from the ddp process we load the saved weights """ loaded_model = original_model if self.is_global_zero: ...
[ "def", "load_spawn_weights", "(", "self", ",", "original_model", ":", "LightningModule", ")", "->", "LightningModule", ":", "loaded_model", "=", "original_model", "if", "self", ".", "is_global_zero", ":", "# load weights saved in ddp", "path", "=", "os", ".", "path"...
[ 146, 4 ]
[ 165, 27 ]
python
en
['en', 'error', 'th']
False
TPUSpawnPlugin.save_spawn_weights
(self, model: LightningModule)
Dump a temporary checkpoint after ddp ends to get weights out of the process
Dump a temporary checkpoint after ddp ends to get weights out of the process
def save_spawn_weights(self, model: LightningModule) -> Optional[str]: """ Dump a temporary checkpoint after ddp ends to get weights out of the process """ if model.trainer.is_global_zero: path = os.path.join(model.trainer.default_root_dir, "__temp_weight_distributed_end.ckpt...
[ "def", "save_spawn_weights", "(", "self", ",", "model", ":", "LightningModule", ")", "->", "Optional", "[", "str", "]", ":", "if", "model", ".", "trainer", ".", "is_global_zero", ":", "path", "=", "os", ".", "path", ".", "join", "(", "model", ".", "tra...
[ 167, 4 ]
[ 174, 23 ]
python
en
['en', 'error', 'th']
False
TPUSpawnPlugin.save_checkpoint
(self, filepath, weights_only: bool = False)
Save model/training states as a checkpoint file through state-dump and file-write. Args: filepath: write-target file's path weights_only: saving model weights only
Save model/training states as a checkpoint file through state-dump and file-write.
def save_checkpoint(self, filepath, weights_only: bool = False): """Save model/training states as a checkpoint file through state-dump and file-write. Args: filepath: write-target file's path weights_only: saving model weights only """ # dump states as a checkpoi...
[ "def", "save_checkpoint", "(", "self", ",", "filepath", ",", "weights_only", ":", "bool", "=", "False", ")", ":", "# dump states as a checkpoint dictionary object", "_checkpoint", "=", "self", ".", "lightning_module", ".", "trainer", ".", "checkpoint_connector", ".", ...
[ 273, 4 ]
[ 283, 85 ]
python
en
['en', 'en', 'en']
True
Report.__init__
(self, metadata: dict = None, generate_pdf: bool = False)
Init Function to set attributes to the class. :param metadata: Dictionary with metadata to be included in the file, defaults to None :type metadata: dict, optional :param generate_pdf: Boolean to enable/disable pdf generation, defaults to False :type generate_pdf: bool, optional ...
Init Function to set attributes to the class.
def __init__(self, metadata: dict = None, generate_pdf: bool = False): """Init Function to set attributes to the class. :param metadata: Dictionary with metadata to be included in the file, defaults to None :type metadata: dict, optional :param generate_pdf: Boolean to enable/disable pd...
[ "def", "__init__", "(", "self", ",", "metadata", ":", "dict", "=", "None", ",", "generate_pdf", ":", "bool", "=", "False", ")", ":", "self", ".", "metadata", "=", "metadata", "self", ".", "generate_pdf", "=", "generate_pdf", "self", ".", "filepath", "=",...
[ 31, 4 ]
[ 43, 33 ]
python
en
['en', 'en', 'en']
True
Report.__enter__
(self, filepath: str = "./report.md")
Enter Function to implement with open method to manage report file. :param filepath: String with the filepath of the output report file, defaults to "./report.md" :type filepath: str, optional :return: An instance of the Report class :rtype: Report
Enter Function to implement with open method to manage report file.
def __enter__(self, filepath: str = "./report.md"): """Enter Function to implement with open method to manage report file. :param filepath: String with the filepath of the output report file, defaults to "./report.md" :type filepath: str, optional :return: An instance of the Report clas...
[ "def", "__enter__", "(", "self", ",", "filepath", ":", "str", "=", "\"./report.md\"", ")", ":", "self", ".", "filepath", "=", "filepath", "self", ".", "report_file", "=", "open", "(", "filepath", ",", "\"w\"", ",", "encoding", "=", "\"utf-8\"", ")", "sel...
[ 45, 4 ]
[ 62, 19 ]
python
en
['en', 'en', 'en']
True
Report.__exit__
(self, exc_type, exc_value, traceback)
Exit Function to implement with open method to manage report file. :param exc_type: Indicates class of exception :param exc_value: Indicates type of exception :param traceback: Report with all of the information needed to solve the exception
Exit Function to implement with open method to manage report file.
def __exit__(self, exc_type, exc_value, traceback): """Exit Function to implement with open method to manage report file. :param exc_type: Indicates class of exception :param exc_value: Indicates type of exception :param traceback: Report with all of the information needed to solve the ...
[ "def", "__exit__", "(", "self", ",", "exc_type", ",", "exc_value", ",", "traceback", ")", ":", "self", ".", "report_file", ".", "close", "(", ")", "# Opening the file in reading format", "with", "open", "(", "self", ".", "filepath", ",", "\"r\"", ",", "encod...
[ 64, 4 ]
[ 88, 13 ]
python
en
['en', 'en', 'en']
True
Report.parse_image
(img_path: str, title: str = "")
Parse image to Markdown syntax. :param img_path: String with the filepath of the image :type img_path: str :param title: String with the title of the image, defaults to "" :type title: str, optional :return: String with the image in markdown syntax :rtype: str
Parse image to Markdown syntax.
def parse_image(img_path: str, title: str = "") -> str: """Parse image to Markdown syntax. :param img_path: String with the filepath of the image :type img_path: str :param title: String with the title of the image, defaults to "" :type title: str, optional :return: Stri...
[ "def", "parse_image", "(", "img_path", ":", "str", ",", "title", ":", "str", "=", "\"\"", ")", "->", "str", ":", "return", "f\"![{title}]({img_path})\\n\"" ]
[ 91, 4 ]
[ 101, 42 ]
python
en
['en', 'en', 'en']
True
Report.parse_title
(title: str, h: int = 1)
Parse title to Markdown syntax. :param title: String with the title :type title: str :param h: Number with the header level, defaults to 1 :type h: int, optional :return: String with the title in markdown syntax :rtype: str
Parse title to Markdown syntax.
def parse_title(title: str, h: int = 1) -> str: """Parse title to Markdown syntax. :param title: String with the title :type title: str :param h: Number with the header level, defaults to 1 :type h: int, optional :return: String with the title in markdown syntax ...
[ "def", "parse_title", "(", "title", ":", "str", ",", "h", ":", "int", "=", "1", ")", "->", "str", ":", "h_title", "=", "\"#\"", "*", "h", "return", "h_title", "+", "\" \"", "+", "title", "+", "\"\\n\"" ]
[ 104, 4 ]
[ 115, 43 ]
python
en
['en', 'en', 'en']
True
Report.parse_list
(listmd: list, unordered: str = "")
Parse list to Markdown syntax. :param listmd: List with values to be printed :type listmd: list :param unordered: String with the character of the ul element, defaults to "" :type unordered: str, optional :return: String with the list in markdown syntax :rtype: str ...
Parse list to Markdown syntax.
def parse_list(listmd: list, unordered: str = "") -> str: """Parse list to Markdown syntax. :param listmd: List with values to be printed :type listmd: list :param unordered: String with the character of the ul element, defaults to "" :type unordered: str, optional :retu...
[ "def", "parse_list", "(", "listmd", ":", "list", ",", "unordered", ":", "str", "=", "\"\"", ")", "->", "str", ":", "output", "=", "\"\"", "if", "unordered", ":", "# Argument must include one of the following characters: -,*,+", "for", "element", "in", "listmd", ...
[ 118, 4 ]
[ 138, 21 ]
python
en
['en', 'en', 'en']
True
Report.parse_code
(codeblock: str, language: str = "python")
Parse code to Markdown syntax. :param codeblock: String input with the codeblock :type codeblock: str :param language: Coding language to lint the code, defaults to "python" :type language: str, optional :return: String with the codeblock in markdown syntax :rtype: str ...
Parse code to Markdown syntax.
def parse_code(codeblock: str, language: str = "python") -> str: """Parse code to Markdown syntax. :param codeblock: String input with the codeblock :type codeblock: str :param language: Coding language to lint the code, defaults to "python" :type language: str, optional ...
[ "def", "parse_code", "(", "codeblock", ":", "str", ",", "language", ":", "str", "=", "\"python\"", ")", "->", "str", ":", "return", "f\"```{language}\\n{codeblock}\\n```\"" ]
[ 141, 4 ]
[ 151, 49 ]
python
en
['en', 'en', 'en']
True
Report.parse_noformat
(paragraph: str)
Parse paragraph to avoid Markdown syntax. :param paragraph: String paragraph input :type paragraph: str :return: String avoiding markdown syntax, returned as a plain textblock :rtype: str
Parse paragraph to avoid Markdown syntax.
def parse_noformat(paragraph: str) -> str: """Parse paragraph to avoid Markdown syntax. :param paragraph: String paragraph input :type paragraph: str :return: String avoiding markdown syntax, returned as a plain textblock :rtype: str """ return f"\n```no-format\n...
[ "def", "parse_noformat", "(", "paragraph", ":", "str", ")", "->", "str", ":", "return", "f\"\\n```no-format\\n{paragraph}\\n```\\n\"" ]
[ 154, 4 ]
[ 162, 52 ]
python
en
['en', 'en', 'en']
True
Report.parse_dataframe
(data: pd.DataFrame, rows: int = 5)
Parse dataframe to a markdown table showing the rows given by rows argument. :param data: Pandas dataframe to be parsed to markdown table :type data: pd.DataFrame :param rows: Number of rows to be parsed, defaults to 5 :type rows: int, optional :return: Markdown table in string ...
Parse dataframe to a markdown table showing the rows given by rows argument.
def parse_dataframe(data: pd.DataFrame, rows: int = 5) -> str: """Parse dataframe to a markdown table showing the rows given by rows argument. :param data: Pandas dataframe to be parsed to markdown table :type data: pd.DataFrame :param rows: Number of rows to be parsed, defaults to 5 ...
[ "def", "parse_dataframe", "(", "data", ":", "pd", ".", "DataFrame", ",", "rows", ":", "int", "=", "5", ")", "->", "str", ":", "return", "f\"{data.head(rows).to_markdown()}\\n\\n\"" ]
[ 165, 4 ]
[ 175, 53 ]
python
en
['en', 'en', 'en']
True
Report.parse_pdf
(mdstring: str)
Parse Markdown string to avoid incompatibility syntax with md2pdf. :param mdstring: String input in markdown syntax :type mdstring: str :return: String output with html <pre> tags :rtype: [type]
Parse Markdown string to avoid incompatibility syntax with md2pdf.
def parse_pdf(mdstring: str): """Parse Markdown string to avoid incompatibility syntax with md2pdf. :param mdstring: String input in markdown syntax :type mdstring: str :return: String output with html <pre> tags :rtype: [type] """ pdfstring = mdstring.replace("`...
[ "def", "parse_pdf", "(", "mdstring", ":", "str", ")", ":", "pdfstring", "=", "mdstring", ".", "replace", "(", "\"```no-format\"", ",", "\"<pre>\"", ")", ".", "replace", "(", "\"```\"", ",", "\"</pre>\"", ")", "return", "pdfstring" ]
[ 178, 4 ]
[ 189, 24 ]
python
en
['en', 'en', 'en']
True
Report.print
(self, paragraph: str)
Print plain text to report file in Markdown syntax. :param paragraph: String paragraph to be printed in the report file :type paragraph: str
Print plain text to report file in Markdown syntax.
def print(self, paragraph: str): """Print plain text to report file in Markdown syntax. :param paragraph: String paragraph to be printed in the report file :type paragraph: str """ self.report_file.write(f"{paragraph}\n")
[ "def", "print", "(", "self", ",", "paragraph", ":", "str", ")", ":", "self", ".", "report_file", ".", "write", "(", "f\"{paragraph}\\n\"", ")" ]
[ 192, 4 ]
[ 198, 48 ]
python
en
['en', 'en', 'en']
True
Report.print_noformat
(self, paragraph: str)
Print plain text to report file escaping Markdown syntax. :param paragraph: String paragraph to be printed in the report file with no format :type paragraph: str
Print plain text to report file escaping Markdown syntax.
def print_noformat(self, paragraph: str): """Print plain text to report file escaping Markdown syntax. :param paragraph: String paragraph to be printed in the report file with no format :type paragraph: str """ self.report_file.write(f"{self.parse_noformat(paragraph)}\n")
[ "def", "print_noformat", "(", "self", ",", "paragraph", ":", "str", ")", ":", "self", ".", "report_file", ".", "write", "(", "f\"{self.parse_noformat(paragraph)}\\n\"", ")" ]
[ 200, 4 ]
[ 206, 69 ]
python
en
['en', 'en', 'en']
True
Report.print_line
(self)
Print horizontal line to report file in Markdown syntax.
Print horizontal line to report file in Markdown syntax.
def print_line(self): """Print horizontal line to report file in Markdown syntax.""" self.report_file.write("\n---\n")
[ "def", "print_line", "(", "self", ")", ":", "self", ".", "report_file", ".", "write", "(", "\"\\n---\\n\"", ")" ]
[ 208, 4 ]
[ 210, 41 ]
python
en
['en', 'en', 'en']
True
Report.print_title
(self, title: str, h: int = 1)
Print title to report file in Markdown syntax. :param title: String title to be printed :type title: str :param h: Number with the header level, defaults to 1 :type h: int, optional
Print title to report file in Markdown syntax.
def print_title(self, title: str, h: int = 1): """Print title to report file in Markdown syntax. :param title: String title to be printed :type title: str :param h: Number with the header level, defaults to 1 :type h: int, optional """ self.report_file.write(f"{s...
[ "def", "print_title", "(", "self", ",", "title", ":", "str", ",", "h", ":", "int", "=", "1", ")", ":", "self", ".", "report_file", ".", "write", "(", "f\"{self.parse_title(title,h)}\\n\"", ")" ]
[ 212, 4 ]
[ 220, 64 ]
python
en
['en', 'en', 'en']
True
Report.print_code
(self, codeblock: str, language: str = "python")
Print code to report file in Markdown syntax. :param codeblock: String input with the codeblock :type codeblock: str :param language: Coding language to lint the code, defaults to "python" :type language: str, optional
Print code to report file in Markdown syntax.
def print_code(self, codeblock: str, language: str = "python"): """Print code to report file in Markdown syntax. :param codeblock: String input with the codeblock :type codeblock: str :param language: Coding language to lint the code, defaults to "python" :type language: str, op...
[ "def", "print_code", "(", "self", ",", "codeblock", ":", "str", ",", "language", ":", "str", "=", "\"python\"", ")", ":", "self", ".", "report_file", ".", "write", "(", "f\"{self.parse_code(codeblock, language)}\\n\"", ")" ]
[ 222, 4 ]
[ 230, 75 ]
python
en
['en', 'en', 'en']
True
Report.print_boxplot
( self, data: pd.DataFrame, labels: list, filename: str = "boxplot.png", img_title: str = "Box Plot", figsize: tuple = (15, 7), color: str = "green", orient: str = "v", same_scale: bool = False, **kwargs, )
Print to file the boxplot of the given data. :param data: Pandas Dataframe with data to be plotted :type data: pd.DataFrame :param labels: List containing the column tags to be plotted :type labels: list :param filename: String with the filename of the output image, defaults to ...
Print to file the boxplot of the given data.
def print_boxplot( self, data: pd.DataFrame, labels: list, filename: str = "boxplot.png", img_title: str = "Box Plot", figsize: tuple = (15, 7), color: str = "green", orient: str = "v", same_scale: bool = False, **kwargs, ): """...
[ "def", "print_boxplot", "(", "self", ",", "data", ":", "pd", ".", "DataFrame", ",", "labels", ":", "list", ",", "filename", ":", "str", "=", "\"boxplot.png\"", ",", "img_title", ":", "str", "=", "\"Box Plot\"", ",", "figsize", ":", "tuple", "=", "(", "...
[ 232, 4 ]
[ 275, 59 ]
python
en
['en', 'en', 'en']
True
Report.print_confusion_matrix
( self, model: BaseEstimator, X_test: np.ndarray, t_test: np.ndarray, xlabel: str, ylabel: str, filename: str = "confusion_matrix.png", img_title: str = "Confusion Matrix", size_dpi: int = 100, **kwargs, )
Print confusion matrix plot of the given model. :param model: Model which be used to print the confusion matrix :type model: BaseEstimator :param X_test: Numpy array with the X_test values :type X_test: np.ndarray :param t_test: Numpy array with the t_test values :type t...
Print confusion matrix plot of the given model.
def print_confusion_matrix( self, model: BaseEstimator, X_test: np.ndarray, t_test: np.ndarray, xlabel: str, ylabel: str, filename: str = "confusion_matrix.png", img_title: str = "Confusion Matrix", size_dpi: int = 100, **kwargs, ): ...
[ "def", "print_confusion_matrix", "(", "self", ",", "model", ":", "BaseEstimator", ",", "X_test", ":", "np", ".", "ndarray", ",", "t_test", ":", "np", ".", "ndarray", ",", "xlabel", ":", "str", ",", "ylabel", ":", "str", ",", "filename", ":", "str", "="...
[ 277, 4 ]
[ 317, 68 ]
python
en
['en', 'en', 'en']
True
Report.print_confusion_matrix_DNN
( self, t_test: np.ndarray, y_pred: np.ndarray, xlabel: str, ylabel: str, title: str, )
Print confusion matrix plot of the given DNN model. :param t_test: Numpy array with the t_test values :type t_test: np.ndarray :param y_pred: Numpy array with the y predicted values :type y_pred: np.ndarray :param xlabel: String with the label of the x axe :type xlabel: ...
Print confusion matrix plot of the given DNN model.
def print_confusion_matrix_DNN( self, t_test: np.ndarray, y_pred: np.ndarray, xlabel: str, ylabel: str, title: str, ): """Print confusion matrix plot of the given DNN model. :param t_test: Numpy array with the t_test values :type t_test: np.nd...
[ "def", "print_confusion_matrix_DNN", "(", "self", ",", "t_test", ":", "np", ".", "ndarray", ",", "y_pred", ":", "np", ".", "ndarray", ",", "xlabel", ":", "str", ",", "ylabel", ":", "str", ",", "title", ":", "str", ",", ")", ":", "m", "=", "confusion_...
[ 319, 4 ]
[ 349, 39 ]
python
en
['en', 'en', 'en']
True
Report.print_roc_curve
( self, t_test: np.ndarray, y_score: np.ndarray, filename: str = "roc_curve.png", img_title: str = "Roc Curve per class", figsize: tuple = (10, 8), xlabel: str = "False Positive Rate", ylabel: str = "True Positive Rate", legend_loc: str = "lower ri...
Print roc curves for any labels of the given model. :param t_test: Numpy array with the t_test values :type t_test: np.ndarray :param y_score: Numpy array with the y score values :type y_pred: np.ndarray :param filename: String with the filename of the output image, defaults to ...
Print roc curves for any labels of the given model.
def print_roc_curve( self, t_test: np.ndarray, y_score: np.ndarray, filename: str = "roc_curve.png", img_title: str = "Roc Curve per class", figsize: tuple = (10, 8), xlabel: str = "False Positive Rate", ylabel: str = "True Positive Rate", legend_l...
[ "def", "print_roc_curve", "(", "self", ",", "t_test", ":", "np", ".", "ndarray", ",", "y_score", ":", "np", ".", "ndarray", ",", "filename", ":", "str", "=", "\"roc_curve.png\"", ",", "img_title", ":", "str", "=", "\"Roc Curve per class\"", ",", "figsize", ...
[ 351, 4 ]
[ 437, 59 ]
python
en
['en', 'en', 'en']
True
Report.print_clreport
( self, t_test: np.ndarray, y_pred: np.ndarray, title: str = "Classification report", )
Print the classification report to the report file. :param t_test: Numpy array with the t_test values :type t_test: np.ndarray :param y_pred: Numpy array with the y predicted values :type y_pred: np.ndarray :param title: String title for the classification report, defaults to "C...
Print the classification report to the report file.
def print_clreport( self, t_test: np.ndarray, y_pred: np.ndarray, title: str = "Classification report", ): """Print the classification report to the report file. :param t_test: Numpy array with the t_test values :type t_test: np.ndarray :param y_pred:...
[ "def", "print_clreport", "(", "self", ",", "t_test", ":", "np", ".", "ndarray", ",", "y_pred", ":", "np", ".", "ndarray", ",", "title", ":", "str", "=", "\"Classification report\"", ",", ")", ":", "self", ".", "print_noformat", "(", "title", "+", "\":\\n...
[ 439, 4 ]
[ 456, 9 ]
python
en
['en', 'en', 'en']
True
Report.print_hpcontrast
(self, data: list, labels: list, alpha: float = 0.05)
Contrast the hypoteses of the scores given in the list and print the results in the report. Using Kurskal-Wallis and Tuckeyhsd tests. :param data: List containing the metric results of the models :type data: list :param labels: List containg the models tags :type labels: list ...
Contrast the hypoteses of the scores given in the list and print the results in the report.
def print_hpcontrast(self, data: list, labels: list, alpha: float = 0.05): """Contrast the hypoteses of the scores given in the list and print the results in the report. Using Kurskal-Wallis and Tuckeyhsd tests. :param data: List containing the metric results of the models :type data: ...
[ "def", "print_hpcontrast", "(", "self", ",", "data", ":", "list", ",", "labels", ":", "list", ",", "alpha", ":", "float", "=", "0.05", ")", ":", "_", ",", "pVal", "=", "stats", ".", "kruskal", "(", "*", "data", ")", "str_toprint", "=", "f\"p-valor Kr...
[ 458, 4 ]
[ 490, 40 ]
python
en
['en', 'en', 'en']
True
Report.print_validation_curve
( self, model: BaseEstimator, X: np.ndarray, y: np.ndarray, param_name: str, param_range=np.logspace(-6, -1, 5), ylabel: str = "Score", filename: str = "validation_curve.png", img_title: str = "Validation Curve", figsize: tuple = (10, 8), ...
Print validation curve plot of the given model. :param model: Model which be used to plot the validation curve :type model: BaseEstimator :param X: Numpy array with the characteristic matrix :type X: np.ndarray :param y: Numpy array with the predicted values :type y: np....
Print validation curve plot of the given model.
def print_validation_curve( self, model: BaseEstimator, X: np.ndarray, y: np.ndarray, param_name: str, param_range=np.logspace(-6, -1, 5), ylabel: str = "Score", filename: str = "validation_curve.png", img_title: str = "Validation Curve", f...
[ "def", "print_validation_curve", "(", "self", ",", "model", ":", "BaseEstimator", ",", "X", ":", "np", ".", "ndarray", ",", "y", ":", "np", ".", "ndarray", ",", "param_name", ":", "str", ",", "param_range", "=", "np", ".", "logspace", "(", "-", "6", ...
[ 492, 4 ]
[ 579, 59 ]
python
en
['en', 'en', 'en']
True
Report.print_mean_acc_model
( self, best_models: tuple, tag: str, filename: str = "mean_accuracy.png", img_title: str = "Mean Accuracy", **kwargs, )
Plot the mean accuracy of the model using its historial results to the report. :param best_models: Tuple with the best models to print their mean accuracy curves :type best_models: tuple :param tag: String with the tag of the model to be printed :type tag: str :param filename: S...
Plot the mean accuracy of the model using its historial results to the report.
def print_mean_acc_model( self, best_models: tuple, tag: str, filename: str = "mean_accuracy.png", img_title: str = "Mean Accuracy", **kwargs, ): """Plot the mean accuracy of the model using its historial results to the report. :param best_models: Tup...
[ "def", "print_mean_acc_model", "(", "self", ",", "best_models", ":", "tuple", ",", "tag", ":", "str", ",", "filename", ":", "str", "=", "\"mean_accuracy.png\"", ",", "img_title", ":", "str", "=", "\"Mean Accuracy\"", ",", "*", "*", "kwargs", ",", ")", ":",...
[ 581, 4 ]
[ 608, 59 ]
python
en
['en', 'en', 'en']
True
Report.print_val_curve_dnn
( self, best_DNN: tuple, metric: str = "accuracy", filename: str = "validation_curve_dnn.png", img_title: str = "Validation Curve", **kwargs, )
Plot the validation curve of the model using its historial results to the report. :param best_DNN: Tuple with the best models to print their validation curves :type best_DNN: tuple :param metric: String with the metric used to perform the validation curve, defaults to "accuracy" :type m...
Plot the validation curve of the model using its historial results to the report.
def print_val_curve_dnn( self, best_DNN: tuple, metric: str = "accuracy", filename: str = "validation_curve_dnn.png", img_title: str = "Validation Curve", **kwargs, ): """Plot the validation curve of the model using its historial results to the report. ...
[ "def", "print_val_curve_dnn", "(", "self", ",", "best_DNN", ":", "tuple", ",", "metric", ":", "str", "=", "\"accuracy\"", ",", "filename", ":", "str", "=", "\"validation_curve_dnn.png\"", ",", "img_title", ":", "str", "=", "\"Validation Curve\"", ",", "*", "*"...
[ 610, 4 ]
[ 637, 59 ]
python
en
['en', 'en', 'en']
True
Report.print_dataframe
(self, data: pd.DataFrame, rows: int = 5)
Print the dataframe with the given rows to the report file. If the dataframe have more than 5 columns, will be divided to print in the report. :param data: Pandas dataframe to be printed :type data: pd.DataFrame :param rows: Number of rows of the dataframe to be printed, defaults to 5 ...
Print the dataframe with the given rows to the report file.
def print_dataframe(self, data: pd.DataFrame, rows: int = 5): """Print the dataframe with the given rows to the report file. If the dataframe have more than 5 columns, will be divided to print in the report. :param data: Pandas dataframe to be printed :type data: pd.DataFrame :...
[ "def", "print_dataframe", "(", "self", ",", "data", ":", "pd", ".", "DataFrame", ",", "rows", ":", "int", "=", "5", ")", ":", "if", "(", "data", ".", "shape", "[", "1", "]", ")", ">", "5", ":", "colum_start", "=", "0", "colum_end", "=", "5", "n...
[ 639, 4 ]
[ 663, 68 ]
python
en
['en', 'en', 'en']
True
Report.print_kmeans
( self, inertia_dic: dict, X: np.ndarray, ylabel: str = "Inertia", filename: str = "kmeans.png", img_title: str = "KMeans Clustering", figsize: tuple = (10, 8), )
Print the kmeans clustering for the given X dataframe and inertias dictionary. :param inertia_dic: Dictionary with the inertias obtained from kmeans model :type inertia_dic: dict :param X: Dataframe to be clustered :type X: np.ndarray :param ylabel: String with the label for the...
Print the kmeans clustering for the given X dataframe and inertias dictionary.
def print_kmeans( self, inertia_dic: dict, X: np.ndarray, ylabel: str = "Inertia", filename: str = "kmeans.png", img_title: str = "KMeans Clustering", figsize: tuple = (10, 8), ): """Print the kmeans clustering for the given X dataframe and inertias di...
[ "def", "print_kmeans", "(", "self", ",", "inertia_dic", ":", "dict", ",", "X", ":", "np", ".", "ndarray", ",", "ylabel", ":", "str", "=", "\"Inertia\"", ",", "filename", ":", "str", "=", "\"kmeans.png\"", ",", "img_title", ":", "str", "=", "\"KMeans Clus...
[ 665, 4 ]
[ 695, 49 ]
python
en
['en', 'en', 'en']
True
Report.print_dbscan
( self, distances: dict, xlabel: str = "Ordered points per distance to the nearest k-neighbor", ylabel: str = "Distance to the nearest k-neighbor", filename: str = "dbscan.png", img_title: str = "DBSCAN Clustering", figsize: tuple = (10, 8), )
Print the dbscan clustering for the given distances list. :param distances: List with the distances between data points :type distances: list :param X: Dataframe to be clustered :type X: np.ndarray :param ylabel: String with the label for the y axe, defaults to "Inertia" ...
Print the dbscan clustering for the given distances list.
def print_dbscan( self, distances: dict, xlabel: str = "Ordered points per distance to the nearest k-neighbor", ylabel: str = "Distance to the nearest k-neighbor", filename: str = "dbscan.png", img_title: str = "DBSCAN Clustering", figsize: tuple = (10, 8), ):...
[ "def", "print_dbscan", "(", "self", ",", "distances", ":", "dict", ",", "xlabel", ":", "str", "=", "\"Ordered points per distance to the nearest k-neighbor\"", ",", "ylabel", ":", "str", "=", "\"Distance to the nearest k-neighbor\"", ",", "filename", ":", "str", "=", ...
[ 697, 4 ]
[ 725, 49 ]
python
en
['en', 'en', 'en']
True
Report.print_autoencoder_validation
( self, anomalies: Anomalies, filename: str = "autoencoder_validation.png", img_title: str = "Autoencoder Validation", **kwargs, )
Print the autoencoder validation graph to the report. :param Anomalies: An instance of the class Anomalies to be printed :type Anomalies: preprocessing.Anomalies :param filename: String with the filename of the output image, defaults to "autoencoder_validation.png" :type filename: str, ...
Print the autoencoder validation graph to the report.
def print_autoencoder_validation( self, anomalies: Anomalies, filename: str = "autoencoder_validation.png", img_title: str = "Autoencoder Validation", **kwargs, ): """Print the autoencoder validation graph to the report. :param Anomalies: An instance of the c...
[ "def", "print_autoencoder_validation", "(", "self", ",", "anomalies", ":", "Anomalies", ",", "filename", ":", "str", "=", "\"autoencoder_validation.png\"", ",", "img_title", ":", "str", "=", "\"Autoencoder Validation\"", ",", "*", "*", "kwargs", ",", ")", ":", "...
[ 727, 4 ]
[ 745, 9 ]
python
en
['en', 'en', 'en']
True
Report.print_autoencoder_threshold
( self, anomalies: Anomalies, filename: str = "autoencoder_threshold.png", img_title: str = "Autoencoder Threshold", **kwargs, )
Print the autoencoder threshold graph to the report. :param Anomalies: An instance of the class Anomalies to be printed :type Anomalies: preprocessing.Anomalies :param filename: String with the filename of the output image, defaults to "autoencoder_threshold.png" :type filename: str, op...
Print the autoencoder threshold graph to the report.
def print_autoencoder_threshold( self, anomalies: Anomalies, filename: str = "autoencoder_threshold.png", img_title: str = "Autoencoder Threshold", **kwargs, ): """Print the autoencoder threshold graph to the report. :param Anomalies: An instance of the class...
[ "def", "print_autoencoder_threshold", "(", "self", ",", "anomalies", ":", "Anomalies", ",", "filename", ":", "str", "=", "\"autoencoder_threshold.png\"", ",", "img_title", ":", "str", "=", "\"Autoencoder Threshold\"", ",", "*", "*", "kwargs", ",", ")", ":", "sel...
[ 747, 4 ]
[ 765, 9 ]
python
en
['en', 'en', 'en']
True
Report.print_autoencoder_error
( self, anomalies: Anomalies, filename: str = "autoencoder_error.png", img_title: str = "Autoencoder Error", **kwargs, )
Print the autoencoder error graph to the report. :param Anomalies: An instance of the class Anomalies to be printed :type Anomalies: preprocessing.Anomalies :param filename: String with the filename of the output image, defaults to "autoencoder_threshold.png" :type filename: str, option...
Print the autoencoder error graph to the report.
def print_autoencoder_error( self, anomalies: Anomalies, filename: str = "autoencoder_error.png", img_title: str = "Autoencoder Error", **kwargs, ): """Print the autoencoder error graph to the report. :param Anomalies: An instance of the class Anomalies to be...
[ "def", "print_autoencoder_error", "(", "self", ",", "anomalies", ":", "Anomalies", ",", "filename", ":", "str", "=", "\"autoencoder_error.png\"", ",", "img_title", ":", "str", "=", "\"Autoencoder Error\"", ",", "*", "*", "kwargs", ",", ")", ":", "self", ".", ...
[ 767, 4 ]
[ 785, 9 ]
python
en
['en', 'it', 'en']
True
Report.print_PCA
( self, X: pd.DataFrame, pca: PCA, xlabel: str = "Main Components", ylabel: str = "Variance %", filename: str = "pca.png", img_title: str = "PCA", figsize: tuple = (10, 5), )
Print the PCA dimension graph to the report. :param X: Pandas Dataframe with the characteristic matrix :type X: pd.DataFrame :param pca: [description] :type pca: PCA :param xlabel: String with the label for the x axe, defaults to "Main Components" :type xlabel: str, opti...
Print the PCA dimension graph to the report.
def print_PCA( self, X: pd.DataFrame, pca: PCA, xlabel: str = "Main Components", ylabel: str = "Variance %", filename: str = "pca.png", img_title: str = "PCA", figsize: tuple = (10, 5), ): """Print the PCA dimension graph to the report. ...
[ "def", "print_PCA", "(", "self", ",", "X", ":", "pd", ".", "DataFrame", ",", "pca", ":", "PCA", ",", "xlabel", ":", "str", "=", "\"Main Components\"", ",", "ylabel", ":", "str", "=", "\"Variance %\"", ",", "filename", ":", "str", "=", "\"pca.png\"", ",...
[ 787, 4 ]
[ 827, 49 ]
python
en
['en', 'en', 'en']
True
Report.save_image
( self, figure: plt.Figure, filename: str, img_title: str, **kwargs )
Image saving method to file and report. :param figure: Matplotlib figure to be printed in the report file :type figure: plt.Figure :param filename: String with the filename of the output image :type filename: str :param img_title: String with the title of the output image ...
Image saving method to file and report.
def save_image( self, figure: plt.Figure, filename: str, img_title: str, **kwargs ): """Image saving method to file and report. :param figure: Matplotlib figure to be printed in the report file :type figure: plt.Figure :param filename: String with the filename of the output ...
[ "def", "save_image", "(", "self", ",", "figure", ":", "plt", ".", "Figure", ",", "filename", ":", "str", ",", "img_title", ":", "str", ",", "*", "*", "kwargs", ")", ":", "# Saving image to file", "img_path", "=", "self", ".", "img_directory", "+", "filen...
[ 829, 4 ]
[ 845, 69 ]
python
en
['en', 'ceb', 'en']
True
Comment.get_comment_with_transforms
(self, annotation_xforms)
Return transformed comment with annotation transformers. Args: annotation_xforms: a dict of transformers for annotations in leading comment. Returns: transformed Comment object.
Return transformed comment with annotation transformers.
def get_comment_with_transforms(self, annotation_xforms): """Return transformed comment with annotation transformers. Args: annotation_xforms: a dict of transformers for annotations in leading comment. Returns: transformed Comment object. """ return Comm...
[ "def", "get_comment_with_transforms", "(", "self", ",", "annotation_xforms", ")", ":", "return", "Comment", "(", "annotations", ".", "xform_annotation", "(", "self", ".", "raw", ",", "annotation_xforms", ")", ",", "self", ".", "file_level_annotations", ")" ]
[ 13, 4 ]
[ 23, 99 ]
python
en
['en', 'en', 'en']
True
SourceCodeInfo.file_level_comments
(self)
Obtain inferred file level comment.
Obtain inferred file level comment.
def file_level_comments(self): """Obtain inferred file level comment.""" if self._file_level_comments: return self._file_level_comments comments = [] # We find the earliest detached comment by first finding the maximum start # line for any location and then scanning f...
[ "def", "file_level_comments", "(", "self", ")", ":", "if", "self", ".", "_file_level_comments", ":", "return", "self", ".", "_file_level_comments", "comments", "=", "[", "]", "# We find the earliest detached comment by first finding the maximum start", "# line for any locatio...
[ 38, 4 ]
[ 52, 23 ]
python
en
['en', 'en', 'en']
True
SourceCodeInfo.file_level_annotations
(self)
Obtain inferred file level annotations.
Obtain inferred file level annotations.
def file_level_annotations(self): """Obtain inferred file level annotations.""" if self._file_level_annotations: return self._file_level_annotations self._file_level_annotations = dict( sum([ list(annotations.extract_annotations(c).items()) for c in self.f...
[ "def", "file_level_annotations", "(", "self", ")", ":", "if", "self", ".", "_file_level_annotations", ":", "return", "self", ".", "_file_level_annotations", "self", ".", "_file_level_annotations", "=", "dict", "(", "sum", "(", "[", "list", "(", "annotations", "....
[ 55, 4 ]
[ 63, 43 ]
python
en
['en', 'en', 'en']
True
SourceCodeInfo.location_path_lookup
(self, path)
Lookup SourceCodeInfo.Location by path in SourceCodeInfo. Args: path: a list of path indexes as per https://github.com/google/protobuf/blob/a08b03d4c00a5793b88b494f672513f6ad46a681/src/google/protobuf/descriptor.proto#L717. Returns: SourceCodeInfo.Location object ...
Lookup SourceCodeInfo.Location by path in SourceCodeInfo.
def location_path_lookup(self, path): """Lookup SourceCodeInfo.Location by path in SourceCodeInfo. Args: path: a list of path indexes as per https://github.com/google/protobuf/blob/a08b03d4c00a5793b88b494f672513f6ad46a681/src/google/protobuf/descriptor.proto#L717. Ret...
[ "def", "location_path_lookup", "(", "self", ",", "path", ")", ":", "return", "self", ".", "_locations", ".", "get", "(", "str", "(", "path", ")", ",", "None", ")" ]
[ 65, 4 ]
[ 75, 51 ]
python
en
['en', 'en', 'en']
True
SourceCodeInfo.leading_comment_path_lookup
(self, path)
Lookup leading comment by path in SourceCodeInfo. Args: path: a list of path indexes as per https://github.com/google/protobuf/blob/a08b03d4c00a5793b88b494f672513f6ad46a681/src/google/protobuf/descriptor.proto#L717. Returns: Comment object.
Lookup leading comment by path in SourceCodeInfo.
def leading_comment_path_lookup(self, path): """Lookup leading comment by path in SourceCodeInfo. Args: path: a list of path indexes as per https://github.com/google/protobuf/blob/a08b03d4c00a5793b88b494f672513f6ad46a681/src/google/protobuf/descriptor.proto#L717. Ret...
[ "def", "leading_comment_path_lookup", "(", "self", ",", "path", ")", ":", "location", "=", "self", ".", "location_path_lookup", "(", "path", ")", "if", "location", "is", "not", "None", ":", "return", "Comment", "(", "location", ".", "leading_comments", ",", ...
[ 79, 4 ]
[ 92, 26 ]
python
en
['en', 'en', 'en']
True
SourceCodeInfo.leading_detached_comments_path_lookup
(self, path)
Lookup leading detached comments by path in SourceCodeInfo. Args: path: a list of path indexes as per https://github.com/google/protobuf/blob/a08b03d4c00a5793b88b494f672513f6ad46a681/src/google/protobuf/descriptor.proto#L717. Returns: List of detached comment str...
Lookup leading detached comments by path in SourceCodeInfo.
def leading_detached_comments_path_lookup(self, path): """Lookup leading detached comments by path in SourceCodeInfo. Args: path: a list of path indexes as per https://github.com/google/protobuf/blob/a08b03d4c00a5793b88b494f672513f6ad46a681/src/google/protobuf/descriptor.prot...
[ "def", "leading_detached_comments_path_lookup", "(", "self", ",", "path", ")", ":", "location", "=", "self", ".", "location_path_lookup", "(", "path", ")", "if", "location", "is", "not", "None", "and", "location", ".", "leading_detached_comments", "!=", "self", ...
[ 94, 4 ]
[ 107, 17 ]
python
en
['en', 'en', 'en']
True
SourceCodeInfo.trailing_comment_path_lookup
(self, path)
Lookup trailing comment by path in SourceCodeInfo. Args: path: a list of path indexes as per https://github.com/google/protobuf/blob/a08b03d4c00a5793b88b494f672513f6ad46a681/src/google/protobuf/descriptor.proto#L717. Returns: Raw detached comment string
Lookup trailing comment by path in SourceCodeInfo.
def trailing_comment_path_lookup(self, path): """Lookup trailing comment by path in SourceCodeInfo. Args: path: a list of path indexes as per https://github.com/google/protobuf/blob/a08b03d4c00a5793b88b494f672513f6ad46a681/src/google/protobuf/descriptor.proto#L717. R...
[ "def", "trailing_comment_path_lookup", "(", "self", ",", "path", ")", ":", "location", "=", "self", ".", "location_path_lookup", "(", "path", ")", "if", "location", "is", "not", "None", ":", "return", "location", ".", "trailing_comments", "return", "''" ]
[ 109, 4 ]
[ 122, 17 ]
python
en
['en', 'en', 'en']
True
TypeContext.extend_message
(self, index, name, deprecated)
Extend type context with a message. Args: index: message index in file. name: message name. deprecated: is the message depreacted?
Extend type context with a message.
def extend_message(self, index, name, deprecated): """Extend type context with a message. Args: index: message index in file. name: message name. deprecated: is the message depreacted? """ return self._extend([4, index], 'message', name, deprecated)
[ "def", "extend_message", "(", "self", ",", "index", ",", "name", ",", "deprecated", ")", ":", "return", "self", ".", "_extend", "(", "[", "4", ",", "index", "]", ",", "'message'", ",", "name", ",", "deprecated", ")" ]
[ 170, 4 ]
[ 178, 68 ]
python
en
['en', 'en', 'en']
True
TypeContext.extend_nested_message
(self, index, name, deprecated)
Extend type context with a nested message. Args: index: nested message index in message. name: message name. deprecated: is the message depreacted?
Extend type context with a nested message.
def extend_nested_message(self, index, name, deprecated): """Extend type context with a nested message. Args: index: nested message index in message. name: message name. deprecated: is the message depreacted? """ return self._extend([3, index], 'messa...
[ "def", "extend_nested_message", "(", "self", ",", "index", ",", "name", ",", "deprecated", ")", ":", "return", "self", ".", "_extend", "(", "[", "3", ",", "index", "]", ",", "'message'", ",", "name", ",", "deprecated", ")" ]
[ 180, 4 ]
[ 188, 68 ]
python
en
['en', 'en', 'en']
True
TypeContext.extend_field
(self, index, name)
Extend type context with a field. Args: index: field index in message. name: field name.
Extend type context with a field.
def extend_field(self, index, name): """Extend type context with a field. Args: index: field index in message. name: field name. """ return self._extend([2, index], 'field', name)
[ "def", "extend_field", "(", "self", ",", "index", ",", "name", ")", ":", "return", "self", ".", "_extend", "(", "[", "2", ",", "index", "]", ",", "'field'", ",", "name", ")" ]
[ 190, 4 ]
[ 197, 54 ]
python
en
['en', 'en', 'en']
True
TypeContext.extend_enum
(self, index, name, deprecated)
Extend type context with an enum. Args: index: enum index in file. name: enum name. deprecated: is the message depreacted?
Extend type context with an enum.
def extend_enum(self, index, name, deprecated): """Extend type context with an enum. Args: index: enum index in file. name: enum name. deprecated: is the message depreacted? """ return self._extend([5, index], 'enum', name, deprecated)
[ "def", "extend_enum", "(", "self", ",", "index", ",", "name", ",", "deprecated", ")", ":", "return", "self", ".", "_extend", "(", "[", "5", ",", "index", "]", ",", "'enum'", ",", "name", ",", "deprecated", ")" ]
[ 199, 4 ]
[ 207, 65 ]
python
en
['en', 'en', 'en']
True
TypeContext.extend_service
(self, index, name)
Extend type context with a service. Args: index: service index in file. name: service name.
Extend type context with a service.
def extend_service(self, index, name): """Extend type context with a service. Args: index: service index in file. name: service name. """ return self._extend([6, index], 'service', name)
[ "def", "extend_service", "(", "self", ",", "index", ",", "name", ")", ":", "return", "self", ".", "_extend", "(", "[", "6", ",", "index", "]", ",", "'service'", ",", "name", ")" ]
[ 209, 4 ]
[ 216, 56 ]
python
en
['en', 'en', 'en']
True
TypeContext.extend_nested_enum
(self, index, name, deprecated)
Extend type context with a nested enum. Args: index: enum index in message. name: enum name. deprecated: is the message depreacted?
Extend type context with a nested enum.
def extend_nested_enum(self, index, name, deprecated): """Extend type context with a nested enum. Args: index: enum index in message. name: enum name. deprecated: is the message depreacted? """ return self._extend([4, index], 'enum', name, deprecated)
[ "def", "extend_nested_enum", "(", "self", ",", "index", ",", "name", ",", "deprecated", ")", ":", "return", "self", ".", "_extend", "(", "[", "4", ",", "index", "]", ",", "'enum'", ",", "name", ",", "deprecated", ")" ]
[ 218, 4 ]
[ 226, 65 ]
python
en
['en', 'en', 'en']
True
TypeContext.extend_enum_value
(self, index, name)
Extend type context with an enum enum. Args: index: enum value index in enum. name: value name.
Extend type context with an enum enum.
def extend_enum_value(self, index, name): """Extend type context with an enum enum. Args: index: enum value index in enum. name: value name. """ return self._extend([2, index], 'enum_value', name)
[ "def", "extend_enum_value", "(", "self", ",", "index", ",", "name", ")", ":", "return", "self", ".", "_extend", "(", "[", "2", ",", "index", "]", ",", "'enum_value'", ",", "name", ")" ]
[ 228, 4 ]
[ 235, 59 ]
python
en
['en', 'en', 'en']
True
TypeContext.extend_oneof
(self, index, name)
Extend type context with an oneof declaration. Args: index: oneof index in oneof_decl. name: oneof name.
Extend type context with an oneof declaration.
def extend_oneof(self, index, name): """Extend type context with an oneof declaration. Args: index: oneof index in oneof_decl. name: oneof name. """ return self._extend([8, index], 'oneof', name)
[ "def", "extend_oneof", "(", "self", ",", "index", ",", "name", ")", ":", "return", "self", ".", "_extend", "(", "[", "8", ",", "index", "]", ",", "'oneof'", ",", "name", ")" ]
[ 237, 4 ]
[ 244, 54 ]
python
en
['en', 'en', 'en']
True
TypeContext.extend_method
(self, index, name)
Extend type context with a service method declaration. Args: index: method index in service. name: method name.
Extend type context with a service method declaration.
def extend_method(self, index, name): """Extend type context with a service method declaration. Args: index: method index in service. name: method name. """ return self._extend([2, index], 'method', name)
[ "def", "extend_method", "(", "self", ",", "index", ",", "name", ")", ":", "return", "self", ".", "_extend", "(", "[", "2", ",", "index", "]", ",", "'method'", ",", "name", ")" ]
[ 246, 4 ]
[ 253, 55 ]
python
en
['en', 'en', 'en']
True
TypeContext.location
(self)
SourceCodeInfo.Location for type context.
SourceCodeInfo.Location for type context.
def location(self): """SourceCodeInfo.Location for type context.""" return self.source_code_info.location_path_lookup(self.path)
[ "def", "location", "(", "self", ")", ":", "return", "self", ".", "source_code_info", ".", "location_path_lookup", "(", "self", ".", "path", ")" ]
[ 256, 4 ]
[ 258, 68 ]
python
en
['en', 'en', 'en']
True
TypeContext.leading_comment
(self)
Leading comment for type context.
Leading comment for type context.
def leading_comment(self): """Leading comment for type context.""" return self.source_code_info.leading_comment_path_lookup(self.path)
[ "def", "leading_comment", "(", "self", ")", ":", "return", "self", ".", "source_code_info", ".", "leading_comment_path_lookup", "(", "self", ".", "path", ")" ]
[ 261, 4 ]
[ 263, 75 ]
python
en
['en', 'en', 'en']
True
TypeContext.leading_detached_comments
(self)
Leading detached comments for type context.
Leading detached comments for type context.
def leading_detached_comments(self): """Leading detached comments for type context.""" return self.source_code_info.leading_detached_comments_path_lookup(self.path)
[ "def", "leading_detached_comments", "(", "self", ")", ":", "return", "self", ".", "source_code_info", ".", "leading_detached_comments_path_lookup", "(", "self", ".", "path", ")" ]
[ 266, 4 ]
[ 268, 85 ]
python
en
['da', 'en', 'en']
True
TypeContext.trailing_comment
(self)
Trailing comment for type context.
Trailing comment for type context.
def trailing_comment(self): """Trailing comment for type context.""" return self.source_code_info.trailing_comment_path_lookup(self.path)
[ "def", "trailing_comment", "(", "self", ")", ":", "return", "self", ".", "source_code_info", ".", "trailing_comment_path_lookup", "(", "self", ".", "path", ")" ]
[ 271, 4 ]
[ 273, 76 ]
python
en
['en', 'en', 'en']
True
test_model_tpu_cores_1
(tmpdir)
Make sure model trains on TPU.
Make sure model trains on TPU.
def test_model_tpu_cores_1(tmpdir): """Make sure model trains on TPU.""" tutils.reset_seed() trainer_options = dict( default_root_dir=tmpdir, progress_bar_refresh_rate=0, max_epochs=2, tpu_cores=1, limit_train_batches=4, limit_val_batches=4, ) model =...
[ "def", "test_model_tpu_cores_1", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer_options", "=", "dict", "(", "default_root_dir", "=", "tmpdir", ",", "progress_bar_refresh_rate", "=", "0", ",", "max_epochs", "=", "2", ",", "tpu_cores", ...
[ 57, 0 ]
[ 70, 79 ]
python
en
['en', 'et', 'en']
True
test_model_tpu_index
(tmpdir, tpu_core)
Make sure model trains on TPU.
Make sure model trains on TPU.
def test_model_tpu_index(tmpdir, tpu_core): """Make sure model trains on TPU.""" tutils.reset_seed() trainer_options = dict( default_root_dir=tmpdir, progress_bar_refresh_rate=0, max_epochs=2, tpu_cores=[tpu_core], limit_train_batches=4, limit_val_batches=4, ...
[ "def", "test_model_tpu_index", "(", "tmpdir", ",", "tpu_core", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer_options", "=", "dict", "(", "default_root_dir", "=", "tmpdir", ",", "progress_bar_refresh_rate", "=", "0", ",", "max_epochs", "=", "2", ","...
[ 76, 0 ]
[ 90, 73 ]
python
en
['en', 'et', 'en']
True
test_model_tpu_cores_8
(tmpdir)
Make sure model trains on TPU.
Make sure model trains on TPU.
def test_model_tpu_cores_8(tmpdir): """Make sure model trains on TPU.""" tutils.reset_seed() trainer_options = dict( default_root_dir=tmpdir, progress_bar_refresh_rate=0, max_epochs=1, tpu_cores=8, limit_train_batches=4, limit_val_batches=4, ) # 8 cor...
[ "def", "test_model_tpu_cores_8", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer_options", "=", "dict", "(", "default_root_dir", "=", "tmpdir", ",", "progress_bar_refresh_rate", "=", "0", ",", "max_epochs", "=", "1", ",", "tpu_cores", ...
[ 95, 0 ]
[ 109, 93 ]
python
en
['en', 'et', 'en']
True
test_model_16bit_tpu_cores_1
(tmpdir)
Make sure model trains on TPU.
Make sure model trains on TPU.
def test_model_16bit_tpu_cores_1(tmpdir): """Make sure model trains on TPU.""" tutils.reset_seed() trainer_options = dict( default_root_dir=tmpdir, precision=16, progress_bar_refresh_rate=0, max_epochs=2, tpu_cores=1, limit_train_batches=8, limit_val_b...
[ "def", "test_model_16bit_tpu_cores_1", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer_options", "=", "dict", "(", "default_root_dir", "=", "tmpdir", ",", "precision", "=", "16", ",", "progress_bar_refresh_rate", "=", "0", ",", "max_epoc...
[ 114, 0 ]
[ 129, 104 ]
python
en
['en', 'et', 'en']
True
test_model_16bit_tpu_index
(tmpdir, tpu_core)
Make sure model trains on TPU.
Make sure model trains on TPU.
def test_model_16bit_tpu_index(tmpdir, tpu_core): """Make sure model trains on TPU.""" tutils.reset_seed() trainer_options = dict( default_root_dir=tmpdir, precision=16, progress_bar_refresh_rate=0, max_epochs=2, tpu_cores=[tpu_core], limit_train_batches=4, ...
[ "def", "test_model_16bit_tpu_index", "(", "tmpdir", ",", "tpu_core", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer_options", "=", "dict", "(", "default_root_dir", "=", "tmpdir", ",", "precision", "=", "16", ",", "progress_bar_refresh_rate", "=", "0",...
[ 135, 0 ]
[ 151, 104 ]
python
en
['en', 'et', 'en']
True
test_model_16bit_tpu_cores_8
(tmpdir)
Make sure model trains on TPU.
Make sure model trains on TPU.
def test_model_16bit_tpu_cores_8(tmpdir): """Make sure model trains on TPU.""" tutils.reset_seed() trainer_options = dict( default_root_dir=tmpdir, precision=16, progress_bar_refresh_rate=0, max_epochs=1, tpu_cores=8, limit_train_batches=4, limit_val_b...
[ "def", "test_model_16bit_tpu_cores_8", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer_options", "=", "dict", "(", "default_root_dir", "=", "tmpdir", ",", "precision", "=", "16", ",", "progress_bar_refresh_rate", "=", "0", ",", "max_epoc...
[ 156, 0 ]
[ 171, 93 ]
python
en
['en', 'et', 'en']
True
test_model_tpu_early_stop
(tmpdir)
Test if single TPU core training works
Test if single TPU core training works
def test_model_tpu_early_stop(tmpdir): """Test if single TPU core training works""" # todo: Test on 8 cores - hanging. class CustomBoringModel(BoringModel): def validation_step(self, *args, **kwargs): out = super().validation_step(*args, **kwargs) self.log('val_loss', out[...
[ "def", "test_model_tpu_early_stop", "(", "tmpdir", ")", ":", "# todo: Test on 8 cores - hanging.", "class", "CustomBoringModel", "(", "BoringModel", ")", ":", "def", "validation_step", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "out", "=",...
[ 176, 0 ]
[ 199, 22 ]
python
en
['en', 'ny', 'en']
True
test_tpu_grad_norm
(tmpdir)
Test if grad_norm works on TPU.
Test if grad_norm works on TPU.
def test_tpu_grad_norm(tmpdir): """Test if grad_norm works on TPU.""" tutils.reset_seed() trainer_options = dict( default_root_dir=tmpdir, progress_bar_refresh_rate=0, max_epochs=4, tpu_cores=1, limit_train_batches=4, limit_val_batches=4, gradient_clip...
[ "def", "test_tpu_grad_norm", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer_options", "=", "dict", "(", "default_root_dir", "=", "tmpdir", ",", "progress_bar_refresh_rate", "=", "0", ",", "max_epochs", "=", "4", ",", "tpu_cores", "=",...
[ 204, 0 ]
[ 218, 79 ]
python
en
['en', 'en', 'en']
True
test_dataloaders_passed_to_fit
(tmpdir)
Test if dataloaders passed to trainer works on TPU
Test if dataloaders passed to trainer works on TPU
def test_dataloaders_passed_to_fit(tmpdir): """Test if dataloaders passed to trainer works on TPU""" tutils.reset_seed() model = BoringModel() trainer = Trainer( default_root_dir=tmpdir, max_epochs=1, tpu_cores=8, ) trainer.fit( model, train_dataloader=mo...
[ "def", "test_dataloaders_passed_to_fit", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "model", "=", "BoringModel", "(", ")", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "max_epochs", "=", "1", ",", "tpu_cores", ...
[ 223, 0 ]
[ 238, 90 ]
python
en
['en', 'en', 'en']
True
test_tpu_id_to_be_as_expected
(tpu_cores, expected_tpu_id)
Test if trainer.tpu_id is set as expected
Test if trainer.tpu_id is set as expected
def test_tpu_id_to_be_as_expected(tpu_cores, expected_tpu_id): """Test if trainer.tpu_id is set as expected""" assert Trainer(tpu_cores=tpu_cores).accelerator_connector.tpu_id == expected_tpu_id
[ "def", "test_tpu_id_to_be_as_expected", "(", "tpu_cores", ",", "expected_tpu_id", ")", ":", "assert", "Trainer", "(", "tpu_cores", "=", "tpu_cores", ")", ".", "accelerator_connector", ".", "tpu_id", "==", "expected_tpu_id" ]
[ 247, 0 ]
[ 249, 87 ]
python
en
['en', 'en', 'en']
True
test_tpu_misconfiguration
()
Test if trainer.tpu_id is set as expected
Test if trainer.tpu_id is set as expected
def test_tpu_misconfiguration(): """Test if trainer.tpu_id is set as expected""" with pytest.raises(MisconfigurationException, match="`tpu_cores` can only be"): Trainer(tpu_cores=[1, 8])
[ "def", "test_tpu_misconfiguration", "(", ")", ":", "with", "pytest", ".", "raises", "(", "MisconfigurationException", ",", "match", "=", "\"`tpu_cores` can only be\"", ")", ":", "Trainer", "(", "tpu_cores", "=", "[", "1", ",", "8", "]", ")" ]
[ 252, 0 ]
[ 255, 33 ]
python
en
['en', 'en', 'en']
True
test_exception_when_no_tpu_found
(tmpdir)
Test if exception is thrown when xla devices are not available
Test if exception is thrown when xla devices are not available
def test_exception_when_no_tpu_found(tmpdir): """Test if exception is thrown when xla devices are not available""" with pytest.raises(MisconfigurationException, match='No TPU devices were found.'): Trainer(tpu_cores=8)
[ "def", "test_exception_when_no_tpu_found", "(", "tmpdir", ")", ":", "with", "pytest", ".", "raises", "(", "MisconfigurationException", ",", "match", "=", "'No TPU devices were found.'", ")", ":", "Trainer", "(", "tpu_cores", "=", "8", ")" ]
[ 259, 0 ]
[ 263, 28 ]
python
en
['en', 'en', 'en']
True
test_distributed_backend_set_when_using_tpu
(tmpdir, tpu_cores)
Test if distributed_backend is set to `tpu` when tpu_cores is not None
Test if distributed_backend is set to `tpu` when tpu_cores is not None
def test_distributed_backend_set_when_using_tpu(tmpdir, tpu_cores): """Test if distributed_backend is set to `tpu` when tpu_cores is not None""" assert Trainer(tpu_cores=tpu_cores).distributed_backend == "tpu"
[ "def", "test_distributed_backend_set_when_using_tpu", "(", "tmpdir", ",", "tpu_cores", ")", ":", "assert", "Trainer", "(", "tpu_cores", "=", "tpu_cores", ")", ".", "distributed_backend", "==", "\"tpu\"" ]
[ 268, 0 ]
[ 270, 68 ]
python
en
['en', 'en', 'en']
True
test_broadcast_on_tpu
()
Checks if an object from the master process is broadcasted to other processes correctly
Checks if an object from the master process is broadcasted to other processes correctly
def test_broadcast_on_tpu(): """ Checks if an object from the master process is broadcasted to other processes correctly""" def test_broadcast(rank): trainer = Trainer(tpu_cores=8) assert isinstance(trainer.accelerator, TPUAccelerator) assert isinstance(trainer.training_type_plugin, TPU...
[ "def", "test_broadcast_on_tpu", "(", ")", ":", "def", "test_broadcast", "(", "rank", ")", ":", "trainer", "=", "Trainer", "(", "tpu_cores", "=", "8", ")", "assert", "isinstance", "(", "trainer", ".", "accelerator", ",", "TPUAccelerator", ")", "assert", "isin...
[ 275, 0 ]
[ 286, 60 ]
python
en
['en', 'en', 'en']
True
test_tpu_cores_with_argparse
(cli_args, expected)
Test passing tpu_cores in command line
Test passing tpu_cores in command line
def test_tpu_cores_with_argparse(cli_args, expected): """Test passing tpu_cores in command line""" cli_args = cli_args.split(' ') if cli_args else [] with mock.patch("argparse._sys.argv", ["any.py"] + cli_args): parser = ArgumentParser(add_help=False) parser = Trainer.add_argparse_args(paren...
[ "def", "test_tpu_cores_with_argparse", "(", "cli_args", ",", "expected", ")", ":", "cli_args", "=", "cli_args", ".", "split", "(", "' '", ")", "if", "cli_args", "else", "[", "]", "with", "mock", ".", "patch", "(", "\"argparse._sys.argv\"", ",", "[", "\"any.p...
[ 323, 0 ]
[ 333, 43 ]
python
en
['en', 'en', 'en']
True
test_tpu_reduce
()
Test tpu spawn reduce operation
Test tpu spawn reduce operation
def test_tpu_reduce(): """Test tpu spawn reduce operation """ def test_reduce(rank): trainer = Trainer(tpu_cores=8) # faster this way reduce_ops = ["mean", "AVG", "undefined", "sum", ReduceOp.SUM, ReduceOp.MAX] for reduce_op in reduce_ops: if reduce_op == "undefined"...
[ "def", "test_tpu_reduce", "(", ")", ":", "def", "test_reduce", "(", "rank", ")", ":", "trainer", "=", "Trainer", "(", "tpu_cores", "=", "8", ")", "# faster this way", "reduce_ops", "=", "[", "\"mean\"", ",", "\"AVG\"", ",", "\"undefined\"", ",", "\"sum\"", ...
[ 338, 0 ]
[ 356, 57 ]
python
en
['en', 'cy', 'en']
True
_sk_precision_recall_curve
(y_true, probas_pred, num_classes=1)
Adjusted comparison function that can also handles multiclass
Adjusted comparison function that can also handles multiclass
def _sk_precision_recall_curve(y_true, probas_pred, num_classes=1): """ Adjusted comparison function that can also handles multiclass """ if num_classes == 1: return sk_precision_recall_curve(y_true, probas_pred) precision, recall, thresholds = [], [], [] for i in range(num_classes): y_...
[ "def", "_sk_precision_recall_curve", "(", "y_true", ",", "probas_pred", ",", "num_classes", "=", "1", ")", ":", "if", "num_classes", "==", "1", ":", "return", "sk_precision_recall_curve", "(", "y_true", ",", "probas_pred", ")", "precision", ",", "recall", ",", ...
[ 17, 0 ]
[ 30, 40 ]
python
en
['en', 'en', 'en']
True
test_finetuning_callback
(tmpdir)
Test finetuning callbacks works as expected
Test finetuning callbacks works as expected
def test_finetuning_callback(tmpdir): """Test finetuning callbacks works as expected""" seed_everything(42) class FinetuningBoringModel(BoringModel): def __init__(self): super().__init__() self.backbone = nn.Sequential(nn.Linear(32, 32, bias=False), nn.BatchNorm1d(32), nn....
[ "def", "test_finetuning_callback", "(", "tmpdir", ")", ":", "seed_everything", "(", "42", ")", "class", "FinetuningBoringModel", "(", "BoringModel", ")", ":", "def", "__init__", "(", "self", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", "...
[ 25, 0 ]
[ 80, 39 ]
python
en
['en', 'en', 'en']
True
test_finetuning_callback_warning
(tmpdir)
Test finetuning callbacks works as expected
Test finetuning callbacks works as expected
def test_finetuning_callback_warning(tmpdir): """Test finetuning callbacks works as expected""" seed_everything(42) class FinetuningBoringModel(BoringModel): def __init__(self): super().__init__() self.backbone = nn.Linear(32, 2, bias=False) self.layer = None ...
[ "def", "test_finetuning_callback_warning", "(", "tmpdir", ")", ":", "seed_everything", "(", "42", ")", "class", "FinetuningBoringModel", "(", "BoringModel", ")", ":", "def", "__init__", "(", "self", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "se...
[ 83, 0 ]
[ 136, 39 ]
python
en
['en', 'en', 'en']
True
test_freeze_unfreeze_function
(tmpdir)
Test freeze properly sets requires_grad on the modules
Test freeze properly sets requires_grad on the modules
def test_freeze_unfreeze_function(tmpdir): """Test freeze properly sets requires_grad on the modules""" seed_everything(42) class FreezeModel(LightningModule): def __init__(self): super().__init__() self.backbone = nn.Sequential(nn.Linear(32, 32), nn.BatchNorm1d(32), nn.Re...
[ "def", "test_freeze_unfreeze_function", "(", "tmpdir", ")", ":", "seed_everything", "(", "42", ")", "class", "FreezeModel", "(", "LightningModule", ")", ":", "def", "__init__", "(", "self", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", "....
[ 139, 0 ]
[ 171, 53 ]
python
en
['en', 'en', 'en']
True
test_unfreeze_and_add_param_group_function
(tmpdir)
Test unfreeze_and_add_param_group properly unfreeze parameters and add to the correct param_group
Test unfreeze_and_add_param_group properly unfreeze parameters and add to the correct param_group
def test_unfreeze_and_add_param_group_function(tmpdir): """Test unfreeze_and_add_param_group properly unfreeze parameters and add to the correct param_group""" seed_everything(42) class FreezeModel(LightningModule): def __init__(self): super().__init__() self.backbone = nn...
[ "def", "test_unfreeze_and_add_param_group_function", "(", "tmpdir", ")", ":", "seed_everything", "(", "42", ")", "class", "FreezeModel", "(", "LightningModule", ")", ":", "def", "__init__", "(", "self", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", ...
[ 174, 0 ]
[ 217, 96 ]
python
en
['en', 'en', 'en']
True
test_on_before_accelerator_backend_setup
(tmpdir)
`on_before_accelerator_backend_setup` hook is used by finetuning callbacks to freeze the model before before configure_optimizers function call.
`on_before_accelerator_backend_setup` hook is used by finetuning callbacks to freeze the model before before configure_optimizers function call.
def test_on_before_accelerator_backend_setup(tmpdir): """ `on_before_accelerator_backend_setup` hook is used by finetuning callbacks to freeze the model before before configure_optimizers function call. """ class TestCallback(Callback): def on_before_accelerator_backend_setup(self, trainer...
[ "def", "test_on_before_accelerator_backend_setup", "(", "tmpdir", ")", ":", "class", "TestCallback", "(", "Callback", ")", ":", "def", "on_before_accelerator_backend_setup", "(", "self", ",", "trainer", ",", "pl_module", ")", ":", "pl_module", ".", "on_before_accelera...
[ 220, 0 ]
[ 245, 22 ]
python
en
['en', 'error', 'th']
False
Scheduling.__init__
(self, jobs: List[int])
Assign jobs as instance of class Scheduling
Assign jobs as instance of class Scheduling
def __init__(self, jobs: List[int]) -> None: """ Assign jobs as instance of class Scheduling """ self.jobs = jobs
[ "def", "__init__", "(", "self", ",", "jobs", ":", "List", "[", "int", "]", ")", "->", "None", ":", "self", ".", "jobs", "=", "jobs" ]
[ 11, 4 ]
[ 15, 24 ]
python
en
['en', 'error', 'th']
False
Scheduling.schedule
(self, total_jobs: int, deadline: List[int])
Parameteres : total_jobs and list of deadline of jobs Returns : List of jobs_id which are profitable and can be done before deadline >>> a = Scheduling([(0, 13, 10),(1, 2, 20),(2, 33, 30),(3, 16, 40)]) >>> a.schedule( 3, [3, 4, 5]) [(1, 2, 20), (2, 33, 30)] ...
Parameteres : total_jobs and list of deadline of jobs Returns : List of jobs_id which are profitable and can be done before deadline >>> a = Scheduling([(0, 13, 10),(1, 2, 20),(2, 33, 30),(3, 16, 40)]) >>> a.schedule( 3, [3, 4, 5]) [(1, 2, 20), (2, 33, 30)] ...
def schedule(self, total_jobs: int, deadline: List[int]) -> List[int]: """ Parameteres : total_jobs and list of deadline of jobs Returns : List of jobs_id which are profitable and can be done before deadline >>> a = Scheduling([(0, 13, 10),(1, 2, 20),(2, 33, 30),(3, ...
[ "def", "schedule", "(", "self", ",", "total_jobs", ":", "int", ",", "deadline", ":", "List", "[", "int", "]", ")", "->", "List", "[", "int", "]", ":", "self", ".", "j", "=", "[", "self", ".", "jobs", "[", "1", "]", "]", "self", ".", "x", "=",...
[ 17, 4 ]
[ 38, 21 ]
python
en
['en', 'error', 'th']
False
Scheduling.feasible
(self, profit_jobs: List[int], deadline: List[int])
Parameters : list of current profitable jobs within deadline list of deadline of jobs Returns : true if k[-1] job is profitable to us else false >>> a = Scheduling([(0, 13, 10),(1, 2, 20),(2, 33, 30),(3, 16, 40)]) >>> a.feasible( [0], [2, 13, 16, 33] ) True ...
Parameters : list of current profitable jobs within deadline list of deadline of jobs Returns : true if k[-1] job is profitable to us else false >>> a = Scheduling([(0, 13, 10),(1, 2, 20),(2, 33, 30),(3, 16, 40)]) >>> a.feasible( [0], [2, 13, 16, 33] ) True ...
def feasible(self, profit_jobs: List[int], deadline: List[int]) -> bool: """ Parameters : list of current profitable jobs within deadline list of deadline of jobs Returns : true if k[-1] job is profitable to us else false >>> a = Scheduling([(0, 13, 10),(1, 2, 20),(2...
[ "def", "feasible", "(", "self", ",", "profit_jobs", ":", "List", "[", "int", "]", ",", "deadline", ":", "List", "[", "int", "]", ")", "->", "bool", ":", "self", ".", "tmp", "=", "profit_jobs", "self", ".", "is_feasible", "=", "True", "i", "=", "0",...
[ 40, 4 ]
[ 84, 31 ]
python
en
['en', 'error', 'th']
False
AbstractTransport.close
(self)
Releases any resources held by the transport
Releases any resources held by the transport
def close(self): """Releases any resources held by the transport""" pass
[ "def", "close", "(", "self", ")", ":", "pass" ]
[ 6, 4 ]
[ 8, 12 ]
python
en
['en', 'en', 'en']
True
AbstractTransport.write_byte
(self, address: int, value: int)
Writes a single byte to the given address :param address: the address to write to :param value: the byte to write
Writes a single byte to the given address :param address: the address to write to :param value: the byte to write
def write_byte(self, address: int, value: int) -> int: """Writes a single byte to the given address :param address: the address to write to :param value: the byte to write """ pass
[ "def", "write_byte", "(", "self", ",", "address", ":", "int", ",", "value", ":", "int", ")", "->", "int", ":", "pass" ]
[ 11, 4 ]
[ 16, 12 ]
python
en
['en', 'en', 'en']
True