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
Background.run
(self)
Método para iniciar a animação do background
Método para iniciar a animação do background
def run(self): """ Método para iniciar a animação do background """ # Enquanto o atributo "stop" for False, a animação continuará em um loop infinito if not self.__stop: # Move as imagens de background na posição X self.move(self.__background[0], -10, 0)...
[ "def", "run", "(", "self", ")", ":", "# Enquanto o atributo \"stop\" for False, a animação continuará em um loop infinito", "if", "not", "self", ".", "__stop", ":", "# Move as imagens de background na posição X", "self", ".", "move", "(", "self", ".", "__background", "[", ...
[ 112, 4 ]
[ 138, 54 ]
python
en
['en', 'error', 'th']
False
Background.stop
(self)
Método para parar a animação do background
Método para parar a animação do background
def stop(self): """ Método para parar a animação do background """ self.__stop = True
[ "def", "stop", "(", "self", ")", ":", "self", ".", "__stop", "=", "True" ]
[ 140, 4 ]
[ 144, 26 ]
python
en
['en', 'error', 'th']
False
a_descriptive_name
(optional_arguments)
A documentation string.
A documentation string.
def a_descriptive_name(optional_arguments): """A documentation string.""" # Your function's code goes here. # Your function's code goes here. # Your function's code goes here. return optional_value
[ "def", "a_descriptive_name", "(", "optional_arguments", ")", ":", "# Your function's code goes here. ", "# Your function's code goes here. ", "# Your function's code goes here. ", "return", "optional_value" ]
[ 1, 0 ]
[ 6, 25 ]
python
en
['en', 'cy', 'en']
True
fbeta
( preds: torch.Tensor, target: torch.Tensor, num_classes: int, beta: float = 1.0, threshold: float = 0.5, average: str = "micro", multilabel: bool = False )
Computes f_beta metric. Works with binary, multiclass, and multilabel data. Accepts probabilities from a model output or integer class values in prediction. Works with multi-dimensional preds and target. If preds and target are the same shape and preds is a float tensor, we use the ``self.thresho...
Computes f_beta metric.
def fbeta( preds: torch.Tensor, target: torch.Tensor, num_classes: int, beta: float = 1.0, threshold: float = 0.5, average: str = "micro", multilabel: bool = False ) -> torch.Tensor: """ Computes f_beta metric. Works with binary, multiclass, and multilabel data. Accepts prob...
[ "def", "fbeta", "(", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "num_classes", ":", "int", ",", "beta", ":", "float", "=", "1.0", ",", "threshold", ":", "float", "=", "0.5", ",", "average", ":", "str", "=...
[ 53, 0 ]
[ 103, 95 ]
python
en
['en', 'error', 'th']
False
f1
( preds: torch.Tensor, target: torch.Tensor, num_classes: int, threshold: float = 0.5, average: str = "micro", multilabel: bool = False )
Computes F1 metric. F1 metrics correspond to a equally weighted average of the precision and recall scores. Works with binary, multiclass, and multilabel data. Accepts probabilities from a model output or integer class values in prediction. Works with multi-dimensional preds and target. If pr...
Computes F1 metric. F1 metrics correspond to a equally weighted average of the precision and recall scores.
def f1( preds: torch.Tensor, target: torch.Tensor, num_classes: int, threshold: float = 0.5, average: str = "micro", multilabel: bool = False ) -> torch.Tensor: """ Computes F1 metric. F1 metrics correspond to a equally weighted average of the precision and recall scores. Works ...
[ "def", "f1", "(", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "num_classes", ":", "int", ",", "threshold", ":", "float", "=", "0.5", ",", "average", ":", "str", "=", "\"micro\"", ",", "multilabel", ":", "boo...
[ 106, 0 ]
[ 150, 81 ]
python
en
['en', 'error', 'th']
False
CompositionalMetric.__init__
( self, operator: Callable, metric_a: Union[Metric, int, float, torch.Tensor], metric_b: Union[Metric, int, float, torch.Tensor, None], )
Args: operator: the operator taking in one (if metric_b is None) or two arguments. Will be applied to outputs of metric_a.compute() and (optionally if metric_b is not None) metric_b.compute() metric_a: first metric whose compute() result is the first arg...
def __init__( self, operator: Callable, metric_a: Union[Metric, int, float, torch.Tensor], metric_b: Union[Metric, int, float, torch.Tensor, None], ): """ Args: operator: the operator taking in one (if metric_b is None) or two arguments. W...
[ "def", "__init__", "(", "self", ",", "operator", ":", "Callable", ",", "metric_a", ":", "Union", "[", "Metric", ",", "int", ",", "float", ",", "torch", ".", "Tensor", "]", ",", "metric_b", ":", "Union", "[", "Metric", ",", "int", ",", "float", ",", ...
[ 13, 4 ]
[ 41, 36 ]
python
en
['en', 'error', 'th']
False
find_position
(string, index, last_index, last_pos)
Given a string and index, return (line, column)
Given a string and index, return (line, column)
def find_position(string, index, last_index, last_pos): """ Given a string and index, return (line, column) """ lines = string.count('\n', last_index, index) if lines > 0: column = index - string.rfind('\n', last_index, index) else: column = last_pos[1] + (index - last_index) ...
[ "def", "find_position", "(", "string", ",", "index", ",", "last_index", ",", "last_pos", ")", ":", "lines", "=", "string", ".", "count", "(", "'\\n'", ",", "last_index", ",", "index", ")", "if", "lines", ">", "0", ":", "column", "=", "index", "-", "s...
[ 812, 0 ]
[ 821, 40 ]
python
en
['en', 'error', 'th']
False
test_global_zero_only_logging_ddp_cpu
(tmpdir)
Makes sure logging only happens from root zero
Makes sure logging only happens from root zero
def test_global_zero_only_logging_ddp_cpu(tmpdir): """ Makes sure logging only happens from root zero """ model = TestModel() model.training_epoch_end = None trainer = Trainer( accelerator='ddp_cpu', num_processes=2, default_root_dir=tmpdir, limit_train_batches=1,...
[ "def", "test_global_zero_only_logging_ddp_cpu", "(", "tmpdir", ")", ":", "model", "=", "TestModel", "(", ")", "model", ".", "training_epoch_end", "=", "None", "trainer", "=", "Trainer", "(", "accelerator", "=", "'ddp_cpu'", ",", "num_processes", "=", "2", ",", ...
[ 36, 0 ]
[ 51, 22 ]
python
en
['en', 'error', 'th']
False
test_global_zero_only_logging_ddp_spawn
(tmpdir)
Makes sure logging only happens from root zero
Makes sure logging only happens from root zero
def test_global_zero_only_logging_ddp_spawn(tmpdir): """ Makes sure logging only happens from root zero """ model = TestModel() model.training_epoch_end = None trainer = Trainer( accelerator='ddp_spawn', gpus=2, default_root_dir=tmpdir, limit_train_batches=1, ...
[ "def", "test_global_zero_only_logging_ddp_spawn", "(", "tmpdir", ")", ":", "model", "=", "TestModel", "(", ")", "model", ".", "training_epoch_end", "=", "None", "trainer", "=", "Trainer", "(", "accelerator", "=", "'ddp_spawn'", ",", "gpus", "=", "2", ",", "def...
[ 55, 0 ]
[ 70, 22 ]
python
en
['en', 'error', 'th']
False
get_date_string
()
Gets the current date and converts into a more user friendly string format.
Gets the current date and converts into a more user friendly string format.
def get_date_string(): """ Gets the current date and converts into a more user friendly string format. """ return dt.now().date().strftime("%b %d, %Y")
[ "def", "get_date_string", "(", ")", ":", "return", "dt", ".", "now", "(", ")", ".", "date", "(", ")", ".", "strftime", "(", "\"%b %d, %Y\"", ")" ]
[ 4, 0 ]
[ 8, 45 ]
python
en
['en', 'error', 'th']
False
get_datetime_string
()
Gets the current date & time then converts into a more user friendly string format.
Gets the current date & time then converts into a more user friendly string format.
def get_datetime_string(): """ Gets the current date & time then converts into a more user friendly string format. """ return dt.now().time().strftime("%I:%M%p") + dt.now().date().strftime("\n%B %d,\n%Y")
[ "def", "get_datetime_string", "(", ")", ":", "return", "dt", ".", "now", "(", ")", ".", "time", "(", ")", ".", "strftime", "(", "\"%I:%M%p\"", ")", "+", "dt", ".", "now", "(", ")", ".", "date", "(", ")", ".", "strftime", "(", "\"\\n%B %d,\\n%Y\"", ...
[ 11, 0 ]
[ 15, 86 ]
python
en
['en', 'error', 'th']
False
BehaviorRecord.__repr__
(self)
Returns field date of behavior record.
Returns field date of behavior record.
def __repr__(self): """" Returns field date of behavior record. """ return f'<BehaviorRecord: {self.date}>'
[ "def", "__repr__", "(", "self", ")", ":", "return", "f'<BehaviorRecord: {self.date}>'" ]
[ 27, 1 ]
[ 31, 41 ]
python
en
['en', 'error', 'th']
False
BehaviorRecord.payload
(self)
Returns the dictionary representation of the Baavior Record instance.
Returns the dictionary representation of the Baavior Record instance.
def payload(self): """ Returns the dictionary representation of the Baavior Record instance. """ _payload = { "date" : self.date, "happy_point_count": self.happy_point_count, "sad_point_count": self.sad_point_count, "bonus_point_count": self.bonus_point_count } return _payload
[ "def", "payload", "(", "self", ")", ":", "_payload", "=", "{", "\"date\"", ":", "self", ".", "date", ",", "\"happy_point_count\"", ":", "self", ".", "happy_point_count", ",", "\"sad_point_count\"", ":", "self", ".", "sad_point_count", ",", "\"bonus_point_count\"...
[ 34, 1 ]
[ 44, 17 ]
python
en
['en', 'error', 'th']
False
Alarm.__repr__
(self)
Returns the name of the Alarm instance
Returns the name of the Alarm instance
def __repr__(self): """ Returns the name of the Alarm instance """ return f"<Alarm: {self.name}>"
[ "def", "__repr__", "(", "self", ")", ":", "return", "f\"<Alarm: {self.name}>\"" ]
[ 59, 1 ]
[ 63, 32 ]
python
en
['en', 'error', 'th']
False
Alarm.payload
(self)
Returns the dictionary representation of the Alarm model instance. @return alarm object @rtype dict
Returns the dictionary representation of the Alarm model instance.
def payload(self): """ Returns the dictionary representation of the Alarm model instance. @return alarm object @rtype dict """ return self.__dict__
[ "def", "payload", "(", "self", ")", ":", "return", "self", ".", "__dict__" ]
[ 66, 1 ]
[ 74, 22 ]
python
en
['en', 'error', 'th']
False
TestLineSplitter.test_no_delimiter
(self)
Test LineSplitter w/o delimiter
Test LineSplitter w/o delimiter
def test_no_delimiter(self): "Test LineSplitter w/o delimiter" strg = " 1 2 3 4 5 # test" test = LineSplitter()(strg) assert_equal(test, ['1', '2', '3', '4', '5']) test = LineSplitter('')(strg) assert_equal(test, ['1', '2', '3', '4', '5'])
[ "def", "test_no_delimiter", "(", "self", ")", ":", "strg", "=", "\" 1 2 3 4 5 # test\"", "test", "=", "LineSplitter", "(", ")", "(", "strg", ")", "assert_equal", "(", "test", ",", "[", "'1'", ",", "'2'", ",", "'3'", ",", "'4'", ",", "'5'", "]", ")", ...
[ 19, 4 ]
[ 25, 53 ]
python
it
['it', 'no', 'pl']
False
TestLineSplitter.test_space_delimiter
(self)
Test space delimiter
Test space delimiter
def test_space_delimiter(self): "Test space delimiter" strg = " 1 2 3 4 5 # test" test = LineSplitter(' ')(strg) assert_equal(test, ['1', '2', '3', '4', '', '5']) test = LineSplitter(' ')(strg) assert_equal(test, ['1 2 3 4', '5'])
[ "def", "test_space_delimiter", "(", "self", ")", ":", "strg", "=", "\" 1 2 3 4 5 # test\"", "test", "=", "LineSplitter", "(", "' '", ")", "(", "strg", ")", "assert_equal", "(", "test", ",", "[", "'1'", ",", "'2'", ",", "'3'", ",", "'4'", ",", "''", ",...
[ 27, 4 ]
[ 33, 44 ]
python
en
['it', 'en', 'en']
True
TestLineSplitter.test_tab_delimiter
(self)
Test tab delimiter
Test tab delimiter
def test_tab_delimiter(self): "Test tab delimiter" strg = " 1\t 2\t 3\t 4\t 5 6" test = LineSplitter('\t')(strg) assert_equal(test, ['1', '2', '3', '4', '5 6']) strg = " 1 2\t 3 4\t 5 6" test = LineSplitter('\t')(strg) assert_equal(test, ['1 2', '3 4', '5 ...
[ "def", "test_tab_delimiter", "(", "self", ")", ":", "strg", "=", "\" 1\\t 2\\t 3\\t 4\\t 5 6\"", "test", "=", "LineSplitter", "(", "'\\t'", ")", "(", "strg", ")", "assert_equal", "(", "test", ",", "[", "'1'", ",", "'2'", ",", "'3'", ",", "'4'", ",", "'5...
[ 35, 4 ]
[ 42, 52 ]
python
da
['it', 'da', 'nl']
False
TestLineSplitter.test_other_delimiter
(self)
Test LineSplitter on delimiter
Test LineSplitter on delimiter
def test_other_delimiter(self): "Test LineSplitter on delimiter" strg = "1,2,3,4,,5" test = LineSplitter(',')(strg) assert_equal(test, ['1', '2', '3', '4', '', '5']) # strg = " 1,2,3,4,,5 # test" test = LineSplitter(',')(strg) assert_equal(test, ['1', '2',...
[ "def", "test_other_delimiter", "(", "self", ")", ":", "strg", "=", "\"1,2,3,4,,5\"", "test", "=", "LineSplitter", "(", "','", ")", "(", "strg", ")", "assert_equal", "(", "test", ",", "[", "'1'", ",", "'2'", ",", "'3'", ",", "'4'", ",", "''", ",", "'5...
[ 44, 4 ]
[ 57, 57 ]
python
en
['en', 'no', 'nl']
False
TestLineSplitter.test_constant_fixed_width
(self)
Test LineSplitter w/ fixed-width fields
Test LineSplitter w/ fixed-width fields
def test_constant_fixed_width(self): "Test LineSplitter w/ fixed-width fields" strg = " 1 2 3 4 5 # test" test = LineSplitter(3)(strg) assert_equal(test, ['1', '2', '3', '4', '', '5', '']) # strg = " 1 3 4 5 6# test" test = LineSplitter(20)(strg)...
[ "def", "test_constant_fixed_width", "(", "self", ")", ":", "strg", "=", "\" 1 2 3 4 5 # test\"", "test", "=", "LineSplitter", "(", "3", ")", "(", "strg", ")", "assert_equal", "(", "test", ",", "[", "'1'", ",", "'2'", ",", "'3'", ",", "'4'", ",", ...
[ 59, 4 ]
[ 71, 48 ]
python
en
['en', 'fy', 'en']
True
TestNameValidator.test_case_sensitivity
(self)
Test case sensitivity
Test case sensitivity
def test_case_sensitivity(self): "Test case sensitivity" names = ['A', 'a', 'b', 'c'] test = NameValidator().validate(names) assert_equal(test, ['A', 'a', 'b', 'c']) test = NameValidator(case_sensitive=False).validate(names) assert_equal(test, ['A', 'A_1', 'B', 'C']) ...
[ "def", "test_case_sensitivity", "(", "self", ")", ":", "names", "=", "[", "'A'", ",", "'a'", ",", "'b'", ",", "'c'", "]", "test", "=", "NameValidator", "(", ")", ".", "validate", "(", "names", ")", "assert_equal", "(", "test", ",", "[", "'A'", ",", ...
[ 87, 4 ]
[ 100, 73 ]
python
en
['en', 'fr', 'en']
True
TestNameValidator.test_excludelist
(self)
Test excludelist
Test excludelist
def test_excludelist(self): "Test excludelist" names = ['dates', 'data', 'Other Data', 'mask'] validator = NameValidator(excludelist=['dates', 'data', 'mask']) test = validator.validate(names) assert_equal(test, ['dates_', 'data_', 'Other_Data', 'mask_'])
[ "def", "test_excludelist", "(", "self", ")", ":", "names", "=", "[", "'dates'", ",", "'data'", ",", "'Other Data'", ",", "'mask'", "]", "validator", "=", "NameValidator", "(", "excludelist", "=", "[", "'dates'", ",", "'data'", ",", "'mask'", "]", ")", "t...
[ 102, 4 ]
[ 107, 70 ]
python
de
['de', 'en', 'ur']
False
TestNameValidator.test_missing_names
(self)
Test validate missing names
Test validate missing names
def test_missing_names(self): "Test validate missing names" namelist = ('a', 'b', 'c') validator = NameValidator() assert_equal(validator(namelist), ['a', 'b', 'c']) namelist = ('', 'b', 'c') assert_equal(validator(namelist), ['f0', 'b', 'c']) namelist = ('a', 'b'...
[ "def", "test_missing_names", "(", "self", ")", ":", "namelist", "=", "(", "'a'", ",", "'b'", ",", "'c'", ")", "validator", "=", "NameValidator", "(", ")", "assert_equal", "(", "validator", "(", "namelist", ")", ",", "[", "'a'", ",", "'b'", ",", "'c'", ...
[ 109, 4 ]
[ 119, 61 ]
python
af
['et', 'af', 'en']
False
TestNameValidator.test_validate_nb_names
(self)
Test validate nb names
Test validate nb names
def test_validate_nb_names(self): "Test validate nb names" namelist = ('a', 'b', 'c') validator = NameValidator() assert_equal(validator(namelist, nbfields=1), ('a',)) assert_equal(validator(namelist, nbfields=5, defaultfmt="g%i"), ['a', 'b', 'c', 'g0', 'g1']...
[ "def", "test_validate_nb_names", "(", "self", ")", ":", "namelist", "=", "(", "'a'", ",", "'b'", ",", "'c'", ")", "validator", "=", "NameValidator", "(", ")", "assert_equal", "(", "validator", "(", "namelist", ",", "nbfields", "=", "1", ")", ",", "(", ...
[ 121, 4 ]
[ 127, 49 ]
python
af
['nl', 'af', 'sw']
False
TestNameValidator.test_validate_wo_names
(self)
Test validate no names
Test validate no names
def test_validate_wo_names(self): "Test validate no names" namelist = None validator = NameValidator() assert_(validator(namelist) is None) assert_equal(validator(namelist, nbfields=3), ['f0', 'f1', 'f2'])
[ "def", "test_validate_wo_names", "(", "self", ")", ":", "namelist", "=", "None", "validator", "=", "NameValidator", "(", ")", "assert_", "(", "validator", "(", "namelist", ")", "is", "None", ")", "assert_equal", "(", "validator", "(", "namelist", ",", "nbfie...
[ 129, 4 ]
[ 134, 73 ]
python
en
['lv', 'en', 'it']
False
TestStringConverter.test_creation
(self)
Test creation of a StringConverter
Test creation of a StringConverter
def test_creation(self): "Test creation of a StringConverter" converter = StringConverter(int, -99999) assert_equal(converter._status, 1) assert_equal(converter.default, -99999)
[ "def", "test_creation", "(", "self", ")", ":", "converter", "=", "StringConverter", "(", "int", ",", "-", "99999", ")", "assert_equal", "(", "converter", ".", "_status", ",", "1", ")", "assert_equal", "(", "converter", ".", "default", ",", "-", "99999", ...
[ 146, 4 ]
[ 150, 47 ]
python
en
['en', 'en', 'en']
True
TestStringConverter.test_upgrade
(self)
Tests the upgrade method.
Tests the upgrade method.
def test_upgrade(self): "Tests the upgrade method." converter = StringConverter() assert_equal(converter._status, 0) # test int assert_equal(converter.upgrade('0'), 0) assert_equal(converter._status, 1) # On systems where long defaults to 32-bit, the statuses w...
[ "def", "test_upgrade", "(", "self", ")", ":", "converter", "=", "StringConverter", "(", ")", "assert_equal", "(", "converter", ".", "_status", ",", "0", ")", "# test int", "assert_equal", "(", "converter", ".", "upgrade", "(", "'0'", ")", ",", "0", ")", ...
[ 152, 4 ]
[ 187, 62 ]
python
en
['en', 'en', 'en']
True
TestStringConverter.test_missing
(self)
Tests the use of missing values.
Tests the use of missing values.
def test_missing(self): "Tests the use of missing values." converter = StringConverter(missing_values=('missing', 'missed')) converter.upgrade('0') assert_equal(converter('0'), 0) assert_equal(converter(''), converter.default) ...
[ "def", "test_missing", "(", "self", ")", ":", "converter", "=", "StringConverter", "(", "missing_values", "=", "(", "'missing'", ",", "'missed'", ")", ")", "converter", ".", "upgrade", "(", "'0'", ")", "assert_equal", "(", "converter", "(", "'0'", ")", ","...
[ 189, 4 ]
[ 201, 16 ]
python
en
['en', 'en', 'en']
True
TestStringConverter.test_upgrademapper
(self)
Tests updatemapper
Tests updatemapper
def test_upgrademapper(self): "Tests updatemapper" dateparser = _bytes_to_date StringConverter.upgrade_mapper(dateparser, date(2000, 1, 1)) convert = StringConverter(dateparser, date(2000, 1, 1)) test = convert('2001-01-01') assert_equal(test, date(2001, 1, 1)) te...
[ "def", "test_upgrademapper", "(", "self", ")", ":", "dateparser", "=", "_bytes_to_date", "StringConverter", ".", "upgrade_mapper", "(", "dateparser", ",", "date", "(", "2000", ",", "1", ",", "1", ")", ")", "convert", "=", "StringConverter", "(", "dateparser", ...
[ 203, 4 ]
[ 213, 44 ]
python
en
['en', 'de', 'en']
False
TestStringConverter.test_string_to_object
(self)
Make sure that string-to-object functions are properly recognized
Make sure that string-to-object functions are properly recognized
def test_string_to_object(self): "Make sure that string-to-object functions are properly recognized" old_mapper = StringConverter._mapper[:] # copy of list conv = StringConverter(_bytes_to_date) assert_equal(conv._mapper, old_mapper) assert_(hasattr(conv, 'default'))
[ "def", "test_string_to_object", "(", "self", ")", ":", "old_mapper", "=", "StringConverter", ".", "_mapper", "[", ":", "]", "# copy of list", "conv", "=", "StringConverter", "(", "_bytes_to_date", ")", "assert_equal", "(", "conv", ".", "_mapper", ",", "old_mappe...
[ 215, 4 ]
[ 220, 41 ]
python
en
['en', 'en', 'en']
True
TestStringConverter.test_keep_default
(self)
Make sure we don't lose an explicit default
Make sure we don't lose an explicit default
def test_keep_default(self): "Make sure we don't lose an explicit default" converter = StringConverter(None, missing_values='', default=-999) converter.upgrade('3.14159265') assert_equal(converter.default, -999) assert_equal(converter.type, np....
[ "def", "test_keep_default", "(", "self", ")", ":", "converter", "=", "StringConverter", "(", "None", ",", "missing_values", "=", "''", ",", "default", "=", "-", "999", ")", "converter", ".", "upgrade", "(", "'3.14159265'", ")", "assert_equal", "(", "converte...
[ 222, 4 ]
[ 234, 53 ]
python
en
['en', 'fr', 'en']
True
TestStringConverter.test_keep_default_zero
(self)
Check that we don't lose a default of 0
Check that we don't lose a default of 0
def test_keep_default_zero(self): "Check that we don't lose a default of 0" converter = StringConverter(int, default=0, missing_values="N/A") assert_equal(converter.default, 0)
[ "def", "test_keep_default_zero", "(", "self", ")", ":", "converter", "=", "StringConverter", "(", "int", ",", "default", "=", "0", ",", "missing_values", "=", "\"N/A\"", ")", "assert_equal", "(", "converter", ".", "default", ",", "0", ")" ]
[ 236, 4 ]
[ 240, 42 ]
python
en
['en', 'en', 'en']
True
TestStringConverter.test_keep_missing_values
(self)
Check that we're not losing missing values
Check that we're not losing missing values
def test_keep_missing_values(self): "Check that we're not losing missing values" converter = StringConverter(int, default=0, missing_values="N/A") assert_equal( converter.missing_values, {'', 'N/A'})
[ "def", "test_keep_missing_values", "(", "self", ")", ":", "converter", "=", "StringConverter", "(", "int", ",", "default", "=", "0", ",", "missing_values", "=", "\"N/A\"", ")", "assert_equal", "(", "converter", ".", "missing_values", ",", "{", "''", ",", "'N...
[ 242, 4 ]
[ 247, 50 ]
python
en
['en', 'en', 'en']
True
TestStringConverter.test_int64_dtype
(self)
Check that int64 integer types can be specified
Check that int64 integer types can be specified
def test_int64_dtype(self): "Check that int64 integer types can be specified" converter = StringConverter(np.int64, default=0) val = "-9223372036854775807" assert_(converter(val) == -9223372036854775807) val = "9223372036854775807" assert_(converter(val) == 92233720368547...
[ "def", "test_int64_dtype", "(", "self", ")", ":", "converter", "=", "StringConverter", "(", "np", ".", "int64", ",", "default", "=", "0", ")", "val", "=", "\"-9223372036854775807\"", "assert_", "(", "converter", "(", "val", ")", "==", "-", "92233720368547758...
[ 249, 4 ]
[ 255, 54 ]
python
en
['en', 'en', 'en']
True
TestStringConverter.test_uint64_dtype
(self)
Check that uint64 integer types can be specified
Check that uint64 integer types can be specified
def test_uint64_dtype(self): "Check that uint64 integer types can be specified" converter = StringConverter(np.uint64, default=0) val = "9223372043271415339" assert_(converter(val) == 9223372043271415339)
[ "def", "test_uint64_dtype", "(", "self", ")", ":", "converter", "=", "StringConverter", "(", "np", ".", "uint64", ",", "default", "=", "0", ")", "val", "=", "\"9223372043271415339\"", "assert_", "(", "converter", "(", "val", ")", "==", "9223372043271415339", ...
[ 257, 4 ]
[ 261, 54 ]
python
en
['en', 'en', 'en']
True
TestMiscFunctions.test_has_nested_dtype
(self)
Test has_nested_dtype
Test has_nested_dtype
def test_has_nested_dtype(self): "Test has_nested_dtype" ndtype = np.dtype(float) assert_equal(has_nested_fields(ndtype), False) ndtype = np.dtype([('A', '|S3'), ('B', float)]) assert_equal(has_nested_fields(ndtype), False) ndtype = np.dtype([('A', int), ('B', [('BA', flo...
[ "def", "test_has_nested_dtype", "(", "self", ")", ":", "ndtype", "=", "np", ".", "dtype", "(", "float", ")", "assert_equal", "(", "has_nested_fields", "(", "ndtype", ")", ",", "False", ")", "ndtype", "=", "np", ".", "dtype", "(", "[", "(", "'A'", ",", ...
[ 266, 4 ]
[ 273, 53 ]
python
en
['en', 'en', 'en']
False
TestMiscFunctions.test_easy_dtype
(self)
Test ndtype on dtypes
Test ndtype on dtypes
def test_easy_dtype(self): "Test ndtype on dtypes" # Simple case ndtype = float assert_equal(easy_dtype(ndtype), np.dtype(float)) # As string w/o names ndtype = "i4, f8" assert_equal(easy_dtype(ndtype), np.dtype([('f0', "i4"), ('f1', "f8")])) ...
[ "def", "test_easy_dtype", "(", "self", ")", ":", "# Simple case", "ndtype", "=", "float", "assert_equal", "(", "easy_dtype", "(", "ndtype", ")", ",", "np", ".", "dtype", "(", "float", ")", ")", "# As string w/o names", "ndtype", "=", "\"i4, f8\"", "assert_equa...
[ 275, 4 ]
[ 330, 66 ]
python
en
['en', 'en', 'en']
True
TestMiscFunctions.test_flatten_dtype
(self)
Testing flatten_dtype
Testing flatten_dtype
def test_flatten_dtype(self): "Testing flatten_dtype" # Standard dtype dt = np.dtype([("a", "f8"), ("b", "f8")]) dt_flat = flatten_dtype(dt) assert_equal(dt_flat, [float, float]) # Recursive dtype dt = np.dtype([("a", [("aa", '|S1'), ("ab", '|S2')]), ("b", int)]) ...
[ "def", "test_flatten_dtype", "(", "self", ")", ":", "# Standard dtype", "dt", "=", "np", ".", "dtype", "(", "[", "(", "\"a\"", ",", "\"f8\"", ")", ",", "(", "\"b\"", ",", "\"f8\"", ")", "]", ")", "dt_flat", "=", "flatten_dtype", "(", "dt", ")", "asse...
[ 332, 4 ]
[ 351, 45 ]
python
en
['en', 'nl', 'en']
False
DeterministicTuringMachine.run
(self)
Run step until we reach accept or reject
Run step until we reach accept or reject
def run(self) -> Tuple[bool, str]: """Run step until we reach accept or reject""" while True: result = self.step() if isinstance(result, bool): return result, "".join(self.tape.content).rstrip(BLANK)
[ "def", "run", "(", "self", ")", "->", "Tuple", "[", "bool", ",", "str", "]", ":", "while", "True", ":", "result", "=", "self", ".", "step", "(", ")", "if", "isinstance", "(", "result", ",", "bool", ")", ":", "return", "result", ",", "\"\"", ".", ...
[ 130, 4 ]
[ 135, 71 ]
python
en
['en', 'en', 'en']
True
ModelHooks.setup
(self, stage: str)
Called at the beginning of fit and test. This is a good hook when you need to build models dynamically or adjust something about them. This hook is called on every process when using DDP. Args: stage: either 'fit' or 'test' Example:: class LitModel(......
Called at the beginning of fit and test. This is a good hook when you need to build models dynamically or adjust something about them. This hook is called on every process when using DDP.
def setup(self, stage: str) -> None: """ Called at the beginning of fit and test. This is a good hook when you need to build models dynamically or adjust something about them. This hook is called on every process when using DDP. Args: stage: either 'fit' or 'test' ...
[ "def", "setup", "(", "self", ",", "stage", ":", "str", ")", "->", "None", ":" ]
[ 27, 4 ]
[ 53, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.teardown
(self, stage: str)
Called at the end of fit and test. Args: stage: either 'fit' or 'test'
Called at the end of fit and test.
def teardown(self, stage: str) -> None: """ Called at the end of fit and test. Args: stage: either 'fit' or 'test' """
[ "def", "teardown", "(", "self", ",", "stage", ":", "str", ")", "->", "None", ":" ]
[ 55, 4 ]
[ 61, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_fit_start
(self)
Called at the very beginning of fit. If on DDP it is called on every process
Called at the very beginning of fit. If on DDP it is called on every process
def on_fit_start(self) -> None: """ Called at the very beginning of fit. If on DDP it is called on every process """
[ "def", "on_fit_start", "(", "self", ")", "->", "None", ":" ]
[ 63, 4 ]
[ 67, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_fit_end
(self)
Called at the very end of fit. If on DDP it is called on every process
Called at the very end of fit. If on DDP it is called on every process
def on_fit_end(self) -> None: """ Called at the very end of fit. If on DDP it is called on every process """
[ "def", "on_fit_end", "(", "self", ")", "->", "None", ":" ]
[ 69, 4 ]
[ 73, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_train_start
(self)
Called at the beginning of training after sanity check.
Called at the beginning of training after sanity check.
def on_train_start(self) -> None: """ Called at the beginning of training after sanity check. """
[ "def", "on_train_start", "(", "self", ")", "->", "None", ":" ]
[ 75, 4 ]
[ 78, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_train_end
(self)
Called at the end of training before logger experiment is closed.
Called at the end of training before logger experiment is closed.
def on_train_end(self) -> None: """ Called at the end of training before logger experiment is closed. """
[ "def", "on_train_end", "(", "self", ")", "->", "None", ":" ]
[ 81, 4 ]
[ 84, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_validation_start
(self)
Called at the beginning of validation.
Called at the beginning of validation.
def on_validation_start(self) -> None: """ Called at the beginning of validation. """
[ "def", "on_validation_start", "(", "self", ")", "->", "None", ":" ]
[ 87, 4 ]
[ 90, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_validation_end
(self)
Called at the end of validation.
Called at the end of validation.
def on_validation_end(self) -> None: """ Called at the end of validation. """
[ "def", "on_validation_end", "(", "self", ")", "->", "None", ":" ]
[ 93, 4 ]
[ 96, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_pretrain_routine_start
(self)
Called at the beginning of the pretrain routine (between fit and train start). - fit - pretrain_routine start - pretrain_routine end - training_start
Called at the beginning of the pretrain routine (between fit and train start).
def on_pretrain_routine_start(self) -> None: """ Called at the beginning of the pretrain routine (between fit and train start). - fit - pretrain_routine start - pretrain_routine end - training_start """
[ "def", "on_pretrain_routine_start", "(", "self", ")", "->", "None", ":" ]
[ 99, 4 ]
[ 108, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_pretrain_routine_end
(self)
Called at the end of the pretrain routine (between fit and train start). - fit - pretrain_routine start - pretrain_routine end - training_start
Called at the end of the pretrain routine (between fit and train start).
def on_pretrain_routine_end(self) -> None: """ Called at the end of the pretrain routine (between fit and train start). - fit - pretrain_routine start - pretrain_routine end - training_start """
[ "def", "on_pretrain_routine_end", "(", "self", ")", "->", "None", ":" ]
[ 111, 4 ]
[ 120, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_train_batch_start
(self, batch: Any, batch_idx: int, dataloader_idx: int)
Called in the training loop before anything happens for that batch. If you return -1 here, you will skip training for the rest of the current epoch. Args: batch: The batched data as it is returned by the training DataLoader. batch_idx: the index of the batch ...
Called in the training loop before anything happens for that batch.
def on_train_batch_start(self, batch: Any, batch_idx: int, dataloader_idx: int) -> None: """ Called in the training loop before anything happens for that batch. If you return -1 here, you will skip training for the rest of the current epoch. Args: batch: The batched data as...
[ "def", "on_train_batch_start", "(", "self", ",", "batch", ":", "Any", ",", "batch_idx", ":", "int", ",", "dataloader_idx", ":", "int", ")", "->", "None", ":" ]
[ 123, 4 ]
[ 133, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_train_batch_end
(self, outputs: Any, batch: Any, batch_idx: int, dataloader_idx: int)
Called in the training loop after the batch. Args: outputs: The outputs of training_step_end(training_step(x)) batch: The batched data as it is returned by the training DataLoader. batch_idx: the index of the batch dataloader_idx: the index of the datalo...
Called in the training loop after the batch.
def on_train_batch_end(self, outputs: Any, batch: Any, batch_idx: int, dataloader_idx: int) -> None: """ Called in the training loop after the batch. Args: outputs: The outputs of training_step_end(training_step(x)) batch: The batched data as it is returned by the traini...
[ "def", "on_train_batch_end", "(", "self", ",", "outputs", ":", "Any", ",", "batch", ":", "Any", ",", "batch_idx", ":", "int", ",", "dataloader_idx", ":", "int", ")", "->", "None", ":" ]
[ 136, 4 ]
[ 145, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_validation_model_eval
(self)
Sets the model to eval during the val loop
Sets the model to eval during the val loop
def on_validation_model_eval(self) -> None: """ Sets the model to eval during the val loop """ self.eval()
[ "def", "on_validation_model_eval", "(", "self", ")", "->", "None", ":", "self", ".", "eval", "(", ")" ]
[ 148, 4 ]
[ 152, 19 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_validation_model_train
(self)
Sets the model to train during the val loop
Sets the model to train during the val loop
def on_validation_model_train(self) -> None: """ Sets the model to train during the val loop """ self.train()
[ "def", "on_validation_model_train", "(", "self", ")", "->", "None", ":", "self", ".", "train", "(", ")" ]
[ 154, 4 ]
[ 158, 20 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_validation_batch_start
(self, batch: Any, batch_idx: int, dataloader_idx: int)
Called in the validation loop before anything happens for that batch. Args: batch: The batched data as it is returned by the validation DataLoader. batch_idx: the index of the batch dataloader_idx: the index of the dataloader
Called in the validation loop before anything happens for that batch.
def on_validation_batch_start(self, batch: Any, batch_idx: int, dataloader_idx: int) -> None: """ Called in the validation loop before anything happens for that batch. Args: batch: The batched data as it is returned by the validation DataLoader. batch_idx: the index of t...
[ "def", "on_validation_batch_start", "(", "self", ",", "batch", ":", "Any", ",", "batch_idx", ":", "int", ",", "dataloader_idx", ":", "int", ")", "->", "None", ":" ]
[ 160, 4 ]
[ 168, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_validation_batch_end
(self, outputs: Any, batch: Any, batch_idx: int, dataloader_idx: int)
Called in the validation loop after the batch. Args: outputs: The outputs of validation_step_end(validation_step(x)) batch: The batched data as it is returned by the validation DataLoader. batch_idx: the index of the batch dataloader_idx: the index of th...
Called in the validation loop after the batch.
def on_validation_batch_end(self, outputs: Any, batch: Any, batch_idx: int, dataloader_idx: int) -> None: """ Called in the validation loop after the batch. Args: outputs: The outputs of validation_step_end(validation_step(x)) batch: The batched data as it is returned by...
[ "def", "on_validation_batch_end", "(", "self", ",", "outputs", ":", "Any", ",", "batch", ":", "Any", ",", "batch_idx", ":", "int", ",", "dataloader_idx", ":", "int", ")", "->", "None", ":" ]
[ 171, 4 ]
[ 180, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_test_batch_start
(self, batch: Any, batch_idx: int, dataloader_idx: int)
Called in the test loop before anything happens for that batch. Args: batch: The batched data as it is returned by the test DataLoader. batch_idx: the index of the batch dataloader_idx: the index of the dataloader
Called in the test loop before anything happens for that batch.
def on_test_batch_start(self, batch: Any, batch_idx: int, dataloader_idx: int) -> None: """ Called in the test loop before anything happens for that batch. Args: batch: The batched data as it is returned by the test DataLoader. batch_idx: the index of the batch ...
[ "def", "on_test_batch_start", "(", "self", ",", "batch", ":", "Any", ",", "batch_idx", ":", "int", ",", "dataloader_idx", ":", "int", ")", "->", "None", ":" ]
[ 183, 4 ]
[ 191, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_test_batch_end
(self, outputs: Any, batch: Any, batch_idx: int, dataloader_idx: int)
Called in the test loop after the batch. Args: outputs: The outputs of test_step_end(test_step(x)) batch: The batched data as it is returned by the test DataLoader. batch_idx: the index of the batch dataloader_idx: the index of the dataloader
Called in the test loop after the batch.
def on_test_batch_end(self, outputs: Any, batch: Any, batch_idx: int, dataloader_idx: int) -> None: """ Called in the test loop after the batch. Args: outputs: The outputs of test_step_end(test_step(x)) batch: The batched data as it is returned by the test DataLoader. ...
[ "def", "on_test_batch_end", "(", "self", ",", "outputs", ":", "Any", ",", "batch", ":", "Any", ",", "batch_idx", ":", "int", ",", "dataloader_idx", ":", "int", ")", "->", "None", ":" ]
[ 194, 4 ]
[ 203, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_test_model_train
(self)
Sets the model to train during the test loop
Sets the model to train during the test loop
def on_test_model_train(self) -> None: """ Sets the model to train during the test loop """ self.train()
[ "def", "on_test_model_train", "(", "self", ")", "->", "None", ":", "self", ".", "train", "(", ")" ]
[ 206, 4 ]
[ 210, 20 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_test_model_eval
(self)
Sets the model to eval during the test loop
Sets the model to eval during the test loop
def on_test_model_eval(self) -> None: """ Sets the model to eval during the test loop """ self.eval()
[ "def", "on_test_model_eval", "(", "self", ")", "->", "None", ":", "self", ".", "eval", "(", ")" ]
[ 212, 4 ]
[ 216, 19 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_predict_model_eval
(self)
Sets the model to eval during the predict loop
Sets the model to eval during the predict loop
def on_predict_model_eval(self) -> None: """ Sets the model to eval during the predict loop """ self.eval()
[ "def", "on_predict_model_eval", "(", "self", ")", "->", "None", ":", "self", ".", "eval", "(", ")" ]
[ 218, 4 ]
[ 222, 19 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_epoch_start
(self)
Called in the training loop at the very beginning of the epoch.
Called in the training loop at the very beginning of the epoch.
def on_epoch_start(self) -> None: """ Called in the training loop at the very beginning of the epoch. """
[ "def", "on_epoch_start", "(", "self", ")", "->", "None", ":" ]
[ 224, 4 ]
[ 227, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_epoch_end
(self)
Called in the training loop at the very end of the epoch.
Called in the training loop at the very end of the epoch.
def on_epoch_end(self) -> None: """ Called in the training loop at the very end of the epoch. """
[ "def", "on_epoch_end", "(", "self", ")", "->", "None", ":" ]
[ 230, 4 ]
[ 233, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_train_epoch_start
(self)
Called in the training loop at the very beginning of the epoch.
Called in the training loop at the very beginning of the epoch.
def on_train_epoch_start(self) -> None: """ Called in the training loop at the very beginning of the epoch. """
[ "def", "on_train_epoch_start", "(", "self", ")", "->", "None", ":" ]
[ 236, 4 ]
[ 239, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_train_epoch_end
(self, outputs)
Called in the training loop at the very end of the epoch.
Called in the training loop at the very end of the epoch.
def on_train_epoch_end(self, outputs) -> None: """ Called in the training loop at the very end of the epoch. """
[ "def", "on_train_epoch_end", "(", "self", ",", "outputs", ")", "->", "None", ":" ]
[ 242, 4 ]
[ 245, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_validation_epoch_start
(self)
Called in the validation loop at the very beginning of the epoch.
Called in the validation loop at the very beginning of the epoch.
def on_validation_epoch_start(self) -> None: """ Called in the validation loop at the very beginning of the epoch. """
[ "def", "on_validation_epoch_start", "(", "self", ")", "->", "None", ":" ]
[ 248, 4 ]
[ 251, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_validation_epoch_end
(self)
Called in the validation loop at the very end of the epoch.
Called in the validation loop at the very end of the epoch.
def on_validation_epoch_end(self) -> None: """ Called in the validation loop at the very end of the epoch. """
[ "def", "on_validation_epoch_end", "(", "self", ")", "->", "None", ":" ]
[ 254, 4 ]
[ 257, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_test_epoch_start
(self)
Called in the test loop at the very beginning of the epoch.
Called in the test loop at the very beginning of the epoch.
def on_test_epoch_start(self) -> None: """ Called in the test loop at the very beginning of the epoch. """
[ "def", "on_test_epoch_start", "(", "self", ")", "->", "None", ":" ]
[ 260, 4 ]
[ 263, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_test_epoch_end
(self)
Called in the test loop at the very end of the epoch.
Called in the test loop at the very end of the epoch.
def on_test_epoch_end(self) -> None: """ Called in the test loop at the very end of the epoch. """
[ "def", "on_test_epoch_end", "(", "self", ")", "->", "None", ":" ]
[ 266, 4 ]
[ 269, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_test_start
(self)
Called at the beginning of testing.
Called at the beginning of testing.
def on_test_start(self) -> None: """ Called at the beginning of testing. """
[ "def", "on_test_start", "(", "self", ")", "->", "None", ":" ]
[ 272, 4 ]
[ 275, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_test_end
(self)
Called at the end of testing.
Called at the end of testing.
def on_test_end(self) -> None: """ Called at the end of testing. """
[ "def", "on_test_end", "(", "self", ")", "->", "None", ":" ]
[ 278, 4 ]
[ 281, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_before_zero_grad
(self, optimizer: Optimizer)
Called after optimizer.step() and before optimizer.zero_grad(). Called in the training loop after taking an optimizer step and before zeroing grads. Good place to inspect weight information with weights updated. This is where it is called:: for optimizer in optimizers: ...
Called after optimizer.step() and before optimizer.zero_grad().
def on_before_zero_grad(self, optimizer: Optimizer) -> None: """ Called after optimizer.step() and before optimizer.zero_grad(). Called in the training loop after taking an optimizer step and before zeroing grads. Good place to inspect weight information with weights updated. T...
[ "def", "on_before_zero_grad", "(", "self", ",", "optimizer", ":", "Optimizer", ")", "->", "None", ":" ]
[ 284, 4 ]
[ 300, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_after_backward
(self)
Called in the training loop after loss.backward() and before optimizers do anything. This is the ideal place to inspect or log gradient information. Example:: def on_after_backward(self): # example to inspect gradient information in tensorboard if s...
Called in the training loop after loss.backward() and before optimizers do anything. This is the ideal place to inspect or log gradient information.
def on_after_backward(self) -> None: """ Called in the training loop after loss.backward() and before optimizers do anything. This is the ideal place to inspect or log gradient information. Example:: def on_after_backward(self): # example to inspect gradient...
[ "def", "on_after_backward", "(", "self", ")", "->", "None", ":" ]
[ 303, 4 ]
[ 318, 11 ]
python
en
['en', 'error', 'th']
False
ModelHooks.on_post_move_to_device
(self)
Called in the ``parameter_validation`` decorator after :meth:`~pytorch_lightning.core.LightningModule.to` is called. This is a good place to tie weights between modules after moving them to a device. Can be used when training models with weight sharing properties on TPU. Addresses the ...
Called in the ``parameter_validation`` decorator after :meth:`~pytorch_lightning.core.LightningModule.to` is called. This is a good place to tie weights between modules after moving them to a device. Can be used when training models with weight sharing properties on TPU.
def on_post_move_to_device(self) -> None: """ Called in the ``parameter_validation`` decorator after :meth:`~pytorch_lightning.core.LightningModule.to` is called. This is a good place to tie weights between modules after moving them to a device. Can be used when training models with weig...
[ "def", "on_post_move_to_device", "(", "self", ")", "->", "None", ":" ]
[ 320, 4 ]
[ 334, 11 ]
python
en
['en', 'error', 'th']
False
DataHooks.prepare_data
(self)
Use this to download and prepare data. .. warning:: DO NOT set state to the model (use `setup` instead) since this is NOT called on every GPU in DDP/TPU Example:: def prepare_data(self): # good download_data() tokenize()...
Use this to download and prepare data.
def prepare_data(self) -> None: """ Use this to download and prepare data. .. warning:: DO NOT set state to the model (use `setup` instead) since this is NOT called on every GPU in DDP/TPU Example:: def prepare_data(self): # good ...
[ "def", "prepare_data", "(", "self", ")", "->", "None", ":" ]
[ 340, 4 ]
[ 383, 11 ]
python
en
['en', 'error', 'th']
False
DataHooks.train_dataloader
(self)
Implement a PyTorch DataLoader for training. Return: Single PyTorch :class:`~torch.utils.data.DataLoader`. The dataloader you return will not be called every epoch unless you set :paramref:`~pytorch_lightning.trainer.Trainer.reload_dataloaders_every_epoch` to ``True``. ...
Implement a PyTorch DataLoader for training.
def train_dataloader(self) -> DataLoader: """ Implement a PyTorch DataLoader for training. Return: Single PyTorch :class:`~torch.utils.data.DataLoader`. The dataloader you return will not be called every epoch unless you set :paramref:`~pytorch_lightning.trainer.Tra...
[ "def", "train_dataloader", "(", "self", ")", "->", "DataLoader", ":", "rank_zero_warn", "(", "\"`train_dataloader` must be implemented to be used with the Lightning Trainer\"", ")" ]
[ 385, 4 ]
[ 429, 102 ]
python
en
['en', 'error', 'th']
False
DataHooks.test_dataloader
(self)
r""" Implement one or multiple PyTorch DataLoaders for testing. The dataloader you return will not be called every epoch unless you set :paramref:`~pytorch_lightning.trainer.Trainer.reload_dataloaders_every_epoch` to ``True``. For data processing use the following pattern: ...
r""" Implement one or multiple PyTorch DataLoaders for testing.
def test_dataloader(self) -> Union[DataLoader, List[DataLoader]]: r""" Implement one or multiple PyTorch DataLoaders for testing. The dataloader you return will not be called every epoch unless you set :paramref:`~pytorch_lightning.trainer.Trainer.reload_dataloaders_every_epoch` to ``Tr...
[ "def", "test_dataloader", "(", "self", ")", "->", "Union", "[", "DataLoader", ",", "List", "[", "DataLoader", "]", "]", ":" ]
[ 431, 4 ]
[ 489, 11 ]
python
cy
['en', 'cy', 'hi']
False
DataHooks.val_dataloader
(self)
r""" Implement one or multiple PyTorch DataLoaders for validation. The dataloader you return will not be called every epoch unless you set :paramref:`~pytorch_lightning.trainer.Trainer.reload_dataloaders_every_epoch` to ``True``. It's recommended that all data downloads and preparation...
r""" Implement one or multiple PyTorch DataLoaders for validation.
def val_dataloader(self) -> Union[DataLoader, List[DataLoader]]: r""" Implement one or multiple PyTorch DataLoaders for validation. The dataloader you return will not be called every epoch unless you set :paramref:`~pytorch_lightning.trainer.Trainer.reload_dataloaders_every_epoch` to ``...
[ "def", "val_dataloader", "(", "self", ")", "->", "Union", "[", "DataLoader", ",", "List", "[", "DataLoader", "]", "]", ":" ]
[ 491, 4 ]
[ 540, 11 ]
python
cy
['en', 'cy', 'hi']
False
DataHooks.predict_dataloader
(self)
r""" Implement one or multiple PyTorch DataLoaders for prediction. It's recommended that all data downloads and preparation happen in :meth:`prepare_data`. - :meth:`~pytorch_lightning.trainer.Trainer.fit` - ... - :meth:`prepare_data` - :meth:`train_dataloader` -...
r""" Implement one or multiple PyTorch DataLoaders for prediction.
def predict_dataloader(self) -> Union[DataLoader, List[DataLoader]]: r""" Implement one or multiple PyTorch DataLoaders for prediction. It's recommended that all data downloads and preparation happen in :meth:`prepare_data`. - :meth:`~pytorch_lightning.trainer.Trainer.fit` - .....
[ "def", "predict_dataloader", "(", "self", ")", "->", "Union", "[", "DataLoader", ",", "List", "[", "DataLoader", "]", "]", ":" ]
[ 542, 4 ]
[ 565, 11 ]
python
cy
['en', 'cy', 'hi']
False
DataHooks.transfer_batch_to_device
(self, batch: Any, device: Optional[torch.device] = None)
Override this hook if your :class:`~torch.utils.data.DataLoader` returns tensors wrapped in a custom data structure. The data types listed below (and any arbitrary nesting of them) are supported out of the box: - :class:`torch.Tensor` or anything that implements `.to(...)` - :...
Override this hook if your :class:`~torch.utils.data.DataLoader` returns tensors wrapped in a custom data structure.
def transfer_batch_to_device(self, batch: Any, device: Optional[torch.device] = None) -> Any: """ Override this hook if your :class:`~torch.utils.data.DataLoader` returns tensors wrapped in a custom data structure. The data types listed below (and any arbitrary nesting of them) are supp...
[ "def", "transfer_batch_to_device", "(", "self", ",", "batch", ":", "Any", ",", "device", ":", "Optional", "[", "torch", ".", "device", "]", "=", "None", ")", "->", "Any", ":", "device", "=", "device", "or", "self", ".", "device", "return", "move_data_to_...
[ 567, 4 ]
[ 616, 49 ]
python
en
['en', 'error', 'th']
False
DataHooks.on_before_batch_transfer
(self, batch, dataloader_idx)
Override to alter or apply batch augmentations to your batch before it is transferred to the device. .. warning:: dataloader_idx always returns 0, and will be updated to support the true idx in the future. Note: This hook only runs on single GPU training and DDP (no data-parallel)...
Override to alter or apply batch augmentations to your batch before it is transferred to the device.
def on_before_batch_transfer(self, batch, dataloader_idx): """ Override to alter or apply batch augmentations to your batch before it is transferred to the device. .. warning:: dataloader_idx always returns 0, and will be updated to support the true idx in the future. Note: ...
[ "def", "on_before_batch_transfer", "(", "self", ",", "batch", ",", "dataloader_idx", ")", ":", "return", "batch" ]
[ 618, 4 ]
[ 644, 20 ]
python
en
['en', 'error', 'th']
False
DataHooks.on_after_batch_transfer
(self, batch, dataloader_idx)
Override to alter or apply batch augmentations to your batch after it is transferred to the device. .. warning:: ``dataloader_idx`` always returns 0, and will be updated to support the true ``idx`` in the future. Note: This hook only runs on single GPU training and DDP (no data-pa...
Override to alter or apply batch augmentations to your batch after it is transferred to the device.
def on_after_batch_transfer(self, batch, dataloader_idx): """ Override to alter or apply batch augmentations to your batch after it is transferred to the device. .. warning:: ``dataloader_idx`` always returns 0, and will be updated to support the true ``idx`` in the future. Note: ...
[ "def", "on_after_batch_transfer", "(", "self", ",", "batch", ",", "dataloader_idx", ")", ":", "return", "batch" ]
[ 646, 4 ]
[ 672, 20 ]
python
en
['en', 'error', 'th']
False
CheckpointHooks.on_load_checkpoint
(self, checkpoint: Dict[str, Any])
r""" Called by Lightning to restore your model. If you saved something with :meth:`on_save_checkpoint` this is your chance to restore this. Args: checkpoint: Loaded checkpoint Example:: def on_load_checkpoint(self, checkpoint): # 99% of the time...
r""" Called by Lightning to restore your model. If you saved something with :meth:`on_save_checkpoint` this is your chance to restore this.
def on_load_checkpoint(self, checkpoint: Dict[str, Any]) -> None: r""" Called by Lightning to restore your model. If you saved something with :meth:`on_save_checkpoint` this is your chance to restore this. Args: checkpoint: Loaded checkpoint Example:: d...
[ "def", "on_load_checkpoint", "(", "self", ",", "checkpoint", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":" ]
[ 678, 4 ]
[ 695, 11 ]
python
cy
['en', 'cy', 'hi']
False
CheckpointHooks.on_save_checkpoint
(self, checkpoint: Dict[str, Any])
r""" Called by Lightning when saving a checkpoint to give you a chance to store anything else you might want to save. Args: checkpoint: Checkpoint to be saved Example:: def on_save_checkpoint(self, checkpoint): # 99% of use cases you don't need ...
r""" Called by Lightning when saving a checkpoint to give you a chance to store anything else you might want to save.
def on_save_checkpoint(self, checkpoint: Dict[str, Any]) -> None: r""" Called by Lightning when saving a checkpoint to give you a chance to store anything else you might want to save. Args: checkpoint: Checkpoint to be saved Example:: def on_save_checkp...
[ "def", "on_save_checkpoint", "(", "self", ",", "checkpoint", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":" ]
[ 697, 4 ]
[ 716, 11 ]
python
cy
['en', 'cy', 'hi']
False
test_qr_mode_full_future_warning
()
Check mode='full' FutureWarning. In numpy 1.8 the mode options 'full' and 'economic' in linalg.qr were deprecated. The release date will probably be sometime in the summer of 2013.
Check mode='full' FutureWarning.
def test_qr_mode_full_future_warning(): """Check mode='full' FutureWarning. In numpy 1.8 the mode options 'full' and 'economic' in linalg.qr were deprecated. The release date will probably be sometime in the summer of 2013. """ a = np.eye(2) assert_warns(DeprecationWarning, np.linalg.qr, a...
[ "def", "test_qr_mode_full_future_warning", "(", ")", ":", "a", "=", "np", ".", "eye", "(", "2", ")", "assert_warns", "(", "DeprecationWarning", ",", "np", ".", "linalg", ".", "qr", ",", "a", ",", "mode", "=", "'full'", ")", "assert_warns", "(", "Deprecat...
[ 9, 0 ]
[ 21, 63 ]
python
en
['en', 'jv', 'en']
True
test_module_exists
()
Test if the some 3rd party libs are available
Test if the some 3rd party libs are available
def test_module_exists(): """Test if the some 3rd party libs are available""" assert _module_available("torch") assert _module_available("torch.nn.parallel") assert not _module_available("torch.nn.asdf") assert not _module_available("asdf") assert not _module_available("asdf.bla.asdf")
[ "def", "test_module_exists", "(", ")", ":", "assert", "_module_available", "(", "\"torch\"", ")", "assert", "_module_available", "(", "\"torch.nn.parallel\"", ")", "assert", "not", "_module_available", "(", "\"torch.nn.asdf\"", ")", "assert", "not", "_module_available",...
[ 17, 0 ]
[ 23, 49 ]
python
en
['en', 'en', 'en']
True
read_dataset
(filepath: str)
Read a pandas DataFrame from csv and return data. :param filepath: String with the filepath of the file :type filepath: str :return: A pandas Dataframe with the data inside the file :rtype: pd.DataFrame
Read a pandas DataFrame from csv and return data.
def read_dataset(filepath: str) -> pd.DataFrame: """Read a pandas DataFrame from csv and return data. :param filepath: String with the filepath of the file :type filepath: str :return: A pandas Dataframe with the data inside the file :rtype: pd.DataFrame """ _, file_extension = path.splitex...
[ "def", "read_dataset", "(", "filepath", ":", "str", ")", "->", "pd", ".", "DataFrame", ":", "_", ",", "file_extension", "=", "path", ".", "splitext", "(", "filepath", ")", "if", "file_extension", "==", "\".csv\"", ":", "data", "=", "pd", ".", "read_csv",...
[ 8, 0 ]
[ 22, 19 ]
python
en
['en', 'en', 'en']
True
drop_values
(data: pd.DataFrame, drop_duplicates: list, to_drop: list)
Drop data with no sense, duplicates or NaN values. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param drop_duplicates: List with the column tags to drop the duplicates :type drop_duplicates: list :param to_drop: List with the column tags to be dropped :type to_drop: lis...
Drop data with no sense, duplicates or NaN values.
def drop_values(data: pd.DataFrame, drop_duplicates: list, to_drop: list) -> pd.DataFrame: """Drop data with no sense, duplicates or NaN values. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param drop_duplicates: List with the column tags to drop the duplicates :type drop_d...
[ "def", "drop_values", "(", "data", ":", "pd", ".", "DataFrame", ",", "drop_duplicates", ":", "list", ",", "to_drop", ":", "list", ")", "->", "pd", ".", "DataFrame", ":", "# Dropping out data registered with the same name, and some meaningless features", "data", "=", ...
[ 25, 0 ]
[ 48, 29 ]
python
en
['en', 'fil', 'en']
True
fill_empty_values
(data: pd.DataFrame, labels: list)
Fill empty values with zeros. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param labels: List with column tags where fill empty values :type labels: list :return: A pandas Dataframe with no empty values :rtype: pd.DataFrame
Fill empty values with zeros.
def fill_empty_values(data: pd.DataFrame, labels: list) -> pd.DataFrame: """Fill empty values with zeros. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param labels: List with column tags where fill empty values :type labels: list :return: A pandas Dataframe with no empt...
[ "def", "fill_empty_values", "(", "data", ":", "pd", ".", "DataFrame", ",", "labels", ":", "list", ")", "->", "pd", ".", "DataFrame", ":", "for", "label", "in", "labels", ":", "data", "[", "label", "]", "=", "data", "[", "label", "]", ".", "fillna", ...
[ 51, 0 ]
[ 64, 15 ]
python
en
['en', 'mg', 'en']
True
to_datetime
(data: pd.DataFrame, labels: list)
Change format to datetime. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param labels: List with column tags where dates will be transform to datetime format :type labels: list :return: A pandas Dataframe with dates in datetime format :rtype: pd.DataFrame
Change format to datetime.
def to_datetime(data: pd.DataFrame, labels: list) -> pd.DataFrame: """Change format to datetime. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param labels: List with column tags where dates will be transform to datetime format :type labels: list :return: A pandas Datafr...
[ "def", "to_datetime", "(", "data", ":", "pd", ".", "DataFrame", ",", "labels", ":", "list", ")", "->", "pd", ".", "DataFrame", ":", "for", "label", "in", "labels", ":", "data", "[", "label", "]", "=", "pd", ".", "to_datetime", "(", "data", "[", "la...
[ 67, 0 ]
[ 80, 15 ]
python
en
['en', 'en', 'en']
True
to_last_date
(data: pd.DataFrame, ref_label: str)
Use the last date of the last year registered considered as the end of the study period. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param ref_label: List with column tags where dates will be filled with the last date registered :type ref_label: str :return: A pandas Dataf...
Use the last date of the last year registered considered as the end of the study period.
def to_last_date(data: pd.DataFrame, ref_label: str) -> pd.DataFrame: """Use the last date of the last year registered considered as the end of the study period. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param ref_label: List with column tags where dates will be filled with ...
[ "def", "to_last_date", "(", "data", ":", "pd", ".", "DataFrame", ",", "ref_label", ":", "str", ")", "->", "pd", ".", "DataFrame", ":", "# Define an auxiliar feature 'last date' to help on calculating life age", "data", "[", "\"last_date\"", "]", "=", "data", "[", ...
[ 83, 0 ]
[ 99, 15 ]
python
en
['en', 'en', 'en']
True
eliminate_spurious_data
(data: pd.DataFrame, sort_value: str)
Clean the dataset from spurious data, negative years and non-sense data. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param sort_value: String tag value that will be used to sort the Dataframe :type sort_value: str :return: A pandas Dataframe with spurious data cleaned ...
Clean the dataset from spurious data, negative years and non-sense data.
def eliminate_spurious_data(data: pd.DataFrame, sort_value: str) -> pd.DataFrame: """Clean the dataset from spurious data, negative years and non-sense data. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param sort_value: String tag value that will be used to sort the Dataframe ...
[ "def", "eliminate_spurious_data", "(", "data", ":", "pd", ".", "DataFrame", ",", "sort_value", ":", "str", ")", "->", "pd", ".", "DataFrame", ":", "# From all numerical data", "numeric", "=", "data", ".", "select_dtypes", "(", "include", "=", "np", ".", "num...
[ 102, 0 ]
[ 123, 30 ]
python
en
['en', 'en', 'en']
True
non_numerical_recoding
(data: pd.DataFrame, non_numerical: str)
Map all the non numerical data to a categorical number. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param non_numerical: String tag with the column with non numerical values :type non_numerical: str :return: A pandas Dataframe with the non_numerical column transformed to n...
Map all the non numerical data to a categorical number.
def non_numerical_recoding(data: pd.DataFrame, non_numerical: str) -> pd.DataFrame: """Map all the non numerical data to a categorical number. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param non_numerical: String tag with the column with non numerical values :type non_nu...
[ "def", "non_numerical_recoding", "(", "data", ":", "pd", ".", "DataFrame", ",", "non_numerical", ":", "str", ")", "->", "pd", ".", "DataFrame", ":", "# Looking for different values", "diff_values", "=", "data", "[", "non_numerical", "]", ".", "unique", "(", ")...
[ 126, 0 ]
[ 145, 15 ]
python
en
['en', 'en', 'en']
True
data_normalization
(data: pd.DataFrame)
Normalize quantitative data of the given dataframe if their skewness is greater than 2. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :return: A pandas dataframe with the data with skewness > 2 been normalized :rtype: pd.DataFrame
Normalize quantitative data of the given dataframe if their skewness is greater than 2.
def data_normalization(data: pd.DataFrame) -> pd.DataFrame: """Normalize quantitative data of the given dataframe if their skewness is greater than 2. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :return: A pandas dataframe with the data with skewness > 2 been normalized :rt...
[ "def", "data_normalization", "(", "data", ":", "pd", ".", "DataFrame", ")", "->", "pd", ".", "DataFrame", ":", "features", "=", "[", "]", "numeric", "=", "data", ".", "select_dtypes", "(", "include", "=", "np", ".", "number", ")", "# Include only quantitat...
[ 148, 0 ]
[ 178, 55 ]
python
en
['en', 'en', 'en']
True
split_X_t
(data: pd.DataFrame, x_tags: list, label_tag: str)
Split X and t from a dataset using their colum tags. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param x_tags: List with the column tags to be used for the characteristics matrix :type x_tags: list :param label_tag: List with the column tag of the label column :type la...
Split X and t from a dataset using their colum tags.
def split_X_t(data: pd.DataFrame, x_tags: list, label_tag: str) -> tuple: """Split X and t from a dataset using their colum tags. :param data: Pandas Dataframe with the data :type data: pd.DataFrame :param x_tags: List with the column tags to be used for the characteristics matrix :type x_tags: lis...
[ "def", "split_X_t", "(", "data", ":", "pd", ".", "DataFrame", ",", "x_tags", ":", "list", ",", "label_tag", ":", "str", ")", "->", "tuple", ":", "X", "=", "data", "[", "x_tags", "]", "t", "=", "data", "[", "label_tag", "]", "return", "X", ",", "t...
[ 181, 0 ]
[ 195, 15 ]
python
en
['en', 'en', 'en']
True
test_accelerator_choice_ddp_cpu_custom_cluster
(device_count_mock)
Test that we choose the custom cluster even when SLURM or TE flags are around
Test that we choose the custom cluster even when SLURM or TE flags are around
def test_accelerator_choice_ddp_cpu_custom_cluster(device_count_mock): """ Test that we choose the custom cluster even when SLURM or TE flags are around """ class CustomCluster(ClusterEnvironment): def master_address(self): return 'asdf' class CB(Callback): def on_fit...
[ "def", "test_accelerator_choice_ddp_cpu_custom_cluster", "(", "device_count_mock", ")", ":", "class", "CustomCluster", "(", "ClusterEnvironment", ")", ":", "def", "master_address", "(", "self", ")", ":", "return", "'asdf'", "class", "CB", "(", "Callback", ")", ":", ...
[ 291, 0 ]
[ 320, 26 ]
python
en
['en', 'error', 'th']
False
test_plugin_accelerator_choice
(accelerator, plugin)
Ensure that when a plugin and accelerator is passed in, that the plugin takes precedent.
Ensure that when a plugin and accelerator is passed in, that the plugin takes precedent.
def test_plugin_accelerator_choice(accelerator, plugin): """ Ensure that when a plugin and accelerator is passed in, that the plugin takes precedent. """ trainer = Trainer(accelerator=accelerator, plugins=plugin, num_processes=2) assert isinstance(trainer.accelerator.training_type_plugin, DDPSharded...
[ "def", "test_plugin_accelerator_choice", "(", "accelerator", ",", "plugin", ")", ":", "trainer", "=", "Trainer", "(", "accelerator", "=", "accelerator", ",", "plugins", "=", "plugin", ",", "num_processes", "=", "2", ")", "assert", "isinstance", "(", "trainer", ...
[ 407, 0 ]
[ 415, 81 ]
python
en
['en', 'error', 'th']
False
initdb
()
Initialize the database.
Initialize the database.
def initdb(): """Initialize the database.""" click.echo('Init the db') db.create_all()
[ "def", "initdb", "(", ")", ":", "click", ".", "echo", "(", "'Init the db'", ")", "db", ".", "create_all", "(", ")" ]
[ 28, 0 ]
[ 31, 19 ]
python
en
['en', 'zu', 'en']
True
renewdb
()
Remove the database.
Remove the database.
def renewdb(): """Remove the database.""" click.echo('Renew the db') db.drop_all() db.create_all()
[ "def", "renewdb", "(", ")", ":", "click", ".", "echo", "(", "'Renew the db'", ")", "db", ".", "drop_all", "(", ")", "db", ".", "create_all", "(", ")" ]
[ 35, 0 ]
[ 39, 19 ]
python
en
['en', 'en', 'en']
True
list_routes
()
List all routes on flask service
List all routes on flask service
def list_routes(): """List all routes on flask service""" output = [] for rule in app.url_map.iter_rules(): methods = ','.join(rule.methods) line = urllib.parse.unquote( "{:50s} {:20s} {}".format(rule.endpoint, methods, rule)) output.append(line) for line in sort...
[ "def", "list_routes", "(", ")", ":", "output", "=", "[", "]", "for", "rule", "in", "app", ".", "url_map", ".", "iter_rules", "(", ")", ":", "methods", "=", "','", ".", "join", "(", "rule", ".", "methods", ")", "line", "=", "urllib", ".", "parse", ...
[ 43, 0 ]
[ 53, 19 ]
python
en
['en', 'en', 'en']
True
KafkaBrokerIntegrationTest.test_kafka_consumer_with_no_messages_received
(self)
This test verifies that consumer sends fetches correctly, and receives nothing.
This test verifies that consumer sends fetches correctly, and receives nothing.
def test_kafka_consumer_with_no_messages_received(self): """ This test verifies that consumer sends fetches correctly, and receives nothing. """ consumer = KafkaConsumer( bootstrap_servers=KafkaBrokerIntegrationTest.kafka_address(), fetch_max_wait_ms=500) consumer.assign([To...
[ "def", "test_kafka_consumer_with_no_messages_received", "(", "self", ")", ":", "consumer", "=", "KafkaConsumer", "(", "bootstrap_servers", "=", "KafkaBrokerIntegrationTest", ".", "kafka_address", "(", ")", ",", "fetch_max_wait_ms", "=", "500", ")", "consumer", ".", "a...
[ 54, 4 ]
[ 73, 58 ]
python
en
['en', 'error', 'th']
False