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 |
|---|---|---|---|---|---|---|
Landing page for support. | def support(request):
return jingo.render(request, 'ecosystem/support.html',
{'page': 'support', 'category': 'build'}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def landing_page():\n\n return render_template('index.html')",
"def support(request):\n return render(request, 'ecosystem/support.html',\n {'page': 'support', 'category': 'build'})",
"def home_page(request):\r\n return render(request, 'ez_main/home_page.html')",
"def landing_page(req... | [
"0.7141835",
"0.70767236",
"0.70286155",
"0.7020918",
"0.697006",
"0.6929728",
"0.6863287",
"0.6836665",
"0.6812963",
"0.67802024",
"0.6773862",
"0.67696095",
"0.6737081",
"0.6737072",
"0.66818017",
"0.6665983",
"0.66654706",
"0.6647602",
"0.6633757",
"0.6633193",
"0.6633193"... | 0.6940305 | 5 |
Creates the Inception Resnet V2 model. | def inception_resnet_v2(inputs,
reuse=None,
scope='InceptionResnetV2'):
end_points = {}
with tf.variable_scope(scope, 'InceptionResnetV2', [inputs], reuse=reuse):
with slim.arg_scope([slim.conv2d, slim.max_pool2d, slim.avg_pool2d],
stride=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_model_inception_v3():\n base_model = tf.keras.applications.InceptionV3(\n include_top=False,\n input_shape=(IMG_SIZE, IMG_SIZE, IMG_CHANNELS)\n )\n model = tf.keras.models.Sequential([\n base_model,\n tf.keras.layers.GlobalAveragePooling2D(),\n tf.keras.laye... | [
"0.6744676",
"0.6727497",
"0.6439699",
"0.64003223",
"0.63465446",
"0.6162748",
"0.61275184",
"0.6122423",
"0.604812",
"0.6020409",
"0.5965477",
"0.5965477",
"0.5965477",
"0.5965477",
"0.5965477",
"0.5960131",
"0.5940005",
"0.5935514",
"0.5896295",
"0.588688",
"0.5865868",
... | 0.613981 | 6 |
Returns True if the user has the 'can_advance_search' permission. | def has_permission(self, request, view):
return has_permission(request.user, Permissions.CAN_ADVANCE_SEARCH) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_search_users(self):\n if self.is_superuser:\n return True\n\n # allow anonymous search users\n if get_setting('module', 'users', 'allowanonymoususersearchuser'):\n return True\n\n # allow user search users\n if get_setting('module', 'users', 'allow... | [
"0.6294999",
"0.6153455",
"0.6138373",
"0.59096414",
"0.5836076",
"0.581368",
"0.578937",
"0.5788327",
"0.5735844",
"0.572073",
"0.570435",
"0.56984746",
"0.5693431",
"0.56538033",
"0.5651187",
"0.56496173",
"0.5635249",
"0.55843014",
"0.55769867",
"0.5561744",
"0.55216855",
... | 0.7794551 | 0 |
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments. | def __init__(self, *args, **kwds):
if args or kwds:
super(Features, self).__init__(*args, **kwds)
#message fields cannot be None, assign default values for those that are
if self.header is None:
self.header = std_msgs.msg.Header()
if self.image_width is None:
self.image_width... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ... | [
"0.77936935",
"0.77195734",
"0.77195734",
"0.76861507",
"0.76260346",
"0.7563092",
"0.7439089",
"0.74163747",
"0.73512906",
"0.73076564",
"0.72798854",
"0.72372425",
"0.7226609",
"0.7223668",
"0.7223668",
"0.7218618",
"0.7210883",
"0.7210883",
"0.7210883",
"0.7210883",
"0.721... | 0.0 | -1 |
Copy weights from one network to another. Optionally copies with Polyak averaging. | def copy_weights(copy_from: nn.Module, copy_to: nn.Module, polyak=None):
if polyak is not None:
for target_param, param in zip(copy_to.parameters(), copy_from.parameters()):
target_param.data.copy_(polyak * param + (1 - polyak) * target_param)
else:
copy_to.load_state_dict(copy_from.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hard_copy_weights(self, target, source):\n for target_param, param in zip(target.parameters(), source.parameters()):\n target_param.data.copy_(param.data)",
"def load_weigths_into_target_network(self):\n logging.debug(\"Transfer Weight!\")\n self.network.save_weights(self._sav... | [
"0.6743146",
"0.65736395",
"0.6488842",
"0.6267655",
"0.6244638",
"0.61854744",
"0.6155884",
"0.6109318",
"0.60702676",
"0.5976342",
"0.5976342",
"0.5972572",
"0.5864322",
"0.5800851",
"0.5753335",
"0.57375103",
"0.5733601",
"0.5721585",
"0.55887544",
"0.5582337",
"0.5561462"... | 0.73075527 | 0 |
Removes step from the wizard sequence. | def remove_step(self, request, step):
steps = self.get_steps(request)
if step in steps:
steps.remove(step) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_step(self):\n idx = self.stepsListWidget.currentRow()\n if len(self.mgr.obj.steps) > 0:\n del self.mgr.obj.steps[idx]\n\n # Flag the Generator as changed\n self.mgr.changed = True\n\n # Refresh lists/tables\n self.load_steps()\n ... | [
"0.8261573",
"0.7557065",
"0.66471654",
"0.66451937",
"0.6586999",
"0.64487106",
"0.61218554",
"0.6114396",
"0.5949584",
"0.59008646",
"0.5868635",
"0.57575274",
"0.5750792",
"0.5652749",
"0.56251156",
"0.56156844",
"0.56103224",
"0.55964226",
"0.5585776",
"0.55698776",
"0.55... | 0.7722685 | 1 |
Given a fully qualified path gets just the file name, without extension | def get_filename(label):
return op.splitext(op.splitext(op.basename(label))[0])[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getfilename(path):\r\n return path.split('\\\\').pop().split('/').pop().rsplit('.', 1)[0]",
"def get_file_name(path: str) -> str:\n return os.path.splitext(os.path.basename(path))[0]",
"def file_name(path):\n return os.path.basename(path).split('.')[0]",
"def get_file_name_with_ext(path: str) ->... | [
"0.86767095",
"0.8656399",
"0.86319417",
"0.84367895",
"0.84334975",
"0.84300536",
"0.8415318",
"0.8402621",
"0.8229649",
"0.82208925",
"0.81956935",
"0.8181871",
"0.81169754",
"0.8077771",
"0.8058005",
"0.79836243",
"0.7912435",
"0.7911167",
"0.78954047",
"0.7809403",
"0.780... | 0.0 | -1 |
Sets up and initializes GPIO for platform. Also sets self._platform | def _init_hardware(self):
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_gpio(self):\n logger.info(\"Setting up GPIO pins\")\n gpio.setmode(gpio.BOARD)\n gpio.setup(self.pins[\"SCLK\"], gpio.OUT)\n gpio.setup(self.pins[\"SDO\"], gpio.OUT)\n gpio.setup(self.pins[\"SDI\"], gpio.IN)\n gpio.setup(self.pins[\"IO_UPDATE\"], gpio.OUT)\n ... | [
"0.7741536",
"0.7545479",
"0.75355583",
"0.74133044",
"0.7247515",
"0.71614397",
"0.7047734",
"0.697941",
"0.69594586",
"0.6947197",
"0.6823976",
"0.681424",
"0.678204",
"0.67785674",
"0.67264336",
"0.6660561",
"0.663437",
"0.6615082",
"0.6607667",
"0.6592249",
"0.6582687",
... | 0.60013676 | 39 |
Find a user with the specified profile slug | def get_by_slug(self, profile_slug):
return User.gql("WHERE profile_slug = :1", profile_slug).get() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_by_slug(self, slug):\n users = self.get_users({ 'profile_url': slug })\n if len(users) > 0:\n return users[0]",
"def get_username_profile(db, username):\n return db['user'].find_one({'username': username})",
"def find_user(self, value, key=\"name\"):\n if not value... | [
"0.80638045",
"0.65579224",
"0.64885336",
"0.64662886",
"0.6301303",
"0.6235031",
"0.6171273",
"0.61613697",
"0.6145804",
"0.6111975",
"0.6018193",
"0.5996949",
"0.5994736",
"0.59891737",
"0.5970464",
"0.5938938",
"0.592821",
"0.5924022",
"0.5922024",
"0.5915598",
"0.59116805... | 0.85294205 | 0 |
Find a user with the specified google id | def get_by_google_id(self, google_id):
return User.gql("WHERE google_id = :1", google_id).get() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(\n user_id=None, discord_id=None, google_id=None, email=None,\n ):\n temp_cursor = user_db.cursor()\n\n pos_selectors = {\n \"user_id\": user_id,\n \"discord_id\": discord_id,\n \"google_id\": google_id,\n \"email\": email,\n }\n\n ... | [
"0.71392584",
"0.712507",
"0.7035926",
"0.6986039",
"0.69133663",
"0.6901022",
"0.67536235",
"0.66529447",
"0.6609614",
"0.660015",
"0.65932477",
"0.65825325",
"0.6550036",
"0.6534064",
"0.6520277",
"0.6517245",
"0.6489986",
"0.64884514",
"0.6468052",
"0.645471",
"0.6444355",... | 0.8106475 | 0 |
Move node down in the tree; restore heap condition after deletion or replacement. | def siftdown(self, node, pos):
c = self.minchild(pos)
while c is not None and self.heap[c].key < node.key:
self.heap[pos] = self.heap[c]
self.heap[pos].pos = pos
pos = c
c = self.minchild(c)
self.heap[pos] = node
node.pos = pos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heapify_down(self):\n index = 0\n while self.has_left_child(index):\n smaller_child_index = self.get_left_child_index(index)\n if self.has_right_child(index) and self.get_right_child(index) < self.get_left_child(index):\n smaller_child_index = self.get_right_c... | [
"0.7428423",
"0.7235141",
"0.705432",
"0.7016701",
"0.69259125",
"0.6842421",
"0.6824583",
"0.6784935",
"0.6733414",
"0.67062294",
"0.669985",
"0.6697912",
"0.6610394",
"0.6569751",
"0.6564386",
"0.6492115",
"0.6401072",
"0.63394696",
"0.63102573",
"0.62963945",
"0.628394",
... | 0.65582484 | 15 |
Move hi up in heap until it's parent is smaller than hi.key | def siftup(self, node, pos):
p = self.parent(pos)
while p is not None and self.heap[p].key > node.key:
self.heap[pos] = self.heap[p]
self.heap[pos].pos = pos
pos = p
p = self.parent(p)
self.heap[pos] = node
node.pos = pos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _upheap(self, node):\n parent = self.parent(node)\n while parent is not None and node.element() < parent.element():\n self._swap(node, parent) # Move node upward while key\n parent = self.parent(node) # smaller than parent's key",
"def heapify_up(self):\n ... | [
"0.7707575",
"0.7410826",
"0.73590356",
"0.73544455",
"0.6957596",
"0.69413173",
"0.69298965",
"0.6896654",
"0.6878417",
"0.6797724",
"0.678814",
"0.67772764",
"0.677413",
"0.67719185",
"0.67536664",
"0.6658071",
"0.6656855",
"0.66416466",
"0.6637386",
"0.6637238",
"0.6567202... | 0.7187986 | 4 |
Return the child of pos with the smallest key | def minchild(self, pos):
minpos = minkey = None
for c in self.children(pos):
if minkey == None or self.heap[c].key < minkey:
minkey, minpos = self.heap[c].key, c
return minpos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_child(self, index):\n if self.empty():\n return None\n if self._has_left(index):\n left = self._left(index)\n small_child = left\n if self._has_right(index):\n right = self._right(index)\n if self._data[right] < self._d... | [
"0.74006736",
"0.7116484",
"0.70543504",
"0.6857358",
"0.6850542",
"0.6751857",
"0.674666",
"0.67175794",
"0.6680468",
"0.66722333",
"0.6585093",
"0.65850776",
"0.65347433",
"0.6527093",
"0.6525669",
"0.65086913",
"0.65037876",
"0.64744943",
"0.647009",
"0.64663863",
"0.64593... | 0.83234566 | 0 |
Timezone the dataset was recorded in. | def timezone(self) -> str:
return self._tz | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timezone(self):\n return self.data.get(\"timezone\")",
"def timezone(self):\n return self._tz",
"def timezone(self):\n return self._timezone",
"def timezone(self):\n return self._timezone",
"def timezone(self):\n return self._timezone",
"def time_zone(self):\n ... | [
"0.7561419",
"0.7258392",
"0.7185377",
"0.7185377",
"0.7185377",
"0.7172306",
"0.7147327",
"0.71362174",
"0.68648845",
"0.6847345",
"0.68342066",
"0.6807863",
"0.6787153",
"0.6710409",
"0.6682241",
"0.6649765",
"0.65786946",
"0.65738446",
"0.648037",
"0.6393906",
"0.6343624",... | 0.6916767 | 8 |
Represents all needed and calculated fields for a song | def __init__(self, song_name, lyrics, valence):
self.name = song_name
self.lyrics = lyrics
self.valence = valence
self.lexD = None
self.emotion = None
self.sentiment = None
self.color = None
self.gloom = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, **kwargs):\n self.paused = self._get('paused', **kwargs)\n self.title = self._get('title', **kwargs)\n self.artist = self._get('artist', **kwargs)\n self.album = self._get('album', **kwargs)\n self.total_time = self._get('total_time', **kwargs)\n self.po... | [
"0.6306602",
"0.6287607",
"0.6179955",
"0.61779034",
"0.61345583",
"0.6006276",
"0.5963658",
"0.5954735",
"0.5890968",
"0.5856833",
"0.5777604",
"0.5751105",
"0.571537",
"0.56615037",
"0.5626021",
"0.56255555",
"0.5610739",
"0.5597043",
"0.54988676",
"0.54967123",
"0.5425968"... | 0.5842779 | 10 |
Once raindrop gets collected, it resets above the map to fall back down again at a random position | def reset_pos(self):
self.rect.x = random.randrange(50, 640)
self.rect.y = random.randrange(-300, -80) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset (self):\n self.seed()\n\n half_range = self.fire.range / 2\n\n _pos = 0\n _loc = round(self.np_random.random() * float(half_range) + half_range)\n self.state = [ _loc, _pos ]\n\n self.reward = -100.0\n self.done = 0\n self.info = {}\n\n retur... | [
"0.6675933",
"0.664267",
"0.63979185",
"0.61980295",
"0.61702466",
"0.61246425",
"0.60906893",
"0.60906893",
"0.60906893",
"0.6087713",
"0.6055687",
"0.6040258",
"0.6033577",
"0.6020524",
"0.59850097",
"0.59743744",
"0.5939368",
"0.59374356",
"0.5936294",
"0.59357095",
"0.592... | 0.61188215 | 6 |
Makes a ListNode object. | def __init__(self, word):
self.data = word
self.next = None
self.count = 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def constructListNode(input_list):\n root = ListNode(0)\n curr = root\n for i in range(len(input_list)):\n curr.next = ListNode(input_list[i])\n curr = curr.next\n return root.next",
"def __init__(self):\n self.head = ListNode()",
"def __init__(self):\n node = ListNode(0... | [
"0.7565334",
"0.7562693",
"0.74412966",
"0.7283934",
"0.7254221",
"0.7254221",
"0.7254221",
"0.7254221",
"0.7254221",
"0.7149055",
"0.71390545",
"0.70629823",
"0.70139253",
"0.70102555",
"0.6979896",
"0.69757533",
"0.675999",
"0.6754366",
"0.67109996",
"0.6614123",
"0.6559729... | 0.0 | -1 |
Parsing None ChaosScheduleActiveDays should return None | def test_parse_none_active_days(self):
res = sf_c.parse_active_days(None)
self.assertIs(res, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parse_none_time_of_day(self):\n\n res = sf_c.parse_time_of_day(None)\n self.assertIs(res, None)",
"def test_parse_valid_active_days(self):\n from azure.servicefabric.models.chaos_schedule_job_active_days_of_week import (\n ChaosScheduleJobActiveDaysOfWeek\n )\n\n ... | [
"0.6751943",
"0.6228337",
"0.59661895",
"0.59067625",
"0.54965144",
"0.5406649",
"0.5333789",
"0.52196527",
"0.5187626",
"0.51385653",
"0.5004968",
"0.49960923",
"0.49754202",
"0.49709788",
"0.49478048",
"0.49429598",
"0.49416745",
"0.49172568",
"0.4917162",
"0.49128798",
"0.... | 0.8040605 | 0 |
Assert that generate_pipeline_code() returns the correct code given a specific pipeline | def test_generate_pipeline_code():
pipeline = ['KNeighborsClassifier',
['CombineDFs',
['GradientBoostingClassifier',
'input_matrix',
38.0,
0.87],
['GaussianNB',
['ZeroCount',
'input_matrix']]],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testHasCode(self):\n begin = 'begin = %s' % uuid.uuid4()\n for_each = 'for_each = %s' % uuid.uuid4()\n end = 'end = %s' % uuid.uuid4()\n generated = build_code([begin], [for_each], [end], concise=True)\n for code in [begin, for_each, end]:\n self.assertIn(code, gen... | [
"0.6514269",
"0.62512493",
"0.6238453",
"0.6202522",
"0.61326873",
"0.60926694",
"0.60866165",
"0.60410506",
"0.5970581",
"0.5970544",
"0.5942894",
"0.58707404",
"0.5852241",
"0.5852133",
"0.58509386",
"0.58175653",
"0.58027273",
"0.5794418",
"0.5774922",
"0.5761395",
"0.5750... | 0.73944086 | 0 |
Assert that exported_pipeline() generated a compile source file as expected given a fixed pipeline | def test_export_pipeline():
tpot_obj = TPOTClassifier()
pipeline = creator.Individual.\
from_string("KNeighborsClassifier(CombineDFs(GradientBoostingClassifier(input_matrix, 38.0, 0.87), SelectKBest(input_matrix, 5)), 18, 33)", tpot_obj._pset)
expected_code = """import numpy as np
from sklearn.ens... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_package_compile(self):\n\n test_data_dir = os.path.join(os.path.dirname(__file__), 'testdata')\n test_package_dir = os.path.join(test_data_dir, 'testpackage')\n tmpdir = tempfile.mkdtemp()\n cwd = os.getcwd()\n try:\n os.chdir(test_package_dir)\n subprocess.check_call(['python3', ... | [
"0.68639344",
"0.6455317",
"0.63941926",
"0.6349713",
"0.6313293",
"0.6239643",
"0.62272173",
"0.61757505",
"0.6166466",
"0.6086911",
"0.5932343",
"0.59191585",
"0.58924156",
"0.5892077",
"0.5885533",
"0.5853605",
"0.5838435",
"0.58301586",
"0.5783722",
"0.5734525",
"0.571869... | 0.53257483 | 60 |
Calibrate a PytorchLightning model for posttraining quantization. | def quantize(model: nn.Module,
precision: str = 'int8',
accelerator: str = None,
use_ipex: bool = False,
calib_dataloader: DataLoader = None,
metric: Metric = None,
accuracy_criterion: dict = None,
app... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_model(engine, batch):\n\t\tengine.model.train()\n\t\tengine.model.rpn.nms_thresh = 0.7\n\t\timg, target = prepare_batch(batch, device=get_device(engine.model))\n\t\tengine.optimizer.zero_grad()\n\t\tloss = engine.model(img, target)\n\t\tlosses = sum(l for l in loss.values())\n\t\tlosses.backward()\n\t\t... | [
"0.6045897",
"0.5802202",
"0.5684414",
"0.56562316",
"0.5616516",
"0.5616516",
"0.56143713",
"0.55853236",
"0.5543913",
"0.5527644",
"0.5527644",
"0.552141",
"0.55189",
"0.54826343",
"0.5478557",
"0.54742044",
"0.5463787",
"0.54626095",
"0.5461075",
"0.5457476",
"0.5454172",
... | 0.0 | -1 |
Filters DataFrames by a particular value within a column. Here used to extract only rows containing first timepoint data. | def flatten(tbl, tpcol, key, val):
tblflat = tbl[tbl[tpcol].isin(val)]
tblflatnm = '%s_flat' %key
return tblflat, tblflatnm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filter(self, col: str, val: Any) -> pd.DataFrame:\n return self._df[self._df[col] == val]",
"def date_filter(frame, date_column, year):\n frame[date_column] = pd.to_datetime(frame[date_column])\n frame = frame[frame[date_column] > pd.Timestamp(year, 1, 1)]\n return frame",
"def filter_valu... | [
"0.63988763",
"0.5993919",
"0.581566",
"0.5697822",
"0.5678616",
"0.5619108",
"0.55870306",
"0.5518542",
"0.55084413",
"0.5481201",
"0.5481201",
"0.5469198",
"0.5467904",
"0.5467396",
"0.54001844",
"0.5356964",
"0.52613497",
"0.52603024",
"0.52583224",
"0.5229005",
"0.5220992... | 0.0 | -1 |
Determine whether the net has reached steady state. | def is_ss(net, tol=None):
if tol is None:
tol = TOL_SS
if net.get_dxdt().abs().max() < tol:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_steady_state(self):\n if isinstance(self.problem, TimeMixin):\n return self.problem.steady_state\n return True",
"def is_stationary(self):\n return self.kernel.is_stationary()",
"def gsteady(self, Ppump):\n return(self.steadystate(Ppump)[1])",
"def active(self):\... | [
"0.7202424",
"0.66788167",
"0.66161233",
"0.64333",
"0.6413577",
"0.63852584",
"0.63334066",
"0.63207936",
"0.62737155",
"0.62597245",
"0.62294275",
"0.6203606",
"0.61802393",
"0.61307913",
"0.6090637",
"0.60816276",
"0.6052147",
"0.60411155",
"0.60320514",
"0.6031736",
"0.60... | 0.0 | -1 |
Find closest element in the array, value wise | def closest_value_index(array, guessValue):
closestValue = find_nearest(array, guessValue)
# Find indices of closestValue
indexArray = numpy.where(array==closestValue)
# Numpys 'where' returns a 2D array with the element index as the value
return indexArray[0][0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closest(array, value):\n idx = (np.abs(array-value)).argmin()\n return idx",
"def _find_nearest(array, value):\n idx = (np.abs(array - value)).argmin()\n return array[idx], idx",
"def find_nearest(value,array):\n idx = numpy.abs(value-array).argmin()\n return idx,array[idx]",
"def find_... | [
"0.8085022",
"0.78891104",
"0.7870643",
"0.78456676",
"0.7834312",
"0.77509147",
"0.77284247",
"0.77284247",
"0.7728113",
"0.7697328",
"0.75947493",
"0.7516948",
"0.7516948",
"0.74335515",
"0.7418442",
"0.74042773",
"0.7394582",
"0.7389139",
"0.7236985",
"0.7231881",
"0.72061... | 0.66647863 | 32 |
Unicode representation of Articulo. | def __str__(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toString(self) -> unicode:\n ...",
"def toString(self) -> unicode:\n ...",
"def __unicode__(self):\n return str(self).decode('ascii')",
"def unicode2ascii(_unicrap):\n xlate = {0xc0:'A', 0xc1:'A', 0xc2:'A', 0xc3:'A', 0xc4:'A', 0xc5:'A',\n 0xc6:'Ae', 0xc7:'C',\n 0xc8:... | [
"0.6250393",
"0.6250393",
"0.6174033",
"0.61650753",
"0.60823303",
"0.5997192",
"0.5973202",
"0.59636295",
"0.5919765",
"0.58358103",
"0.5712334",
"0.56707996",
"0.56419504",
"0.5637994",
"0.5606472",
"0.559777",
"0.55942786",
"0.55942786",
"0.55901283",
"0.55791634",
"0.5552... | 0.0 | -1 |
Setup the model and optimizer which are used in every test method. | def setUp(self):
img_path = osp.join(osp.dirname(__file__), '../../data/gray.jpg')
self.results = {
'img_path':
img_path,
'img_shape': (300, 400),
'instances': [{
'bbox': [0, 0, 10, 20],
'bbox_label': 1,
'mas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(self):\n self.model.monitor = myMonitor.get_monitor(self.model)\n self.model.monitor.time_budget_exceeded = False\n if self.algorithm is not None:\n self.algorithm.setup(model=self.model, dataset=self.dataset)\n self.setup_extensions()\n\n # Model.modify_upda... | [
"0.7305137",
"0.697892",
"0.69494593",
"0.69275254",
"0.6853147",
"0.684245",
"0.6789481",
"0.678464",
"0.6770382",
"0.6764707",
"0.67071134",
"0.67024434",
"0.6692876",
"0.6688242",
"0.66820997",
"0.66749924",
"0.6672053",
"0.6646978",
"0.6620903",
"0.6616007",
"0.6613408",
... | 0.0 | -1 |
Function that reads from a json string | def from_json_string(my_str):
import json
return json.loads(my_str) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_json(json_string):\n return json.loads(json_string)",
"def from_json_string(my_str):\n return loads(my_str)",
"def load_json(json_str):\n return _api_internal._load_json(json_str)",
"def from_string(string):\n # in order to complete this lab we are going to use the python lib json in... | [
"0.780601",
"0.7705444",
"0.76354706",
"0.7567893",
"0.75404316",
"0.75404316",
"0.75404316",
"0.7509352",
"0.7487973",
"0.7487973",
"0.7417874",
"0.74161947",
"0.7405414",
"0.7405414",
"0.7405414",
"0.7387246",
"0.7341651",
"0.7283647",
"0.7267272",
"0.7260823",
"0.72325665"... | 0.76089454 | 3 |
Equality comparator for when priority nodes are equal | def __eq__(self, other: 'PriorityNode') -> bool:
return self.priority == other.priority and self.value == other.value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_nodes(n1, n2):\n return n1['g_val'] + n1['h_val'] < n2['g_val'] + n2['h_val']",
"def __gt__(self, other: 'MinNode') -> bool:\n if self.priority == other.priority:\n return self.value > other.value\n return self.priority > other.priority",
"def __lt__(self, other):\n ... | [
"0.6305053",
"0.62454695",
"0.6221857",
"0.6221857",
"0.6221857",
"0.6217803",
"0.621271",
"0.62051886",
"0.61851126",
"0.61149734",
"0.6093743",
"0.60841876",
"0.6032718",
"0.60225785",
"0.5988181",
"0.5834206",
"0.5746631",
"0.57331556",
"0.5729711",
"0.57255316",
"0.570965... | 0.68058455 | 0 |
Less than comparator. Determines if self is greater than other node, and thus should be sorted lower than other node in priority queue | def __lt__(self, other: 'MaxNode') -> bool:
if self.priority == other.priority:
return self.value > other.value
return self.priority > other.priority | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __lt__(self, other):\n return self.priority < other.priority",
"def __lt__(self, other):\n return self.priority < other.priority",
"def __lt__(self, other):\n return self.priority < other.priority",
"def __lt__(self, other: 'MinNode') -> bool:\n if self.priority == other.prior... | [
"0.8083019",
"0.8083019",
"0.8083019",
"0.80802006",
"0.80214477",
"0.79048234",
"0.7758918",
"0.7649571",
"0.75990796",
"0.7569564",
"0.7545615",
"0.74122584",
"0.73777735",
"0.73719496",
"0.73099464",
"0.73099464",
"0.72618645",
"0.72574604",
"0.72574604",
"0.7256262",
"0.7... | 0.80635387 | 4 |
Less than comparator. Determines if self node is less than other node, and thus should be sorted higher than other node in priority queue | def __lt__(self, other: 'MinNode') -> bool:
if self.priority == other.priority:
return self.value < other.value
return self.priority < other.priority | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __lt__(self, other):\n return self.priority < other.priority",
"def __lt__(self, other):\n return self.priority < other.priority",
"def __lt__(self, other):\n return self.priority < other.priority",
"def __lt__(self, other):\n return self._priority < other._priority",
"def _... | [
"0.80030835",
"0.80030835",
"0.80030835",
"0.794239",
"0.79020095",
"0.7818099",
"0.75934714",
"0.75028694",
"0.7470647",
"0.74481285",
"0.74137795",
"0.73580897",
"0.7299327",
"0.7247052",
"0.72315484",
"0.72315484",
"0.7225977",
"0.7192972",
"0.7183324",
"0.7181078",
"0.718... | 0.7988938 | 3 |
Retrieve all the values of a nested key in a dictionary. Paths containing the string '' are interpreted as any node and are yielded one by one. | def _resolve_paths(d, path):
try:
if len(path) == 0:
yield (), d
elif len(path) == 1:
yield (path[0],), d[path[0]]
else:
if path[0] == '*':
keys = d.keys()
else:
keys = [pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RecurseKeys(self):\n yield self\n for subkey in self.GetSubkeys():\n for key in subkey.RecurseKeys():\n yield key",
"def get_values(self, ckey):\n for next_key, item in yield_obj(self, ckey):\n if isdictinstance(item):\n for final, elem in yield_obj(item, n... | [
"0.6841909",
"0.6771018",
"0.6606681",
"0.65377074",
"0.6517077",
"0.6495936",
"0.6471605",
"0.64644504",
"0.64212",
"0.6416361",
"0.6390183",
"0.6344546",
"0.633108",
"0.63248146",
"0.63227946",
"0.6247362",
"0.6218378",
"0.6199879",
"0.6160294",
"0.60877275",
"0.60766244",
... | 0.6051408 | 21 |
Check whether the given value is a listlike object or not. Returns Flase if value is a string or not iterable, True otherwise. | def is_iterable_container(value):
# strings are iterable too so we have to treat them as a special case
return not isinstance(value, str) and isinstance(value, collections.Iterable) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_list_like(value):\n if is_iterable(value) and not isinstance(value, six.string_types):\n return True\n\n else:\n return False",
"def _list_like(self, value):\n return (not hasattr(value, \"strip\") and\n (hasattr(value, \"__getitem__\") or\n hasattr(value, ... | [
"0.876554",
"0.8191456",
"0.81497395",
"0.80453247",
"0.8024011",
"0.79769915",
"0.79546684",
"0.7923328",
"0.78632766",
"0.7819619",
"0.76024616",
"0.7489555",
"0.7482828",
"0.7408834",
"0.7395987",
"0.7352859",
"0.7319182",
"0.72246915",
"0.721369",
"0.720826",
"0.7163422",... | 0.7247233 | 17 |
Serialize topology to string. | def serialize_topology(topology):
# Check if we need to convert the topology to mdtraj
if isinstance(topology, mdtraj.Topology):
mdtraj_top = topology
else:
mdtraj_top = mdtraj.Topology.from_openmm(topology)
atoms, bonds = mdtraj_top.to_dataframe()
separators = (',', ':') # don't d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_topology_to_string(shape, level=0, buffer=\"\"):\n brt = BRep_Tool()\n s = shape.ShapeType()\n if s == TopAbs_VERTEX:\n pnt = brt.Pnt(topods_Vertex(shape))\n print(\"..\" * level + \"<Vertex %i: %s %s %s>\\n\" % (\n hash(shape), pnt.X(), pnt.Y(), pnt.Z()))\n else:\n ... | [
"0.6994054",
"0.69807374",
"0.67042637",
"0.6632102",
"0.661653",
"0.66044927",
"0.6583388",
"0.6529209",
"0.64980805",
"0.645073",
"0.643685",
"0.643685",
"0.64295405",
"0.6403917",
"0.63885576",
"0.6282763",
"0.6276511",
"0.62753433",
"0.62753433",
"0.62516814",
"0.6248344"... | 0.70903414 | 0 |
Serialize topology to string. | def deserialize_topology(serialized_topology):
topology_dict = json.loads(serialized_topology)
atoms = pandas.read_json(topology_dict['atoms'], orient='records')
bonds = np.array(topology_dict['bonds'])
topology = mdtraj.Topology.from_dataframe(atoms, bonds)
return topology | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_topology(topology):\n # Check if we need to convert the topology to mdtraj\n if isinstance(topology, mdtraj.Topology):\n mdtraj_top = topology\n else:\n mdtraj_top = mdtraj.Topology.from_openmm(topology)\n\n atoms, bonds = mdtraj_top.to_dataframe()\n separators = (',', ':... | [
"0.70903414",
"0.6994054",
"0.69807374",
"0.67042637",
"0.6632102",
"0.661653",
"0.66044927",
"0.6583388",
"0.6529209",
"0.64980805",
"0.645073",
"0.643685",
"0.643685",
"0.64295405",
"0.6403917",
"0.63885576",
"0.6282763",
"0.6276511",
"0.62753433",
"0.62753433",
"0.62516814... | 0.0 | -1 |
Convert the given string from underscore_case to camelCase. Underscores at the beginning or at the end of the string are ignored. All underscores in the middle of the string are removed. | def underscore_to_camelcase(underscore_str):
# Count leading and trailing '_' characters
n_leading = re.search(r'[^_]', underscore_str)
if n_leading is None: # this is empty or contains only '_'s
return underscore_str
n_leading = n_leading.start()
n_trailing = re.search(r'[^_]', underscore_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lower_case_underscore_to_camel_case(string):\n splitted_string = string.split('_')\n # use string's class to work on the string to keep its type\n class_ = string.__class__\n return class_.join('', map(class_.capitalize, splitted_string))",
"def to_camel_case(s):\n if s[:1].isupper() and '_' n... | [
"0.8334214",
"0.82076305",
"0.8174703",
"0.81237626",
"0.81176054",
"0.81013364",
"0.8046013",
"0.7915276",
"0.7866924",
"0.78094685",
"0.7762325",
"0.77048254",
"0.7701489",
"0.7678666",
"0.76629364",
"0.7653981",
"0.7613958",
"0.754442",
"0.7543234",
"0.7501239",
"0.7492149... | 0.851316 | 0 |
Convert the given string from camelCase to underscore_case. | def camelcase_to_underscore(camelcase_str):
underscore_str = re.sub(r'([A-Z])', '_\g<1>', camelcase_str)
return underscore_str.lower() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def underscore(string):\n # NOTE(retr0h): Taken from jpvanhal/inflection\n # https://github.com/jpvanhal/inflection\n string = re.sub(r\"([A-Z]+)([A-Z][a-z])\", r\"\\1_\\2\", string)\n string = re.sub(r\"([a-z\\d])([A-Z])\", r\"\\1_\\2\", string)\n string = string.replace(\"-\", \"_\")\n\n return... | [
"0.832528",
"0.8259162",
"0.787637",
"0.7859887",
"0.78386825",
"0.7825418",
"0.77342176",
"0.7729359",
"0.7611293",
"0.75300956",
"0.746375",
"0.7407295",
"0.7360585",
"0.72856396",
"0.7277373",
"0.7224132",
"0.7221523",
"0.7220971",
"0.7196418",
"0.71664214",
"0.70946884",
... | 0.83982015 | 0 |
Finds the closest two points in two polytopes and their distance. It is zero if polytopes have nonempty intersection | def distance_polytopes(Q1,Q2,ball="infinity",solver="gurobi"):
Q1,Q2=pp.to_AH_polytope(Q1),pp.to_AH_polytope(Q2)
n=Q1.n
prog=MP.MathematicalProgram()
zeta1=prog.NewContinuousVariables(Q1.P.H.shape[1],1,"zeta1")
zeta2=prog.NewContinuousVariables(Q2.P.H.shape[1],1,"zeta2")
delta=prog.NewContinuous... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closest_points(self, other):\n p0_other, p1_other = other.p0, other.p1\n\n # w = p1 - p0\n # v = p1_other - p0_other\n # s*w + p0 = t*v + p0_other\n\n w = self.p1 - self.p0\n v = p1_other - p0_other\n\n A = np.vstack((w,v)).T\n b = p0_other - self.p0\n\n ... | [
"0.7163431",
"0.716085",
"0.70670956",
"0.70428723",
"0.700006",
"0.69354475",
"0.6909527",
"0.69041294",
"0.68911296",
"0.6878483",
"0.68710345",
"0.68042463",
"0.67956144",
"0.67917985",
"0.67637295",
"0.67606354",
"0.67465806",
"0.671405",
"0.6709906",
"0.67097384",
"0.669... | 0.0 | -1 |
Perform image patch extraction with specific heightwidth sliding window by stepsize if no specific window size, the input image will be split into 4 patches equally as default | def subimage(path_image, height=None, width=None, stepsize=1):
img = cv2.imread(path_image)
h, w = img.shape[:2]
if height is None or width is None:
height = int(h / 2)
width = int(w / 2)
stepsize = width
for x in range(0, h, stepsize):
px = x
end_x = x + height... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sliding_window(image, patch_size: tuple, step: int, show_debug: bool = False) -> list:\n if isinstance(image, Image.Image):\n image = np.array(image)\n\n if step == 0:\n h, w = image.shape[0], image.shape[1] # 720, 1280\n w_iter, h_iter = w // patch_size[0], h // patch_size[1]\n ... | [
"0.73611057",
"0.7248055",
"0.6630848",
"0.6567142",
"0.6476218",
"0.6436784",
"0.6407254",
"0.6360954",
"0.6277561",
"0.6221146",
"0.61922",
"0.6177711",
"0.61571825",
"0.608918",
"0.5951996",
"0.5918592",
"0.5918239",
"0.5916951",
"0.5910459",
"0.5817856",
"0.5792767",
"0... | 0.5650704 | 36 |
Forward a batch of examples; step the optimizer to update weights. | def update(self, ex):
if not self.optimizer:
raise RuntimeError('No optimizer set.')
# Train mode
self.network.train()
source_ids = ex['source_ids']
source_pos_ids = ex['source_pos_ids']
source_type_ids = ex['source_type_ids']
source_mask =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, batch):\n self.output = np.dot(np.array(batch), self.weights) + self.biases",
"def forward(self, batch):\n raise NotImplementedError",
"def forward(self, batch):\n raise NotImplementedError",
"def _forward(self,\n batch_inputs: dict,\n batch_... | [
"0.755966",
"0.7365022",
"0.7365022",
"0.71350104",
"0.70242864",
"0.6970409",
"0.68549407",
"0.6843882",
"0.6682936",
"0.66230994",
"0.65783733",
"0.65695024",
"0.65522337",
"0.6531368",
"0.65215904",
"0.65200007",
"0.650741",
"0.6493124",
"0.6490873",
"0.64697593",
"0.64479... | 0.0 | -1 |
Cast np.long64 array to a pointer to long 64s. | def _as_u64_array(array):
return ffi.cast("unsigned long int*", array.ctypes.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def memory_read64(self, addr, num_long_words):\n buf_size = num_long_words\n buf = (ctypes.c_ulonglong * buf_size)()\n units_read = self._dll.JLINKARM_ReadMemU64(addr, buf_size, buf, 0)\n if units_read < 0:\n raise errors.JLinkException(units_read)\n\n return buf[:unit... | [
"0.64104253",
"0.6091199",
"0.5973906",
"0.5877257",
"0.5874388",
"0.58734906",
"0.5854478",
"0.57825345",
"0.56832486",
"0.55650955",
"0.5543634",
"0.55245477",
"0.5479692",
"0.5333816",
"0.53311026",
"0.5321107",
"0.52858675",
"0.5259048",
"0.5251764",
"0.5251611",
"0.52495... | 0.7214756 | 0 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0)
res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Compute knowledgedistillation (KD) loss given [scores] and [target_scores]. Both [scores] and [target_scores] should be tensors, although [target_scores] should be repackaged. | def dist_loss(self, scores, target_scores, T=2.):
log_scores_norm = F.log_softmax(scores / T, dim=1)
targets_norm = F.softmax(target_scores / T, dim=1)
# Calculate distillation loss (see e.g., Li and Hoiem, 2017)
KD_loss_unnorm = -(targets_norm * log_scores_norm)
KD_loss_unnorm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def criterion_kd(helper, outputs, targets, teacher_outputs):\n alpha = helper.alpha\n T = helper.temperature\n KD_loss = torch.nn.KLDivLoss()(torch.nn.functional.log_softmax(outputs/T, dim=1),\n torch.nn.functional.softmax(teacher_outputs/T, dim=1)) * (alpha * T * T) + \\\n ... | [
"0.66889256",
"0.647368",
"0.6352336",
"0.6297619",
"0.6290931",
"0.62591076",
"0.62270427",
"0.62127155",
"0.6198624",
"0.61758053",
"0.6124072",
"0.60418004",
"0.6023914",
"0.60148126",
"0.60147744",
"0.60116273",
"0.59878206",
"0.59826034",
"0.59289175",
"0.59205925",
"0.5... | 0.7841524 | 0 |
Initialise a new Quaternion object. | def __init__(self, *args, **kwargs):
s = len(args)
if s is 0:
# No positional arguments supplied
if len(kwargs) > 0:
# Keyword arguments provided
if ("scalar" in kwargs) or ("vector" in kwargs):
scalar = kwargs.get("scalar", 0.0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name, times, w, x, y, z):\n w = numpy.array(w)\n x = numpy.array(x)\n y = numpy.array(y)\n z = numpy.array(z)\n assert len(w.shape) == 1\n assert len(x.shape) == 1\n assert len(y.shape) == 1\n assert len(z.shape) == 1\n values = nump... | [
"0.6897372",
"0.6721299",
"0.6637888",
"0.6518855",
"0.63873243",
"0.63672495",
"0.63110554",
"0.6310234",
"0.6300406",
"0.61213624",
"0.6093357",
"0.60226864",
"0.601507",
"0.59054023",
"0.58775455",
"0.5865946",
"0.58049446",
"0.5797647",
"0.57817876",
"0.57591516",
"0.5710... | 0.6778208 | 1 |
Initialise from matrix representation Create a Quaternion by specifying the 3x3 rotation or 4x4 transformation matrix (as a numpy array) from which the quaternion's rotation should be created. | def _from_matrix(cls, matrix):
try:
shape = matrix.shape
except AttributeError:
raise TypeError("Invalid matrix type: Input must be a 3x3 or 4x4 numpy array or matrix")
if shape == (3, 3):
R = matrix
elif shape == (4,4):
R = matrix[:-1][:,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_quaternion(self, q: np.ndarray) -> np.ndarray:\n if q is None:\n return np.identity(3)\n if q.shape[-1]!=4 or q.ndim>2:\n raise ValueError(\"Quaternion must be of the form (4,) or (N, 4)\")\n if q.ndim>1:\n q /= np.linalg.norm(q, axis=1)[:, None] #... | [
"0.7311851",
"0.72665644",
"0.72580254",
"0.7106785",
"0.7086884",
"0.7077216",
"0.7066465",
"0.7046833",
"0.7022371",
"0.69664466",
"0.69632995",
"0.6948709",
"0.691855",
"0.69097525",
"0.6898305",
"0.68966854",
"0.68948305",
"0.6890741",
"0.6871614",
"0.68650794",
"0.685491... | 0.0 | -1 |
Initialise from axis and angle representation Create a Quaternion by specifying the 3vector rotation axis and rotation angle (in radians) from which the quaternion's rotation should be created. | def _from_axis_angle(cls, axis, angle):
mag_sq = np.dot(axis, axis)
if mag_sq == 0.0:
raise ZeroDivisionError("Provided rotation axis has no length")
# Ensure axis is in unit vector form
if (abs(1.0 - mag_sq) > 1e-12):
axis = axis / sqrt(mag_sq)
theta = an... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fromAngleAxis(cls,angle,axis):\n from axis_angle import AxisAngle\n return AxisAngle(angle,axis).asQuat()",
"def angle_axis_to_quaternion(axis, theta):\n if isinstance(axis, string_types):\n axis = axis.lower()\n if axis == 'x':\n axis = np.array([1., 0., 0.])\n ... | [
"0.7607799",
"0.7275667",
"0.715811",
"0.70364606",
"0.69666624",
"0.6937144",
"0.69287485",
"0.68918985",
"0.6835804",
"0.68086904",
"0.6702957",
"0.6622921",
"0.66170025",
"0.6616207",
"0.6504553",
"0.6482632",
"0.64641374",
"0.64623475",
"0.644495",
"0.642536",
"0.639625",... | 0.6638207 | 11 |
Generate a random unit quaternion. Uniformly distributed across the rotation space | def random(cls):
r1, r2, r3 = np.random.random(3)
q1 = sqrt(1.0 - r1) * (sin(2 * pi * r2))
q2 = sqrt(1.0 - r1) * (cos(2 * pi * r2))
q3 = sqrt(r1) * (sin(2 * pi * r3))
q4 = sqrt(r1) * (cos(2 * pi * r3))
return cls(q1, q2, q3, q4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rand(cls):\n q_vec = np.random.rand(4)\n q=Quat(q_vec)\n q.normalize()\n return q",
"def random_quaternion():\n\n import numpy as np\n \n while True: # Loop until within unit disk\n zeta = 2.0*np.random.rand(2) - 1.0 # Two uniform random numbers between -1 and 1\n ... | [
"0.7808249",
"0.77805984",
"0.76898515",
"0.74918467",
"0.7350321",
"0.7183589",
"0.6769476",
"0.66111594",
"0.6439313",
"0.64386076",
"0.63275373",
"0.6287318",
"0.62708724",
"0.6242244",
"0.623126",
"0.614464",
"0.6102751",
"0.6048292",
"0.6038024",
"0.60299873",
"0.6027124... | 0.5489763 | 68 |
The 'official' string representation of the Quaternion object. This is a string representation of a valid Python expression that could be used to recreate an object with the same value (given an appropriate environment) | def __repr__(self):
return "Quaternion({}, {}, {}, {})".format(repr(self.q[0]), repr(self.q[1]), repr(self.q[2]), repr(self.q[3])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n result = \"Quaternion (%g (%g %g %g))\" % \\\n (self.real, self.pure[0],\n self.pure[1], self.pure[2])\n return result",
"def __repr__(self):\n if self.real != 1.:\n # if it is not the identity\n theta = numpy.arcco... | [
"0.7770647",
"0.7500261",
"0.7483202",
"0.6888256",
"0.6367992",
"0.6189208",
"0.6144917",
"0.6097079",
"0.6037099",
"0.5956855",
"0.58912826",
"0.5878482",
"0.5868978",
"0.5843426",
"0.5842367",
"0.5837517",
"0.5830067",
"0.5826384",
"0.58114",
"0.5803914",
"0.58015555",
"... | 0.76403445 | 1 |
Object is guaranteed to be a unit quaternion after calling this operation UNLESS the object is equivalent to Quaternion(0) | def _normalise(self):
if not self.is_unit():
n = self.norm
if n > 0:
self.q = self.q / n | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero() -> Quaternion:\n return Quaternion(0, np.array([0, 0, 0]))",
"def test_to_quaternion(self):\r\n R = np.identity(3)\r\n q = to_quaternion(R)\r\n zero_vec = q - np.array([0., 0., 0., 1.])\r\n self.assertAlmostEqual(np.linalg.norm(zero_vec), 0.0)\r\n\r\n for _ in... | [
"0.7535643",
"0.7168846",
"0.6997174",
"0.66790915",
"0.6593965",
"0.6468035",
"0.6324596",
"0.63066006",
"0.62732565",
"0.6255501",
"0.6251131",
"0.62226933",
"0.6213367",
"0.62131196",
"0.6187813",
"0.6168961",
"0.6168445",
"0.61574817",
"0.61496484",
"0.6133883",
"0.611794... | 0.0 | -1 |
Normalise the object to a unit quaternion using a fast approximation method if appropriate. Object is guaranteed to be a quaternion of approximately unit length after calling this operation UNLESS the object is equivalent to Quaternion(0) | def _fast_normalise(self):
if not self.is_unit():
mag_squared = np.dot(self.q, self.q)
if (mag_squared == 0):
return
if (abs(1.0 - mag_squared) < 2.107342e-08):
mag = ((1.0 + mag_squared) / 2.0) # More efficient. Pade approximation valid if er... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalised(self):\n q = Quaternion(self)\n q._normalise()\n return q",
"def normalize(self):\n mag = np.linalg.norm(self.array)\n if mag > 0:\n arr_norm = self.array/mag\n self.__scalar = arr_norm[0]\n self.__vector = arr_norm[1:]\n e... | [
"0.75308925",
"0.73575425",
"0.70829713",
"0.6964013",
"0.68823934",
"0.660373",
"0.6467085",
"0.63059",
"0.63022935",
"0.6156565",
"0.61265516",
"0.6031479",
"0.6026007",
"0.59281176",
"0.5878548",
"0.5857076",
"0.5798119",
"0.5797967",
"0.5781102",
"0.5756461",
"0.5749534",... | 0.66503847 | 5 |
Get a unit quaternion (versor) copy of this Quaternion object. A unit quaternion has a `norm` of 1.0 | def normalised(self):
q = Quaternion(self)
q._normalise()
return q | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inv(self) -> Quaternion:\n return self.conj() / self.squared_norm()",
"def inverse(self):\n real = self.real / self.magnitude()\n pure = -self.pure / self.magnitude()\n return Quaternion((real, pure))",
"def normalize(self):\n mag = np.linalg.norm(self.array)\n if ... | [
"0.73017275",
"0.7217264",
"0.66402215",
"0.64759904",
"0.64233994",
"0.64149874",
"0.6369355",
"0.63609916",
"0.6350557",
"0.63467",
"0.6337341",
"0.6308332",
"0.6296443",
"0.6281762",
"0.6256192",
"0.6226858",
"0.621434",
"0.6213358",
"0.61562926",
"0.60837024",
"0.6081556"... | 0.7736335 | 0 |
Returns the unit vector and angle of a nonscalar quaternion according to the following decomposition q = q.norm() (e (q.polar_unit_vector q.polar_angle)) | def polar_decomposition(self):
return self.polar_unit_vector, self.polar_angle | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quaternion_about_axis(angle, axis):\r\n q = numpy.array([0.0, axis[0], axis[1], axis[2]])\r\n qlen = vector_norm(q)\r\n if qlen > _EPS:\r\n q *= math.sin(angle/2.0) / qlen\r\n q[0] = math.cos(angle/2.0)\r\n return q",
"def getUnitVector(self):\n return Vector.createFromPolar(1, s... | [
"0.65412503",
"0.6414882",
"0.6218068",
"0.62039655",
"0.6191646",
"0.61067235",
"0.60998684",
"0.6094069",
"0.6078345",
"0.6064933",
"0.6041016",
"0.6040501",
"0.6029711",
"0.59812486",
"0.59776986",
"0.5933573",
"0.5933448",
"0.5911293",
"0.59072775",
"0.5906337",
"0.584986... | 0.6508488 | 1 |
Determine whether the quaternion is of unit length to within a specified tolerance value. | def is_unit(self, tolerance=1e-14):
return abs(1.0 - self._sum_of_squares()) < tolerance # if _sum_of_squares is 1, norm is 1. This saves a call to sqrt() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quaternion_is_valid(quat, tol=10e-3):\n valid = abs((quat.w * quat.w\n + quat.x * quat.x\n + quat.y * quat.y\n + quat.z * quat.z) - 1.0) < tol\n\n return valid",
"def _check_within_tolerance(value, tolerance):\n return tf.norm(tensor=value, ord=np.inf) <= tolerance",
"def is_at_... | [
"0.68738914",
"0.65428126",
"0.6324549",
"0.60699326",
"0.5997036",
"0.56748796",
"0.56247234",
"0.5591194",
"0.55745167",
"0.55745167",
"0.5517766",
"0.55006254",
"0.54480755",
"0.5434748",
"0.5421352",
"0.5407257",
"0.5398202",
"0.5387196",
"0.5370689",
"0.53618497",
"0.534... | 0.69816524 | 0 |
Rotate a quaternion vector using the stored rotation. | def _rotate_quaternion(self, q):
self._normalise()
return self * q * self.conjugate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate(self, vector):\n if isinstance(vector, Quaternion):\n return self._rotate_quaternion(vector)\n q = Quaternion(vector=vector)\n a = self._rotate_quaternion(q).vector\n if isinstance(vector, list):\n l = [x for x in a]\n return l\n elif i... | [
"0.76396304",
"0.7476263",
"0.71210253",
"0.7065472",
"0.7030398",
"0.6957803",
"0.6939218",
"0.69356614",
"0.6892578",
"0.68725437",
"0.68480575",
"0.68452024",
"0.6836982",
"0.68085814",
"0.6804264",
"0.67511916",
"0.6740954",
"0.6723454",
"0.6708862",
"0.66999793",
"0.6694... | 0.71828383 | 2 |
Rotate a 3D vector by the rotation stored in the Quaternion object. | def rotate(self, vector):
if isinstance(vector, Quaternion):
return self._rotate_quaternion(vector)
q = Quaternion(vector=vector)
a = self._rotate_quaternion(q).vector
if isinstance(vector, list):
l = [x for x in a]
return l
elif isinstance(vec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rotate_vec_z(self):\n\n quat = Quat.from_axis_angle_deg(Vec3(0, 0, 1), 90.)\n vec = Vec3(1, 1, 1)\n\n rotated_vec = quat.rotate_vec(vec)\n\n # 90 deg around z moves x from positive to negative\n self.assertAlmostEqual(-1.0, rotated_vec.x)\n self.assertAlmostEqual(... | [
"0.7442001",
"0.7393339",
"0.731943",
"0.72554666",
"0.7035626",
"0.6974383",
"0.69246083",
"0.6871868",
"0.6820391",
"0.6768539",
"0.6747768",
"0.6736577",
"0.67314655",
"0.67116624",
"0.671004",
"0.66535336",
"0.66430235",
"0.6558954",
"0.64195323",
"0.6416659",
"0.6406163"... | 0.70270586 | 5 |
Quaternion Exponential. Find the exponential of a quaternion amount. | def exp(cls, q):
tolerance = 1e-17
v_norm = np.linalg.norm(q.vector)
vec = q.vector
if v_norm > tolerance:
vec = vec / v_norm
magnitude = exp(q.scalar)
return Quaternion(scalar = magnitude * cos(v_norm), vector = magnitude * sin(v_norm) * vec) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exponential(self) -> np.ndarray:\n if self.is_real():\n return np.array([1.0, 0.0, 0.0, 0.0])\n t = np.linalg.norm(self.v)\n u = self.v/t\n q_exp = np.array([np.cos(t), *u*np.sin(t)])\n if self.is_pure():\n return q_exp\n q_exp *= np.e**self.w\n ... | [
"0.71114075",
"0.6922064",
"0.6761784",
"0.6698097",
"0.6566796",
"0.65662146",
"0.6518922",
"0.6505434",
"0.6247588",
"0.62259674",
"0.6218284",
"0.6157853",
"0.61036587",
"0.6096547",
"0.6088416",
"0.6058496",
"0.6023043",
"0.6014042",
"0.6004124",
"0.59977245",
"0.5985327"... | 0.74731445 | 0 |
Quaternion logarithm map. Find the logarithm map on the quaternion Riemannian manifold. | def log_map(cls, q, p):
return Quaternion.log(q.inverse * p) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sym_log_map(cls, q, p):\n inv_sqrt_q = (q ** (-0.5))\n return Quaternion.log(inv_sqrt_q * p * inv_sqrt_q)",
"def log_map(b, x):\n \"\"\"\n LOG_MAP The log map for n-spheres\n b is the base point (vector in R^n), norm(b)=1\n x is a point on the hypersphere (also a vector in R^n), nor... | [
"0.74002033",
"0.66031426",
"0.6584412",
"0.65297574",
"0.6411896",
"0.6162951",
"0.5666967",
"0.56575906",
"0.56152904",
"0.5504425",
"0.5459028",
"0.5364058",
"0.53350645",
"0.5331771",
"0.53280705",
"0.5313443",
"0.53013915",
"0.5296036",
"0.5293389",
"0.52798086",
"0.5272... | 0.7831674 | 0 |
Quaternion absolute distance. Find the distance between two quaternions accounting for the sign ambiguity. | def absolute_distance(cls, q0, q1):
q0_minus_q1 = q0 - q1
q0_plus_q1 = q0 + q1
d_minus = q0_minus_q1.norm
d_plus = q0_plus_q1.norm
if (d_minus < d_plus):
return d_minus
else:
return d_plus | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quat_diff(q1, q2):\n q1 = np.asarray(q1)\n if np.dot(q1, q2) < 0:\n # Quaternions have opposite handedness, flip q1 since it's already an ndarray\n q1 = -1 * q1\n q_inv = q1 * np.array([1.0, -1.0, -1.0, -1.0])\n q_inv = q_inv / np.dot(q_inv, q_inv)\n\n # We only coare about the sca... | [
"0.7377739",
"0.7291456",
"0.70072335",
"0.6939972",
"0.6732121",
"0.6577006",
"0.64560276",
"0.63659805",
"0.6324358",
"0.62470526",
"0.6202936",
"0.61523676",
"0.6135933",
"0.6099799",
"0.6084546",
"0.60820466",
"0.60458064",
"0.60227257",
"0.6012722",
"0.6000179",
"0.59724... | 0.66975385 | 5 |
Quaternion symmetrized distance. Find the intrinsic symmetrized geodesic distance between q0 and q1. | def sym_distance(cls, q0, q1):
q = Quaternion.sym_log_map(q0, q1)
return q.norm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(cls, q0, q1):\n q = Quaternion.log_map(q0, q1)\n return q.norm",
"def sym_distance(p, q):\n p = np.asarray(p)\n q = np.asarray(q)\n return np.minimum(norm(p - q), norm(p + q))",
"def quat_diff(q1, q2):\n q1 = np.asarray(q1)\n if np.dot(q1, q2) < 0:\n # Quaternio... | [
"0.7509909",
"0.7185872",
"0.7014478",
"0.6989046",
"0.671862",
"0.6536577",
"0.637598",
"0.62886834",
"0.62637776",
"0.6256937",
"0.62506646",
"0.6205324",
"0.6186371",
"0.61693656",
"0.6162809",
"0.61626226",
"0.6064064",
"0.6045683",
"0.60238117",
"0.5996324",
"0.5962996",... | 0.84585714 | 0 |
Spherical Linear Interpolation between quaternions. | def slerp(cls, q0, q1, amount=0.5):
# Ensure quaternion inputs are unit quaternions and 0 <= amount <=1
q0._fast_normalise()
q1._fast_normalise()
amount = np.clip(amount, 0, 1)
dot = np.dot(q0.q, q1.q)
# If the dot product is negative, slerp won't take the shorter path.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getValue(self, *args):\n return _osgAnimation.QuatSphericalLinearInterpolator_getValue(self, *args)",
"def spherical_function(j, x, y, z):\n theta = np.arccos(z)\n phi = np.arctan2(y, x)\n return angular_function(j, theta, phi)",
"def test_interpolate_same_quaternion():\n n_steps = 3\n ... | [
"0.617327",
"0.6169262",
"0.6148625",
"0.6074003",
"0.59313565",
"0.593104",
"0.5922888",
"0.5721803",
"0.5659829",
"0.5631086",
"0.5614306",
"0.5593201",
"0.5579721",
"0.55582625",
"0.5523142",
"0.55225587",
"0.55224067",
"0.55026954",
"0.5430118",
"0.54281986",
"0.5422003",... | 0.54015434 | 23 |
Generator method to get an iterable sequence of `n` evenly spaced quaternion rotations between any two existing quaternion endpoints lying on the unit radius hypersphere. This is a convenience function that is based on `Quaternion.slerp()` as defined above. This is a class method and is called as a method of the class ... | def intermediates(cls, q0, q1, n, include_endpoints=False):
step_size = 1.0 / (n + 1)
if include_endpoints:
steps = [i * step_size for i in range(0, n + 2)]
else:
steps = [i * step_size for i in range(1, n + 1)]
for step in steps:
yield cls.slerp(q0, q... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xrndSphere(n):\n for i in xrange(n):\n yield rndSphere()",
"def test_interpolate_same_quaternion():\n n_steps = 3\n random_state = np.random.RandomState(42)\n a = pr.random_axis_angle(random_state)\n q = pr.quaternion_from_axis_angle(a)\n traj = [pr.quaternion_slerp(q, q, t) for t in... | [
"0.6230401",
"0.5919071",
"0.5741861",
"0.5732232",
"0.56885034",
"0.56254333",
"0.53983253",
"0.538138",
"0.53574276",
"0.535273",
"0.5342855",
"0.53310436",
"0.5309906",
"0.5303296",
"0.5255435",
"0.525032",
"0.52398527",
"0.5235149",
"0.52096504",
"0.5206831",
"0.51914227"... | 0.68614244 | 0 |
Get the instantaneous quaternion derivative representing a quaternion rotating at a 3D rate vector `rate` | def derivative(self, rate):
rate = self._validate_number_sequence(rate, 3)
return 0.5 * self * Quaternion(vector=rate) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def integrate(self, rate, timestep):\n self._fast_normalise()\n rate = self._validate_number_sequence(rate, 3)\n\n rotation_vector = rate * timestep\n rotation_norm = np.linalg.norm(rotation_vector)\n if rotation_norm > 0:\n axis = rotation_vector / rotation_norm\n ... | [
"0.5619358",
"0.5561249",
"0.5428783",
"0.5396991",
"0.5378732",
"0.5333648",
"0.5315936",
"0.52689356",
"0.5253576",
"0.5243056",
"0.52155966",
"0.5206561",
"0.5189379",
"0.5188165",
"0.51839274",
"0.5159883",
"0.5147297",
"0.51464164",
"0.5128188",
"0.5104641",
"0.51042175"... | 0.78864855 | 0 |
Advance a time varying quaternion to its value at a time `timestep` in the future. The Quaternion object will be modified to its future value. It is guaranteed to remain a unit quaternion. | def integrate(self, rate, timestep):
self._fast_normalise()
rate = self._validate_number_sequence(rate, 3)
rotation_vector = rate * timestep
rotation_norm = np.linalg.norm(rotation_vector)
if rotation_norm > 0:
axis = rotation_vector / rotation_norm
angle... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put_time(self, time_step, time_value):\n ierr = exolib.py_exptim(self.exoid, time_step + self._o, time_value)\n if ierr:\n raise ExodusIIWriterError(\"Error putting time\")",
"def put_time(self, step, value):\n assert step > 0, \"Step must be larger than 0.\"\n # XXX: C... | [
"0.5825153",
"0.5648373",
"0.5582278",
"0.5361749",
"0.52615345",
"0.5253586",
"0.52514726",
"0.5247261",
"0.5221789",
"0.5159327",
"0.51306",
"0.5119364",
"0.50095236",
"0.49933302",
"0.49704632",
"0.4965376",
"0.49258292",
"0.491121",
"0.4903681",
"0.48923856",
"0.48765534"... | 0.53679127 | 3 |
Get the 3x3 rotation matrix equivalent of the quaternion rotation. | def rotation_matrix(self):
self._normalise()
product_matrix = np.dot(self._q_matrix(), self._q_bar_matrix().conj().transpose())
return product_matrix[1:][:,1:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quaternion2rot3d(quat):\n q01 = quat[0] * quat[1]\n q02 = quat[0] * quat[2]\n q03 = quat[0] * quat[3]\n q11 = quat[1] * quat[1]\n q12 = quat[1] * quat[2]\n q13 = quat[1] * quat[3]\n q22 = quat[2] * quat[2]\n q23 = quat[2] * quat[3]\n q33 = quat[3] * quat[3]\n\n # Obtain the rotati... | [
"0.79238105",
"0.7838864",
"0.7814647",
"0.7813661",
"0.7637882",
"0.761448",
"0.7613394",
"0.7467703",
"0.7390191",
"0.7379554",
"0.73601913",
"0.7359641",
"0.73430336",
"0.73293257",
"0.7327276",
"0.729859",
"0.72715056",
"0.72620225",
"0.7231791",
"0.7222487",
"0.72210836"... | 0.74857116 | 7 |
Get the 4x4 homogeneous transformation matrix equivalent of the quaternion rotation. | def transformation_matrix(self):
t = np.array([[0.0], [0.0], [0.0]])
Rt = np.hstack([self.rotation_matrix, t])
return np.vstack([Rt, np.array([0.0, 0.0, 0.0, 1.0])]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quaternion_matrix(quaternion):\r\n q = numpy.array(quaternion, dtype=numpy.float64, copy=True)\r\n n = numpy.dot(q, q)\r\n if n < _EPS:\r\n return numpy.identity(4)\r\n q *= math.sqrt(2.0 / n)\r\n q = numpy.outer(q, q)\r\n return numpy.array([\r\n [1.0-q[2, 2]-q[3, 3], q[1, ... | [
"0.76597637",
"0.76221406",
"0.7551924",
"0.7487867",
"0.74398667",
"0.7439178",
"0.74036646",
"0.73975825",
"0.7382098",
"0.7365217",
"0.72756994",
"0.7202362",
"0.71945894",
"0.71482193",
"0.7139099",
"0.70530987",
"0.70502305",
"0.7012761",
"0.7011859",
"0.69337714",
"0.68... | 0.69361484 | 19 |
Get the axis or vector about which the quaternion rotation occurs For a null rotation (a purely real quaternion), the rotation angle will always be `0`, but the rotation axis is undefined. It is by default assumed to be `[0, 0, 0]`. | def get_axis(self, undefined=np.zeros(3)):
tolerance = 1e-17
self._normalise()
norm = np.linalg.norm(self.vector)
if norm < tolerance:
# Here there are an infinite set of possible axes, use what has been specified as an undefined axis.
return undefined
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quaternion_about_axis(angle, axis):\r\n q = numpy.array([0.0, axis[0], axis[1], axis[2]])\r\n qlen = vector_norm(q)\r\n if qlen > _EPS:\r\n q *= math.sin(angle/2.0) / qlen\r\n q[0] = math.cos(angle/2.0)\r\n return q",
"def get_rotation(self) -> np.array:\n axis = self.get_arms()[... | [
"0.70825595",
"0.68636996",
"0.6698312",
"0.6544582",
"0.6539169",
"0.6519736",
"0.649929",
"0.64232033",
"0.64046514",
"0.6382638",
"0.630308",
"0.63016963",
"0.6286425",
"0.62622744",
"0.62307894",
"0.622153",
"0.62100315",
"0.6184274",
"0.61735785",
"0.6165052",
"0.6140774... | 0.60692173 | 28 |
Return the real or scalar component of the quaternion object. | def scalar(self):
return self.q[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __truediv__(self, scalar: float):\n if not (isinstance(scalar, float) or isinstance(scalar, int)):\n raise TypeError('scalar must be an scalar type (integer or float')\n return Quaternion(self.__real / scalar, self.__img / scalar)",
"def quaternion(self, name, q):\n R = self.R... | [
"0.6890712",
"0.631148",
"0.62214905",
"0.6202536",
"0.61291295",
"0.61241406",
"0.61192185",
"0.6100044",
"0.6086581",
"0.6084066",
"0.6077211",
"0.60578656",
"0.60505754",
"0.6030138",
"0.6007177",
"0.59975404",
"0.59891254",
"0.5977018",
"0.5976825",
"0.59689003",
"0.59281... | 0.66431254 | 1 |
Return all the elements of the quaternion object. | def elements(self):
return self.q | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_q(self, method: str = 'chiaverini', **kw) -> np.ndarray:\n return self.to_quaternion(method=method, **kw)",
"def _quaternions(self, R):\n # Simple Wikipedia version\n # en.wikipedia.org/wiki/Rotation_matrix#Quaternion\n # For other options see math.stackexchange.com/questions/2... | [
"0.6405536",
"0.6401198",
"0.61890584",
"0.6168035",
"0.59928924",
"0.5937231",
"0.59276384",
"0.5903541",
"0.58369404",
"0.5785775",
"0.5768507",
"0.57612556",
"0.5760467",
"0.5745204",
"0.57412744",
"0.57322943",
"0.57261413",
"0.5723953",
"0.57079697",
"0.5706826",
"0.5705... | 0.632025 | 2 |
Returns set of primes less than n | def primes(upper_bound):
global cache
lower_bound = 2
prime_set = new_primes(upper_bound, cache, lower_bound)
prime_set.update(cache)
cache = prime_set
return prime_set | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primes(n):\n return [i for i in xrange(1, n + 1) if mr_prime(i)]",
"def primes_less(n):\n test_nums = list(range(3, int(floor(sqrt(n))), 2))\n prime_flags = [True] * ((n - 2) // 2)\n for a in test_nums:\n next_div = a**2\n while next_div < n:\n prime_flags[(next_div-3)//2... | [
"0.80588055",
"0.78285134",
"0.7778529",
"0.77425486",
"0.77180666",
"0.76460505",
"0.75593144",
"0.7522407",
"0.7522342",
"0.74992657",
"0.749596",
"0.74639285",
"0.7444756",
"0.74159294",
"0.7388086",
"0.73706895",
"0.736047",
"0.7354939",
"0.73546493",
"0.73143435",
"0.730... | 0.0 | -1 |
Returns a boolean based on whether n is prime | def is_prime(n):
prime_set = primes(n + 1)
return n in prime_set | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def if_prime(cls, n):\n\n if (n <= 1):\n return False\n if (n <= 3):\n return True\n\n if (n % 2 == 0 or n % 3 == 0):\n return False\n\n i = 5\n while(i * i <= n):\n if (n % i == 0 or n % (i + 2) == 0):\n return False\n ... | [
"0.87660676",
"0.8747181",
"0.8738689",
"0.86315215",
"0.8620995",
"0.859904",
"0.859513",
"0.8555033",
"0.85442287",
"0.85242295",
"0.8516884",
"0.84886813",
"0.8473586",
"0.84648055",
"0.84648055",
"0.84642893",
"0.84306467",
"0.8430542",
"0.84282",
"0.84243876",
"0.8419325... | 0.8454273 | 16 |
Split a tensor into a list of tensors based on split_indices. | def _split_tensor(t, split_indices):
# TODO: Switch to something below
# return [t[i:j] for i, j in zip(split_indices[:-1], split_indices[1:])]
if split_indices.device.type != "cpu":
split_indices = split_indices.to("cpu")
return torch.tensor_split(t, split_indices) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_tensor(input, n):\n batch_size = tf.shape(input)[0]\n ls = tf.cast(tf.lin_space(0.0, tf.cast(batch_size, FLOAT_TYPE), n + 1), INT_TYPE)\n return [input[ls[i]:ls[i+1]] for i in range(n)]",
"def split(x, axis, split_size):\n assert axis < x.ndim, 'Dimension out of range!'\n\n if isinstance... | [
"0.7095557",
"0.6711191",
"0.66574436",
"0.66574436",
"0.66416603",
"0.66046864",
"0.6575918",
"0.6494781",
"0.6494781",
"0.6494781",
"0.6494781",
"0.6494781",
"0.6494781",
"0.6494781",
"0.6492781",
"0.64825976",
"0.6445895",
"0.64158356",
"0.6380246",
"0.6216168",
"0.6158133... | 0.84769017 | 0 |
Replace null values with None in provided settings dict. When storing values in the peer relation, it might be necessary at some future point to flush these values. We therefore need to use a real (nonNone or empty string) value to represent an unset settings. This value then needs to be converted to None when applying... | def filter_null(settings, null='__null__'):
filtered = {}
for k, v in settings.iteritems():
if v == null:
filtered[k] = None
else:
filtered[k] = v
return filtered | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_None(self):\r\n\r\n self.loss_list = None\r\n self.meshsol_list = None\r\n self.loss_index = None\r\n self.logger_name = None\r\n self.axes_dict = None\r\n self.Pstator = None\r\n self.Protor = None\r\n self.Pmagnet = None\r\n self.Pprox = Non... | [
"0.59310794",
"0.5846938",
"0.58445704",
"0.5787659",
"0.56930125",
"0.56153136",
"0.55880547",
"0.5536252",
"0.55325824",
"0.54729944",
"0.54607475",
"0.544646",
"0.54451513",
"0.54275024",
"0.54275024",
"0.5414735",
"0.53839976",
"0.5370808",
"0.53195566",
"0.5314751",
"0.5... | 0.73649627 | 0 |
Database relations are expected to provide a list of 'allowed' units to confirm that the database is ready for use by those units. If db relation has provided this information and local unit is a member, returns True otherwise False. | def is_db_ready(use_current_context=False, db_rel=None):
key = 'allowed_units'
db_rels = ['shared-db', 'pgsql-db']
if db_rel:
db_rels = [db_rel]
rel_has_units = False
if use_current_context:
if not any([relation_id() in relation_ids(r) for r in db_rels]):
raise Exceptio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_relation(self, obj1, obj2, **hints):\n if obj1._state.db in self.pool and obj2._state.db in self.pool:\n return True\n return None",
"def allow_relation(self, obj1, obj2, **hints):\n\n if obj1._state.db == obj2._state.db:\n return True\n return False",
... | [
"0.6171301",
"0.60665643",
"0.60360205",
"0.59937686",
"0.5599228",
"0.55960643",
"0.5558504",
"0.5541194",
"0.55264825",
"0.5523213",
"0.5513061",
"0.5437884",
"0.5437884",
"0.5409977",
"0.5366675",
"0.53568417",
"0.5351868",
"0.534887",
"0.5340705",
"0.5316343",
"0.5316272"... | 0.7656244 | 0 |
Add a checkbox element | def add_checkbox(
self,
name: str,
label: str,
default: bool = False,
) -> None: # noqa: E501
self._client.results[name] = default
self._client.add_element(
name=str(name), element=Checkbox(label=str(label), value=bool(default))
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_check_box(self, name, caption, value=False, label=None, add_indicator=None, location=(None,0)):\n widget=QtWidgets.QCheckBox(self)\n widget.setText(_translate(self.name,caption,None))\n widget.setObjectName(_fromUtf8(self.name+\"_\"+name))\n widget.setChecked(value)\n ret... | [
"0.77319163",
"0.7371061",
"0.7210991",
"0.71375376",
"0.71326876",
"0.69095206",
"0.6893391",
"0.6645446",
"0.65329176",
"0.6520399",
"0.64932495",
"0.63283676",
"0.63256705",
"0.6247017",
"0.62313795",
"0.618531",
"0.61627126",
"0.60912466",
"0.6062207",
"0.60352236",
"0.60... | 0.68086946 | 7 |
Create an initial UserProfile based on information in the IAM service for this user. | def initialize_user_profile(self, authz_token):
try:
return self.user_profile_client_pool.initializeUserProfile(authz_token)
except TException:
logger.exception("Error occurred in add_gateway, ", TException)
raise | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_profile(self, user):\n salt = sha.new(str(random.random())).hexdigest()[:5]\n activation_key = sha.new(salt+user.username).hexdigest()\n return self.create(user=user,\n activation_key=activation_key)",
"def create_profile(self, user):\r\n salt = sh... | [
"0.71464145",
"0.71133995",
"0.70557314",
"0.6954174",
"0.67835927",
"0.6752906",
"0.67432594",
"0.67190695",
"0.67002827",
"0.663787",
"0.6635657",
"0.6608703",
"0.66076994",
"0.6604428",
"0.6593462",
"0.6586927",
"0.65734667",
"0.65573263",
"0.65566504",
"0.6547293",
"0.654... | 0.6114687 | 52 |
Exclude hashtags, mentions and weblinks Remove punctuation Return a clean list of words in the tweet | def cleanTweetText(tweet):
twext = excludeTwitterTags(tweet)
twext = stripPunctuation(twext)
return twext | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_clean(text):\n out = []\n # Define a punctuation dictionary so that we can replace each punctuation with an empty space.\n table = str.maketrans('', '', string.punctuation)\n stopWords = set(stopwords.words('senti')) # Set stop words language to English\n tokens = text.split() # Split eac... | [
"0.794172",
"0.7834933",
"0.7796678",
"0.7635389",
"0.75602967",
"0.755541",
"0.7512659",
"0.74974066",
"0.74683416",
"0.73870474",
"0.73492694",
"0.7323641",
"0.7280895",
"0.7265606",
"0.72649074",
"0.7264521",
"0.7254825",
"0.72207093",
"0.7183189",
"0.7159937",
"0.7116283"... | 0.7705537 | 4 |
Constructor, create our lists. | def __init__(self):
self.wall_list = pygame.sprite.Group()
self.enemy_sprites = pygame.sprite.Group() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_lists(self):\n pass",
"def __init__(self):\n List.__init__(self)",
"def __init__(self, *args):\n this = _libsbml.new_ListOf(*args)\n try: self.this.append(this)\n except: self.this = this",
"def lists(self):\r\n return Lists(self)",
"def __init__(self):\n... | [
"0.77571535",
"0.73735946",
"0.733058",
"0.72393185",
"0.7238762",
"0.7196542",
"0.7183845",
"0.7093615",
"0.7026376",
"0.6951966",
"0.6950029",
"0.6943144",
"0.6930302",
"0.6907225",
"0.6900374",
"0.68802685",
"0.68684286",
"0.6846315",
"0.68366283",
"0.68366283",
"0.6835388... | 0.0 | -1 |
Adds the current vertex and its dependencies to the dependency graph. | def __build_dependency_graph(self, transform):
if self.get(transform) == None:
color = "orange" if transform in self.final_transforms else "red"
self.graph.add_vertex(label=transform.get_name(), transform=transform, color=color)
for dependency in transform.requires():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self):\n self.visited_node += [False]\n self.V = self.V + 1\n self.adjacency_list.append(list())",
"def add_vertex(self, vertex):\n self.vertices.append(vertex)\n self.vertex_edge[vertex] = []",
"def add_vertex(self, vertex):\n raise NotImplementedError"... | [
"0.7591406",
"0.68852603",
"0.67429274",
"0.6700446",
"0.66098523",
"0.65453345",
"0.6526063",
"0.64045465",
"0.64045465",
"0.63488936",
"0.6316527",
"0.63044244",
"0.6298568",
"0.6298393",
"0.6275129",
"0.62512773",
"0.6202193",
"0.6166403",
"0.61540854",
"0.6143149",
"0.612... | 0.581637 | 46 |
Returns a pseudorandom 3bytes word that has not been returned before | def get_next(self):
assert(len(self.past_values) < 256**3)
while self.advance_state() in self.past_values:
pass
self.past_values.add(self.state)
return self.state | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gensalt():\n return hexlify(os.urandom(24)).decode()",
"def tubeid():\n return binascii.hexlify(os.urandom(12))",
"def create_challenge():\n\treturn os.urandom(12)",
"def randkey():\n return binascii.b2a_hex(os.urandom(15))",
"def dummy_content():\n return os.urandom(1 * 1024 * 1024) # 1MB... | [
"0.7354417",
"0.70975083",
"0.6825754",
"0.671492",
"0.6712926",
"0.67048985",
"0.66741127",
"0.6672423",
"0.6650761",
"0.6632435",
"0.6614214",
"0.66136575",
"0.6610773",
"0.6583272",
"0.6557179",
"0.65482646",
"0.6483019",
"0.64546657",
"0.64363825",
"0.6429734",
"0.6426126... | 0.0 | -1 |
Constructor for BilinearAttention. self The object pointer. encoder_size Integer. Hidden size of the LSTM encoder. decoder_size Integer. Hidden size of the LSTM decoder. label_size Integer. Size of label lists. | def __init__(self, encoder_size, decoder_size, label_size):
super(BilinearAttention, self).__init__()
self.W = nn.Parameter(torch.zeros(label_size, decoder_size, encoder_size))
self.u = nn.Parameter(torch.zeros(label_size, encoder_size))
self.v = nn.Parameter(torch.zeros(label_size, decoder_size))
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, input_size, hidden_size, num_layers=1, num_classes=2, device=None):\n super(BiRNN, self).__init__()\n self.device = device\n self.hidden_size = hidden_size\n self.num_layers = num_layers\n self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=Tru... | [
"0.6251472",
"0.6227781",
"0.618919",
"0.6184239",
"0.61834466",
"0.6179027",
"0.6171905",
"0.6169773",
"0.61409086",
"0.6131525",
"0.60995835",
"0.60366285",
"0.6013923",
"0.59730935",
"0.5969984",
"0.5969146",
"0.5966917",
"0.5954985",
"0.59431875",
"0.59414804",
"0.5921127... | 0.70725596 | 0 |
Iterate through the directors dict (returned by get_movies_by_director), return a list of tuples (director, average_score) ordered by highest score in descending order. Only take directors into account with >= MIN_MOVIES | def get_average_scores(directors: Dict[str, List[Movie]]) -> List[Tuple[str, float]]:
res = []
for director_name, movies in directors.items():
if len(movies) >= MIN_MOVIES:
avg_score = calc_mean_score(movies)
info = (director_name, avg_score)
res.append(info)
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_average_scores(directors):\n records = {\n director: movies\n for director, movies in directors.items()\n if len(movies) >= MIN_MOVIES\n }\n return {\n (director, _calc_mean(movies)): movies for director, movies in records.items()\n }",
"def mostProfitableDirectors... | [
"0.7843141",
"0.6248571",
"0.60361856",
"0.5994113",
"0.5971395",
"0.595341",
"0.5912637",
"0.58677286",
"0.5760197",
"0.5739307",
"0.568698",
"0.55475",
"0.552494",
"0.54797196",
"0.5329077",
"0.5291607",
"0.52831244",
"0.5230926",
"0.5213934",
"0.5212534",
"0.5178042",
"0... | 0.8556152 | 0 |
Version = 1.1 This is a stable function. This function take an image and how it by using matplot function. | def image_show(img, cmap=None, suptitle=""):
fig = plt.figure()
fig.suptitle(suptitle, fontsize=14, fontweight='bold')
if cmap is not None:
plt.imshow(img, cmap=cmap, vmin=0, vmax=255)
else:
plt.imshow(img)
plt.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imshow(img):\n imadd(img)\n plt.ion()\n plt.show()",
"def visualizeImg(img):\n plt.figure(figsize=(10,4))\n plt.imshow(img)\n plt.show()",
"def show(image):\n fig = pyplot.figure()\n ax = fig.add_subplot(1,1,1)\n imgplot = ax.imshow(image, cmap=mpl.cm.Greys)\n imgplot.set_interpolat... | [
"0.7230369",
"0.7060281",
"0.69906336",
"0.69698346",
"0.6913505",
"0.6909899",
"0.6909899",
"0.6909899",
"0.68680435",
"0.68677527",
"0.6854991",
"0.6765721",
"0.67600965",
"0.67372704",
"0.67266524",
"0.668477",
"0.66634995",
"0.6641409",
"0.66387796",
"0.6582827",
"0.65683... | 0.0 | -1 |
Version = 1.0 This is a stable function. Apply sharpening kernel on image. | def apply_sharpening_on(image):
# Create kernel
kernel = np.array([[0, -1, 0],
[-1, 5, -1],
[0, -1, 0]])
# Sharpen image
sharp_image = cv2.filter2D(image, -1, kernel)
return sharp_image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sharpen(im):\n kernel = np.array([[-1, -1, -1], [-1, 9, -1], [-1, -1, -1]])\n im = cv2.filter2D(im, -1, kernel)\n return im",
"def sharp_img(img,stride=1,pad_type='None'):\n\n kernel = kernel_bank['sharp']\n return img_conv_2D(img,kernel,stride,pad_type)",
"def sharp_ground(X):\n return i... | [
"0.7494452",
"0.68159723",
"0.6806056",
"0.67662704",
"0.65945816",
"0.65689504",
"0.6291979",
"0.6229695",
"0.6156147",
"0.6151508",
"0.61233026",
"0.60914946",
"0.60614175",
"0.5916674",
"0.5892571",
"0.5851311",
"0.584736",
"0.5814132",
"0.58140785",
"0.5801179",
"0.577177... | 0.78789306 | 0 |
> This is not stable function. > Need to through exception when overlapping is 100% > This function take a full image and make patches of that image save them into array and return that array. | def get_image_patches_by_sliding_window(img, stepSize, window_size, overlapping):
# read the image and define the stepSize and window size
# (width,height)
if overlapping == 100:
return None
# generation step size for overlapping
overlapping = 100 - overlapping
stepSize = int(stepSize * ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_patches_non_overlap(array, patch_height, patch_width): \n total_patches_in_height = array.shape[0]//patch_height\n total_patches_in_width = array.shape[1]//patch_width\n # print(\"total patches in height from supplied image array : {}\".format(total_patches_in_height))\n # print(\"total patc... | [
"0.76917577",
"0.7628648",
"0.735203",
"0.70104164",
"0.70086795",
"0.70021147",
"0.69690126",
"0.6968966",
"0.67578614",
"0.67400336",
"0.66633534",
"0.6625895",
"0.65687555",
"0.6501859",
"0.6498882",
"0.64809364",
"0.6477131",
"0.64351875",
"0.63552785",
"0.63228303",
"0.6... | 0.6441806 | 17 |
This function plot the confusion matrix on plt show(). Version = 1.1 | def show_confusion_matrix(matrix, labels: None):
cm = matrix
fig = plt.figure()
ax = fig.add_subplot(111)
cax = ax.matshow(cm)
plt.title('Confusion matrix of the classifier')
fig.colorbar(cax)
if labels is not None:
ax.set_xticklabels([''] + labels)
ax.set_yticklabels([''] + ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self):\r\n interp = ClassificationInterpretation.from_learner(self.learn)\r\n interp.plot_confusion_matrix()",
"def showConfusionMatrix(self): \r\n sn.heatmap(self.conf_matrix, annot=True)\r\n plt.plot( label=\"Accuracy\")\r\n plt.plot( label=\"Error\"... | [
"0.82762265",
"0.81509614",
"0.8039441",
"0.8035047",
"0.7906974",
"0.7891906",
"0.78673786",
"0.78527755",
"0.78111124",
"0.7809694",
"0.7789535",
"0.7771946",
"0.7765782",
"0.7760434",
"0.77519256",
"0.77512455",
"0.774387",
"0.77410054",
"0.7721321",
"0.77159935",
"0.77086... | 0.7626149 | 37 |
Update the actual test buttons. Remove any existing buttons, and make new buttons to correspond to each test. | def _updateTestButtons(self):
trace.into('ProctorGUI', '_updateTestButtons')
#
# Remove any existing buttons
#
for name, button in self.test_buttons.items():
button.delete()
del self.test_buttons[name]
self.update_idletasks()
#
# Ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_custom_button(self):\n pass",
"def update_buttons(self):\n # Enable the Add/Remove step buttons if a Generator is loaded\n enable = self.mgr.obj is not None\n self.addButton.setEnabled(enable)\n self.removeButton.setEnabled(enable)\n self.upButton.setEnab... | [
"0.73152477",
"0.7119484",
"0.69649494",
"0.6861652",
"0.68003595",
"0.6647996",
"0.65972406",
"0.6465998",
"0.6450104",
"0.6373936",
"0.62794554",
"0.6266501",
"0.6230984",
"0.6221348",
"0.6215094",
"0.62144077",
"0.61867416",
"0.6178063",
"0.61634165",
"0.6151623",
"0.60934... | 0.9215448 | 0 |
Return the chain of the sampler. | def chain(self):
return self._chain | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chain(self):\n return self.sampler.chain",
"def get_chain(self, **kwargs):\n self._check_if_fitted()\n return self._sampler.get_chain(**kwargs)",
"def get_chain(self):\n return self.chain",
"def get_chain(self):\n return self.chain",
"def get_chain(self):\n ret... | [
"0.8980825",
"0.7827096",
"0.7610388",
"0.7610388",
"0.73056906",
"0.73056906",
"0.68870157",
"0.62685716",
"0.61598504",
"0.60821205",
"0.6036403",
"0.5992385",
"0.5857339",
"0.58387834",
"0.5799687",
"0.5799326",
"0.57546514",
"0.5743965",
"0.5734663",
"0.5701477",
"0.56656... | 0.74392706 | 4 |
Return the chain of the sampler. | def learned_step_size(self):
return np.array(self._cov_learn).T | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chain(self):\n return self.sampler.chain",
"def get_chain(self, **kwargs):\n self._check_if_fitted()\n return self._sampler.get_chain(**kwargs)",
"def get_chain(self):\n return self.chain",
"def get_chain(self):\n return self.chain",
"def chain(self):\n return ... | [
"0.8980825",
"0.7827096",
"0.7610388",
"0.7610388",
"0.74392706",
"0.73056906",
"0.73056906",
"0.68870157",
"0.62685716",
"0.61598504",
"0.60821205",
"0.6036403",
"0.5992385",
"0.5857339",
"0.58387834",
"0.5799687",
"0.5799326",
"0.57546514",
"0.5743965",
"0.5734663",
"0.5701... | 0.0 | -1 |
Return the chain of the sampler. | def acceptance_fraction(self):
return float(self._accepted / self.num_iterations) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chain(self):\n return self.sampler.chain",
"def get_chain(self, **kwargs):\n self._check_if_fitted()\n return self._sampler.get_chain(**kwargs)",
"def get_chain(self):\n return self.chain",
"def get_chain(self):\n return self.chain",
"def chain(self):\n return ... | [
"0.8980825",
"0.7827096",
"0.7610388",
"0.7610388",
"0.74392706",
"0.73056906",
"0.73056906",
"0.68870157",
"0.62685716",
"0.61598504",
"0.60821205",
"0.6036403",
"0.5992385",
"0.5857339",
"0.58387834",
"0.5799687",
"0.5799326",
"0.57546514",
"0.5743965",
"0.5734663",
"0.5701... | 0.0 | -1 |
Walks through all files and directories under `root` and yields the full path of any filenames that `fnmatch.fnmatch(, pattern)`. | def walk_recursive(root, pattern='*.py'):
for root, dirnames, filenames in os.walk(root):
for filename in fnmatch.filter(filenames, pattern):
yield os.path.join(root, filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LocateFiles(pattern, root=os.curdir):\n for path, _, files in os.walk(os.path.abspath(root)):\n for filename in fnmatch.filter(files, pattern):\n yield os.path.join(path, filename)",
"def locate(pattern, root=os.curdir):\n for path, dirs, files in os.walk(os.path.abspath(root)):\n for file... | [
"0.83933556",
"0.8214798",
"0.8155336",
"0.7981",
"0.7729926",
"0.76721615",
"0.7652997",
"0.7614962",
"0.7614962",
"0.7578584",
"0.755358",
"0.7534318",
"0.7326198",
"0.7276274",
"0.72407496",
"0.7207877",
"0.7199945",
"0.71581954",
"0.71419525",
"0.7121617",
"0.7120801",
... | 0.8185896 | 2 |
Returns a new dictionary where keys are d.values() and values are d.keys(). If there are duplicate values, raises a KeyError. | def swap_keys_and_values(d):
result = dict(zip(d.values(), d.keys()))
if len(d) != len(result):
raise KeyError('There were duplicate values in argument. Values: %s' %
d.values())
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keys_and_values_to_dict(keys_and_values: list, key_name: str = \"Key\", value_name: str = \"Value\") -> dict:\n result = {}\n for item in keys_and_values:\n if key_name not in item:\n raise ValueError(f\"Key {key_name} is not in {item}.\")\n if value_name not in item:\n ... | [
"0.69387746",
"0.6747371",
"0.66195005",
"0.6501823",
"0.64759344",
"0.6473327",
"0.6402916",
"0.6379832",
"0.627405",
"0.6240398",
"0.6221938",
"0.6166402",
"0.61271924",
"0.6117409",
"0.60622114",
"0.59754556",
"0.5956823",
"0.5932185",
"0.589935",
"0.58689797",
"0.5864014"... | 0.8025588 | 0 |
Makes a random action given an action spec and observation. | def _make_random_action(action_spec, observation):
# Sample the random action.
action = {}
for name, spec in action_spec.items():
if name == "Index":
value = np.random.randint(observation["n_edge"])
elif spec.dtype in (np.int32, np.int64, int):
value = np.random.randint(spec.minimum, spec.maxi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def act(observation):\n current_policy = sess.run(policy, {observation_: [observation]})\n action = np.random.choice(action_size, p=current_policy[0])\n return action",
"def random_action(self, observation):\n return self.env.action_space.sample()",
"def make_action(self, observation, test=True):\n ... | [
"0.7849887",
"0.7734636",
"0.75351",
"0.75286674",
"0.74156785",
"0.7306499",
"0.721033",
"0.71077156",
"0.7078297",
"0.7078297",
"0.70573205",
"0.7055624",
"0.7051728",
"0.70432496",
"0.7030282",
"0.7022285",
"0.7012023",
"0.6993087",
"0.6982319",
"0.68012226",
"0.67923117",... | 0.8487527 | 0 |
Take random actions in the given environment. | def _random_unroll(env, seed=1234, num_steps=10, difficulty=5,
random_choice_before_reset=False):
np.random.seed(seed)
action_spec = env.action_spec()
if random_choice_before_reset:
np.random.choice([8], p=[1.])
timestep = env.reset(difficulty=difficulty)
trajectory = [timestep]
actio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose_random_action(env):\n return env.action_space.sample()",
"def random_action(self, observation):\n return self.env.action_space.sample()",
"def RandomAgentProgram(actions):\n return lambda percept: random.choice(actions)",
"def RandomAgentProgram(actions):\n return lambda percept: r... | [
"0.77562207",
"0.70007205",
"0.6967004",
"0.6967004",
"0.67368835",
"0.663912",
"0.660041",
"0.6562257",
"0.6552611",
"0.6531501",
"0.64059526",
"0.63924783",
"0.6322872",
"0.6318179",
"0.631096",
"0.6269377",
"0.6234741",
"0.6224007",
"0.6185568",
"0.6160437",
"0.61415756",
... | 0.5540363 | 84 |
Test that login is successful when the usernames differ in case, but case is ignored. | def test_login_ignore_case(self):
self.env.config.set('trac', 'ignore_auth_case', 'yes')
req = MockRequest(self.env, remote_user='John')
self.module._do_login(req)
self.assertIn('trac_auth', req.outcookie, '"trac_auth" Cookie not set')
auth_cookie = req.outcookie['trac_auth'].... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_incorrect_username(db_session):\n assert (login(\"unknown\", \"unknown\") == \"login.failed\")",
"def test_login_success_username_case_insensitive(self):\r\n\r\n # the migrations add a default admin account\r\n user_data = {'login': u'ADMIN',\r\n 'password': u'admin'... | [
"0.79026246",
"0.7773692",
"0.76358145",
"0.75348103",
"0.74235874",
"0.7361029",
"0.7320939",
"0.7216745",
"0.71445346",
"0.70992696",
"0.70950204",
"0.70914066",
"0.7074992",
"0.7049906",
"0.7029885",
"0.6991027",
"0.69633305",
"0.6963014",
"0.6919273",
"0.68887734",
"0.688... | 0.75505483 | 3 |
Returns string encoded to USASCII character set. | def to_ascii(s):
return s.encode('ascii', 'ignore') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_ascii(ustr):\n return ustr.encode('utf8')",
"def _UnicodeToAscii(string):\n return unicode(string).encode('utf-8')",
"def unicode_to_ascii(s: str) -> str:\n chars = []\n for c in unicodedata.normalize('NFD', s):\n if unicodedata.category(c) != 'Mn' and c in ALLOWED_CHARS:\n ... | [
"0.7002251",
"0.6774208",
"0.66303164",
"0.6583956",
"0.6571069",
"0.6434446",
"0.63789207",
"0.6292562",
"0.62587684",
"0.62229204",
"0.61922956",
"0.61744785",
"0.615399",
"0.614992",
"0.61226106",
"0.6118431",
"0.60532516",
"0.59951615",
"0.5994154",
"0.59810096",
"0.59546... | 0.6700381 | 2 |
Invalid inventory raises schema error | def test_save_bad_inventory():
config_ = {"bad": "yes"}
inventory_ = {"wrong": True}
assert_raises(
schema.SchemaError,
inventory.save,
name=self._project["name"],
config=config_,
inventory=inventory_
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_save_bad_inventory2():\n config_ = {\"schema\": \"avalon-core:config-1.0\"}\n inventory_ = {\"schema\": \"avalon-core:inventory-1.0\"}\n\n assert_raises(\n schema.ValidationError,\n inventory.save,\n name=self._project[\"name\"],\n config=config_,\n inventory=in... | [
"0.71571326",
"0.6274744",
"0.61911494",
"0.6168386",
"0.59572893",
"0.5907338",
"0.5834711",
"0.5708318",
"0.55828935",
"0.5582214",
"0.5492496",
"0.5488747",
"0.5469643",
"0.5455663",
"0.54556453",
"0.5453509",
"0.54225206",
"0.53988916",
"0.53943044",
"0.5385803",
"0.53793... | 0.7212919 | 0 |
Load a pretrained tensorflow text embedding from a directory. | def load_embedding(src: str, embedding_type, layers) -> TransformerEmbedding:
emb = TransformerEmbedding(src, embedding_type=embedding_type, layers=layers)
return emb | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_embedding(path=PROJECT_DIR / \"outputs/models/embedding.pkl\"):\n try:\n with open(path, \"rb\") as inp:\n embedding = pickle.load(inp)\n return embedding\n\n except FileNotFoundError:\n logger.error(f\"There is no embedding to load at {path}\")",
"def load_pretrain... | [
"0.7240618",
"0.72316754",
"0.71106684",
"0.7042985",
"0.6935713",
"0.69212294",
"0.69135755",
"0.68794066",
"0.67890835",
"0.6634037",
"0.66029656",
"0.6577349",
"0.65738606",
"0.6520501",
"0.6472627",
"0.64321387",
"0.639579",
"0.63936013",
"0.63434964",
"0.63299173",
"0.63... | 0.5934213 | 66 |
Initialize spectral residual detector. | def init_od_sr(state_dict: Dict) -> SpectralResidual:
od = SpectralResidual(threshold=state_dict['threshold'],
window_amp=state_dict['window_amp'],
window_local=state_dict['window_local'],
n_est_points=state_dict['n_est_points'],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _setup_sensor ( self ):\n self.spectral = Spectral ( np.array([500, 610, 780, 1580.] ),\n np.array([590, 680, 890, 1750.] ) )",
"def _setup_sensor ( self ):\n self.spectral = Spectral ( np.array([450, 520, 630, 770., 1550, 2090.] ),\n ... | [
"0.6212946",
"0.6147205",
"0.5873858",
"0.57876533",
"0.5772864",
"0.576776",
"0.5739732",
"0.56906",
"0.568867",
"0.56192493",
"0.5612864",
"0.55664325",
"0.555783",
"0.555056",
"0.55239",
"0.55196464",
"0.5493547",
"0.54915714",
"0.54645497",
"0.54589725",
"0.5456158",
"0... | 0.54780006 | 18 |
Return a unique ID to use for this entity. | def unique_id(self):
return f"{self.config_entry.entry_id}_{self.hub_name}_{self.sensor_name}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique_id(self) -> str:\n return self._unique_id",
"def unique_id(self) -> str:\n return self._unique_id",
"def unique_id(self) -> str:\n return self._unique_id",
"def unique_id(self) -> str:\n return self._unique_id",
"def unique_id(self) -> str:\n return self._uniqu... | [
"0.8460817",
"0.8460817",
"0.8460817",
"0.8460817",
"0.8460817",
"0.8460817",
"0.8460817",
"0.8460817",
"0.8355675",
"0.8343812",
"0.8343812",
"0.83238506",
"0.8221654",
"0.8221654",
"0.8203365",
"0.8203365",
"0.81823623",
"0.8174053",
"0.8151542",
"0.8146305",
"0.81339616",
... | 0.0 | -1 |
Return the state attributes. | def device_state_attributes(self):
return {
"attribution": ATTRIBUTION,
"id": str(self.coordinator.data.get("id")),
"integration": DOMAIN,
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.8953404",
"0.8953404",
"0.85239846",
"0.8366765",
"0.8366765",
"0.8363429",
"0.83362615",
"0.8334551",
"0.8310377",
"0.8292682",
"0.8289349",
"0.8289349",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.828... | 0.74449235 | 81 |
Calculate distance on sphere between pairs of coordinates via haversine formula | def spherical_distance_haversine(coord_pairs, radius=MEAN_EARTH_RADIUS_M):
assert np.shape(coord_pairs)[1:] == (2, 2), "coord_pairs must be nx2x2"
coord_pairs_rad = coord_pairs * np.pi / 180.0
lat0 = coord_pairs_rad[:,0,1]
lat1 = coord_pairs_rad[:,1,1]
delta_lon = coord_pairs_rad[:,0,0] - coord_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spherical_distance(coord_pair, radius=MEAN_EARTH_RADIUS_M):\n\n return spherical_distance_haversine(np.array([coord_pair]), radius)[0]",
"def spherical_distances(x, y):\n # Compute the norms of all points, we do NOT check they actually all lie on\n # the same sphere (that's the caller's responsibili... | [
"0.7542477",
"0.7169996",
"0.71392715",
"0.71389306",
"0.7060756",
"0.7033742",
"0.70308125",
"0.7023419",
"0.69841963",
"0.69740987",
"0.6952145",
"0.69412816",
"0.6934077",
"0.69331956",
"0.69216913",
"0.69141984",
"0.6904543",
"0.69035935",
"0.68973",
"0.6891433",
"0.68682... | 0.76774156 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.