query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Tests 1 gpu with synthetic data.
def benchmark_fp16_synth_1gpu_gpuparams(self): params = self._shared_params_fp16()._replace(num_gpus=1) self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nvidia_driver2():\r\n a = numpy.random.rand(10000).astype(\"float32\")\r\n cuda.shared_constructor(a)\r\n assert theano.sandbox.cuda.use.device_number is not None", "def benchmark_fake_1gpu_gpuparams(self):\n params = self._shared_params()._replace(\n num_gpus=1, data_dir=self.fake_da...
[ "0.68693227", "0.68644226", "0.6670029", "0.6670029", "0.6670029", "0.6513355", "0.6409363", "0.6339023", "0.6307369", "0.6302433", "0.62930727", "0.628481", "0.6263361", "0.6261016", "0.6261016", "0.6261016", "0.62364423", "0.6221056", "0.61878484", "0.61514795", "0.6134151"...
0.5854345
54
Tests 1 gpu with synthetic data at batch 128 (useful for small GPUs).
def benchmark_fp16_batch128_synth_1gpu_gpuparams(self): params = self._shared_params_fp16()._replace(num_gpus=1, batch_size=128) self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def benchmark_fake_1gpu_gpuparams(self):\n params = self._shared_params()._replace(\n num_gpus=1, data_dir=self.fake_data_dir, data_name='imagenet')\n self._run_benchmark(params)", "def renset50_128_gpu_1_real(self):\n test_id = 'resnet50.gpu_1.128.real'\n args = {}\n config = self.build_re...
[ "0.6996932", "0.68239915", "0.6788029", "0.6788029", "0.6788029", "0.66804606", "0.66679364", "0.66217", "0.66191864", "0.65522", "0.65306324", "0.6525069", "0.6513519", "0.65103894", "0.6473042", "0.64716434", "0.6469671", "0.64597243", "0.64363796", "0.6432946", "0.6420975"...
0.6542441
10
Tests 8 gpu with synthetic data with parameters replicated.
def benchmark_fp16_synth_8gpu_gpureplicated(self): params = self._shared_params_fp16()._replace( num_gpus=8, num_batches=200, variable_update='replicated', all_reduce_spec='nccl', gradient_repacking=2) self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def benchmark_fake_8gpu_gpureplicated(self):\n params = self._shared_params()._replace(\n num_gpus=8,\n data_dir=self.fake_data_dir,\n data_name='imagenet',\n variable_update='replicated',\n all_reduce_spec='nccl',\n gradient_repacking=2)\n self._run_benchmark(params...
[ "0.7032033", "0.69963396", "0.6776914", "0.6776914", "0.6776914", "0.66615206", "0.66254723", "0.66057956", "0.6542688", "0.65189254", "0.6514595", "0.64651054", "0.6460251", "0.6460251", "0.6460251", "0.6424654", "0.6421601", "0.6421601", "0.6421601", "0.64193594", "0.640392...
0.6229135
31
Tests 1 gpu with synthetic data.
def benchmark_fp16_xla_compile_synth_1gpu_gpuparams(self): params = self._shared_params_fp16()._replace(num_gpus=1, xla_compile=True) self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nvidia_driver2():\r\n a = numpy.random.rand(10000).astype(\"float32\")\r\n cuda.shared_constructor(a)\r\n assert theano.sandbox.cuda.use.device_number is not None", "def benchmark_fake_1gpu_gpuparams(self):\n params = self._shared_params()._replace(\n num_gpus=1, data_dir=self.fake_da...
[ "0.68693227", "0.68644226", "0.6670029", "0.6670029", "0.6670029", "0.6513355", "0.6409363", "0.6339023", "0.6307369", "0.6302433", "0.62930727", "0.628481", "0.6263361", "0.6261016", "0.6261016", "0.6261016", "0.62364423", "0.6221056", "0.61878484", "0.61514795", "0.6134151"...
0.5574212
92
Tests 1 gpu with synthetic data at batch 128 (useful for small GPUs).
def benchmark_fp16_xla_compile_batch128_synth_1gpu_gpuparams(self): params = self._shared_params_fp16()._replace( num_gpus=1, num_batches=200, batch_size=128, xla_compile=True) self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def benchmark_fake_1gpu_gpuparams(self):\n params = self._shared_params()._replace(\n num_gpus=1, data_dir=self.fake_data_dir, data_name='imagenet')\n self._run_benchmark(params)", "def renset50_128_gpu_1_real(self):\n test_id = 'resnet50.gpu_1.128.real'\n args = {}\n config = self.build_re...
[ "0.69958156", "0.682366", "0.6787007", "0.6787007", "0.6787007", "0.6681163", "0.6667279", "0.6620514", "0.661992", "0.65511274", "0.65423864", "0.6529478", "0.6524801", "0.65131027", "0.6510148", "0.64724696", "0.6470911", "0.64678276", "0.64585525", "0.64392275", "0.6432143...
0.63505596
23
Tests 8 gpu with synthetic data with parameters replicated.
def benchmark_fp16_xla_compile_synth_8gpu_gpureplicated(self): params = self._shared_params_fp16()._replace( num_gpus=8, num_batches=200, variable_update='replicated', all_reduce_spec='nccl', gradient_repacking=2, xla_compile=True) self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def benchmark_fake_8gpu_gpureplicated(self):\n params = self._shared_params()._replace(\n num_gpus=8,\n data_dir=self.fake_data_dir,\n data_name='imagenet',\n variable_update='replicated',\n all_reduce_spec='nccl',\n gradient_repacking=2)\n self._run_benchmark(params...
[ "0.7032033", "0.69963396", "0.6776914", "0.6776914", "0.6776914", "0.66615206", "0.66254723", "0.66057956", "0.6542688", "0.65189254", "0.6514595", "0.64651054", "0.6460251", "0.6460251", "0.6460251", "0.6424654", "0.6421601", "0.6421601", "0.6421601", "0.64193594", "0.640392...
0.60494316
49
Tests 8 gpu with synthetic data with parameters replicated.
def benchmark_fp16_xla_synth_8gpu_gpureplicated(self): params = self._shared_params_fp16()._replace( num_gpus=8, num_batches=200, variable_update='replicated', all_reduce_spec='nccl', gradient_repacking=2, xla=True) self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def benchmark_fake_8gpu_gpureplicated(self):\n params = self._shared_params()._replace(\n num_gpus=8,\n data_dir=self.fake_data_dir,\n data_name='imagenet',\n variable_update='replicated',\n all_reduce_spec='nccl',\n gradient_repacking=2)\n self._run_benchmark(params...
[ "0.7032033", "0.69963396", "0.6776914", "0.6776914", "0.6776914", "0.66615206", "0.66254723", "0.66057956", "0.6542688", "0.65189254", "0.6514595", "0.64651054", "0.6460251", "0.6460251", "0.6460251", "0.6424654", "0.6421601", "0.6421601", "0.6421601", "0.64193594", "0.640392...
0.61390185
40
Tests 1 gpu with synthetic data with parameters on gpu.
def benchmark_synth_1gpu_gpuparams(self): params = self._shared_params()._replace( num_gpus=1, variable_update='parameter_server') self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nvidia_driver2():\r\n a = numpy.random.rand(10000).astype(\"float32\")\r\n cuda.shared_constructor(a)\r\n assert theano.sandbox.cuda.use.device_number is not None", "def benchmark_xla_fake_1gpu_gpuparams(self):\n params = self._shared_params()._replace(\n num_gpus=1,\n data_dir...
[ "0.6849444", "0.6842127", "0.6842127", "0.6842127", "0.6806564", "0.65948963", "0.64988655", "0.6470903", "0.6463176", "0.6449034", "0.6449034", "0.6449034", "0.6434609", "0.6434609", "0.6434609", "0.6394382", "0.63401216", "0.63058764", "0.62591136", "0.622038", "0.6212372",...
0.6623691
5
Tests 1 gpu with synthetic data with parameters on gpu.
def benchmark_fp16_synth_1gpu_gpuparams(self): params = self._shared_params()._replace( num_gpus=1, use_fp16=True, variable_update='parameter_server') self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nvidia_driver2():\r\n a = numpy.random.rand(10000).astype(\"float32\")\r\n cuda.shared_constructor(a)\r\n assert theano.sandbox.cuda.use.device_number is not None", "def benchmark_xla_fake_1gpu_gpuparams(self):\n params = self._shared_params()._replace(\n num_gpus=1,\n data_dir...
[ "0.6849444", "0.6842127", "0.6842127", "0.6842127", "0.6806564", "0.6623691", "0.6623691", "0.6623691", "0.65948963", "0.64988655", "0.6470903", "0.6463176", "0.6449034", "0.6449034", "0.6449034", "0.6434609", "0.6434609", "0.6434609", "0.6394382", "0.63401216", "0.63058764",...
0.589859
45
Tests 8 gpu with synthetic data with parameters replicated.
def benchmark_synth_8gpu_gpureplicated(self): params = self._shared_params()._replace( num_gpus=8, all_reduce_spec='nccl', variable_update='replicated', compact_gradient_transfer=False, gradient_repacking=2) self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def benchmark_fake_8gpu_gpureplicated(self):\n params = self._shared_params()._replace(\n num_gpus=8,\n data_dir=self.fake_data_dir,\n data_name='imagenet',\n variable_update='replicated',\n all_reduce_spec='nccl',\n gradient_repacking=2)\n self._run_benchmark(params...
[ "0.70339614", "0.6998338", "0.67798436", "0.67798436", "0.67798436", "0.66640925", "0.66270465", "0.6607402", "0.6544504", "0.65209305", "0.6516939", "0.64671475", "0.646316", "0.646316", "0.646316", "0.6424724", "0.6424724", "0.6424724", "0.64220685", "0.640691", "0.6365974"...
0.6426629
15
Tests 1 gpu with synthetic data with parameters on gpu.
def benchmark_synth_1gpu_gpuparams(self): params = self._shared_params()._replace( num_gpus=1, variable_update='parameter_server') self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nvidia_driver2():\r\n a = numpy.random.rand(10000).astype(\"float32\")\r\n cuda.shared_constructor(a)\r\n assert theano.sandbox.cuda.use.device_number is not None", "def benchmark_xla_fake_1gpu_gpuparams(self):\n params = self._shared_params()._replace(\n num_gpus=1,\n data_dir...
[ "0.6849444", "0.6842127", "0.6842127", "0.6842127", "0.6806564", "0.65948963", "0.64988655", "0.6470903", "0.6463176", "0.6449034", "0.6449034", "0.6449034", "0.6434609", "0.6434609", "0.6434609", "0.6394382", "0.63401216", "0.63058764", "0.62591136", "0.622038", "0.6212372",...
0.6623691
6
Tests 1 gpu with synthetic data with parameters on gpu.
def benchmark_fp16_synth_1gpu_gpuparams(self): params = self._shared_params()._replace( num_gpus=1, use_fp16=True, variable_update='parameter_server') self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nvidia_driver2():\r\n a = numpy.random.rand(10000).astype(\"float32\")\r\n cuda.shared_constructor(a)\r\n assert theano.sandbox.cuda.use.device_number is not None", "def benchmark_xla_fake_1gpu_gpuparams(self):\n params = self._shared_params()._replace(\n num_gpus=1,\n data_dir...
[ "0.685032", "0.6841664", "0.6841664", "0.6841664", "0.68068004", "0.662228", "0.662228", "0.662228", "0.65943164", "0.64983135", "0.6472363", "0.64628416", "0.6447796", "0.6447796", "0.6447796", "0.6433172", "0.6433172", "0.6433172", "0.63929737", "0.6340391", "0.6306232", ...
0.5897658
47
Tests 1 gpu with synthetic data.
def benchmark_synth_1gpu_gpuparams(self): params = self._shared_params()._replace( num_gpus=1, variable_update='parameter_server') self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nvidia_driver2():\r\n a = numpy.random.rand(10000).astype(\"float32\")\r\n cuda.shared_constructor(a)\r\n assert theano.sandbox.cuda.use.device_number is not None", "def benchmark_fake_1gpu_gpuparams(self):\n params = self._shared_params()._replace(\n num_gpus=1, data_dir=self.fake_da...
[ "0.68690443", "0.6864538", "0.6670059", "0.6670059", "0.6670059", "0.65134996", "0.6409901", "0.6339313", "0.63075054", "0.63025165", "0.62934625", "0.62848353", "0.6262437", "0.6236009", "0.6221688", "0.61870956", "0.61505145", "0.6133958", "0.61243606", "0.61219215", "0.611...
0.62617034
15
Tests 1 gpu with synthetic data.
def benchmark_fp16_synth_1gpu_gpuparams(self): params = self._shared_params()._replace( num_gpus=1, use_fp16=True, variable_update='parameter_server') self._run_benchmark(params)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nvidia_driver2():\r\n a = numpy.random.rand(10000).astype(\"float32\")\r\n cuda.shared_constructor(a)\r\n assert theano.sandbox.cuda.use.device_number is not None", "def benchmark_fake_1gpu_gpuparams(self):\n params = self._shared_params()._replace(\n num_gpus=1, data_dir=self.fake_da...
[ "0.68693227", "0.68644226", "0.6670029", "0.6670029", "0.6670029", "0.6513355", "0.6409363", "0.6339023", "0.6307369", "0.6302433", "0.62930727", "0.628481", "0.6263361", "0.6261016", "0.6261016", "0.6261016", "0.62364423", "0.6221056", "0.61878484", "0.61514795", "0.6134151"...
0.55732614
94
Initialize to evaluate the given model.
def __init__(self, model, tb_logger): super(Evaluator, self).__init__(self.predict_on_batch) self.model = model # FROC avg_fps = list(range(1, 26)) avg_fps.append(0.5) avg_fps.sort() tags = ['froc_{}fp'.format(fp) for fp in avg_fps] for avg_fp, tag in zip(avg_fps, tags): FROC([avg_fp], iou_threshold=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(self, model):\n pass", "def initialize_model(self):\n pass", "def __init__(self, model: Model1D):\n self._model = model", "def init_model(self):\n pass", "def __init__(self, model):\n self._model = model", "def __init__(self, model: torch.nn.Module) -> No...
[ "0.7481986", "0.7126397", "0.7034386", "0.69110596", "0.6908171", "0.6785774", "0.66568065", "0.6598777", "0.6598777", "0.6598777", "0.6598777", "0.6596549", "0.65477544", "0.65339285", "0.65232486", "0.650452", "0.65018505", "0.64969116", "0.64827305", "0.6479092", "0.647909...
0.68419325
5
Checks whether or not the given value is a list. If not, the value is wrapped in a list.
def as_array(value): if not isinstance(value, list): return [value] return value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_list(value):\n return isinstance(value, list)", "def is_list(value):\n return isinstance(value, list) or None", "def _is_list(val):\n\n return isinstance(val, list)", "def _is_list(item):\n return isinstance(item, list)", "def _as_list(value):\n if not isinstance(value, list):\n ...
[ "0.8680331", "0.85705376", "0.8563555", "0.8045087", "0.79318523", "0.78993213", "0.76863736", "0.763193", "0.75801706", "0.74683887", "0.74660915", "0.74118376", "0.7399207", "0.73930025", "0.7383555", "0.7273248", "0.7260357", "0.7258882", "0.7208937", "0.71853125", "0.7170...
0.65135103
43
The Reinforce class that inherits from tf.keras.Model The forward pass calculates the policy for the agent given a batch of states.
def __init__(self, state_size, num_actions): super(DQN, self).__init__() self.num_actions = num_actions self.batch_size = 128 self.epsilon = 0.7 self.min_epsilon = 0.05 self.epsilon_update = 0.995 # TODO: Define network parameters and optimizer ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_policy(self, minibatch_size):\n \n steps = self.rewards.shape[0]\n batch_size = self.rewards.shape[0] * self.rewards.shape[1]\n #steps = 500\n #batch_size = 500\n #print(steps)\n #print(batch_size)\n \n # Compute advantages\n '''\n ...
[ "0.6436904", "0.6032315", "0.6026611", "0.601873", "0.6017846", "0.59955966", "0.5985061", "0.5950357", "0.59094274", "0.5882624", "0.58564055", "0.584904", "0.58314776", "0.5816677", "0.58139634", "0.5808012", "0.58070445", "0.5794069", "0.5793512", "0.57890964", "0.5788168"...
0.0
-1
The ba.SessionTeam the last associated player was last on. This can still return a valid result even if the player is gone. Raises a ba.SessionTeamNotFoundError if the team no longer exists.
def team(self) -> ba.SessionTeam: assert self._sessionteam is not None team = self._sessionteam() if team is None: raise SessionTeamNotFoundError() return team
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_current_team(self):\n import src.application.Domain.Team as Team\n try:\n return Cache.get_element(self.id, \"PLAYER_CURRENT_TEAM\")\n except KeyError:\n pass\n\n matches = self.get_matches()\n current_team = None\n if len(matches) > 0:\n ...
[ "0.7216847", "0.6900742", "0.66578245", "0.66330844", "0.6547067", "0.6479717", "0.62449354", "0.6152123", "0.61037", "0.60159665", "0.5972868", "0.5849638", "0.5701771", "0.5699857", "0.5652835", "0.56428695", "0.5613378", "0.55964994", "0.556874", "0.5529789", "0.547218", ...
0.733711
0
Return the instance's associated ba.SessionPlayer. Raises a ba.SessionPlayerNotFoundError if the player no longer exists.
def player(self) -> ba.SessionPlayer: if not self._sessionplayer: raise SessionPlayerNotFoundError() return self._sessionplayer
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_player(self):\n\n return self._player", "def get_player(self):\n return self._pubg.player(self.player_id, self.shard)", "def getPlayer(self):\n return self.__player__", "def get_player(self):\n return self.player", "def get_player(self):\n return self.player", "...
[ "0.743738", "0.7402506", "0.7295465", "0.72595996", "0.72595996", "0.72433406", "0.7239704", "0.71080315", "0.7065276", "0.6844511", "0.67718583", "0.67491597", "0.6728232", "0.66990435", "0.6686677", "0.66236794", "0.65860915", "0.65817225", "0.64872545", "0.64735943", "0.64...
0.8709909
0
Get the icon for this instance's player.
def get_icon(self) -> Dict[str, Any]: player = self._last_sessionplayer assert player is not None return player.get_icon()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_icon(self):\n return self._icon", "def get_icon(self):\n return self.ICON", "def get_icon(self):\n\n return self._icon", "def icon(self):\n return self._icon", "def icon(self):\n return self._icon", "def icon(self):\n return self._icon", "def icon(self)...
[ "0.8224745", "0.8167761", "0.8157798", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", "0.80451965", ...
0.8600978
0
Reset the stats instance completely.
def reset(self) -> None: # Just to be safe, lets make sure no multi-kill timers are gonna go off # for no-longer-on-the-list players. for p_entry in list(self._player_records.values()): p_entry.cancel_multi_kill_timer() self._player_records = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stats_reset(self):\n self.stats.reset()", "def stats_reset(self):\n self.stats.reset()", "def reset(self):\n self.stats = {}", "def reset(self):\n self.sum_metric = 0.\n self.num_inst = 0.\n self.metrics.reset_stats()", "def reset(self) -> None:\n self.s...
[ "0.90652543", "0.90652543", "0.8812741", "0.8390857", "0.82766926", "0.8268264", "0.82210475", "0.8172284", "0.8087154", "0.8006801", "0.774938", "0.77395576", "0.76727045", "0.76727045", "0.76727045", "0.7646259", "0.7597306", "0.75918174", "0.7559243", "0.7539407", "0.75279...
0.0
-1
Checks if the current user is a billing agent.
def billing_agent_required(func): def wrapper(request, *args, **kwargs): if not base_check(request): return redirect('{0}?next={1}'.format(reverse('core_login'), request.path)) agent_for = models.BillingAgent.objects.filter(users__id__exact=request.user.pk) if not agent_for a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_billing_admin(self):\n return self._is_billing_admin", "def user_allow_credit(self):\n try:\n return self.user.creditAllowed()\n except AttributeError:\n return False", "def check_active(self, user):\r\n if not self.require_active:\r\n # Ignor...
[ "0.6315221", "0.59411496", "0.58754206", "0.57932866", "0.575876", "0.5636669", "0.55624324", "0.55372965", "0.55352527", "0.5513492", "0.5512186", "0.54553396", "0.5443187", "0.5416635", "0.5399732", "0.53816503", "0.5380428", "0.5378703", "0.53652763", "0.5343467", "0.53334...
0.5497796
11
Checks that a user is a billing agent for the given agent_id
def agent_for_billing_agent_required(func): def wrapper(request, *args, **kwargs): if not base_check(request): return redirect('{0}?next={1}'.format(reverse('core_login'), request.path)) billing_agent_id = kwargs.get('billing_agent_id', None) if billing_agent_id: b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def billing_agent_required(func):\n\n def wrapper(request, *args, **kwargs):\n\n if not base_check(request):\n return redirect('{0}?next={1}'.format(reverse('core_login'), request.path))\n\n agent_for = models.BillingAgent.objects.filter(users__id__exact=request.user.pk)\n\n if n...
[ "0.5783203", "0.545144", "0.52983826", "0.5147958", "0.51051456", "0.5056659", "0.5030645", "0.49473125", "0.48939788", "0.48748228", "0.48704013", "0.47893205", "0.47676402", "0.4743416", "0.47248974", "0.47086093", "0.46884227", "0.46674922", "0.4622117", "0.4620822", "0.46...
0.62423426
0
Is the user with given nickname author of the argument?
def is_author_of_argument(db_user: User, argument_uid: int) -> bool: db_user = db_user if db_user and db_user.nickname != nick_of_anonymous_user else None if not db_user: return False db_argument = DBDiscussionSession.query(Argument).filter(Argument.uid == argument_uid, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_user(id):\n return id.startswith('U')", "def user_present(ctx: Context, channel: TextChannel) -> bool:\n for member in channel.members:\n if member.id == ctx.author.id:\n return True\n\n return False", "def test_func(self):\n answer = self.get_object()\n return True if self.re...
[ "0.7161157", "0.69651043", "0.6880884", "0.6862806", "0.68380934", "0.6775048", "0.66643804", "0.66483647", "0.6629766", "0.6629766", "0.6629766", "0.6601748", "0.65652424", "0.6536646", "0.6536646", "0.6517549", "0.6496187", "0.64579695", "0.64579695", "0.6435304", "0.641495...
0.64973456
16
Are the given bubbles already at the end of the bubble list
def bubbles_already_last_in_list(bubble_list, bubbles): if isinstance(bubbles, list): length = len(bubbles) else: length = 1 bubbles = [bubbles] if len(bubble_list) < length: return False for bubble in bubbles: if 'message' not in bubble: return Fals...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_bubble(self):\n if (len(self.all_bubbles) <= Settings.nof_bubbles and \n pygame.time.get_ticks() > self.last_bubble_time + self.time_units * Settings.time_units_per_bubble_spawn):\n def new_bubble():\n new_b = Bubble(self)\n for b in self.all_bubbles:\...
[ "0.6666143", "0.6292394", "0.61022216", "0.6087888", "0.5968704", "0.5967805", "0.59380186", "0.5840422", "0.5825611", "0.57922196", "0.5783696", "0.5762628", "0.5748692", "0.57429105", "0.57076824", "0.570765", "0.5697314", "0.56844884", "0.56792027", "0.56762797", "0.566570...
0.79846394
0
Collects TF data according to specifications. The specifications are passed as arguments when the object is initialized.
def __init__( self, app, backend, moduleRefs, locations, modules, version, checkout, silent ): self.backend = backend self.app = app self.moduleRefs = ( [] if moduleRefs is None else moduleRefs.split(",") if type(moduleRefs) is str ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, freqs, num_parallel_calls=10):\n self.num_parallel_calls = tf.convert_to_tensor(num_parallel_calls, tf.int32)\n self.freqs = tf.convert_to_tensor(freqs, dtype=float_type)\n self.freq_feed = tf.data.Dataset.from_tensors(self.freqs).repeat()#tf.data.Dataset.from_generator(self...
[ "0.6329395", "0.61413383", "0.5935537", "0.593139", "0.5930828", "0.58727735", "0.58289486", "0.5819099", "0.5712762", "0.5707471", "0.56970984", "0.5695019", "0.5681213", "0.56389177", "0.5620952", "0.56125474", "0.5605494", "0.5578582", "0.5568792", "0.5553603", "0.55221295...
0.0
-1
Return the projection of v onto u (proj_u(v) = ((v.u)/(u.u))u
def proj(u, v, epsilon=1e-8): if np.all(np.abs(u)<epsilon): # u ~= 0 return np.zeros(u.shape) return (float(np.dot(v,u))/np.dot(u,u))*u
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _proj(u,v):\n return (np.einsum('i...,i...->...',u,v)/np.einsum('i...,i...->...',u,u))*u", "def project_vector(u, v):\n u_np = np.array([u.get_x(), u.get_y()])\n v_np = np.array([v.get_x(), v.get_y()])\n proj = (np.dot(u_np, v_np) / np.dot(v_np, v_np)) * v_np\n return Point(proj[0], pr...
[ "0.8536385", "0.82629746", "0.75377023", "0.71556705", "0.7155253", "0.70530933", "0.69710904", "0.668328", "0.6652345", "0.6639387", "0.66209424", "0.6589637", "0.6421282", "0.6409937", "0.63477236", "0.6339082", "0.6254058", "0.6247361", "0.6216448", "0.62073195", "0.620251...
0.8297423
1
This returns a (i, j, 3) RGB ndarray
def readImageFileRGB(imageFileLocation): sourceImage = io.imread(imageFileLocation) return sourceImage
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _colored_img_to_arr(image, verbose=False):\n height, width = image.size\n arr = np.array(image.getdata())\n arr = arr.reshape(3, height, width)\n r = arr[0]\n g = arr[1]\n b = arr[2]\n return r, g, b", "def get_pixel_list(img):\n orig_shape = img.shape # Remember the original shape o...
[ "0.7603724", "0.6980612", "0.692613", "0.6873278", "0.6691795", "0.667897", "0.6615184", "0.6590044", "0.6500631", "0.64706457", "0.6462606", "0.6444133", "0.6422103", "0.642086", "0.6414279", "0.64121324", "0.64014524", "0.6370433", "0.6341648", "0.63132757", "0.6310592", ...
0.0
-1
Convert a scipy sparse matrix to a torch sparse tensor.
def sparse_mx_to_torch_sparse_tensor(sparse_mx): sparse_mx = sparse_mx.tocoo().astype(np.float32) indices = torch.from_numpy( np.vstack((sparse_mx.row, sparse_mx.col)).astype(np.int64)) values = torch.from_numpy(sparse_mx.data) shape = torch.Size(sparse_mx.shape) return torch.sparse.FloatTen...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def csr2tensor(self, matrix: sp.csr_matrix):\n matrix = matrix.tocoo()\n x = torch.sparse.FloatTensor(\n torch.LongTensor(np.array([matrix.row, matrix.col])),\n torch.FloatTensor(matrix.data.astype(np.float32)),\n matrix.shape,\n ).to(self.device)\n retu...
[ "0.8299787", "0.8148542", "0.8045949", "0.80325705", "0.80134654", "0.79973555", "0.79973555", "0.7985302", "0.7985302", "0.7985302", "0.7977018", "0.79650825", "0.7754673", "0.7713117", "0.7429514", "0.7429514", "0.735423", "0.71969247", "0.7156927", "0.69882196", "0.6969645...
0.80300856
12
Symmetrically normalize adjacency matrix.
def normalize_adj_adj(adj): adj = sp.coo_matrix(adj) rowsum = np.array(adj.sum(1)) d_inv_sqrt = np.power(rowsum, -0.5).flatten() d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0. d_mat_inv_sqrt = sp.diags(d_inv_sqrt) return adj.dot(d_mat_inv_sqrt).transpose().dot(d_mat_inv_sqrt).tocoo()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_adj(adj):\n\n rowsum = np.array(adj.sum(1))\n d_inv_sqrt = np.power(rowsum, -0.5).flatten()\n d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0.\n d_mat_inv_sqrt = np.diag(d_inv_sqrt)\n return adj.dot(d_mat_inv_sqrt).transpose().dot(d_mat_inv_sqrt)", "def normalize_adj(adj):\n adj = sp.coo_mat...
[ "0.788518", "0.7698141", "0.7698141", "0.7698141", "0.7698141", "0.7698141", "0.7698141", "0.7698141", "0.7698141", "0.7698141", "0.7691616", "0.7566608", "0.7335597", "0.730491", "0.72684425", "0.688461", "0.68616927", "0.686005", "0.6832041", "0.682895", "0.6750887", "0.6...
0.759434
11
Fills all the empty cells of a grid
def fillEmptyCells(self, item, gameGrid=None, emptyValue=0): if not gameGrid: gameGrid = self.gameGrid for r, c in gameGrid: currentCell = gameGrid.getItem(r, c) if currentCell == emptyValue: self.addObject(item, r, c, gameGrid=gameGrid)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear(self):\n self._cells = [[EMPTY for dummy_col in range(self._grid_width)]\n for dummy_row in range(self._grid_height)]", "def fill_grid(self):\n\n for row_margin, row in enumerate(range(self.rows)):\n self.grid.append([])\n\n for col_margin, col ...
[ "0.76632416", "0.7621818", "0.75952387", "0.74975634", "0.74916685", "0.7481925", "0.7413288", "0.7362961", "0.7247829", "0.72437507", "0.7216486", "0.7172293", "0.7167135", "0.71184343", "0.7106008", "0.70642877", "0.7000256", "0.6992466", "0.69651955", "0.68956023", "0.6878...
0.70906675
15
Creates a tiled background from one pygame surface
def setBackground(self, background, dest=None, empty=0): if not dest: dest = self.screen self.base = pygame.display.set_mode(dest.get_size()) backgroundGrid = g.Grid(self.rows, self.columns) self.fillEmptyCells(background, gameGrid=backgroundGrid) # blit ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_bg_surf(self) -> Surface:\n if self.props.bg is None:\n surf = engine.create_surface(self.tsize, True)\n surf.fill(self.props.bg_color)\n return surf\n else:\n if not self.cached_background or not self.cached_background.get_size() == self.tsize:...
[ "0.73389775", "0.7260543", "0.724829", "0.71087015", "0.69204116", "0.6842658", "0.6791536", "0.6790116", "0.6757758", "0.6747914", "0.67291915", "0.6680279", "0.66726863", "0.66700983", "0.6636175", "0.66221046", "0.6578734", "0.65783006", "0.65776974", "0.64833075", "0.6454...
0.7063202
4
Displays all surfaces on the screen. It also optionally displays a tiled background surface. Assumes that all nonzero cells of self.gameGrid contain a pygame Surface
def updateDisplay(self, gameGrid=None, dest=None, background=None, empty=0, text=None, text_location=(0,0), font=None, fontColour=(0,0,0), fontA...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def renderall(self):\n\n if not self.isinitialized:\n return\n # clear display\n self.screen.fill(BGCOLOR)\n # draw the board\n self.drawBoard()\n # flip the display to show whatever we drew\n pygame.display.flip()", "def render(self):\n self._su...
[ "0.704325", "0.69334257", "0.6922403", "0.69140124", "0.68000084", "0.67427665", "0.67152977", "0.66950035", "0.6687002", "0.6600376", "0.65010166", "0.6496584", "0.6420134", "0.64136314", "0.64111423", "0.6394302", "0.63930076", "0.6385775", "0.6383417", "0.6376125", "0.6354...
0.63114095
24
Create a EagleSprite object
def __init__(self, world_map, GRID_LOCK, coordinates=None): ''' Take parameters, and Sprite Constants ''' super(EagleSprite, self).__init__(world_map, EagleSprite.IMAGE, GRID_LOCK, EagleSprite.HEALTH_BAR, EagleSprite.AVG_SPEED, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, sprite):\n self.sprite = sprite", "def setUp(self):\r\n pos =[0,0]\r\n vel = [0,0]\r\n ang = 0.0\r\n ang_vel= [0,0]\r\n image = None\r\n\r\n center = [1,1]\r\n size = 1\r\n info = ImageInfo(center, size)\r\n\r\n self.sprite ...
[ "0.7201538", "0.69384205", "0.69384205", "0.6848861", "0.673118", "0.6723862", "0.670584", "0.66811734", "0.66732067", "0.6670018", "0.6630302", "0.6598109", "0.6572538", "0.6569692", "0.65427154", "0.65427154", "0.6542392", "0.6539204", "0.65254194", "0.648932", "0.64865303"...
0.6978917
1
Set of actions that can be performed in this state. By default, a fixed list of actions, except for terminal states. Override this method if you need to specialize by state.
def actions(self, state): actions = [] raise_forces = [("RAISE_FORCE", state.force*2.0)] reduce_forces = [] #[("REDUCE_FORCE", state.force/2.0)] controlled = [t for t in self.territories if getattr(state, t) == "CONTROLLED"] owned = set([t for t in self.territories if getattr(sta...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def actions(self, state):\n\t\traise NotImplementedError", "def actions(self, state):\n raise NotImplementedError # Override this!", "def actions(self, agent_state):\n raise NotImplementedError(\"Don't know what actions are available\")", "def get_actions(self, state: TState = None) -> Sequenc...
[ "0.72804165", "0.72786003", "0.72770673", "0.72407955", "0.72076285", "0.71805793", "0.7165399", "0.7132563", "0.7130398", "0.70961136", "0.70793957", "0.70667523", "0.69910103", "0.6979679", "0.6953815", "0.69265264", "0.6924061", "0.6881996", "0.6874342", "0.68145865", "0.6...
0.641919
52
r""" Validates the image type irrespective of its case. For eg. both .PNG and .png are valid image types. Also, accepts numpy array images.
def load_image(image_path): # Case insenstive check of the image type. img_lower = image_path.lower() if ( img_lower.endswith( ".jpg", -4, ) or img_lower.endswith( ".png", -4, ) or img_lower.endswith( ".jpeg"...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_image_type(filename: str) -> bool:\n supported_extensions = (\"png\", \"jpg\", \"jpeg\")\n return (filename not in (None, \"\")) and (get_extension(filename) in supported_extensions)", "def check_type(filename):\n try:\n im = Image.read(filename)\n except SanperaError:\n re...
[ "0.7495959", "0.6977729", "0.65080136", "0.6450042", "0.6444895", "0.6352692", "0.6250493", "0.6225645", "0.621305", "0.61896366", "0.6167511", "0.61380357", "0.6133625", "0.6103464", "0.60284865", "0.5992564", "0.5965599", "0.59549177", "0.5945663", "0.5941345", "0.5910385",...
0.0
-1
Initialize the Mailgun component and get the webhook_id.
async def webhook_id_with_api_key(hass): await async_setup_component( hass, mailgun.DOMAIN, {mailgun.DOMAIN: {CONF_API_KEY: API_KEY, CONF_DOMAIN: "example.com"}}, ) await async_process_ha_core_config( hass, {"internal_url": "http://example.local:8123"}, ) res...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def webhook_id_without_api_key(hass):\n await async_setup_component(hass, mailgun.DOMAIN, {})\n\n await async_process_ha_core_config(\n hass,\n {\"internal_url\": \"http://example.local:8123\"},\n )\n result = await hass.config_entries.flow.async_init(\n \"mailgun\", context=...
[ "0.65602106", "0.6304719", "0.61283344", "0.60008144", "0.5909418", "0.58013016", "0.57644165", "0.57214236", "0.5634054", "0.54889697", "0.54335654", "0.54301345", "0.5383406", "0.5362592", "0.5313893", "0.53108734", "0.5299105", "0.52925026", "0.52800435", "0.5250265", "0.5...
0.65639246
0
Initialize the Mailgun component and get the webhook_id w/o API key.
async def webhook_id_without_api_key(hass): await async_setup_component(hass, mailgun.DOMAIN, {}) await async_process_ha_core_config( hass, {"internal_url": "http://example.local:8123"}, ) result = await hass.config_entries.flow.async_init( "mailgun", context={"source": config_e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def webhook_id_with_api_key(hass):\n await async_setup_component(\n hass,\n mailgun.DOMAIN,\n {mailgun.DOMAIN: {CONF_API_KEY: API_KEY, CONF_DOMAIN: \"example.com\"}},\n )\n\n await async_process_ha_core_config(\n hass,\n {\"internal_url\": \"http://example.local:81...
[ "0.72934836", "0.62986255", "0.6287862", "0.6020876", "0.5996549", "0.5883158", "0.58081007", "0.57637113", "0.57467294", "0.5716825", "0.57111394", "0.5688419", "0.5652002", "0.5650072", "0.5637579", "0.5605841", "0.559543", "0.55846953", "0.5568327", "0.5548385", "0.5533693...
0.7272961
1
Test that webhook doesn't trigger an event without a signature.
async def test_mailgun_webhook_with_missing_signature( http_client, webhook_id_with_api_key, mailgun_events ) -> None: event_count = len(mailgun_events) await http_client.post( f"/api/webhook/{webhook_id_with_api_key}", json={"hello": "mailgun", "signature": {}}, ) assert len(mailg...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def test_mailgun_webhook_with_missing_signature_without_api_key(\n http_client, webhook_id_without_api_key, mailgun_events\n) -> None:\n event_count = len(mailgun_events)\n\n await http_client.post(\n f\"/api/webhook/{webhook_id_without_api_key}\",\n json={\"hello\": \"mailgun\", \"sig...
[ "0.7513723", "0.7487684", "0.71957815", "0.7036714", "0.7015703", "0.6817947", "0.6772169", "0.6762407", "0.6703106", "0.6405593", "0.63978493", "0.6350789", "0.6334918", "0.6296101", "0.6232124", "0.62216955", "0.6201577", "0.61999995", "0.61535585", "0.6121563", "0.6107652"...
0.7376048
2
Test that webhook doesn't trigger an event with a wrong signature.
async def test_mailgun_webhook_with_different_api_key( http_client, webhook_id_with_api_key, mailgun_events ) -> None: timestamp = "1529006854" token = "a8ce0edb2dd8301dee6c2405235584e45aa91d1e9f979f3de0" event_count = len(mailgun_events) await http_client.post( f"/api/webhook/{webhook_id_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_bad_signature(fail_on_mismatch, settings, rf):\n app_key = '123appkey'\n setattr(settings, APP_KEY_SETTING, app_key)\n setattr(settings, FAIL_ON_MISMATCH_SETTING, fail_on_mismatch)\n view = OurVeryOwnReceiverView.as_view()\n request = rf.post(\n WEBHOOK_URL,\n GOOD_EVENT_LIST_...
[ "0.8132082", "0.7621063", "0.7590919", "0.7569171", "0.73560065", "0.73500896", "0.70519054", "0.6982641", "0.686664", "0.6863123", "0.68231237", "0.66798073", "0.66548973", "0.65954757", "0.6557377", "0.6521396", "0.6485591", "0.6407095", "0.6404922", "0.6379917", "0.6375282...
0.6493045
16
Test that webhook triggers an event without a signature w/o API key.
async def test_mailgun_webhook_with_missing_signature_without_api_key( http_client, webhook_id_without_api_key, mailgun_events ) -> None: event_count = len(mailgun_events) await http_client.post( f"/api/webhook/{webhook_id_without_api_key}", json={"hello": "mailgun", "signature": {}}, )...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def test_mailgun_webhook_event_without_an_api_key(\n http_client, webhook_id_without_api_key, mailgun_events\n) -> None:\n timestamp = \"1529006854\"\n token = \"a8ce0edb2dd8301dee6c2405235584e45aa91d1e9f979f3de0\"\n\n event_count = len(mailgun_events)\n\n await http_client.post(\n f\"/...
[ "0.78311443", "0.74861836", "0.74470305", "0.7275878", "0.7143942", "0.70008343", "0.6867617", "0.68193966", "0.667108", "0.65822953", "0.6461271", "0.62830025", "0.62830025", "0.6255105", "0.6254698", "0.6233343", "0.62201196", "0.6178848", "0.61746246", "0.6162005", "0.6143...
0.7882784
0
Test that webhook triggers an event if there is no api key.
async def test_mailgun_webhook_event_without_an_api_key( http_client, webhook_id_without_api_key, mailgun_events ) -> None: timestamp = "1529006854" token = "a8ce0edb2dd8301dee6c2405235584e45aa91d1e9f979f3de0" event_count = len(mailgun_events) await http_client.post( f"/api/webhook/{webhoo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_webhook_no_env(self):\n payload = json.dumps({})\n rsp = self.client.post(self.webhook_url, {'payload': payload})\n\n self.assertEqual(rsp.status_code, 400)\n self.assertEqual(rsp.content, b'Got event without an env in config.')", "def test_webhook_empty_event(self):\n ...
[ "0.7435028", "0.72691625", "0.72062886", "0.70882434", "0.6976369", "0.6950188", "0.6866108", "0.6684333", "0.6652941", "0.62824595", "0.62668353", "0.6251787", "0.6109379", "0.6105504", "0.60713077", "0.6037791", "0.6037791", "0.60287344", "0.60178393", "0.5906953", "0.59039...
0.74822223
0
Maximum input length supported by the decoder.
def max_positions(self): return 1e6 # an arbitrary large number
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_length(self) -> int | None:\n return self._underlying.max_length", "def max_length(self):\n\t\treturn self._max_length", "def _max_length(self):\n return self.__max_length", "def len_max(self):\n return 16 + 16 + 8 + 8 + Tools.bin_to_dec(self.get_data_size()) + Tools.bin_to_dec(s...
[ "0.7796591", "0.7736442", "0.76166713", "0.7445456", "0.7329024", "0.7299141", "0.7163814", "0.71371233", "0.69623315", "0.6938757", "0.69200283", "0.6907954", "0.68964267", "0.6823691", "0.6818247", "0.6818247", "0.6818247", "0.6818247", "0.68138736", "0.6789785", "0.6698681...
0.0
-1
Maximum output length supported by the decoder.
def max_positions(self): if self.embed_positions is None: return self.max_target_positions return min(self.max_target_positions, self.embed_positions.max_positions)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def len_max(self):\n return 16 + 16 + 8 + 8 + Tools.bin_to_dec(self.get_data_size()) + Tools.bin_to_dec(self.get_verification_size())", "def setMaxOutputLength(self, value):\n return self._set(maxOutputLength=value)", "def setMaxOutputLength(self, value):\n return self._set(maxOutputLength...
[ "0.7432989", "0.73925817", "0.73925817", "0.73925817", "0.7161096", "0.71449983", "0.70124006", "0.69647205", "0.69551724", "0.69273204", "0.68699276", "0.68549514", "0.684077", "0.68397105", "0.68026745", "0.6781775", "0.67704415", "0.6759464", "0.6752665", "0.6748612", "0.6...
0.0
-1
Is the tree at this node balanced? A tree is balanced if 1) the depths of its child trees differ by no more than one and 2) this is true for EVERY subtree.
def is_balanced(self): def _height(node): """Calculate the height of a node""" if not node: return 0 return 1 + max(_height(node.left), _height(node.right)) def _is_balanced(node): """Check if the subtree at a node is balanced""" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_balanced(self):\n \n if self.node is None:\n return True\n \n # Left subtree height\n lst = self.node.left.height\n # Right subtree height\n rst = self.node.right.height\n\n if (abs(lst - rst) <= 1) and self.node.left.is_balanced() is True a...
[ "0.86853987", "0.84249496", "0.83568394", "0.8016725", "0.7805704", "0.7745818", "0.7720889", "0.769582", "0.76726794", "0.76346797", "0.7398455", "0.7304947", "0.7243492", "0.69928813", "0.6906595", "0.6858249", "0.68325627", "0.67020386", "0.6576677", "0.65657276", "0.65091...
0.8979192
0
Check if the subtree at a node is balanced
def _is_balanced(node): # An empty node is always balanced if not node: return True # If the heights differ by more than 1, return False if abs(_height(node.left) - _height(node.right)) > 1: return False return _is_balanced(n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_balanced(root):\n return depth(root) != -1;", "def is_balanced(self):\n\n def _height(node):\n \"\"\"Calculate the height of a node\"\"\"\n\n if not node:\n return 0\n\n return 1 + max(_height(node.left), _height(node.right))\n\n def _is_bal...
[ "0.85485834", "0.84527177", "0.8333652", "0.79819745", "0.7876206", "0.7722655", "0.76744944", "0.75890386", "0.75406873", "0.7462788", "0.7449527", "0.740391", "0.7400275", "0.732011", "0.72324157", "0.71178484", "0.71018744", "0.7062439", "0.70399404", "0.7017949", "0.69612...
0.8544276
1
Method to turn off all motors
def turnOffMotors(self): self.mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE) self.mh.getMotor(2).run(Adafruit_MotorHAT.RELEASE) self.mh.getMotor(3).run(Adafruit_MotorHAT.RELEASE) self.mh.getMotor(4).run(Adafruit_MotorHAT.RELEASE)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def turn_off_motors():\n MOTOR_HAT.release_motors()", "def turnOffMotors(self) -> None:\n mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE)\n mh.getMotor(2).run(Adafruit_MotorHAT.RELEASE)\n mh.getMotor(3).run(Adafruit_MotorHAT.RELEASE)\n mh.getMotor(4).run(Adafruit_MotorHAT.RELEASE)", ...
[ "0.8592148", "0.851119", "0.8040889", "0.7906769", "0.7805959", "0.7798688", "0.7773433", "0.76799667", "0.7502376", "0.739445", "0.738192", "0.7315012", "0.7299683", "0.7183742", "0.7165379", "0.71424824", "0.7134631", "0.7134242", "0.7115855", "0.7101031", "0.70863384", "...
0.8516176
1
Verify that the notifications model add functionality works correctly.
def test_add_notification(db, session): # pylint: disable=unused-argument # add a notification using model user_id = 'test-user' request_id = 213 request_type = 'registration' request_status = 3 message = 'this is a test notification' notification = Notification(user_id=user_id, request_id=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_successfully_create_notifications(self):\n pre_function_notifications = Notification.objects.all()\n self.assertEqual(len(pre_function_notifications), 0)\n\n create_notification(\n user=self.user_with_targets,\n title=\"Hi.\",\n body=\"Hello there, fri...
[ "0.700339", "0.66539806", "0.65723556", "0.65723556", "0.65031123", "0.6466875", "0.6466875", "0.64643466", "0.64562064", "0.64536756", "0.64363176", "0.6429757", "0.6379911", "0.63693553", "0.6356505", "0.63382804", "0.6300429", "0.6246195", "0.6235942", "0.62145853", "0.621...
0.6586845
2
Verify that the exist_user() work correctly.
def test_exist_users(db, session): # pylint: disable=unused-argument # add a notification for user user_id = 'notf-user' request_id = 223 request_type = 'registration' request_status = 3 message = 'this is a test notification' notification = Notification(user_id=user_id, request_id=request_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_existing_user(self):\n user = User.objects.create(username=self.username)\n actual = get_user_if_exists(None, self.details)\n self.assertDictEqual(actual, {'is_new': False, 'user': user})", "def test_existence(self):\n self.assertTrue(User.objects.filter(username='rcm').exist...
[ "0.77960485", "0.77627444", "0.7740027", "0.7725378", "0.7705841", "0.7667053", "0.7647634", "0.7575908", "0.7482518", "0.7470327", "0.7437159", "0.74088514", "0.7401119", "0.73874384", "0.73681366", "0.7352972", "0.7310509", "0.72930884", "0.7282122", "0.72662264", "0.723895...
0.0
-1
If 2 nodes in left sided tree, root points to left child only.
def test_left_sided_tree_with_two_nodes_root_has_child(empty_t): empty_t.insert(10) empty_t.insert(5) assert empty_t.root.left assert not empty_t.root.right
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def left_root(self):\n return self.left_child(self.virtual_root)", "def set_left(self, new_left_child):\n node = BinaryNode.or_none(new_left_child)\n self.left = node\n if node is not None:\n node.parent = self", "def _left(node):\n return 2 * node + 1", "def get_lef...
[ "0.7588447", "0.74530876", "0.737186", "0.7345712", "0.72915757", "0.72578865", "0.7257847", "0.7257847", "0.72072995", "0.7196273", "0.7169099", "0.71688557", "0.7149541", "0.71471435", "0.7131863", "0.70970094", "0.7092864", "0.7091102", "0.708573", "0.7084005", "0.70785147...
0.6917129
29
If 2 nodes in right sided tree, root points to right child only.
def test_right_sided_tree_with_two_nodes_root_has_child(empty_t): empty_t.insert(10) empty_t.insert(15) assert empty_t.root.right assert not empty_t.root.left
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rightChild(self, pos):\n return (2 * pos) + 1", "def rightChild(self, pos):\n return (2 * pos) + 1", "def double_with_right_child(self, node):\n node.right = self.rotate_with_left_child(node.right)\n # double rotate to the left\n return self.rotate_with_right_child(node)", ...
[ "0.7179868", "0.7179868", "0.71786", "0.71778613", "0.71650267", "0.71153384", "0.70899", "0.70810086", "0.7062603", "0.6952836", "0.69426894", "0.68752825", "0.6821023", "0.68162835", "0.68099874", "0.6807865", "0.6806213", "0.6802527", "0.6779954", "0.67576253", "0.67562616...
0.700672
9
Balanced tree with 3 nodes, check root children's values are correct.
def test_balanced_tree_with_3_nodes_childens_values(balanced_3_nodes): assert balanced_3_nodes.root.right.value == 15 assert balanced_3_nodes.root.left.value == 5
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tree_3_nodes_balanced_return_1(balanced_3_nodes):\n assert balanced_3_nodes.balance() == 0", "def test_balanced_tree_with_3_nodes_root_has_2_kids(balanced_3_nodes):\n assert balanced_3_nodes.root.right\n assert balanced_3_nodes.root.left", "def test_balanced_tree_with_7_nodes_is_correct(balan...
[ "0.7833882", "0.77613556", "0.7484149", "0.7428502", "0.73045456", "0.71581566", "0.70541465", "0.70445824", "0.69201666", "0.69041145", "0.68269646", "0.67697656", "0.66766065", "0.66583943", "0.6621639", "0.661566", "0.65951407", "0.65948695", "0.65937513", "0.6516213", "0....
0.8542064
0
Tree with one node should have depth of zero.
def test_tree_one_node_has_depth_zero(one_t): assert one_t.depth() == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_minimal_tree_creation():\n t = Tree(None)\n\n assert t.data is None\n assert t.parent is None\n assert len(t) == 0", "def test_tree_with_one_node_root_no_children(one_t):\n assert not one_t.root.left\n assert not one_t.root.right", "def test_empty_tree(height_one_tree):\n assert h...
[ "0.751546", "0.7346145", "0.7110515", "0.7080724", "0.7057927", "0.69525915", "0.69221705", "0.6851852", "0.6724012", "0.6675885", "0.66632724", "0.6659297", "0.65440464", "0.6507005", "0.64917517", "0.6420321", "0.638464", "0.63820815", "0.63635814", "0.6362949", "0.63126796...
0.8031135
0
2 node tree with root child on left should have depth one.
def test_tree_two_nodes_left_has_depth_one(one_t): one_t.insert(5) assert one_t.depth() == 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tree_two_nodes_right(one_t):\n one_t.insert(5)\n assert one_t.depth() == 1", "def test_tree_with_one_leaf_node_right_of_left_depth(balanced_3_nodes):\n balanced_3_nodes.insert(8)\n assert balanced_3_nodes.depth() == 2", "def test_left_sided_tree_with_two_nodes_root_has_child(empty_t):\n ...
[ "0.6955858", "0.6955325", "0.6935698", "0.6911057", "0.67805696", "0.67161113", "0.6655438", "0.6652108", "0.66326386", "0.6617105", "0.65316904", "0.6526484", "0.65078735", "0.6501491", "0.6493022", "0.64760756", "0.6448446", "0.64291966", "0.6355407", "0.6330967", "0.633096...
0.7497773
0
2 node tree with root child on right should have depth one.
def test_tree_two_nodes_right(one_t): one_t.insert(5) assert one_t.depth() == 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tree_two_nodes_left_has_depth_one(one_t):\n one_t.insert(5)\n assert one_t.depth() == 1", "def test_right_sided_tree_with_two_nodes_root_has_child(empty_t):\n empty_t.insert(10)\n empty_t.insert(15)\n assert empty_t.root.right\n assert not empty_t.root.left", "def build():\n r = T...
[ "0.704765", "0.6946737", "0.6707072", "0.6695055", "0.66807026", "0.6589825", "0.65718335", "0.65046525", "0.64511806", "0.6449902", "0.63852024", "0.63487285", "0.6272101", "0.62459", "0.618931", "0.61873764", "0.617784", "0.6134591", "0.6083809", "0.60810345", "0.6057394", ...
0.7105184
0
Balanced tree with 4 nodes and 4th leaf node is on left side of tree and right of parent has depth of 2.
def test_tree_with_one_leaf_node_right_of_left_depth(balanced_3_nodes): balanced_3_nodes.insert(8) assert balanced_3_nodes.depth() == 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tree_with_one_leaf_node_left_of_right_depth(balanced_3_nodes):\n balanced_3_nodes.insert(13)\n assert balanced_3_nodes.depth() == 2", "def test_left_rotation_four_node_tree():\n from bbst import Bst\n tree = Bst([1, 2, 3, 4, 5])\n assert tuple(tree.in_order()) == (1, 2, 3, 4, 5)\n asse...
[ "0.71292627", "0.6762931", "0.6756393", "0.66574717", "0.6596076", "0.65813565", "0.6572666", "0.6556964", "0.65388376", "0.6519721", "0.65160626", "0.6515965", "0.64874494", "0.64745146", "0.64722043", "0.6457913", "0.63843876", "0.63693255", "0.63555896", "0.62592983", "0.6...
0.7156542
0
Balanced tree with 4 nodes and 4th leaf node is on right side of tree and left of parent has depth of 2.
def test_tree_with_one_leaf_node_left_of_right_depth(balanced_3_nodes): balanced_3_nodes.insert(13) assert balanced_3_nodes.depth() == 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tree_with_one_leaf_node_right_of_left_depth(balanced_3_nodes):\n balanced_3_nodes.insert(8)\n assert balanced_3_nodes.depth() == 2", "def test_right_rotation_four_node_tree():\n from bbst import Bst\n tree = Bst([5, 4, 3, 2, 1])\n assert tuple(tree.in_order()) == (1, 2, 3, 4, 5)\n asse...
[ "0.7138633", "0.6834415", "0.6765605", "0.67631423", "0.67279345", "0.6660937", "0.6649829", "0.66126704", "0.66034675", "0.6534828", "0.6522762", "0.65216666", "0.64937145", "0.64550674", "0.64436096", "0.64385974", "0.6415337", "0.638254", "0.63313764", "0.63113934", "0.630...
0.71251637
1
Balanced tree with 7 nodes depth should be 2.
def test_balanced_tree_7_nodes_has_depth_two(balanced_7_nodes): assert balanced_7_nodes.depth() == 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_balanced_tree_with_7_nodes_is_correct(balanced_7_nodes):\n root = balanced_7_nodes.root\n assert root.value == 10\n assert root.left.value == 5\n assert root.right.value == 15\n assert root.left.left.value == 3\n assert root.left.right.value == 7\n assert root.right.right.value == 20\...
[ "0.77753365", "0.71761006", "0.70185614", "0.7000902", "0.6885562", "0.68806344", "0.66714054", "0.6646024", "0.6628808", "0.654948", "0.6545334", "0.6496474", "0.6483075", "0.64692205", "0.64678186", "0.6461578", "0.63873595", "0.63627535", "0.63566834", "0.6342123", "0.6339...
0.70949095
2
Tree with just one node should return balance of zero.
def test_tree_with_one_node_balance_is_zero(one_t): assert one_t.balance() == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def balance(self, node=None):\n if node is None:\n node = self.root\n if self.root is None:\n return 0\n if not node.left and not node.right:\n return 0\n elif not node.left:\n return node.right.balance_number\n elif not node.ri...
[ "0.7311562", "0.7239354", "0.7077118", "0.6983659", "0.6818844", "0.6802887", "0.6781922", "0.6762638", "0.6714572", "0.66545063", "0.6593687", "0.654109", "0.653976", "0.65184605", "0.65158653", "0.64326537", "0.63812584", "0.6377963", "0.6359528", "0.63393354", "0.629772", ...
0.81377167
0
Tree with 2 nodes and left sided should return balance of 1.
def test_tree_2_nodes_left_unbalanced(one_t): one_t.insert(9) assert one_t.balance() == 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_balance_left_tree(bst_all_to_left):\n assert bst_all_to_left.balance() == -1", "def balance(node):\n return abs(height(node.left_child) - height(node.right_child)) <= 1", "def __balance(self) -> \"Node\":\n current = self\n\n while True:\n current.__update_height()\n\n ...
[ "0.7440352", "0.7304175", "0.71722114", "0.7096782", "0.7082586", "0.70798236", "0.7042629", "0.69351935", "0.6897452", "0.6883425", "0.68588066", "0.68079114", "0.6744646", "0.67194605", "0.671656", "0.67019874", "0.66044945", "0.65706974", "0.6434796", "0.6381176", "0.63582...
0.6913936
8
Tree with 2 nodes and right sided should return balance of 1.
def test_tree_2_nodes_right_unbalanced(one_t): one_t.insert(11) assert one_t.balance() == -1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def balance(node):\n return abs(height(node.left_child) - height(node.right_child)) <= 1", "def __balance(self) -> \"Node\":\n current = self\n\n while True:\n current.__update_height()\n\n if current.balance_factor == 2: # right subtree is higher\n middle = c...
[ "0.74079746", "0.72917724", "0.7202149", "0.7183455", "0.71270645", "0.711292", "0.71075785", "0.69092643", "0.6883706", "0.68591243", "0.67910075", "0.6764973", "0.67522997", "0.6715749", "0.6705761", "0.66904163", "0.6657418", "0.65899897", "0.6511071", "0.6484475", "0.6426...
0.7113036
5
Tree with 3 balanced nodes should return balance of 0.
def test_tree_3_nodes_balanced_return_1(balanced_3_nodes): assert balanced_3_nodes.balance() == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tree_4_nodes_left_unbalanced_return_1(balanced_3_nodes):\n balanced_3_nodes.insert(8)\n assert balanced_3_nodes.balance() == 1", "def test_tree_4_nodes_right_unbalanced_return_1(balanced_3_nodes):\n balanced_3_nodes.insert(13)\n assert balanced_3_nodes.balance() == -1", "def test_balanced_...
[ "0.7543359", "0.75261676", "0.7438584", "0.74215513", "0.69786453", "0.69012505", "0.68852454", "0.682188", "0.68070483", "0.67696095", "0.67511123", "0.6739986", "0.666209", "0.6640643", "0.6611547", "0.6571121", "0.65617704", "0.65599173", "0.6553773", "0.6462627", "0.64603...
0.8187075
0
Tree with 3 balanced nodes should return balance of 0.
def test_tree_4_nodes_left_unbalanced_return_1(balanced_3_nodes): balanced_3_nodes.insert(8) assert balanced_3_nodes.balance() == 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tree_3_nodes_balanced_return_1(balanced_3_nodes):\n assert balanced_3_nodes.balance() == 0", "def test_tree_4_nodes_right_unbalanced_return_1(balanced_3_nodes):\n balanced_3_nodes.insert(13)\n assert balanced_3_nodes.balance() == -1", "def test_balanced_tree_with_3_nodes_childens_values(balan...
[ "0.8187075", "0.75261676", "0.7438584", "0.74215513", "0.69786453", "0.69012505", "0.68852454", "0.682188", "0.68070483", "0.67696095", "0.67511123", "0.6739986", "0.666209", "0.6640643", "0.6611547", "0.6571121", "0.65617704", "0.65599173", "0.6553773", "0.6462627", "0.64603...
0.7543359
1
Tree with 3 balanced nodes should return balance of 0.
def test_tree_4_nodes_right_unbalanced_return_1(balanced_3_nodes): balanced_3_nodes.insert(13) assert balanced_3_nodes.balance() == -1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tree_3_nodes_balanced_return_1(balanced_3_nodes):\n assert balanced_3_nodes.balance() == 0", "def test_tree_4_nodes_left_unbalanced_return_1(balanced_3_nodes):\n balanced_3_nodes.insert(8)\n assert balanced_3_nodes.balance() == 1", "def test_balanced_tree_with_3_nodes_childens_values(balanced...
[ "0.8184732", "0.75411683", "0.7436448", "0.742179", "0.6980795", "0.6903109", "0.6887498", "0.6824567", "0.6808705", "0.67720324", "0.67532027", "0.6742265", "0.6664238", "0.66380394", "0.66120857", "0.65714306", "0.65647215", "0.6560164", "0.6555794", "0.64608663", "0.645829...
0.7523573
2
Tree with 7 balanced nodes should return balance of 0.
def test_tree_7_nodes_balanced_return_1(balanced_7_nodes): assert balanced_7_nodes.balance() == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_balanced_tree_with_7_nodes_is_correct(balanced_7_nodes):\n root = balanced_7_nodes.root\n assert root.value == 10\n assert root.left.value == 5\n assert root.right.value == 15\n assert root.left.left.value == 3\n assert root.left.right.value == 7\n assert root.right.right.value == 20\...
[ "0.7391062", "0.71809137", "0.706578", "0.7059752", "0.70538396", "0.6965259", "0.68406576", "0.6818913", "0.68030757", "0.67645925", "0.67174983", "0.6667804", "0.6645605", "0.6630689", "0.65475035", "0.65367204", "0.6515263", "0.64961755", "0.64783007", "0.64380705", "0.643...
0.8026898
0
Make a list of Animal objects with a random number of each Animal and randomly generated properties.
def generate_animals_randomly(count): animals = [] for _ in range(count): # chooses an animal at random from one of the map keys animal_choice = np.random.choice(list(mappings.keys())) # generates a list of 1 animal and takes the first element animals.append(generate_animals(anim...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate(count):\n return unpack_random_animals(generate_animals_randomly(count))", "def generate_animals(animal_choice, count):\n animals = []\n for _ in range(count):\n # uses the animal choice to map to appropriate function pointer and create Animal object\n animals.append(mappings[...
[ "0.7332295", "0.71083283", "0.6811306", "0.65797573", "0.65355265", "0.6272358", "0.625434", "0.6152746", "0.6148341", "0.6087322", "0.5990863", "0.59766746", "0.59746253", "0.5944207", "0.5940308", "0.5879651", "0.5871254", "0.5868636", "0.58618575", "0.58511394", "0.5817351...
0.7695748
0
Combine any number of dictionaries into one dictionary.
def merge_animal_dicts(*dicts): full = dicts[0] for d in dicts: full.update(d) return full
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_n_dictionnaries(dicts):\n result = dicts[0]\n for i in range(1, len(dicts)):\n result = merge_2_dictionnaries(result, dicts[i])\n return result", "def merge_dicts(*dicts):\n result = {}\n for d in dicts:\n result.update(d)\n return result", "def merge_dicts(*dict_args)...
[ "0.7844369", "0.7503754", "0.73642457", "0.73642457", "0.73642457", "0.73642457", "0.73642457", "0.73642457", "0.73317885", "0.7326537", "0.7309403", "0.72056", "0.71941596", "0.7130463", "0.71180624", "0.7094619", "0.706383", "0.6981261", "0.6947028", "0.6942253", "0.6904091...
0.70138425
17
Combine any number of dictionaries into one dictionary.
def merge_animal_dict_list(dict_list): full = dict_list[0] for d in dict_list: full.update(d) return full
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_n_dictionnaries(dicts):\n result = dicts[0]\n for i in range(1, len(dicts)):\n result = merge_2_dictionnaries(result, dicts[i])\n return result", "def merge_dicts(*dicts):\n result = {}\n for d in dicts:\n result.update(d)\n return result", "def merge_dicts(*dict_args)...
[ "0.7843783", "0.7502678", "0.73630744", "0.73630744", "0.73630744", "0.73630744", "0.73630744", "0.73630744", "0.7330972", "0.7325212", "0.73085374", "0.7204152", "0.7192893", "0.71294683", "0.7117602", "0.7093341", "0.7062397", "0.70128095", "0.69805497", "0.69463325", "0.69...
0.5917548
61
Sets the lowest_fee_multiplier of this TransactionFeesDTO.
def lowest_fee_multiplier(self, lowest_fee_multiplier): if self.local_vars_configuration.client_side_validation and lowest_fee_multiplier is None: # noqa: E501 raise ValueError("Invalid value for `lowest_fee_multiplier`, must not be `None`") # noqa: E501 self._lowest_fee_multiplier = lowe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setMinValue(self, min_value):\r\n\t\tself.MinValue = min_value", "def setMinValue(self, min_value):\r\n\t\tself.MinValue = min_value", "def userMinimum(self, new_min: float) -> None:\n self._user_minimum = new_min\n self.reset_limits()", "def min(self, min):\n\n self._min = min", "...
[ "0.64898986", "0.64898986", "0.6488992", "0.6431611", "0.6431611", "0.6393317", "0.6393317", "0.6393317", "0.63761234", "0.60856915", "0.60263133", "0.59961194", "0.5973716", "0.5790497", "0.5790497", "0.5774643", "0.5772046", "0.57607865", "0.5759083", "0.574623", "0.5743429...
0.83397907
0
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, TransactionFeesDTO): return False return self.to_dict() == other.to_dict()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def __eq__(self, other):\n if i...
[ "0.8088132", "0.8088132", "0.8054589", "0.7982687", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", ...
0.0
-1
Returns true if both objects are not equal
def __ne__(self, other): if not isinstance(other, TransactionFeesDTO): return True return self.to_dict() != other.to_dict()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True", "def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)", "def __ne__(self, other) -> bool:\n return not self.__eq__(other)", "def __eq__(self, other):\n ...
[ "0.845611", "0.8391477", "0.8144138", "0.81410587", "0.8132492", "0.8093973", "0.80920255", "0.80920255", "0.80920255", "0.8085325", "0.8085325", "0.8076365", "0.8076365", "0.8065748", "0.8042487", "0.8042487", "0.8042487", "0.8042487", "0.8042487", "0.8042487", "0.8042487", ...
0.0
-1
Load a JSON file into an object.
def JSONtoObject(fileName): # TODO: ensure file exists first!! with open(fileName) as json_data: d = json.load(json_data) return d #return json.loads(d, object_hook=_json_object_hook)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_from_json_file(filename):\n with open(filename, 'r') as f:\n obj = json.loads(f.read())\n return obj", "def load_json(filename):\n with open(filename) as file:\n obj = json.load(file)\n return obj", "def load_from_json_file(filename):\n with open(filename, 'r') as jFil...
[ "0.8598642", "0.8395932", "0.8266937", "0.8233468", "0.81264126", "0.81164724", "0.81017375", "0.803881", "0.8019395", "0.797093", "0.79455245", "0.7939328", "0.7936845", "0.79365903", "0.7934787", "0.79302585", "0.79236114", "0.7913424", "0.7902785", "0.7894301", "0.788816",...
0.74420935
59
Function, representing gaussian peak shape
def gaussian(x, sigma): try: r = np.exp(-0.5*(x/sigma)**2) except: r = np.zeros(len(x)) return r
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gaussian(x, peak_x=.0, sigma=1.0, name=''):\n x = x.astype(np.float)\n variables = {'function': gaussian, 'peak_x': peak_x, 'sigma': sigma}\n y = np.exp((-1 * (x - peak_x)**2) / (2 * sigma**2))\n return packer(x, y, variables, name=name)", "def gaussianPSF(shape, sigma):\n psf = dg.drawGaussia...
[ "0.696511", "0.6573864", "0.63947034", "0.6373754", "0.62643504", "0.6242376", "0.6214449", "0.6207855", "0.6201189", "0.6190154", "0.6185931", "0.6159832", "0.6137901", "0.61069894", "0.61069894", "0.61069894", "0.6092655", "0.6072533", "0.6071066", "0.60425305", "0.6009968"...
0.59228355
32
Create a function that computes the mpf value for a mathematical constant, given a function that computes the fixedpoint value.
def def_mpf_constant(fixed): def f(prec, rnd=round_fast): wp = prec + 20 v = fixed(wp) if rnd in (round_up, round_ceiling): v += 1 return normalize(0, v, -wp, bitcount(v), prec, rnd) f.__doc__ = fixed.__doc__ return f
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def M(f):\n return 1127 * numpy.log(1 + f/700.0)", "def mw_f(mw):\n return np.power(mw, 0.5)", "def PointMilieu(x,f):\n\tNx = f.shape[0]\n\tS=0.0\n\tfor i in range(0,Nx-1):\n\t\tS=S+f[i]*(x[i+1]-x[i]) \n\treturn S", "def constant_memo(f):\n f.memo_prec = -1\n f.memo_val = None\n def g(pre...
[ "0.64376664", "0.632875", "0.63238263", "0.6293339", "0.61158365", "0.6096112", "0.60566914", "0.60330117", "0.60141337", "0.5983397", "0.5978756", "0.5960186", "0.595882", "0.594747", "0.5939758", "0.59339786", "0.59170383", "0.59141934", "0.5883238", "0.58614445", "0.583585...
0.7680616
0
nth power of a fixed point number with precision prec Returns the power in the form man, exp, man 2exp ~= yn
def int_pow_fixed(y, n, prec): if n == 2: return (y*y), 0 bc = bitcount(y) exp = 0 workprec = 2 * (prec + 4*bitcount(n) + 4) _, pm, pe, pbc = fone while 1: if n & 1: pm = pm*y pe = pe+exp pbc += bc - 2 pbc = pbc + bctable[int(pm >> ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __pow__(self,n):\r\n\t\t\r\n\t\t# take power\r\n\t\tp = self.power(n)\r\n\t\t\r\n\t\treturn p", "def nth_pow(x, n, name=None):\n if not n >= 0:\n raise ValueError(\"n (power) has to be >= 0. Currently, n={}\".format(n))\n\n power = to_complex(1.)\n for _ in range(n):\n power *= x\n ...
[ "0.72427875", "0.7122238", "0.6921036", "0.68760496", "0.68477404", "0.67794096", "0.6776796", "0.67665905", "0.67505574", "0.6726683", "0.667205", "0.6654134", "0.66452605", "0.6632109", "0.6630714", "0.66219175", "0.6566922", "0.6566922", "0.65655667", "0.6561131", "0.65591...
0.7472906
0
Compute the natural logarithm of the mpf value x. If x is negative, ComplexResult is raised.
def mpf_log(x, prec, rnd=round_fast): sign, man, exp, bc = x #------------------------------------------------------------------ # Handle special values if not man: if x == fzero: return fninf if x == finf: return finf if x == fnan: return fnan if sign: raise ComplexR...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logM(nX, QBERx, eps_c):\n lM = nX * h(QBERx) + (nX * (1.0 - QBERx) - FInv(int(nX), QBERx, eps_c) - \\\n 1) * np.math.log((1.0 - QBERx) / QBERx) - \\\n 0.5*np.math.log(nX) - np.math.log(1.0 / eps_c)\n return lM", "def log(x, err=defaultError):\n if (defaultError >= err...
[ "0.6722066", "0.65403736", "0.652976", "0.64332366", "0.6387174", "0.6316283", "0.6295226", "0.6292194", "0.6272305", "0.62642926", "0.6258983", "0.62531596", "0.6210413", "0.61899626", "0.6188021", "0.61878854", "0.61442184", "0.60948145", "0.6083674", "0.60815394", "0.60628...
0.7339514
0
Compute exp(x) as a fixedpoint number. Works for any x, but for speed should have |x| < 1. For an arbitrary number, use exp(x) = exp(xmlog(2)) 2^m where m = floor(x/log(2)).
def exp_basecase(x, prec): if prec > EXP_COSH_CUTOFF: return exponential_series(x, prec, 0) r = int(prec**0.5) prec += r s0 = s1 = (MPZ_ONE << prec) k = 2 a = x2 = (x*x) >> prec while a: a //= k; s0 += a; k += 1 a //= k; s1 += a; k += 1 a = (a*x2) >> prec ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exp(x):\n raise NotImplementedError", "def F(x):\n return math.exp(-0.5 * (x ** 2))", "def Exp(num):\n return math.exp(float(num))", "def exp_integral(x):\n gamma = 0.577215665\n return (-gamma - expn(x,1) - np.log(x))", "def general_exp(x, max_order=15):\n\n result = 1.0\n if ...
[ "0.74089205", "0.7127717", "0.7097001", "0.7076243", "0.7049351", "0.6989556", "0.6985232", "0.6937879", "0.69301677", "0.69227314", "0.6896891", "0.68756795", "0.6803069", "0.66446495", "0.6617223", "0.65495634", "0.6539737", "0.6526851", "0.6521789", "0.64955944", "0.648317...
0.6354147
21
Return a list with every nth item (default 10th item)
def get_every_nth_state(n=10): loops = int(50/n) state_list = [] for i in range(loops): state_list.append(states[(i+1)*n-1]) return state_list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_items(n, fmt, obj):\n if n == 0:\n return gen_item(fmt, obj)\n lst = [0] * n\n for i in range(n):\n lst[i] = gen_item(fmt, obj)\n return lst", "def gen_items(n, fmt, obj):\n if n == 0:\n return gen_item(fmt, obj)\n lst = [0] * n\n for i in range(n):\n lst[...
[ "0.7207928", "0.7207928", "0.687115", "0.66590416", "0.6629614", "0.6608964", "0.65636677", "0.65495723", "0.65447074", "0.65447074", "0.6529606", "0.6529606", "0.65175754", "0.65175754", "0.65075326", "0.6482572", "0.64602387", "0.64564514", "0.64204675", "0.641609", "0.6398...
0.0
-1
Return a list with every nth item (default 10th item)
def get_every_nth_state(n=10): new_states = [] for i, state in enumerate(states, 1): if i % n == 0: new_states.append(state) return new_states
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_items(n, fmt, obj):\n if n == 0:\n return gen_item(fmt, obj)\n lst = [0] * n\n for i in range(n):\n lst[i] = gen_item(fmt, obj)\n return lst", "def gen_items(n, fmt, obj):\n if n == 0:\n return gen_item(fmt, obj)\n lst = [0] * n\n for i in range(n):\n lst[...
[ "0.7207928", "0.7207928", "0.687115", "0.66590416", "0.6629614", "0.6608964", "0.65636677", "0.65495723", "0.65447074", "0.65447074", "0.6529606", "0.6529606", "0.65175754", "0.65175754", "0.65075326", "0.6482572", "0.64602387", "0.64564514", "0.64204675", "0.641609", "0.6390...
0.6398458
20
Takes columns with numbers as object datatypes and converts them to numeric datatypes. Objects are coerced to type int or type float.
def make_numeric( df, vars_=[ 'emp', 'empszfi', 'firmpdemp', 'payann', 'rcppdemp', 'eth_group', 'geotype', 'rcpszfi', 'sex', 'vet_group']): df[vars_] = df[vars_].apply(pd.to_numeric) return df
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_numeric_and_downcast_data(df: pd.DataFrame):\n fcols = df.select_dtypes('float').columns\n \n icols = df.select_dtypes('integer').columns\n\n df[fcols] = df[fcols].apply(pd.to_numeric, downcast='float')\n \n df[icols] = df[icols].apply(pd.to_numeric, downcast='integer')\n\n return df", ...
[ "0.77506346", "0.74672294", "0.71642965", "0.7127298", "0.7075661", "0.70447075", "0.6922425", "0.6768693", "0.6732713", "0.66990083", "0.6607125", "0.653357", "0.6527024", "0.64929605", "0.6491336", "0.64872915", "0.6408212", "0.63119954", "0.6288784", "0.62346303", "0.61833...
0.6751405
8
Build $ref for the Patron of the Loan.
def circulation_build_patron_ref(loan_pid, loan): return { "$ref": "{scheme}://{host}/api/resolver/circulation/loans/{loan_pid}/" "patron".format( scheme=current_app.config["JSONSCHEMAS_URL_SCHEME"], host=current_app.config["JSONSCHEMAS_HOST"], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_reference(self):\n self.make_reference2()", "def create_field_href(reference: NamedRef,\n env: BuildEnvironment) -> pending_xref:\n\n text = reference.name\n options = {'refdoc': env.docname,\n 'refdomain': \"py\",\n 'reftype': \"obj\",\n ...
[ "0.5759521", "0.56444156", "0.551406", "0.53681666", "0.53607523", "0.5313985", "0.5270692", "0.5216583", "0.5200527", "0.51855", "0.5067602", "0.5063289", "0.50590837", "0.5044267", "0.49684963", "0.49435917", "0.494327", "0.49417028", "0.4900365", "0.4893127", "0.48843253",...
0.7500036
0
Return a default extensions max count.
def circulation_default_extension_max_count(loan): return float("inf")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_default_extension_max_count(loan):\n raise NotImplementedConfigurationError(\n config_variable=\"CIRCULATION_POLICIES.extension.max_count\"\n )", "def max_count(self):\n return self.config.get('max_count', 500)", "def maximum_dot_count(self) -> Union[int, None]:\n return self...
[ "0.81865335", "0.68664175", "0.6615069", "0.6594694", "0.63514656", "0.63513935", "0.62709254", "0.62364495", "0.62364495", "0.62364495", "0.62364495", "0.62364495", "0.6236437", "0.6086669", "0.60724926", "0.59964883", "0.59810853", "0.5943175", "0.59397507", "0.5819747", "0...
0.70964044
1
Verify if a transaction is possible based on the amount of coins of a given sender.
def verify_transaction(transaction, get_balance, check_funds=True): if check_funds: sender_balance = get_balance(transaction.sender) return sender_balance >= transaction.amount and Wallet.verify_transaction(transaction) else: return Wallet.verify_transaction(transacti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verify_transaction(transaction):\n sender_balance = get_balance(transaction['sender'])\n return sender_balance >= transaction['amount']", "def verify_transaction(\n transaction: SignedRawTransaction,\n get_balance: Callable,\n get_last_tx_nonce: Callable,\n check_funds: bool...
[ "0.73298097", "0.72159344", "0.6773513", "0.67698246", "0.6670269", "0.6630627", "0.66070634", "0.6523586", "0.6505029", "0.63353336", "0.63328344", "0.6319559", "0.6279769", "0.6276232", "0.6257167", "0.62551206", "0.6247719", "0.6209033", "0.61864763", "0.6173244", "0.61649...
0.6829098
2
Merge dictionaries and keep values of common keys in list
def mergeDict(self, dict1, dict2): dict3 = {**dict1, **dict2} for key, value in dict3.items(): if key in dict1 and key in dict2: try: dict3[key] = value + dict1[key] except TypeError: self.log.info(f"Error merging dicts. {value} + {dict1[key]}") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def consense_dicts(dicts):\n all_keys = sorted(set(chain(*(dc for dc in dicts))))\n return {key: consense_values([dc[key] for dc in dicts if key in dc])\n for key in all_keys}", "def merge_dicts(listDicts) :\n return dict(itertools.chain.from_iterable([x.items() for x in listDicts]))", "def...
[ "0.72021914", "0.71432066", "0.70324683", "0.6900698", "0.6780409", "0.6753274", "0.6716131", "0.66834766", "0.66738147", "0.66429615", "0.66304237", "0.65319204", "0.6531288", "0.6529319", "0.64532375", "0.63469326", "0.63437533", "0.634144", "0.63292664", "0.63292664", "0.6...
0.0
-1
Computes L2 distance between two tensors.
def _dist(a, b): return torch.pow(a - b, 2).sum(-1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def l2_distance(v1, v2):\n\treturn np.linalg.norm(np.array(v1) - np.array(v2))", "def nn_distance(xyz1, xyz2):\n return _op_library.nn_distance(xyz1, xyz2)", "def l2_distance(self, x, y):\n if len(x) != len(y):\n raise ValueError(\"Dimensions of x {} and y {} are not the same\".format(len(...
[ "0.75202453", "0.73540443", "0.7302629", "0.729751", "0.7269003", "0.7198709", "0.7171787", "0.7149975", "0.70195603", "0.7018996", "0.7016226", "0.6976708", "0.6976708", "0.6928742", "0.6923857", "0.69052804", "0.68570155", "0.6812567", "0.680426", "0.68026745", "0.6795049",...
0.68337023
17
Compute the losses related to the bounding boxes, the L1 regression loss and the GIoU loss targets dicts must contain the key "bboxes" containing a tensor of dim [nb_target_boxes, 4].\n The target boxes are expected in format (center_x, center_y, w, h), normalized by the image size.
def loss_boxes(self, outputs, targets, indices, num_boxes): assert 'bboxes' in outputs idx = self._get_src_permutation_idx(indices) src_boxes = outputs['bboxes'][idx] target_boxes = torch.cat([t[i] for t, (_, i) in zip(targets['bboxes'], indices)], dim=0) loss_bbox = F.l1_loss(s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loss_boxes(self, outputs, targets, indices, num_boxes):\n assert 'pred_boxes' in outputs\n idx = self._get_src_permutation_idx(indices)\n src_boxes = outputs['pred_boxes'][idx]\n tgt_idx = [i[torch.where(i >= 0)[0]] for i in indices]\n target_boxes = torch.cat([t['boxes'][i] ...
[ "0.76171696", "0.75167185", "0.7493145", "0.7467779", "0.7281409", "0.71409297", "0.66154635", "0.65858203", "0.6473602", "0.6422158", "0.64097595", "0.6379357", "0.62659144", "0.62544805", "0.6193454", "0.6193454", "0.6183106", "0.61541325", "0.61492205", "0.6134603", "0.611...
0.7666579
0
Getter for accessing the core descriptor of a figure
def get_figure_desc(figure): return figure['output']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fig(self):\n return self._fig", "def __repr__(self):\n return \"Figure(%s)\"%(\", \".join(self._point() + self._prop()))", "def get_figure(self):\n import mayavi.mlab as mlab\n if self.new_figure or self.figure_id is not None:\n self.figure = mlab.figure(self.figure_i...
[ "0.66017544", "0.6053044", "0.5848975", "0.58075285", "0.57740504", "0.5714793", "0.5701013", "0.5633309", "0.5511613", "0.5425175", "0.5417449", "0.5407744", "0.53435", "0.53334755", "0.53300977", "0.5311221", "0.5301668", "0.52918065", "0.52509534", "0.52488667", "0.5228397...
0.64275765
1
Create an HTML snippet string with a table containing the Figure data.
def html_data_table(self): return "XXX"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getHTMLTable(self):\n stocks = self.getTrackedStocks()\n\n html = \" \\\n <html> \\\n <head></head> \\\n <body> \\\n <table> \\\n <tr> \\\n <th>Ticker</th> \\\n <th>Company</th> \\\n ...
[ "0.69037575", "0.67676765", "0.67202413", "0.6711735", "0.6707162", "0.66312706", "0.6624729", "0.6608823", "0.65691924", "0.6521426", "0.64992243", "0.6482022", "0.64547414", "0.6443209", "0.642608", "0.64012563", "0.63261837", "0.6315934", "0.6310039", "0.6302321", "0.63001...
0.66427773
5
Specifically get an attribute of an object's class.
def get_class_attr(obj, name, default=None): return getattr(obj.__class__, name, default)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_attr(obj, attr):\n return getattr(obj, attr)", "def get_class_attribute(self):\n return self.class_attr", "def get(self, att):\n return getattr(self, att)", "def _get(self, name):\n return object.__getattribute__(self, name)", "def _get(self, name):\n return object.__...
[ "0.7518186", "0.70152", "0.7006729", "0.69819677", "0.69819677", "0.6927824", "0.6927824", "0.6863979", "0.68323994", "0.67309654", "0.67216897", "0.6714518", "0.6665863", "0.65950394", "0.6560801", "0.6560673", "0.65603155", "0.65542626", "0.65521115", "0.65298915", "0.65284...
0.7564235
0
Specifically get an attribute of an instance (i.e. do not fall back on a class attribute with the same name, as does getattr).
def get_instance_attr(obj, name, default=None) : class_value = get_class_attr(obj, name) obj_value = getattr(obj, name, default) # If there was no instance attribute by that name, getattr will return the # class_value if it exists, which we do not want. if has_value(class_value) and obj_value is class_valu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_attr(obj, attr):\n return getattr(obj, attr)", "def __getattr__(self, attr):\n\t\treturn getattr(self.__instance, attr)", "def __getattr__(self, attr):\r\n return getattr(self.__instance, attr)", "def __getattr__(self, attr):\n return getattr(self.__instance, attr)", "def __getattr...
[ "0.78736395", "0.78712726", "0.7838239", "0.7798901", "0.7798901", "0.7798901", "0.7798901", "0.7798901", "0.7798901", "0.7798901", "0.7798901", "0.7776922", "0.7738692", "0.7730138", "0.7522005", "0.7522005", "0.7359941", "0.7359941", "0.7307754", "0.727432", "0.7258511", ...
0.74882907
16
Construct string data for table.
def string_lines(self, headers = False, labels = True): if self.header is not None: if self.header[-1] != '\n': self.header += '\n' strlist = [self.header] else: strlist = [] # if headers: # s = self._build_header() # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n\n table_list = [self.headers]\n\n for row in self.data:\n table_list.append([row[col] or \"\" for col in self.headers])\n\n return create_table_string(table_list)", "def construct_table(self):\n table_str = self.header_row\n row_lbls, col_lbls = ...
[ "0.81764126", "0.7674482", "0.7258065", "0.6948124", "0.6944249", "0.6921044", "0.6880364", "0.66657484", "0.6653033", "0.6563135", "0.6555848", "0.6553113", "0.65104955", "0.6502733", "0.6457192", "0.6401758", "0.64007396", "0.6360511", "0.63561267", "0.6343194", "0.6336957"...
0.0
-1
Receive user images and generate predictions
def make_prediction(): if request.method == 'POST': # ensure file has been provided if 'file' not in request.files: flash('No file part') return redirect(request.url) file = request.files['file'] # ensure a valid file has been chosen by user if file....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serve_images(self, image_arrays):\n if not self.sess:\n self.build()\n predictions = self.sess.run(\n self.signitures['prediction'],\n feed_dict={self.signitures['image_arrays']: image_arrays})\n return predictions", "def predict(self, images, batch_size):\n pass", "def post(...
[ "0.7472705", "0.73742104", "0.7254437", "0.7110669", "0.7080539", "0.70302886", "0.70238817", "0.69648755", "0.6911016", "0.6901426", "0.684397", "0.68312913", "0.68097275", "0.6803548", "0.67985606", "0.67048246", "0.66964465", "0.6681655", "0.66808546", "0.6638854", "0.6628...
0.68983686
10
Return the source type, eg gps or router, of the device.
def source_type(self): return SOURCE_TYPE_ROUTER
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def source_type(self):\n return SOURCE_TYPE_GPS", "def source_type(self):\n return SOURCE_TYPE_GPS", "def source_type(self) -> SourceType:\n return SourceType.ROUTER", "def source_type(self) -> SourceType:\n return SourceType.ROUTER", "def source_type(self) -> SourceType:\n ...
[ "0.79885626", "0.79885626", "0.7750512", "0.7750512", "0.7750512", "0.7449024", "0.72812986", "0.71759343", "0.66198623", "0.6579725", "0.64343446", "0.6371079", "0.62237245", "0.6218695", "0.6187604", "0.6182113", "0.61786586", "0.61733663", "0.61695445", "0.6154849", "0.608...
0.7760277
2
Returns a rectangular signal with zeros everywhere except vor values n1 <= n <= n2.
def rect_signal(n, n1, n2): assert np.all(np.array(n, dtype=int) == n), 'rect_signal: n should be an integer or an array of integers.' return np.where(np.logical_and(n>=n1, n<=n2), 1, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zeros(cls, n):\n return cls._createVetor([0] * n)", "def make_b_array(n):\n array = np.linspace(-3, 3, n)\n for i, x in enumerate(array[1:-1], start=1):\n if abs(x) < 1:\n array[i] = 2\n else:\n array[i] = 0\n array[0] = 0\n array[n-1] = 0\n\n return ...
[ "0.60182494", "0.58586043", "0.58548576", "0.5293726", "0.5175979", "0.514803", "0.5101125", "0.51001316", "0.5078733", "0.50687474", "0.5058722", "0.50396436", "0.4995493", "0.4982181", "0.4965126", "0.4958443", "0.49423468", "0.4933293", "0.49217728", "0.49153107", "0.49151...
0.6787109
0
Returns a unit jump signal where the signal is 1 for t >= 0 and 0 otherwise.
def unit_jump(t): return np.where(t >= 0, 1, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unit_jump(n):\n assert np.all(np.array(n, dtype=int) == n), 'unit_jump: n should be an integer or an array of integers.'\n return np.where(n >= 0, 1, 0)", "def vi1(t):\n u_t = 1*(t>0)\n return (np.sin(2000*np.pi*t)+np.cos(2e6*np.pi*t)) * u_t", "def signal(x):\r\n if x >= 0.0:\r\n ...
[ "0.6819824", "0.61332476", "0.5991529", "0.59799427", "0.58555067", "0.58059156", "0.5723766", "0.560459", "0.5601942", "0.55934185", "0.5575071", "0.55309856", "0.5468955", "0.54275525", "0.5424813", "0.5422111", "0.5392566", "0.53465587", "0.53183526", "0.53130627", "0.5304...
0.86122507
0
Returns a rectangular signal with zeros everywhere except vor values n1 <= n <= n2.
def rect_signal(t, t1, t2): return np.where(np.logical_and(t>=t1, t<=t2), 1, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rect_signal(n, n1, n2):\n assert np.all(np.array(n, dtype=int) == n), 'rect_signal: n should be an integer or an array of integers.'\n return np.where(np.logical_and(n>=n1, n<=n2), 1, 0)", "def zeros(cls, n):\n return cls._createVetor([0] * n)", "def make_b_array(n):\n array = np.li...
[ "0.6788449", "0.6017715", "0.5860259", "0.52945375", "0.5176004", "0.51461935", "0.51027435", "0.51006603", "0.5077774", "0.506735", "0.5057538", "0.5040203", "0.49966726", "0.49829865", "0.49652663", "0.49575454", "0.4939463", "0.4932154", "0.49205437", "0.4915921", "0.49145...
0.58545244
3
Shifts the signal h by k. If dt is provided, k will be interpreted as a time shift. If t is provided, dt will be calculated as (max(t)min(t))/len(t) Otherwise k will be interpreted as an index shift.
def shift(h, k, dt=None, t=None, periodic=False): out = np.zeros((len(h),)) if dt is None: if t is not None: dt = (max(t)-min(t))/len(t) else: dt = 1 k = int(k/dt) if k > 0: out[:-k] = h[k:] if periodic: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shift(h, k, periodic=False):\n assert int(k)==k, 'shift: k should be an integer number.'\n out = np.zeros((len(h),))\n if k > 0:\n out[:-k] = h[k:]\n if periodic:\n out[-k:] = h[:k]\n else:\n out[-k:] = h[:k]\n if periodic:\...
[ "0.72043794", "0.5390982", "0.5276485", "0.52753544", "0.5227475", "0.52126694", "0.5184885", "0.5178507", "0.5140929", "0.5115203", "0.5009085", "0.49959663", "0.49937502", "0.49839687", "0.49695626", "0.4957099", "0.49505943", "0.4946834", "0.4943613", "0.49233142", "0.4923...
0.8425683
0
Dilates the signal h by a factor d. f(t) > f(t/d).
def dilate(h, d): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fdq1(f, x, h=1e-5):\n return (f(x+h) - f(x))/h\n \n raise NotImplementedError(\"Problem 2 Incomplete\")", "def h_func(air_density, dt, rah):\n h = np.array(air_density, copy=True, ndmin=1)\n h *= 1004.\n h *= dt\n h /= rah\n return h", "def fd(f, x, h, fl=np.complex_):\n return n...
[ "0.59818965", "0.5966445", "0.5943252", "0.5894658", "0.5890772", "0.58900493", "0.5870081", "0.5870023", "0.57961464", "0.5784368", "0.5704117", "0.56788325", "0.5656882", "0.5656882", "0.5656882", "0.56452984", "0.56449276", "0.5603406", "0.55940557", "0.555316", "0.5506647...
0.6483614
0
Function that returns boundary points of object's (obstacle) boundary box
def get_boundary_points(self, object_handle): points = [] obstacle_position = self.get_object_position(object_handle) ret, orient = vrep.simxGetObjectOrientation(self.client_id, object_handle, -1, \ vrep.simx_opmode_blocking) ret, x_1 =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def boundingBox(self):\n y_max = np.max(self.points[:,0])\n x_max = np.max(self.points[:,1])\n y_min = np.min(self.points[:,0])\n x_min = np.min(self.points[:,1])\n \n return ((x_max, y_max), (x_min, y_min))", "def real_boundaries(self):\n return (self._points[0][...
[ "0.72273123", "0.72234446", "0.72163844", "0.7175103", "0.70771307", "0.7020583", "0.69548523", "0.6953363", "0.69514775", "0.69397044", "0.6908995", "0.69066787", "0.6904298", "0.6881243", "0.6824278", "0.67831343", "0.67817706", "0.6748717", "0.6698134", "0.669315", "0.6689...
0.7628352
0
Runs basic whitespace cleaning and splitting on a piece of text.
def whitespace_tokenize(text): text = text.strip() if not text: return [] tokens = text.split() return tokens
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tokenize(text):\n return text.split(' ')", "def clean_whitespace(text):\n return text\n #return re.sub(r'\\r\\n|\\n', \"\\t\", text)", "def _split(self):\n \n self._words = []\n \n # (1) Expand contractions\n text = self._text.replace(\"'m \", \" am \")\n tex...
[ "0.6439049", "0.6284847", "0.62824225", "0.6255953", "0.6255953", "0.6255953", "0.62147355", "0.6206382", "0.6165981", "0.61554945", "0.61485386", "0.61298126", "0.6112172", "0.61113316", "0.6097497", "0.60766", "0.6067344", "0.6060772", "0.60185647", "0.6017855", "0.59917736...
0.6300005
1