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 |
|---|---|---|---|---|---|---|
Plots hyperconnectivity in 3D. | def plot_links_3d_intra(ax: str, epo1: mne.Epochs, epo2: mne.Epochs,
C1: np.ndarray, C2: np.ndarray, threshold: str='auto',
steps: int=10):
# extract sensor infos and transform loc to fit with headmodel
loc1 = copy(np.array([ch['loc'][:3] for ch in epo1.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot3d(self):\n plot_rupture_wire3d(self)",
"def plot_3d_plot(self, features, headers, labels):\n self.master_plot.scatter(features[:, 0], features[:, 1], features[:, 2], c=labels)\n self.master_plot.set_xlabel(headers[0])\n self.master_plot.set_ylabel(headers[1])\n self.ma... | [
"0.740988",
"0.6841408",
"0.680333",
"0.6557689",
"0.6546958",
"0.6427141",
"0.6426638",
"0.64190346",
"0.63411844",
"0.6326457",
"0.62901676",
"0.62557065",
"0.6214867",
"0.61868155",
"0.61695606",
"0.612503",
"0.61064655",
"0.608286",
"0.60490936",
"0.6036209",
"0.60334635"... | 0.54743326 | 79 |
Functionality is implicit in setUp and tearDown. If this passes those must have passed | def test_transportzone_create(self):
self.assertTrue(True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\r\n # nothing to do, all tests use different things\r\n pass",
"def tearDown(self):\n\t\tpass",
"def tearDown(self):\n pass",
"def tearDown(self):\r\n pass",
"def tearDown(self):\r\n pass",
"def tearDown(self):\r\n pass",
"def tearDown(self... | [
"0.83913517",
"0.8227105",
"0.8211071",
"0.8201365",
"0.8201365",
"0.8201365",
"0.8201365",
"0.8201365",
"0.8196506",
"0.8196506",
"0.8196506",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.817... | 0.0 | -1 |
Functionality is implicit in setUp and tearDown. If this passes those must have passed | def test_transportzone_delete(self):
self.assertTrue(True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\r\n # nothing to do, all tests use different things\r\n pass",
"def tearDown(self):\n\t\tpass",
"def tearDown(self):\n pass",
"def tearDown(self):\r\n pass",
"def tearDown(self):\r\n pass",
"def tearDown(self):\r\n pass",
"def tearDown(self... | [
"0.83913517",
"0.8227105",
"0.8211071",
"0.8201365",
"0.8201365",
"0.8201365",
"0.8201365",
"0.8201365",
"0.8196506",
"0.8196506",
"0.8196506",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.81777453",
"0.817... | 0.0 | -1 |
Look up key in the cache and return the value for it. | def get(self, key):
_filter = {'_id': key}
doc = self.collection.find_one(_filter)
if doc and not self._verify_timeout(doc):
return self._unpickle(doc['value']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, key):\n if key in self.cache:\n value = self.cache[key].value\n # Re-enqueue to indicate recently used\n self._re_enqueue(self.cache[key])\n return value\n else:\n return -1",
"def get(self, key):\n # Initialize key variabl... | [
"0.829563",
"0.81635714",
"0.8070154",
"0.79891354",
"0.79411787",
"0.7914772",
"0.7880844",
"0.78413755",
"0.78324014",
"0.78324014",
"0.776193",
"0.77000964",
"0.75934494",
"0.75250804",
"0.75154066",
"0.7464589",
"0.74200094",
"0.7410663",
"0.740485",
"0.73709685",
"0.7365... | 0.0 | -1 |
Get the units of the value. | def units(self):
return self._units | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def units(self):\n return self.__class__.get_setting_units(self.key, **self.get_kwargs())",
"def get_units(self):\r\n msg = struct.pack('>2B', 56, 14)\r\n response = self.query(msg)\r\n\r\n if response[1] == 2:\r\n units = 'A'\r\n to_nm_multiplier = 1 / 10\r\n ... | [
"0.8198577",
"0.7997838",
"0.7976108",
"0.7874357",
"0.7825075",
"0.78075206",
"0.77789235",
"0.7737168",
"0.7721054",
"0.75396943",
"0.75386035",
"0.74936783",
"0.74911666",
"0.7488608",
"0.74767506",
"0.7466484",
"0.7462952",
"0.7450685",
"0.7446459",
"0.7433422",
"0.743321... | 0.8183448 | 1 |
Returns the Relative Entropy. Relative entropy is P1log2(P1/P2) where here P1 is P(rightword) and P2 is P(right word | left word). | def RE(bigramprob, token1p, token2p):
return token1p * math.log(token1p/(bigramprob/token2p), 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relative_entropy(P, Q):\n return rel_entropy_P_Q",
"def calculate_entropy(prob):\n return -(prob * math.log(prob,2))",
"def entropy(self):\n ent = 0.0\n for f in self.byte_freq:\n if f > 0:\n freq = float(f) / self.byte_total\n ent = ent + freq *... | [
"0.6731936",
"0.66846216",
"0.66484",
"0.663098",
"0.6579301",
"0.6513949",
"0.64769757",
"0.6423609",
"0.6395869",
"0.63805485",
"0.6373209",
"0.6287455",
"0.62828374",
"0.62612027",
"0.62527895",
"0.62280035",
"0.62183833",
"0.62090355",
"0.6202973",
"0.61832315",
"0.618009... | 0.0 | -1 |
Determines if this user is an admin of this challenge. | def is_admin(self, user) -> bool:
return (
user.is_superuser
or user.groups.filter(pk=self.admins_group.pk).exists()
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_admin_user(self):\n if \"is_admin\" in self._properties and self.is_admin == 'YES':\n return True\n return False",
"def is_admin(self, user):\n return user.name in self.admins",
"def is_admin(self):\n return self.admin",
"def is_admin(self):\n if not self.... | [
"0.8358774",
"0.8199402",
"0.81191206",
"0.8107907",
"0.8096805",
"0.8069906",
"0.8068912",
"0.8041306",
"0.8041306",
"0.8037206",
"0.8026606",
"0.7953814",
"0.79521793",
"0.7893848",
"0.7883147",
"0.7864104",
"0.7829007",
"0.7815371",
"0.77968514",
"0.778028",
"0.77679765",
... | 0.77631724 | 21 |
Group name based on the name of the subscription class. | def _group_name(cls, group=None):
suffix = f"{cls.__module__}.{cls.__qualname__}"
if group is not None:
suffix += "-" + group
# Wrap the suffix into SHA256 to guarantee that the length of
# the group name is limited. Otherwise Channels will complain
# about that the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_name(self):\n\t\treturn \"DocumentChat-%s\" % self.id",
"def name(self):\n return f\"{self._group.friendly_name} {GROUP_SUFFIX}\"",
"def group_name(self) -> str:\n return pulumi.get(self, \"group_name\")",
"def get_secgrp_name ( base_name, group_type ) :\n return base_name.upper( ) ... | [
"0.6966121",
"0.6915291",
"0.6903103",
"0.68559325",
"0.6676207",
"0.6647403",
"0.65681654",
"0.6552836",
"0.6548531",
"0.65140355",
"0.65140355",
"0.65088445",
"0.6490989",
"0.64664996",
"0.64664996",
"0.64418054",
"0.640847",
"0.6251304",
"0.6251304",
"0.6251304",
"0.625130... | 0.7251618 | 0 |
Find the index of the first element from the start of the array that verifies the given condition. The function is applied from the start of the array to the pivot. | def bisect_keep_left(a, fn):
lo = 0
hi = len(a)
while lo < hi:
mid = (lo + hi) // 2
if fn(a[: mid + 1]):
hi = mid
else:
lo = mid + 1
return lo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_of_first(array, find):\n\n if len(array) == 0:\n return 0\n\n left = 0\n right = len(array) - 1\n\n if array[left] >= find:\n return 0\n\n if array[right] < find:\n return len(array)\n\n while right - left > 1:\n mid = (left + right) // 2\n if array[mi... | [
"0.6615144",
"0.66116774",
"0.63508654",
"0.6262433",
"0.6246073",
"0.6233158",
"0.6214967",
"0.62139827",
"0.6139333",
"0.6134017",
"0.61296976",
"0.61280024",
"0.6084851",
"0.60374564",
"0.6028714",
"0.59944415",
"0.5987495",
"0.59172755",
"0.5910116",
"0.58894193",
"0.5884... | 0.0 | -1 |
Find the index of the first element from the end of the array that verifies the given condition. The function is applied from the pivot to the end of array. | def bisect_keep_right(a, fn):
lo = 0
hi = len(a)
while lo < hi:
mid = (lo + hi) // 2
if fn(a[mid:]):
lo = mid + 1
else:
hi = mid
return lo | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findFirstFalseValue( data ):\n #~ idx = np.argmin( data ); \n #~ if( data[idx] ):\n #~ return -1;\n #~ return idx;\n \n # argmin seems far less efficient than argmax... (and seems to compute all the list)\n n = len(data);\n i = 0; \n while( i < n ):\n if( not data[i] ... | [
"0.64304715",
"0.6406804",
"0.6367104",
"0.63510406",
"0.6307789",
"0.6293876",
"0.62010723",
"0.6100576",
"0.60961956",
"0.60667586",
"0.6062324",
"0.60471153",
"0.6035693",
"0.60117686",
"0.59729064",
"0.5953844",
"0.5926345",
"0.5906509",
"0.5887448",
"0.58642536",
"0.5819... | 0.0 | -1 |
Create a new LRUCache with the given size. | def __init__(self, cache_size):
# type: (int) -> None
self.cache_size = cache_size
super(LRUCache, self).__init__() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_cache(\n size: int,\n) -> t.Optional[t.MutableMapping[t.Tuple[weakref.ref, str], \"Template\"]]:\n if size == 0:\n return None\n\n if size < 0:\n return {}\n\n return LRUCache(size) # type: ignore",
"def __init__(self, size):\n self.cache = deque()\n self.max_s... | [
"0.7275999",
"0.6261309",
"0.62120396",
"0.6130822",
"0.5963818",
"0.596008",
"0.59307206",
"0.5893305",
"0.58909136",
"0.57236415",
"0.56542253",
"0.5586899",
"0.55461204",
"0.5506772",
"0.54911464",
"0.5473021",
"0.54658246",
"0.5448263",
"0.5419874",
"0.5380743",
"0.536398... | 0.6812692 | 1 |
Returns the time span (years) for a list of bibcodes | def get_timespan(biblist):
years = map(lambda a: int(a[:4]), biblist)
minYr = min(years)
maxYr = max(years)
span = maxYr - minYr + 1
return max(span,1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _enumerate_years(self, preprocessed_data, disjoint):\n pass",
"def getYears():\n url = \"http://www.boxofficemojo.com/weekend/\"\n src = urllib.request.urlopen(url).read()\n soup = BeautifulSoup(src, 'html.parser')\n year_header = soup.find_all(name = \"b\")[1]\n year_elems = year_heade... | [
"0.6142388",
"0.6001194",
"0.5942807",
"0.5837687",
"0.582791",
"0.5818545",
"0.5794234",
"0.578802",
"0.57844144",
"0.56901085",
"0.5625398",
"0.56192505",
"0.56091267",
"0.55819166",
"0.55794823",
"0.55773306",
"0.5574862",
"0.55555683",
"0.55534154",
"0.55407286",
"0.55338... | 0.80209076 | 0 |
Create a temporary directory and set it as the working directory. The directory will be deleted after the test has finished. | def chdir_tmp(self):
dirname = make_tempdir()
os.chdir(dirname)
return dirname | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tempdir():\n\n # Create a directory and return the path\n return tempfile.mkdtemp()",
"def fresh_directory():\n os.chdir(tempfile.mkdtemp())",
"def make_tempdir():\n global _TEMPDIR\n if not _TEMPDIR:\n _TEMPDIR = tempfile.mkdtemp()\n return _TEMPDIR",
"def makeTempDirParent():\n... | [
"0.80533063",
"0.7933043",
"0.77821136",
"0.7733498",
"0.7688417",
"0.7663208",
"0.7660145",
"0.7654722",
"0.7649455",
"0.7639673",
"0.7621977",
"0.7621201",
"0.7583251",
"0.7565345",
"0.7545439",
"0.75439125",
"0.75005573",
"0.7482618",
"0.748254",
"0.7448652",
"0.7441782",
... | 0.7607051 | 12 |
Initialize the name and age attributes. | def __init__(self, f_name, l_name, age, birthplace):
self.f_name = f_name
self.l_name = l_name
self.age = age
self.birthplace = birthplace
self.login_attempts = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name, age):\n\t\tself.name = name\n\t\tself.age = age",
"def __init__(self, name, age):\n\t\tself.name = name\n\t\tself.age = age",
"def __init__(self, name, age):\n\t\tself.name = name\n\t\tself.age = age",
"def __init__(self, first_name, last_name, age):\n\n self.first_name = firs... | [
"0.7830388",
"0.7830388",
"0.7830388",
"0.7734194",
"0.7693192",
"0.7693192",
"0.7693192",
"0.7693192",
"0.7693192",
"0.7693192",
"0.7693192",
"0.7693192",
"0.76082045",
"0.76082045",
"0.76082045",
"0.76082045",
"0.759261",
"0.74363476",
"0.73375696",
"0.7313237",
"0.7298834"... | 0.65288407 | 36 |
Initialize attributes of parent class User, then the ones specific to admin. | def __init__(self, f_name, l_name, age, birthplace):
super().__init__(f_name, l_name, age, birthplace)
#initialize an empty set of privileges.
self.privileges = Privileges() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, **kwargs):\n super(User, self).__init__(**kwargs)\n\n # Set default role for a regular new User\n self.role = Role.query.filter_by(default=True).first()",
"def __init__(self, **kwargs):\n super(User, self).__init__(**kwargs)\n Role.insert_roles()\n if ... | [
"0.6648573",
"0.6513397",
"0.64985955",
"0.64902616",
"0.6398927",
"0.6286533",
"0.6128769",
"0.6011839",
"0.5997765",
"0.596782",
"0.59525526",
"0.59372234",
"0.58947575",
"0.58701926",
"0.58529794",
"0.5852023",
"0.58269054",
"0.58261067",
"0.5823807",
"0.58147746",
"0.5805... | 0.5257992 | 78 |
Return values in order of sorted keys. | def values(self):
return [self[key] for key in self.keys()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sortedKeys(self):\n sortedItems = list(self.items())\n\n def compare(x, y): return sign(y[1] - x[1])\n sortedItems.sort(cmp=compare)\n return [x[0] for x in sortedItems]",
"def sortedKeys(self):\n sortedItems = self.items()\n compare = lambda x, y: sign(y[1] - x[1])\... | [
"0.7904885",
"0.7886828",
"0.75174004",
"0.7398093",
"0.7358324",
"0.73361063",
"0.73093545",
"0.7170837",
"0.71443033",
"0.70589036",
"0.7043204",
"0.6922942",
"0.68633324",
"0.67360926",
"0.67336285",
"0.67085075",
"0.6693954",
"0.6667687",
"0.66433114",
"0.6614744",
"0.658... | 0.0 | -1 |
Selects the VM with the minimum RAM usage. | def minimum_migration_time(vms_ram):
min_index, min_value = min(enumerate(vms_ram.values()),
key=operator.itemgetter(1))
return vms_ram.keys()[min_index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_min_vm_mem(self):\n\t\treturn call_sdk_function('PrlDispCfg_GetMinVmMem', self.handle)",
"def set_min_vm_mem(self, nMemSize):\n\t\tcall_sdk_function('PrlDispCfg_SetMinVmMem', self.handle, nMemSize)",
"def required_vcpu_minimum(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"required_vcpu... | [
"0.6647378",
"0.62604773",
"0.62160164",
"0.6144949",
"0.61316353",
"0.6055661",
"0.5991467",
"0.59723663",
"0.5953554",
"0.5939088",
"0.5689884",
"0.56821537",
"0.5664244",
"0.5625738",
"0.55890685",
"0.55531013",
"0.55230355",
"0.5510371",
"0.5478521",
"0.5470055",
"0.54271... | 0.5390762 | 21 |
Selects the VM with the minimum CPU utilization. | def minimum_utilization(vms_cpu):
last_utilization = [x[-1] for x in vms_cpu.values()]
min_index, min_value = min(enumerate(last_utilization),
key=operator.itemgetter(1))
return vms_cpu.keys()[min_index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def required_vcpu_minimum(self) -> pulumi.Input[int]:\n return pulumi.get(self, \"required_vcpu_minimum\")",
"def min_vcpu(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self, \"min_vcpu\")",
"def test_template_cpu_profile(self):\n vm_cpu_profile_id = ll_vms.get_cpu_profile_id(\... | [
"0.72526425",
"0.7011721",
"0.63308936",
"0.60917324",
"0.6035295",
"0.6023393",
"0.6006956",
"0.5992485",
"0.5965587",
"0.59436",
"0.5917357",
"0.59166175",
"0.58953786",
"0.5852635",
"0.58448076",
"0.582146",
"0.5800917",
"0.577696",
"0.57175386",
"0.570692",
"0.57066315",
... | 0.6841053 | 2 |
Initialize required model and set it up for feature extracting or finetuning. | def initialize_model(model_name, num_classes, feature_extract, verbose=False):
model_ft = None
if model_name == "resnet":
""" Resnet18
"""
model_ft = models.resnet18(pretrained=True)
set_parameter_requires_grad(model_ft, feature_extract)
num_ftrs = model_ft.fc.in_featur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_model(self):\n pass",
"def initialize_model(self):\n pass",
"def initialize(self):\n LOG.info(\"Initializing Model.\")\n self.model = self.convert(df=self.training_df)\n if self.bootstraps is not None:\n LOG.info(\"Bootstrapping Data.\")\n self.... | [
"0.8137613",
"0.8083294",
"0.77861387",
"0.7667924",
"0.7655212",
"0.7516402",
"0.73619854",
"0.7167599",
"0.70977885",
"0.70911384",
"0.70802355",
"0.70802355",
"0.7069199",
"0.7034669",
"0.70092505",
"0.69933903",
"0.69754475",
"0.69631857",
"0.69370747",
"0.69126236",
"0.6... | 0.6620162 | 57 |
Filters a queryset in order to produce a different set of document from subsequent queries. | def filter(self, *arguments, **kwargs):
from jetengine.query_builder.node import Q, QCombination, QNot
from jetengine.query_builder.transform import validate_fields
if arguments and len(arguments) == 1 and isinstance(arguments[0], (Q, QNot, QCombination)):
if self._filters:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryset(self, request, queryset):\n # Compare the requested value (either '80s' or 'other')\n # to decide how to filter the queryset.\n\n if self.value() is None:\n return queryset.all()\n\n return queryset.filter(firm__pk=self.value())",
"def queryset(self, request, q... | [
"0.69708765",
"0.69311494",
"0.6664716",
"0.6530393",
"0.6494069",
"0.64547443",
"0.6451156",
"0.63962543",
"0.6394907",
"0.63769436",
"0.6359857",
"0.63582456",
"0.6333332",
"0.6324688",
"0.6254043",
"0.6252978",
"0.6248702",
"0.6232776",
"0.62278765",
"0.61904234",
"0.61880... | 0.0 | -1 |
Skips N documents before returning in subsequent queries. | def skip(self, skip):
self._skip = skip
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skiplimit(page_size, page_num):\n # Calculate number of documents to skip\n skips = page_size * (int(page_num/page_size) - 1)\n\n if skips < 0:\n skips = 0\n \n print('skip', skips, 'pages', page_size,'num', page_num )\n # Skip and limit\n cursor = db... | [
"0.6999121",
"0.6907539",
"0.6881064",
"0.68775254",
"0.6701172",
"0.65173024",
"0.6130043",
"0.60704154",
"0.6045231",
"0.60276335",
"0.5944566",
"0.5944566",
"0.5837923",
"0.58352345",
"0.58317924",
"0.57123476",
"0.56377345",
"0.5606788",
"0.56060445",
"0.55743974",
"0.556... | 0.52892554 | 34 |
Returns all the rooms in amity | def all_rooms(self):
all_rooms = {}
all_rooms.update(self.offices)
all_rooms.update(self.living_spaces)
return all_rooms | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_rooms(self):\n pass",
"def get_rooms(self):\n rooms = []\n for i in self.rooms:\n rooms.append(self.rooms[i])\n\n return rooms",
"def possible_rooms(self):\r\n return self.rooms",
"def rooms(self):\n def closure(cur):\n cur.execute(\"\"\... | [
"0.8204143",
"0.78632534",
"0.7633574",
"0.7584495",
"0.73597836",
"0.7067902",
"0.69353426",
"0.69070756",
"0.6900405",
"0.68167204",
"0.6814724",
"0.6791709",
"0.6767192",
"0.6737338",
"0.6645935",
"0.6639812",
"0.654427",
"0.65355426",
"0.6518172",
"0.6513724",
"0.65038687... | 0.73712796 | 4 |
Randomly assigns a person to a room given a person and a set of rooms | def random_assign(self, person, room_set):
random_room = self.random_select(room_set)
while room_set[random_room]['room'].allocate_room_space() == -1:
random_room = self.random_select(room_set) # pragma: no cover
if self.all_rooms[random_room]['room'].room_type == "LivingSpace":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_room(rooms) -> str:\n new_id = random.randbytes(12).hex().upper()\n while new_id in rooms:\n new_id = random.randbytes(12).hex().upper()\n return new_id",
"def assign_room(self, person, room):\n if self.all_rooms[room]['room'].room_type == \"OfficeSpace\":\n perso... | [
"0.661049",
"0.6292546",
"0.6165787",
"0.6140363",
"0.6056285",
"0.60361624",
"0.60237163",
"0.59895754",
"0.59590673",
"0.5879357",
"0.5824096",
"0.5805581",
"0.57861465",
"0.5780779",
"0.5779937",
"0.5703116",
"0.57024616",
"0.56998724",
"0.56895363",
"0.5687332",
"0.566957... | 0.81070304 | 0 |
Testing the formula of our Sigmoid | def testActivation(self):
result = Sigmoid.activ(self, 12)
self.assertEqual(0.9999938558253978, result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sigmoid_activation(self):\n self.assertEqual([0.5, 0.5], list(\n af.Sigmoid().output(np.array([0, 0]))))\n self.assertEqual([0.25, 0.25], list(\n af.Sigmoid().derivative(np.array([0, 0]))))",
"def test_activation_sigmoid(self):\r\n senal = 1\r\n result =... | [
"0.8267925",
"0.8258236",
"0.8112205",
"0.80946875",
"0.8093645",
"0.8093645",
"0.80658656",
"0.80563045",
"0.8054069",
"0.8052812",
"0.80483633",
"0.8029341",
"0.8023862",
"0.8023862",
"0.8023862",
"0.8023862",
"0.8023862",
"0.8023862",
"0.79961234",
"0.7994961",
"0.7985629"... | 0.7754598 | 43 |
Testing the Derivative of our Sigmoid | def testDerivation(self):
result = Sigmoid.deriv(self, 12)
self.assertEqual(-132, result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sigmoid_derivative_returns_correct_value(self):\n self.assertAlmostEqual(sigmoid_derivative(0), 0.25)\n self.assertAlmostEqual(sigmoid_derivative(1), 0.19661193324)",
"def sigmoid_derivative(x):\n return x * (1.0 - x)",
"def sigmoid_derivative(x):\n return x * (1-x)",
"def deriva... | [
"0.8180188",
"0.81243986",
"0.81189024",
"0.805349",
"0.805349",
"0.8010116",
"0.78242546",
"0.78125215",
"0.7479861",
"0.7418305",
"0.7387366",
"0.7288652",
"0.71884555",
"0.7100876",
"0.7078081",
"0.70698327",
"0.7021324",
"0.7013257",
"0.6956748",
"0.69056696",
"0.6897431"... | 0.7972614 | 6 |
Testing the Heuristic of our Sigmoid | def testHeuristic(self):
result = Sigmoid.heuristic(self, 12)
self.assertEqual(0.28867513459481287, result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_activation_sigmoid(self):\r\n senal = 1\r\n result = activation.soft_sigmoid(senal)\r\n self.assertEqual(result, 0.6963549298238342)",
"def test_sigmoid_activation(self):\n self.assertEqual([0.5, 0.5], list(\n af.Sigmoid().output(np.array([0, 0]))))\n self.a... | [
"0.7854105",
"0.7736825",
"0.73598605",
"0.73230517",
"0.7227331",
"0.7217456",
"0.72055835",
"0.7178818",
"0.7176533",
"0.71699923",
"0.71699923",
"0.7166367",
"0.71447587",
"0.71349937",
"0.7134822",
"0.71298677",
"0.7094675",
"0.70837206",
"0.7069477",
"0.7055999",
"0.7055... | 0.8756104 | 0 |
2D numpy array with dims [lat, lon] | def fourth_order_derivative(arr: np.ndarray, dim=0, isglobal=True):
# assert isinstance(arr, np.ndarray), 'Input must be numpy array'
output = np.zeros_like(arr)
if dim == 0:
ysize = np.shape(arr)[0]
for lat_idx in range(2, np.shape(arr)[0] - 2):
for lon_idx in range(np.shape(ar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_numpy_array_2D(self):\n wx = []\n wy = []\n for wp in self.waypoints:\n wx.append(wp.location.x)\n wy.append(wp.location.y)\n return np.array([wx, wy])",
"def init_lon_lat_arr(lon_arr, lat_arr):\n tmp_lon = np.array(lon_arr).squeeze()\n tmp_l... | [
"0.71712947",
"0.6579578",
"0.64526325",
"0.6421857",
"0.6415699",
"0.6379741",
"0.6376902",
"0.63461226",
"0.630419",
"0.630419",
"0.6295113",
"0.6268113",
"0.6256764",
"0.6247396",
"0.62210727",
"0.6202465",
"0.6166401",
"0.61609215",
"0.6140968",
"0.61344",
"0.60215414",
... | 0.0 | -1 |
The identity block is the block that has no conv layer at shortcut. Arguments | def identity_block(input_tensor, kernel_size, filters, stage, block, trainable=True, use_conv_bias=True,
weight_regularizer=None, bias_regularizer=None, bn_training=False, separate_scale=False):
filters1, filters2, filters3 = filters
if K.image_data_format() == 'channels_last':
bn_axi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identity_block(self, input_tensor, filters, activation, stage, block, start_with_batch_norm = True):\n\n # Set the naming convention\n conv_name_base = 'res' + str(stage) + block + '_branch'\n batch_norm_name_base = 'batch_norm' + str(stage) + block + '_branch'\n\n x_shortcut = inpu... | [
"0.71272004",
"0.7022438",
"0.6910338",
"0.68836653",
"0.68505627",
"0.6847176",
"0.68221945",
"0.6821999",
"0.680346",
"0.6799615",
"0.67849326",
"0.67714536",
"0.67158884",
"0.67146987",
"0.67137283",
"0.6664201",
"0.6624224",
"0.662218",
"0.662218",
"0.66078824",
"0.659845... | 0.61787283 | 31 |
A block that has a conv layer at shortcut. Arguments | def conv_block(input_tensor, kernel_size, filters, stage, block, strides=(2, 2), trainable=True, use_conv_bias=True,
weight_regularizer=None, bias_regularizer=None, bn_training=False, separate_scale=False):
filters1, filters2, filters3 = filters
if K.image_data_format() == 'channels_last':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv_block(self, output_channel, filter_, activate):\n return self.add_layer(conv_block, output_channel, filter_, activate)",
"def _convolution_block(self, X, filters, f, s, stage, block):\n\n\t\tconv_layer_name = 'res' + str(stage) + block + '_branch'\n\t\tbn_layer_name = 'bn' + str(stage) + block + ... | [
"0.72210574",
"0.6797653",
"0.67508686",
"0.673468",
"0.6702727",
"0.66709983",
"0.66706705",
"0.6638113",
"0.6602907",
"0.6602907",
"0.65983295",
"0.65591985",
"0.6556552",
"0.6553555",
"0.6531844",
"0.65101147",
"0.650745",
"0.6479069",
"0.6421294",
"0.64118993",
"0.6391051... | 0.0 | -1 |
A time distributed block that has a conv layer at shortcut. Arguments | def td_conv_block(input_tensor, kernel_size, filters, stage, block, td_input_shape, strides=(2, 2), use_conv_bias=True,
weight_regularizer=None, bias_regularizer=None, bn_training=False, separate_scale=False):
filters1, filters2, filters3 = filters
bn_axis = 3
conv_name_base = 'res' + str(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv_block(input, filters, phase=phase):\r\n\r\n conv_block = tf.layers.conv2d(\r\n inputs=input,\r\n filters=filters,\r\n kernel_size=3,\r\n padding=\"SAME\",\r\n activation=tf.nn.relu)\r\n\r\n #conv_block = tf.contrib.layers.batch_norm(\r\n... | [
"0.6529457",
"0.6387441",
"0.6375557",
"0.632813",
"0.6301473",
"0.6301473",
"0.6256626",
"0.62173",
"0.62118053",
"0.6171322",
"0.61576533",
"0.60962176",
"0.60711426",
"0.60369456",
"0.60347295",
"0.60133743",
"0.60014707",
"0.59652877",
"0.5942636",
"0.5926511",
"0.5916915... | 0.6321705 | 4 |
Creates a Keras model of the ResNet50 classification layers on top of a passed in base model. | def resnet50_classifier(num_rois, num_classes, base_model = None, weight_regularizer=None, bias_regularizer=None):
roi_input = Input(shape=(None, 4), name='roi_input')
pooling_input = base_model.output if base_model else Input(shape=(None, None, FINAL_CONV_FILTERS))
model_input = base_model.input if base_m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ResNet50_model(input_shape, pooling):\n from keras.applications.resnet import ResNet50\n return ResNet50(include_top=False, weights='imagenet', input_shape=input_shape, pooling=pooling)",
"def get_model(imgsize: ImageSize, classes_count: int) -> keras.Model:\n data_augmentation = keras.Sequential(\n... | [
"0.7391861",
"0.7387784",
"0.7344437",
"0.73161316",
"0.72661614",
"0.7263081",
"0.71050507",
"0.7058973",
"0.7058829",
"0.70493585",
"0.7008709",
"0.6967189",
"0.6911631",
"0.69103736",
"0.6900661",
"0.6884714",
"0.68797714",
"0.6879316",
"0.68508047",
"0.6819644",
"0.675767... | 0.6396006 | 68 |
Creates a Keras model of the ResNet101 classification layers on top of a passed in base model. | def resnet101_classifier(num_rois, num_classes, base_model = None, weight_regularizer=None, bias_regularizer=None):
roi_input = Input(shape=(None, 4), name='roi_input')
pooling_input = base_model.output if base_model else Input(shape=(None, None, FINAL_CONV_FILTERS))
model_input = base_model.input if base_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_model(num_classes=43):\n model = models.Sequential()\n model.add(layers.Conv2D(64, (3, 3), activation='relu',\n input_shape=(32, 32, 3)))\n model.add(layers.Conv2D(64, (3, 3), activation='relu',\n input_shape=(32, 32, 3)))\n model.add(laye... | [
"0.7128066",
"0.70930386",
"0.70458",
"0.7019832",
"0.7003545",
"0.69567436",
"0.69505155",
"0.6879751",
"0.6853782",
"0.6836605",
"0.6812333",
"0.67720383",
"0.67675203",
"0.6765699",
"0.6755833",
"0.6752714",
"0.6739834",
"0.67379296",
"0.6736957",
"0.6724901",
"0.6724267",... | 0.61938083 | 77 |
Embed two ipa segments and measure their euclidean distance; this should correspond to their tendency to be allophones. | def dist(self,ipa_seg1,ipa_seg2):
v1 = self.embed(ipa_seg1)
v2 = self.embed(ipa_seg2)
return np.sqrt(((v1-v2)**2).sum()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pairwise_dist(self,seq1,seq2):\n \n return jf.damerau_levenshtein_distance(str(seq1), str(seq2))",
"def distanceTwoPoints(self,A,B):\n #productive\n # used by addNeedleToScene\n profprint()\n length = ( (A[0]-B[0])**2 + (A[1]-B[1])**2 + (A[2]-B[2])**2 ) ** 0.5\n return length",
"d... | [
"0.67606306",
"0.65332437",
"0.6501552",
"0.6457923",
"0.64200395",
"0.6380993",
"0.6364466",
"0.6290203",
"0.62689984",
"0.6266659",
"0.6266658",
"0.62664247",
"0.6247864",
"0.6246196",
"0.62451917",
"0.6244833",
"0.6209965",
"0.62079644",
"0.61623096",
"0.6159843",
"0.61306... | 0.80763394 | 0 |
Stop the monitor thread. | def monitor_stop(_service_or_event):
_LOGGER.info("Stopping monitor for %s", name)
mon.terminate() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_monitor(self):\n self._logger.info(\"Stopping monitor...\")\n if self.monitor_lc:\n self.monitor_lc.cancel()\n if self.monitor_process:\n self.monitor_process.terminate()\n os.system(\"pkill -f listenblock\") # To kill the spawned Go run subprocess",
... | [
"0.80320716",
"0.7971689",
"0.79214144",
"0.7916955",
"0.78480417",
"0.7749154",
"0.7681981",
"0.7632703",
"0.76182944",
"0.7616441",
"0.7562319",
"0.7502068",
"0.7459798",
"0.74423534",
"0.73142034",
"0.7310694",
"0.7203108",
"0.71779794",
"0.71779794",
"0.7152884",
"0.71430... | 0.7709552 | 6 |
Return the name of the sensor. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._sensor.name",
"def get_sensor_name(self):\n return self.data[1]",
"def name(self):\n return self.device.device_data[self.device_id]['name'] + \\\n f' {self._sensor_type}'",
"def name(self):\n return f\"{self._name} {SENSOR_TYPES[self.senso... | [
"0.91896784",
"0.9168378",
"0.890185",
"0.8770976",
"0.8511273",
"0.8479953",
"0.844435",
"0.8299758",
"0.8186503",
"0.8105667",
"0.8079737",
"0.8066149",
"0.8049647",
"0.7700968",
"0.7612295",
"0.7611456",
"0.7600605",
"0.7600605",
"0.7600605",
"0.75392073",
"0.75166553",
... | 0.0 | -1 |
Return the state attributes of the sensor. | def extra_state_attributes(self):
return {ATTR_DEVICE: "SKYBEACON", ATTR_MODEL: 1} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\r\n return self._attributes",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self) ... | [
"0.8418945",
"0.82497084",
"0.8243777",
"0.8243777",
"0.8200083",
"0.8169021",
"0.8169021",
"0.8159991",
"0.8159991",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
... | 0.0 | -1 |
Return the name of the sensor. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._sensor.name",
"def get_sensor_name(self):\n return self.data[1]",
"def name(self):\n return self.device.device_data[self.device_id]['name'] + \\\n f' {self._sensor_type}'",
"def name(self):\n return f\"{self._name} {SENSOR_TYPES[self.senso... | [
"0.91896784",
"0.9168378",
"0.890185",
"0.8770976",
"0.8511273",
"0.8479953",
"0.844435",
"0.8299758",
"0.8186503",
"0.8105667",
"0.8079737",
"0.8066149",
"0.8049647",
"0.7700968",
"0.7612295",
"0.7611456",
"0.7600605",
"0.7600605",
"0.7600605",
"0.75392073",
"0.75166553",
... | 0.0 | -1 |
Return the state attributes of the sensor. | def extra_state_attributes(self):
return {ATTR_DEVICE: "SKYBEACON", ATTR_MODEL: 1} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\r\n return self._attributes",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self) ... | [
"0.8418945",
"0.82497084",
"0.8243777",
"0.8243777",
"0.8200083",
"0.8169021",
"0.8169021",
"0.8159991",
"0.8159991",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
"0.8145903",
... | 0.0 | -1 |
Returns the first_name plus the last_name, with a space in between. | def get_full_name(self) -> str:
return f"{self.first_name} {self.last_name}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_name(first_name, last_name):\n return first_name + \" \" + last_name",
"def full_name(first_name, last_name):\n\t\n\treturn first_name + \" \" + last_name",
"def get_formated_name(first_name,last_name):\n\tfull_name = first_name + '' + last_name\n\treturn full_name.title()",
"def get_full_name(se... | [
"0.8313066",
"0.82006806",
"0.8049215",
"0.80409706",
"0.8017754",
"0.7999701",
"0.79541886",
"0.7942144",
"0.7942144",
"0.7942144",
"0.7937664",
"0.79287225",
"0.7921711",
"0.790314",
"0.7892264",
"0.7890117",
"0.7878668",
"0.786143",
"0.78528684",
"0.7823523",
"0.7813124",
... | 0.76168615 | 75 |
Returns the short name for the user. | def get_short_name(self) -> str:
return self.first_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_short_name(self):\n return self.username",
"def get_short_name(self):\n return self.username",
"def get_short_name(self):\n return self.username",
"def get_short_name(self):\n # The user is identified by their email address\n return self.first_name",
"def get_shor... | [
"0.90316343",
"0.90316343",
"0.90316343",
"0.8829965",
"0.88074076",
"0.8665172",
"0.8423785",
"0.8307673",
"0.8281205",
"0.8281205",
"0.81919736",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0... | 0.8335693 | 7 |
`EMailAddress` fulfills the `IEMailAddress` interface. | def test_address__EMailAddress__1():
zope.interface.verify.verifyObject(IEMailAddress, EMailAddress()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_address(self, email_address: \"str\"):\n self._attrs[\"emailAddress\"] = email_address",
"def email_address(self) -> \"str\":\n return self._attrs.get(\"emailAddress\")",
"def email_address(self) -> str:\n return self._email_address",
"def email_address(self, email_address: str... | [
"0.6575288",
"0.64950085",
"0.64579916",
"0.6131975",
"0.6025894",
"0.60043603",
"0.5961127",
"0.59554297",
"0.58573127",
"0.5845955",
"0.5845955",
"0.5845955",
"0.58273154",
"0.58237827",
"0.58150816",
"0.5751274",
"0.56745785",
"0.5644719",
"0.56211364",
"0.5594601",
"0.559... | 0.6616022 | 0 |
A really empty postal address has a title of 'none'. | def test_address__postal_address_title__1(zcmlS):
pa = PostalAddress()
pa.country = None # reset default value of `Germany`
assert u'none' == ITitle(pa) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_address__phone_number_title__1(zcmlS):\n assert u'none' == ITitle(PhoneNumber())",
"def test_address__postal_address_title__3(zcmlS):\n pa = PostalAddress()\n pa.address_prefix = u'c/o Mama'\n pa.street = u'Papa street 3 a'\n pa.zip = u'12345'\n pa.city = u'Dingshausen'\n assert (u'... | [
"0.64308167",
"0.63877356",
"0.63581485",
"0.6342017",
"0.6312883",
"0.6271514",
"0.6171144",
"0.5977026",
"0.59618914",
"0.59343565",
"0.5917596",
"0.58876866",
"0.5782001",
"0.57356155",
"0.5676563",
"0.5672931",
"0.5656839",
"0.5647892",
"0.5640917",
"0.56102604",
"0.55778... | 0.78182733 | 0 |
`postal_address_title` is able to render the full address. | def test_address__postal_address_title__3(zcmlS):
pa = PostalAddress()
pa.address_prefix = u'c/o Mama'
pa.street = u'Papa street 3 a'
pa.zip = u'12345'
pa.city = u'Dingshausen'
assert (u'c/o Mama, Papa street 3 a, 12345, Dingshausen, Germany' ==
ITitle(pa)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_address__postal_address_title__1(zcmlS):\n pa = PostalAddress()\n pa.country = None # reset default value of `Germany`\n assert u'none' == ITitle(pa)",
"def test_address__postal_address_title__2(zcmlS):\n pa = PostalAddress()\n pa.street = u'Papa street 3 a'\n assert u'Papa street 3 a... | [
"0.7070961",
"0.7062273",
"0.6978884",
"0.67677826",
"0.66240066",
"0.6560572",
"0.63749677",
"0.6369803",
"0.6324753",
"0.6323915",
"0.6323063",
"0.6315863",
"0.62620693",
"0.62382877",
"0.62153846",
"0.6200656",
"0.6188068",
"0.61759895",
"0.61531645",
"0.6129766",
"0.61195... | 0.68578833 | 3 |
An empty email address has a title of 'none'. | def test_address__email_address_title__1(zcmlS):
assert u'none' == ITitle(EMailAddress()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_blank_email(self):\n rv = self.signup('Bo', 'Theo', '', 'Bo1995', 'Bo1995')\n self.assertIn(b'Field must be between 6 and 30 characters long.', rv.data)",
"def test_clean_email_empty(self):\n\n raw_email = 'from=<>'\n result = clean_email(raw_email)\n self.assertEqual(... | [
"0.66553444",
"0.6637005",
"0.64359033",
"0.63364977",
"0.6198812",
"0.6126723",
"0.6096096",
"0.6088302",
"0.60620964",
"0.6033238",
"0.59954655",
"0.59245265",
"0.59007007",
"0.5860275",
"0.58321434",
"0.5815138",
"0.5797517",
"0.57697994",
"0.5760658",
"0.5758798",
"0.5735... | 0.72898865 | 0 |
`email_address_title` renders the email address if set. | def test_address__email_address_title__2(zcmlS):
ea = EMailAddress()
ea.email = u'tester@example.org'
assert u'tester@example.org' == ITitle(ea) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_address(self, email_address: \"str\"):\n self._attrs[\"emailAddress\"] = email_address",
"def test_address__email_address_title__1(zcmlS):\n assert u'none' == ITitle(EMailAddress())",
"def email_address(self) -> \"str\":\n return self._attrs.get(\"emailAddress\")",
"def displayname... | [
"0.6634025",
"0.65544415",
"0.6334045",
"0.61618733",
"0.60610723",
"0.5928594",
"0.5923661",
"0.59220517",
"0.5904097",
"0.58510286",
"0.5786233",
"0.57532173",
"0.57532173",
"0.57532173",
"0.57532173",
"0.5692212",
"0.56840754",
"0.56834984",
"0.56553644",
"0.56553644",
"0.... | 0.6133336 | 4 |
An empty home page address has a title of 'none'. | def test_address__home_page_address_title__1(zcmlS):
assert u'none' == ITitle(HomePageAddress()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_home_page(self):\n return not self.title and self.category is None",
"def test_home_page_title(self):\n response = self.client.get('/')\n self.assertIn(site_main_title, response.content.title().decode())",
"def ishome(self) -> bool:\n pass",
"def go_home(self):\r\n i... | [
"0.73061264",
"0.6611779",
"0.6549926",
"0.6512639",
"0.6451303",
"0.63789827",
"0.6354246",
"0.6312345",
"0.6180358",
"0.6165196",
"0.61481225",
"0.6115395",
"0.60608286",
"0.6036514",
"0.60295653",
"0.6005833",
"0.5982511",
"0.5979746",
"0.5970174",
"0.5925152",
"0.5917377"... | 0.7212746 | 1 |
Should get a response for index_view | def test_get_response(self):
c = Client()
response = c.get(reverse('index_view'))
self.assertEqual(response.status_code, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_index_view(self):\n response = self.client.get('/')\n eq_(response.status_code, 200)",
"def test_index_view(self):\n response = self.client.get(reverse('index'))\n self.assertEquals(response.status_code, 200)",
"def test_index_view(self):\n response = self.client.get... | [
"0.8095904",
"0.7845433",
"0.782158",
"0.7718163",
"0.7575526",
"0.74780184",
"0.74763775",
"0.7443849",
"0.7407937",
"0.73874086",
"0.7376741",
"0.73649764",
"0.73514485",
"0.7256127",
"0.72414166",
"0.7228027",
"0.72251457",
"0.7224616",
"0.7217547",
"0.7213208",
"0.7206027... | 0.7302546 | 13 |
Left > Root > Right | def print_in_order(self):
self._print_in_order(self.root) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _uproot(self):\n left, right = self.left, self.right\n if left is not None:\n left.parent = None\n if right is not None:\n right.parent = None\n return left, right",
"def test_right_sided_tree_with_two_nodes_root_has_child(empty_t):\n empty_t.insert(10)\n ... | [
"0.70784307",
"0.69766366",
"0.6851301",
"0.66160506",
"0.6586332",
"0.6527517",
"0.6496328",
"0.64527637",
"0.63941693",
"0.6380981",
"0.6361701",
"0.630774",
"0.6298266",
"0.62820125",
"0.625141",
"0.6236812",
"0.62137413",
"0.61986184",
"0.6190501",
"0.61833656",
"0.617814... | 0.0 | -1 |
Extract timestamp from logline and convert it to a datetime object. | def convert_to_datetime(line):
pattern = r'[A-Z]\s([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2})'
m = re.search(pattern, line)
dt_str = m.group(1)
dt = dt_parser.parse(dt_str)
return dt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetLogTime(self, line):\r\n if not re.match(r\"\\d+-\\d+-\\d\", line):\r\n return None\r\n\r\n # Split the timestamp at the beginning of the line\r\n time_split = re.split(r\"-\\d{4}\\s\", line)\r\n\r\n # Create a datetime object\r\n time_object = datetime.datetime.strptime(time_split[0],\r... | [
"0.7894984",
"0.77740496",
"0.695406",
"0.68546563",
"0.6769478",
"0.67109925",
"0.6622672",
"0.6456695",
"0.63138235",
"0.616476",
"0.6128174",
"0.6100498",
"0.6089461",
"0.598432",
"0.5888641",
"0.5876601",
"0.5875058",
"0.5857872",
"0.58554876",
"0.58303213",
"0.5822145",
... | 0.678654 | 4 |
GET method to give index page | async def index(request):
async with request.app['db'].acquire() as conn:
query = db.users.select().where(db.users.c.id == 0)
result = await conn.fetch(query)
return {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index():\n\n return {\n 'page': 'index',\n }",
"def get_index(self):\n self.client.get('/')",
"def index_fn():\n page_title = \"Index\"\n \n if request.method == \"GET\":\n return render_template(\"index.html\",\n pg_title=page_title,\n ... | [
"0.79317015",
"0.78113776",
"0.76708597",
"0.75761515",
"0.7501288",
"0.7454135",
"0.74068",
"0.7381321",
"0.7357477",
"0.73419756",
"0.732147",
"0.7307594",
"0.72465545",
"0.7199229",
"0.7156537",
"0.71545565",
"0.7138021",
"0.7130101",
"0.7130101",
"0.7130101",
"0.7127526",... | 0.0 | -1 |
use pythagorean theorem to find distance between 2 points | def get_distance(point1, point2):
a = (point1['x'] - point2['x']) ** 2
b = (point1['y'] - point2['y']) ** 2
return (a + b) ** (1.0 / 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(a: Point, b: Point) -> float:\n return math.sqrt(math.pow(b.x - a.x, 2) + math.pow(b.y - a.y, 2))",
"def distance(pt1, pt2):\n\tx1, y1 = pt1\n\tx2, y2 = pt2\n\tx = x2 - x1\n\ty = y2 - y1\n\ts = x**2 + y**2\n\treturn np.sqrt(s)",
"def get_distance(x1, y1, x2, y2):\n return math.sqrt((x1 - x2)... | [
"0.81103736",
"0.811019",
"0.80318433",
"0.8021718",
"0.7996506",
"0.7973252",
"0.7958827",
"0.7957725",
"0.79562575",
"0.79458326",
"0.7934458",
"0.7917717",
"0.7911169",
"0.7903556",
"0.78938276",
"0.7881318",
"0.78785694",
"0.7875536",
"0.7873968",
"0.7867094",
"0.785848",... | 0.751348 | 72 |
Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. | def sort_012(input_list):
aux_dict = {}
for i in input_list:
if type(i) is not int or not 0 <= i <= 2:
return "Invalid argument"
if i not in aux_dict:
aux_dict[i] = 0
aux_dict[i] += 1
return ([0] * aux_dict[0] if 0 in aux_dict else []) + \
([1] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort(array):\n\n for i in range(0, len(array)):\n for j in range(len(array)-1, i, -1):\n if array[j] < array[j-1]:\n ## Move the lighter bubble up\n _temp = array[j]\n array[j] = array[j-1]\n array[j-1] = _temp\n \n ... | [
"0.67902184",
"0.67568636",
"0.66841114",
"0.6669199",
"0.66594225",
"0.6642779",
"0.66002",
"0.65886194",
"0.65529597",
"0.65501475",
"0.6499986",
"0.6486351",
"0.6464038",
"0.6443789",
"0.64297307",
"0.64286256",
"0.6421149",
"0.6420366",
"0.6417744",
"0.6404247",
"0.638730... | 0.0 | -1 |
Returns ID of parent analytic account based on the value of 'default_parent_id' context key, or None if it cannot be resolved to a single account.analytic.account | def _resolve_analytic_account_id_from_context(self, cr, uid, context=None):
if context is None:
context = {}
if type(context.get('default_parent_id')) in (int, long):
return context['default_parent_id']
if isinstance(context.get('default_parent_id'), basestring):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _default_parent_id(self):\n active_id = self.env.context.get('active_id')\n if not active_id:\n return False\n ticket = self.browse(active_id)\n if not ticket.parent_id:\n return active_id\n elif not ticket.type.has_children:\n return ticket.p... | [
"0.72689587",
"0.68581516",
"0.68581516",
"0.6574403",
"0.6553922",
"0.65482193",
"0.6515276",
"0.64323163",
"0.63847",
"0.6357428",
"0.6357428",
"0.6314105",
"0.6308585",
"0.6275099",
"0.62470776",
"0.61945814",
"0.6143773",
"0.6143773",
"0.61077136",
"0.61077136",
"0.610107... | 0.8411692 | 0 |
Returns the mean landmark translated to x and y. | def getTranslatedMean(self, x, y):
return self.meanLandmark.translate(x, y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTranslatedAndInverseScaledMean(self, x, y):\n if self.name == 1:\n return self.meanLandmark.scale(self.meanScale * 0.8).translate(x, y)\n\n return self.meanLandmark.scale(self.meanScale).translate(x, y)",
"def get_mean_coord(self):\n # load dataset in a dummy manner\n ... | [
"0.76252717",
"0.6780492",
"0.6736275",
"0.6686297",
"0.66434413",
"0.66201663",
"0.66144544",
"0.646295",
"0.62793386",
"0.62758166",
"0.62735265",
"0.623081",
"0.6217785",
"0.6085483",
"0.6084838",
"0.6077369",
"0.60525715",
"0.6025422",
"0.6023019",
"0.6010154",
"0.6002302... | 0.82277626 | 0 |
Returns the squared Mahalanobis distance of a new gray level profile from the built gray level model with index landmarkPointIndex. | def mahalanobisDistance(self, normalizedGrayLevelProfile, landmarkPointIndex):
Sp = self.C_yj[landmarkPointIndex]
pMinusMeanTrans = (normalizedGrayLevelProfile - self.meanProfilesForLandmarkPoints[landmarkPointIndex])
return pMinusMeanTrans.T @ Sp @ pMinusMeanTrans | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_mahalanobis_distance(point, centroid, sd, dimension):\n x = 0 # initialize\n for i in range(dimension):\n x += ((point[i]-centroid[i]) / sd[i]) ** 2 # calculate sum of squares\n\n return x ** 0.5 # return mahalanobis distance",
"def mahalanobis_distance(self, x: np.ndarray) -... | [
"0.63910484",
"0.62413347",
"0.6069017",
"0.5920619",
"0.5719909",
"0.5660642",
"0.55381817",
"0.5392169",
"0.5387014",
"0.53545237",
"0.5324508",
"0.51521164",
"0.51422065",
"0.50880665",
"0.50654554",
"0.5013631",
"0.49948198",
"0.49587294",
"0.49418697",
"0.4938101",
"0.49... | 0.8393171 | 0 |
Bad request because missing either 'email' or 'username' field | async def test_post_password_recoveries__bad_request(client):
response = await client.post(
"/password_recoveries/", json={"some-useless-field": "foo"}
)
assert response.status == 400 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_login_missing_email(self):\n response = self.client.post('/api/v2/auth/login',\n data=json.dumps(users[6]),\n content_type='application/json')\n self.assertEqual(response.status_code, 400)\n self.assertIn('Missing r... | [
"0.72924054",
"0.7196817",
"0.71262723",
"0.7122745",
"0.70591927",
"0.7027526",
"0.6989337",
"0.6935636",
"0.68425137",
"0.6840508",
"0.6797867",
"0.6796428",
"0.67636985",
"0.6761608",
"0.6759129",
"0.6749441",
"0.6741007",
"0.6709953",
"0.67077166",
"0.66891813",
"0.667430... | 0.0 | -1 |
test_write_stock_csv should write stocks list to csv file | def test_write_stock_csv(self):
obj1 = collections.OrderedDict(
[('a', 'A1'), ('b', 'B1'), ('c', 'C1')])
obj2 = collections.OrderedDict(
[('a', 'A2'), ('b', 'B2'), ('c', 'C2')])
objects1 = [obj1, obj2]
write_stock_csv('test.csv', objects1)
objects2 = read_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_csv(self, stock_list):\n\n with open(self.outfile, 'w') as outfile:\n writer = csv.writer(outfile, delimiter=',',\n quoting=csv.QUOTE_MINIMAL)\n for symbol, values in stock_list.items():\n # Need to find a better way to handle thi... | [
"0.7499189",
"0.6870502",
"0.6778869",
"0.6755973",
"0.6652575",
"0.661904",
"0.6572605",
"0.6507047",
"0.6499869",
"0.64451003",
"0.639779",
"0.638123",
"0.63664067",
"0.6345303",
"0.633595",
"0.6313448",
"0.62937444",
"0.6255691",
"0.6181912",
"0.6155778",
"0.61188984",
"... | 0.76222926 | 0 |
Write the given input texts and (optionally) labels to the file pointed to by ``input_path``. | def _write_input(
self, X: List[str], labels: Optional[List[List[str]]], input_path: Path
):
df = pd.DataFrame({"Text": X})
if labels is not None:
df["Label"] = labels
df.to_csv(input_path, sep="\t", index=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _write_input(\n self,\n X: List[str],\n labels: Optional[Union[List[str], List[List[str]]]],\n input_path: Path,\n ):\n df = pd.DataFrame({\"Text\": X})\n\n if labels is not None:\n df[\"Label\"] = labels\n\n df.to_csv(input_path, sep=\"\\t\", inde... | [
"0.684504",
"0.6668793",
"0.6668793",
"0.635559",
"0.6217582",
"0.6160168",
"0.577795",
"0.576962",
"0.5678321",
"0.55674744",
"0.5549849",
"0.5538833",
"0.55052674",
"0.54890496",
"0.5488365",
"0.5448648",
"0.543804",
"0.542459",
"0.53980565",
"0.5387054",
"0.5384514",
"0.... | 0.6839173 | 1 |
Mandatory override function in superclass. Returns length of loaded dataset. | def __len__(self):
return len(self.output) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_dataset_size(loader):\n if isinstance(loader, (tuple, list)):\n return len(loader[0].dataset)\n else:\n return len(loader.dataset)",
"def __len__(self):\n return len(self.dataset)",
"def __len__(self):\n return self._dataset.size(dirs=self._dirs)",
"... | [
"0.80030566",
"0.7943926",
"0.7820067",
"0.7766852",
"0.7678906",
"0.75396556",
"0.75396556",
"0.75396556",
"0.75043267",
"0.7501755",
"0.7497508",
"0.7497508",
"0.74825704",
"0.74715525",
"0.74570704",
"0.74471617",
"0.7420353",
"0.7386651",
"0.7376123",
"0.7365217",
"0.7364... | 0.0 | -1 |
Creates a sizex by sizey matrix filled with zeros. | def make_matrix(sizex, sizey):
return [[0]*sizey for i in xrange(sizex)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix_init(sizex, sizey):\n return [[0]*sizey for i in range(sizex)]",
"def make_matrix(sizex, sizey):\n return [[0] * sizey for i in range(sizex)]",
"def zeroes(height, width):\n g = [[0.0 for _ in range(width)] for __ in range(height)]\n return Matrix(g)",
"def zeroMatrix(width, he... | [
"0.8044378",
"0.79192764",
"0.7141801",
"0.71086985",
"0.70619905",
"0.7058825",
"0.63757265",
"0.6285351",
"0.6129874",
"0.6119288",
"0.6119288",
"0.6112796",
"0.6047175",
"0.59919316",
"0.5989762",
"0.5955519",
"0.5932239",
"0.5928885",
"0.58918095",
"0.5875584",
"0.5867596... | 0.7826062 | 2 |
Return safe defaults in case the model has been deactivated. | def defaults():
return {"cr_shelter_unit_id": S3ReusableField.dummy("shelter_unit_id"),
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dealWithDefaultValues(self):\n return _libsbml.Model_dealWithDefaultValues(self)",
"def get_defaults(self):\n\t\treturn self.__defaults",
"def defaults(self):\n\n return None",
"def defaults(self):\n\n return None",
"def save_defaults(self):\n\n pass",
"def defaults(self) ... | [
"0.6704352",
"0.6437775",
"0.6197481",
"0.6197481",
"0.58717006",
"0.58687043",
"0.57729316",
"0.5717376",
"0.564481",
"0.5623723",
"0.559991",
"0.55781573",
"0.55714065",
"0.5563264",
"0.55541",
"0.5542086",
"0.55243695",
"0.55159396",
"0.5508865",
"0.54931754",
"0.547874",
... | 0.0 | -1 |
Test that 2 values are substracted and returned correctly | def test_sub_numbers(self):
a, b = 5, 10
expected = b - a
self.assertEqual(subtract(b, a), expected) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtract(first, second):\n return first - second",
"def subtract(a, b):\n return a - b",
"def subtract(a, b):\n return a - b",
"def test_subtract(self):\n self.assertEqual(work_file.subtract(10, 5), 5)\n self.assertEqual(work_file.subtract(-1, 1), -2)\n self.assertEqual(work... | [
"0.804061",
"0.79145193",
"0.79145193",
"0.78542084",
"0.7803446",
"0.779536",
"0.77492326",
"0.77427816",
"0.7698939",
"0.76966065",
"0.76601917",
"0.7639433",
"0.7638072",
"0.7626434",
"0.7626434",
"0.7611759",
"0.7607299",
"0.76019794",
"0.7557734",
"0.7557734",
"0.7557734... | 0.79995584 | 1 |
Checks to see if there are four matching pieces in a row, either vertically, horizontally, or diagonally. If a chain of four is found, sets the game state to finished. | def check_four_in_a_row(self, player_symbol, row, col, step_row_1, step_col_1, step_row_2, step_col_2):
num_connected = 1 # Tally of how many game pieces were found matching thus far
def increment_connected(step_row, step_col):
"""
Checks to see if the game is over. This occurs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_horizontal_four(self, row, col):\r\n player = self.board[row][col]\r\n consecutiveL = 0\r\n consecutiveR = 0\r\n # count consecutive left discs\r\n i = col\r\n current = player\r\n while current == player:\r\n consecutiveL += 1\r\n i -= ... | [
"0.6922374",
"0.66840625",
"0.64892954",
"0.64408207",
"0.63848925",
"0.6353268",
"0.6328373",
"0.62730414",
"0.6174195",
"0.6171858",
"0.6111728",
"0.6059355",
"0.604693",
"0.60390556",
"0.60211223",
"0.6010612",
"0.5994626",
"0.5972163",
"0.5957336",
"0.5956504",
"0.5956266... | 0.7492082 | 0 |
Bulk write documents until success. | def bulk_write(self, dbname, collname, reqs):
while True:
try:
self._mc[dbname][collname].bulk_write(reqs,
ordered=True,
bypass_document_validation=False)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _batch_write(self):\n if self.to_put:\n db.put(self.to_put)\n self.to_put = []\n if self.to_delete:\n db.delete(self.to_delete)\n self.to_delete = []",
"def bulk_process(self):\n\n def actions():\n try:\n task = self.q... | [
"0.7192743",
"0.65246505",
"0.63898623",
"0.6385667",
"0.63492996",
"0.6334286",
"0.6257019",
"0.6244905",
"0.6218736",
"0.6209886",
"0.6157362",
"0.6113165",
"0.6098169",
"0.60600716",
"0.6022036",
"0.60178256",
"0.6005164",
"0.5988246",
"0.59769654",
"0.5952172",
"0.5941964... | 0.7383944 | 0 |
Check if image in real board. Only for testing purposes. | def is_image(pos, image, start_pos, dim_square):
# Grab image on real board
im = region_grabber((start_pos[0] + pos[1] * dim_square[0],
start_pos[1] - (pos[0] + 1.0) * dim_square[1],
start_pos[0] + (pos[1] + 1.0) * dim_square[0],
start_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_complete_board(start_pos, dim_square, board):\n change = False\n for row in range(8):\n for col in range(8):\n # Grab image on real board\n im = region_grabber((start_pos[0] + col * dim_square[0],\n start_pos[1] - (row + 1.0) * dim_square... | [
"0.71885407",
"0.68555164",
"0.67893136",
"0.673317",
"0.67161083",
"0.6665011",
"0.6631849",
"0.65990996",
"0.6558072",
"0.6558072",
"0.6541214",
"0.65381455",
"0.6522217",
"0.65121466",
"0.65118283",
"0.64880115",
"0.64880115",
"0.64669675",
"0.6450527",
"0.64136064",
"0.63... | 0.7508351 | 0 |
Sort self.population by fitness (syllabification accuracy) | def _sort(self):
self.population.sort()
self.population.reverse() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_population(self):\n self.population.sort(key=lambda x: x.fitness, reverse=True)",
"def sortPopulation(self, population):\n\t\tpopulation.sort(lambda a, b: cmp(b.fitness, a.fitness))",
"def sortPopulation(self):\n self.population = sorted(self.population, key=attrgetter('fitness'), revers... | [
"0.87737924",
"0.86788595",
"0.8601598",
"0.81122667",
"0.79397",
"0.7820548",
"0.76353085",
"0.7547891",
"0.7450132",
"0.7239935",
"0.70309937",
"0.6798045",
"0.6756193",
"0.6711694",
"0.6597281",
"0.6593974",
"0.6577862",
"0.6548365",
"0.6532791",
"0.63001645",
"0.62502646"... | 0.75675005 | 7 |
error message in dictionary format | def to_dict(self):
error_message = dict()
error_message['message'] = self.message
return error_message | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def err(error_dictionary):\n return {'error': error_dictionary['message']}, error_dictionary['code']",
"def format_error(invalid, doc_type):\n # using string for checking is probably not ideal,\n # but voluptuous does not have specific sub error\n # types for these errors\n if invalid.error_messag... | [
"0.76499707",
"0.7378972",
"0.7279438",
"0.71593463",
"0.7040711",
"0.6938815",
"0.6931366",
"0.68156344",
"0.678888",
"0.67476755",
"0.6720692",
"0.6715239",
"0.6705228",
"0.6703433",
"0.6617815",
"0.6614262",
"0.65905756",
"0.6565387",
"0.6528504",
"0.65272206",
"0.6499777"... | 0.73649246 | 3 |
error message in dictionary format | def to_dict(self):
error_message = dict()
error_message['message'] = self.message
return error_message | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def err(error_dictionary):\n return {'error': error_dictionary['message']}, error_dictionary['code']",
"def format_error(invalid, doc_type):\n # using string for checking is probably not ideal,\n # but voluptuous does not have specific sub error\n # types for these errors\n if invalid.error_messag... | [
"0.76499707",
"0.7378972",
"0.7279438",
"0.71593463",
"0.7040711",
"0.6938815",
"0.6931366",
"0.68156344",
"0.678888",
"0.67476755",
"0.6720692",
"0.6715239",
"0.6705228",
"0.6703433",
"0.6617815",
"0.6614262",
"0.65905756",
"0.6565387",
"0.6528504",
"0.65272206",
"0.6499777"... | 0.73649246 | 2 |
If we have an array [1,2,3,4,6,7,8] then 1 then 2 then 3 then 4 are all consecutive but 6 is not, so that's the first nonconsecutive number. | def test_first_non_consecutive_positive(self):
allure.dynamic.title("Non consecutive number should be returned")
allure.dynamic.severity(allure.severity_level.NORMAL)
allure.dynamic.description_html('<h3>Codewars badge:</h3>'
'<img src="https://www.codewa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_uniques_consecutive(array):\n val = array[0]\n indices = []\n for idx, element in enumerate(array):\n if element != val:\n indices.append(idx)\n val = element\n return indices",
"def all_non_consecutive(arr):\n return [{'i': i + 1, 'n': arr[i + 1]} for i in ra... | [
"0.7205783",
"0.6978893",
"0.64937234",
"0.6451656",
"0.63255125",
"0.61780334",
"0.6162221",
"0.6138022",
"0.61095184",
"0.609287",
"0.6091891",
"0.607028",
"0.6048456",
"0.5907556",
"0.5887999",
"0.58820367",
"0.58790714",
"0.5838989",
"0.5787702",
"0.577735",
"0.57750547",... | 0.5338121 | 62 |
Calculates the Euclidean distance between two ndimensional points. | def euclidean_distance(x: np.ndarray, y: np.ndarray) -> float:
distance = np.linalg.norm(x - y)
return distance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euclidean_distance(point_one, point_two):\n return np.linalg.norm(point_one-point_two)",
"def euclidean_distance(point1, point2):\n return np.linalg.norm(np.array(point1) - np.array(point2))",
"def euclidean_distance(point1, point2):\n\n return math.sqrt(sum([(x - y) ** 2 for x, y in zip(point1, p... | [
"0.8113031",
"0.80638844",
"0.80350214",
"0.79191804",
"0.79120433",
"0.78668535",
"0.7677741",
"0.7667952",
"0.76411223",
"0.7616137",
"0.76140165",
"0.7587541",
"0.75603145",
"0.7559601",
"0.747789",
"0.74760985",
"0.7470736",
"0.7409104",
"0.7404642",
"0.73925745",
"0.7384... | 0.75936145 | 11 |
Selects nindividuals based on a tournament selection. | def tournament_selection(
fitness: List[float], n: int, size: Optional[int] = 2
) -> np.array:
selected = []
for _ in range(n):
step = [np.random.choice(fitness) for _ in range(size)]
selected.append(np.where(min(step) == fitness)[0][0])
return selected | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select(individuals, n):\r\n # return selBest(individuals, n)\r\n return individuals[:n]",
"def tournament_selection(random, population, args):\r\n num_selected = args.setdefault('num_selected', 1)\r\n tournament_size = args.setdefault('tournament_size', 2)\r\n if tournament_size > len(populati... | [
"0.7670836",
"0.6781968",
"0.6779319",
"0.6696371",
"0.65584224",
"0.6494462",
"0.6480758",
"0.6448931",
"0.64086753",
"0.63414335",
"0.6203028",
"0.61687315",
"0.61512125",
"0.6116255",
"0.6103634",
"0.60695887",
"0.6026936",
"0.59772146",
"0.57734156",
"0.5756821",
"0.57305... | 0.66073257 | 4 |
Check primality of n | def is_prime(n):
if n <= 1: return False
if n <= 3: return True
if (n % 2 == 0 or n % 3 == 0):
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime(n):\n return mr_prime(n)",
"def isprime(n):\r\n\treturn is_prime(n)",
"def isprime(n):\n\treturn is_prime(n)",
"def test_prime(n):\n if SIEVE[n]:\n return True\n else:\n return False",
"def ll_primality(n: int) -> bool:\n if n <= 2 or not trial_div(n):\n return... | [
"0.80992275",
"0.8091926",
"0.80086535",
"0.79091895",
"0.7862459",
"0.78593487",
"0.78580266",
"0.78325564",
"0.77968925",
"0.7771323",
"0.7751659",
"0.77158827",
"0.7701474",
"0.76703954",
"0.76624835",
"0.76412416",
"0.7622049",
"0.7607035",
"0.7601526",
"0.759262",
"0.759... | 0.7461934 | 41 |
Tests whether ``AutoModerationActionMetadataSendAlertMessage.copywith`` works as expected. | def test__AutoModerationActionMetadataSendAlertMessage__copy_with__0():
channel_id = 202211130005
metadata = AutoModerationActionMetadataSendAlertMessage(channel_id)
copy = metadata.copy_with()
_assert_fields_set(copy)
vampytest.assert_eq(metadata, copy)
vampytest.assert_is_not(metadat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__AutoModerationActionMetadataSendAlertMessage__copy():\n channel_id = 202211130004\n metadata = AutoModerationActionMetadataSendAlertMessage(channel_id)\n \n copy = metadata.copy()\n \n _assert_fields_set(copy)\n vampytest.assert_eq(metadata, copy)\n vampytest.assert_is_not(metadat... | [
"0.8365034",
"0.8132742",
"0.6109042",
"0.5947049",
"0.59106904",
"0.5738674",
"0.5691074",
"0.56470615",
"0.56146604",
"0.5582267",
"0.55611527",
"0.5546766",
"0.5496249",
"0.54696953",
"0.54543877",
"0.54482365",
"0.5444191",
"0.5437268",
"0.5435533",
"0.5413261",
"0.538999... | 0.8769369 | 0 |
Tests whether ``AutoModerationActionMetadataSendAlertMessage.copywith`` works as expected. | def test__AutoModerationActionMetadataSendAlertMessage__copy_with__1():
old_channel_id = 202211130006
new_channel_id = 202211130007
metadata = AutoModerationActionMetadataSendAlertMessage(old_channel_id)
copy = metadata.copy_with(channel_id = new_channel_id)
_assert_fields_set(copy)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__AutoModerationActionMetadataSendAlertMessage__copy_with__0():\n channel_id = 202211130005\n metadata = AutoModerationActionMetadataSendAlertMessage(channel_id)\n \n copy = metadata.copy_with()\n \n _assert_fields_set(copy)\n vampytest.assert_eq(metadata, copy)\n vampytest.assert_i... | [
"0.87702733",
"0.8365242",
"0.61075175",
"0.59471005",
"0.5909267",
"0.5737132",
"0.5689219",
"0.5647191",
"0.5612684",
"0.55815345",
"0.5560786",
"0.55463266",
"0.54960096",
"0.5470252",
"0.5453037",
"0.5450252",
"0.54432315",
"0.54368407",
"0.5436774",
"0.54125553",
"0.5390... | 0.8133036 | 2 |
Create JWT token that the user can use to verify its account. | def gen_verification_token(user):
exp_date = timezone.now() + timedelta(days=3)
payload = {
'user': user.username,
'exp': int(exp_date.timestamp()),
'type': 'email_confirmation'
}
token = jwt.encode(payload, settings.SECRET_KEY, algorithm='HS256')
return token.decode() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_auth_token():\n data = get_request_data(request)\n address = data.get(\"address\")\n expiration = int(data.get(\"expiration\"))\n\n pk = get_provider_private_key(use_universal_key=True)\n token = jwt.encode({\"exp\": expiration, \"address\": address}, pk, algorithm=\"HS256\")\n token =... | [
"0.8282378",
"0.80514276",
"0.7851687",
"0.7721485",
"0.7649764",
"0.7649361",
"0.7649308",
"0.7645845",
"0.7607744",
"0.76066774",
"0.75824034",
"0.75423574",
"0.7538712",
"0.7521649",
"0.7513469",
"0.75050616",
"0.7489892",
"0.74733555",
"0.74679905",
"0.7365179",
"0.735080... | 0.72012657 | 27 |
String format of the bag | def string(self):
text = ""
for char, qty in self.chars.items():
text += char * qty
return "".join(sorted(text)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return \"Bag({})\".format(self.items)",
"def __str__(self) -> str:\n out = \"BAG: \" + str(self.da.length()) + \" elements. [\"\n out += ', '.join([str(self.da.get_at_index(_))\n for _ in range(self.da.length())])\n return out + ']'",
"d... | [
"0.7950907",
"0.7386061",
"0.7386061",
"0.7253224",
"0.7028062",
"0.6997094",
"0.68322074",
"0.67953736",
"0.67915803",
"0.67286205",
"0.6723436",
"0.6695357",
"0.6673068",
"0.6663958",
"0.6649888",
"0.6609714",
"0.66033703",
"0.6595756",
"0.659179",
"0.65538925",
"0.6551282"... | 0.0 | -1 |
Iterates over the Markov model training dataset and yields each word after it has been normalized. | def word_iterator(folder):
for filename in glob.glob(os.path.join(folder, "*.txt")):
with codecs.open(filename, "r", "utf8") as file:
for line in file.readlines():
for word in WORD_SPLIT_PATTERN.split(line.strip()):
if word == "":
conti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_words(document):\n stopwords = set(nltk.corpus.stopwords.words('english'))\n lemmatizer = nltk.stem.wordnet.WordNetLemmatizer()\n for token in document:\n token = token.lower()\n if token in string.punctuation: continue\n if token in stopwords: continue\n yield l... | [
"0.67787945",
"0.66020733",
"0.6427151",
"0.63987124",
"0.62096125",
"0.62070453",
"0.61821884",
"0.6125366",
"0.6113335",
"0.6111175",
"0.6073639",
"0.607104",
"0.6042077",
"0.6030016",
"0.602074",
"0.6011849",
"0.5976713",
"0.5973664",
"0.59685045",
"0.5935536",
"0.5931783"... | 0.58246803 | 27 |
Split a word into ngrams of given size. Additionnal markers are added to spot the beginning of the word and the end of the word. | def ngrams(word, size):
expanded = "^" + word + "$"
for start in range(len(expanded) - size + 1):
yield expanded[start:start + size] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_ngrams(sent, n):\n\t\n\t# EXAMPLES \n\t# > word_ngrams(tokenize('hello world'), 1)\n\t# [('hello',), ('world',)]\n\t# > word_ngrams(tokenize('hello world'), 2)\n\t# [('<s>', 'hello'), ('hello', 'world'), ('world', '</s>')]\n\n\t# YOUR CODE HERE\n\ttokenized_sent = tokenize(sent)\n\tif n != 1:\n\t\ttokeniz... | [
"0.6683455",
"0.64721507",
"0.64460325",
"0.642066",
"0.6349792",
"0.624833",
"0.623322",
"0.6215212",
"0.60293466",
"0.6022291",
"0.59631234",
"0.5948643",
"0.59212023",
"0.59210443",
"0.5913783",
"0.59074926",
"0.5856212",
"0.58303565",
"0.57855767",
"0.5782412",
"0.5768578... | 0.76383626 | 0 |
Find best annagram pseudonyms given an original name and a gender. Return the topl best lastnames for each firstname found. | def find_best_pseudonyms(original_name, gender, topk, topl):
bests = dict()
def sorting_key(tuple_):
return -tuple_[2]
for firstname, lastname, proba in find_pseudonyms(original_name, gender, topk):
if lastname is None or not basic_check(lastname):
continue
bests.setdefau... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_pseudonyms(original_name, gender, topk):\n firstnames = load_firstnames(gender)\n model = load_model()\n whitelist = LetterBag(slugify.slugify(\n WORD_SPLIT_PATTERN.sub(\"\", original_name)))\n for firstname in firstnames:\n if not whitelist.includes(firstname):\n cont... | [
"0.75637275",
"0.5974024",
"0.57639587",
"0.57553995",
"0.5727625",
"0.5718182",
"0.56577724",
"0.56511444",
"0.5596104",
"0.5521637",
"0.54962844",
"0.5455091",
"0.542547",
"0.5422269",
"0.5415745",
"0.5400399",
"0.53829455",
"0.5340641",
"0.5336451",
"0.5305794",
"0.5297481... | 0.7477746 | 1 |
Converts a symbolic quorum value into its onthewire equivalent. | def translate_rw_val(self, rw):
val = self.rw_names.get(rw)
if val is None:
return rw
elif type(rw) is int and rw >= 0:
return val
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_node(value: str) -> Node:\n if not value:\n res = Empty()\n elif value in CONCATENATION_SYMBOLS:\n res = Concatenation()\n elif value in UNION_SYMBOLS:\n res = Union()\n elif value in KLEENE_STAR_SYMBOLS:\n res = KleeneStar()\n elif value in EPSILON_SYMBOLS:\n ... | [
"0.51702935",
"0.5084005",
"0.49781507",
"0.47811675",
"0.4726146",
"0.4718772",
"0.47007942",
"0.4690973",
"0.46854898",
"0.4661592",
"0.46595207",
"0.46471363",
"0.463699",
"0.46346462",
"0.4630813",
"0.45961478",
"0.45835793",
"0.45762154",
"0.45626056",
"0.45616698",
"0.4... | 0.0 | -1 |
Turn the Home Assistant device off. | def off(self) -> bool:
off_cmd = HomeAssistantPlugin.service_map[self.domain.lower()]["off"]
return self.send(off_cmd) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_off(self, **kwargs) -> None:\n _LOGGER.debug(\n \"SynoDSMSurveillanceHomeModeToggle.turn_off(%s)\",\n self._api.information.serial,\n )\n self._api.surveillance_station.set_home_mode(False)",
"def turn_off(self, **kwargs):\n self.smartplug.turn_off()",
... | [
"0.7850617",
"0.74568003",
"0.7393454",
"0.7352647",
"0.7255848",
"0.718536",
"0.7115582",
"0.7103612",
"0.70640975",
"0.70598316",
"0.7033294",
"0.69919395",
"0.69842374",
"0.6961822",
"0.6953062",
"0.6935224",
"0.69306844",
"0.69253564",
"0.68891907",
"0.688758",
"0.6871846... | 0.7608161 | 1 |
Creates coefficients retaining top k coefficients of the block image. | def fourier_coeffs(block, num_retain_coeff):
# convert the image to a single column vector
img_vector = block.ravel()
# compute the FFT
fourier = np.fft.fft(img_vector)
# retain the top 'k' coefficients, and zero out the remaining ones
sorted_indices = np.argsort(-1.0 * np.absolute(fourier).r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_k_matrix(self):\r\n K = self.uv_vol + self.Epsilon * self.guv_vol + \\\r\n (self.Epsilon / self.Beta) * self.uv_bound\r\n return K",
"def as_top_k(\n self,\n k,\n matrix,\n type_name,\n simplify_unitsize_minibatch = True\n ):\n if k < 1:\n raise... | [
"0.56602925",
"0.54991806",
"0.54835874",
"0.5463933",
"0.5424539",
"0.5413049",
"0.5401942",
"0.5345499",
"0.532592",
"0.531647",
"0.5273666",
"0.526269",
"0.52447486",
"0.5207695",
"0.51997465",
"0.519456",
"0.5178433",
"0.51710004",
"0.51493824",
"0.5148901",
"0.5135369",
... | 0.5618071 | 1 |
getter for the regions | def get_regions(self):
return self._regions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regions(self):\n return self._regions",
"def regions(self) -> Sequence[str]:\n return pulumi.get(self, \"regions\")",
"def regions(self) -> pulumi.Output[Sequence[str]]:\n return pulumi.get(self, \"regions\")",
"def get_regions(self):\n if self.initiated is False:\n ... | [
"0.81802195",
"0.79194844",
"0.781313",
"0.7763705",
"0.772684",
"0.7590881",
"0.7494172",
"0.7459377",
"0.73858845",
"0.7261627",
"0.7240542",
"0.7153533",
"0.7117894",
"0.7087992",
"0.7021671",
"0.7021671",
"0.7000117",
"0.69225067",
"0.6917416",
"0.6864084",
"0.68468624",
... | 0.8352879 | 0 |
get a list of lines associated with a region | def get_lines_for_region(self, index):
tmp = []
for line in self._lines:
if get_region(line[0]) == index:
tmp.append(line)
if len(tmp) > 0:
return tmp
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_line_regions_from_xml_file(filename: str) -> List[Dict[str, int]]:\n xml_root_element = ElementTree.parse(filename).getroot() # nosec\n xml_line_elements = xml_root_element.findall(\"handwritten-part/line\")\n return [_get_line_region_from_xml_element(el) for el in xml_line_elements]",
"def re... | [
"0.67705333",
"0.6480109",
"0.6411146",
"0.6359232",
"0.62722015",
"0.61928856",
"0.6146658",
"0.6128025",
"0.6128025",
"0.607992",
"0.6004337",
"0.5996746",
"0.5961456",
"0.5933513",
"0.5928789",
"0.59131867",
"0.58552706",
"0.58519715",
"0.58189243",
"0.5817266",
"0.5792196... | 0.76426655 | 0 |
find if a region has associated markers defined. | def region_has_markers(self, index):
if len(self.get_points_for_region(index)) > 0:
return True
if len(self.get_lines_for_region(index)) > 0:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_has_regions(seq):\n for j in range(len(seq)):\n seq[j]['has_entries'] = 0\n if int(seq[j]['entry_count']) != 0 and int(seq[j]['is_country']) != 1:\n seq[j]['has_entries'] = 1\n\n if int(seq[j]['entry_count']) != 0 and ('regions' not in seq[j] or 'children' not in seq[j]... | [
"0.6060194",
"0.59957755",
"0.58552074",
"0.58483815",
"0.581036",
"0.574171",
"0.5732829",
"0.5700655",
"0.5697024",
"0.5693156",
"0.5689939",
"0.56572324",
"0.56381226",
"0.5628235",
"0.5625097",
"0.5625097",
"0.56234944",
"0.56207615",
"0.56041795",
"0.55909616",
"0.557039... | 0.7316687 | 0 |
Anything like VAR=1, 2, 3 will be converted to ['1', '2', '3'] | def read_list(name, default=NO_ARGUMENT, separator=","):
value = os.environ.get(name)
if value is None:
if default is NO_ARGUMENT:
return []
else:
return default
return [v.strip() for v in value.split(separator) if v.strip()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_vars(self, input):\n input = self.convert(input)\n if not isinstance(input, list):\n input = [input]\n converted = []\n for item in input:\n if item in self._variables:\n converted.append(self._variables[item])\n else:\n ... | [
"0.6551904",
"0.64629716",
"0.6372466",
"0.62758815",
"0.62310743",
"0.6197362",
"0.6190952",
"0.6100497",
"0.6083205",
"0.60695595",
"0.6057259",
"0.6035543",
"0.6014601",
"0.6001532",
"0.599806",
"0.5994971",
"0.5950771",
"0.5935739",
"0.5904567",
"0.59042424",
"0.58823985"... | 0.0 | -1 |
Ensure we can create a new Post object and view object. | def test_create_post(self):
self.test_category = Category.objects.create(name='django')
self.testuser1 = User.objects.create_superuser(
username='test_user1', password='123456789')
# self.testuser1.is_staff = True
self.client.login(username=self.testuser1.username,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_post_valid(self):\n response = self._post()\n self.assertEquals(self.model.objects.count(), 1)\n obj = self.model.objects.get()\n self.assertEquals(obj.pk, self.obj.pk)\n self.assertRedirectsNoFollow(response, obj.get_absolute_url())\n self.assertEquals(obj.name, ... | [
"0.6718318",
"0.6601472",
"0.6572695",
"0.6498801",
"0.6470121",
"0.6470121",
"0.6375783",
"0.6365215",
"0.63327426",
"0.6318878",
"0.63178396",
"0.6235738",
"0.62184966",
"0.6200379",
"0.6198572",
"0.61763394",
"0.6158209",
"0.61569965",
"0.6098442",
"0.60974216",
"0.6023251... | 0.5738871 | 71 |
Draws bounding boxes on image. | def draw_bounding_boxes_on_image(image, boxes, color=[], thickness=5):
boxes_shape = boxes.shape
if not boxes_shape:
return
if len(boxes_shape) != 2 or boxes_shape[1] != 4:
raise ValueError('Input must be of size [N, 4]')
for i in range(boxes_shape[0]):
draw_bounding_box_on_imag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_bounding_boxes(self, image_path):\n img = cv.imread(image_path, cv.IMREAD_ANYDEPTH)\n bboxes = np.zeros((img.shape[0], img.shape[1], 3), dtype=np.uint8)\n unique, counts = np.unique(img, return_counts=True)\n for uni in unique:\n if uni == 0:\n continu... | [
"0.8076397",
"0.7820277",
"0.76927733",
"0.7610535",
"0.7599556",
"0.755463",
"0.75047433",
"0.74949056",
"0.74869376",
"0.7408229",
"0.73944974",
"0.7372314",
"0.73156387",
"0.72889423",
"0.72772336",
"0.72665834",
"0.72541445",
"0.72048014",
"0.71857786",
"0.7153384",
"0.71... | 0.75017977 | 7 |
Draws bounding boxes on image (numpy array). | def draw_bounding_boxes_on_image_array(image, boxes, color=[], thickness=5):
draw_bounding_boxes_on_image(image, boxes, color, thickness)
return image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_bounding_boxes(image, boxes):\n num_boxes = boxes.shape[0]\n gt_boxes_new = boxes.copy()\n draw_image = Image.fromarray(np.uint8(image))\n for i in range(num_boxes):\n draw_image = _draw_single_box(image=draw_image,\n quad=gt_boxes_new[i,:],\n ... | [
"0.79818755",
"0.79709566",
"0.7824105",
"0.77812636",
"0.775545",
"0.7747321",
"0.7740998",
"0.76833564",
"0.76603985",
"0.7570056",
"0.7501415",
"0.74275297",
"0.7333825",
"0.7324662",
"0.72812927",
"0.7276726",
"0.7225879",
"0.72172683",
"0.72038776",
"0.720301",
"0.719058... | 0.8026695 | 0 |
Return a CamelCase or camelCase version of a snake_case str. | def to_camel_case(string: str, first_lower: bool = False) -> str:
if first_lower:
first, _, rest = string.partition("_")
else:
first, rest = ("", string)
return first.lower() + "".join(part.capitalize() for part in rest.split("_")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snake_to_camel_case(snake_str: str) -> str:\n\n words = snake_str.strip(\"_\").split(\"_\")\n return words[0] + \"\".join(word[:1].upper() + word[1:] for word in words[1:])",
"def to_snake_case(str):\n s1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', str)\n s2 = re.sub('-', '_', s1)\n return re.sub... | [
"0.8169291",
"0.79741883",
"0.7870548",
"0.7856515",
"0.784361",
"0.7827698",
"0.7771482",
"0.7724259",
"0.77127",
"0.7698199",
"0.76788455",
"0.76749676",
"0.764776",
"0.7591212",
"0.75759494",
"0.7572352",
"0.7572246",
"0.7570467",
"0.7529595",
"0.7508867",
"0.7502726",
"... | 0.7210004 | 40 |
Compute softmax values for each sets of scores in x. | def softmax(self, x):
if x.ndim == 1:
x = x.reshape((1, -1))
max_x = np.max(x, axis=1).reshape((-1, 1))
exp_x = np.exp(x - max_x)
return exp_x / np.sum(exp_x, axis=1).reshape((-1, 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7796294",
"0.7760558",
"0.7759004",
"0.77567077",
"0.76577055",
"0.76577055",
"0.76577055",
"0.76577055",
"0.7585655",
"0.743143",
"0.7407772",
"0.73941606",
"0.7358175",
"0.73174125",
"0.72689486",
"0.72623265",
"0.7256868",
"0.723019",
"0.7214918",
"0.7201743",
"0.720127... | 0.72614294 | 16 |
Return max increasing and max decreasing ending at root, and max overall. | def get_max(self, root):
if not root:
return 0, 0, 0
inc, dec = 1, 1
li, ld, lt = self.get_max(root.left)
ri, rd, rt = self.get_max(root.right)
if root.left:
if li and root.left.val - root.val == 1:
inc = li + 1
if ld and root.left.val - root.val == -1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_value(tree):\n max_utility = float(\"-inf\")\n \n if (is_terminal(tree)):\n return tree\n else:\n #options = []\n for node in tree:\n #options.append(max_value(node))\n max_utility = max(max_utility, min_value(node))\n return max_utility",
"de... | [
"0.7117328",
"0.71112776",
"0.7044887",
"0.6997567",
"0.6748646",
"0.67087173",
"0.6672394",
"0.65949374",
"0.6586346",
"0.657762",
"0.6531086",
"0.65100175",
"0.64714116",
"0.644434",
"0.64382434",
"0.6416008",
"0.63879347",
"0.6356409",
"0.63550186",
"0.63374007",
"0.632372... | 0.81563914 | 0 |
Asserts that |graph| exists in the |logs| dict and is nonempty. | def _CheckFileExistsWithData(self, logs, graph):
self.assertTrue(graph in logs, 'File %s was not output.' % graph)
self.assertTrue(logs[graph], 'File %s did not contain data.' % graph) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_nodes_exist(graph_no_edges):\n for node in graph_no_edges:\n assert graph_no_edges.has_node(node)",
"def test_build_graph():\r\n assert valid_graph.get_graph() is not None\r\n assert invalid_graph.get_graph() != collections.defaultdict(list)",
"def test_empty_graph():\n try:\n ... | [
"0.6450355",
"0.6435499",
"0.6332156",
"0.58225304",
"0.56112653",
"0.5578354",
"0.55469215",
"0.540938",
"0.5402035",
"0.5321576",
"0.5301873",
"0.53012145",
"0.5222393",
"0.522052",
"0.5219795",
"0.5218054",
"0.5212965",
"0.5143586",
"0.5140861",
"0.5116674",
"0.5102559",
... | 0.6826049 | 0 |
Constructor i is the dimensionality of the data h is the dimensionality of the hidden state o is the dimensionality of the outputs | def __init__(self, i, h, o):
self.Wh = np.random.randn(h + i, h)
self.Wy = np.random.randn(h, o)
self.bh = np.zeros((1, h))
self.by = np.zeros((1, o)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, i, h, o):\n self.Wh = np.random.randn(i + h, h)\n self.Wy = np.random.randn(h, o)\n self.bh = np.zeros((1, h))\n self.by = np.zeros((1, o))",
"def __init__(self, i, h, o):\n self.Wh = np.random.normal(size=(i+h, h))\n self.Wy = np.random.normal(size=(h... | [
"0.74491924",
"0.7310735",
"0.7109744",
"0.6963149",
"0.6876471",
"0.6844026",
"0.6822135",
"0.68198514",
"0.67973614",
"0.67842036",
"0.6595558",
"0.65876734",
"0.6560841",
"0.6540244",
"0.6502405",
"0.6495898",
"0.64951384",
"0.6476122",
"0.64760554",
"0.6459543",
"0.645103... | 0.7468779 | 0 |
Initialize the portfolio dataset container; pass dicts of DataSetLists (e.g. returned by bb.load()). Alternatively, we can unpickle an existing portfolio. | def __init__(self, algorithms={}, strategies={}, pickleFile=None):
if pickleFile is None:
self.algds = algorithms
self.stratds = strategies
self._bestalg = None
self._unifpf = None
else:
if pickleFile.find('.gz') < 0:
pickleFile... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_portfolio(self):\n\n raise NotImplementedError('''\n Must implement initialize_portfolio. Call help() for details.\n ''')",
"def generate_portfolio_data(self):\n self.__load_portfolio_historical_prices()\n self.__populate_historical_trade_data()\n self... | [
"0.68556726",
"0.6618647",
"0.6465207",
"0.62287617",
"0.6069952",
"0.6034334",
"0.603317",
"0.5974946",
"0.59577096",
"0.5862897",
"0.5710271",
"0.5706027",
"0.5693904",
"0.5675089",
"0.56075424",
"0.55934465",
"0.557694",
"0.55541694",
"0.5523486",
"0.549156",
"0.5452368",
... | 0.0 | -1 |
Get basename for for the output files (based on target/informants used) | def _get_abgp_file_basename(OPTIONS):
if OPTIONS.target:
try:
num_loci = OPTIONS.selected_num_loci
except:
num_loci = len(OPTIONS.loci) + len(OPTIONS.dnafiles)
return "%s.%s%sSL." % (ABFGP_VERSION,OPTIONS.target,num_loci)
else:
return "%s." % ABGP_VERSION | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gen_basename(param_dict, clargs):\n if param_dict['output_basename'] in ['', 'auto']:\n return clargs.input_fname.lower().split('.json')[0]\n\n else:\n return param_dict['output_basename']",
"def _get_output_filename(dataset_dir, split_name):\n return '%s/%s*.tfrecord' % (dataset_dir,... | [
"0.74934465",
"0.71939796",
"0.6933678",
"0.69292694",
"0.67933995",
"0.6763905",
"0.6733406",
"0.667847",
"0.6661968",
"0.665754",
"0.6652924",
"0.6642772",
"0.6609915",
"0.65880424",
"0.656221",
"0.6550737",
"0.64930534",
"0.6489632",
"0.64813685",
"0.64727837",
"0.6466696"... | 0.64989513 | 16 |
Impute and scale features, and assign them back to groups. | def prepare_features(groups, do_scale):
feature_list = []
for group in groups:
for features in group.features:
feature_list.append(features)
feature_matrix = np.vstack(feature_list)
feature_matrix = impute.impute(feature_matrix)
if do_scale:
feature_matrix, s_min, s_max ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(self, X):\n \n # Check is fit had been called\n check_is_fitted(self, ['imputer_dict_'])\n \n # Check that the input is of the same shape as the one passed\n # during fit.\n if X.shape[1] != self.input_shape_[1]:\n raise ValueError('Number o... | [
"0.63233083",
"0.62725437",
"0.6229262",
"0.6128322",
"0.6078188",
"0.5929566",
"0.5838305",
"0.5762656",
"0.5743847",
"0.5663462",
"0.56588876",
"0.5619213",
"0.56066513",
"0.55260825",
"0.55241024",
"0.54984134",
"0.54897094",
"0.5454188",
"0.5434047",
"0.53759694",
"0.5370... | 0.60100543 | 5 |
Run an executable. Assumes CMake build system | def run_executable(args, input_file) -> dict:
try:
Path(args.exe).resolve(strict=True)
except FileNotFoundError as error:
raise error
os.environ["OMP_NUM_THREADS"] = str(args.omp_num_threads)
run_command = ['./' + args.exe, input_file]
if 'mpi' or 'hybrid' in args.build_type:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def executable():\n\n if len(sys.argv) == 1:\n arguments.get_help()\n sys.exit('\\nGive me something to do and I will do it\\n')\n else:\n # Parse the Arguments that have been provided\n args = arguments.get_args()\n\n # Load The System Logger\n log = logger.load_in(... | [
"0.7362236",
"0.7151264",
"0.6916307",
"0.6471797",
"0.6439295",
"0.63777673",
"0.63584745",
"0.63296705",
"0.6259526",
"0.6247414",
"0.6237462",
"0.6231711",
"0.6178511",
"0.61759675",
"0.61743546",
"0.61740214",
"0.6164506",
"0.6110152",
"0.6092354",
"0.6073716",
"0.6073716... | 0.0 | -1 |
In the constructor we instantiate two nn.Linear modules and assign them as member variables. | def __init__(self, D_in, H_in, H_out, D_out):
super(ThreeLayerNet, self).__init__()
self.linear1 = torch.nn.Linear(D_in, H_in)
self.linear2 = torch.nn.Linear(H_in, H_out)
self.linear3 = torch.nn.Linear(H_out, D_out) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n super(LinearND, self).__init__()\n self.fc = nn.Linear(*args)",
"def __init__(self, linear_args, activation_functions, softmax=False):\n super(NN, self).__init__()\n assert len(activation_functions) == len(linear_args) - 1\n k = len(linear_args)\n ... | [
"0.77401125",
"0.75483596",
"0.75074446",
"0.74346",
"0.7366003",
"0.7335429",
"0.73152226",
"0.7286699",
"0.7273464",
"0.72729063",
"0.72729063",
"0.7268201",
"0.72429734",
"0.72030157",
"0.7167753",
"0.7111596",
"0.7077496",
"0.7065618",
"0.7063983",
"0.7053454",
"0.7018263... | 0.72211164 | 13 |
Construct a 2D meshgrid. | def meshgrid(batch, height, width, is_homogeneous=False):
x_t = tf.matmul(tf.ones(shape=tf.stack([height, 1])),
tf.transpose(tf.expand_dims(
tf.linspace(-1.0, 1.0, width), 1), [1, 0]))
y_t = tf.matmul(tf.expand_dims(tf.linspace(-1.0, 1.0, height), 1),
tf.one... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_grid(self, nx, ny):\n nx_vec = np.arange(nx)\n ny_vec = np.arange(ny)\n yv, xv = np.meshgrid(ny_vec, nx_vec)\n grid = np.stack((yv, xv), axis=2)\n grid = grid.reshape(1, 1, ny, nx, 2)\n return grid",
"def _create_meshgrid(self):\n x = np.linspace(self.lim... | [
"0.8013386",
"0.78057563",
"0.7699751",
"0.76337194",
"0.76337194",
"0.76120704",
"0.75835127",
"0.757513",
"0.757513",
"0.7566025",
"0.7566025",
"0.7566025",
"0.7566025",
"0.7556386",
"0.75155663",
"0.75066143",
"0.7411159",
"0.7392174",
"0.72235304",
"0.71797687",
"0.715451... | 0.6064806 | 80 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.