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 |
|---|---|---|---|---|---|---|
Returns a set with items present in both set | def intersection(self, other_set):
intersect_set = Set()
for value in other_set.values():
if value in self.__collection:
intersect_set.add(value)
return intersect_set | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersect(self,a, b):\n\t\treturn list(set(a) & set(b))",
"def intersection (set1, set2):\n assert is_iterable(set1)\n assert is_iterable(set2)\n result = []\n for v in set1:\n if v in set2:\n result.append (v)\n return result",
"def intersection(self, *other):\n ret... | [
"0.7795925",
"0.7535576",
"0.7507916",
"0.7497714",
"0.7459463",
"0.7459463",
"0.7459463",
"0.7459463",
"0.73972535",
"0.72555166",
"0.72438127",
"0.72212756",
"0.71699435",
"0.71643317",
"0.71643317",
"0.7127566",
"0.7088141",
"0.7069921",
"0.70560974",
"0.70490927",
"0.7047... | 0.7129159 | 15 |
Sets the ImageItem that will be affected by the contrast / color controls | def setImageItem(self, item):
self.imageItem = item
self.ui.histogram.setImageItem(item)
self.ui.histogram.fillHistogram(False) # for speed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setImageItem(self, imageItem):\n logger.debug(\"setImageItem\")\n check_class(imageItem, ImageItem, allowNone=True)\n\n # Remove old imageItem\n if self._imageItem:\n self._imageItem.sigImageChanged.disconnect(self.onImageChanged)\n\n self._imageItem = imageItem\n ... | [
"0.6698638",
"0.63666564",
"0.63666564",
"0.618654",
"0.6082435",
"0.6019494",
"0.5851096",
"0.5798176",
"0.57681805",
"0.57629234",
"0.5745294",
"0.5722946",
"0.5722249",
"0.5692401",
"0.56734264",
"0.56531453",
"0.5630831",
"0.5611451",
"0.5597851",
"0.5586994",
"0.5579418"... | 0.6600377 | 1 |
Save experience in replay memory, and use random sample from buffer to learn. | def step(self, i_episode, states, actions, rewards, next_states, dones):
#for stepping maddpg
# index 0 is for agent 0 and index 1 is for agent 1
all_states = np.reshape(states, newshape=(-1))
all_next_states = np.reshape(next_states, newshape=(-1))
# Save experience / r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, experience):\n self.buffer.add(experience)\n self.update_counter = (self.update_counter + 1) % self.update_every\n self.learn_counter = (self.learn_counter + 1) % self.learn_every\n if self.buffer.can_sample():\n if self.learn_counter == 0:\n sam... | [
"0.7053607",
"0.68865967",
"0.68061346",
"0.68013716",
"0.6796738",
"0.6754518",
"0.6750716",
"0.67243785",
"0.6705259",
"0.66295135",
"0.66144985",
"0.65173626",
"0.6486849",
"0.6446293",
"0.6338314",
"0.6338314",
"0.6310219",
"0.6309544",
"0.63070244",
"0.6298208",
"0.62685... | 0.0 | -1 |
Initialize a logistic model. This function prepares an initialized logistic model. It will initialize the weight vector, self.W, based on the method specified in W_init. We assume that the FIRST index of Weight is the bias term, Weight = [Bias, W1, W2, W3, ...] where Wi correspnds to each feature dimension | def __init__(self, ndims, W_init='zeros'):
self.ndims = ndims
self.W_init = W_init
self.W0 = None
###############################################################
# Fill your code below
###############################################################
if W_init == 'z... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\n self.W = np.random.randn(self.Ninput, self.Noutput) \\\n * np.sqrt(2./self.Ninput)\n self.b = np.random.rand(self.Noutput)",
"def weights_init(mod):\n classname = mod.__class__.__name__\n if classname.find('Conv') != -1:\n mod.weight.data.normal_(0.... | [
"0.7022944",
"0.7021388",
"0.6924028",
"0.6909792",
"0.68658465",
"0.68084025",
"0.6800197",
"0.6782989",
"0.6781278",
"0.6713851",
"0.6705339",
"0.66667783",
"0.66612774",
"0.664089",
"0.6638176",
"0.66376954",
"0.6606218",
"0.65898764",
"0.65777296",
"0.65669614",
"0.656492... | 0.6036123 | 90 |
Finds out if line is the last line of a paragraph or not. | def _is_last(self, line, next_line, is_first):
if not next_line:
return True, True
# Check metrics
first = self._first.avg
middle = self._middle.avg
last_threshold = first - (middle - first)
if middle - first > 2 * max(self._first.dev, self._middle.dev):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_last_line(prev):\n \n if prev[-1][0]=='r':\n last_line = prev[-1].split()[1]\n del prev[-1]\n return last_line\n else:\n return str(len(prev)-1)",
"def ends_in_sentence_end(line):\n return len(line) > 0 and line[-1] in [\"\\\"\", \".\", \"!\", \"?\"]",
"def _last_line(value):\n i... | [
"0.6859791",
"0.6710706",
"0.65929025",
"0.6564311",
"0.65269077",
"0.6438694",
"0.64074075",
"0.60998446",
"0.6019254",
"0.60047543",
"0.59988815",
"0.59114605",
"0.5903782",
"0.5901972",
"0.58995634",
"0.5898713",
"0.5892648",
"0.588466",
"0.58552134",
"0.5843744",
"0.58038... | 0.70707935 | 0 |
Returns the lattice parameter for the triangular lattice given the conditions. | def macro_lattice_parameter(self):
return self.a * (2.0 * self.rad + self.d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_lattice_params(self) -> Tuple[str, Tuple[float, ...]]:\n try:\n if self.system == \"Triclinic\":\n return self.system, (\n self.a1,\n self.a2,\n self.a3,\n degrees(self.alpha1),\n ... | [
"0.6300782",
"0.6048365",
"0.58221895",
"0.57635117",
"0.56097496",
"0.54346824",
"0.53983456",
"0.53033954",
"0.5227487",
"0.5208842",
"0.5208842",
"0.5208842",
"0.5184839",
"0.5117734",
"0.5114538",
"0.5113322",
"0.50938183",
"0.50469047",
"0.50441736",
"0.50404346",
"0.504... | 0.6058649 | 1 |
Edge inner product matrix for \\(\\sigma\\). Used in the EB formulation | def MeSigma(self, freq):
sigma = ColeColePelton(freq, self.sigmaInf, self.eta, self.tau, self.c)
return self.mesh.getEdgeInnerProduct(sigma) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def M(sigma, X):\n total= 0.0\n for i in range(len(X)):\n for j in range(len(X)):\n total= total + eq_8(i, j, sigma, X)\n \n a= total/len(X)**2\n b= 2.0*eq_5_0(sigma, X)/len(X)\n return a + b",
"def sy... | [
"0.6934346",
"0.6338951",
"0.6172928",
"0.59980947",
"0.5965465",
"0.5952755",
"0.5933873",
"0.5930332",
"0.59021074",
"0.58890396",
"0.5887808",
"0.5875859",
"0.5831452",
"0.58271015",
"0.58241117",
"0.5784743",
"0.57439363",
"0.57299584",
"0.5727446",
"0.571188",
"0.5710202... | 0.5654023 | 25 |
Inverse of the edge inner product matrix for \\(\\sigma\\). | def MeSigmaI(self, freq):
sigma = ColeColePelton(freq, self.sigmaInf, self.eta, self.tau, self.c)
return self.mesh.getEdgeInnerProduct(sigma, invMat=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inverse(mat): # pylint: disable=R1710\n return mat.inverse()",
"def inv(mat):\n return mat.inv()",
"def inverse(self):\n\t\tif not self.is_square():\n\t\t\traise(ValueError, \"Non-square Matrix does not have an inverse.\")\n\t\tif self.row_len > 2:\n\t\t\traise(NotImplementedError, \"inversion not i... | [
"0.66158926",
"0.65487677",
"0.6487925",
"0.6487864",
"0.64860386",
"0.6407303",
"0.63946116",
"0.63938946",
"0.6380737",
"0.6317936",
"0.62807494",
"0.62802655",
"0.6235184",
"0.62324834",
"0.6226246",
"0.6218729",
"0.6165483",
"0.6133683",
"0.61204165",
"0.6109855",
"0.6012... | 0.58390766 | 33 |
Creates and saves a User with the given username and password. | def _create_user(self, phone, password, is_staff, is_superuser, **extra_fields):
now = timezone.now()
if not phone:
raise ValueError('The given username must be set')
user = self.model(phone=phone,
is_staff=is_staff, is_active=True,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signup(cls, username, email, password):\n\n hashed_pwd = bcrypt.generate_password_hash(password).decode('UTF-8')\n\n user = User(\n username=username,\n email=email,\n password=hashed_pwd,\n )\n\n db.session.add(user)\n return user",
"def _c... | [
"0.8363992",
"0.83445954",
"0.83315355",
"0.83084",
"0.8294438",
"0.82500577",
"0.82356954",
"0.81589705",
"0.81589705",
"0.8138204",
"0.81350994",
"0.81269205",
"0.8125317",
"0.8120479",
"0.8115275",
"0.8114692",
"0.81033385",
"0.81033385",
"0.81033385",
"0.81033385",
"0.808... | 0.0 | -1 |
Returns the first_name plus the last_name, with a space in between. | def get_full_name(self):
return self.phone | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_full_name(first_name, last_name):\n return first_name + \" \" + last_name",
"def full_name(first_name, last_name):\n return first_name + \" \" + last_name",
"def full_name(first_name, last_name):\n\n #make string with full name using first and last name\n return first_name + \" \" + last_na... | [
"0.83918446",
"0.8312925",
"0.8094133",
"0.8089168",
"0.80696714",
"0.8011144",
"0.7960004",
"0.7945147",
"0.7942392",
"0.79309964",
"0.78689504",
"0.786258",
"0.7848908",
"0.78170854",
"0.7801344",
"0.77968085",
"0.7784014",
"0.77747273",
"0.7771431",
"0.7771431",
"0.7770768... | 0.0 | -1 |
Returns the short name for the user. | def get_short_name(self):
return self.phone | {
"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\t\treturn self.username",
"def user_name_for_group(self):\n if self.show_real_name:\n return self.user.get_full_name()\n else:\n ... | [
"0.90316343",
"0.90316343",
"0.9025407",
"0.84024477",
"0.8281205",
"0.82724315",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
"0.81823653",
... | 0.0 | -1 |
Imitate Java's DateTimeFormatter.ISO_INSTANT style for datetimes. It's not exactly ISO_INSTANT, because we're truncating to second precision. | def time_format(timestamp):
as_utc = timestamp.astimezone(pytz.UTC)
return as_utc.strftime('%Y-%m-%dT%H:%M:%SZ') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isostring(dt):\n\n if dt:\n return dt.replace(microsecond=0).isoformat()",
"def test_pretty_datetime_may(self):\n from shared.templatetags.custom_filters import pretty_datetime\n iso_test_string = \"2020-05-19T14:09:46.500Z\"\n pretty_iso_string = pretty_datetime(iso_test_strin... | [
"0.5943205",
"0.57685703",
"0.57481986",
"0.5738837",
"0.5703332",
"0.56396013",
"0.5628582",
"0.5448816",
"0.54221237",
"0.5418451",
"0.54046535",
"0.53765845",
"0.535264",
"0.5345989",
"0.5335614",
"0.5328239",
"0.53148115",
"0.52927536",
"0.52496433",
"0.524538",
"0.524238... | 0.0 | -1 |
Align coordinates (x1,y1) < (x2,y2) to work with torchvision `box_iou` op | def align_coordinates(boxes):
x1y1 = torch.min(boxes[:,:2,],boxes[:, 2:])
x2y2 = torch.max(boxes[:,:2,],boxes[:, 2:])
boxes = torch.cat([x1y1,x2y2],dim=1)
return boxes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unaligned_box_iou(self, boxes1, boxes2):\n boxes1 = boxes1[:, None, :] # (n, 1, 4)\n boxes2 = boxes2[None, :, :] # (1, m, 4)\n \n area1 = (boxes1[..., 2] - boxes1[..., 0] + 1) * (boxes1[..., 3] - boxes1[..., 1] + 1) # (n, 1)\n area2 = (boxes2[..., 2] - boxes2[..., 0] + 1... | [
"0.70646334",
"0.69990057",
"0.69984895",
"0.69984895",
"0.69984895",
"0.69146824",
"0.69146824",
"0.68726146",
"0.684085",
"0.6741181",
"0.6701809",
"0.66642326",
"0.6646809",
"0.65917814",
"0.65821034",
"0.654065",
"0.6535734",
"0.6472227",
"0.6472073",
"0.6465352",
"0.6463... | 0.74027425 | 0 |
Initialize the frame and widgets. | def __init__(self):
EasyFrame.__init__(self, title = "Doctor Server",
background = DoctorServerGUI.COLOR)
self.hostLabel = self.addLabel(row = 0, column = 0,
text = "Host name")
self.hostField = self.addTextField(row = 0, column =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize(self):\n self._frame = ttk.Frame(master=self._root)\n\n self._create_header()\n self._create_footer()\n\n self._frame.grid_columnconfigure(1, weight=1, minsize=250)",
"def mainFramesInit(self):\n self._titleFrame.pack(side=DEFAULT_DIRECTION, fill='both')\n ... | [
"0.79807484",
"0.7770177",
"0.756326",
"0.74803275",
"0.74774367",
"0.7443188",
"0.7430336",
"0.7429438",
"0.74268883",
"0.7356295",
"0.73512083",
"0.7344396",
"0.73358136",
"0.72304547",
"0.7206776",
"0.7202221",
"0.7154342",
"0.71473444",
"0.7102016",
"0.7092275",
"0.708383... | 0.6542484 | 62 |
get the percentage the maximum is reached or beyond like quantile(0.95) | def get_max_outs(datalogger, datestring, value_key, max_value):
matrix = []
for func, args in datalogger.get_ts_caches(datestring):
series = func(*args).get_serie(value_key)
matrix.append((
float(100 * sum((value > max_value for value in series)))/len(series),
args[1:],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_amax_percentile(self):\n\n if self.percentile < 0 or self.percentile > 100:\n raise ValueError(\"Invalid percentile. Must be in range 0 <= percentile <= 100.\")\n\n # If calibrator hasn't collected any data, return none\n if self.init_state == 0:\n return Non... | [
"0.72565883",
"0.7186056",
"0.7129423",
"0.7025119",
"0.69757795",
"0.68215317",
"0.6745192",
"0.6703594",
"0.66851693",
"0.6607059",
"0.65877694",
"0.6542483",
"0.6538274",
"0.65368015",
"0.65368015",
"0.6498219",
"0.6495109",
"0.6462449",
"0.6453745",
"0.640955",
"0.6407106... | 0.0 | -1 |
Gets the public_ip of this InstanceConfigResult. | def public_ip(self):
return self._public_ip | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_ip(self) -> Optional[str]:\n return pulumi.get(self, \"public_ip\")",
"def public_ip_address(self) -> str:\n return pulumi.get(self, \"public_ip_address\")",
"def get_public_ip(self):\n ip_addr = requests.get(self._PUBLIC_IP_URL).text\n return ip_addr.strip(\" \")",
"de... | [
"0.81825876",
"0.8106029",
"0.7667059",
"0.7467185",
"0.7324352",
"0.7118844",
"0.7118844",
"0.7106459",
"0.70933867",
"0.7004864",
"0.69970477",
"0.69869745",
"0.69652236",
"0.6960859",
"0.6960859",
"0.6960859",
"0.6960859",
"0.6960859",
"0.6960859",
"0.6960859",
"0.6960859"... | 0.81751317 | 2 |
Sets the public_ip of this InstanceConfigResult. | def public_ip(self, public_ip):
self._public_ip = public_ip | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_ip_address(self, public_ip_address):\n\n self._public_ip_address = public_ip_address",
"def public_virtual_ip_address(self, public_virtual_ip_address):\n\n self._public_virtual_ip_address = public_virtual_ip_address",
"def assign_public_ip(self) -> Optional[pulumi.Input[bool]]:\n ... | [
"0.72585744",
"0.7086692",
"0.6952934",
"0.6827138",
"0.67903745",
"0.66188097",
"0.66188097",
"0.66188097",
"0.66188097",
"0.6585044",
"0.6575525",
"0.6550129",
"0.6469966",
"0.6427538",
"0.6427538",
"0.6180287",
"0.6160541",
"0.61058193",
"0.6062063",
"0.60268164",
"0.59932... | 0.78157645 | 1 |
Returns the string representation of the model | def to_str(self):
import simplejson as json
if six.PY2:
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
return json.dumps(sanitize_for_serialization(self), ensure_ascii=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _repr_model_(self):\n return str(self)",
"def __str__(self):\n\n return str(self.model)",
"def get_model_string(self):\n raise NotImplementedError()",
"def __str__(self):\n return self.model",
"def serialize_model(self):\n return dill.dumps(self.model)",
"def __str_... | [
"0.8602374",
"0.85093755",
"0.8237104",
"0.8050309",
"0.80128866",
"0.79348034",
"0.78766525",
"0.77898884",
"0.7786461",
"0.7745792",
"0.7627315",
"0.76055235",
"0.757999",
"0.7514394",
"0.75038797",
"0.75035286",
"0.74850684",
"0.7440529",
"0.74325883",
"0.74239755",
"0.740... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n return not self == other",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other):\n return self.__dict__ != other.__dict__",
"def __eq__(self, other):\n return not self.__ne__(other)",
... | [
"0.8410411",
"0.8391477",
"0.8172175",
"0.81410587",
"0.80920255",
"0.8088807",
"0.80676955"
] | 0.0 | -1 |
1hot encodes a tensor | def to_categorical(y, num_classes):
return np.eye(num_classes, dtype='uint8')[y] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_encode(x):\n # the return matrix (shape: [num samples x 10 categories])\n ret = np.zeros([len(x), 10], dtype=np.float32)\n for i, label in enumerate(x):\n ret[i][label] = 1 # only set the label/category-slot to 1, leave all others at 0\n return ret",
"def one_hot_encode(t):\r\n\tK ... | [
"0.8299777",
"0.8277978",
"0.82525593",
"0.820015",
"0.81454945",
"0.8130698",
"0.8129103",
"0.79672784",
"0.78878",
"0.78265285",
"0.77947706",
"0.7755286",
"0.7741744",
"0.7728651",
"0.7718605",
"0.7703139",
"0.76660216",
"0.76515305",
"0.7647948",
"0.7647948",
"0.76003397"... | 0.0 | -1 |
Output a random scalar in grayscale with a least a small contrast with the background color | def get_random_color(background_color):
color = random_state.randint(256)
if abs(color - background_color) < 30: # not enough contrast
color = (color + 128) % 256
return color | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rand_bright(img):\n return tf.image.random_brightness(img, max_delta=63)",
"def random_grayscale(image, prob=.2):\n convert = rand() < prob\n if convert:\n #convert to grayscale first, and then\n #back to 3 channels fake BGR\n image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\... | [
"0.6317694",
"0.6307159",
"0.6265592",
"0.6261215",
"0.6205647",
"0.61573476",
"0.6146706",
"0.6141459",
"0.61389816",
"0.61342746",
"0.61280835",
"0.60958546",
"0.6083224",
"0.60441595",
"0.603935",
"0.60157603",
"0.6009609",
"0.5996101",
"0.5996078",
"0.59555787",
"0.591838... | 0.6057936 | 13 |
Apply a final Gaussian blur to the image | def final_blur(img, kernel_size=(5, 5)):
cv.GaussianBlur(img, kernel_size, 0, img) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_blur(self, img, kernel_size):\r\n return cv2.GaussianBlur(img, (kernel_size, kernel_size), 0)",
"def gaussian_blur(img, kernel_size):\r\n return cv2.GaussianBlur(img, (kernel_size, kernel_size), 0)",
"def gaussian_blur(img, kernel_size):\r\n return cv2.GaussianBlur(img, (kernel_size, ... | [
"0.78392065",
"0.7792403",
"0.7792403",
"0.7757736",
"0.77445567",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
"0.77440614",
... | 0.83300287 | 0 |
Compute the angle (in rad) between the two vectors v1 and v2. | def angle_between_vectors(v1, v2):
v1_u = v1 / np.linalg.norm(v1)
v2_u = v2 / np.linalg.norm(v2)
return np.arccos(np.clip(np.dot(v1_u, v2_u), -1.0, 1.0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def angle(v1, v2):\n\n ang = np.arccos(np.dot(v1, v2) / (length(v1) * length(v2)))\n return ang",
"def angle(v1, v2):\n return math.acos(dotproduct(v1, v2) / (length(v1) * length(v2)))",
"def angle(self, v1, v2):\n c = np.dot(v1, v2) / la.norm(v1) / la.norm(v2)\n angle = np.arccos(np.cli... | [
"0.8769634",
"0.87666297",
"0.863152",
"0.86199456",
"0.86199373",
"0.8606904",
"0.852987",
"0.8466734",
"0.84404707",
"0.8427854",
"0.84111047",
"0.83560216",
"0.8341895",
"0.8287553",
"0.82525593",
"0.82342905",
"0.8232674",
"0.814543",
"0.8118207",
"0.808689",
"0.7849255",... | 0.8240877 | 15 |
A decorator to split and reproject polygon vectors in a GeoDataFrame whose values cross the Greenwich Meridian. Begins by examining whether the geometry bounds the supplied cross longitude = 0 and if so, proceeds to split the polygons at the meridian into new polygons and erase a small buffer to prevent invalid geometr... | def func_checker(*args, **kwargs):
try:
poly = kwargs["poly"]
x_dim = kwargs["x_dim"]
wrap_lons = kwargs["wrap_lons"]
except KeyError:
return func(*args, **kwargs)
if wrap_lons:
if (np.min(x_dim) < 0 and np.max(x_dim) >= 360) or (
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def func_checker(*args, **kwargs):\n try:\n poly = kwargs[\"poly\"]\n x_dim = kwargs[\"x_dim\"]\n wrap_lons = kwargs[\"wrap_lons\"]\n except KeyError:\n return func(*args, **kwargs)\n\n if wrap_lons:\n if (np.min(x_dim) < 0 and np.max(x_di... | [
"0.6380663",
"0.5900841",
"0.5818547",
"0.53651494",
"0.5364978",
"0.5361575",
"0.5265604",
"0.51761234",
"0.516586",
"0.50843996",
"0.50818515",
"0.50095344",
"0.4952454",
"0.49387267",
"0.4934869",
"0.49214903",
"0.48511305",
"0.48409006",
"0.48402038",
"0.48113808",
"0.481... | 0.6459423 | 0 |
Creates a mask with values corresponding to the features in a GeoDataFrame. The returned mask's points have the value of the first geometry of `poly` they fall in. | def create_mask(
*,
x_dim: xarray.DataArray = None,
y_dim: xarray.DataArray = None,
poly: gpd.GeoDataFrame = None,
wrap_lons: bool = False,
):
# Check for intersections
for i, (inda, pola) in enumerate(poly.iterrows()):
for (indb, polb) in poly.iloc[i + 1 :].iterrows():
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inpolygon(data, poly):\n from shapely.geometry import Point\n lon = data['lon']\n lat = data['lat']\n def inpolygon(polygon, xp, yp):\n return np.array([Point(x, y).intersects(polygon)\n for x, y in zip(xp, yp)], dtype=np.bool)\n mask = inpolygon(poly, lon.data.ra... | [
"0.6766087",
"0.65063554",
"0.6272264",
"0.62043643",
"0.60757524",
"0.59278476",
"0.5917083",
"0.5892334",
"0.58272237",
"0.5803217",
"0.5727588",
"0.57120657",
"0.568852",
"0.56856287",
"0.5677352",
"0.56524396",
"0.5600478",
"0.5598108",
"0.55262405",
"0.5501801",
"0.54935... | 0.6806616 | 0 |
Return a user model | def user_model(username, **kwargs):
user = {
'username': username,
'scope': 'basic',
}
user.update(kwargs)
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_model(self):\n return self.auth.store.user_model",
"def user_model(self):\n return self.auth.store.user_model",
"def User(django_user_model):\n return django_user_model",
"def get_user(uid):\n uid = uuid.UUID(uid)\n model = people.User.query.filter_by(id=uid).first()\n if n... | [
"0.781099",
"0.781099",
"0.7713086",
"0.7338031",
"0.73166394",
"0.71240216",
"0.7083803",
"0.7066533",
"0.69980353",
"0.69853365",
"0.69729114",
"0.69726455",
"0.6936086",
"0.6935575",
"0.68602467",
"0.6857634",
"0.68022597",
"0.68001026",
"0.67843807",
"0.67769337",
"0.6742... | 0.70026684 | 8 |
Check that an exception is raised if the jwt is not validated by ROK | def test_wrong_jwt(rok_connector_with_secret, rok_ds_jwt):
responses.add(method=responses.POST, url='http://bla.bla', body='<Fault xmlns= ...')
with pytest.raises(InvalidJWTError):
rok_connector_with_secret.retrieve_data_with_jwt(rok_ds_jwt, endpoint='http://bla.bla') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_payload(self, token): \n try:\n payload = jwt_decode_handler(token)\n except jwt.ExpiredSignature:\n msg = _('Signature has expired.')\n raise serializers.ValidationError(msg)\n except jwt.DecodeError:\n msg = _('Error decoding signature.'... | [
"0.68970907",
"0.6657292",
"0.65633374",
"0.65544945",
"0.65219384",
"0.6508475",
"0.6507801",
"0.6472119",
"0.6453939",
"0.6431843",
"0.63859075",
"0.6348599",
"0.63044107",
"0.6296359",
"0.6248332",
"0.624195",
"0.62083614",
"0.6184861",
"0.61826354",
"0.61773163",
"0.61627... | 0.7311972 | 0 |
Get current module configuration | def get(self):
self._not_configurable() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(self):\n return self.config.config",
"def get_config(self):\n return self.context.get_config()",
"def get_config(self):\n return self.config",
"def get_config(self):\n return self.config",
"def _get_config(self):\n return self.__config",
"def _get_config(self... | [
"0.80174506",
"0.78734523",
"0.7799118",
"0.7799118",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
"0.7790982",
... | 0.0 | -1 |
Add a 2D max pool layer to each subnet. | def add_max_pool_layer(self, shape=(4, 1),
strides=None,
padding='SAME'):
for subnet in [self.subnet_A, self.subnet_B]:
x = subnet[-1]
ksize = [1, shape[0], shape[1], 1]
if strides is None:
st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addMaxPool(self, **kwargs):\n\n input_layer = self.input_layer if not self.all_layers\\\n else self.all_layers[-1]\n\n self.n_maxpool_layers += 1\n name = \"maxpool%i\" % self.n_maxpool_layers\n\n new_layer = MaxPool(input_layer, name=name, **kwargs)\n\n self.all_l... | [
"0.7079891",
"0.6418232",
"0.6362284",
"0.629208",
"0.6172301",
"0.6172301",
"0.61374724",
"0.6126387",
"0.61187947",
"0.6115671",
"0.6115671",
"0.6115671",
"0.6115671",
"0.6115671",
"0.60954",
"0.60835654",
"0.6062538",
"0.60463107",
"0.6045611",
"0.6038555",
"0.6038555",
... | 0.79391825 | 0 |
Return Tensorflow variable with a given dimension, initialized with tf.truncated_normal with standard deviation weight_scale. | def weight_variable(self, shape, weight_scale=0.1):
initial = tf.truncated_normal(shape, stddev=weight_scale)
return tf.Variable(initial, name='a_weight') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight_variable(shape):\n initial = tf.truncated_normal(shape, stddev=0.1)\n return tf.Variable(initial)",
"def weight_variable(shape):\r\n initial = tf.truncated_normal(shape, stddev=0.1)\r\n return tf.Variable(initial)",
"def weight_variable(self, shape):\r\n initial = tf.truncated_normal(shape,... | [
"0.76187783",
"0.7510227",
"0.75091356",
"0.74901587",
"0.74901587",
"0.7481096",
"0.7481096",
"0.7481096",
"0.7481096",
"0.74671376",
"0.74671376",
"0.74671376",
"0.74671376",
"0.74671376",
"0.74634415",
"0.74634415",
"0.7437409",
"0.73848605",
"0.73832357",
"0.72567344",
"0... | 0.7192441 | 22 |
Return Tensorflow variable with a given dimension, initialized as a tf.constant equal to parameter weight_scale. | def bias_variable(self, shape, weight_scale=0.1):
initial = tf.constant(weight_scale, shape=shape)
return tf.Variable(initial, name='a_bias') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight_variable(self, shape, weight_scale=0.1):\n initial = tf.truncated_normal(shape, stddev=weight_scale)\n return tf.Variable(initial, name='a_weight')",
"def weight_variable(name, shape):\n return tf.get_variable(name, shape, dtype=tf.float32, initializer=tf.truncated_normal_initializer(... | [
"0.762552",
"0.7253263",
"0.71739274",
"0.7165497",
"0.71544635",
"0.71482897",
"0.7140372",
"0.7133222",
"0.7133222",
"0.7133222",
"0.7133222",
"0.7133222",
"0.7129229",
"0.7119197",
"0.7119197",
"0.7119197",
"0.7119197",
"0.71035886",
"0.71009433",
"0.71009433",
"0.7088566"... | 0.6708335 | 29 |
Return loss function for training butterfly networks as a tensor. Minize pair distances while maximizing nonpair distances smaller than `m`. | def loss(self, m=10, alpha=1):
y_A, y_B = self.subnet_A[-1], self.subnet_B[-1]
squared_dists = tf.reduce_sum(tf.square(y_A - y_B),
reduction_indices=1)
pair_errors = squared_dists
non_pair_errors = tf.square(tf.maximum(0.0, m - tf.sqrt(squared_dists... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss(params, a, m, cutoff):\n fidelity, _, normIn, normOut, _ = circuit(params, a, m, cutoff)\n loss = -fidelity + 10*(1-np.abs(normIn)) + 10*(1-np.abs(normOut))\n return loss",
"def loss_function(mapping12):\n global dm1, dm2\n loss = np.linalg.norm(dm1[np.triu_indices(size1)] - dm2[mapping12... | [
"0.6409893",
"0.5983807",
"0.58659655",
"0.5858618",
"0.5842281",
"0.5833926",
"0.5813575",
"0.5736662",
"0.5732086",
"0.57303613",
"0.57277966",
"0.571614",
"0.5709829",
"0.5702176",
"0.56847906",
"0.5672326",
"0.5641213",
"0.56301504",
"0.5623263",
"0.562212",
"0.56112593",... | 0.7159078 | 0 |
Converts a numpy array into a serialized parameter string. | def NumpyAsParameter(numpy_array):
assert numpy_array.dtype == 'float32', 'Saved arrays should be float32.'
return numpy_array.tostring() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str_array(\n array: Union[ndarray, Sequence[float], Sequence[Sequence[float]]]\n) -> str:\n if not isinstance(array, ndarray):\n array = asarray(array)\n num_axis = len(array.shape)\n if num_axis == 1:\n return \"[\" + \", \".join([f\"{x:.3g}\" for x in array]) + \"]\"\n return... | [
"0.70993906",
"0.6988059",
"0.69399446",
"0.6870227",
"0.67331743",
"0.66444093",
"0.6489397",
"0.64377904",
"0.63388014",
"0.631769",
"0.6305577",
"0.6296605",
"0.6271062",
"0.6261299",
"0.62588847",
"0.6213623",
"0.62069213",
"0.61910045",
"0.61666495",
"0.61666495",
"0.616... | 0.77997154 | 0 |
Returns a dictionary of the counts of '', 'O', and '.' in state. | def count_pieces(state):
result = {'#': 0, 'O': 0, '.': 0}
for row in state:
for square in row:
result[square] += 1
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_pieces(state):\n result = {'#': 0, 'O': 0, '.': 0}\n for row in state:\n for space in row:\n if space == '#':\n result['#'] += 1\n elif space == 'O':\n result['O'] += 1\n else:\n result['.'] += 1\n return result... | [
"0.77111566",
"0.6450417",
"0.629671",
"0.61230606",
"0.60785085",
"0.6055402",
"0.60288465",
"0.5920866",
"0.5910382",
"0.58826876",
"0.5881989",
"0.58815473",
"0.58082867",
"0.57648605",
"0.5749298",
"0.57490796",
"0.57489735",
"0.57272524",
"0.5710097",
"0.56536824",
"0.56... | 0.7063233 | 1 |
Returns the state that would result from color playing move (which is either a pair (r, c) or 'pass'. Assumes move is legal. we start by making a deep copy of state so we wont change state, we then add the tiles that were flipped by playing 'move' to the list flipped, and then for each of these tiles we check if someth... | def successor(state, move, color):
oregon = deepcopy(state)
if move is 'pass':
return state
flipped = []
oregon[move[0]][move[1]] = color
for slope in OFFSETS:
flipped += flips(oregon, move[0], move[1], color, slope[0], slope[1])
for tile in flipped:
oregon[tile[0]][tile... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def successor(state, move, color):\n if move == 'pass':\n return state\n flip = []\n new_state = deepcopy(state)\n for x in OFFSETS:\n if len(flips(state, move[0], move[1], color, x[0], x[1])) > 0:\n flip.append(flips(state, move[0], move[1], color, x[0], x[1]))\n for i in f... | [
"0.7315014",
"0.7054301",
"0.67438483",
"0.6518778",
"0.64680874",
"0.6457673",
"0.641958",
"0.6325351",
"0.62590915",
"0.61907196",
"0.61260325",
"0.6120716",
"0.6120716",
"0.6120716",
"0.6089175",
"0.60612714",
"0.6043609",
"0.6043104",
"0.6016685",
"0.6007691",
"0.59890145... | 0.73057914 | 1 |
Initialize this linked list and append the given items, if any. | def __init__(self, iterable=None):
self.head = None # First node
self.tail = None # Last node
self.size = 0 # Number of nodes
# Append the given items
if iterable is not None:
for item in iterable:
self.append(item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, items=None):\n # Initialize a new linked list to store the items\n self.list = LinkedList()\n # self.size property is _size()\n if items is not None:\n for item in items:\n self.add(item)",
"def __init__(self, items=None):\n # Initia... | [
"0.7823849",
"0.73151284",
"0.7237857",
"0.72270656",
"0.7193887",
"0.7094527",
"0.69056433",
"0.6805241",
"0.6748211",
"0.6748211",
"0.6682381",
"0.6681221",
"0.66556454",
"0.66294175",
"0.65985966",
"0.6542515",
"0.6529034",
"0.64502317",
"0.64290744",
"0.64290744",
"0.6409... | 0.6727534 | 11 |
Return True if this linked list is empty, or False. | def is_empty(self):
return self.head is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return self.head.next is None",
"def isEmpty(self):\n return True if self.head is None else False",
"def isEmpty(self) -> bool:\n return self.head == None",
"def isEmpty(self) -> bool:\n return self.head == None",
"def is_empty(self):\n return self.h... | [
"0.88283503",
"0.87898487",
"0.87222123",
"0.87222123",
"0.8680919",
"0.8676428",
"0.8637684",
"0.86295927",
"0.8571739",
"0.85667664",
"0.8563026",
"0.84859544",
"0.84719425",
"0.8466275",
"0.84423196",
"0.84339637",
"0.8361087",
"0.8342684",
"0.83384484",
"0.8312394",
"0.82... | 0.85825473 | 11 |
Return the item at the given index in this linked list, or raise ValueError if the given index is out of range of the list size. | def get_at_index(self, index):
# Check if the given index is out of range and if so raise an error
if not (0 <= index < self.size):
raise ValueError('List index out of range: {}'.format(index))
current_node = self.head
index_counter = 0
# if index is he... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get( self, index ):\n\n if index < 0 or index >= self.size:\n raise IndexError( str( index ) + ' is out of range.' )\n\n curr = self.head\n while index > 0:\n curr = curr.next\n index -= 1\n return curr.data",
"def get(self, index):\n if ind... | [
"0.740916",
"0.7398684",
"0.73548806",
"0.7331983",
"0.7281293",
"0.72545904",
"0.72545904",
"0.7122561",
"0.7069617",
"0.70646286",
"0.7060615",
"0.7006379",
"0.70052683",
"0.70006514",
"0.6976848",
"0.69654274",
"0.6863898",
"0.68589455",
"0.68560034",
"0.6831526",
"0.67907... | 0.7261162 | 5 |
Insert the given item at the tail of this linked list. | def append(self, item):
# Create a new node to hold the given item
new_node = Node(item)
# Check if this linked list is empty
if self.is_empty():
# Assign head to new node
self.head = new_node
else:
# Otherwise insert new node after tail
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, item):\n # Insert the item at the end and bubble up to the root\n self.items.append(item)\n if self.size() > 1:\n self._bubble_up(self._last_index())",
"def append(self, item):\n # TODO: append given item\n new_node = Node(item)\n if self.is_e... | [
"0.7283685",
"0.72345734",
"0.71695954",
"0.71304846",
"0.71255624",
"0.7107158",
"0.70298004",
"0.70175946",
"0.69855773",
"0.698448",
"0.6979203",
"0.69553536",
"0.6909858",
"0.6891194",
"0.68188393",
"0.68168277",
"0.6806981",
"0.6799403",
"0.67990834",
"0.6747208",
"0.674... | 0.6978385 | 11 |
Determines if a data array is suitable for plotting by checking the contents of its elements. Empty arrays cause the function to return True. | def invalid_dataset(data):
for key in data.variables:
if len(data[key]) < 1:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_ndarray(data_to_check):\n flag = False\n if isinstance(data_to_check, np.ndarray):\n flag = True\n return flag",
"def data_is_an_array_with_more_than_one_element(data) -> bool:\n if np.isscalar(data):\n return False\n\n return data.size > 1",
"def _is_valid_data(data):\n ... | [
"0.7334786",
"0.72688425",
"0.7077974",
"0.7060229",
"0.68211395",
"0.6724189",
"0.66698116",
"0.6664933",
"0.6646834",
"0.6575998",
"0.65621346",
"0.65564406",
"0.65546453",
"0.65490174",
"0.6537153",
"0.651016",
"0.64935815",
"0.6479949",
"0.64303905",
"0.6422352",
"0.64000... | 0.646591 | 18 |
Converts a dataset from xarray format to an OrderedDict of Variables. | def dataset_to_dict(data):
dataset = DataSet()
for key in data.variables:
dataset[key] = Variable(key, data[key])
return dataset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self):\n dataset = xr.open_dataset(self._filename)\n state = {}\n for name, value in dataset.data_vars.items():\n state[name] = DataArray(value[0, :]) # remove time axis\n state['time'] = datetime64_to_datetime(dataset['time'][0].values)\n return state",
"d... | [
"0.6202152",
"0.61343503",
"0.60778534",
"0.5854227",
"0.57923406",
"0.5791023",
"0.55263454",
"0.5477053",
"0.5454666",
"0.5412217",
"0.53758794",
"0.53663176",
"0.53629464",
"0.5254145",
"0.5240559",
"0.5170293",
"0.5153914",
"0.5144181",
"0.5141146",
"0.5044785",
"0.503930... | 0.6479902 | 0 |
Evaluate if two slicers are equivalent. | def __eq__(self, otherSlicer):
# If the two slicers are both healpix slicers, check nsides value.
if isinstance(otherSlicer, HealpixSlicer):
return (otherSlicer.nside == self.nside)
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(a, b):\n iseq = False\n scalErr = np.abs(a.X_scale - b.X_scale) / np.max(np.abs(a.X_scale))\n centErr = np.abs(a.X_center - b.X_center) / np.max(np.abs(a.X_center))\n\n RErr = np.abs(a.S - b.S) / np.max(np.abs(a.S))\n LErr = np.abs(a.L - b.L) / np.max(np.abs(a.L))\n ... | [
"0.5957783",
"0.58731246",
"0.58433634",
"0.5787223",
"0.5774634",
"0.57545406",
"0.57441944",
"0.5699041",
"0.56567466",
"0.5648529",
"0.564623",
"0.5645381",
"0.5641127",
"0.5640909",
"0.5583493",
"0.5569167",
"0.5565111",
"0.5547802",
"0.5541847",
"0.5507198",
"0.55049974"... | 0.7271944 | 0 |
Function to return a '|' delimited string which contains the updated contribution information. | def write(self, contribution):
cmte_id = contribution.cmte_id
group = self._get_group(contribution)
amnt = str(int(round(self.data[cmte_id][group].median)))
cnt = str(int(round(self.data[cmte_id][group].count)))
total = str(int(round(self.data[cmte_id][group].total)))
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n s = [ str(self.uri), str(self.lastmod), str(self.length),\n str(self.md5 if self.md5 else self.sha1) ]\n if (self.change is not None):\n s.append(str(self.change))\n if (self.path is not None):\n s.append(str(self.path))\n return \... | [
"0.5991528",
"0.55827844",
"0.55299914",
"0.55035865",
"0.55030257",
"0.54999787",
"0.5499362",
"0.5491967",
"0.54736054",
"0.54435366",
"0.5442947",
"0.5391225",
"0.5357214",
"0.53561044",
"0.531372",
"0.5288848",
"0.52695173",
"0.5247197",
"0.5232287",
"0.5205439",
"0.51861... | 0.5324821 | 14 |
Function to generate a '|' delimited string which contains the updated contribution information. | def write(self, contribution):
for cmte_id, date_running_median in sorted(self.data.items()):
for dt, running_median in sorted(date_running_median.items()):
amnt = str(int(round(running_median.median)))
cnt = str(int(round(running_median.count)))
total... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n s = [ str(self.uri), str(self.lastmod), str(self.length),\n str(self.md5 if self.md5 else self.sha1) ]\n if (self.change is not None):\n s.append(str(self.change))\n if (self.path is not None):\n s.append(str(self.path))\n return \... | [
"0.6103077",
"0.59874034",
"0.5920234",
"0.58036256",
"0.57875353",
"0.57144505",
"0.56355834",
"0.5620963",
"0.5499697",
"0.5484917",
"0.5431172",
"0.54247516",
"0.54050285",
"0.5403762",
"0.53621",
"0.5361399",
"0.53531826",
"0.53423",
"0.5337528",
"0.5326829",
"0.53255063"... | 0.0 | -1 |
Generator to yield one after the others all items currently in the queue Q, without any waiting. | def get_all_from_queue(Q):
try:
while True:
yield Q.get_nowait( )
except queue.Empty:
raise StopIteration | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n while not self.post_queue.empty():\n yield self.post_queue.get()",
"def tasks(self):\n while True:\n ingredient = self.ingredientQueue.get()\n # If poison pill appears, stop generating tasks.\n if ingredient is None:\n ... | [
"0.6981119",
"0.6906081",
"0.66054434",
"0.64848584",
"0.6399687",
"0.6376729",
"0.635194",
"0.629381",
"0.6120286",
"0.61145955",
"0.6089845",
"0.60766774",
"0.60648346",
"0.60616297",
"0.60555905",
"0.6037601",
"0.60015935",
"0.59958005",
"0.59943956",
"0.59857917",
"0.5976... | 0.75308734 | 0 |
Check if the object has a parent object | def has_parent(obj):
return obj and hasattr(obj, 'parent') and obj.parent | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_on_parent(self):\n pass",
"def isContainedBy(self, obj):\n\t\tret = False\n\t\tp = self.Parent\n\t\twhile p is not None:\n\t\t\tif p is obj:\n\t\t\t\tret = True\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tp = p.Parent\n\t\treturn ret",
"def HasParent(self, type_):\r\n\r\n try:\r\n\r\n ... | [
"0.79006",
"0.7769584",
"0.74012893",
"0.7336038",
"0.7322141",
"0.7244784",
"0.7244672",
"0.7202469",
"0.7179421",
"0.70980126",
"0.7043829",
"0.69477326",
"0.6946715",
"0.690819",
"0.68979645",
"0.68889093",
"0.6864231",
"0.6804025",
"0.6738162",
"0.66821015",
"0.6671467",
... | 0.89234287 | 0 |
Unset object parents but maintain current position in world, optionally reparenting to the active object | def deparent_move_reparent(move_to_new_parent=True, reparent=True):
if reparent:
# use active as target for reparenting selected child to new parent
objs = get_inactive_selected()
target = bpy.context.scene.objects.active
else:
objs = get_selected()
# move, deparent, optiona... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unset_parent(obj):\n if obj and hasattr(obj, 'parent'):\n obj.parent = None\n return obj",
"def parentClear(ob, type):\n\tif type == 'CLEAR_KEEP_TRANSFORM':\n\t\tmw = ob.matrix_world.copy()\n\t\tob.parent = None\n\t\tob.matrix_world = mw\n\telse:\n\t\tob.parent = None",
"def unparent(context):... | [
"0.68650323",
"0.6823112",
"0.6815915",
"0.65554714",
"0.648097",
"0.64008987",
"0.63791263",
"0.63262653",
"0.60721767",
"0.60377544",
"0.59794676",
"0.5972436",
"0.5937747",
"0.5843547",
"0.58396405",
"0.5792932",
"0.5780508",
"0.5774529",
"0.5764447",
"0.5748983",
"0.57108... | 0.6072178 | 8 |
Process a specified Date time. | def date_time(self, *arg, format_=None):
year, month, day, hour, minute, second = arg
utc_dt = datetime(year,
month,
day,
hour,
minute,
second,
tzin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _process_datetime(self, soup):\n try:\n date = soup.find('action-date').text.split('-')\n conv = {v: k for k, v in enumerate(calendar.month_abbr)}\n date[1] = conv[date[1]]\n time = soup.find('action-time').get('time-etz').split(':')\n dt = datetime... | [
"0.5989979",
"0.5888597",
"0.5775331",
"0.55580026",
"0.54928285",
"0.5471491",
"0.54269266",
"0.5424491",
"0.5411538",
"0.53931683",
"0.53026485",
"0.52852994",
"0.5273076",
"0.5250432",
"0.52062446",
"0.5189522",
"0.51806295",
"0.5175345",
"0.517507",
"0.51718676",
"0.51688... | 0.55665255 | 3 |
Generate the current datetime. | def _now(self):
now = datetime.now()
local_dt = now.astimezone(self.time_zone)
return local_dt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nowdate():\n return datetime.datetime.now().timetuple()",
"def get_current_date(self):\n return datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S')",
"def datet():\n return datetime.now()",
"def curr_time():\r\n d = datetime.now()\r\n curr_date = str(d.year) + '_' + str(d.month) + ... | [
"0.8103343",
"0.79640615",
"0.7920266",
"0.7873943",
"0.786625",
"0.78216445",
"0.7735986",
"0.7709559",
"0.7709559",
"0.7709559",
"0.7709559",
"0.7694872",
"0.7687635",
"0.7680648",
"0.7637083",
"0.7636364",
"0.76129556",
"0.75559545",
"0.7553131",
"0.7539491",
"0.7534034",
... | 0.7073668 | 81 |
Return roll, pitch, yaw from car's pose | def get_car_euler(self, car_pose):
return tf.transformations.euler_from_quaternion([
car_pose.orientation.x,
car_pose.orientation.y,
car_pose.orientation.z,
car_pose.orientation.w]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getHeading():\n return bearing(getPose()['Pose']['Orientation'])",
"def get_yaw(pose_stamped):\n orientation = get_orientation(pose_stamped.pose)\n\n euler = tf.transformations.euler_from_quaternion(orientation)\n return euler[2] # z direction",
"def get_yaw_from_pose(p: Pose) -> float:\n\n ... | [
"0.64945453",
"0.64434177",
"0.62026525",
"0.61319774",
"0.6130405",
"0.60689425",
"0.60689425",
"0.5988989",
"0.597472",
"0.5932469",
"0.59279525",
"0.59202915",
"0.5913885",
"0.5904007",
"0.5901863",
"0.58362186",
"0.58199066",
"0.57807755",
"0.572156",
"0.5713383",
"0.5708... | 0.5215918 | 85 |
This method tests fetching a user's profile | def test_fetching_profile(self):
response = self.client.get("/api/profile/test123/", format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK)
assert "username" in response.data
assert "bio" in response.data
assert "location" in response.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_get_profile(self):\n try:\n self.user.get_profile()\n except SiteProfileNotAvailable:\n pass",
"def test_access_profile(self):\n response = self.user_client.get(reverse_lazy('profile_detail'))\n self.assertEqual(response.status_code, 200)",
"def t... | [
"0.8673785",
"0.84101033",
"0.8373316",
"0.83712196",
"0.83212936",
"0.82740486",
"0.82721716",
"0.8233416",
"0.82200325",
"0.8172333",
"0.8150381",
"0.8127634",
"0.8117629",
"0.80541253",
"0.80282885",
"0.8012369",
"0.80006075",
"0.7992898",
"0.79873896",
"0.79368085",
"0.78... | 0.82332116 | 8 |
This method tests fetching a profile that doesn't exists | def test_fetching_missing_profile(self):
response = self.client.get("/api/profile/testuuuu/", format="json")
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
assert "errors" in response.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_get_profile(self):\n try:\n self.user.get_profile()\n except SiteProfileNotAvailable:\n pass",
"def test_get_user_profile_doesnot_exist(self):\n response = self.client.get(\"/api/profiles/dfsfdsfdsd/\", format=\"json\")\n self.assertEqual(response.s... | [
"0.811111",
"0.80943024",
"0.7947829",
"0.77751344",
"0.77751344",
"0.75345546",
"0.72596925",
"0.72343236",
"0.7224506",
"0.715433",
"0.70735747",
"0.7063153",
"0.6976052",
"0.69684196",
"0.69379985",
"0.69247353",
"0.68530136",
"0.68010885",
"0.6795911",
"0.67953175",
"0.67... | 0.8262539 | 0 |
This method tests the profile model | def test_profile_model(self):
entry = Profile(bio="i love me", location="mbuya", fun_fact="food")
self.assertEqual(str(entry.bio), "i love me")
self.assertEqual(str(entry.location), "mbuya")
self.assertEqual(str(entry.fun_fact), "food") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_can_see_its_profile(self):\n one_user = User.objects.first()\n self.assertIsNotNone(one_user.profile)",
"def test_get_profile(self):\n profile = Profile(self.client, \"exampleUser\")\n\n self.assertEqual(profile.username, \"exampleUser\")\n self.assertEqual(profil... | [
"0.7785994",
"0.77819014",
"0.77458304",
"0.77320904",
"0.7606563",
"0.7593099",
"0.7401796",
"0.7400081",
"0.7400081",
"0.72970504",
"0.7293616",
"0.7289369",
"0.7287546",
"0.72577965",
"0.7247257",
"0.72098124",
"0.7206523",
"0.7171848",
"0.71351457",
"0.71115506",
"0.71049... | 0.8226491 | 0 |
This method tests following a user without logging in | def test_follow_a_user_no_auth(self):
client = APIClient()
client.credentials(HTTP_TOKEN="not-a-token")
response = client.post("/api/profile/test1234/follow/", format="json")
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
self.assertEqual(response.data.get("det... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_following_logged_out(self):\n\n with self.client as c:\n res = c.get(f'/users/{self.testuser.id}/following', follow_redirects=True)\n self.assertEqual(res.status_code, 200)\n self.assertIn(\"Access unauthorized\", str(res.data))",
"def test_visit_other_user_p... | [
"0.76420516",
"0.7546843",
"0.7513591",
"0.7511712",
"0.74955785",
"0.74552137",
"0.74417937",
"0.74076897",
"0.73643404",
"0.7323765",
"0.7318205",
"0.73154557",
"0.7294398",
"0.7288903",
"0.7267699",
"0.72133857",
"0.72089005",
"0.71619844",
"0.71085155",
"0.7044212",
"0.70... | 0.7221085 | 15 |
This method tests unfollowing a user | def test_unfollow_a_user(self):
self.client.post("/api/profile/test1234/follow/", format="json")
response = self.client.delete(
"/api/profile/test1234/unfollow/", format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
response.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unfollow_a_user_not_following(self):\n response = self.client.delete(\n \"/api/profile/test1234/unfollow/\", format=\"json\")\n self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)\n self.assertEqual(\n response.data.get(\"message\"),\n ... | [
"0.85305816",
"0.83274555",
"0.804927",
"0.7928863",
"0.7851319",
"0.7829444",
"0.7822531",
"0.7702483",
"0.76595944",
"0.7643557",
"0.75989234",
"0.7563606",
"0.75419617",
"0.7520955",
"0.7480285",
"0.7458814",
"0.739433",
"0.7345242",
"0.7261711",
"0.71908796",
"0.71671516"... | 0.8348236 | 1 |
This method tests unfollowing a user who is not being followed | def test_unfollow_a_user_not_following(self):
response = self.client.delete(
"/api/profile/test1234/unfollow/", format="json")
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
response.data.get("message"),
"You are currentl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unfollow_user(self):\n login_response = self.client.post(self.login_url, self.user_data, format='json')\n headers = {'HTTP_AUTHORIZATION': 'Bearer {}'.format(login_response.data.get('token'))}\n\n unfollow_response = self.client.delete(self.follow_url, **headers)\n self.assertE... | [
"0.8367832",
"0.8324904",
"0.830047",
"0.81845766",
"0.815808",
"0.80216444",
"0.7980947",
"0.79698104",
"0.79392296",
"0.7932808",
"0.7917642",
"0.7808317",
"0.7769253",
"0.77620023",
"0.775456",
"0.7747725",
"0.7739335",
"0.770379",
"0.76605976",
"0.76493275",
"0.76055807",... | 0.88173157 | 0 |
This method tests response for a user following themselves | def test_user_follows_themselves(self):
response = self.client.post(
"/api/profile/test123/follow/", format="json")
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
response.data.get("message"),
"As awesome as you may be, y... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_follow_user(self):\n\n login_response = self.client.post(self.login_url, self.user_data, format='json')\n headers = {'HTTP_AUTHORIZATION': 'Bearer {}'.format(login_response.data.get('token'))}\n follow_response = self.client.post(self.follow_url, **headers)\n self.assertEqual(l... | [
"0.7851512",
"0.77770215",
"0.7761036",
"0.7697879",
"0.76410604",
"0.7638373",
"0.75877285",
"0.75859106",
"0.75494957",
"0.7486937",
"0.7462865",
"0.7407376",
"0.7405996",
"0.73939306",
"0.7369312",
"0.73577213",
"0.73574936",
"0.7335629",
"0.7319237",
"0.73023546",
"0.7247... | 0.7893002 | 0 |
This method tests following a user that doesnt exist | def test_follow_a_user_who_doesnt_exist(self):
response = self.client.post(
"/api/profile/someuser/follow/", format="json")
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_is_not_following(self):\n\n resp = self.test_user.is_following(self.test_user2)\n\n self.assertEqual(False, resp)",
"def test_user_is_not_followed_by(self):\n\n resp = self.test_user.is_followed_by(self.test_user2)\n self.assertEqual(False, resp)",
"def test_user_not_f... | [
"0.808417",
"0.7979186",
"0.79360265",
"0.7680225",
"0.76329297",
"0.7611902",
"0.7584409",
"0.75272954",
"0.7506388",
"0.7421354",
"0.7397772",
"0.7382027",
"0.7379391",
"0.7363298",
"0.7335951",
"0.732718",
"0.73228997",
"0.7306413",
"0.7282195",
"0.72721463",
"0.7264081",
... | 0.7587791 | 6 |
Rotates basis by angles specified. | def __init__(self, angles=DEFAULT_ANGLES, axes=DEFAULT_AXES, *args, **kwargs):
super().__init__(*args, **kwargs)
x_angles = angles if axes[0] else torch.tensor([0], dtype=torch.float32)
z_angles = angles if axes[1] else torch.tensor([0], dtype=torch.float32)
y_angles = angles if axes[2]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotationFromAngleDirection(*args):\n return _almathswig.rotationFromAngleDirection(*args)",
"def rotationFromAngleDirection(*args):\n return _almathswig.rotationFromAngleDirection(*args)",
"def Rotation_fromAngleDirection(*args):\n return _almathswig.Rotation_fromAngleDirection(*args)",
"def Rotation_... | [
"0.70419174",
"0.70419174",
"0.70049465",
"0.70049465",
"0.6861959",
"0.6861959",
"0.6753033",
"0.6750428",
"0.6750428",
"0.67386365",
"0.66405064",
"0.65731496",
"0.6557219",
"0.65490514",
"0.6478007",
"0.63947386",
"0.63861746",
"0.63847816",
"0.63557017",
"0.63211787",
"0.... | 0.0 | -1 |
Returns data of a single joint. | def __init__(self, joint_name,*args, **kwargs):
self.joint_name = joint_name
super().__init__(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_single_joint (self,num):\n return self.val[num-1]",
"def _get_joint_info(self):\n info = p.getJointStates(\n self.robot,\n jointIndices=self.robot_arm_joint_indices,\n physicsClientId=self.id)\n\n pos, vel, rf, t = [], [], [], []\n\n for joint_... | [
"0.60742605",
"0.5965251",
"0.5917911",
"0.5857953",
"0.5712779",
"0.5676377",
"0.5613316",
"0.5535047",
"0.54871255",
"0.54242057",
"0.541869",
"0.5390672",
"0.5353197",
"0.5318795",
"0.53181136",
"0.5285966",
"0.527362",
"0.5272912",
"0.52724624",
"0.52657634",
"0.5248823",... | 0.0 | -1 |
Transforms animation data to sliding windows of data. | def __init__(self, window_size, stride, *args, **kwargs):
super().__init__(*args, **kwargs)
self.window_size = window_size
self.stride = stride | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sliding_windows(data, seq_length, future=1):\n x = []\n y = []\n\n for i in range(len(data)-seq_length-future):\n tx = data[i:(i+seq_length)]\n ty = data[i+seq_length+future-1]\n x.append(tx)\n y.append(ty)\n\n return np.array(x),np.array(y)",
"def sliding_windows(dat... | [
"0.66718346",
"0.64451265",
"0.62327373",
"0.6072788",
"0.5995178",
"0.5938003",
"0.5834884",
"0.58229506",
"0.5820739",
"0.5811532",
"0.58036524",
"0.57478744",
"0.5702571",
"0.56893206",
"0.56773967",
"0.5672597",
"0.561213",
"0.55523664",
"0.55388105",
"0.55385023",
"0.553... | 0.0 | -1 |
Checks a members Guild Permissions | async def check_permissions(self, ctx, *, member: discord.Member = None):
member = member or ctx.author
# Here we check if the value of each permission is True.
perms = '\n'.join(perm for perm, value in member.guild_permissions if value)
# And to make it look nice, we wrap it in an Embed.
embed = di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def check_permissions(self, ctx, *, member):\n member = await search(ctx, member)\n if not member:\n member = ctx.author\n\n # Here we check if the value of each permission is True.\n perms = '\\n'.join(\n perm for perm, value in member.guild_permissions if v... | [
"0.7211836",
"0.7155094",
"0.672314",
"0.6708675",
"0.66196203",
"0.64509326",
"0.63732666",
"0.63720506",
"0.63638836",
"0.6330571",
"0.6275244",
"0.62000644",
"0.61586756",
"0.6118124",
"0.6118124",
"0.6118124",
"0.6118124",
"0.6118124",
"0.6103729",
"0.60974056",
"0.609422... | 0.6994716 | 2 |
Check to see if any children of the Node are suspected of being small. To do this, iterate over each of the Node's children. For each child, consider all possible combinations of the child's itemsets and attempt to traverse to those nodes. If the child's subset Nodes are all Boxes, then the child is suspected of being ... | def handle_supersets(self):
for child in self.children:
transition_child = True
# Generate all sized combinations of the child itemset from 1 to the max length of the child itemset.
for i in range(1, len(child)):
if not transition_child:
b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_tree_viability(self, tree):\n\n ## Check that the type of the tree is LevelSetTree\n self.assertTrue(isinstance(tree, dcl.level_set_tree.LevelSetTree))\n\n ## Check min and max density levels\n start_levels = [x.start_level for x in tree.nodes.values()]\n self.assertAl... | [
"0.6706569",
"0.659247",
"0.6098397",
"0.6075094",
"0.5744959",
"0.5736071",
"0.56748796",
"0.56542903",
"0.55764246",
"0.54172426",
"0.5319665",
"0.53143203",
"0.5309171",
"0.5257104",
"0.52338153",
"0.521896",
"0.521896",
"0.5213835",
"0.520625",
"0.5201989",
"0.5178577",
... | 0.6518274 | 2 |
Return a random float in the range [0, 1) | def float(self):
# get one and return it
return gsl.rng_uniform(self.rng) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _random_float(self):\n return random.uniform(1, 2)",
"def generate_float(self):\n\n value = random()\n return value",
"def getRandomFloat(minFloat, maxFloat):\n random.uniform(minFloat, maxFloat)",
"def _rand_float(self, low, high):\n\n return self.np_random.uniform... | [
"0.87448144",
"0.84006536",
"0.78244984",
"0.758074",
"0.74938715",
"0.7357534",
"0.7326019",
"0.72695076",
"0.7128028",
"0.69500923",
"0.6926148",
"0.6924753",
"0.6880933",
"0.68219316",
"0.6805994",
"0.67602056",
"0.6648451",
"0.66355205",
"0.66326725",
"0.66042036",
"0.660... | 0.74041 | 5 |
Walk over the message tree, yielding each subpart. The walk is performed in depthfirst order. This method is a generator. | def walk(self):
yield self
if self.is_multipart():
for subpart in self.get_payload():
for subsubpart in subpart.walk():
yield subsubpart | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def typed_subpart_iterator(msg, maintype = 'text', subtype = None):\n\tfor subpart in msg.walk():\n\t\tif subpart.get_content_maintype() == maintype:\n\t\t\tif subtype is None or subpart.get_content_subtype() == subtype:\n\t\t\t\tyield subpart",
"def walk_tree(self):\n stack = [self.parent]\n\n whi... | [
"0.65155303",
"0.6191275",
"0.61762244",
"0.6161851",
"0.61542946",
"0.60966426",
"0.6096308",
"0.6067182",
"0.6029377",
"0.6011487",
"0.60030335",
"0.5995189",
"0.598529",
"0.5955864",
"0.5916791",
"0.5912674",
"0.5891333",
"0.58886003",
"0.58405876",
"0.58269006",
"0.581472... | 0.7669884 | 0 |
Transform the price vector into a normalize vector. (Px/P0 1) | def normalize_data(self):
data = self.data
p0 = data[0]
normalised = np.array([(pi / p0) - 1 for pi in data])
normalised = normalised[np.newaxis, :, np.newaxis]
return normalised | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_p_vec(p_vec):\n return p_vec / np.sum(p_vec)",
"def normalize_vector(v, p=2):\n v_norm = norm(v, p=p)\n return vector(*[vi/v_norm for vi in v])",
"def normalize(vector):\n return vector / np.sqrt(np.dot(vector, vector))",
"def normalize(v: Vector2) -> Vector2:\n return scale(... | [
"0.7399244",
"0.7376934",
"0.7366628",
"0.7337651",
"0.7235046",
"0.71873075",
"0.71651775",
"0.7164821",
"0.71565115",
"0.71435195",
"0.70733607",
"0.7053775",
"0.70028",
"0.69868296",
"0.697566",
"0.695866",
"0.69521135",
"0.692699",
"0.6889921",
"0.6859361",
"0.68570954",
... | 0.0 | -1 |
Initialize a new network. | def __init__(self, input_dim=(1, 28, 28), num_classes=10):
self.params = {}
#######################################################################
# TODO: Initialize weights and biases for the convolutional neural #
# network. Weights should be initialized from a Gaussian distributi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_network(self):\n #Create the network\n self.network = Network(\"50.19.23.117\", 8080)",
"def __init__(self, amount_nodes, amount_links):\n self.nodes = {}\n self.__createNetwork__(amount_nodes, amount_links)",
"def init_network(name=NETWORK_NAME, nodes=[\"Alice\",\"Bob\",... | [
"0.8108218",
"0.76692665",
"0.7656324",
"0.76131594",
"0.7444921",
"0.74334115",
"0.7371696",
"0.72837204",
"0.70510834",
"0.7018292",
"0.69512916",
"0.69427025",
"0.6935787",
"0.69219816",
"0.6816404",
"0.6807591",
"0.67830807",
"0.6775899",
"0.67708445",
"0.6768226",
"0.676... | 0.0 | -1 |
The set of arguments for constructing a Subscription resource. | def __init__(__self__, *,
protocol: pulumi.Input[str],
topic_arn: pulumi.Input[str],
delivery_policy: Optional[Any] = None,
endpoint: Optional[pulumi.Input[str]] = None,
filter_policy: Optional[Any] = None,
filter_poli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__,\n resource_name: str,\n args: SubscriptionArgs,\n opts: Optional[pulumi.ResourceOptions] = None):\n ...",
"def __init__(__self__,\n resource_name: str,\n opts: Optional[pulumi.ResourceOptions] = None,\n ... | [
"0.78140116",
"0.64488304",
"0.634876",
"0.6191446",
"0.6107919",
"0.60913295",
"0.60814863",
"0.5999243",
"0.5991154",
"0.5983495",
"0.5983495",
"0.59587634",
"0.5890025",
"0.5886919",
"0.5886822",
"0.5868369",
"0.583997",
"0.58196425",
"0.58073175",
"0.57810974",
"0.5764385... | 0.5302086 | 100 |
Weighted average norm function as defined in 1985 Shampine. Takes a matrix and 2 weights and returns the maximum value (divided by wi) of the sum of each value in each row multiplied by wj. | def weightednorm(matrix, weights):
wi, wj = weights
ivalues = []
matrix = np.array(matrix)
try:
num_rows, num_columns = matrix.shape
dimensions = 2
except ValueError:
dimensions = 1
try:
num_rows = 1
num_columns = matrix.shape[0]
except... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weightednorm(matrix, weights):\n # Unpack the parameters\n wi, wj = weights\n\n # Initialize a list that will be called later to obtain the maximum value\n colsums = np.zeros(len(matrix))\n\n # Try loop used because numpy didn't seem to like 1D arrays for the\n # weighted norm\n try:\n ... | [
"0.75252855",
"0.6718781",
"0.65091085",
"0.6432307",
"0.63731784",
"0.6331785",
"0.6202949",
"0.6149382",
"0.60940415",
"0.60940415",
"0.6077976",
"0.60480744",
"0.6042871",
"0.60348666",
"0.6025936",
"0.59846526",
"0.59846115",
"0.5972666",
"0.5962937",
"0.59628993",
"0.590... | 0.7722839 | 1 |
Initialize metadata and real data for a sensor; for detailed info see docs | def setup(self) -> None:
# Meta
self.lat: Optional[float] = self.safe_float('Lat')
self.lon: Optional[float] = self.safe_float('Lon')
self.identifier: Optional[int] = self.channel_data.get('ID')
self.parent: Optional[int] = self.channel_data.get('ParentID')
self.type: str... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, sensor):\n self.sensor = sensor\n # update\n self.sensor_data.temperature = None\n self.sensor_data.humidity = None",
"def create_sensors(self):\n self._add_sensor('temp')\n self._add_sensor('humid')\n self._add_sensor('winddir')\n self._... | [
"0.7492242",
"0.6881894",
"0.6728476",
"0.6693154",
"0.66912216",
"0.66284204",
"0.66275555",
"0.6596116",
"0.6572266",
"0.65691453",
"0.6564251",
"0.6551904",
"0.6534312",
"0.6448177",
"0.6438216",
"0.6422191",
"0.64139915",
"0.6387975",
"0.6380109",
"0.63731396",
"0.6367379... | 0.6367109 | 21 |
String representation of the class | def __repr__(self):
child_string = f', child of {self.parent}' if self.parent is not None else ''
return f"Sensor {self.identifier}{child_string}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return \"Class({})\".format(\", \".join(\"{}={}\".format(k, v) for k, v in self.items()))",
"def to_str (self):\n return str(self.__class__) + \" \" + pprint.pformat(self.to_dict())",
"def __str__(self):\n return \"\\n\".join([str(c) for c in self.get_classes()])",
"... | [
"0.8656521",
"0.8455953",
"0.83694166",
"0.8277728",
"0.81655306",
"0.81581765",
"0.814591",
"0.80360377",
"0.78959006",
"0.78959006",
"0.7880071",
"0.7877217",
"0.7853193",
"0.7823131",
"0.77910405",
"0.7776167",
"0.7740576",
"0.77326995",
"0.77192354",
"0.77192354",
"0.7711... | 0.0 | -1 |
Return 2vector valued velocity. ordering of dimensions is same as in the netcdf variables, with velocity component at the end (which at least with the local suntans nc code is (face,layer,time) ) | def get_cell_velocity(self,time_slice,mesh_name=None,face_slice=slice(None)):
# time_slice used to be time_step
mesh_name = mesh_name or self.mesh_name
slices={'time':time_slice,
'n'+mesh_name+'_face':face_slice}
u_comp=ncslice(self.nc.variables[mesh_name+'_cell_east_ve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def velocity(self):\n return self.vx, self.vy",
"def transporting_velocity(self):\n xn = self.x.n\n xnp1 = self.x.np1\n # computes ubar from un and unp1\n return xn('u') + self.alpha*(xnp1('u')-xn('u'))",
"def create_velocity_scale(self):\n return(self.c2v(range(self.n... | [
"0.67182475",
"0.666979",
"0.66040885",
"0.65503556",
"0.65287596",
"0.6508243",
"0.6486791",
"0.6477589",
"0.64577293",
"0.6453151",
"0.64429253",
"0.6427095",
"0.6427095",
"0.6376797",
"0.6364567",
"0.6341414",
"0.63111705",
"0.63111705",
"0.63001406",
"0.62715197",
"0.6265... | 0.64965093 | 6 |
Return 2vector valued velocity. | def get_cell_velocity(self,time_slice,face_slice=None):
# time_slice used to be time_step
mesh_name = self.mesh_name
if self.time_dim is not None:
slices={self.time_dim:time_slice}
else:
slices={}
if face_slice is not None:
slice... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_velocity(self):\r\n return self._v",
"def velocity(self):\n return self.vx, self.vy",
"def velocity(self):\n with self.lock:\n velocity = self._velocity\n return velocity",
"def velocity(self):\n multirotor_state = self.sim_handler.client_state\n a... | [
"0.81047803",
"0.8041426",
"0.8011769",
"0.7921143",
"0.78935117",
"0.7884734",
"0.7847891",
"0.78137386",
"0.78023773",
"0.778239",
"0.7774251",
"0.7728805",
"0.77125615",
"0.7694625",
"0.7590544",
"0.75780237",
"0.75780237",
"0.75043607",
"0.7492725",
"0.74898106",
"0.74877... | 0.0 | -1 |
Returns whether a string is in ASCII. | def is_ascii(string):
return all(ord(c) < 128 for c in string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_ascii(s):\r\n return all(ord(c) < 128 for c in s)",
"def is_ascii(s):\n return all(ord(c) < 128 for c in s)",
"def is_ascii(s):\n return all(ord(c) < 128 for c in s)",
"def isAscii(s: str) -> bool:\n try:\n s.encode('ascii')\n return True\n except UnicodeEncodeError:\n ... | [
"0.8389414",
"0.838354",
"0.838354",
"0.83597386",
"0.83316684",
"0.8174022",
"0.7666155",
"0.7637639",
"0.74566907",
"0.72856873",
"0.7021921",
"0.6974223",
"0.67577153",
"0.67387724",
"0.67187774",
"0.6568902",
"0.65494215",
"0.64625907",
"0.64570904",
"0.6436339",
"0.64169... | 0.8473319 | 0 |
Determines the reason why a header is invalid. | def invalid_headers_reason(headers):
if headers is None:
return 'Headers dictionary was None.'
if not isinstance(headers, dict):
return 'Invalid type for headers. Should be a dictionary.'
for k, v in six.iteritems(headers):
if not isinstance(k, six.string_types):
return 'Header names should be s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def httperrincompleteheaders(self) :\n\t\ttry :\n\t\t\treturn self._httperrincompleteheaders\n\t\texcept Exception as e:\n\t\t\traise e",
"def _check_header(self):\n if not self.spec_strm[0] == data_spec_constants.DSG_MAGIC_NUM:\n raise exceptions.MalformedHeaderException(\n \"He... | [
"0.73793876",
"0.71113586",
"0.70050377",
"0.68887776",
"0.6717017",
"0.6616391",
"0.65930206",
"0.64394873",
"0.6414212",
"0.63674444",
"0.6325786",
"0.6306056",
"0.6269503",
"0.6250753",
"0.6236807",
"0.617895",
"0.617462",
"0.6136168",
"0.6125893",
"0.6070274",
"0.60290855... | 0.71559584 | 1 |
Initializes an email message. This initializer creates a new `MailMessage` protocol buffer and initializes it with any keyword arguments. | def __init__(self, mime_message=None, **kw):
if mime_message:
mime_message = _parse_mime_message(mime_message)
self.update_from_mime_message(mime_message)
self.__original = mime_message
self.initialize(**kw) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, message=None):\n if isinstance(message, email.message.Message):\n self._become_message(copy.deepcopy(message))\n if isinstance(message, Message):\n message._explain_to(self)\n elif isinstance(message, bytes):\n self._become_message(em... | [
"0.6999212",
"0.65272313",
"0.6371061",
"0.63121104",
"0.6236944",
"0.61217695",
"0.6106835",
"0.6031098",
"0.60161114",
"0.59987265",
"0.5916372",
"0.5916372",
"0.5916372",
"0.5916372",
"0.59032744",
"0.5856343",
"0.584636",
"0.5832635",
"0.58295405",
"0.57981616",
"0.579619... | 0.603995 | 7 |
Get the magnitude zero point. | def get_magzp(self):
return self.meds_meta['magzp_ref'][0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __abs__(self):\r\n return self.magnitude",
"def _get_wavelength_magnitude(self, wavelength, zero_point_flux):\n flux = pf.PlottedPlanckFunction(self.surface_temp)(wavelength)\n # Get ratio of own flux to Vega's flux, ie. a reference point.\n return -2.5 * math.log(flux / zero_poin... | [
"0.7317524",
"0.7221478",
"0.70485044",
"0.6998562",
"0.6950807",
"0.6929673",
"0.6916039",
"0.6902153",
"0.6864023",
"0.68547225",
"0.671773",
"0.6679313",
"0.66581976",
"0.6633552",
"0.6576111",
"0.6554585",
"0.65522856",
"0.6524445",
"0.6513073",
"0.6474581",
"0.6418002",
... | 0.6000003 | 39 |
getCommandcodeBegin(self) get commandcode of begin except | def getCommandcodeBegin(self):
commandcode = "BEGINEXCEPT ({})".format(self.error) # commandcode
return commandcode | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCommandcodeEND(self):\n commandcode = \"ENDEXCEPT\" # commandcode\n return commandcode",
"def get_begin_string(self):\n return self.__begin_string",
"def get_code(self):\n to_return = \"\"\n for command in self.commands:\n to_return += command + \"\\n\"\n... | [
"0.7028773",
"0.6519944",
"0.6373815",
"0.6313938",
"0.62837064",
"0.6265312",
"0.62064135",
"0.62064135",
"0.62064135",
"0.62064135",
"0.62064135",
"0.61948967",
"0.6167015",
"0.6147601",
"0.60932934",
"0.60932934",
"0.60932934",
"0.6066326",
"0.6001739",
"0.5984619",
"0.596... | 0.78206015 | 0 |
Hash equal for same kinds of CudaNdarrayType. | def __hash__(self):
return hash(type(self)) ^ hash(self.broadcastable) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_array_hashable(arr):\n # look for precomputed value\n if isinstance(arr, DataArray) and np.ndarray is not DataArray:\n return arr.attrs.get('hash', get_array_hashable(arr.data))\n else:\n try:\n return arr.name.encode('utf-8') # dask array\n except AttributeError:\... | [
"0.64809465",
"0.6367519",
"0.6311264",
"0.6278089",
"0.6220671",
"0.615701",
"0.6115051",
"0.6095121",
"0.6062728",
"0.6041452",
"0.6039712",
"0.6013315",
"0.6013056",
"0.6008117",
"0.6008117",
"0.6007846",
"0.6007846",
"0.6000273",
"0.5994901",
"0.598043",
"0.59561443",
"... | 0.6169783 | 5 |
Finds contiguous True regions of the boolean array "condition". Returns a 2D array where the first column is the start index of the region and the second column is the end index. | def contiguous_regions(condition):
# Find the indicies of changes in "condition"
d = np.diff(condition)
idx, = d.nonzero()
# We need to start things after the change in "condition". Therefore,
# we'll shift the index by 1 to the right.
idx += 1
if condition[0]:
# If t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contiguous_regions(condition):\n\n # Find the indicies of changes in \"condition\"\n d = np.diff(condition)\n idx, = d.nonzero() \n\n # We need to start things after the change in \"condition\". Therefore, \n # we'll shift the index by 1 to the right.\n idx += 1\n\n if condition[0]:\n ... | [
"0.8509755",
"0.8450829",
"0.8442515",
"0.8431789",
"0.8431789",
"0.8431789",
"0.60076123",
"0.5880353",
"0.56802535",
"0.56728995",
"0.5663503",
"0.56248593",
"0.5404504",
"0.53610605",
"0.53091437",
"0.52525634",
"0.5220662",
"0.5214563",
"0.5151838",
"0.51418614",
"0.51265... | 0.84435296 | 2 |
Return the state of the entity. | def state(self):
return self._state | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state(self):\n return self.get_entity.state",
"def state(self) -> Union[None, str, int, float]:\n return self.entity.state",
"def getState (self):\n return self.state",
"def getState(self):\n return self.state",
"def getState(self):\n return self.state",
"def state(... | [
"0.8871852",
"0.8128686",
"0.76583034",
"0.7620778",
"0.7620778",
"0.7613815",
"0.75572854",
"0.75572854",
"0.75572854",
"0.75572854",
"0.75572854",
"0.75492287",
"0.75282794",
"0.7519398",
"0.7518661",
"0.7491793",
"0.7472836",
"0.74694204",
"0.7457726",
"0.7431133",
"0.7424... | 0.727765 | 87 |
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 name(self):\n return self.sensor.name",
"def name(self) -> str:\n return self._sensor.name",
"def sensor_name(self):\n return self._sensor_name",
"def name(self):\n return SENSOR_NAME",
"def name(self):\n return '{... | [
"0.9172938",
"0.9172938",
"0.9119264",
"0.90965885",
"0.8981336",
"0.85841",
"0.8511273",
"0.8511273",
"0.82223254",
"0.81386924",
"0.809015",
"0.79436237",
"0.77122",
"0.7700968",
"0.7556649",
"0.7541934",
"0.7540329",
"0.7538318",
"0.75381917",
"0.7537575",
"0.74322224",
... | 0.0 | -1 |
Return the polling state. | def should_poll(self):
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state(self):\n # Poll for the first request.\n if self._state == None:\n ev = self._query_waiters.request(self._do_query_state)\n ev.wait(1.0)\n return self._state",
"def is_polling(self):\n return self.__isPolling",
"def state(self):\n ev = self._query_waiters.request(self.__d... | [
"0.74456733",
"0.7330484",
"0.71339875",
"0.7058845",
"0.7037944",
"0.6999668",
"0.68968564",
"0.6809555",
"0.68076676",
"0.6775933",
"0.67729336",
"0.67729336",
"0.67729336",
"0.67729336",
"0.67729336",
"0.67291653",
"0.6724314",
"0.6641413",
"0.6641413",
"0.66395515",
"0.66... | 0.0 | -1 |
Return device specific state attributes. | def device_state_attributes(self):
return self._predictions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self):\n\t\treturn self._state_attributes",
"def device_state_attributes(self):\n\t\treturn self._attributes",
"def device_state_attributes(self):\r\n return self._attr",
"def device_state_attributes(self):\n... | [
"0.87130606",
"0.86939776",
"0.86756635",
"0.86663085",
"0.8589153",
"0.8589153",
"0.8508101",
"0.84891194",
"0.84891194",
"0.84891194",
"0.84891194",
"0.84891194",
"0.84891194",
"0.84891194",
"0.84891194",
"0.84891194",
"0.84891194",
"0.84891194",
"0.84891194",
"0.84891194",
... | 0.7289586 | 90 |
Returns a whether a path should be ignored or not. | def _ignore_path(cls, path, ignore_list=None, allowed_list=None):
ignore_list = ignore_list or []
allowed_list = allowed_list or []
return cls._matches_patterns(path, ignore_list) and not cls._matches_patterns(
path, allowed_list
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_path_ignored(self, path):\n if self.ignore_links and os.path.islink(path):\n return True\n for idir in self.ignore_paths:\n ipath = os.path.join(self.tree_base, idir)\n if ipath == path:\n return True\n return False",
"def _should_ignor... | [
"0.79434055",
"0.78744787",
"0.77518195",
"0.73422724",
"0.7302781",
"0.7282074",
"0.7257791",
"0.70232975",
"0.6966501",
"0.6888481",
"0.68461597",
"0.68188703",
"0.6809234",
"0.67771715",
"0.66619146",
"0.66426164",
"0.66305697",
"0.6630521",
"0.66128236",
"0.656864",
"0.65... | 0.73414755 | 4 |
Calculates the vertical distances from the samples to the model. | def distance(self, samples):
X = samples[:,0]
Y = samples[:,1]
k = self.params[0]
m = self.params[1]
dists = abs(k * X + m - Y)
return dists | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vertical_sweep(self):\n self.vclosest = []\n ic = 0\n for c in self.end_points:\n # find closest point to the right\n i = 0\n ix = -1\n min_distance = 10000.0\n for cn in self.end_points:\n delta = c - cn\n ... | [
"0.61749953",
"0.5730183",
"0.5729953",
"0.57037115",
"0.5597624",
"0.55915767",
"0.5588175",
"0.5576105",
"0.5459526",
"0.5453553",
"0.543847",
"0.54029423",
"0.5354997",
"0.5266893",
"0.5260026",
"0.52204114",
"0.52092195",
"0.5194506",
"0.5180546",
"0.5173935",
"0.5087103"... | 0.54476637 | 10 |
Check for API TOKEN is in Envrionment variable else in config file. Return if exists. Decide to keep or remove taking values from env. Other checks look for `creds` file. | def check_credential_file() -> Union[str, bool]:
if (cred := os.environ.get("AQITOKEN")) is not None:
return cred
elif os.path.exists(CREDS_FILE):
with open(CREDS_FILE) as cred:
return cred.readline().strip()
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_environment(self):\n # Setup credentials\n if os.getenv(\"DO_API_TOKEN\"):\n self.api_token = os.getenv(\"DO_API_TOKEN\")\n if os.getenv(\"DO_API_KEY\"):\n self.api_token = os.getenv(\"DO_API_KEY\")",
"def read_environment(self):\n # Setup credentials\n ... | [
"0.64047575",
"0.64047575",
"0.6108844",
"0.5954869",
"0.5907496",
"0.5861227",
"0.5860904",
"0.579643",
"0.5760951",
"0.57558674",
"0.57226264",
"0.5698525",
"0.5688913",
"0.56793314",
"0.564353",
"0.56320024",
"0.5631389",
"0.5617529",
"0.5588714",
"0.5579536",
"0.557439",
... | 0.5217388 | 57 |
Creates a mapping expanding the range(key) used for aqi values in AQI_INFO_MAPPING. Repeats the value for that range of keys. | def info_mapper():
data = {}
for range, info in AQI_INFO_MAPPING:
for index in range:
data[index] = info
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_range(chain_range_dic):\n chain_ranges = {}\n for chain in chain_range_dic:\n min_idx = min(chain_range_dic[chain])\n max_idx = max(chain_range_dic[chain])\n chain_ranges[chain] = (min_idx, max_idx)\n return chain_ranges",
"def get_mappings(self):\n mappings = [{\n ... | [
"0.5653295",
"0.5546356",
"0.55325854",
"0.54459256",
"0.5425509",
"0.5393971",
"0.53854424",
"0.5381519",
"0.5354411",
"0.5354411",
"0.5309353",
"0.5294317",
"0.52199584",
"0.5174134",
"0.51586545",
"0.5141988",
"0.5122902",
"0.5096014",
"0.5093262",
"0.5075379",
"0.5071673"... | 0.7763893 | 0 |
Return the version of this package as a string. | def get_version():
return '1.0.0' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_version(self):\n return str(self.version)",
"def version_string(self):\n _version_string_result = _str_dc(self._swigobj.version_string())\n return _version_string_result",
"def string(self) -> str:\n if self._version.endswith(\".\"):\n self._version = self._versi... | [
"0.86453295",
"0.8616935",
"0.8441032",
"0.84103364",
"0.8292053",
"0.8292053",
"0.82840866",
"0.82840866",
"0.82840866",
"0.8230265",
"0.81942683",
"0.8146824",
"0.8146824",
"0.8146824",
"0.8146824",
"0.8146824",
"0.8146824",
"0.81270003",
"0.80805814",
"0.80343944",
"0.7969... | 0.0 | -1 |
Return an argparse.ArgumentParser instance. | def get_parser():
description, _, epilog = __doc__.partition("\n")
parser = argparse.ArgumentParser(description=description,
epilog=epilog)
inctrl = parser.add_argument_group('input control')
inctrl.add_argument('-r', '--recursive', action='store_true',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_argument_parser():\n return argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)",
"def arg_parser():\n return argparse.ArgumentParser(\n formatter_class=argparse.ArgumentDefaultsHelpFormatter)",
"def arg_parser():\n import argparse\n return argparse... | [
"0.8199786",
"0.7924235",
"0.7650048",
"0.76065975",
"0.7492536",
"0.7458145",
"0.73155004",
"0.72714823",
"0.7257955",
"0.7252513",
"0.7234032",
"0.72339445",
"0.7188088",
"0.7102067",
"0.70517856",
"0.69987977",
"0.69861645",
"0.6972858",
"0.69655347",
"0.6948274",
"0.69347... | 0.0 | -1 |
Need to add user given parameters to yandexurl, so this takes them in, and URL encodes them to make them URL friendly, and returns a completed URL. >>> translation_params("This is a test", "enfr") text=This+is+a+test&lang=enfr | def translation_params(text: str, lang: str):
encode_dict = {"text": text, "lang": lang}
urlext = urllib.parse.urlencode(encode_dict)
return translateurl + urlext | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_add_parameters(url, params):\r\n if params:\r\n fragments = list(urlparse.urlparse(url))\r\n fragments[4] = urllib.urlencode(parse_qsl(fragments[4]) +\r\n params.items())\r\n url = urlparse.urlunparse(fragments)\r\n return url",
"def get_u... | [
"0.6335608",
"0.63178486",
"0.62969136",
"0.6124303",
"0.6092631",
"0.60474795",
"0.60441464",
"0.60377395",
"0.59338564",
"0.5798356",
"0.5784911",
"0.5770895",
"0.57542783",
"0.5752061",
"0.5745132",
"0.5729922",
"0.5694657",
"0.56540215",
"0.5643283",
"0.56397974",
"0.5628... | 0.8245914 | 0 |
Uses Yandex's dictionary to convert the shorthand form of language that Yandex returns into it's full name >>> longhand("en") English | def longhand(abbrev: str) -> str:
r = requests.get(langlisturl)
lang_dict = r.json()
return lang_dict['langs'][abbrev] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def english():\n\n return \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"",
"def ala_lc(word):\n ala_lc_dict = {\n 'Ё' : 'Ë',\n 'А' : 'A',\n 'Б' : 'B',\n 'В' : 'V',\n 'Г' : 'G',\n 'Д' : 'D',\n 'Е' : 'E',\n 'Ж' : 'Zh',\n 'З' : 'Z',\n 'И' : 'I',\n '... | [
"0.59073925",
"0.58566594",
"0.5742834",
"0.57401145",
"0.5698695",
"0.5657518",
"0.56368804",
"0.56226146",
"0.5548822",
"0.5534197",
"0.5516169",
"0.54903567",
"0.5472276",
"0.54033697",
"0.537643",
"0.53476137",
"0.53287226",
"0.5305937",
"0.5298308",
"0.52830577",
"0.5264... | 0.73672795 | 0 |
The sum of the squared losses (not average) Used for BFGS linear regression minimisation | def total_squared_loss(THETA, data):
return sum(generate_squared_losses(THETA, data)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def objective(self):\n self.update_sum_squares()\n return self.sum_squares",
"def compute_squared_loss(y, tx, w):\n \n # w use mse\n # in the theoretical part of the session we have derived that L(w) = 1/2N e'*e\n \n N = y.shape[0]\n e = y- np.dot(tx,w)\n \n return (1/2) * np... | [
"0.69935143",
"0.69238704",
"0.6814594",
"0.6713069",
"0.6616464",
"0.65816396",
"0.65579927",
"0.65476304",
"0.65419567",
"0.65141875",
"0.6505947",
"0.64987487",
"0.64586353",
"0.64525855",
"0.6437184",
"0.6437008",
"0.64259124",
"0.6418554",
"0.64134145",
"0.640118",
"0.63... | 0.7633198 | 0 |
Calculates the MSE using the given theta on the data | def calc_mse(data, THETA):
# get a list of the squared losses
squared_losses = generate_squared_losses(THETA, data)
# calculate the average squared loss from the list
return sum(squared_losses) / len(squared_losses) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MSE(self, y_hat, y):\n return np.mean((y_hat - y) ** 2)",
"def squared_error(theta):\n n, m = x_data.shape\n return np.linalg.norm(x_data.dot(theta) - y_data) ** 2",
"def d_squared_error(theta):\n return 2 * x_data.T.dot(x_data.dot(theta) - y_data)",
"def MSE(y, predictions):\n\n mse =... | [
"0.67928934",
"0.67150164",
"0.671491",
"0.6710503",
"0.66829294",
"0.6680098",
"0.6671129",
"0.66437924",
"0.6584287",
"0.65196174",
"0.64835346",
"0.6470359",
"0.6448706",
"0.6421488",
"0.641392",
"0.638985",
"0.6375302",
"0.6356629",
"0.6347754",
"0.6347451",
"0.63231975",... | 0.67119634 | 3 |
Calculates loss of regularised linear regression | def regularised_linear_loss(THETA, data, lamb):
complexity = 0
for theta in nditer(THETA):
complexity += abs(theta)
return (lamb * total_squared_loss(THETA, data)) + ((1 - lamb) * complexity) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss(self, *args):\n theta,X,y,reg = args\n m,dim = X.shape\n J = 0\n\n ##########################################################################\n # Compute the loss function for regularized logistic regression #\n # TODO: 1-2 lines of code expected ... | [
"0.7347045",
"0.7210524",
"0.71209985",
"0.70902205",
"0.7073829",
"0.7046176",
"0.70369637",
"0.7027659",
"0.7025813",
"0.7002427",
"0.69876665",
"0.6984049",
"0.6971293",
"0.69577605",
"0.69348645",
"0.69090503",
"0.69078606",
"0.68945783",
"0.6883202",
"0.68692833",
"0.686... | 0.7010778 | 9 |
Log_sum_exp trick as described in the slides. Parameter XTHETA is the dot product of X and THETA where X is the vector of expanded features | def log_sum_exp(XTHETA):
max = XTHETA[0,0]
for elem in nditer(XTHETA):
if elem > max:
max = elem
sum = 0
for elem in nditer(XTHETA):
sum += exp(elem - max)
return (max + log(sum)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_sum_exp(x):\r\n # TF ordering\r\n axis = len(x.size()) - 1\r\n m, _ = torch.max(x, dim=axis)\r\n m2, _ = torch.max(x, dim=axis, keepdim=True)\r\n return m + torch.log(torch.sum(torch.exp(x - m2), dim=axis))",
"def log_sum_exp(x):\n # TF ordering\n axis = len(x.size()) - 1\n m, _ =... | [
"0.8039108",
"0.80200905",
"0.77644217",
"0.7740747",
"0.7737092",
"0.76301444",
"0.7614457",
"0.73834854",
"0.73834854",
"0.7319836",
"0.7296172",
"0.7284523",
"0.70543146",
"0.70384526",
"0.70161974",
"0.70017505",
"0.6991689",
"0.69418335",
"0.6937272",
"0.6906958",
"0.689... | 0.8058024 | 0 |
L{PeerIndex.get} automatically strips trailing whitespace from a username, since passing a username with trailing whitespace to the API can result in strange behaviour. For example, at the time of this writing, a username with a trailing newline will result in an HTTP 200 status code with HTML representing a 404 as the... | def testGetStripsTrailingWhitespaceInUsername(self):
client = FakeHTTPClient()
headers = {'status': '200', 'x-ratelimit-remaining': '9998',
'content-location': 'http://api.peerindex.net/...',
'-content-encoding': 'gzip', 'transfer-encoding': 'chunked',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testGetStripsLeadingAtSignInUsername(self):\n client = FakeHTTPClient()\n headers = {'status': '200', 'x-ratelimit-remaining': '9998',\n 'content-location': 'http://api.peerindex.net/...',\n '-content-encoding': 'gzip', 'transfer-encoding': 'chunked',\n ... | [
"0.69553024",
"0.6190726",
"0.6000362",
"0.5968451",
"0.59630686",
"0.5760434",
"0.5708496",
"0.5634277",
"0.56258136",
"0.5614985",
"0.5609073",
"0.55981994",
"0.5589802",
"0.5589802",
"0.5589802",
"0.5589802",
"0.5589802",
"0.5589802",
"0.5587619",
"0.55764353",
"0.55642307... | 0.76621175 | 0 |
Return header value from request if provided, otherwise None. | def extract(self, request: Request) -> Optional[str]:
try:
return request.headers[self.header]
except:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_header(self, header):\n return self._headers.get(header)",
"def get_header(self, key='', default_value=u''):\n from inflector import titleize\n key = '-'.join(titleize(key).split(' '))\n if key is '':\n return default_value\n try:\n if key not in self.... | [
"0.7591218",
"0.75654495",
"0.7511718",
"0.7427926",
"0.73024213",
"0.72471964",
"0.7219044",
"0.7219044",
"0.71893525",
"0.706719",
"0.6926473",
"0.6867085",
"0.6862913",
"0.68321025",
"0.68315256",
"0.677536",
"0.67742044",
"0.6737989",
"0.6734853",
"0.6729322",
"0.65101546... | 0.8094159 | 0 |
Return the type of the request body for the specified operation. | def get_body_type(operation):
signature = inspect.signature(operation)
type_hints = typing.get_type_hints(operation, include_extras=True)
as_body_param = None
in_body_params = {}
required_keys = set()
for name, hint in type_hints.items():
if name == "return":
continue
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def op_type(self) -> str:\n if isinstance(self._node, NodeProto):\n return self._node.op_type\n if isinstance(self._node, ValueInfoProto):\n return INPUT_TYPE\n else:\n return INIT_TYPE",
"def _define_operation_type(self) -> str:\n\n # Get available mo... | [
"0.6226361",
"0.60972494",
"0.6080429",
"0.5954957",
"0.5817272",
"0.5771138",
"0.570952",
"0.5707713",
"0.5634146",
"0.55753726",
"0.55753726",
"0.5522239",
"0.54882675",
"0.5485922",
"0.5474265",
"0.5411421",
"0.52463406",
"0.52101105",
"0.5203796",
"0.5203796",
"0.5170817"... | 0.7860228 | 0 |
Reshapes a >= rank 2 tensor to a rank 2 tensor (i.e., a matrix). | def reshape_to_matrix(input_tensor):
ndims = input_tensor.shape.ndims
if ndims < 2:
raise ValueError("Input tensor must have at least rank 2. Shape = %s" %
(input_tensor.shape))
if ndims == 2:
return input_tensor
width = input_tensor.shape[-1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reshape_to_matrix(input_tensor):\n \"\"\"把一个rank >= 2的tensor变成一个rank为2的矩阵\"\"\"\n ndims = input_tensor.shape.ndims\n if ndims < 2:\n raise ValueError(\"Input tensor must have at least rank 2. Shape = %s\" %\n (input_tensor.shape))\n if ndims == 2:\n return input_tensor\n\n width ... | [
"0.8056062",
"0.7719459",
"0.76339686",
"0.75891525",
"0.7577096",
"0.7507519",
"0.72042274",
"0.71878314",
"0.71878314",
"0.71363693",
"0.70127475",
"0.6995799",
"0.69731414",
"0.6626832",
"0.6601237",
"0.6557156",
"0.65529305",
"0.65057254",
"0.64744866",
"0.64299166",
"0.6... | 0.75013775 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.