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 true if a given element is in the linked list; false otherwise True or False ValueError if the element is None | def contains(self, element):
if element is None:
raise ValueError
else:
cur = self.head
while cur is not None:
if cur.element is element:
return True
cur = cur.next
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __contains__(self: 'LinkedList', elem: 'object') -> bool:\r\n current = self.first\r\n while current.ref is not None:\r\n if current.value == elem:\r\n return True\r\n current = current.ref\r\n return False",
"def member(el, inlist): \n if(el in in... | [
"0.76936215",
"0.71897286",
"0.7166481",
"0.7140809",
"0.7052064",
"0.7051542",
"0.678054",
"0.6775837",
"0.6744603",
"0.66861653",
"0.66861653",
"0.6679296",
"0.6644778",
"0.66188437",
"0.6551587",
"0.63778186",
"0.63655204",
"0.6363733",
"0.63589734",
"0.6358096",
"0.635488... | 0.8268603 | 0 |
The timestamp when this Product becomes available for recommendation. | def available_time(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "available_time") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_start_time(self):\n for element in self._product_metadata.iter(\"Product_Info\"):\n return element.find(\"PRODUCT_START_TIME\").text",
"def generation_time(self):\n for element in self._product_metadata.iter(\"Product_Info\"):\n return element.findtext(\"GENERATION... | [
"0.6645048",
"0.6474386",
"0.6326228",
"0.6326228",
"0.6326228",
"0.6326228",
"0.6326228",
"0.6326228",
"0.6326228",
"0.63231164",
"0.63231164",
"0.6267625",
"0.62111545",
"0.61584955",
"0.6146718",
"0.6112572",
"0.60324043",
"0.6029529",
"0.6006811",
"0.5972303",
"0.5972303"... | 0.5860943 | 27 |
Immutable. The type of the product. This field is outputonly. Default to Catalog.product_level_config.ingestion_product_type if unset. | def type(self) -> Optional[pulumi.Input['ProductType']]:
return pulumi.get(self, "type") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_type(self):\n return self._product_type",
"def type(self) -> str:\n return self._prod_type",
"def type(self) -> str:\n return self._prod_type",
"def product_type_code(self):\n return self._product_type_code",
"def product_type(self):\n for element in self._pro... | [
"0.8263139",
"0.7828053",
"0.7828053",
"0.7483793",
"0.73726726",
"0.72932804",
"0.7257336",
"0.7080504",
"0.67811024",
"0.66702676",
"0.66358215",
"0.6493603",
"0.6493603",
"0.6493603",
"0.6493603",
"0.6493603",
"0.6493603",
"0.6493603",
"0.6493603",
"0.6493603",
"0.6493603"... | 0.8205113 | 1 |
The timestamp when this Product becomes available for recommendation. | def available_time(self) -> pulumi.Output[str]:
return pulumi.get(self, "available_time") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_start_time(self):\n for element in self._product_metadata.iter(\"Product_Info\"):\n return element.find(\"PRODUCT_START_TIME\").text",
"def generation_time(self):\n for element in self._product_metadata.iter(\"Product_Info\"):\n return element.findtext(\"GENERATION... | [
"0.6645048",
"0.6474386",
"0.6326228",
"0.6326228",
"0.6326228",
"0.6326228",
"0.6326228",
"0.6326228",
"0.6326228",
"0.63231164",
"0.63231164",
"0.6267625",
"0.62111545",
"0.61584955",
"0.6146718",
"0.6112572",
"0.60324043",
"0.6006811",
"0.5972303",
"0.5972303",
"0.5963641"... | 0.6029529 | 17 |
Immutable. The type of the product. This field is outputonly. Default to Catalog.product_level_config.ingestion_product_type if unset. | def type(self) -> pulumi.Output[str]:
return pulumi.get(self, "type") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_type(self):\n return self._product_type",
"def type(self) -> Optional[pulumi.Input['ProductType']]:\n return pulumi.get(self, \"type\")",
"def type(self) -> str:\n return self._prod_type",
"def type(self) -> str:\n return self._prod_type",
"def product_type_code(self... | [
"0.8264306",
"0.8206427",
"0.78283226",
"0.78283226",
"0.748483",
"0.73741645",
"0.7294367",
"0.72587144",
"0.70816076",
"0.67819256",
"0.6671513",
"0.66356677",
"0.6488536",
"0.6453491",
"0.6280278",
"0.6268222",
"0.6257381",
"0.6257381",
"0.6257381",
"0.6257381",
"0.6257381... | 0.64935714 | 24 |
Get a random colour target. | def get_random_target():
targets = ColourTarget.query.all()
return random.choice(targets) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_color():\n return Game.COLORS[random.randint(0, len(Game.COLORS) - 1)][0]",
"def random_color():\n global random_color_hold\n random_color_hold = random.choice(colors)\n return random_color_hold",
"def _rand_color(self):\n\n return self._rand_elem(COLOR_NAMES)",
"def random_... | [
"0.7668297",
"0.73022056",
"0.7199167",
"0.71791244",
"0.71613634",
"0.7141905",
"0.7097308",
"0.69178444",
"0.68535125",
"0.67943656",
"0.67402536",
"0.67368734",
"0.6727303",
"0.6713809",
"0.6702442",
"0.6672843",
"0.6659111",
"0.66552883",
"0.6648444",
"0.65648556",
"0.650... | 0.8418386 | 0 |
This function loads the json file into a dictionary | def load_json(file_loc):
with open(file_loc, 'r') as fin:
config = json.load(fin)
return config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_to_dict(file_name):\n\twith open(file_name) as json_data:\n\t\treturn json.load(json_data)",
"def load_dict_from_json_file (file_name):\n with open(file_name, \"r\") as json_file:\n return json.load(json_file)",
"def json_dict(path):\n json_file=open(path)\n json_str = json_file.read()... | [
"0.8044083",
"0.80023634",
"0.7907206",
"0.7907206",
"0.77230686",
"0.77108544",
"0.7682374",
"0.7672621",
"0.76708287",
"0.766161",
"0.7655626",
"0.7642564",
"0.763527",
"0.7634147",
"0.76283765",
"0.76261204",
"0.76216114",
"0.7597479",
"0.75895375",
"0.7586415",
"0.7520054... | 0.0 | -1 |
Returns true if a pkt is a beacon frame for the given SSID, false otherwise. | def ssid_filter(ssid: str, pkt: Packet) -> bool:
if not pkt.haslayer(Dot11Beacon):
return False
layer = pkt.getlayer(Dot11Elt)
while layer is not None and layer.ID != 0:
layer = layer.getlayer(Dot11Elt, 2)
if layer is not None:
return layer.info.decode() == ssid
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_beacon(call):\n\n if call.upper() in beacon_address:\n return 1\n else:\n return 0",
"def check_connection(self, network_bssid):\n time.sleep(40) #time for connection state to be updated\n self.log.info(\"Check network for {}\".format(network_bssid))\n current_net... | [
"0.6188241",
"0.5448876",
"0.54434526",
"0.5407858",
"0.53287417",
"0.53271013",
"0.52913135",
"0.52913135",
"0.52754074",
"0.5238502",
"0.5226646",
"0.509944",
"0.50982493",
"0.50933206",
"0.5076666",
"0.5043768",
"0.503765",
"0.49521452",
"0.4929463",
"0.49280792",
"0.48756... | 0.7469764 | 0 |
Creates and saves a User with the given username, email and password. | def _create_user(self, **kargs):
self.create_roles()
if 'username' not in kargs:
raise ValueError('The given username must be set')
role = kargs.pop('role', 2)
password = kargs.pop('password', '12345')
#email_address = self.normalize_email(kargs['email_address'])
... | {
"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 cr... | [
"0.85182536",
"0.84783906",
"0.8407149",
"0.840616",
"0.840616",
"0.8398672",
"0.83922565",
"0.839183",
"0.839183",
"0.839183",
"0.839183",
"0.8347033",
"0.8322837",
"0.8283844",
"0.82814354",
"0.82584244",
"0.8233358",
"0.82262945",
"0.8220019",
"0.8214565",
"0.8205882",
"... | 0.0 | -1 |
Make out of hour and minute a readable text. | def get_text_time(hour, minute):
# Build the "key". Take care abut the pre-leading zeros for the hours and minutes.
hour = hour%24 # Use modulo to accept mistaken inputs above 23 hours.
minute = minute%60 # Use modulo to accept mistaken inputs above 59 minutes.
minute = minute - minute%5 # This e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n if self.hour > 12:\n hour_string = str(self.hour - 12)\n else:\n hour_string = str(self.hour)\n\n if self.minute < 10:\n minute_string = \"0\" + str(self.minute)\n else:\n minute_string = str(self.minute)\n\n return... | [
"0.75496835",
"0.7037292",
"0.7027869",
"0.6996345",
"0.69934505",
"0.6868956",
"0.6865633",
"0.68470335",
"0.68115026",
"0.6803295",
"0.67826724",
"0.6782175",
"0.6771917",
"0.6747793",
"0.67446077",
"0.67055565",
"0.6693141",
"0.6687255",
"0.66737306",
"0.6671616",
"0.66587... | 0.7100594 | 1 |
Creates a `truncated_normal_initializer` with the given range. | def create_initializer(initializer_range=0.02):
return tf.truncated_normal_initializer(stddev=initializer_range) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_initializer(initializer_range=0.02):\n return tf.truncated_normal_initializer(stddev=initializer_range)",
"def create_initializer(initializer_range=0.02):\n return tf.truncated_normal_initializer(stddev=initializer_range)",
"def create_initializer(initializer_range=0.02):\r\n return tf.truncated... | [
"0.8152708",
"0.8152708",
"0.81492186",
"0.80477655",
"0.6936349",
"0.66252977",
"0.62793905",
"0.62135834",
"0.6205201",
"0.61933607",
"0.6108912",
"0.6001189",
"0.59569645",
"0.5804507",
"0.5753272",
"0.57244396",
"0.57005537",
"0.5670215",
"0.5633056",
"0.56200624",
"0.561... | 0.8173978 | 0 |
Convert FLUXCAL to magnitudes. | def conv_flux_mag(self, flux, zpt=27.5):
mag = [zpt - 2.5 * np.log10(f) if f > 1e-5 else 9999 for f in flux]
return np.array(mag) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flux_to_mag( self, flux ):\n\n\t\treturn -2.5*np.log10( np.abs( flux ) ) + self.zeropoint",
"def flux_to_magnitude(cube):\n orig_units = str(cube.units)\n assert ('W' in orig_units) or ('s-1' in orig_units)\n\n dim_coord_names = [coord.name() for coord in cube.dim_coords]\n if 'year' in dim_coord... | [
"0.66396093",
"0.630753",
"0.62638396",
"0.6253509",
"0.61211455",
"0.6112601",
"0.6046616",
"0.59827137",
"0.5939005",
"0.5888774",
"0.5849158",
"0.5783108",
"0.5754662",
"0.5729232",
"0.57159287",
"0.5715427",
"0.566205",
"0.566028",
"0.5651296",
"0.5602937",
"0.5581957",
... | 0.6196654 | 4 |
test for collision type of a tile position | def collide(self, tile_pos):
type = self.get_tile_type(tile_pos[0], tile_pos[1]) #get tile type
if type != settings.TILE_NORMAL: #if it's not a normal tile
return True #this is a collison
return False #otherwise, we're fine | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tile_type(self, tile_x, tile_y, player_req=False):\n if tile_y < 0 or tile_x < 0: #if the tile is negative\n return -1 #it shouldn't exist\n try: #test if there's an object in the given position\n t = self.pos2obj[(tile_x, tile_y)] #get object\n if t != self.p... | [
"0.67387366",
"0.66724545",
"0.6641744",
"0.66010505",
"0.65935147",
"0.65322137",
"0.6504219",
"0.643829",
"0.64247215",
"0.64237946",
"0.64236236",
"0.63736373",
"0.6372484",
"0.6371648",
"0.63652754",
"0.633481",
"0.6329737",
"0.63255703",
"0.63198584",
"0.63184494",
"0.63... | 0.7847106 | 0 |
Compute density based on input data and number of bins. | def density(self, X, bins='auto', mhist='numpy'):
if mhist=='numpy':
histvals, binedges = np.histogram(X, bins=bins, density=True)
binedges = (binedges + np.roll(binedges, -1))[:-1] / 2.0
# binedges[-1] += 10**-6
else:
import seaborn as sns
sns... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _estimate_density(self, x):\n\n self.density_, self.bins_ = np.histogram(x, bins=10, density=True)",
"def densityDistribution(data, binNumber = 100, rmax = 15.):\n rho_3d = np.zeros((binNumber,binNumber,binNumber))\n w_3d = np.zeros((binNumber,binNumber,binNumber))\n rho_xz = np.zeros((binNum... | [
"0.6917822",
"0.6662804",
"0.6608354",
"0.6608354",
"0.6608354",
"0.64963",
"0.6471735",
"0.63592225",
"0.6337329",
"0.6324082",
"0.6305022",
"0.6268923",
"0.6215989",
"0.6188155",
"0.60600483",
"0.60580903",
"0.60580903",
"0.60580903",
"0.6056194",
"0.6033242",
"0.60228866",... | 0.7108136 | 0 |
r"""Compute weights vector from the binomial distribution. | def binomial_weights(
outcome_data: List[np.ndarray],
shot_data: np.ndarray,
num_outcomes: Optional[np.ndarray] = None,
beta: float = 0,
) -> np.ndarray:
num_data = len(outcome_data)
if num_outcomes is None:
num_outcomes = 2 * np.ones(num_data, dtype=int)
# Get leading dimension of r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_weights(self, x):\n return 1.0",
"def weights(self):\n return np.array(self._weights)",
"def __inti_weight__(self,num_input):\n weights=[]\n for counter in range(num_input):\n weights.append(random.randint(0,1))\n weights=np.array(weights)\n weights=... | [
"0.67052805",
"0.658221",
"0.65495366",
"0.6536255",
"0.6456165",
"0.6374216",
"0.63723534",
"0.63723534",
"0.6332809",
"0.63015425",
"0.6293631",
"0.62880987",
"0.62822956",
"0.6268933",
"0.6268933",
"0.6268933",
"0.6266404",
"0.62533605",
"0.6234121",
"0.6225974",
"0.620919... | 0.62384605 | 18 |
Find the closing fragment for every fragment. Returns numpy.array With as many elements as fragments. If the fragment has no closing pair then the array contains 1 at that position otherwise it contains the index of the closing pair | def match_fragments(fragments, max_backtrack=20):
match = np.repeat(-1, len(fragments))
stack = []
for i, fragment in enumerate(fragments):
if isinstance(fragment, hp.HtmlTag):
if fragment.tag_type == hp.HtmlTagType.OPEN_TAG:
stack.append((i, fragment))
elif (... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fragment_index(self, tree_index):\n return np.where(\n tree_index > 0, self.index[tree_index], -1)",
"def test_closing():\n arr = numpy.zeros((11, 11))\n # a 5x5 patch\n arr[4:9, 4:9] = 255\n # with a hole in the middle\n arr[6, 6] = 0\n\n parameters = {'data': [arr], 'siz... | [
"0.5098128",
"0.50836116",
"0.5036957",
"0.5014677",
"0.49851274",
"0.49504933",
"0.49132887",
"0.48836336",
"0.48831025",
"0.486101",
"0.483035",
"0.48145714",
"0.48145714",
"0.48145714",
"0.4811261",
"0.4805471",
"0.47983998",
"0.4786459",
"0.47757062",
"0.4765508",
"0.4754... | 0.61142516 | 0 |
A list of paths going upwards that start at a descendant of 'i' and end at a 'i' | def prefixes_at(self, i):
paths = []
for j in range(i, max(i+1, self.match[i])):
paths.append(self.prefix(j, i))
return paths | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yield_paths_from_i(self, i):\n path = [i] # path traversed so far\n seen = {i} # set of vertices in path\n yield path\n\n def search():\n for neighbour in self.downstream_nodes[path[-1]]:\n if neighbour not in seen:\n ... | [
"0.72378033",
"0.7121729",
"0.6453158",
"0.6384865",
"0.63807625",
"0.63448864",
"0.63329655",
"0.63329655",
"0.63329655",
"0.63329655",
"0.6283783",
"0.6280684",
"0.623899",
"0.62205374",
"0.6146196",
"0.6120361",
"0.6092298",
"0.60907495",
"0.60889626",
"0.6038441",
"0.6024... | 0.6260319 | 12 |
Evaluates the BSpline curve at the given u parameter. | def curvept(self, u=-1, check_vars=True, get_ctrlpts=False):
if check_vars:
# Check all parameters are set before the curve evaluation
self._check_variables()
# Check u parameters are correct
utils.check_uv(u)
# Initialize an empty list which will contain... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_single_true(self, u):\r\n x = 4*u - 2. # [-2, 2]\r\n # for i in range(self._dim):\r\n # x[i] = 4 * x[i] - 2. \r\n value = 0.0\r\n for i in range(self._dim-1):\r\n value += pow(1. - x[i], 2.0) + 100. * pow(x[i+1] - pow(x[i], 2.0), 2.0)\r\n resul... | [
"0.6417941",
"0.6413457",
"0.6159899",
"0.60604197",
"0.5987915",
"0.5969625",
"0.59608173",
"0.59587556",
"0.59096026",
"0.5894991",
"0.5809456",
"0.5807705",
"0.5807705",
"0.58030033",
"0.5752698",
"0.5716886",
"0.56871885",
"0.5677411",
"0.56393844",
"0.5630736",
"0.562515... | 0.0 | -1 |
Computes the control points of all derivative curves up to and including the {degree}th derivative. Implements Algorithm A3.3. Output is PK[k][i], ith control point of the kth derivative curve where 0 <= k <= degree and r1 <= i <= r2k | def derivatives_ctrlpts(self, order=0, r1=0, r2=0):
# Algorithm A3.3
r = r2 - r1
PK = [[[None for x in range(self._dimension)] for y in range(r + 1)] for z in range(order + 1)]
for i in range(0, r + 1):
PK[0][i][:] = [elem for elem in self._control_points[r1 + i]]
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derivatives_ctrlpts(**kwargs):\n # r1 - minimum span, r2 - maximum span\n r1 = kwargs.get('r1')\n r2 = kwargs.get('r2')\n deriv_order = kwargs.get('deriv_order')\n degree = kwargs.get('degree')\n knot_vector = kwargs.get('knotvector')\n control_points = kwargs.g... | [
"0.77285856",
"0.68266946",
"0.66162336",
"0.6499196",
"0.58447427",
"0.5817954",
"0.57505304",
"0.5726683",
"0.56471235",
"0.56142884",
"0.55508626",
"0.5523903",
"0.5496124",
"0.5460003",
"0.54507834",
"0.5422179",
"0.5389895",
"0.5379957",
"0.53649986",
"0.53486615",
"0.53... | 0.7573001 | 1 |
Gets the size of the control points array in Udirection. | def ctrlpts_size_u(self):
return self._control_points_size_u | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ctrlpts_size_v(self):\n return self._control_points_size_v",
"def npoints(self):\n return self.data.y.size",
"def get_length(self):\n\n return len(self.points)",
"def get_size(self, py_array):\r\n\r\n return len(t_funcs.flatten(py_array))",
"def __len__(self):\n nx, n... | [
"0.70451766",
"0.68318427",
"0.67988753",
"0.6683078",
"0.6661783",
"0.6612808",
"0.6533654",
"0.6528533",
"0.6509515",
"0.6493321",
"0.64773077",
"0.6459765",
"0.6440237",
"0.64398015",
"0.6427727",
"0.64228064",
"0.6420852",
"0.63999385",
"0.63959444",
"0.63832444",
"0.6371... | 0.77503276 | 0 |
Gets the size of the control points array in Vdirection. | def ctrlpts_size_v(self):
return self._control_points_size_v | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def v_size(self) -> int:\n return self.numVertices",
"def v_size(self) -> int:\n return len(self._vertexes)",
"def vec_size(self):\n return self._parms.get(\"vec_size\")",
"def ctrlpts_size_u(self):\n return self._control_points_size_u",
"def dim(v):\n return len(v)",
"def ... | [
"0.72564334",
"0.70698774",
"0.68753165",
"0.6874859",
"0.6749346",
"0.66746616",
"0.6579615",
"0.65246177",
"0.6490571",
"0.64739907",
"0.64407825",
"0.64399695",
"0.6403437",
"0.6403435",
"0.6363952",
"0.6326457",
"0.63049257",
"0.62874967",
"0.62874967",
"0.6271355",
"0.62... | 0.78943807 | 0 |
Knot vector for U direction. | def knotvector_u(self):
return tuple(self._knot_vector_u) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def knotvector_v(self):\n return tuple(self._knot_vector_v)",
"def insert_knot_u(self, **kwargs):\n # Call parent method\n super(SurfaceEvaluator, self).insert_knot_u(**kwargs)\n\n u = kwargs.get('knot')\n r = kwargs.get('r')\n s = kwargs.get('s')\n degree = kwarg... | [
"0.6861173",
"0.6704381",
"0.66093886",
"0.64302987",
"0.636691",
"0.62695926",
"0.61144614",
"0.6107713",
"0.60673743",
"0.60477406",
"0.6041296",
"0.59923637",
"0.5971199",
"0.5933093",
"0.5917083",
"0.5904654",
"0.5890504",
"0.58903253",
"0.587835",
"0.5868937",
"0.5864306... | 0.756765 | 0 |
Returns a valid local hostname. When importing a local cluster the hostname provided will be in format clovrxxxxxxx and the proper hostname will need to be parsed out to avoid errors when making remote calls to the cluster. | def _formatLocalHostname(cluster):
master = cluster.get('master')
if master and 'clovr-' in master['public_dns']:
master['public_dns'] = master['public_dns'].replace('clovr-', '').replace('-', '.')
master['private_dns'] = master['private_dns'].replace('clovr-', '').replace('-', '.')
cluste... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_hostname(self):\n return self.m_iface.local_hostname()",
"def get_hostname():\n\treturn socket.gethostname().split('.',1)[0]",
"def getHostname():\n try:\n if rqd.rqconstants.OVERRIDE_HOSTNAME:\n return rqd.rqconstants.OVERRIDE_HOSTNAME\n if rqd.rqconstants.RQD_USE_... | [
"0.7581982",
"0.71946794",
"0.71776175",
"0.71287024",
"0.7123",
"0.7095279",
"0.69633365",
"0.6918883",
"0.6913115",
"0.68482137",
"0.68316907",
"0.66655874",
"0.6665165",
"0.6653735",
"0.6624168",
"0.6597809",
"0.6597421",
"0.6593486",
"0.65527517",
"0.6550911",
"0.654671",... | 0.74793327 | 1 |
This is a slightly modified version of _linear used by Tensorflow rnn. The only change is that we have allowed bias_start=None. | def linear(args, output_size, bias, bias_start=None, scope=None):
if args is None or (nest.is_sequence(args) and not args):
raise ValueError("`args` must be specified")
if not nest.is_sequence(args):
args = [args]
# Calculate the total size of arguments on dimension 1.
total_arg_size = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def super_linear(x,\n output_size,\n scope=None,\n reuse=False,\n init_w='gaussian',\n weight_start=0.001,\n use_bias=True,\n bias_start=0.0,\n input_size=None):\n shape = x.get_shape().... | [
"0.69506925",
"0.69290024",
"0.68423873",
"0.68196267",
"0.679468",
"0.6700992",
"0.66832936",
"0.6634057",
"0.66117907",
"0.6602305",
"0.65814793",
"0.6574615",
"0.6568927",
"0.65194154",
"0.64818317",
"0.6435983",
"0.6422115",
"0.6421445",
"0.64104635",
"0.6368832",
"0.6347... | 0.649625 | 14 |
Gets phrase Series from key DataFrame | None > pd.Series | def get_phrase_series():
return db.index | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_phrase_series(self):\n return self.db.index",
"def text():\n test = [\"This is four words\",\n \"This one is five words\"]\n\n return pd.Series(test)",
"def get_phrase_list(key_list):\n try:\n index = db.loc[db[key_list].all(axis=1), :].index\n return list(index... | [
"0.6100029",
"0.5771086",
"0.56091046",
"0.54742277",
"0.54618317",
"0.54482067",
"0.5439559",
"0.5421383",
"0.51984954",
"0.5180723",
"0.51682496",
"0.5148477",
"0.5147514",
"0.5133289",
"0.51236844",
"0.51204646",
"0.5113602",
"0.50975627",
"0.50834125",
"0.50583565",
"0.50... | 0.64125437 | 0 |
Get list of valid phrases for a list of keys | list(str) > list(str) | def get_phrase_list(key_list):
try:
index = db.loc[db[key_list].all(axis=1), :].index
return list(index.values)
except KeyError:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_dict_page(pagetext_list, keyslist):\n \n filteredtext = [] # Initialize empty list to hold strings of page\n \n for string in pagetext_list:\n lowercasestring = str(string).lower() # lower-case string...\n dict_list = [key.lower() for key in list(keyslist)] # ...compared with l... | [
"0.65964586",
"0.63134706",
"0.6275132",
"0.6148095",
"0.6133871",
"0.60490453",
"0.6045968",
"0.5992449",
"0.5973059",
"0.59509605",
"0.59381616",
"0.59340215",
"0.5910371",
"0.59070665",
"0.589152",
"0.5873764",
"0.5841258",
"0.58146745",
"0.5814615",
"0.58018863",
"0.57961... | 0.6690686 | 0 |
Generator function that partitions the input data_str (a big string) into chunks of nlines. | def partition(data_str, nlines):
lines = data_str.split('\n')
for i in xrange(0, len(lines), nlines):
yield '\n'.join(lines[i:i+nlines]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(string, n):\n for start in range(0, len(string), n):\n yield string[start:start + n]",
"def chunks(self,s, n):\n for start in range(0, len(s), n):\n yield s[start:start+n]",
"def chunks(s, n):\n for start in range(0, len(s), n):\n yield s[start:start + n... | [
"0.76165974",
"0.7194953",
"0.7115047",
"0.68384546",
"0.67697674",
"0.67653364",
"0.67650473",
"0.67618334",
"0.66097546",
"0.660475",
"0.6602087",
"0.6602087",
"0.65730995",
"0.6554677",
"0.653143",
"0.65047556",
"0.65047556",
"0.65047556",
"0.65047556",
"0.65047556",
"0.65... | 0.8776361 | 0 |
Inverted Residual Block This function defines a sequence of 1 or more identical layers. Arguments | def _inverted_residual_block(inputs, filters, kernel, t, alpha, strides, n):
x = _bottleneck(inputs, filters, kernel, t, alpha, strides)
for i in range(1, n):
x = _bottleneck(x, filters, kernel, t, alpha, 1, True)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inverted_residual_block(self):\n block = []\n # pad = 1 if self.s == 3 else 0\n # conv 1*1\n block.append(nn.Conv2d(self.in_, self.in_*self.t, 1, bias=False))\n block.append(nn.BatchNorm2d(self.in_*self.t))\n block.append(nn.ReLU6())\n\n # conv 3*3 depthwise\n ... | [
"0.71603286",
"0.66664356",
"0.62089604",
"0.6192982",
"0.61896926",
"0.61766887",
"0.6134086",
"0.5932372",
"0.59105635",
"0.59086627",
"0.5905549",
"0.5809555",
"0.5801442",
"0.57884777",
"0.57875866",
"0.5768704",
"0.57652074",
"0.5721819",
"0.5708257",
"0.57067126",
"0.57... | 0.63711435 | 2 |
Tests if no messages sent if no user uses standup_send during the time given. | def test_standup_start_empty():
user = auth.auth_register("email@email.com", "password", "Solid", "Snake")
channel_dict = channels.channels_create(user['token'], "test_channel", False)
# Send a message so that a call of channel_messages does not raise an InputError
message.message_send(user['token'], ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ok_to_send(self):\n dow = datetime.today().weekday()\n nw = datetime.now()\n t = float((nw.hour * 60) + nw.minute)\n\n if self.sent:\n return False\n return (self.agreeable_day(dow) and\n self.within_workday(t))",
"def check_time():\n if (time.t... | [
"0.6721126",
"0.6676999",
"0.64274114",
"0.63941914",
"0.6056585",
"0.6029714",
"0.59819824",
"0.59195703",
"0.5907286",
"0.5891176",
"0.58735764",
"0.5849887",
"0.56765044",
"0.5644396",
"0.5623759",
"0.56152743",
"0.5590951",
"0.5590564",
"0.5580151",
"0.5580091",
"0.555994... | 0.5510753 | 31 |
Tests if standup_send raises an InputError if channel_id given is invalid. | def test_standup_send_nvid():
user = auth.auth_register("email@email.com", "password", "Cat'n", "America")
channel_dict = channels.channels_create(user['token'], "test_channel", False)
standup.standup_start(user['token'], channel_dict['channel_id'], 1)
with pytest.raises(error.InputError):
st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_standup_send_invalid_channel():\n # Clear data and extract token\n requests.delete(url + \"/clear/v1\")\n authorised_info = requests.post(url + \"/auth/register/v2\", json = {\n 'email': 'unswstudent@gmail.com',\n 'password': 'kensington',\n 'name_first': 'unsw',\n 'na... | [
"0.66687644",
"0.6110957",
"0.6049799",
"0.58927125",
"0.5885895",
"0.5535428",
"0.55263865",
"0.54824567",
"0.5456764",
"0.5451003",
"0.5447669",
"0.5397407",
"0.5272516",
"0.524269",
"0.5228575",
"0.52153224",
"0.5212476",
"0.52073884",
"0.52016646",
"0.5162881",
"0.5160191... | 0.6015773 | 3 |
Tests if standup_send raises an AccessError if the token given is invalid. | def test_standup_send_nvt():
user = auth.auth_register("email@email.com", "password", "Peppa", "Pig")
channel_dict = channels.channels_create(user['token'], "test_channel", False)
standup.standup_start(user['token'], channel_dict['channel_id'], 1)
with pytest.raises(error.AccessError):
standu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_m_send_for_valied_token():\n with pytest.raises(AccessError):\n message_send(\"notatoken\", -1, \"test\")",
"def test_valid_token(self):\n response = self.call(self.url, {'appId': self.app.get_token()})\n self.assertNotEqual(response.status_code, 404)",
"def test_standup_send_i... | [
"0.684322",
"0.63391405",
"0.6329886",
"0.61682326",
"0.61637014",
"0.6075142",
"0.6023873",
"0.6010755",
"0.59912646",
"0.59909135",
"0.5954917",
"0.5944105",
"0.59408885",
"0.59332883",
"0.5895825",
"0.587332",
"0.58225554",
"0.58203655",
"0.5819338",
"0.58157307",
"0.58103... | 0.0 | -1 |
Tests if standup_send raises an AccessError if user is not a member of the channel. | def test_standup_send_not_member():
user1 = auth.auth_register("email1@email.com", "password", "Night", "Man")
user2 = auth.auth_register("email2@email.com", "password", "Day", "Man")
channel_dict = channels.channels_create(user1['token'], "test_channel", False)
standup.standup_start(user1['token'], c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_standup_send_not_member():\n # Following the clearing of data, register a user\n requests.delete(url + \"/clear/v1\")\n authorised_info1 = requests.post(url + \"/auth/register/v2\", json = {\n 'email': 'alex.steel@gmail.com',\n 'password': 'alexsteel2000',\n 'name_first': 'al... | [
"0.65914017",
"0.6567464",
"0.6309164",
"0.6101957",
"0.59758043",
"0.5973602",
"0.5917283",
"0.58745646",
"0.58275324",
"0.5819516",
"0.5811549",
"0.5766884",
"0.5736557",
"0.5719797",
"0.57084614",
"0.56803596",
"0.567132",
"0.5670333",
"0.5661398",
"0.5648839",
"0.56463605... | 0.7686512 | 0 |
Asks the question "Could these two paths theoretically be the same? Uses some brutish heuristics to answer it. | def could_these_two_paths_possibly_represent_the_same_underlying_path(
a: str, b: str
) -> bool:
if a is b:
return True
a_spl = [x for x in a.split("/") if x != ""]
b_spl = [x for x in b.split("/") if x != ""]
# if the two lengths aren't equal, return false
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def same_path(p1, p2):\n return same_path(p1, p2)",
"def same_path(path1, path2):\n if path1 is path2: # use id system to avoid work.\n return True\n if len(path1) != len(path2) or set(path1) != set(path2):\n return False\n\n starts = (ix for ix, n2 in enumerate(path2) if path1[0] ... | [
"0.6444492",
"0.6410185",
"0.6382511",
"0.6303646",
"0.6222334",
"0.6204839",
"0.61558735",
"0.60441965",
"0.60362226",
"0.6027903",
"0.60186183",
"0.5975956",
"0.5934037",
"0.58965576",
"0.58492965",
"0.58232665",
"0.5784365",
"0.57831055",
"0.5776962",
"0.5756224",
"0.57545... | 0.63651615 | 3 |
Test access and refresh tokens creation for successful login | def test_jwt_for_authenticated_user(self):
payload = {'email': 'testuser@email.com', 'password': 'Test'}
create_user(**payload)
res = self.client.post(TOKEN_URL, payload)
self.assertIn('access', res.data)
self.assertIn('refresh', res.data)
self.assertEqual(res.status_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_refresh_token_endpoint(self):\n payload = {\n 'email': 'testuser@email.com',\n 'password': 'testpass',\n 'name': 'Testosterone'\n }\n create_user(**payload)\n tokens = self.client.post(TOKEN_URL, payload)\n refresh_token = tokens.data['re... | [
"0.79203874",
"0.77121323",
"0.7681624",
"0.7664122",
"0.76462716",
"0.7440103",
"0.74329054",
"0.72138923",
"0.71887875",
"0.71608555",
"0.7129495",
"0.70870036",
"0.7074473",
"0.70493037",
"0.70366776",
"0.7035256",
"0.70232725",
"0.69972646",
"0.69549316",
"0.69542485",
"0... | 0.71468985 | 10 |
Test that refresh token results in new access token | def test_refresh_token_endpoint(self):
payload = {
'email': 'testuser@email.com',
'password': 'testpass',
'name': 'Testosterone'
}
create_user(**payload)
tokens = self.client.post(TOKEN_URL, payload)
refresh_token = tokens.data['refresh']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_refresh_token_returns_access_token(self):\n payload = {\n 'email': 'teste@email.com',\n 'password': '12345678'\n }\n res = self.client.post(TOKEN_URL, payload)\n\n refresh_token = res.data['refresh']\n old_access_token = res.data['access']\n\n ... | [
"0.8926551",
"0.8432987",
"0.8427361",
"0.82413346",
"0.8163452",
"0.7923382",
"0.7854824",
"0.7790503",
"0.763499",
"0.759764",
"0.7595176",
"0.7536786",
"0.7455143",
"0.7440879",
"0.7439213",
"0.738879",
"0.723406",
"0.7231758",
"0.72244775",
"0.7202528",
"0.72000587",
"0... | 0.8147434 | 5 |
Test retrieving profile is successful for authenticated user | def test_retrieve_profile_success(self):
res = self.client.get(USER_URL)
self.assertEqual(res.status_code, status.HTTP_200_OK)
self.assertEqual(res.data, {
'name': self.user.name,
'email': self.user.email
}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_profile_successful(self):\n res = self.client.get(MU_URL)\n\n self.assertEqual(res.status_code, status.HTTP_200_OK)\n self.assertEqual(\n res.data,\n {'name': self.user.name, 'email': self.user.email}\n )",
"def test_access_profile(self):\n ... | [
"0.87221056",
"0.8650588",
"0.85886073",
"0.85199237",
"0.8515894",
"0.8467322",
"0.8408918",
"0.84073156",
"0.83861893",
"0.83723766",
"0.83323187",
"0.8284451",
"0.82838666",
"0.82595843",
"0.81691045",
"0.816903",
"0.8025268",
"0.801662",
"0.79301596",
"0.7909994",
"0.7901... | 0.8753464 | 0 |
Test that post is not allowed on user detail url | def test_post_user_detail_not_allowed(self):
res = self.client.post(USER_URL, {})
self.assertEqual(res.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_post_not_allowed(self):\n response = self.client.post(self.user_endpoint, {})\n self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)",
"def test_post_not_allowed(self):\n self.user.is_staff = True\n request = self.create_request('post', user=self.user)\n... | [
"0.7603937",
"0.75635403",
"0.7363266",
"0.72025967",
"0.7170122",
"0.7163576",
"0.71389556",
"0.7028489",
"0.6935111",
"0.6928638",
"0.6901903",
"0.6900643",
"0.68995154",
"0.6899271",
"0.6872173",
"0.6835116",
"0.68224806",
"0.68020487",
"0.67995465",
"0.67995465",
"0.67995... | 0.7934393 | 0 |
Set the input_file_memory attribute. | def set_input_file_memory(self) -> None:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def memory(self, memory):\n\n self._memory = memory",
"def _set_memory(self, memory: D.T_memory[D.T_state]) -> None:\n self._memory = memory",
"def test_set_input_file_memory(self):\n expected_memory = math.ceil(14 * 1024)\n self.assertEqual(self.job_1.input_file_memory, expected_me... | [
"0.66030556",
"0.644917",
"0.6364067",
"0.62437576",
"0.6223202",
"0.61899006",
"0.61248076",
"0.6094352",
"0.6074307",
"0.5958406",
"0.595441",
"0.58067507",
"0.57266295",
"0.5710129",
"0.5708351",
"0.5696663",
"0.5632597",
"0.5623315",
"0.5576451",
"0.5479148",
"0.54720837"... | 0.8805421 | 0 |
Initialize all WorkedHours needed in tests. | def setUp(self):
self.client = Client()
self.kafo = Caffe.objects.create(
name='kafo',
city='Gliwice',
street='Wieczorka',
house_number='14',
postal_code='44-100'
)
self.filtry = Caffe.objects.create(
name='filtry'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_initialize_hours(self):\n project = factories.ProjectFactory.create()\n self.client.force_login(project.owned_by)\n response = self.client.get(\n project.urls[\"createhours\"] + \"?hours=1.5\",\n HTTP_X_REQUESTED_WITH=\"XMLHttpRequest\",\n )\n self.... | [
"0.6492147",
"0.60590446",
"0.6030614",
"0.59600955",
"0.59261286",
"0.5880062",
"0.5861776",
"0.5794463",
"0.57877916",
"0.5784728",
"0.57769555",
"0.5751286",
"0.56953156",
"0.56809765",
"0.56649584",
"0.56572664",
"0.5623137",
"0.5563694",
"0.5562967",
"0.5540352",
"0.5523... | 0.5209205 | 61 |
Converts potential temperature (theta) at a given pressure to temperature | def Theta2TmpK(theta, P, pref=constants['Pref']):
return theta * (P / pref) ** (constants['Rd'] / constants['Cp']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def theta(d, p0=None, field_name='temp'):\n Rd = 287.0\n Cp = 1004.0\n K = Rd / Cp\n if p0 is None:\n p0 = d.phalf.max()\n t = d[field_name]\n p = get_pressure(t)\n theta = t * (p0 / p) ** K\n theta.name = 'pot_temp'\n return theta",
"def tinvert_thetae(thetaeVal, wT, p):\n ... | [
"0.6649804",
"0.65319437",
"0.6527637",
"0.64171994",
"0.6323688",
"0.62740934",
"0.62196",
"0.6196414",
"0.6174606",
"0.6140569",
"0.6122274",
"0.6088169",
"0.60881084",
"0.60855633",
"0.605836",
"0.6036797",
"0.5945422",
"0.590332",
"0.5890195",
"0.5863169",
"0.5855694",
... | 0.5984073 | 16 |
Converts temperature at a given pressure to potential temperature (theta) | def TmpK2Theta(T, P, pref=constants['Pref']):
return T * (pref / P) ** (constants['Rd'] / constants['Cp']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def theta(d, p0=None, field_name='temp'):\n Rd = 287.0\n Cp = 1004.0\n K = Rd / Cp\n if p0 is None:\n p0 = d.phalf.max()\n t = d[field_name]\n p = get_pressure(t)\n theta = t * (p0 / p) ** K\n theta.name = 'pot_temp'\n return theta",
"def tinvert_thetae(thetaeVal, wT, p):\n ... | [
"0.7113355",
"0.6387829",
"0.6292448",
"0.6268249",
"0.6215913",
"0.61996377",
"0.61961",
"0.6137442",
"0.61348283",
"0.6104445",
"0.60868967",
"0.60717374",
"0.6065317",
"0.6009847",
"0.599929",
"0.5967274",
"0.5935958",
"0.59300137",
"0.59283286",
"0.5893762",
"0.5885974",
... | 0.5745676 | 32 |
merge two sorted list | def merge(left, right):
merged = []
left_idx = 0
right_idx = 0
# Find the next largest value between left and right
# and adding that to the result list
while left_idx < len(left) and right_idx < len(right):
# Use '<=' so as to be stable in the order
if left[left_idx] <= right[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(list1, list2): \n merge_list = []\n _ind1 = _ind2 = 0\n while _ind1 < len(list1) and _ind2 < len(list2) :\n if list1[_ind1] < list2[_ind2]:\n merge_list.append(list1[_ind1])\n _ind1 += 1\n else:\n merge_list.append(list2[_ind2])\n _ind2... | [
"0.8063427",
"0.7986292",
"0.789757",
"0.7884639",
"0.7868988",
"0.78516495",
"0.78268915",
"0.7826844",
"0.7824764",
"0.7819784",
"0.7784979",
"0.77229685",
"0.7691126",
"0.76779217",
"0.76761854",
"0.75981647",
"0.7579595",
"0.7561421",
"0.75579935",
"0.75579935",
"0.752741... | 0.7271325 | 42 |
Log probability of an RBFkernel GP. If the output is vectorvalued, then the individual dimensions are assumed independent. | def gp_log_prob(X, Y, sigma_noise, sigma_f, length_scale, verbose=False):
# ======================================================================
# Ensure the input has the correct size
# ======================================================================
if len(X.shape) != 2:
raise Incompat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _log_probs(self):\n output = self.graph[-2].value\n norm_probs = np.exp(output)/np.sum(np.exp(output), axis=1, keepdims=True)\n\n return np.log(norm_probs)",
"def logprob(predictions, labels):\n predictions[predictions < 1e-10] = 1e-10\n return np.sum(np.multiply(labels, -np.log(predic... | [
"0.6600472",
"0.65896595",
"0.6559596",
"0.64414555",
"0.6428281",
"0.63998246",
"0.63523173",
"0.6305528",
"0.6247727",
"0.6210601",
"0.6185484",
"0.6164617",
"0.6163417",
"0.61536014",
"0.6091639",
"0.6051853",
"0.6042681",
"0.6026761",
"0.60156876",
"0.60004795",
"0.597462... | 0.62517256 | 8 |
The derivative of the standard Normal CDF is the standard normal PDF | def backward(self, x):
normalizing_constant = 1. / math.sqrt(2 * math.pi)
return x.pow(2).div_(-2).exp_().mul_(normalizing_constant) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cdfNormal(z):\n if (abs(z) < ERF_CODY_LIMIT1):\n # Phi(z) approx (1+y R_3(y^2))/2, y=z/sqrt(2)\n return 0.5 * (1.0 + (z / M_SQRT2) * _erfRationalHelperR3(0.5 * z * z))\n elif (z < 0.0):\n # Phi(z) approx N(z)Q(-z)/(-z), z<0\n return np.exp(logPdfNormal(z)) * _erfRationalHelper... | [
"0.75635624",
"0.7418579",
"0.7251102",
"0.7234032",
"0.7220157",
"0.70353234",
"0.7025889",
"0.70093155",
"0.6964657",
"0.6945941",
"0.6818765",
"0.6790275",
"0.6786468",
"0.678598",
"0.66782343",
"0.66594124",
"0.66295135",
"0.6612438",
"0.6582887",
"0.6579876",
"0.6550272"... | 0.0 | -1 |
read a column from a tsv file and convert the content into a list by default | def get_column_from_tsv(tsv_file, column_id, to_list=True):
tsv_content = pd.read_table(tsv_file)
desired_column = tsv_content[column_id]
if to_list:
return desired_column.to_list()
return desired_column | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_tsv(cls, input_file, quotechar=None) -> List:\n with open(input_file, \"r\", encoding=\"utf-8\") as f:\n reader = csv.reader(f, delimiter=\"\\t\", quotechar=quotechar)\n lines = []\n for line in reader:\n if sys.version_info[0] == 2:\n ... | [
"0.7176204",
"0.6991027",
"0.6963778",
"0.69479096",
"0.69479096",
"0.69224656",
"0.69073325",
"0.69024634",
"0.6860568",
"0.68566185",
"0.68034",
"0.68030465",
"0.68030465",
"0.67992073",
"0.6797069",
"0.67667294",
"0.6738225",
"0.6732353",
"0.6718379",
"0.67082113",
"0.6679... | 0.69038904 | 7 |
This function returns SQLAlchemy objects for backend use. | def extract_formatted_surficial_data_obs(filter_val, ts_order, start_ts=None, end_ts=None, limit=None):
surficial_data = get_surficial_data(
filter_val, ts_order, start_ts, end_ts, limit)
formatted_list = []
sorted_data = sorted(
surficial_data, key=lambda datum: datum.marker_observation.ts... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_db() -> Iterator[Session]:\n yield from _get_fastapi_sessionmaker().get_db()",
"def get_db():\n Base.query = db_session.query_property()\n Base.metadata.create_all(bind=sql_engine)",
"def engine(db: object) -> sqlalchemy.engine.Engine:\n pass",
"def connect_with_alchemy(self):\n re... | [
"0.69591933",
"0.6872081",
"0.68548137",
"0.6817112",
"0.6742557",
"0.6579039",
"0.6534309",
"0.65339476",
"0.645613",
"0.645613",
"0.6453763",
"0.6453763",
"0.6453763",
"0.63975793",
"0.6377251",
"0.6377251",
"0.6377251",
"0.6377251",
"0.63699603",
"0.6355868",
"0.6340759",
... | 0.0 | -1 |
Student constructor with no parameter | def student_constructor():
check50_java.junit5.run_and_interpret_test(
classpaths=['tests/'],
args=['--select-method', 'StudentTest#testConstructor']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, student_id, student_name, grad_year, classes_taken):\n self.student_name = student_name\n self.student_id = student_id\n self.grad_year = grad_year\n self.classes_taken = classes_taken",
"def __init__(self, first_name=\"\", second_name=\"\", student_ID=0):\n ... | [
"0.75319976",
"0.73875827",
"0.7218796",
"0.68594813",
"0.6657097",
"0.661563",
"0.62486327",
"0.617806",
"0.6111196",
"0.6089707",
"0.60134846",
"0.6007736",
"0.5997042",
"0.5997042",
"0.5997042",
"0.5989689",
"0.5984043",
"0.5956246",
"0.59489626",
"0.59143734",
"0.5900288"... | 0.6621027 | 5 |
Get the full file path for a require(). | def _locate_require_file(p, file_path, lua_path=None):
rel_path_base = os.path.dirname(file_path)
if lua_path is None:
lua_path = os.getenv('PICO8_LUA_PATH')
if lua_path is None:
lua_path = DEFAULT_LUA_PATH
for lookup_p in lua_path.split(';'):
candidate = lookup_p.replace... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_path():\n return os.path.dirname(os.path.abspath(os.path.realpath(__file__)))",
"def __get_path_to_file(filename: str):\n return str(Path(__file__).parent / Path(filename))",
"def _get_path_to_module():\n return Path(os.path.realpath(__file__)).parent",
"def get_abs_path(rel_path):\... | [
"0.7461783",
"0.7443782",
"0.7414157",
"0.7380923",
"0.73759216",
"0.7364472",
"0.71961725",
"0.7192204",
"0.71897924",
"0.71897924",
"0.7165768",
"0.714792",
"0.70392525",
"0.7005058",
"0.7005058",
"0.7000039",
"0.69931",
"0.6991015",
"0.69864404",
"0.6894075",
"0.6889508",
... | 0.0 | -1 |
Create and return a new object. See help(type) for accurate signature. | def __new__(*args, **kwargs):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(cls, *args, **kwargs):\n return cls(*args, **kwargs)",
"def _factory(*args_, **kwargs_):\n return ObsType(*args_, **kwargs_)",
"def make_instance(self, cls, args, kw):\n return Object(cls, args, kw)",
"def __new__(cls):\n raise TypeError(\"%s may not be instantiated.\" ... | [
"0.70525295",
"0.69892246",
"0.69411",
"0.6937072",
"0.692134",
"0.68386704",
"0.67864245",
"0.67692834",
"0.67692834",
"0.6714244",
"0.6670643",
"0.66675353",
"0.6653578",
"0.6652061",
"0.66407984",
"0.66275185",
"0.6615648",
"0.6611473",
"0.6590555",
"0.65855825",
"0.655820... | 0.0 | -1 |
Returns tuple a 2x2 matrix and its inverse | def get_matrix():
a = np.random.uniform(-2, 2, (2, 2))
while not (determinant_2_2(a)):
a = np.random.uniform(-2, 2, (2, 2))
return a, np.linalg.inv(a) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inverse(A):\n## return np.transpose( inverse_transpose(A), (0,2,1))\n return np.swapaxes( inverse_transpose(A), -1,-2)",
"def inverse (self):\n matrixResult = [[complex.ComplexNumber(0,0) for x in range(self.m)] for y in range(self.n)] \n for i in range (self.m):\n for j in ran... | [
"0.7354673",
"0.7272103",
"0.7270313",
"0.7244626",
"0.71044207",
"0.7081041",
"0.70058167",
"0.69988924",
"0.6975099",
"0.6794569",
"0.6771286",
"0.67568797",
"0.67012393",
"0.66973686",
"0.66823596",
"0.6649479",
"0.6647188",
"0.65934503",
"0.6510843",
"0.64858204",
"0.6454... | 0.7276799 | 1 |
''' """ Get variables that don't have an "axis" attribute | def get_nc_variables_no_axis_by_attributes(self, axis=lambda v: v is None):
variables_list = self.dataset.get_variables_by_attributes(axis=axis)
return variables_list if len(variables_list) > 0 else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_group_variables_no_axis_by_attributes(self, group_name, axis=lambda v: v is None):\n variables_list = self.groups[group_name].get_variables_by_attributes(axis=axis)\n return variables_list if len(variables_list) > 0 else None\n\n # get data array",
"def get_nc_variables_x_by_attribut... | [
"0.66967523",
"0.6588546",
"0.6459651",
"0.64143395",
"0.62537026",
"0.6231975",
"0.607618",
"0.59401315",
"0.5850069",
"0.5817641",
"0.5736309",
"0.5695863",
"0.56452084",
"0.5581465",
"0.5549285",
"0.5402638",
"0.5377368",
"0.5347791",
"0.5301485",
"0.5285507",
"0.52723145"... | 0.7530343 | 0 |
Test the correct reception of a json request | def test_get_json(json_example1):
api_obj = XchApi()
assert api_obj
quote = api_obj._parse_json_to_quote(json_example1)
assert quote
assert type(quote) == dict
assert quote["from"]
assert quote["to"]
assert quote["qty"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requested_json():\n\n return request.query.get('format') == 'JSON'",
"def test_program_json(self):\n\n url = reverse('disclosures:program-json', args=['408039_981'])\n resp = client.get(url)\n self.assertTrue('housing' in resp.content)\n self.assertTrue('books' in resp.content)... | [
"0.7057778",
"0.68511987",
"0.6836493",
"0.68186903",
"0.6801424",
"0.6791578",
"0.6735272",
"0.67245543",
"0.66539997",
"0.6640849",
"0.6638926",
"0.6632783",
"0.66201425",
"0.65914994",
"0.6589729",
"0.6580093",
"0.65643287",
"0.65590125",
"0.65016526",
"0.64990455",
"0.647... | 0.62199855 | 47 |
Test whether custom validate_gpu_limit raises a serializers.ValidationError when the gpu_limit is not within the limits provided by the corresponding plugin. | def test_validate_gpu_limit(self):
data = self.data
plugin = self.plugin
plg_inst_serializer = PluginInstanceSerializer(data=data)
plg_inst_serializer.is_valid(raise_exception=True)
plg_inst_serializer.context['view'] = mock.Mock()
plg_inst_serializer.context['view'].get_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validate_cpu_limit(self):\n data = self.data\n plugin = self.plugin\n plg_inst_serializer = PluginInstanceSerializer(data=data)\n plg_inst_serializer.is_valid(raise_exception=True)\n plg_inst_serializer.context['view'] = mock.Mock()\n plg_inst_serializer.context['... | [
"0.6664439",
"0.65524805",
"0.61438584",
"0.5994093",
"0.59572953",
"0.58451194",
"0.58401287",
"0.583754",
"0.577606",
"0.5774778",
"0.5681723",
"0.5665928",
"0.56375784",
"0.5586265",
"0.5583034",
"0.55782366",
"0.5557658",
"0.5546539",
"0.55193746",
"0.5512809",
"0.5506869... | 0.7772704 | 0 |
Test whether custom validate_number_of_workers raises a serializers.ValidationError when the number_of_workers is not within the limits provided by the corresponding plugin. | def test_validate_number_of_workers(self):
data = self.data
plugin = self.plugin
plg_inst_serializer = PluginInstanceSerializer(data=data)
plg_inst_serializer.is_valid(raise_exception=True)
plg_inst_serializer.context['view'] = mock.Mock()
plg_inst_serializer.context['vie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(self, data):\n # validate compute-related descriptors\n if 'min_number_of_workers' in data:\n data['min_number_of_workers'] = self.validate_app_workers_descriptor(\n {'name': 'min_number_of_workers', 'value': data['min_number_of_workers']})\n\n if 'max_nu... | [
"0.63099074",
"0.6222283",
"0.6181175",
"0.6142054",
"0.60856324",
"0.6055176",
"0.5923731",
"0.59079075",
"0.5820859",
"0.5783621",
"0.5745414",
"0.57117957",
"0.5591518",
"0.55639255",
"0.55283016",
"0.55283016",
"0.54942334",
"0.5494109",
"0.54638606",
"0.54468983",
"0.542... | 0.69041973 | 0 |
Test whether custom validate_memory_limit raises a serializers.ValidationError when the memory_limit is not within the limits provided by the corresponding plugin. | def test_validate_memory_limit(self):
data = self.data
plugin = self.plugin
plg_inst_serializer = PluginInstanceSerializer(data=data)
plg_inst_serializer.is_valid(raise_exception=True)
plg_inst_serializer.context['view'] = mock.Mock()
plg_inst_serializer.context['view'].g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validate_gpu_limit(self):\n data = self.data\n plugin = self.plugin\n plg_inst_serializer = PluginInstanceSerializer(data=data)\n plg_inst_serializer.is_valid(raise_exception=True)\n plg_inst_serializer.context['view'] = mock.Mock()\n plg_inst_serializer.context['... | [
"0.6648763",
"0.64954144",
"0.64348596",
"0.6268126",
"0.6070161",
"0.5986199",
"0.5747755",
"0.5735394",
"0.56695473",
"0.5631462",
"0.56024224",
"0.55912596",
"0.5571158",
"0.5568574",
"0.55680364",
"0.55506325",
"0.5467375",
"0.5450789",
"0.5415019",
"0.5409288",
"0.538879... | 0.77722514 | 0 |
Plot loss values during LCA inference | def plot_inference_stats(data, title="", save_filename=None):
#Calculate nnz
#act is in
act = data["a"]
pdb.set_trace()
labels = [key for key in data["losses"].keys()]
losses = [val for val in data["losses"].values()]
num_im, num_steps = losses[0].shape
means = [None,]*len(labels)
sems = [None,]*len(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize(self, activations, loss, iteration):\n print(\"Creating Visualization\")\n np_act = activations.to(\"cpu\").numpy()\n loss = loss.to(\"cpu\").numpy()\n # l2 normalize each feature of activations\n act_norm = sklearn.preprocessing.normalize(np_act, axis=0)\n #... | [
"0.68609345",
"0.6616528",
"0.6610752",
"0.65187424",
"0.64981586",
"0.6375056",
"0.6353663",
"0.63498044",
"0.6346929",
"0.63454336",
"0.6339992",
"0.6309808",
"0.62988275",
"0.62814164",
"0.62374187",
"0.62373567",
"0.6227959",
"0.62238204",
"0.62160176",
"0.6196827",
"0.61... | 0.5681841 | 71 |
Create and return a new object. See help(type) for accurate signature. | def __new__(*args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(cls, *args, **kwargs):\n return cls(*args, **kwargs)",
"def _factory(*args_, **kwargs_):\n return ObsType(*args_, **kwargs_)",
"def make_instance(self, cls, args, kw):\n return Object(cls, args, kw)",
"def __new__(cls):\n raise TypeError(\"%s may not be instantiated.\" ... | [
"0.70525295",
"0.69892246",
"0.69411",
"0.6937072",
"0.692134",
"0.68386704",
"0.67864245",
"0.67692834",
"0.67692834",
"0.6714244",
"0.6670643",
"0.66675353",
"0.6653578",
"0.6652061",
"0.66407984",
"0.66275185",
"0.6615648",
"0.6611473",
"0.6590555",
"0.65855825",
"0.655820... | 0.6484714 | 29 |
Use this to make the device resource be represented by self. This method is run for its sideeffects on self. This method makes an HTTP get query against its uri, if successful its attribute __dict__ is replaced with the dict representing the device state. To figure out what that state is, run a subsequest query of the | def _refresh(self):
read_session = self._meta_data['bigip']._meta_data['icr_session']
response = read_session.get(self._meta_data['uri'])
self._local_update(response.json()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _state(self, name, state):\r\n device = self._get_device(name)\r\n if state is not None:\r\n device.set_state(state)\r\n response = device.get_state()\r\n return response",
"def update(self):\n response = self.get(DEVICE_STATE_ENDPOINT)\n if response is No... | [
"0.6096479",
"0.5898268",
"0.5841597",
"0.56412804",
"0.56296384",
"0.56126565",
"0.55967766",
"0.55775416",
"0.5564821",
"0.5555231",
"0.55379516",
"0.5483896",
"0.5457945",
"0.54366225",
"0.5392812",
"0.53313106",
"0.5291228",
"0.52852166",
"0.526701",
"0.52639824",
"0.5258... | 0.0 | -1 |
converts timedeltas to seconds, leaves any numbers | def convert_timedeltas(x):
try:
return x.seconds
except:
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timedelta_to_seconds(td):\r\n return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6) / float(10 ** 6)",
"def timedelta_to_seconds(td):\r\n return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6) / float(10 ** 6)",
"def timedelta_to_seconds(td):\n # type: (d... | [
"0.76885396",
"0.76885396",
"0.74810016",
"0.7349691",
"0.7062864",
"0.70138067",
"0.6991567",
"0.69847393",
"0.6973494",
"0.6959036",
"0.695666",
"0.6948472",
"0.69089454",
"0.6907802",
"0.6907802",
"0.6896058",
"0.68744326",
"0.68663806",
"0.68419254",
"0.6831302",
"0.68092... | 0.81771255 | 0 |
Returns the number of frames that are left. | def frames_left(self):
return self.frames_length - self.frame_idx | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frames_left(self):\n return self.frames_length - self.current_frame_id",
"def get_frame_count(self):\n if self.auto_resume: self.resume()\n return self.current_frame_count",
"def frames(self) -> int:\n raise NotImplementedError",
"def __len__(self):\n return len(self.__... | [
"0.873691",
"0.7757963",
"0.76699",
"0.74947673",
"0.7446102",
"0.7387197",
"0.7320197",
"0.73080397",
"0.7305509",
"0.71808374",
"0.7154651",
"0.7083672",
"0.6964739",
"0.68994445",
"0.68427163",
"0.67995834",
"0.6795817",
"0.6750816",
"0.67370033",
"0.6732884",
"0.6687672",... | 0.8619626 | 1 |
Initialize the Decision step. | def __init__(self, routine: AutomaticCalibrationRoutine, **kw):
super().__init__(routine=routine, **kw) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _step_init(self, state, action):\n pass",
"def _step_init(self, obs, action):\n pass",
"def InitializeSolutionStep(self):\n pass",
"def _initialize(self):\n\n # The decision tree is modeled implicitly by storing the nodes' data\n # in two two-dimensional arrays of appro... | [
"0.7212801",
"0.7152872",
"0.6898987",
"0.67568564",
"0.6570387",
"0.65175784",
"0.6494648",
"0.64933544",
"0.6485796",
"0.64549893",
"0.63125294",
"0.6251017",
"0.62496",
"0.6247861",
"0.62021136",
"0.6197369",
"0.6180408",
"0.61390626",
"0.61390626",
"0.61390626",
"0.613906... | 0.0 | -1 |
Test dtype legalization of the index map indices. | def test_index_map_dtype_legalize():
@T.prim_func
def func(A: T.Buffer(T.int64(58), "int32")):
for i in T.serial(T.int64(58)):
with T.block("block"):
vi = T.axis.remap("S", [i])
T.writes(A[vi])
A[vi] = 0
sch = tir.Schedule(func)
# # ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_index_map_dtype_legalize_with_constant():\n\n @T.prim_func\n def func(A: T.Buffer(T.int64(16), \"int32\")):\n for i in T.grid(T.int64(16)):\n with T.block(\"block\"):\n vi = T.axis.remap(\"S\", [i])\n A[vi] = 0\n\n sch = tir.Schedule(func)\n\n # ... | [
"0.6523286",
"0.6190223",
"0.60358006",
"0.580323",
"0.5798124",
"0.57890123",
"0.57853496",
"0.57744545",
"0.57588816",
"0.5739826",
"0.57218695",
"0.5691203",
"0.560523",
"0.5590521",
"0.55893975",
"0.55887854",
"0.5542349",
"0.5542032",
"0.55394274",
"0.5471417",
"0.547141... | 0.7263061 | 0 |
Input n>=6, Returns a array of primes, 2 <= p < n | def primeSieve(n):
sieve = numpy.ones(n/3 + (n%6==2), dtype=numpy.bool)
for i in xrange(1,int(n**0.5)/3+1):
if sieve[i]:
k=3*i+1|1
sieve[ k*k/3 ::2*k] = False
sieve[k*(k-2*(i&1)+4)/3::2*k] = False
return numpy.r_[2,3,((3*numpy.nonzero(sieve)[0][1:]+1)|1)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primes(n):\n # https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188\n if n < 6:\n if n == 1:\n return np.array([])\n elif n == 2:\n return np.array([2])\n elif n == 3:\n return np.array([2,3])\n ... | [
"0.82365984",
"0.79940313",
"0.7874743",
"0.7757625",
"0.75981665",
"0.74960804",
"0.7486007",
"0.74813527",
"0.74592316",
"0.7442301",
"0.7431565",
"0.74008214",
"0.7382748",
"0.73649675",
"0.7351732",
"0.7343314",
"0.7336094",
"0.73021823",
"0.7296965",
"0.72911805",
"0.729... | 0.68954456 | 46 |
Poisson regression log likelihood with correlated gaussian prior Computes the log likelihood (technically the full log unnormalized posterior) of a Poisson regression with a Gaussian prior over the log intensity values. The likelihood is log p(y | f) p(f | K_theta) = log dpoiss(y | lam=exp(f)) + log N(f|0,K) | def poisson_log_posterior(y, f, cK_inv, f0=0.0,
grad=False, hess=False,
hessp=False, p=None):
#if bias term is included, shift fs
f = f + f0 #
assert len(f)==cK_inv.shape[0], "log_like f doesn't match covariance mat"
if grad:
K_inv_f = cK_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def poisson_likelihood(self,beta,alpha): \n return np.sum(ss.poisson.logpmf(self.data,np.exp(np.sum(self.X*alpha.T,axis=1))))",
"def poisson_log_likelihood(\n spikes: cp.ndarray, conditional_intensity: cp.ndarray\n ) -> cp.ndarray:\n # Logarithm of the absolute value of the gamma func... | [
"0.7141045",
"0.68629885",
"0.6833894",
"0.6819736",
"0.67407894",
"0.668542",
"0.6624186",
"0.65094894",
"0.64985853",
"0.6497824",
"0.6474682",
"0.6459563",
"0.64433885",
"0.6411824",
"0.6396123",
"0.6352714",
"0.63465255",
"0.6329243",
"0.62887037",
"0.6286521",
"0.6283311... | 0.6374014 | 15 |
Yield successive nsized chunks from lst. | def chunks(lst, n):
# https://stackoverflow.com/a/312464/5026265
for i in range(0, len(lst), n):
yield lst[i:i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def _chunks(self, lst: List, n: int) -> List:\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def _chunks(self, lst: List, n: int) -> List:\n for i in range(0, len(lst), n):\... | [
"0.83071756",
"0.8290744",
"0.8290744",
"0.8237026",
"0.8146566",
"0.81460685",
"0.81414855",
"0.81414855",
"0.81267184",
"0.81267184",
"0.8107211",
"0.8082399",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0.80533457",
"0... | 0.79214925 | 44 |
Optimized bivariate normal cumulative distribution function for computing persistence images using a Gaussian kernel. | def gaussian(birth, pers, mu=None, sigma=None):
if mu is None:
mu = np.array([0.0, 0.0], dtype=np.float64)
if sigma is None:
sigma = np.array([[1.0, 0.0], [0.0, 1.0]], dtype=np.float64)
if sigma[0][1] == 0.0:
return sbvn_cdf(birth, pers,
mu_x=mu[0], mu_y=mu[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GaussianKernel(kernel, sigma):\n\n lim = kernel // 2 + (kernel % 2) / 2\n x = np.linspace(-lim, lim, kernel + 1)\n kern1d = np.diff(norm.cdf(x))\n kern2d = np.outer(kern1d, kern1d)\n return kern2d / kern2d.sum()",
"def gaussian_kernel(size=21, nsig=3):\r\n x = np.linspace(-nsig, nsig, s... | [
"0.6899855",
"0.65592813",
"0.62911826",
"0.62888414",
"0.62697977",
"0.62423795",
"0.6192907",
"0.6139509",
"0.6131049",
"0.60887975",
"0.6074929",
"0.6074929",
"0.6071546",
"0.6070785",
"0.6067835",
"0.6029409",
"0.60069484",
"0.59092206",
"0.5897733",
"0.5884453",
"0.58844... | 0.6314897 | 2 |
Standard bivariate normal cumulative distribution function with specified mean and variances. | def sbvn_cdf(x, y, mu_x=0.0, mu_y=0.0, sigma_x=1.0, sigma_y=1.0):
x = (x - mu_x) / np.sqrt(sigma_x)
y = (y - mu_y) / np.sqrt(sigma_y)
return norm_cdf(x) * norm_cdf(y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normal_(self, mean=0, std=1):\n return init_funcs.normal_fill(self, mean, std)",
"def normal_cdf(self, x, mu=[0.0], sigma=[1.0]):\n x = self.astensor(x)\n mu = self.astensor(mu)\n sigma = self.astensor(sigma)\n normal = torch.distributions.Normal(mu, sigma)\n return norm... | [
"0.70879227",
"0.68265194",
"0.67816913",
"0.67635804",
"0.65704006",
"0.65134144",
"0.64921695",
"0.64898854",
"0.6467661",
"0.6410048",
"0.6399319",
"0.63867486",
"0.63856477",
"0.63456583",
"0.63446236",
"0.63107204",
"0.6281064",
"0.62447226",
"0.6236044",
"0.6230018",
"0... | 0.62205124 | 21 |
Return weights and abscissae for the LegendreGauss quadrature integral approximation. | def gauss_legendre_quad(r):
if np.abs(r) < 0.3:
lg = 3
w = np.array([0.1713244923791705, 0.3607615730481384, 0.4679139345726904])
x = np.array([0.9324695142031522, 0.6612093864662647, 0.2386191860831970])
elif np.abs(r) < 0.75:
lg = 6
w = np.array([.04717533638651177, 0.1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gauss_weights(data): # noqa\n\n # get number of latitudes\n nlat = data.latitude.size\n\n # get Legendre polynomial weights\n weights = legendre(nlat).weights[:, 1]\n\n return weights",
"def OldGaussLegWeights(n,a=-1,b=1):\n \n x = np.zeros( (n) ) # Preallocations.\n w = x*1.0\n m... | [
"0.7356465",
"0.69319975",
"0.68857926",
"0.67438716",
"0.6374465",
"0.6153378",
"0.6121069",
"0.60540026",
"0.59884644",
"0.58897996",
"0.56689763",
"0.55529463",
"0.55399024",
"0.54963243",
"0.5494849",
"0.5485069",
"0.54459655",
"0.5436886",
"0.54352385",
"0.5424359",
"0.5... | 0.6436868 | 4 |
Return the height of this node (the number of edges on the longest downward path from this node to a descendant leaf node). | def height(self):
# Nodes without children have no height
if self.is_leaf():
return 0
heights = []
# Check on every possible child if it exists
for child in self.children:
# Measure the height of the child and
# add height to the list... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def height(self):\n\n # if tree is empty\n if self.node is None:\n\n return -1\n\n # else\n return max(self.node.node_height(), self.node.node_height())",
"def get_height(self,*args):\r\n return BSTree.get_height(self,*args)",
"def height(self) -> int:\r\n i... | [
"0.8394656",
"0.80997294",
"0.80788463",
"0.80700064",
"0.8036559",
"0.8029467",
"0.80143535",
"0.79939574",
"0.7791563",
"0.7785304",
"0.77751416",
"0.7773585",
"0.7764713",
"0.7747886",
"0.77132297",
"0.77084243",
"0.7650208",
"0.7637565",
"0.7637565",
"0.76207477",
"0.7616... | 0.77733964 | 12 |
Helper function to serialise a Python dictionary in JSON format. Handles opening and closing file. | def serialize_json(var, name):
with open(name, "w") as f:
json.dump(var, f) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(self, fp: str) -> None:\r\n outdict = {key: str(val) for key, val in self.to_dict().items()}\r\n with open(fp, \"w\") as outjson:\r\n json.dump(outdict, outjson)",
"def _dict_to_json(data, fname, sim_dt=None):\n with open(os.path.join(DATA_DIR, fname), 'w') as f:\n ... | [
"0.70724964",
"0.7015986",
"0.70068395",
"0.69246",
"0.68982357",
"0.6876412",
"0.6860751",
"0.6778576",
"0.676688",
"0.6760014",
"0.67241555",
"0.66631293",
"0.6654867",
"0.66539073",
"0.6636203",
"0.66361666",
"0.6619138",
"0.65727115",
"0.6567456",
"0.6564903",
"0.65252316... | 0.6603939 | 17 |
Wrap the ``self._model.np_weights = stuff`` expression. The ``assertRaises`` method expects a callable object, so we need to wrap the expression in a def. If we didn't wrap it in a def then we'd throw the exception too early, and ``assertRaises`` would never get called in order to see it. Normally we'd use a lambda for... | def _NpWeightSettingExpression():
self._model.np_weight = 'this is not an np.ndarray' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _WeightSettingExpression():\n # This np.ndarray has the wrong shape.\n self._model.np_weight = np.array([[1,2], [3,4]])",
"def test_compute_weights_invalid_expectation():\n with pytest.raises(\n ValueError, match=r\"Expectation must be t or logt, got: a\"\n ):\n compute_weights(... | [
"0.5902472",
"0.5500189",
"0.54278135",
"0.5241134",
"0.5214521",
"0.51605844",
"0.5131346",
"0.50751364",
"0.50511366",
"0.5006171",
"0.4978576",
"0.49780664",
"0.49028876",
"0.49014646",
"0.48966476",
"0.48842183",
"0.48699102",
"0.4868052",
"0.48635423",
"0.48548183",
"0.4... | 0.59336585 | 0 |
Wrap the ``self._model.weights = stuff`` expression. | def _WeightSettingExpression():
# This np.ndarray has the wrong shape.
self._model.np_weight = np.array([[1,2], [3,4]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_weights(self, w):\r\n raise NotImplementedError('This function must be implemented within child class!')",
"def my_assign_weights(context, data):\n pass",
"def _NpWeightSettingExpression():\n self._model.np_weight = 'this is not an np.ndarray'",
"def setWeights(self, weights): # real s... | [
"0.70698655",
"0.67512244",
"0.67492723",
"0.67150456",
"0.6714151",
"0.65537155",
"0.6534156",
"0.6473962",
"0.6447819",
"0.644238",
"0.64011323",
"0.6399875",
"0.6325857",
"0.63169223",
"0.6315583",
"0.6290713",
"0.6262366",
"0.62235034",
"0.6221683",
"0.6219397",
"0.618362... | 0.7697659 | 0 |
Serialize an object as JSON to a given file path. | def render_json(obj: Any, filepath: Path) -> None:
with filepath.open("w", encoding="utf-8") as file_obj:
json.dump(obj, file_obj, sort_keys=True, indent=2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_json(obj, path):\n with open(path, 'wt') as stream:\n json.dump(obj, stream, indent=4)\n return path",
"def write_json(python_object, path, filename):\n if not isinstance(path, str):\n raise TypeError('`path` must be str')\n elif not isinstance(filename, str):\n raise Ty... | [
"0.8177282",
"0.7841938",
"0.77036667",
"0.75963795",
"0.75912565",
"0.758869",
"0.75721365",
"0.7508663",
"0.749712",
"0.74941397",
"0.74908155",
"0.7475119",
"0.7447455",
"0.7446788",
"0.741106",
"0.7390451",
"0.7379561",
"0.73599106",
"0.7355141",
"0.73520297",
"0.7304789"... | 0.74922955 | 10 |
Serialize a dict as an env file to the given file path. | def render_envfile(variables: Mapping[str, str], filepath: Path) -> None:
with filepath.open("w", encoding="utf-8") as fp:
data = "\n".join("{}={}".format(key, value) for key, value in variables.items())
fp.write(data)
fp.write("\n") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(filepath=None, **kwargs):\n if filepath is None:\n filepath = os.path.join('.env')\n\n with open(filepath, 'wb') as file_handle:\n file_handle.writelines(\n '{0}={1}\\n'.format(key.upper(), val)\n for key, val in kwargs.items()\n )",
"def to_file(self, pa... | [
"0.6697309",
"0.65311134",
"0.63427496",
"0.6320976",
"0.6307468",
"0.6300358",
"0.6152461",
"0.6147727",
"0.6126848",
"0.61204845",
"0.6114854",
"0.6055057",
"0.60369045",
"0.60251266",
"0.59877247",
"0.59826195",
"0.5980205",
"0.5973806",
"0.5973058",
"0.5949327",
"0.592813... | 0.627985 | 6 |
Boolean denoting if java mode is enabled. | def is_java(self):
try:
return self.__meta_data__.get("global").get("languages").get("java")
except:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_enabled():\n return _ENABLED",
"def enabled(self) -> bool:\n return pulumi.get(self, \"enabled\")",
"def enabled(self) -> bool:\n return pulumi.get(self, \"enabled\")",
"def enabled(self) -> bool:\n return pulumi.get(self, \"enabled\")",
"def enabled(self) -> bool:\n r... | [
"0.6577481",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",
"0.65560514",... | 0.6225319 | 73 |
Boolean denoting if version control system awareness is enabled. | def is_vcs(self):
try:
return self.__meta_data__.get("vcs").get("enabled")
except:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_managed(self):\n return self.system_managed",
"def is_vcs(self, value):\n try:\n self.__meta_data__.get(\"vcs\")[\"enabled\"] = value\n except:\n pass",
"def strict_mode_ok(self):\n\n if not self.strict_mode:\n return True\n\n return no... | [
"0.6179333",
"0.6176538",
"0.6158347",
"0.61582094",
"0.60026014",
"0.58719754",
"0.57905036",
"0.56623477",
"0.5650336",
"0.56361854",
"0.5605018",
"0.5561959",
"0.5555728",
"0.5554467",
"0.5550204",
"0.55328715",
"0.55182606",
"0.551171",
"0.5505517",
"0.5496625",
"0.547359... | 0.7045465 | 0 |
Boolean denoting if version control system awareness is enabled. | def is_vcs(self, value):
try:
self.__meta_data__.get("vcs")["enabled"] = value
except:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_vcs(self):\n try:\n return self.__meta_data__.get(\"vcs\").get(\"enabled\")\n except:\n return False",
"def is_managed(self):\n return self.system_managed",
"def uses_git(self):\n return self._uses_git",
"def strict_mode_ok(self):\n\n if not sel... | [
"0.70455325",
"0.6178201",
"0.6158173",
"0.61578685",
"0.60028195",
"0.58718914",
"0.5790797",
"0.5661314",
"0.56508905",
"0.563628",
"0.56041235",
"0.5560696",
"0.55558765",
"0.5554825",
"0.5551276",
"0.5532317",
"0.55182374",
"0.55114895",
"0.5504842",
"0.54965585",
"0.5471... | 0.6176705 | 2 |
Boolean denoting if ruby mode is enabled. | def is_ruby(self):
try:
return self.__meta_data__.get("global").get("languages").get("ruby")
except:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_enabled(self) -> bool:\n\n return is_python(self.view, True)",
"def python(self) -> Optional[bool]:\n return pulumi.get(self, \"python\")",
"def python(self) -> Optional[bool]:\n return pulumi.get(self, \"python\")",
"def is_enabled():\n return _ENABLED",
"def _is_test_mode()... | [
"0.6829564",
"0.6702872",
"0.6702872",
"0.6555602",
"0.6526902",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"0.6433198",
"... | 0.6702339 | 3 |
This class overloads this function and establishes actual pooling mode. | def setBatchSize(self, _batch_size = 0): # this formally assigns the mode and index
self.batch_size = int(_batch_size) if isint(_batch_size) else len(_batch_size)
if not(self.batch_size): return
# Pooling mode defaults to ranger
self.mode = self.pool_mode
if self.pool_mode == POOLMODE_DEFAULT... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_pool(self):\r\n self.logger.info(\"...using pool\")\r\n return mp.Pool(processes=self.number_of_cores)",
"def _pooling(net, stride, operation, use_bounded_activation):\n padding = 'SAME'\n pooling_type, pooling_shape = _operation_to_pooling_info(operation)\n if use_bounded_activation:\n... | [
"0.693916",
"0.69137275",
"0.68420815",
"0.677807",
"0.67576927",
"0.67576927",
"0.67576927",
"0.67576927",
"0.67576927",
"0.67576927",
"0.6718595",
"0.65012795",
"0.6409641",
"0.63861793",
"0.6330776",
"0.6322788",
"0.6301859",
"0.62646294",
"0.62624574",
"0.62337923",
"0.62... | 0.0 | -1 |
Makes rotation of 360 degrees from base template in TMPL_DIR. Saves rotated templates as tmpl{deg}.png in TMPL_DIR | def make_templates():
try:
base = cv2.imread(os.path.join(TMPL_DIR, 'minion-template.png'))
except IOError:
print('Failed to make templates. Base template is not found')
return
for deg in range(360):
tmpl = ndimage.rotate(base, deg)
cv2.imwrite(os.path.join(TMPL_DIR, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotate_outfolder_angle_catalog(config):\n ifile = config['catalog_file']\n ofile = config['90_catalog_file']\n old_catalog_file = open(ifile, 'r')\n catalog_file = open(ofile, 'w')\n angle0, angle90 = 0, 0\n for old_line in old_catalog_file:\n l = old_line.split(\"\\t\")\n angle... | [
"0.5912733",
"0.58211243",
"0.5677984",
"0.56061727",
"0.55033356",
"0.545363",
"0.53957117",
"0.5357775",
"0.5351881",
"0.53456694",
"0.53450865",
"0.53166723",
"0.5313677",
"0.530943",
"0.5284786",
"0.5262986",
"0.5260974",
"0.5260735",
"0.5249531",
"0.52441543",
"0.5216783... | 0.73375314 | 0 |
Convert class labels from scalars to onehot vectors. | def dense_to_one_hot(labels_dense):
num_classes = len(np.unique(labels_dense))
num_labels = labels_dense.shape[0]
index_offset = numpy.arange(num_labels) * num_classes
labels_one_hot = numpy.zeros((num_labels, num_classes))
labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1
return labe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_label(classes, label):\n m = label.shape[0]\n new_label = np.zeros((classes, m))\n for i in range(m):\n clas = label[i]\n new_label[clas,i] = 1\n return new_label",
"def convert_to_one_hot(labels):\n numbers = np.max(labels) + 1\n return np.eye(numbers)[labels]... | [
"0.8279212",
"0.81934166",
"0.81630087",
"0.81026804",
"0.80831635",
"0.8075612",
"0.8014544",
"0.79461926",
"0.79381865",
"0.78392273",
"0.7811976",
"0.7777559",
"0.77540547",
"0.7742955",
"0.77226317",
"0.77226317",
"0.77226317",
"0.77226317",
"0.77226317",
"0.7715275",
"0.... | 0.75616586 | 47 |
Returns vector containing values from the imaging signal | def get_values(self):
return self.__values | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getIm(self):\n return numpy.array(self.take(range(3)))",
"def _as_vector(self, keep_channels=False):\n if keep_channels:\n return self.masked_pixels.reshape([-1, self.n_channels])\n else:\n return self.masked_pixels.ravel()",
"def im(self): \n return self.i... | [
"0.67683494",
"0.65385205",
"0.64374673",
"0.61251426",
"0.59094197",
"0.58956116",
"0.58683366",
"0.584698",
"0.5839348",
"0.5797806",
"0.5756506",
"0.57434505",
"0.5737018",
"0.5726941",
"0.57262665",
"0.5707212",
"0.5703582",
"0.5696051",
"0.567959",
"0.5676175",
"0.566636... | 0.0 | -1 |
Returns sample rate of the imaging signal in Hz | def get_sample_rate(self):
time_diffs = np.diff(self.get_time()).mean()
return 1000/time_diffs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_rate(self):\n return self.audio_samplerate / 256.0",
"def sampling_rate(self):\n return self.librarycall('get_sampleRate')",
"def get_freq(self):\n scales=self.cw.getscales()\n # scale frequencies and correct with sample rate\n freq=1/(self.cw.fourierwl*scales)*self.sample_rat... | [
"0.7685146",
"0.7317915",
"0.7255382",
"0.717074",
"0.70736736",
"0.7001589",
"0.69828314",
"0.693022",
"0.68644404",
"0.685997",
"0.68283874",
"0.66470486",
"0.6541519",
"0.6540262",
"0.652276",
"0.65153015",
"0.64991456",
"0.6498685",
"0.64806783",
"0.6438105",
"0.63841486"... | 0.74397993 | 1 |
Returns whether a family passes gross income test >>> gross_income_test(1000, 4, 2, "San Francisco") True >>> gross_income_test(2000, 4, 2, "San Francisco") False >>> gross_income_test(1500, 3, 1, "San Francisco") False >>> gross_income_test(1000, 4, 2, "Long Beach") True >>> gross_income_test(1500, 3, 2, "Long Beach")... | def gross_income_test(total_income, fam_members, emp_fam_members, county_of_res):
income = total_income - (90 * emp_fam_members)
if county_of_res in REGION_1:
try:
return income < REGION_1_MBSAC[fam_members]
except KeyError:
return income < REGION_1_MBSAC[10]
else:
try:
return income < REGION_2_MB... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_gross_taxable_income_calculator(self):\n assert calc_logic.calculate_gross_taxable_income(1000, 0.78) == 780\n assert calc_logic.calculate_gross_taxable_income(1000, 0.54) == 540",
"def verify_income(user_object: object) -> bool:\n # Check to see if user meets the CERB threshold for ann... | [
"0.6349564",
"0.62887925",
"0.5620256",
"0.55089146",
"0.52783597",
"0.5261859",
"0.52335644",
"0.52061117",
"0.5204496",
"0.51166666",
"0.50907475",
"0.4980436",
"0.49461335",
"0.49224746",
"0.49052933",
"0.4904307",
"0.4882772",
"0.48364747",
"0.48350278",
"0.48330185",
"0.... | 0.6785776 | 0 |
Slices a matrix along a specific axes | def np_slice(matrix, axes={}):
new_mtx = matrix.copy()
ix = []
for dim in range(new_mtx.ndim):
ax = axes.get(dim, None)
if ax is None:
ix.append(slice(ax))
else:
ix.append(slice(*ax))
return new_mtx[tuple(ix)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slice_along_axis(x, axis, idx):\n pos = x.axes.index(axis)\n ss = tuple(idx if i == pos else slice(None) for i in range(len(x.axes)))\n axes = x.axes[:pos] + x.axes[pos + 1:]\n return tensor_slice(x, ss, axes=axes)",
"def _slice(_x, n, dim):\n if _x.ndim == 3:\n return _x[:, :, n * dim:... | [
"0.667484",
"0.6227304",
"0.61673045",
"0.6160032",
"0.6056533",
"0.60285664",
"0.60204566",
"0.60101455",
"0.60101455",
"0.5993646",
"0.5986931",
"0.5980602",
"0.59280014",
"0.5874461",
"0.5861014",
"0.57827055",
"0.5708056",
"0.5691772",
"0.56785285",
"0.56763715",
"0.56442... | 0.7148892 | 0 |
String giving a faithful, unambiguous representation of this binary float and its format. Two binary floats are interchangeable for all practical purposes if their identifying strings are identical. | def identifying_string(binary_float):
# XXX We actually use this for all result types; fix accordingly.
# (TestCase could also check return type.)
if isinstance(binary_float, int):
return str(binary_float)
if isinstance(binary_float, STRING_TYPES):
return binary_float
if isinstanc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def floatx() -> str:\r\n return _FLOATX",
"def float_to_str(f):\n d1 = ctx.create_decimal(repr(f))\n return format(d1, 'f')",
"def Float32b():\n return FormatField(\">\", \"f\")",
"def test_str(self):\n str(self.res_double)\n str(self.res_single)\n \"{:.6f}\".format(s... | [
"0.62111133",
"0.6140349",
"0.601491",
"0.60087687",
"0.597821",
"0.5935717",
"0.5935717",
"0.5935717",
"0.59251153",
"0.59091717",
"0.5904657",
"0.58826333",
"0.58431697",
"0.58292675",
"0.5786399",
"0.57759",
"0.5768713",
"0.5762302",
"0.57555044",
"0.57418364",
"0.56837887... | 0.710893 | 0 |
Reads a file and returns a list containing all the lines in the file | def readFile(self, fileName):
inputFile = open(fileName, 'r')
if not inputFile:
print('error, input file cant be opened!')
exit(1)
return inputFile.readlines() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _readlines(self, filename):\n lines = []\n if self._has_file(filename):\n with open(filename, 'r') as file:\n lines = [line.strip() for line in file]\n return lines",
"def read_lines(filename):\n out = []\n with open(filename, 'r') as file:\n for li... | [
"0.84557277",
"0.83646256",
"0.8337828",
"0.82505906",
"0.82106686",
"0.8140806",
"0.8113367",
"0.8111601",
"0.8111289",
"0.8111289",
"0.8103597",
"0.805489",
"0.80487746",
"0.8035948",
"0.80120635",
"0.8005141",
"0.7994306",
"0.79881275",
"0.7957916",
"0.79445297",
"0.793460... | 0.7195424 | 84 |
Takes a list of raw texts and returns a list of tuples, where each tuple is created from the raw text | def getTaggedList(self, raw):
# taggedList = list of tuples of (word, POS, NETag, wordNum, sentNum, relation or None)
taggedList = []
for line in raw:
l = line.split()
if len(l) == 5:
l.append('None')
if len(l) == 6:
l.append('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_reader(path: str) -> Tuple[list, list]:\n with open(path, 'r', encoding='utf-8') as fobj:\n parts = fobj.read().split('\\n\\n')\n parts = [part.strip() for part in parts]\n parts = [part for part in parts if len(part) > 0]\n assert parts, 'text file empty \"{}\"'.format(path)\n\... | [
"0.65195006",
"0.63024235",
"0.6291053",
"0.6274324",
"0.61120874",
"0.59957093",
"0.5950763",
"0.5934134",
"0.5916881",
"0.5876963",
"0.5876811",
"0.58738905",
"0.58240604",
"0.5808562",
"0.5796294",
"0.57804096",
"0.57386684",
"0.5726353",
"0.5699032",
"0.5697864",
"0.56847... | 0.53257686 | 58 |
Returns the p value for likelihood ratio test | def likelihood_ratio_test(full, reduced, df):
D = -2 * (reduced - full)
return special.gammaincc(df/2, D/2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def likelihood_ratio(self, mu_test):\n return np.exp(-0.5 / self.sigma**2 * (self.measured-mu_test)**2)",
"def log_likelihood_ratio_func(x):\n z = mu * x - 0.5 * mu ** 2\n if z > 0:\n return z + np.log(p) + np.log1p((1 / p - 1) * np.exp(-z))\n else:\n return np.l... | [
"0.71172553",
"0.67407227",
"0.66607344",
"0.66319853",
"0.65557855",
"0.647325",
"0.641855",
"0.6377546",
"0.63735485",
"0.6368924",
"0.6350093",
"0.63322675",
"0.6319804",
"0.62688655",
"0.62412024",
"0.6231163",
"0.6222201",
"0.6214126",
"0.6201412",
"0.6196329",
"0.617628... | 0.5935697 | 45 |
r""" Notes One state variable ``xi`` and one algebraic variable ``y`` are added. Equations implemented are | def define(self):
PIController.define(self)
# state freeze does not affect initial values
self.xi.e_str = f'(1 - {self.freeze.name}) * {self.ki.name} * ' \
f'({self.u.name} - {self.ref.name})'
# Freeze and unfreeze should invoke a Jacobian update
# In ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_symbolic_state_vars(self):\n self.x_sp = np.array(sp.symbols('x:' + str(self.nvars)))",
"def addLiquidity_Y(params, substep, state_history, prev_state, policy_input):\n asset_id = policy_input['asset_id'] # defines asset subscript\n pool = prev_state['pool']\n a = params['a']\n delta_... | [
"0.59495384",
"0.59156936",
"0.5727506",
"0.5649705",
"0.5584137",
"0.5551553",
"0.55501246",
"0.5546599",
"0.5529674",
"0.5486526",
"0.5479114",
"0.5475976",
"0.5461184",
"0.5457879",
"0.5451688",
"0.54463637",
"0.54209256",
"0.54071105",
"0.5399472",
"0.5396995",
"0.5377648... | 0.50808644 | 66 |
Checks the total number of available images of fivek data | def fivek_dimension():
return len(os.listdir(fivek_path("original"))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n_selected_images():\n try:\n return len(list(paths.list_images(config.ilp_img_path)))\n except Exception as e:\n # might fail in case dir has not been created\n print('[!] Failed checking for existing images')\n print(e)\n return 0 # in that case there are no images y... | [
"0.70975417",
"0.67311424",
"0.6615636",
"0.6615636",
"0.6575165",
"0.6564112",
"0.6564112",
"0.6535261",
"0.6458449",
"0.64440376",
"0.64322037",
"0.63932794",
"0.63893795",
"0.63821685",
"0.6381549",
"0.6363963",
"0.6341451",
"0.6310768",
"0.6298425",
"0.6273353",
"0.625763... | 0.6457669 | 9 |
This Function returns the Cosine of the Angle | def cosine(self):
return math.cos(self.angle) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cosine(angle):\r\n\r\n return math.cos(angle)",
"def cos(angle):\n return math.cos(angles.deg_to_rad(angle))",
"def cos(a):\n return math.cos(a)",
"def cos(angle):\n return np.cos(2 * np.pi * angle)",
"def cos(self):\n return self._unop(\"cos\")",
"def cosd(angle):\n ret... | [
"0.85235786",
"0.8368602",
"0.8309632",
"0.82122785",
"0.80301875",
"0.79907554",
"0.79649305",
"0.79485095",
"0.7876859",
"0.78263986",
"0.76711845",
"0.76709884",
"0.7591722",
"0.7581421",
"0.7552169",
"0.75141317",
"0.75006884",
"0.7381683",
"0.7338088",
"0.73188543",
"0.7... | 0.8398635 | 1 |
Checks if this object belongs to this member or not | def _check_object(self, object, ring, sorted_keys):
hashed_key = self._hash(object.id)
position = bisect.bisect(sorted_keys, hashed_key)
position = position if position < len(sorted_keys) else 0
return ring[sorted_keys[position]] == self.member_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_member(self):\n if six.PY34:\n if self.is_barefunction:\n return False\n if not self.is_descriptor:\n return True\n return self.first_parameter is not None \\\n and self.first_parameter.name == 'self'",
"def is_member(self, name:... | [
"0.7153806",
"0.7134766",
"0.7112196",
"0.69810516",
"0.6932758",
"0.6865597",
"0.6741444",
"0.66872865",
"0.6660844",
"0.665368",
"0.66116977",
"0.65651464",
"0.65555316",
"0.65497124",
"0.6537656",
"0.6521502",
"0.64837277",
"0.6469015",
"0.6457813",
"0.64343673",
"0.641489... | 0.62868035 | 25 |
Returns whether the stack is empty. | def empty(self) -> bool:
return len(self.que) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_stack_empty(self):\n if self.stack.__len__() == 0:\n return True\n else:\n return False",
"def is_empty(self):\n return len(self.__stack) == 0",
"def is_empty(self):\n return self.stack == []",
"def is_empty(self):\n return self.stack == []",
... | [
"0.9223479",
"0.9104887",
"0.90884537",
"0.90884537",
"0.90884537",
"0.90884537",
"0.90185934",
"0.9015882",
"0.89481044",
"0.89459634",
"0.89435357",
"0.89222306",
"0.8914569",
"0.88877344",
"0.8867761",
"0.8850044",
"0.8830557",
"0.87923694",
"0.87492615",
"0.87358737",
"0.... | 0.0 | -1 |
Convert a list to a string that can be stored as an HDF5 attribute | def _list2h5attr(data: List[str]) -> str:
return f"list {str(data)}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _tuple2h5attr(data: Tuple[str]) -> str:\n return f\"tuple {str(data)}\"",
"def _str2h5attr(data: str) -> str:\n return f\"str {data}\"",
"def _h5attr2str(attr: str) -> str:\n return attr",
"def _dict2h5attr(data: Dict[str, str]) -> str:\n return f\"dict {str(data)}\"",
"def _set2h5attr(data... | [
"0.6829676",
"0.66247416",
"0.6556079",
"0.65024716",
"0.6433855",
"0.6317726",
"0.60544133",
"0.5970147",
"0.59299874",
"0.59173954",
"0.5886402",
"0.5785557",
"0.57294923",
"0.57259434",
"0.57184935",
"0.56876945",
"0.567068",
"0.56613004",
"0.5652442",
"0.5648716",
"0.5607... | 0.81823814 | 0 |
Convert a list to a string that can be stored as an HDF5 attribute | def _tuple2h5attr(data: Tuple[str]) -> str:
return f"tuple {str(data)}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _list2h5attr(data: List[str]) -> str:\n return f\"list {str(data)}\"",
"def _str2h5attr(data: str) -> str:\n return f\"str {data}\"",
"def _h5attr2str(attr: str) -> str:\n return attr",
"def _dict2h5attr(data: Dict[str, str]) -> str:\n return f\"dict {str(data)}\"",
"def _set2h5attr(data: S... | [
"0.81840295",
"0.6629015",
"0.6559465",
"0.65058947",
"0.6437152",
"0.6316143",
"0.6053021",
"0.5968215",
"0.59289455",
"0.59181297",
"0.5887193",
"0.5784068",
"0.57260346",
"0.57238394",
"0.5715685",
"0.5685179",
"0.56694454",
"0.5658618",
"0.5650648",
"0.5646221",
"0.560509... | 0.68331814 | 1 |
Convert a list to a string that can be stored as an HDF5 attribute | def _set2h5attr(data: Set[str]) -> str:
return f"set {str(data)}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _list2h5attr(data: List[str]) -> str:\n return f\"list {str(data)}\"",
"def _tuple2h5attr(data: Tuple[str]) -> str:\n return f\"tuple {str(data)}\"",
"def _str2h5attr(data: str) -> str:\n return f\"str {data}\"",
"def _h5attr2str(attr: str) -> str:\n return attr",
"def _dict2h5attr(data: Di... | [
"0.81825805",
"0.68298334",
"0.66249275",
"0.6556214",
"0.65025383",
"0.6317745",
"0.6054474",
"0.5970326",
"0.59300894",
"0.5917542",
"0.5886551",
"0.5785727",
"0.5729602",
"0.5726054",
"0.57185876",
"0.5687835",
"0.5670679",
"0.5661395",
"0.5652558",
"0.56488836",
"0.560778... | 0.6434057 | 5 |
Searches data structure and replaces 'nan' and 'inf' with respective float values | def _recursive_replace(data):
if isinstance(data, str):
if data == "nan":
return float("nan")
if data == "inf":
return float("inf")
if data == "-inf":
return -float("inf")
if isinstance(data, List):
return [_recursive_replace(v) for v in data]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_nan_with_inf(ulog, topic_msgs_list):\n for topic_msgs in topic_msgs_list:\n for ulogtopic in ulog.data_list:\n if ulogtopic.name == topic_msgs.topic:\n if topic_msgs.msgs:\n for msg in topic_msgs.msgs:\n nan_ind = np.isnan(ul... | [
"0.72922415",
"0.6664615",
"0.6581795",
"0.64593613",
"0.6441822",
"0.64367026",
"0.6416186",
"0.6402148",
"0.63140863",
"0.6250561",
"0.6233812",
"0.6056149",
"0.60529417",
"0.6040462",
"0.60287774",
"0.60136503",
"0.6002499",
"0.5994134",
"0.59772784",
"0.59757936",
"0.5959... | 0.55550814 | 54 |
To validate both days and bump_up formats. | def validate_day_and_bump_up(timestamp: str, search: str) -> bool:
_search = re.search(search, timestamp)
if _search and search == days_re_search:
return True
elif _search and search == bump_re_search:
return True
elif _search and search == min_hour_re_search:
return True
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_dates(self):\n sedt = self.start_date > self.end_date\n if (self.start_date and self.end_date and sedt):\n raise ValidationError(_('Event start-date must be lower\\\n then Event end-date!'))",
"def check_dates(self):\n if self.start_date and... | [
"0.6081494",
"0.5912881",
"0.589965",
"0.58698565",
"0.57929605",
"0.5768495",
"0.5766086",
"0.56720436",
"0.56283396",
"0.5615267",
"0.5613387",
"0.55827105",
"0.5582112",
"0.5553228",
"0.5529973",
"0.55063957",
"0.5502893",
"0.54906553",
"0.5469204",
"0.5463326",
"0.5454265... | 0.6044879 | 1 |
Create the query params value for `serp_url`. | def get_query_params(sort='date', order='desc', category_slug='tvs', location_slug='sri-lanka', page=1, category_value=870) -> str:
sort = f'sort={sort}'
order = f'order={order}'
category_slug = f'categorySlug={category_slug}'
location_slug = f'locationSlug={location_slug}'
page = f'page={page}'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_url_params(self):\n # Go through the paramaters and join them up\n params_list = []\n for param, value in self.__dict__.items():\n # Replace underscores with a dash to match url query params\n param_key = param.replace(\"_\", \"-\") if '_' in param else param\n ... | [
"0.673447",
"0.6360597",
"0.63199884",
"0.61271596",
"0.60721517",
"0.6047698",
"0.6042639",
"0.60270625",
"0.6024467",
"0.601648",
"0.60077137",
"0.60064536",
"0.598381",
"0.5968218",
"0.5960662",
"0.58929664",
"0.58817184",
"0.5881379",
"0.586914",
"0.5863374",
"0.5846946",... | 0.5916049 | 15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.