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
CallbackHookNameValidator._on_pretrain_routine_end_log
()
Called when the train ends.
Called when the train ends.
def _on_pretrain_routine_end_log(): """Called when the train ends.""" return None
[ "def", "_on_pretrain_routine_end_log", "(", ")", ":", "return", "None" ]
[ 148, 4 ]
[ 150, 19 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_batch_start_log
()
Called when the training batch begins.
Called when the training batch begins.
def _on_batch_start_log(): """Called when the training batch begins.""" return {"on_step": [False, True], "on_epoch": [False, True]}
[ "def", "_on_batch_start_log", "(", ")", ":", "return", "{", "\"on_step\"", ":", "[", "False", ",", "True", "]", ",", "\"on_epoch\"", ":", "[", "False", ",", "True", "]", "}" ]
[ 153, 4 ]
[ 155, 68 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_batch_end_log
()
Called when the training batch ends.
Called when the training batch ends.
def _on_batch_end_log(): """Called when the training batch ends.""" return {"on_step": [False, True], "on_epoch": [False, True]}
[ "def", "_on_batch_end_log", "(", ")", ":", "return", "{", "\"on_step\"", ":", "[", "False", ",", "True", "]", ",", "\"on_epoch\"", ":", "[", "False", ",", "True", "]", "}" ]
[ 158, 4 ]
[ 160, 68 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_train_batch_start_log
()
Called when the training batch begins.
Called when the training batch begins.
def _on_train_batch_start_log(): """Called when the training batch begins.""" return {"on_step": [False, True], "on_epoch": [False, True]}
[ "def", "_on_train_batch_start_log", "(", ")", ":", "return", "{", "\"on_step\"", ":", "[", "False", ",", "True", "]", ",", "\"on_epoch\"", ":", "[", "False", ",", "True", "]", "}" ]
[ 163, 4 ]
[ 165, 68 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_train_batch_end_log
()
Called when the training batch ends.
Called when the training batch ends.
def _on_train_batch_end_log(): """Called when the training batch ends.""" return {"on_step": [False, True], "on_epoch": [False, True]}
[ "def", "_on_train_batch_end_log", "(", ")", ":", "return", "{", "\"on_step\"", ":", "[", "False", ",", "True", "]", ",", "\"on_epoch\"", ":", "[", "False", ",", "True", "]", "}" ]
[ 168, 4 ]
[ 170, 68 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_validation_batch_start_log
()
Called when the validation batch begins.
Called when the validation batch begins.
def _on_validation_batch_start_log(): """Called when the validation batch begins.""" return {"on_step": [False, True], "on_epoch": [False, True]}
[ "def", "_on_validation_batch_start_log", "(", ")", ":", "return", "{", "\"on_step\"", ":", "[", "False", ",", "True", "]", ",", "\"on_epoch\"", ":", "[", "False", ",", "True", "]", "}" ]
[ 173, 4 ]
[ 175, 68 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_validation_batch_end_log
()
Called when the validation batch ends.
Called when the validation batch ends.
def _on_validation_batch_end_log(): """Called when the validation batch ends.""" return {"on_step": [False, True], "on_epoch": [False, True]}
[ "def", "_on_validation_batch_end_log", "(", ")", ":", "return", "{", "\"on_step\"", ":", "[", "False", ",", "True", "]", ",", "\"on_epoch\"", ":", "[", "False", ",", "True", "]", "}" ]
[ 178, 4 ]
[ 180, 68 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_test_batch_start_log
()
Called when the test batch begins.
Called when the test batch begins.
def _on_test_batch_start_log(): """Called when the test batch begins.""" return {"on_step": [False, True], "on_epoch": [False, True]}
[ "def", "_on_test_batch_start_log", "(", ")", ":", "return", "{", "\"on_step\"", ":", "[", "False", ",", "True", "]", ",", "\"on_epoch\"", ":", "[", "False", ",", "True", "]", "}" ]
[ 183, 4 ]
[ 185, 68 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_test_batch_end_log
()
Called when the test batch ends.
Called when the test batch ends.
def _on_test_batch_end_log(): """Called when the test batch ends.""" return {"on_step": [False, True], "on_epoch": [False, True]}
[ "def", "_on_test_batch_end_log", "(", ")", ":", "return", "{", "\"on_step\"", ":", "[", "False", ",", "True", "]", ",", "\"on_epoch\"", ":", "[", "False", ",", "True", "]", "}" ]
[ 188, 4 ]
[ 190, 68 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_validation_start_log
()
Called when the validation loop begins.
Called when the validation loop begins.
def _on_validation_start_log(): """Called when the validation loop begins.""" return {"on_step": [False, True], "on_epoch": [False, True]}
[ "def", "_on_validation_start_log", "(", ")", ":", "return", "{", "\"on_step\"", ":", "[", "False", ",", "True", "]", ",", "\"on_epoch\"", ":", "[", "False", ",", "True", "]", "}" ]
[ 193, 4 ]
[ 195, 68 ]
python
en
['en', 'af', 'en']
True
CallbackHookNameValidator._on_validation_end_log
()
Called when the validation loop ends.
Called when the validation loop ends.
def _on_validation_end_log(): """Called when the validation loop ends.""" return None
[ "def", "_on_validation_end_log", "(", ")", ":", "return", "None" ]
[ 198, 4 ]
[ 200, 19 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_test_start_log
()
Called when the test begins.
Called when the test begins.
def _on_test_start_log(): """Called when the test begins.""" return {"on_step": [False, True], "on_epoch": [False, True]}
[ "def", "_on_test_start_log", "(", ")", ":", "return", "{", "\"on_step\"", ":", "[", "False", ",", "True", "]", ",", "\"on_epoch\"", ":", "[", "False", ",", "True", "]", "}" ]
[ 203, 4 ]
[ 205, 68 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_test_end_log
()
Called when the test ends.
Called when the test ends.
def _on_test_end_log(): """Called when the test ends.""" return None
[ "def", "_on_test_end_log", "(", ")", ":", "return", "None" ]
[ 208, 4 ]
[ 210, 19 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_keyboard_interrupt_log
()
Called when the training is interrupted by KeyboardInterrupt.
Called when the training is interrupted by KeyboardInterrupt.
def _on_keyboard_interrupt_log(): """Called when the training is interrupted by KeyboardInterrupt.""" return None
[ "def", "_on_keyboard_interrupt_log", "(", ")", ":", "return", "None" ]
[ 213, 4 ]
[ 215, 19 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_save_checkpoint_log
()
Called when saving a model checkpoint.
Called when saving a model checkpoint.
def _on_save_checkpoint_log(): """Called when saving a model checkpoint.""" return None
[ "def", "_on_save_checkpoint_log", "(", ")", ":", "return", "None" ]
[ 218, 4 ]
[ 220, 19 ]
python
en
['en', 'en', 'en']
True
CallbackHookNameValidator._on_load_checkpoint_log
()
Called when loading a model checkpoint.
Called when loading a model checkpoint.
def _on_load_checkpoint_log(): """Called when loading a model checkpoint.""" return None
[ "def", "_on_load_checkpoint_log", "(", ")", ":", "return", "None" ]
[ 223, 4 ]
[ 225, 19 ]
python
en
['en', 'en', 'en']
True
TestAtleast1d.test_r1array
(self)
Test to make sure equivalent Travis O's r1array function
Test to make sure equivalent Travis O's r1array function
def test_r1array(self): """ Test to make sure equivalent Travis O's r1array function """ assert_(atleast_1d(3).shape == (1,)) assert_(atleast_1d(3j).shape == (1,)) assert_(atleast_1d(long(3)).shape == (1,)) assert_(atleast_1d(3.0).shape == (1,)) assert_(atleast_1d...
[ "def", "test_r1array", "(", "self", ")", ":", "assert_", "(", "atleast_1d", "(", "3", ")", ".", "shape", "==", "(", "1", ",", ")", ")", "assert_", "(", "atleast_1d", "(", "3j", ")", ".", "shape", "==", "(", "1", ",", ")", ")", "assert_", "(", "...
[ 49, 4 ]
[ 56, 61 ]
python
en
['en', 'en', 'en']
True
TestAtleast2d.test_r2array
(self)
Test to make sure equivalent Travis O's r2array function
Test to make sure equivalent Travis O's r2array function
def test_r2array(self): """ Test to make sure equivalent Travis O's r2array function """ assert_(atleast_2d(3).shape == (1, 1)) assert_(atleast_2d([3j, 1]).shape == (1, 2)) assert_(atleast_2d([[[3, 1], [4, 5]], [[3, 5], [1, 2]]]).shape == (2, 2, 2))
[ "def", "test_r2array", "(", "self", ")", ":", "assert_", "(", "atleast_2d", "(", "3", ")", ".", "shape", "==", "(", "1", ",", "1", ")", ")", "assert_", "(", "atleast_2d", "(", "[", "3j", ",", "1", "]", ")", ".", "shape", "==", "(", "1", ",", ...
[ 90, 4 ]
[ 95, 84 ]
python
en
['en', 'en', 'en']
True
test_amp_single_gpu_dp
(tmpdir)
Make sure DP/DDP + AMP work.
Make sure DP/DDP + AMP work.
def test_amp_single_gpu_dp(tmpdir): """Make sure DP/DDP + AMP work.""" tutils.reset_seed() trainer = Trainer( default_root_dir=tmpdir, max_epochs=1, gpus=1, accelerator='dp', precision=16, ) model = AMPTestModel() # tutils.run_model_test(trainer_options,...
[ "def", "test_amp_single_gpu_dp", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "max_epochs", "=", "1", ",", "gpus", "=", "1", ",", "accelerator", "=", "'dp'", ",", ...
[ 41, 0 ]
[ 57, 90 ]
python
en
['en', 'id', 'en']
True
test_amp_single_gpu_ddp_spawn
(tmpdir)
Make sure DP/DDP + AMP work.
Make sure DP/DDP + AMP work.
def test_amp_single_gpu_ddp_spawn(tmpdir): """Make sure DP/DDP + AMP work.""" tutils.reset_seed() trainer = Trainer( default_root_dir=tmpdir, max_epochs=1, gpus=1, accelerator='ddp_spawn', precision=16, ) model = AMPTestModel() # tutils.run_model_test(tra...
[ "def", "test_amp_single_gpu_ddp_spawn", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "max_epochs", "=", "1", ",", "gpus", "=", "1", ",", "accelerator", "=", "'ddp_spaw...
[ 61, 0 ]
[ 75, 90 ]
python
en
['en', 'id', 'en']
True
test_amp_multi_gpu_dp
(tmpdir)
Make sure DP/DDP + AMP work.
Make sure DP/DDP + AMP work.
def test_amp_multi_gpu_dp(tmpdir): """Make sure DP/DDP + AMP work.""" tutils.reset_seed() trainer = Trainer( default_root_dir=tmpdir, max_epochs=1, gpus=2, accelerator='dp', precision=16, ) model = AMPTestModel() # tutils.run_model_test(trainer_options, ...
[ "def", "test_amp_multi_gpu_dp", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "max_epochs", "=", "1", ",", "gpus", "=", "2", ",", "accelerator", "=", "'dp'", ",", "...
[ 80, 0 ]
[ 96, 90 ]
python
en
['en', 'id', 'en']
True
test_amp_multi_gpu_ddp_spawn
(tmpdir)
Make sure DP/DDP + AMP work.
Make sure DP/DDP + AMP work.
def test_amp_multi_gpu_ddp_spawn(tmpdir): """Make sure DP/DDP + AMP work.""" tutils.reset_seed() trainer = Trainer( default_root_dir=tmpdir, max_epochs=1, gpus=2, accelerator='ddp_spawn', precision=16, ) model = AMPTestModel() # tutils.run_model_test(trai...
[ "def", "test_amp_multi_gpu_ddp_spawn", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "max_epochs", "=", "1", ",", "gpus", "=", "2", ",", "accelerator", "=", "'ddp_spawn...
[ 100, 0 ]
[ 114, 90 ]
python
en
['en', 'id', 'en']
True
test_amp_gpu_ddp_slurm_managed
(tmpdir)
Make sure DDP + AMP work.
Make sure DDP + AMP work.
def test_amp_gpu_ddp_slurm_managed(tmpdir): """Make sure DDP + AMP work.""" # simulate setting slurm flags tutils.set_random_master_port() model = AMPTestModel() # exp file to get meta logger = tutils.get_default_logger(tmpdir) # exp file to get weights checkpoint = tutils.init_checkp...
[ "def", "test_amp_gpu_ddp_slurm_managed", "(", "tmpdir", ")", ":", "# simulate setting slurm flags", "tutils", ".", "set_random_master_port", "(", ")", "model", "=", "AMPTestModel", "(", ")", "# exp file to get meta", "logger", "=", "tutils", ".", "get_default_logger", "...
[ 127, 0 ]
[ 161, 31 ]
python
en
['en', 'da', 'en']
True
test_cpu_model_with_amp
(tmpdir)
Make sure model trains on CPU.
Make sure model trains on CPU.
def test_cpu_model_with_amp(tmpdir): """Make sure model trains on CPU.""" with pytest.raises(MisconfigurationException, match="AMP is only available on GPU"): Trainer(precision=16)
[ "def", "test_cpu_model_with_amp", "(", "tmpdir", ")", ":", "with", "pytest", ".", "raises", "(", "MisconfigurationException", ",", "match", "=", "\"AMP is only available on GPU\"", ")", ":", "Trainer", "(", "precision", "=", "16", ")" ]
[ 165, 0 ]
[ 168, 29 ]
python
en
['en', 'en', 'en']
True
test_amp_without_apex
(tmpdir)
Check that even with apex amp type without requesting precision=16 the amp backend is void.
Check that even with apex amp type without requesting precision=16 the amp backend is void.
def test_amp_without_apex(tmpdir): """Check that even with apex amp type without requesting precision=16 the amp backend is void.""" model = BoringModel() trainer = Trainer( default_root_dir=tmpdir, amp_backend='native', ) assert trainer.amp_backend is None trainer = Trainer( ...
[ "def", "test_amp_without_apex", "(", "tmpdir", ")", ":", "model", "=", "BoringModel", "(", ")", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "amp_backend", "=", "'native'", ",", ")", "assert", "trainer", ".", "amp_backend", "is", "...
[ 172, 0 ]
[ 190, 56 ]
python
en
['en', 'en', 'en']
True
test_amp_with_apex
(tmpdir)
Check calling apex scaling in training.
Check calling apex scaling in training.
def test_amp_with_apex(tmpdir): """Check calling apex scaling in training.""" class CustomModel(BoringModel): def training_step(self, batch, batch_idx, optimizer_idx): return super().training_step(batch, batch_idx) def configure_optimizers(self): optimizer1 = optim.Ada...
[ "def", "test_amp_with_apex", "(", "tmpdir", ")", ":", "class", "CustomModel", "(", "BoringModel", ")", ":", "def", "training_step", "(", "self", ",", "batch", ",", "batch_idx", ",", "optimizer_idx", ")", ":", "return", "super", "(", ")", ".", "training_step"...
[ 196, 0 ]
[ 227, 81 ]
python
en
['en', 'en', 'en']
True
test_pytorch_parity
( tmpdir, cls_model: LightningModule, max_diff_speed: float, max_diff_memory: float, num_epochs: int = 4, num_runs: int = 3, )
Verify that the same pytorch and lightning models achieve the same results
Verify that the same pytorch and lightning models achieve the same results
def test_pytorch_parity( tmpdir, cls_model: LightningModule, max_diff_speed: float, max_diff_memory: float, num_epochs: int = 4, num_runs: int = 3, ): """ Verify that the same pytorch and lightning models achieve the same results """ lightning = measure_loops(cls_model, kind="PT...
[ "def", "test_pytorch_parity", "(", "tmpdir", ",", "cls_model", ":", "LightningModule", ",", "max_diff_speed", ":", "float", ",", "max_diff_memory", ":", "float", ",", "num_epochs", ":", "int", "=", "4", ",", "num_runs", ":", "int", "=", "3", ",", ")", ":",...
[ 52, 0 ]
[ 76, 92 ]
python
en
['en', 'error', 'th']
False
measure_loops
(cls_model, kind, num_runs=10, num_epochs=10)
Returns an array with the last loss from each epoch for each run
Returns an array with the last loss from each epoch for each run
def measure_loops(cls_model, kind, num_runs=10, num_epochs=10): """ Returns an array with the last loss from each epoch for each run """ hist_losses = [] hist_durations = [] hist_memory = [] device_type = "cuda" if torch.cuda.is_available() else "cpu" torch.backends.cudnn.deterministic ...
[ "def", "measure_loops", "(", "cls_model", ",", "kind", ",", "num_runs", "=", "10", ",", "num_epochs", "=", "10", ")", ":", "hist_losses", "=", "[", "]", "hist_durations", "=", "[", "]", "hist_memory", "=", "[", "]", "device_type", "=", "\"cuda\"", "if", ...
[ 88, 0 ]
[ 123, 5 ]
python
en
['en', 'error', 'th']
False
plot_img
(img, *args, **kwargs)
See uspy.plotting.plot_img
See uspy.plotting.plot_img
def plot_img(img, *args, **kwargs): """See uspy.plotting.plot_img""" img = LEEMImg(img) return base_plot_img(img, *args, **kwargs)
[ "def", "plot_img", "(", "img", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "img", "=", "LEEMImg", "(", "img", ")", "return", "base_plot_img", "(", "img", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 14, 0 ]
[ 17, 46 ]
python
en
['en', 'et', 'sw']
False
ValidationStepVariations.validation_step
(self, batch, batch_idx, *args, **kwargs)
Lightning calls this inside the validation loop :param batch: :return:
Lightning calls this inside the validation loop :param batch: :return:
def validation_step(self, batch, batch_idx, *args, **kwargs): """ Lightning calls this inside the validation loop :param batch: :return: """ self.validation_step_called = True x, y = batch x = x.view(x.size(0), -1) y_hat = self(x) loss_val...
[ "def", "validation_step", "(", "self", ",", "batch", ",", "batch_idx", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "validation_step_called", "=", "True", "x", ",", "y", "=", "batch", "x", "=", "x", ".", "view", "(", "x", ".", ...
[ 24, 4 ]
[ 47, 21 ]
python
en
['en', 'error', 'th']
False
ValidationStepVariations.validation_step__multiple_dataloaders
(self, batch, batch_idx, dataloader_idx, **kwargs)
Lightning calls this inside the validation loop :param batch: :return:
Lightning calls this inside the validation loop :param batch: :return:
def validation_step__multiple_dataloaders(self, batch, batch_idx, dataloader_idx, **kwargs): """ Lightning calls this inside the validation loop :param batch: :return: """ x, y = batch x = x.view(x.size(0), -1) y_hat = self(x) loss_val = self.loss...
[ "def", "validation_step__multiple_dataloaders", "(", "self", ",", "batch", ",", "batch_idx", ",", "dataloader_idx", ",", "*", "*", "kwargs", ")", ":", "x", ",", "y", "=", "batch", "x", "=", "x", ".", "view", "(", "x", ".", "size", "(", "0", ")", ",",...
[ 67, 4 ]
[ 88, 21 ]
python
en
['en', 'error', 'th']
False
test_lr_monitor_single_lr
(tmpdir)
Test that learning rates are extracted and logged for single lr scheduler.
Test that learning rates are extracted and logged for single lr scheduler.
def test_lr_monitor_single_lr(tmpdir): """ Test that learning rates are extracted and logged for single lr scheduler. """ tutils.reset_seed() model = BoringModel() lr_monitor = LearningRateMonitor() trainer = Trainer( default_root_dir=tmpdir, max_epochs=2, limit_val_batches...
[ "def", "test_lr_monitor_single_lr", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "model", "=", "BoringModel", "(", ")", "lr_monitor", "=", "LearningRateMonitor", "(", ")", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",...
[ 26, 0 ]
[ 49, 51 ]
python
en
['en', 'en', 'en']
True
test_lr_monitor_single_lr_with_momentum
(tmpdir, opt)
Test that learning rates and momentum are extracted and logged for single lr scheduler.
Test that learning rates and momentum are extracted and logged for single lr scheduler.
def test_lr_monitor_single_lr_with_momentum(tmpdir, opt): """ Test that learning rates and momentum are extracted and logged for single lr scheduler. """ class LogMomentumModel(BoringModel): def __init__(self, opt): super().__init__() self.opt = opt def configu...
[ "def", "test_lr_monitor_single_lr_with_momentum", "(", "tmpdir", ",", "opt", ")", ":", "class", "LogMomentumModel", "(", "BoringModel", ")", ":", "def", "__init__", "(", "self", ",", "opt", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", "....
[ 53, 0 ]
[ 92, 52 ]
python
en
['en', 'error', 'th']
False
test_log_momentum_no_momentum_optimizer
(tmpdir)
Test that if optimizer doesn't have momentum then a warning is raised with log_momentum=True.
Test that if optimizer doesn't have momentum then a warning is raised with log_momentum=True.
def test_log_momentum_no_momentum_optimizer(tmpdir): """ Test that if optimizer doesn't have momentum then a warning is raised with log_momentum=True. """ class LogMomentumModel(BoringModel): def configure_optimizers(self): optimizer = optim.ASGD(self.parameters(), lr=1e-2) ...
[ "def", "test_log_momentum_no_momentum_optimizer", "(", "tmpdir", ")", ":", "class", "LogMomentumModel", "(", "BoringModel", ")", ":", "def", "configure_optimizers", "(", "self", ")", ":", "optimizer", "=", "optim", ".", "ASGD", "(", "self", ".", "parameters", "(...
[ 95, 0 ]
[ 126, 52 ]
python
en
['en', 'error', 'th']
False
test_lr_monitor_multi_lrs
(tmpdir, logging_interval)
Test that learning rates are extracted and logged for multi lr schedulers.
Test that learning rates are extracted and logged for multi lr schedulers.
def test_lr_monitor_multi_lrs(tmpdir, logging_interval): """ Test that learning rates are extracted and logged for multi lr schedulers. """ tutils.reset_seed() class CustomBoringModel(BoringModel): def training_step(self, batch, batch_idx, optimizer_idx): return super().training_step(b...
[ "def", "test_lr_monitor_multi_lrs", "(", "tmpdir", ",", "logging_interval", ")", ":", "tutils", ".", "reset_seed", "(", ")", "class", "CustomBoringModel", "(", "BoringModel", ")", ":", "def", "training_step", "(", "self", ",", "batch", ",", "batch_idx", ",", "...
[ 172, 0 ]
[ 218, 74 ]
python
en
['en', 'en', 'en']
True
test_lr_monitor_param_groups
(tmpdir)
Test that learning rates are extracted and logged for single lr scheduler.
Test that learning rates are extracted and logged for single lr scheduler.
def test_lr_monitor_param_groups(tmpdir): """ Test that learning rates are extracted and logged for single lr scheduler. """ tutils.reset_seed() class CustomClassificationModel(ClassificationModel): def configure_optimizers(self): param_groups = [{ 'params': list(self.p...
[ "def", "test_lr_monitor_param_groups", "(", "tmpdir", ")", ":", "tutils", ".", "reset_seed", "(", ")", "class", "CustomClassificationModel", "(", "ClassificationModel", ")", ":", "def", "configure_optimizers", "(", "self", ")", ":", "param_groups", "=", "[", "{", ...
[ 221, 0 ]
[ 259, 51 ]
python
en
['en', 'en', 'en']
True
foo
(var1, var2, long_var_name='hi')
r"""A one-line summary that does not use variable names or the function name. Several sentences providing an extended description. Refer to variables using back-ticks, e.g. `var`. Parameters ---------- var1 : array_like Array_like means all those objects -- lists, nested lists, etc. --...
r"""A one-line summary that does not use variable names or the function name.
def foo(var1, var2, long_var_name='hi'): r"""A one-line summary that does not use variable names or the function name. Several sentences providing an extended description. Refer to variables using back-ticks, e.g. `var`. Parameters ---------- var1 : array_like Array_like means all ...
[ "def", "foo", "(", "var1", ",", "var2", ",", "long_var_name", "=", "'hi'", ")", ":", "pass" ]
[ 37, 0 ]
[ 122, 8 ]
python
en
['en', 'en', 'en']
True
RSB.forward
(self, x)
Forward function.
Forward function.
def forward(self, x): """Forward function.""" identity = x x = self.conv_bn_relu1(x) spx = torch.split(x, self.branch_channels, 1) outputs = list() outs = list() for i in range(self.num_steps): outputs_i = list() outputs.append(outputs_i) ...
[ "def", "forward", "(", "self", ",", "x", ")", ":", "identity", "=", "x", "x", "=", "self", ".", "conv_bn_relu1", "(", "x", ")", "spx", "=", "torch", ".", "split", "(", "x", ",", "self", ".", "branch_channels", ",", "1", ")", "outputs", "=", "list...
[ 88, 4 ]
[ 120, 18 ]
python
en
['en', 'cy', 'en']
False
strict_schema
(schema: Dict)
If a new document is to be created, it __must__ have the logiak fields filled even if their value is "" so we make a strict schema in which null is not in the union.
If a new document is to be created, it __must__ have the logiak fields filled even if their value is "" so we make a strict schema in which null is not in the union.
def strict_schema(schema: Dict): ''' If a new document is to be created, it __must__ have the logiak fields filled even if their value is "" so we make a strict schema in which null is not in the union. ''' schema['fields'] = [ field_remove_optional(f) if f['name'] in LOGIAK_INTERNAL...
[ "def", "strict_schema", "(", "schema", ":", "Dict", ")", ":", "schema", "[", "'fields'", "]", "=", "[", "field_remove_optional", "(", "f", ")", "if", "f", "[", "'name'", "]", "in", "LOGIAK_INTERNAL_FIELDS", "else", "f", "for", "f", "in", "schema", "[", ...
[ 203, 0 ]
[ 214, 17 ]
python
en
['en', 'error', 'th']
False
main
()
Serialization composite code generator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generates main source code files for composite deserializers. The files are generated, as they are extremely repetitive (composite deserializer for 0..9 sub-deserializers). Usage: launcher.py LOCATION_OF_OUTPUT_FILE where:...
Serialization composite code generator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generates main source code files for composite deserializers. The files are generated, as they are extremely repetitive (composite deserializer for 0..9 sub-deserializers).
def main(): """ Serialization composite code generator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generates main source code files for composite deserializers. The files are generated, as they are extremely repetitive (composite deserializer for 0..9 sub-deserializers). Usage: launcher.py LOCATION_OF_O...
[ "def", "main", "(", ")", ":", "serialization_composite_h_file", "=", "os", ".", "path", ".", "abspath", "(", "sys", ".", "argv", "[", "1", "]", ")", "generator", ".", "generate_main_code", "(", "serialization_composite_h_file", ")" ]
[ 9, 0 ]
[ 28, 64 ]
python
en
['en', 'error', 'th']
False
TestTubeLogger.experiment
(self)
r""" Actual TestTube object. To use TestTube features in your :class:`~pytorch_lightning.core.lightning.LightningModule` do the following. Example:: self.logger.experiment.some_test_tube_function()
r"""
def experiment(self) -> Experiment: r""" Actual TestTube object. To use TestTube features in your :class:`~pytorch_lightning.core.lightning.LightningModule` do the following. Example:: self.logger.experiment.some_test_tube_function() """ if self._experimen...
[ "def", "experiment", "(", "self", ")", "->", "Experiment", ":", "if", "self", ".", "_experiment", "is", "not", "None", ":", "return", "self", ".", "_experiment", "self", ".", "_experiment", "=", "Experiment", "(", "save_dir", "=", "self", ".", "save_dir", ...
[ 110, 4 ]
[ 133, 31 ]
python
cy
['en', 'cy', 'hi']
False
TrainLoop.get_optimizers_iterable
(self)
Generates an iterable with (idx, optimizer) for each optimizer.
Generates an iterable with (idx, optimizer) for each optimizer.
def get_optimizers_iterable(self): """ Generates an iterable with (idx, optimizer) for each optimizer. """ if not self.trainer.optimizer_frequencies: # call training_step once per optimizer return list(enumerate(self.trainer.optimizers)) optimizer_freq_cu...
[ "def", "get_optimizers_iterable", "(", "self", ")", ":", "if", "not", "self", ".", "trainer", ".", "optimizer_frequencies", ":", "# call training_step once per optimizer", "return", "list", "(", "enumerate", "(", "self", ".", "trainer", ".", "optimizers", ")", ")"...
[ 243, 4 ]
[ 257, 60 ]
python
en
['en', 'error', 'th']
False
TrainLoop.block_ddp_sync_behaviour
(self, should_block_sync: bool = False)
automatic_optimization = True Blocks ddp sync gradients behaviour on backwards pass. This is useful for skipping sync when accumulating gradients, reducing communication overhead automatic_optimization = False do not block ddp gradient sync when using manual optimization ...
automatic_optimization = True Blocks ddp sync gradients behaviour on backwards pass. This is useful for skipping sync when accumulating gradients, reducing communication overhead
def block_ddp_sync_behaviour(self, should_block_sync: bool = False): """ automatic_optimization = True Blocks ddp sync gradients behaviour on backwards pass. This is useful for skipping sync when accumulating gradients, reducing communication overhead automatic_optimization = Fa...
[ "def", "block_ddp_sync_behaviour", "(", "self", ",", "should_block_sync", ":", "bool", "=", "False", ")", ":", "if", "(", "isinstance", "(", "self", ".", "trainer", ".", "training_type_plugin", ",", "ParallelPlugin", ")", "and", "(", "self", ".", "automatic_op...
[ 683, 4 ]
[ 704, 22 ]
python
en
['en', 'error', 'th']
False
TrainLoop.training_step_and_backward
(self, split_batch, batch_idx, opt_idx, optimizer, hiddens)
wrap the forward step in a closure so second order methods work
wrap the forward step in a closure so second order methods work
def training_step_and_backward(self, split_batch, batch_idx, opt_idx, optimizer, hiddens): """ wrap the forward step in a closure so second order methods work """ with self.trainer.profiler.profile("training_step_and_backward"): # lightning module hook result = se...
[ "def", "training_step_and_backward", "(", "self", ",", "split_batch", ",", "batch_idx", ",", "opt_idx", ",", "optimizer", ",", "hiddens", ")", ":", "with", "self", ".", "trainer", ".", "profiler", ".", "profile", "(", "\"training_step_and_backward\"", ")", ":", ...
[ 733, 4 ]
[ 764, 21 ]
python
en
['en', 'error', 'th']
False
TrainLoop.process_train_step_outputs
(self, all_train_step_outputs, early_stopping_accumulator, checkpoint_accumulator)
Figure out what needs to be tracked/logged at the end of the epoch
Figure out what needs to be tracked/logged at the end of the epoch
def process_train_step_outputs(self, all_train_step_outputs, early_stopping_accumulator, checkpoint_accumulator): """ Figure out what needs to be tracked/logged at the end of the epoch """ # the training step outputs a list per optimizer. The list contains the outputs at each time step ...
[ "def", "process_train_step_outputs", "(", "self", ",", "all_train_step_outputs", ",", "early_stopping_accumulator", ",", "checkpoint_accumulator", ")", ":", "# the training step outputs a list per optimizer. The list contains the outputs at each time step", "# when no TBPTT is used, then t...
[ 858, 4 ]
[ 883, 32 ]
python
en
['en', 'error', 'th']
False
PyGNews.__init__
(self, baseURL=constants.baseURL, country="US", language="en")
Set default parameters for PyGNews objects. Args: baseURL (str, optional): Google News Feed URL. Defaults to constants.baseURL. country (str, optional): Base country for the Feed URL. Defaults to "US". la...
Set default parameters for PyGNews objects. Args: baseURL (str, optional): Google News Feed URL. Defaults to constants.baseURL. country (str, optional): Base country for the Feed URL. Defaults to "US". la...
def __init__(self, baseURL=constants.baseURL, country="US", language="en"): """Set default parameters for PyGNews objects. Args: baseURL (str, optional): Google News Feed URL. Defaults to constants.baseURL. country (str, optional): Base country...
[ "def", "__init__", "(", "self", ",", "baseURL", "=", "constants", ".", "baseURL", ",", "country", "=", "\"US\"", ",", "language", "=", "\"en\"", ")", ":", "self", ".", "baseURL", "=", "baseURL", "self", ".", "country", "=", "country", "self", ".", "lan...
[ 5, 4 ]
[ 17, 32 ]
python
en
['fr', 'en', 'en']
True
PyGNews.top_stories
(self)
Return a dictionaries of top news on Google. Returns: dict: Google news top stories.
Return a dictionaries of top news on Google.
def top_stories(self): """Return a dictionaries of top news on Google. Returns: dict: Google news top stories. """ feeder = helpers.feed_parser( self.baseURL + helpers.set_ceid(country=self.country, language=self.language) ) entries_d...
[ "def", "top_stories", "(", "self", ")", ":", "feeder", "=", "helpers", ".", "feed_parser", "(", "self", ".", "baseURL", "+", "helpers", ".", "set_ceid", "(", "country", "=", "self", ".", "country", ",", "language", "=", "self", ".", "language", ")", ")...
[ 19, 4 ]
[ 31, 27 ]
python
en
['en', 'en', 'en']
True
PyGNews.topic_headlines
(self, topic: str = "WORLD")
Return a list of all articles from the topic page of Google News given a country and a language Args: topic (str, optional): topic of interest. Defaults to "WORLD". Available Topics include WORLD, ...
Return a list of all articles from the topic page of Google News given a country and a language
def topic_headlines(self, topic: str = "WORLD"): """ Return a list of all articles from the topic page of Google News given a country and a language Args: topic (str, optional): topic of interest. Defaults to "WORLD". Available Topics include ...
[ "def", "topic_headlines", "(", "self", ",", "topic", ":", "str", "=", "\"WORLD\"", ")", ":", "if", "topic", ".", "upper", "(", ")", "in", "constants", ".", "TOPICS", ":", "passed_feed", "=", "helpers", ".", "feed_parser", "(", "self", ".", "baseURL", "...
[ 33, 4 ]
[ 76, 13 ]
python
en
['en', 'en', 'en']
True
PyGNews.location_headlines
(self, location: str = "US")
Gives a list of all articles about a specific geolocation given a country and a language Args: location (str, optional): Abbreviation of the Country name to search. Defaults to "US". Returns: dict: News headlines from country
Gives a list of all articles about a specific geolocation given a country and a language
def location_headlines(self, location: str = "US"): """Gives a list of all articles about a specific geolocation given a country and a language Args: location (str, optional): Abbreviation of the Country name to search. Defaults to "US". Returns: dict: News ...
[ "def", "location_headlines", "(", "self", ",", "location", ":", "str", "=", "\"US\"", ")", ":", "loacation_parsed", "=", "helpers", ".", "feed_parser", "(", "self", ".", "baseURL", "+", "\"/headlines/section/geo/{}\"", ".", "format", "(", "location", ")", "+",...
[ 78, 4 ]
[ 95, 28 ]
python
en
['en', 'en', 'en']
True
PyGNews.search
( self, search_query: str = None, since_when=None, after_date=None, before_date=None, )
Gives all articles based on search querry and specified date. Args: search_query (str, optional): Search Querry. Defaults to None. since_when ([type], optional): Time since when news was published. 2m Corresponds to 2 minutes, ...
Gives all articles based on search querry and specified date.
def search( self, search_query: str = None, since_when=None, after_date=None, before_date=None, ): """Gives all articles based on search querry and specified date. Args: search_query (str, optional): Search Querry. Defaults to None. si...
[ "def", "search", "(", "self", ",", "search_query", ":", "str", "=", "None", ",", "since_when", "=", "None", ",", "after_date", "=", "None", ",", "before_date", "=", "None", ",", ")", ":", "if", "search_query", "is", "None", ":", "raise", "TypeError", "...
[ 97, 4 ]
[ 150, 28 ]
python
en
['en', 'en', 'en']
True
auc
(x: torch.Tensor, y: torch.Tensor, reorder: bool = False)
Computes Area Under the Curve (AUC) using the trapezoidal rule Args: x: x-coordinates y: y-coordinates reorder: if True, will reorder the arrays Return: Tensor containing AUC score (float) Example: >>> from pytorch_lightning.metrics.functional import auc ...
Computes Area Under the Curve (AUC) using the trapezoidal rule
def auc(x: torch.Tensor, y: torch.Tensor, reorder: bool = False) -> torch.Tensor: """ Computes Area Under the Curve (AUC) using the trapezoidal rule Args: x: x-coordinates y: y-coordinates reorder: if True, will reorder the arrays Return: Tensor containing AUC score (fl...
[ "def", "auc", "(", "x", ":", "torch", ".", "Tensor", ",", "y", ":", "torch", ".", "Tensor", ",", "reorder", ":", "bool", "=", "False", ")", "->", "torch", ".", "Tensor", ":", "x", ",", "y", "=", "_auc_update", "(", "x", ",", "y", ")", "return",...
[ 53, 0 ]
[ 73, 46 ]
python
en
['en', 'error', 'th']
False
render_search_response
(gen_json:bool=False)
Return either a JSON- or HTML-formatted search response.
Return either a JSON- or HTML-formatted search response.
def render_search_response(gen_json:bool=False) -> str: """Return either a JSON- or HTML-formatted search response.""" phrase = request.form['phrase'] letters = request.form['letters'] results = str(search4letters(phrase, letters)) if gen_json: return jsonify(the_phrase=phrase, ...
[ "def", "render_search_response", "(", "gen_json", ":", "bool", "=", "False", ")", "->", "str", ":", "phrase", "=", "request", ".", "form", "[", "'phrase'", "]", "letters", "=", "request", ".", "form", "[", "'letters'", "]", "results", "=", "str", "(", ...
[ 6, 0 ]
[ 19, 47 ]
python
en
['en', 'en', 'en']
True
entry_page
()
Returns the entry page to browser.
Returns the entry page to browser.
def entry_page() -> 'html': """Returns the entry page to browser.""" return render_template('entry.html', the_title='Welcome to search4letters on the web!', the_url='/search4')
[ "def", "entry_page", "(", ")", "->", "'html'", ":", "return", "render_template", "(", "'entry.html'", ",", "the_title", "=", "'Welcome to search4letters on the web!'", ",", "the_url", "=", "'/search4'", ")" ]
[ 22, 0 ]
[ 26, 46 ]
python
en
['en', 'en', 'en']
True
search4
()
Returns the results of a call to 'search4letters' to the browser.
Returns the results of a call to 'search4letters' to the browser.
def search4() -> 'html': """Returns the results of a call to 'search4letters' to the browser.""" return render_search_response()
[ "def", "search4", "(", ")", "->", "'html'", ":", "return", "render_search_response", "(", ")" ]
[ 29, 0 ]
[ 31, 35 ]
python
en
['en', 'en', 'en']
True
entry_json_page
()
Returns the JSON entry page to browser.
Returns the JSON entry page to browser.
def entry_json_page() -> 'html': """Returns the JSON entry page to browser.""" return render_template('entry.html', the_title='Welcome to search4letters JSON page', the_url='/searchjson')
[ "def", "entry_json_page", "(", ")", "->", "'html'", ":", "return", "render_template", "(", "'entry.html'", ",", "the_title", "=", "'Welcome to search4letters JSON page'", ",", "the_url", "=", "'/searchjson'", ")" ]
[ 34, 0 ]
[ 38, 49 ]
python
en
['en', 'en', 'en']
True
search4json
()
Returns the results of a call to 'search4letters' to the browser.
Returns the results of a call to 'search4letters' to the browser.
def search4json() -> 'json': """Returns the results of a call to 'search4letters' to the browser.""" return render_search_response(True)
[ "def", "search4json", "(", ")", "->", "'json'", ":", "return", "render_search_response", "(", "True", ")" ]
[ 41, 0 ]
[ 43, 39 ]
python
en
['en', 'en', 'en']
True
normalize_whitespace
(s)
Remove leading and trailing whitespace, and convert internal stretches of whitespace to a single space.
Remove leading and trailing whitespace, and convert internal stretches of whitespace to a single space.
def normalize_whitespace(s): """ Remove leading and trailing whitespace, and convert internal stretches of whitespace to a single space. """ return ' '.join(s.split())
[ "def", "normalize_whitespace", "(", "s", ")", ":", "return", "' '", ".", "join", "(", "s", ".", "split", "(", ")", ")" ]
[ 30, 0 ]
[ 35, 30 ]
python
en
['en', 'error', 'th']
False
test_from_template
()
Regression test for gh-10712.
Regression test for gh-10712.
def test_from_template(): """Regression test for gh-10712.""" pyf = process_str(pyf_src) normalized_pyf = normalize_whitespace(pyf) normalized_expected_pyf = normalize_whitespace(expected_pyf) assert_equal(normalized_pyf, normalized_expected_pyf)
[ "def", "test_from_template", "(", ")", ":", "pyf", "=", "process_str", "(", "pyf_src", ")", "normalized_pyf", "=", "normalize_whitespace", "(", "pyf", ")", "normalized_expected_pyf", "=", "normalize_whitespace", "(", "expected_pyf", ")", "assert_equal", "(", "normal...
[ 38, 0 ]
[ 43, 57 ]
python
en
['en', 'en', 'en']
True
magic
(major, minor)
Return the magic string for the given file format version. Parameters ---------- major : int in [0, 255] minor : int in [0, 255] Returns ------- magic : str Raises ------ ValueError if the version cannot be formatted.
Return the magic string for the given file format version.
def magic(major, minor): """ Return the magic string for the given file format version. Parameters ---------- major : int in [0, 255] minor : int in [0, 255] Returns ------- magic : str Raises ------ ValueError if the version cannot be formatted. """ if major < 0 o...
[ "def", "magic", "(", "major", ",", "minor", ")", ":", "if", "major", "<", "0", "or", "major", ">", "255", ":", "raise", "ValueError", "(", "\"major version must be 0 <= major < 256\"", ")", "if", "minor", "<", "0", "or", "minor", ">", "255", ":", "raise"...
[ 194, 0 ]
[ 217, 51 ]
python
en
['en', 'en', 'en']
True
read_magic
(fp)
Read the magic string to get the version of the file format. Parameters ---------- fp : filelike object Returns ------- major : int minor : int
Read the magic string to get the version of the file format.
def read_magic(fp): """ Read the magic string to get the version of the file format. Parameters ---------- fp : filelike object Returns ------- major : int minor : int """ magic_str = _read_bytes(fp, MAGIC_LEN, "magic string") if magic_str[:-2] != MAGIC_PREFIX: msg ...
[ "def", "read_magic", "(", "fp", ")", ":", "magic_str", "=", "_read_bytes", "(", "fp", ",", "MAGIC_LEN", ",", "\"magic string\"", ")", "if", "magic_str", "[", ":", "-", "2", "]", "!=", "MAGIC_PREFIX", ":", "msg", "=", "\"the magic string is not correct; expecte...
[ 219, 0 ]
[ 239, 23 ]
python
en
['en', 'en', 'en']
True
dtype_to_descr
(dtype)
Get a serializable descriptor from the dtype. The .descr attribute of a dtype object cannot be round-tripped through the dtype() constructor. Simple types, like dtype('float32'), have a descr which looks like a record array with one field with '' as a name. The dtype() constructor interprets this ...
Get a serializable descriptor from the dtype.
def dtype_to_descr(dtype): """ Get a serializable descriptor from the dtype. The .descr attribute of a dtype object cannot be round-tripped through the dtype() constructor. Simple types, like dtype('float32'), have a descr which looks like a record array with one field with '' as a name. The dt...
[ "def", "dtype_to_descr", "(", "dtype", ")", ":", "if", "dtype", ".", "names", "is", "not", "None", ":", "# This is a record array. The .descr is fine. XXX: parts of the", "# record array with an empty name, like padding bytes, still get", "# fiddled with. This needs to be fixed in t...
[ 241, 0 ]
[ 271, 24 ]
python
en
['en', 'error', 'th']
False
descr_to_dtype
(descr)
descr may be stored as dtype.descr, which is a list of (name, format, [shape]) tuples where format may be a str or a tuple. Offsets are not explicitly saved, rather empty fields with name, format == '', '|Vn' are added as padding. This function reverses the process, eliminating the empty padding f...
descr may be stored as dtype.descr, which is a list of (name, format, [shape]) tuples where format may be a str or a tuple. Offsets are not explicitly saved, rather empty fields with name, format == '', '|Vn' are added as padding.
def descr_to_dtype(descr): ''' descr may be stored as dtype.descr, which is a list of (name, format, [shape]) tuples where format may be a str or a tuple. Offsets are not explicitly saved, rather empty fields with name, format == '', '|Vn' are added as padding. This function reverses the proces...
[ "def", "descr_to_dtype", "(", "descr", ")", ":", "if", "isinstance", "(", "descr", ",", "str", ")", ":", "# No padding removal needed", "return", "numpy", ".", "dtype", "(", "descr", ")", "elif", "isinstance", "(", "descr", ",", "tuple", ")", ":", "# subty...
[ 273, 0 ]
[ 312, 64 ]
python
en
['en', 'error', 'th']
False
header_data_from_array_1_0
(array)
Get the dictionary of header metadata from a numpy.ndarray. Parameters ---------- array : numpy.ndarray Returns ------- d : dict This has the appropriate entries for writing its string representation to the header of the file.
Get the dictionary of header metadata from a numpy.ndarray.
def header_data_from_array_1_0(array): """ Get the dictionary of header metadata from a numpy.ndarray. Parameters ---------- array : numpy.ndarray Returns ------- d : dict This has the appropriate entries for writing its string representation to the header of the file. ...
[ "def", "header_data_from_array_1_0", "(", "array", ")", ":", "d", "=", "{", "'shape'", ":", "array", ".", "shape", "}", "if", "array", ".", "flags", ".", "c_contiguous", ":", "d", "[", "'fortran_order'", "]", "=", "False", "elif", "array", ".", "flags", ...
[ 314, 0 ]
[ 339, 12 ]
python
en
['en', 'en', 'en']
True
_wrap_header
(header, version)
Takes a stringified header, and attaches the prefix and padding to it
Takes a stringified header, and attaches the prefix and padding to it
def _wrap_header(header, version): """ Takes a stringified header, and attaches the prefix and padding to it """ import struct assert version is not None fmt, encoding = _header_size_info[version] if not isinstance(header, bytes): # always true on python 3 header = header.encode(enc...
[ "def", "_wrap_header", "(", "header", ",", "version", ")", ":", "import", "struct", "assert", "version", "is", "not", "None", "fmt", ",", "encoding", "=", "_header_size_info", "[", "version", "]", "if", "not", "isinstance", "(", "header", ",", "bytes", ")"...
[ 342, 0 ]
[ 364, 55 ]
python
en
['en', 'error', 'th']
False
_wrap_header_guess_version
(header)
Like `_wrap_header`, but chooses an appropriate version given the contents
Like `_wrap_header`, but chooses an appropriate version given the contents
def _wrap_header_guess_version(header): """ Like `_wrap_header`, but chooses an appropriate version given the contents """ try: return _wrap_header(header, (1, 0)) except ValueError: pass try: ret = _wrap_header(header, (2, 0)) except UnicodeEncodeError: pass...
[ "def", "_wrap_header_guess_version", "(", "header", ")", ":", "try", ":", "return", "_wrap_header", "(", "header", ",", "(", "1", ",", "0", ")", ")", "except", "ValueError", ":", "pass", "try", ":", "ret", "=", "_wrap_header", "(", "header", ",", "(", ...
[ 367, 0 ]
[ 388, 17 ]
python
en
['en', 'error', 'th']
False
_write_array_header
(fp, d, version=None)
Write the header for an array and returns the version used Parameters ---------- fp : filelike object d : dict This has the appropriate entries for writing its string representation to the header of the file. version: tuple or None None means use oldest that works e...
Write the header for an array and returns the version used
def _write_array_header(fp, d, version=None): """ Write the header for an array and returns the version used Parameters ---------- fp : filelike object d : dict This has the appropriate entries for writing its string representation to the header of the file. version: tuple or No...
[ "def", "_write_array_header", "(", "fp", ",", "d", ",", "version", "=", "None", ")", ":", "header", "=", "[", "\"{\"", "]", "for", "key", ",", "value", "in", "sorted", "(", "d", ".", "items", "(", ")", ")", ":", "# Need to use repr here, since we eval th...
[ 391, 0 ]
[ 416, 20 ]
python
en
['en', 'en', 'en']
True
write_array_header_1_0
(fp, d)
Write the header for an array using the 1.0 format. Parameters ---------- fp : filelike object d : dict This has the appropriate entries for writing its string representation to the header of the file.
Write the header for an array using the 1.0 format.
def write_array_header_1_0(fp, d): """ Write the header for an array using the 1.0 format. Parameters ---------- fp : filelike object d : dict This has the appropriate entries for writing its string representation to the header of the file. """ _write_array_header(fp, d, (1,...
[ "def", "write_array_header_1_0", "(", "fp", ",", "d", ")", ":", "_write_array_header", "(", "fp", ",", "d", ",", "(", "1", ",", "0", ")", ")" ]
[ 418, 0 ]
[ 428, 38 ]
python
en
['en', 'en', 'en']
True
write_array_header_2_0
(fp, d)
Write the header for an array using the 2.0 format. The 2.0 format allows storing very large structured arrays. .. versionadded:: 1.9.0 Parameters ---------- fp : filelike object d : dict This has the appropriate entries for writing its string representation to the header ...
Write the header for an array using the 2.0 format. The 2.0 format allows storing very large structured arrays.
def write_array_header_2_0(fp, d): """ Write the header for an array using the 2.0 format. The 2.0 format allows storing very large structured arrays. .. versionadded:: 1.9.0 Parameters ---------- fp : filelike object d : dict This has the appropriate entries for writing its st...
[ "def", "write_array_header_2_0", "(", "fp", ",", "d", ")", ":", "_write_array_header", "(", "fp", ",", "d", ",", "(", "2", ",", "0", ")", ")" ]
[ 431, 0 ]
[ 444, 38 ]
python
en
['en', 'en', 'en']
True
read_array_header_1_0
(fp)
Read an array header from a filelike object using the 1.0 file format version. This will leave the file object located just after the header. Parameters ---------- fp : filelike object A file object or something with a `.read()` method like a file. Returns ------- shape :...
Read an array header from a filelike object using the 1.0 file format version.
def read_array_header_1_0(fp): """ Read an array header from a filelike object using the 1.0 file format version. This will leave the file object located just after the header. Parameters ---------- fp : filelike object A file object or something with a `.read()` method like a file...
[ "def", "read_array_header_1_0", "(", "fp", ")", ":", "return", "_read_array_header", "(", "fp", ",", "version", "=", "(", "1", ",", "0", ")", ")" ]
[ 446, 0 ]
[ 475, 49 ]
python
en
['en', 'error', 'th']
False
read_array_header_2_0
(fp)
Read an array header from a filelike object using the 2.0 file format version. This will leave the file object located just after the header. .. versionadded:: 1.9.0 Parameters ---------- fp : filelike object A file object or something with a `.read()` method like a file. Re...
Read an array header from a filelike object using the 2.0 file format version.
def read_array_header_2_0(fp): """ Read an array header from a filelike object using the 2.0 file format version. This will leave the file object located just after the header. .. versionadded:: 1.9.0 Parameters ---------- fp : filelike object A file object or something with a...
[ "def", "read_array_header_2_0", "(", "fp", ")", ":", "return", "_read_array_header", "(", "fp", ",", "version", "=", "(", "2", ",", "0", ")", ")" ]
[ 477, 0 ]
[ 508, 49 ]
python
en
['en', 'error', 'th']
False
_filter_header
(s)
Clean up 'L' in npz header ints. Cleans up the 'L' in strings representing integers. Needed to allow npz headers produced in Python2 to be read in Python3. Parameters ---------- s : string Npy file header. Returns ------- header : str Cleaned up header.
Clean up 'L' in npz header ints.
def _filter_header(s): """Clean up 'L' in npz header ints. Cleans up the 'L' in strings representing integers. Needed to allow npz headers produced in Python2 to be read in Python3. Parameters ---------- s : string Npy file header. Returns ------- header : str Clea...
[ "def", "_filter_header", "(", "s", ")", ":", "import", "tokenize", "if", "sys", ".", "version_info", "[", "0", "]", ">=", "3", ":", "from", "io", "import", "StringIO", "else", ":", "from", "StringIO", "import", "StringIO", "tokens", "=", "[", "]", "las...
[ 511, 0 ]
[ 549, 43 ]
python
en
['en', 'en', 'en']
True
_read_array_header
(fp, version)
see read_array_header_1_0
see read_array_header_1_0
def _read_array_header(fp, version): """ see read_array_header_1_0 """ # Read an unsigned, little-endian short int which has the length of the # header. import struct hinfo = _header_size_info.get(version) if hinfo is None: raise ValueError("Invalid version {!r}".format(version))...
[ "def", "_read_array_header", "(", "fp", ",", "version", ")", ":", "# Read an unsigned, little-endian short int which has the length of the", "# header.", "import", "struct", "hinfo", "=", "_header_size_info", ".", "get", "(", "version", ")", "if", "hinfo", "is", "None",...
[ 552, 0 ]
[ 603, 48 ]
python
en
['en', 'error', 'th']
False
write_array
(fp, array, version=None, allow_pickle=False, pickle_kwargs=None)
Write an array to an NPY file, including a header. If the array is neither C-contiguous nor Fortran-contiguous AND the file_like object is not a real file object, this function will have to copy data in memory. Parameters ---------- fp : file_like object An open, writable file obj...
Write an array to an NPY file, including a header.
def write_array(fp, array, version=None, allow_pickle=False, pickle_kwargs=None): """ Write an array to an NPY file, including a header. If the array is neither C-contiguous nor Fortran-contiguous AND the file_like object is not a real file object, this function will have to copy data in memory. ...
[ "def", "write_array", "(", "fp", ",", "array", ",", "version", "=", "None", ",", "allow_pickle", "=", "False", ",", "pickle_kwargs", "=", "None", ")", ":", "_check_version", "(", "version", ")", "_write_array_header", "(", "fp", ",", "header_data_from_array_1_...
[ 605, 0 ]
[ 674, 44 ]
python
en
['en', 'error', 'th']
False
read_array
(fp, allow_pickle=False, pickle_kwargs=None)
Read an array from an NPY file. Parameters ---------- fp : file_like object If this is not a real file object, then this may take extra memory and time. allow_pickle : bool, optional Whether to allow writing pickled data. Default: False .. versionchanged:: 1.16.3 ...
Read an array from an NPY file.
def read_array(fp, allow_pickle=False, pickle_kwargs=None): """ Read an array from an NPY file. Parameters ---------- fp : file_like object If this is not a real file object, then this may take extra memory and time. allow_pickle : bool, optional Whether to allow writing...
[ "def", "read_array", "(", "fp", ",", "allow_pickle", "=", "False", ",", "pickle_kwargs", "=", "None", ")", ":", "version", "=", "read_magic", "(", "fp", ")", "_check_version", "(", "version", ")", "shape", ",", "fortran_order", ",", "dtype", "=", "_read_ar...
[ 677, 0 ]
[ 769, 16 ]
python
en
['en', 'error', 'th']
False
open_memmap
(filename, mode='r+', dtype=None, shape=None, fortran_order=False, version=None)
Open a .npy file as a memory-mapped array. This may be used to read an existing file or create a new one. Parameters ---------- filename : str or path-like The name of the file on disk. This may *not* be a file-like object. mode : str, optional The mode in which to op...
Open a .npy file as a memory-mapped array.
def open_memmap(filename, mode='r+', dtype=None, shape=None, fortran_order=False, version=None): """ Open a .npy file as a memory-mapped array. This may be used to read an existing file or create a new one. Parameters ---------- filename : str or path-like The name of t...
[ "def", "open_memmap", "(", "filename", ",", "mode", "=", "'r+'", ",", "dtype", "=", "None", ",", "shape", "=", "None", ",", "fortran_order", "=", "False", ",", "version", "=", "None", ")", ":", "if", "isfileobj", "(", "filename", ")", ":", "raise", "...
[ 772, 0 ]
[ 870, 17 ]
python
en
['en', 'error', 'th']
False
_read_bytes
(fp, size, error_template="ran out of data")
Read from file-like object until size bytes are read. Raises ValueError if not EOF is encountered before size bytes are read. Non-blocking objects only supported if they derive from io objects. Required as e.g. ZipExtFile in python 2.6 can return less data than requested.
Read from file-like object until size bytes are read. Raises ValueError if not EOF is encountered before size bytes are read. Non-blocking objects only supported if they derive from io objects.
def _read_bytes(fp, size, error_template="ran out of data"): """ Read from file-like object until size bytes are read. Raises ValueError if not EOF is encountered before size bytes are read. Non-blocking objects only supported if they derive from io objects. Required as e.g. ZipExtFile in python 2....
[ "def", "_read_bytes", "(", "fp", ",", "size", ",", "error_template", "=", "\"ran out of data\"", ")", ":", "data", "=", "bytes", "(", ")", "while", "True", ":", "# io files (default in python3) return None or raise on", "# would-block, python2 file will truncate, probably n...
[ 873, 0 ]
[ 898, 19 ]
python
en
['en', 'error', 'th']
False
confusion_matrix
( preds: torch.Tensor, target: torch.Tensor, num_classes: int, normalize: Optional[str] = None, threshold: float = 0.5 )
Computes the confusion matrix. 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.thres...
Computes the confusion matrix. 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.
def confusion_matrix( preds: torch.Tensor, target: torch.Tensor, num_classes: int, normalize: Optional[str] = None, threshold: float = 0.5 ) -> torch.Tensor: """ Computes the confusion matrix. Works with binary, multiclass, and multilabel data. Accepts probabilities from a model output o...
[ "def", "confusion_matrix", "(", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ",", "num_classes", ":", "int", ",", "normalize", ":", "Optional", "[", "str", "]", "=", "None", ",", "threshold", ":", "float", "=", "0.5...
[ 54, 0 ]
[ 96, 56 ]
python
en
['en', 'error', 'th']
False
_DeprecationTestCase.assert_deprecated
(self, function, num=1, ignore_others=False, function_fails=False, exceptions=np._NoValue, args=(), kwargs={})
Test if DeprecationWarnings are given and raised. This first checks if the function when called gives `num` DeprecationWarnings, after that it tries to raise these DeprecationWarnings and compares them with `exceptions`. The exceptions can be different for cases where this code path ...
Test if DeprecationWarnings are given and raised.
def assert_deprecated(self, function, num=1, ignore_others=False, function_fails=False, exceptions=np._NoValue, args=(), kwargs={}): """Test if DeprecationWarnings are given and raised. This first checks if the function when ...
[ "def", "assert_deprecated", "(", "self", ",", "function", ",", "num", "=", "1", ",", "ignore_others", "=", "False", ",", "function_fails", "=", "False", ",", "exceptions", "=", "np", ".", "_NoValue", ",", "args", "=", "(", ")", ",", "kwargs", "=", "{",...
[ 48, 4 ]
[ 117, 64 ]
python
en
['en', 'en', 'en']
True
_DeprecationTestCase.assert_not_deprecated
(self, function, args=(), kwargs={})
Test that warnings are not raised. This is just a shorthand for: self.assert_deprecated(function, num=0, ignore_others=True, exceptions=tuple(), args=args, kwargs=kwargs)
Test that warnings are not raised.
def assert_not_deprecated(self, function, args=(), kwargs={}): """Test that warnings are not raised. This is just a shorthand for: self.assert_deprecated(function, num=0, ignore_others=True, exceptions=tuple(), args=args, kwargs=kwargs) """ self.assert_d...
[ "def", "assert_not_deprecated", "(", "self", ",", "function", ",", "args", "=", "(", ")", ",", "kwargs", "=", "{", "}", ")", ":", "self", ".", "assert_deprecated", "(", "function", ",", "num", "=", "0", ",", "ignore_others", "=", "True", ",", "exceptio...
[ 119, 4 ]
[ 128, 69 ]
python
en
['en', 'en', 'en']
True
ROC.update
(self, preds: torch.Tensor, target: torch.Tensor)
Update state with predictions and targets. Args: preds: Predictions from model target: Ground truth values
Update state with predictions and targets.
def update(self, preds: torch.Tensor, target: torch.Tensor): """ Update state with predictions and targets. Args: preds: Predictions from model target: Ground truth values """ preds, target, num_classes, pos_label = _roc_update(preds, target, self.num_cla...
[ "def", "update", "(", "self", ",", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ")", ":", "preds", ",", "target", ",", "num_classes", ",", "pos_label", "=", "_roc_update", "(", "preds", ",", "target", ",", "self", ...
[ 111, 4 ]
[ 123, 34 ]
python
en
['en', 'error', 'th']
False
ROC.compute
( self )
Compute the receiver operating characteristic Returns: 3-element tuple containing fpr: tensor with false positive rates. If multiclass, this is a list of such tensors, one for each class. tpr: tensor with true positiv...
Compute the receiver operating characteristic
def compute( self ) -> Union[Tuple[torch.Tensor, torch.Tensor, torch.Tensor], Tuple[List[torch.Tensor], List[torch.Tensor], List[torch.Tensor]]]: """ Compute the receiver operating characteristic Returns: ...
[ "def", "compute", "(", "self", ")", "->", "Union", "[", "Tuple", "[", "torch", ".", "Tensor", ",", "torch", ".", "Tensor", ",", "torch", ".", "Tensor", "]", ",", "Tuple", "[", "List", "[", "torch", ".", "Tensor", "]", ",", "List", "[", "torch", "...
[ 125, 4 ]
[ 146, 76 ]
python
en
['en', 'error', 'th']
False
PrecisionRecallCurve.update
(self, preds: torch.Tensor, target: torch.Tensor)
Update state with predictions and targets. Args: preds: Predictions from model target: Ground truth values
Update state with predictions and targets.
def update(self, preds: torch.Tensor, target: torch.Tensor): """ Update state with predictions and targets. Args: preds: Predictions from model target: Ground truth values """ preds, target, num_classes, pos_label = _precision_recall_curve_update( ...
[ "def", "update", "(", "self", ",", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ")", ":", "preds", ",", "target", ",", "num_classes", ",", "pos_label", "=", "_precision_recall_curve_update", "(", "preds", ",", "target",...
[ 112, 4 ]
[ 126, 34 ]
python
en
['en', 'error', 'th']
False
PrecisionRecallCurve.compute
( self )
Compute the precision-recall curve Returns: 3-element tuple containing precision: tensor where element i is the precision of predictions with score >= thresholds[i] and the last element is 1. If multiclass, this is a list of such...
Compute the precision-recall curve
def compute( self ) -> Union[Tuple[torch.Tensor, torch.Tensor, torch.Tensor], Tuple[List[torch.Tensor], List[torch.Tensor], List[torch.Tensor]]]: """ Compute the precision-recall curve Returns: 3-eleme...
[ "def", "compute", "(", "self", ")", "->", "Union", "[", "Tuple", "[", "torch", ".", "Tensor", ",", "torch", ".", "Tensor", ",", "torch", ".", "Tensor", "]", ",", "Tuple", "[", "List", "[", "torch", ".", "Tensor", "]", ",", "List", "[", "torch", "...
[ 128, 4 ]
[ 151, 95 ]
python
en
['en', 'error', 'th']
False
_tocomplex
(arr)
Convert its input `arr` to a complex array. The input is returned as a complex array of the smallest type that will fit the original data: types like single, byte, short, etc. become csingle, while others become cdouble. A copy of the input is always made. Parameters ---------- arr : arra...
Convert its input `arr` to a complex array.
def _tocomplex(arr): """Convert its input `arr` to a complex array. The input is returned as a complex array of the smallest type that will fit the original data: types like single, byte, short, etc. become csingle, while others become cdouble. A copy of the input is always made. Parameters ...
[ "def", "_tocomplex", "(", "arr", ")", ":", "if", "issubclass", "(", "arr", ".", "dtype", ".", "type", ",", "(", "nt", ".", "single", ",", "nt", ".", "byte", ",", "nt", ".", "short", ",", "nt", ".", "ubyte", ",", "nt", ".", "ushort", ",", "nt", ...
[ 35, 0 ]
[ 95, 37 ]
python
en
['en', 'lb', 'en']
True
_fix_real_lt_zero
(x)
Convert `x` to complex if it has real, negative components. Otherwise, output is just the array version of the input (via asarray). Parameters ---------- x : array_like Returns ------- array Examples -------- >>> np.lib.scimath._fix_real_lt_zero([1,2]) array([1, 2]) ...
Convert `x` to complex if it has real, negative components.
def _fix_real_lt_zero(x): """Convert `x` to complex if it has real, negative components. Otherwise, output is just the array version of the input (via asarray). Parameters ---------- x : array_like Returns ------- array Examples -------- >>> np.lib.scimath._fix_real_lt_ze...
[ "def", "_fix_real_lt_zero", "(", "x", ")", ":", "x", "=", "asarray", "(", "x", ")", "if", "any", "(", "isreal", "(", "x", ")", "&", "(", "x", "<", "0", ")", ")", ":", "x", "=", "_tocomplex", "(", "x", ")", "return", "x" ]
[ 98, 0 ]
[ 123, 12 ]
python
en
['en', 'en', 'en']
True
_fix_int_lt_zero
(x)
Convert `x` to double if it has real, negative components. Otherwise, output is just the array version of the input (via asarray). Parameters ---------- x : array_like Returns ------- array Examples -------- >>> np.lib.scimath._fix_int_lt_zero([1,2]) array([1, 2]) >>...
Convert `x` to double if it has real, negative components.
def _fix_int_lt_zero(x): """Convert `x` to double if it has real, negative components. Otherwise, output is just the array version of the input (via asarray). Parameters ---------- x : array_like Returns ------- array Examples -------- >>> np.lib.scimath._fix_int_lt_zero(...
[ "def", "_fix_int_lt_zero", "(", "x", ")", ":", "x", "=", "asarray", "(", "x", ")", "if", "any", "(", "isreal", "(", "x", ")", "&", "(", "x", "<", "0", ")", ")", ":", "x", "=", "x", "*", "1.0", "return", "x" ]
[ 126, 0 ]
[ 150, 12 ]
python
en
['en', 'en', 'en']
True
_fix_real_abs_gt_1
(x)
Convert `x` to complex if it has real components x_i with abs(x_i)>1. Otherwise, output is just the array version of the input (via asarray). Parameters ---------- x : array_like Returns ------- array Examples -------- >>> np.lib.scimath._fix_real_abs_gt_1([0,1]) array([0...
Convert `x` to complex if it has real components x_i with abs(x_i)>1.
def _fix_real_abs_gt_1(x): """Convert `x` to complex if it has real components x_i with abs(x_i)>1. Otherwise, output is just the array version of the input (via asarray). Parameters ---------- x : array_like Returns ------- array Examples -------- >>> np.lib.scimath._fix...
[ "def", "_fix_real_abs_gt_1", "(", "x", ")", ":", "x", "=", "asarray", "(", "x", ")", "if", "any", "(", "isreal", "(", "x", ")", "&", "(", "abs", "(", "x", ")", ">", "1", ")", ")", ":", "x", "=", "_tocomplex", "(", "x", ")", "return", "x" ]
[ 153, 0 ]
[ 177, 12 ]
python
en
['en', 'en', 'en']
True
sqrt
(x)
Compute the square root of x. For negative input elements, a complex value is returned (unlike `numpy.sqrt` which returns NaN). Parameters ---------- x : array_like The input value(s). Returns ------- out : ndarray or scalar The square root of `x`. If `x` was a scal...
Compute the square root of x.
def sqrt(x): """ Compute the square root of x. For negative input elements, a complex value is returned (unlike `numpy.sqrt` which returns NaN). Parameters ---------- x : array_like The input value(s). Returns ------- out : ndarray or scalar The square root of `x...
[ "def", "sqrt", "(", "x", ")", ":", "x", "=", "_fix_real_lt_zero", "(", "x", ")", "return", "nx", ".", "sqrt", "(", "x", ")" ]
[ 185, 0 ]
[ 225, 21 ]
python
en
['en', 'error', 'th']
False
log
(x)
Compute the natural logarithm of `x`. Return the "principal value" (for a description of this, see `numpy.log`) of :math:`log_e(x)`. For real `x > 0`, this is a real number (``log(0)`` returns ``-inf`` and ``log(np.inf)`` returns ``inf``). Otherwise, the complex principle value is returned. P...
Compute the natural logarithm of `x`.
def log(x): """ Compute the natural logarithm of `x`. Return the "principal value" (for a description of this, see `numpy.log`) of :math:`log_e(x)`. For real `x > 0`, this is a real number (``log(0)`` returns ``-inf`` and ``log(np.inf)`` returns ``inf``). Otherwise, the complex principle value ...
[ "def", "log", "(", "x", ")", ":", "x", "=", "_fix_real_lt_zero", "(", "x", ")", "return", "nx", ".", "log", "(", "x", ")" ]
[ 229, 0 ]
[ 273, 20 ]
python
en
['en', 'error', 'th']
False
log10
(x)
Compute the logarithm base 10 of `x`. Return the "principal value" (for a description of this, see `numpy.log10`) of :math:`log_{10}(x)`. For real `x > 0`, this is a real number (``log10(0)`` returns ``-inf`` and ``log10(np.inf)`` returns ``inf``). Otherwise, the complex principle value is returne...
Compute the logarithm base 10 of `x`.
def log10(x): """ Compute the logarithm base 10 of `x`. Return the "principal value" (for a description of this, see `numpy.log10`) of :math:`log_{10}(x)`. For real `x > 0`, this is a real number (``log10(0)`` returns ``-inf`` and ``log10(np.inf)`` returns ``inf``). Otherwise, the complex princ...
[ "def", "log10", "(", "x", ")", ":", "x", "=", "_fix_real_lt_zero", "(", "x", ")", "return", "nx", ".", "log10", "(", "x", ")" ]
[ 277, 0 ]
[ 323, 22 ]
python
en
['en', 'error', 'th']
False
logn
(n, x)
Take log base n of x. If `x` contains negative inputs, the answer is computed and returned in the complex domain. Parameters ---------- n : array_like The integer base(s) in which the log is taken. x : array_like The value(s) whose log base `n` is (are) required. Return...
Take log base n of x.
def logn(n, x): """ Take log base n of x. If `x` contains negative inputs, the answer is computed and returned in the complex domain. Parameters ---------- n : array_like The integer base(s) in which the log is taken. x : array_like The value(s) whose log base `n` is (are...
[ "def", "logn", "(", "n", ",", "x", ")", ":", "x", "=", "_fix_real_lt_zero", "(", "x", ")", "n", "=", "_fix_real_lt_zero", "(", "n", ")", "return", "nx", ".", "log", "(", "x", ")", "/", "nx", ".", "log", "(", "n", ")" ]
[ 331, 0 ]
[ 363, 30 ]
python
en
['en', 'error', 'th']
False
log2
(x)
Compute the logarithm base 2 of `x`. Return the "principal value" (for a description of this, see `numpy.log2`) of :math:`log_2(x)`. For real `x > 0`, this is a real number (``log2(0)`` returns ``-inf`` and ``log2(np.inf)`` returns ``inf``). Otherwise, the complex principle value is returned. ...
Compute the logarithm base 2 of `x`.
def log2(x): """ Compute the logarithm base 2 of `x`. Return the "principal value" (for a description of this, see `numpy.log2`) of :math:`log_2(x)`. For real `x > 0`, this is a real number (``log2(0)`` returns ``-inf`` and ``log2(np.inf)`` returns ``inf``). Otherwise, the complex principle val...
[ "def", "log2", "(", "x", ")", ":", "x", "=", "_fix_real_lt_zero", "(", "x", ")", "return", "nx", ".", "log2", "(", "x", ")" ]
[ 367, 0 ]
[ 411, 21 ]
python
en
['en', 'error', 'th']
False
power
(x, p)
Return x to the power p, (x**p). If `x` contains negative values, the output is converted to the complex domain. Parameters ---------- x : array_like The input value(s). p : array_like of ints The power(s) to which `x` is raised. If `x` contains multiple values, `p...
Return x to the power p, (x**p).
def power(x, p): """ Return x to the power p, (x**p). If `x` contains negative values, the output is converted to the complex domain. Parameters ---------- x : array_like The input value(s). p : array_like of ints The power(s) to which `x` is raised. If `x` contains mul...
[ "def", "power", "(", "x", ",", "p", ")", ":", "x", "=", "_fix_real_lt_zero", "(", "x", ")", "p", "=", "_fix_int_lt_zero", "(", "p", ")", "return", "nx", ".", "power", "(", "x", ",", "p", ")" ]
[ 419, 0 ]
[ 460, 25 ]
python
en
['en', 'error', 'th']
False
arccos
(x)
Compute the inverse cosine of x. Return the "principal value" (for a description of this, see `numpy.arccos`) of the inverse cosine of `x`. For real `x` such that `abs(x) <= 1`, this is a real number in the closed interval :math:`[0, \\pi]`. Otherwise, the complex principle value is returned. ...
Compute the inverse cosine of x.
def arccos(x): """ Compute the inverse cosine of x. Return the "principal value" (for a description of this, see `numpy.arccos`) of the inverse cosine of `x`. For real `x` such that `abs(x) <= 1`, this is a real number in the closed interval :math:`[0, \\pi]`. Otherwise, the complex principle ...
[ "def", "arccos", "(", "x", ")", ":", "x", "=", "_fix_real_abs_gt_1", "(", "x", ")", "return", "nx", ".", "arccos", "(", "x", ")" ]
[ 464, 0 ]
[ 505, 23 ]
python
en
['en', 'error', 'th']
False
arcsin
(x)
Compute the inverse sine of x. Return the "principal value" (for a description of this, see `numpy.arcsin`) of the inverse sine of `x`. For real `x` such that `abs(x) <= 1`, this is a real number in the closed interval :math:`[-\\pi/2, \\pi/2]`. Otherwise, the complex principle value is retur...
Compute the inverse sine of x.
def arcsin(x): """ Compute the inverse sine of x. Return the "principal value" (for a description of this, see `numpy.arcsin`) of the inverse sine of `x`. For real `x` such that `abs(x) <= 1`, this is a real number in the closed interval :math:`[-\\pi/2, \\pi/2]`. Otherwise, the complex princi...
[ "def", "arcsin", "(", "x", ")", ":", "x", "=", "_fix_real_abs_gt_1", "(", "x", ")", "return", "nx", ".", "arcsin", "(", "x", ")" ]
[ 509, 0 ]
[ 551, 23 ]
python
en
['en', 'error', 'th']
False
arctanh
(x)
Compute the inverse hyperbolic tangent of `x`. Return the "principal value" (for a description of this, see `numpy.arctanh`) of `arctanh(x)`. For real `x` such that `abs(x) < 1`, this is a real number. If `abs(x) > 1`, or if `x` is complex, the result is complex. Finally, `x = 1` returns``inf`` a...
Compute the inverse hyperbolic tangent of `x`.
def arctanh(x): """ Compute the inverse hyperbolic tangent of `x`. Return the "principal value" (for a description of this, see `numpy.arctanh`) of `arctanh(x)`. For real `x` such that `abs(x) < 1`, this is a real number. If `abs(x) > 1`, or if `x` is complex, the result is complex. Finally, `...
[ "def", "arctanh", "(", "x", ")", ":", "x", "=", "_fix_real_abs_gt_1", "(", "x", ")", "return", "nx", ".", "arctanh", "(", "x", ")" ]
[ 555, 0 ]
[ 602, 24 ]
python
en
['en', 'error', 'th']
False
MNIST._try_load
(path_data, trials: int = 30, delta: float = 1.)
Resolving loading from the same time from multiple concurrent processes.
Resolving loading from the same time from multiple concurrent processes.
def _try_load(path_data, trials: int = 30, delta: float = 1.): """Resolving loading from the same time from multiple concurrent processes.""" res, exception = None, None assert trials, "at least some trial has to be set" assert os.path.isfile(path_data), f'missing file: {path_data}' ...
[ "def", "_try_load", "(", "path_data", ",", "trials", ":", "int", "=", "30", ",", "delta", ":", "float", "=", "1.", ")", ":", "res", ",", "exception", "=", "None", ",", "None", "assert", "trials", ",", "\"at least some trial has to be set\"", "assert", "os"...
[ 118, 4 ]
[ 135, 18 ]
python
en
['en', 'en', 'en']
True
search4
()
Returns the results of a call to 'search4letters' to the browser.
Returns the results of a call to 'search4letters' to the browser.
def search4() -> str: """Returns the results of a call to 'search4letters' to the browser.""" return str(search4letters('life, the universe, and everything', 'xyz'))
[ "def", "search4", "(", ")", "->", "str", ":", "return", "str", "(", "search4letters", "(", "'life, the universe, and everything'", ",", "'xyz'", ")", ")" ]
[ 7, 0 ]
[ 9, 75 ]
python
en
['en', 'en', 'en']
True
get_confirmation
()
Obtain stdin confirmation to add users in GH.
Obtain stdin confirmation to add users in GH.
def get_confirmation(): """Obtain stdin confirmation to add users in GH.""" return input('Add users to envoyproxy/assignable ? [yN] ').strip().lower() in ('y', 'yes')
[ "def", "get_confirmation", "(", ")", ":", "return", "input", "(", "'Add users to envoyproxy/assignable ? [yN] '", ")", ".", "strip", "(", ")", ".", "lower", "(", ")", "in", "(", "'y'", ",", "'yes'", ")" ]
[ 19, 0 ]
[ 21, 94 ]
python
en
['en', 'en', 'en']
True
SingleDevicePlugin.reduce
(self, tensor: Union[Any, torch.Tensor], *args: Any, **kwargs: Any)
Reduces a tensor from several distributed processes to one aggregated tensor. As this plugin only operates with a single device, the reduction is simply the identity. Args: tensor: the tensor to sync and reduce *args: ignored **kwargs: ignored Retur...
Reduces a tensor from several distributed processes to one aggregated tensor. As this plugin only operates with a single device, the reduction is simply the identity.
def reduce(self, tensor: Union[Any, torch.Tensor], *args: Any, **kwargs: Any) -> Union[Any, torch.Tensor]: """ Reduces a tensor from several distributed processes to one aggregated tensor. As this plugin only operates with a single device, the reduction is simply the identity. Args: ...
[ "def", "reduce", "(", "self", ",", "tensor", ":", "Union", "[", "Any", ",", "torch", ".", "Tensor", "]", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "Union", "[", "Any", ",", "torch", ".", "Tensor", "]", ":", ...
[ 21, 4 ]
[ 34, 21 ]
python
en
['en', 'error', 'th']
False