query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Given an image numpy array, it returns all the points in each object in the image. Assuming background have maximum number of points, it will remove background object points. input | def _get_mask_points(img_arr):
img_unique_val = np.unique(img_arr)
max_point_object_id = -1
max_num_points = -1
masks_point_dict = dict()
for mask_id in img_unique_val:
points_location = np.where(img_arr == mask_id)
min_height = min(points_location[0])
max_height = max(points... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_objects(img, threshold=.3):\n thresholded_img = np.uint8(img > threshold)\n _, markers = cv2.connectedComponents(thresholded_img)\n object_centers = []\n for ii in range(1, np.max(markers)):\n masked_img = mask_img(img, markers == ii)\n object_index = np.argmax(masked_img)\n ... | [
"0.6686785",
"0.6322959",
"0.62514174",
"0.61938",
"0.6173828",
"0.61347634",
"0.61281",
"0.6068525",
"0.60538",
"0.5940649",
"0.5925896",
"0.5898862",
"0.5897576",
"0.5851124",
"0.5839876",
"0.5823407",
"0.5781983",
"0.57549876",
"0.5752311",
"0.57283723",
"0.57160974",
"0... | 0.64154553 | 1 |
Function to convert velocity to spherical coordinates velocity Returns ~einsteinpy.coordinates.velocity.SphericalDifferential Spherical representation of the velocity in Cartesian Coordinates. | def spherical_differential(self):
r, theta, phi, v_r, v_t, v_p = self.convert_spherical()
return SphericalDifferential(
r * u.m,
theta * u.rad,
phi * u.rad,
v_r * u.m / u.s,
v_t * u.rad / u.s,
v_p * u.rad / u.s,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _velocity_cartesian2spherical(pos,vel):\n\n \n #save cartesian position of each particle\n x=pos[:,0]\n y=pos[:,1]\n z=pos[:,2]\n\n #save cartesian velocities\n vx=vel[:,0]\n vy=vel[:,1]\n vz=vel[:,2]\n\n #convert to spherical coordinates\n pos_sph=_position_cartesian2spherical... | [
"0.7311547",
"0.71452445",
"0.6971911",
"0.67958176",
"0.6771112",
"0.66505325",
"0.6608041",
"0.6568496",
"0.6398689",
"0.63865006",
"0.6365045",
"0.63537866",
"0.6316992",
"0.6254722",
"0.61298764",
"0.60265553",
"0.60205036",
"0.59701353",
"0.59636456",
"0.59336466",
"0.59... | 0.7613973 | 1 |
Function for returning values in SI units. Returns ~numpy.ndarray Array containing values in SI units (m, rad, rad, m/s, rad/s, rad/s) | def si_values(self):
element_list = [
self.r.to(u.m),
self.theta.to(u.rad),
self.phi.to(u.rad),
self.v_r.to(u.m / u.s),
self.v_t.to(u.rad / u.s),
self.v_p.to(u.rad / u.s),
]
return np.array([e.value for e in element_list], d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit_array(self):\n return self._data_array.values * units(self._units)",
"def si_values(self):\n element_list = [\n self.x.to(u.m),\n self.y.to(u.m),\n self.z.to(u.m),\n self.v_x.to(u.m / u.s),\n self.v_y.to(u.m / u.s),\n self.v... | [
"0.6597943",
"0.649187",
"0.63240147",
"0.6257522",
"0.6255147",
"0.6213908",
"0.6213201",
"0.6091031",
"0.60509723",
"0.58182454",
"0.55522114",
"0.55494267",
"0.55082214",
"0.54812056",
"0.5480648",
"0.54716265",
"0.54494315",
"0.5425861",
"0.53436226",
"0.5266943",
"0.5266... | 0.6856912 | 1 |
Function to convert velocity to cartesian coordinates Returns ~einsteinpy.coordinates.velocity.CartesianDifferential Cartesian representation of the velocity in Spherical Coordinates. | def cartesian_differential(self):
x, y, z, v_x, v_y, v_z = self.convert_cartesian()
return CartesianDifferential(
x * u.m, y * u.m, z * u.m, v_x * u.m / u.s, v_y * u.m / u.s, v_z * u.m / u.s
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _velocity_spherical2cartesian(pos,vel):\n \n #save cartesian position of each particle\n r=pos[:,0]\n theta=pos[:,1]\n phi=pos[:,2]\n\n\n #save cyindrical velocities\n vr=vel[:,0]\n vtheta=vel[:,1]\n vphi=vel[:,2]\n\n\n #compute cartesian velocities\n vx = vr*np.sin(theta)*np.c... | [
"0.75717354",
"0.749493",
"0.73145956",
"0.7314483",
"0.72647214",
"0.7194624",
"0.7028506",
"0.6992018",
"0.6795275",
"0.67766845",
"0.6697479",
"0.6671886",
"0.6653969",
"0.6644937",
"0.65747213",
"0.6547389",
"0.64662033",
"0.6464509",
"0.6451586",
"0.64358544",
"0.6414557... | 0.752729 | 1 |
Function for returning values in SI units. Returns ~numpy.ndarray Array containing values in SI units (m, rad, rad, m/s, rad/s, rad/s) | def si_values(self):
element_list = [
self.r.to(u.m),
self.theta.to(u.rad),
self.phi.to(u.rad),
self.v_r.to(u.m / u.s),
self.v_t.to(u.rad / u.s),
self.v_p.to(u.rad / u.s),
]
return np.array([e.value for e in element_list], d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit_array(self):\n return self._data_array.values * units(self._units)",
"def si_values(self):\n element_list = [\n self.x.to(u.m),\n self.y.to(u.m),\n self.z.to(u.m),\n self.v_x.to(u.m / u.s),\n self.v_y.to(u.m / u.s),\n self.v... | [
"0.6597943",
"0.649187",
"0.63240147",
"0.6257522",
"0.6255147",
"0.6213908",
"0.6213201",
"0.6091031",
"0.60509723",
"0.58182454",
"0.55522114",
"0.55494267",
"0.55082214",
"0.54812056",
"0.5480648",
"0.54716265",
"0.54494315",
"0.5425861",
"0.53436226",
"0.5266943",
"0.5266... | 0.6856912 | 0 |
Function to convert velocity to spherical coordinates Returns ~einsteinpy.coordinates.velocity.SphericalDifferential Spherical representation of the velocity in BoyerLindquist Coordinates. | def spherical_differential(self):
r, theta, phi, v_r, v_t, v_p = self.convert_spherical()
return SphericalDifferential(
r * u.m,
theta * u.rad,
phi * u.rad,
v_r * u.m / u.s,
v_t * u.rad / u.s,
v_p * u.rad / u.s,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _velocity_cylindrical2spherical(pos,vel):\n \n pos_cart=_position_cylindrical2cartesian(pos)\n vel_cart=_velocity_cylindrical2cartesian(pos,vel)\n vel_sph=_velocity_cartesian2spherical(pos_cart,vel_cart)\n\n return vel_sph",
"def _velocity_cartesian2spherical(pos,vel):\n\n \n #save carte... | [
"0.672321",
"0.6639501",
"0.635419",
"0.6353",
"0.6298572",
"0.61776495",
"0.6175607",
"0.61004883",
"0.601829",
"0.5944876",
"0.58419675",
"0.5830476",
"0.5705863",
"0.5697523",
"0.56473684",
"0.5615951",
"0.5607414",
"0.55717176",
"0.55411494",
"0.5518485",
"0.54982543",
... | 0.71730846 | 1 |
remove background from image | def remove_background(img):
mask = np.zeros(img.shape[:2], np.uint8)
bgdModel = np.zeros((1, 65), np.float64)
fgdModel = np.zeros((1, 65), np.float64)
rect = (50, 50, 450, 290)
cv.grabCut(img, mask, rect, bgdModel, fgdModel, 5, cv.GC_INIT_WITH_RECT)
mask2 = np.where((mask == 2)|(mask == 0), 0, 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_background(img):\n\n img = img.astype(np.uint8)\n # Binarize the image using OTSU's algorithm. This is used to find the center\n # of mass of the image, and find the threshold to remove background noise\n threshold, _ = cv2.threshold(img, 0, 255, cv2.THRESH_BINARY + cv2.THRES... | [
"0.7596473",
"0.7517804",
"0.7516415",
"0.7453885",
"0.7361087",
"0.72094864",
"0.7066235",
"0.678405",
"0.6615194",
"0.66145176",
"0.66145176",
"0.6563456",
"0.6563456",
"0.6557612",
"0.65447515",
"0.6516783",
"0.6507971",
"0.64584637",
"0.644767",
"0.6401402",
"0.637965",
... | 0.76232606 | 0 |
Gets the full name of sender. Uses a get request. | def get_full_name(sender, token):
url = "https://graph.facebook.com/v2.6/" + sender + "?fields=first_name,last_name&access_token=" + token
headers = {'content-type': 'application/json'}
response = requests.get(url, headers=headers)
data = json.loads(response.content)
return ''.join(data['first_name'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sender(self):\n key, alt = ('Sender', 'From') if not self.resent else \\\n ('Resent-Sender', 'Resent-From')\n value = self.get(key) or self.get(alt)\n _, addr = getaddresses([value])[0]\n return addr",
"def name(self):\n name = self.__telegram_info.mes... | [
"0.64837116",
"0.6365123",
"0.6297198",
"0.62794083",
"0.62514067",
"0.6221852",
"0.6220194",
"0.6220194",
"0.6200113",
"0.61839944",
"0.617625",
"0.60754865",
"0.6052838",
"0.60519934",
"0.60513854",
"0.6046378",
"0.6003633",
"0.59597677",
"0.5958653",
"0.5941031",
"0.593358... | 0.64352673 | 1 |
if noninteractive is truthy, always return default. intended primarily as a wrapper to preempt attempts to prompt user input. | def catch_interaction(
noninteractive: Any, func: Callable, *args, _default: Any = "", **kwargs
):
if noninteractive:
return _default
return func(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_with_default(prompt, default):\n response = raw_input(\"%s (Default %s) \"%(prompt, default))\n if not response:\n return default\n return response",
"def user_prompt(prompt, default=None):\n prompt = f\"\\n {prompt} [{default}] runs or type an amount: \"\n response = input(prompt... | [
"0.6602298",
"0.64760804",
"0.63981557",
"0.63623685",
"0.6330591",
"0.61910653",
"0.614743",
"0.6139188",
"0.6115366",
"0.6073459",
"0.6009013",
"0.5976778",
"0.59015214",
"0.58762276",
"0.5871548",
"0.5866867",
"0.584779",
"0.58292",
"0.5807008",
"0.5786783",
"0.57751215",
... | 0.67750555 | 0 |
iterable > function returns function that checks if its single argument contains all (or by changing oper, perhaps any) items | def are_in(items: Collection, oper: Callable = and_) -> Callable:
def in_it(container: Collection) -> bool:
inclusion = partial(contains, container)
return reduce(oper, map(inclusion, items))
return in_it | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all(iterable):\n for item in iterable:\n if not item:\n return False\n return True",
"def every(lst, fn):\n return reduce(lambda acc, elem: acc and fn(elem), lst, True)",
"def contains_all(self, *items):\n return all(item in self for item in items)",
"def any(iterable):\... | [
"0.7025728",
"0.68925816",
"0.6799579",
"0.6778553",
"0.67687476",
"0.67141616",
"0.6710857",
"0.6701432",
"0.6675492",
"0.662684",
"0.6607761",
"0.655131",
"0.6546161",
"0.6533346",
"0.65054846",
"0.64836633",
"0.64503634",
"0.6401916",
"0.6399416",
"0.6397432",
"0.6397432",... | 0.7199069 | 0 |
'greedy map' function. map `func` across `iterables` using `mapper` and evaluate with `evaluator`. because we splat the variadic `iterables` argument into `mapper`, behavior is roughly equivalent to `itertools.starmap` if you pass more than one iterable. for cases in which you need a terse or configurable way to map an... | def gmap(
func: Callable,
*iterables: Iterable,
mapper: Callable[[Callable, tuple[Iterable]], Iterable] = map,
evaluator: Callable[[Iterable], Any] = tuple
):
return evaluator(mapper(func, *iterables)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eager_map(func, iterable):\n for _ in map(func, iterable):\n continue",
"def map(iterable, function):\n for x in iterable:\n yield function(x)",
"def map(function, iterable):\n\n return [function(x) for x in iterable]",
"def map(self, fn, *iterables, **kwargs):\n fn = self._... | [
"0.727791",
"0.724331",
"0.7051725",
"0.6898326",
"0.6776462",
"0.6744139",
"0.6707595",
"0.6653942",
"0.6592648",
"0.6541584",
"0.6536001",
"0.6513968",
"0.648274",
"0.64515436",
"0.63744414",
"0.63716865",
"0.62399644",
"0.6196002",
"0.61775833",
"0.6175089",
"0.6169941",
... | 0.8387936 | 0 |
Return the boolean version of a number | def CBool(num):
n = float(num)
if n:
return 1
else:
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test04_boolean_operator(self):\n\n import _cppyy\n number = _cppyy.gbl.number\n\n n = number(20)\n assert n\n\n n = number(0)\n assert not n",
"def bool(self):\n return bool(self.int(2))",
"def _usable_number(self, num):\n real = isinstance(num, numbers.R... | [
"0.67085755",
"0.6664846",
"0.6640058",
"0.6522127",
"0.6354467",
"0.6318844",
"0.6232596",
"0.61336666",
"0.61238825",
"0.61155796",
"0.60645497",
"0.60555285",
"0.59960485",
"0.5991613",
"0.5946587",
"0.59410155",
"0.5910892",
"0.5907826",
"0.5907112",
"0.5859945",
"0.58325... | 0.7226725 | 0 |
Choose from a list of options If the index is out of range then we return None. The list is indexed from 1. | def Choose(index, *args):
if index <= 0:
return None
try:
return args[index - 1]
except IndexError:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def the_option_at_index(index: Union[int, str]) -> \"SelectByIndex\":\n return SelectByIndex(index)",
"def choose_from(self,index_list):\r\n\r\n if len(index_list)==1:\r\n return index_list[0]\r\n\r\n if len(index_list)==2:\r\n while True:\r\n imp_temp = ... | [
"0.6644077",
"0.6347903",
"0.6231553",
"0.6197753",
"0.61250263",
"0.60571647",
"0.6016472",
"0.6006558",
"0.59368837",
"0.5905473",
"0.5868816",
"0.5859146",
"0.58081263",
"0.57136124",
"0.5678431",
"0.5664946",
"0.56619287",
"0.56481266",
"0.5636362",
"0.56212187",
"0.56143... | 0.7803504 | 0 |
Try to create an OLE object This only works on windows! | def CreateObject(classname, ipaddress=None):
if not win32com:
raise ImportError('Not on Windows - cannot create COM object')
if ipaddress:
raise VB2PYNotSupported("DCOM not supported")
return win32com.client.Dispatch(classname) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _winoffice(self):\n # LOG: processing_type property\n self.set_property('processing_type', 'WinOffice')\n oid = oletools.oleid.OleID(self.src_path) # First assume a valid file\n if not olefile.isOleFile(self.src_path):\n # Manual processing, may already count as suspicio... | [
"0.5287344",
"0.51087296",
"0.51052445",
"0.5105081",
"0.5038427",
"0.50332063",
"0.500756",
"0.4986537",
"0.4856805",
"0.48357683",
"0.4802901",
"0.48026037",
"0.48021197",
"0.4792462",
"0.4780404",
"0.47746176",
"0.47093895",
"0.46859106",
"0.46847957",
"0.46789405",
"0.466... | 0.61552715 | 0 |
Return the String associated with an operating system environment variable envstring Optional. String expression containing the name of an environment variable. number Optional. Numeric expression corresponding to the numeric order of the environment string in the environmentstring table. The number argument can be any... | def Environ(envstring):
try:
envint = int(envstring)
except ValueError:
return os.environ.get(envstring, "")
# Is an integer - need to get the envint'th value
try:
return "%s=%s" % (list(os.environ.keys())[envint], list(os.environ.values())[envint])
except IndexError:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getenv_string(setting, default=''):\n return os.environ.get(setting, default)",
"def test_get_environment_string(self):\n pass",
"def _get_env(key: str) -> str:\n value = os.getenv(key)\n assert isinstance(value, str), (\n f\"the {key} environment variable must be set and... | [
"0.6552138",
"0.62165606",
"0.6127461",
"0.61043334",
"0.5977026",
"0.5974327",
"0.5880715",
"0.58638054",
"0.58064455",
"0.57543194",
"0.5713163",
"0.5692808",
"0.56204563",
"0.5599559",
"0.55874664",
"0.5569792",
"0.5565246",
"0.5565246",
"0.55345047",
"0.5521654",
"0.55209... | 0.780673 | 0 |
Determine if we reached the end of file for the particular channel | def EOF(channel):
return VBFiles.EOF(channel) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reached_end_of_stream(self):\n pass",
"def eof_check(self) -> bool:\n eof = False\n curr_pos = self.fileobject.tell()\n # print(curr_pos, self.st_size)\n chunk = self.fileobject.read(25)\n if chunk == '':\n # Is there something on the back burner??\n ... | [
"0.66775554",
"0.6652134",
"0.6621471",
"0.6582723",
"0.65502644",
"0.65502644",
"0.65502644",
"0.65502644",
"0.65212584",
"0.64770806",
"0.6436078",
"0.6431244",
"0.6417623",
"0.63535255",
"0.6350785",
"0.63307154",
"0.61963063",
"0.616728",
"0.6133811",
"0.611205",
"0.60584... | 0.72668666 | 0 |
Return the length of a given file | def FileLen(filename):
return os.stat(str(filename))[6] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _filelength(self):\r\n with open(self.fileName, 'rb') as f:\r\n f.seek(0, 2) # move to end of file\r\n length = f.tell() # get current position\r\n return length",
"def findFLength(filename):\n f = os.popen('wc -l < {}'.format(filename))\n return int(f.read())",
... | [
"0.8291489",
"0.8033439",
"0.80026686",
"0.79879576",
"0.7905295",
"0.78845304",
"0.7876845",
"0.78724664",
"0.7828686",
"0.7820954",
"0.78019077",
"0.7798586",
"0.77813584",
"0.7755042",
"0.7709965",
"0.7709965",
"0.7709965",
"0.77049273",
"0.7685765",
"0.76809627",
"0.76497... | 0.834456 | 0 |
Returns a zerobased array containing subset of a string array based on a specified filter criteria | def Filter(sourcesarray, match, include=1):
if include:
return Array(*[item for item in sourcesarray if item.find(match) > -1])
else:
return Array(*[item for item in sourcesarray if item.find(match) == -1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_fn(arr):\n return lambda l: ([n for n in arr if n == l])",
"def filter(self, filterarray):\n return FeatureSet(list(np.array(self)[np.array(filterarray)]))",
"def subset(arr, start, end):\n return [[row_data for row_data in row[start[1]:end[1]]] for row in arr[start[0]:end[0]]]",
"def... | [
"0.5791858",
"0.57571936",
"0.569493",
"0.56764555",
"0.56472826",
"0.5434943",
"0.5370937",
"0.5358635",
"0.52934223",
"0.5246935",
"0.52461225",
"0.5188089",
"0.51835763",
"0.5115934",
"0.5108654",
"0.50504124",
"0.5034765",
"0.50195634",
"0.50031567",
"0.49780133",
"0.4975... | 0.59934235 | 0 |
Determine if an object is an array | def IsArray(obj):
return isinstance(obj, (list, tuple)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_arraylike(obj):\n if isinstance(obj, list):\n return True\n elif isinstance(obj, np.ndarray):\n return True\n elif isinstance(obj, pd.Series):\n return True\n elif isinstance(obj, pd.DataFrame):\n return True\n return False",
"def is_array(schema_obj):\n\n if is... | [
"0.8131859",
"0.78075755",
"0.77648115",
"0.774824",
"0.76568",
"0.75508946",
"0.7546086",
"0.74527085",
"0.7409406",
"0.73134905",
"0.71920586",
"0.7132876",
"0.70407593",
"0.70193404",
"0.6981981",
"0.68952763",
"0.6841536",
"0.6817918",
"0.67961663",
"0.67788136",
"0.67067... | 0.8533337 | 0 |
Return the left most characters in the text | def Left(text, number):
return text[:number] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def characters_left(self):\r\n return self.max_chars - len(self.variable.get())",
"def Right(text, number):\n return text[-number:]",
"def keyword_length(text):\n text = scrub_string(text)\n a = [fabs(IC(text, ncol) - ENGLISH_IC) for ncol in range(1, MAX_LEN)]\n return a.index(min(a)) + 1",
... | [
"0.76972735",
"0.6075009",
"0.60736424",
"0.6047909",
"0.6003288",
"0.5963332",
"0.5958215",
"0.5919674",
"0.59092534",
"0.58404374",
"0.5834725",
"0.5794999",
"0.579165",
"0.57874477",
"0.5779034",
"0.5778344",
"0.57569116",
"0.5754645",
"0.5738545",
"0.57297117",
"0.5723335... | 0.7287347 | 1 |
Return true if the text matches the pattern The pattern is a string containing wildcards = any string of characters ? = any one character Fortunately, the fnmatch library module does this for us! | def Like(text, pattern):
return fnmatch.fnmatch(text, pattern) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regex_match(text, pattern):\n try:\n pattern = re.compile(\n pattern,\n flags=re.IGNORECASE + re.UNICODE + re.MULTILINE,\n )\n except BaseException:\n return False\n return pattern.search(text) is not None",
"def match(cls, t... | [
"0.7849038",
"0.76907206",
"0.76165885",
"0.73174125",
"0.7219586",
"0.7164653",
"0.68953913",
"0.6827941",
"0.67844343",
"0.6763894",
"0.6674704",
"0.6618624",
"0.66003686",
"0.6596534",
"0.6573882",
"0.6555509",
"0.655082",
"0.65427655",
"0.65384084",
"0.65255356",
"0.65145... | 0.82227486 | 0 |
Return True if X implies Y Performs a bitwise comparison of identically positioned bits and sets corresponding bit in the output. | def Imp(x, y):
ix, iy = int(x), int(y)
if not (ix or iy):
result = 1
else:
result = 0
while ix or iy:
# Shift result by one bit
result = result << 1
#
# Get the bits for comparison
x_bit1 = ix & 1
y_bit1 = iy & 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __and__(self, other):\n return BitBoard(self.num & other.num)",
"def __iand__(self, other):\n self.truths = self.truths | other.truths\n return self",
"def __or__(self, y):\n return self.__and__(y) ^ self ^ y",
"def __and__(self, other):\n return np.logical_and(self.arr... | [
"0.5854761",
"0.584245",
"0.58119255",
"0.57361525",
"0.57329947",
"0.57323116",
"0.5731651",
"0.5688032",
"0.5653026",
"0.56213224",
"0.5614277",
"0.5599483",
"0.55569243",
"0.5550215",
"0.55319524",
"0.5531421",
"0.5518942",
"0.5518383",
"0.5518057",
"0.5518057",
"0.5515992... | 0.62820095 | 0 |
Load an image as a bitmap for display in a BitmapImage control | def LoadPicture(filename):
return Bitmap(filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def BitmapFromImage(*args, **kwargs):\n val = _gdi_.new_BitmapFromImage(*args, **kwargs)\n return val",
"def load_image(path_to_image, image_name):\n print(\"Loading: \", path_to_image + image_name, \" ...\")\n return Image.open(path_to_image + image_name)",
"def set_image(self, image_URL, bkg = No... | [
"0.6720157",
"0.6664427",
"0.66112494",
"0.6585068",
"0.6558995",
"0.655867",
"0.65482175",
"0.65217286",
"0.6480828",
"0.6468993",
"0.6439372",
"0.64379865",
"0.6414927",
"0.6369924",
"0.6343527",
"0.63117355",
"0.62969905",
"0.625913",
"0.6219303",
"0.621666",
"0.62067175",... | 0.7395635 | 0 |
Do a VB LSet Left aligns a string within a string variable, or copies a variable of one userdefined type to another variable of a different userdefined type. LSet stringvar = string LSet replaces any leftover characters in stringvar with spaces. If string is longer than stringvar, LSet places only the leftmost characte... | def LSet(var, value):
return value[:len(var)] + " " * (len(var) - len(value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RSet(var, value):\n return \" \" * (len(var) - len(value)) + value[:len(var)]",
"def setto(self, s):\n\t\tlength = len(s)\n\t\tself.b = self.b[:self.j+1] + s + self.b[self.j+length+1:]\n\t\tself.k = self.j + length",
"def string_swap(seq1, seq2):\n\n l1 = len(seq1)\n l2 = len(seq2)\n if l1 >= l... | [
"0.5684025",
"0.52701616",
"0.5119802",
"0.5114327",
"0.50312454",
"0.5026097",
"0.48728633",
"0.48196828",
"0.47808087",
"0.46736914",
"0.46631265",
"0.46533147",
"0.46418238",
"0.4633189",
"0.46091893",
"0.457231",
"0.45466822",
"0.45454702",
"0.45427588",
"0.45427588",
"0.... | 0.6876957 | 0 |
Returns a string in which a specified substring has been replaced with another substring a specified number of times The return value of the Replace function is a string, with substitutions made, that begins at the position specified by start and and concludes at the end of the expression string. It is not a copy of th... | def Replace(expression, find, replace, start=1, count=-1):
if find:
return expression[:start - 1] + expression[start - 1:].replace(find, replace, count)
else:
return expression | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def REPLACE(old_text, start_num, num_chars, new_text):\n if start_num < 1:\n raise ValueError(\"start_num invalid\")\n return old_text[:start_num - 1] + new_text + old_text[start_num - 1 + num_chars:]",
"def replace_in_string(string, length, substring, idx):\n return string[:idx]+substring+string[idx+len... | [
"0.69472235",
"0.6930251",
"0.66695154",
"0.64962995",
"0.63499135",
"0.6083488",
"0.6069293",
"0.6031655",
"0.6022877",
"0.598244",
"0.5966292",
"0.5940701",
"0.5935663",
"0.5875606",
"0.58752525",
"0.58342385",
"0.57794666",
"0.57153463",
"0.5702825",
"0.56442857",
"0.56126... | 0.7357595 | 0 |
Return the right most characters in the text | def Right(text, number):
return text[-number:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def characters_left(self):\r\n return self.max_chars - len(self.variable.get())",
"def findAlphabeticallyLastWord(text):\n return max(text.split(' '))",
"def get_max_character(strings):\n m=0\n for string in strings:\n for char in string:\n if char>m:\n m=char\n return m",
"def lo... | [
"0.66617775",
"0.6458333",
"0.62414336",
"0.61733127",
"0.6130016",
"0.6114353",
"0.611083",
"0.60179204",
"0.59715396",
"0.59695387",
"0.59517705",
"0.59111524",
"0.59110934",
"0.5877624",
"0.58610624",
"0.5852691",
"0.58513427",
"0.5844956",
"0.58354264",
"0.583465",
"0.583... | 0.67059237 | 0 |
Do a VB RSet Right aligns a string within a string variable. RSet stringvar = string If stringvar is longer than string, RSet replaces any leftover characters in stringvar with spaces, back to its beginning. | def RSet(var, value):
return " " * (len(var) - len(value)) + value[:len(var)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LSet(var, value):\n return value[:len(var)] + \" \" * (len(var) - len(value))",
"def rstring(string):\n return RTEXT + string + NTEXT",
"def _padright(width, s):\n fmt = \"{0:<%ds}\" % width\n return fmt.format(s)",
"def rightpad(field, length):\r\n field = str(field)\r\n field_length =... | [
"0.66794926",
"0.5602928",
"0.5465059",
"0.52692467",
"0.52135104",
"0.5187947",
"0.5178085",
"0.51736885",
"0.51162773",
"0.50952494",
"0.50288147",
"0.5014927",
"0.5000405",
"0.4966606",
"0.49568656",
"0.49412823",
"0.4936924",
"0.49336472",
"0.49120805",
"0.4890213",
"0.48... | 0.7263928 | 0 |
Delete a setting in the central setting file | def DeleteSetting(appname, section, key):
settings = _OptionsDB(appname)
settings.delete(section, key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delsetting(name):\r\n if '__delattr__' in settings.__class__.__dict__:\r\n delattr(settings, name)\r\n else:\r\n delattr(settings._wrapped, name)",
"def clearSetting(self, name: unicode) -> None:\n ...",
"def remove_setting(self, category, setting):\n category_instance = s... | [
"0.72362244",
"0.7093934",
"0.66168183",
"0.6608237",
"0.65604854",
"0.64848113",
"0.6457743",
"0.63939166",
"0.635336",
"0.6336297",
"0.6328854",
"0.623674",
"0.61954266",
"0.6193954",
"0.6153951",
"0.612454",
"0.604961",
"0.60189205",
"0.6010476",
"0.5962726",
"0.5918145",
... | 0.754308 | 0 |
Split a string using the delimiter If the optional limit is present then this defines the number of items returned. The compare is used for different string comparison types in VB, but this is not implemented at the moment | def Split(text, delimiter=" ", limit=-1, compare=None):
if compare is not None:
raise VB2PYNotSupported("Compare options for Split are not currently supported")
#
if limit == 0:
return VBArray(0)
elif limit > 0:
return Array(*str(text).split(delimiter, limit - 1))
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(self, sep=None, maxsplit=None):\n return split(self, sep, maxsplit)",
"def split(self, string, maxsplit=MAX_INT, include_separators=False):\n return self._split(\n string, maxsplit=maxsplit, include_separators=include_separators\n )",
"def explode(delim, val, limit = N... | [
"0.6533399",
"0.64230263",
"0.6183412",
"0.60216355",
"0.5943199",
"0.5683144",
"0.5631569",
"0.55919874",
"0.5572784",
"0.5486138",
"0.5480019",
"0.5479996",
"0.54729277",
"0.5463248",
"0.54153234",
"0.5413893",
"0.5308845",
"0.5301453",
"0.5294461",
"0.52909225",
"0.528777"... | 0.7360037 | 0 |
Choose from a list of expression each with its own condition The arguments are presented as a sequence of condition, expression pairs and the first condition that returns a true causes its expression to be returned. If no conditions are true then the function returns None | def Switch(*args):
arg_list = list(args)
arg_list.reverse()
#
while arg_list:
cond, expr = arg_list.pop(), arg_list.pop()
if cond:
return expr
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_if(cond,seq):\n for x in seq:\n if cond(x): return x\n return None",
"def find_if(cond,seq):\n for x in seq:\n if cond(x): return x\n return None",
"def or_list(conditionList):\n return functools.reduce(numpy.logical_or, conditionList)",
"def select(condlist, choicelist,... | [
"0.6422477",
"0.6422477",
"0.6359925",
"0.635987",
"0.6204265",
"0.6166474",
"0.6049754",
"0.5968415",
"0.59649223",
"0.59408706",
"0.58751965",
"0.5863526",
"0.58623445",
"0.5844146",
"0.57734656",
"0.5697268",
"0.56084704",
"0.5544484",
"0.5540427",
"0.55290014",
"0.5500933... | 0.65245444 | 0 |
Return the value of a string This function finds the longest leftmost number in the string and returns it. If there are no valid numbers then it returns 0. The method chosen here is very poor we just keep trying to convert the string to a float and just use the last successful as we increase the size of the string. A R... | def Val(text):
best = 0
for idx in range(len(text)):
try:
best = float(text[:idx + 1])
except ValueError:
pass
return best | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_number(s:str):\n array = re.findall(r'[0-9]+', s)\n if array.__len__() is 0:\n return -1\n return int(array[-1])",
"def _get_number_from_string(x):\n try:\n return float(x)\n except ValueError:\n raise ValueError('Unknown element')",
"def float(s... | [
"0.66451454",
"0.64589363",
"0.63910717",
"0.6363433",
"0.63494194",
"0.630394",
"0.61770207",
"0.616602",
"0.6151756",
"0.61081976",
"0.60855013",
"0.6082988",
"0.60598946",
"0.6020905",
"0.60046595",
"0.5965904",
"0.5914045",
"0.58885247",
"0.58840555",
"0.58837414",
"0.584... | 0.7048725 | 0 |
Return arguments passed in an event VB Control events have parameters passed in the call, eg MouseMove(Button, Shift, X, Y). In vb2py.PythonCard the event parameters are all passed as a single event object. We can easily unpack the attributes back to the values in the Event Handler but we also have to account for the f... | def vbGetEventArgs(names, arguments):
# arguments is the *args tuple
#
# Is there only one parameter
if len(arguments) == 1:
# Try to unpack names from this argument
try:
ret = []
for name in names:
if name.endswith("()"):
ret.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convert_args(self, expr, args, kwargs):\n assert expr is not None\n\n if not kwargs:\n return args\n\n if kwargs and not isinstance(expr, Function):\n raise Exception(\"can only supply keyword parameters for a \"\n \"relay.Function, found {... | [
"0.5983954",
"0.58679104",
"0.5814009",
"0.55884343",
"0.5439283",
"0.5410738",
"0.53881556",
"0.5294634",
"0.52934223",
"0.5280633",
"0.52511024",
"0.5245851",
"0.52443963",
"0.5239429",
"0.5231915",
"0.5231915",
"0.5226041",
"0.5197778",
"0.51946074",
"0.5181564",
"0.517265... | 0.69104767 | 0 |
Return the AddressOf a variable This does not work in Python and likely the code using it is going to need significant work so we just throw an error here. | def AddressOf(obj):
raise NotImplementedError('AddressOf does not work in Python and code will likely need refactoring') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LocalAddress(self) -> _n_5_t_0:",
"def get_address_value(obj):\n no_dynamic = obj.GetDynamicValue(lldb.eNoDynamicValues)\n \"\"\":type: lldb.SBValue\"\"\"\n address = no_dynamic.GetAddress()\n \"\"\":type: lldb.SBAddress\"\"\"\n address_value = address.GetFileAddress()\n \"\"\":type: int\"\... | [
"0.6837938",
"0.67366517",
"0.6421531",
"0.61839086",
"0.6139431",
"0.60965663",
"0.6088812",
"0.6042399",
"0.6003365",
"0.5988634",
"0.5901362",
"0.5862584",
"0.58369744",
"0.58360106",
"0.58224577",
"0.5810336",
"0.5739616",
"0.56862915",
"0.56791055",
"0.56228083",
"0.5603... | 0.69282764 | 0 |
Close any pipes we have to the process (both input and output) and wait for it to exit. If cancelled, kills the process and waits for it to finish exiting before propagating the cancellation. | async def aclose(self):
with _core.open_cancel_scope(shield=True):
if self.stdin is not None:
await self.stdin.aclose()
if self.stdout is not None:
await self.stdout.aclose()
if self.stderr is not None:
await self.stderr.aclose(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cleanup_proc(self):\n logger.debug(\"{}: Cleaning up and waiting for process to exit\".format(\n self))\n try:\n self._loop.remove_reader(self._proc.stdout)\n self._proc.stdout.close()\n self... | [
"0.6373793",
"0.62173724",
"0.6169654",
"0.61305934",
"0.60700935",
"0.59654534",
"0.5956748",
"0.5948705",
"0.5810264",
"0.5779637",
"0.5764489",
"0.57414836",
"0.5654102",
"0.563886",
"0.5624931",
"0.5586638",
"0.55606866",
"0.5533835",
"0.54964846",
"0.5493101",
"0.5481666... | 0.63417107 | 1 |
Fetch the permission for the specified team. | def get(self, namespace_name, repository_name, teamname):
logger.debug(
"Get repo: %s/%s permissions for team %s", namespace_name, repository_name, teamname
)
role = model.get_repo_role_for_team(teamname, namespace_name, repository_name)
return role.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_team(self, filter_) -> Optional[Team]:\n have_access_to_all_data = current_user.has_role(\n \"superadmin\"\n ) or current_user.has_role(\"dataprovider\")\n if have_access_to_all_data:\n return super()._get_team(filter_)\n\n return current_user.writable_tea... | [
"0.6106908",
"0.5748608",
"0.56881076",
"0.56774604",
"0.55650204",
"0.55000824",
"0.5437011",
"0.5423022",
"0.5415314",
"0.537421",
"0.5367137",
"0.536253",
"0.53582126",
"0.5344388",
"0.5340846",
"0.5338855",
"0.53167564",
"0.52845156",
"0.5233721",
"0.5189439",
"0.51863176... | 0.58408916 | 1 |
Update the existing team permission. | def put(self, namespace_name, repository_name, teamname):
new_permission = request.get_json()
logger.debug("Setting permission to: %s for team %s", new_permission["role"], teamname)
try:
perm = model.set_repo_permission_for_team(
teamname, namespace_name, repository... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch(self, team_id, project_id):\n try:\n role = request.get_json(force=True)[\"role\"]\n except DataError as e:\n current_app.logger.error(f\"Error validating request: {str(e)}\")\n return {\"Error\": str(e), \"SubCode\": \"InvalidData\"}, 400\n\n try:\n ... | [
"0.6878937",
"0.6413856",
"0.63367105",
"0.6301946",
"0.6131176",
"0.6117391",
"0.6080835",
"0.6073183",
"0.60508394",
"0.5943088",
"0.5899792",
"0.5887498",
"0.5872705",
"0.58438593",
"0.58361334",
"0.5809778",
"0.5783322",
"0.57781184",
"0.5766685",
"0.57608736",
"0.5757116... | 0.7250105 | 0 |
add event 'event', which is of type event to minheap of events assign an id to it return the assigned id | def addEvent(self, event):
event.__id=id
id+=1
self.addToHeap(event)
return event.__id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_id(self, event_name):\n try:\n event_id = self.gui_event_ids[event_name]\n except KeyError:\n event_id = len(self.gui_events)\n self.gui_event_ids[event_name] = event_id\n self.gui_events.append(event_name)\n if event_id >= 16383:\n ... | [
"0.64335954",
"0.6268853",
"0.61110896",
"0.61066127",
"0.6027039",
"0.5884291",
"0.587974",
"0.5795214",
"0.5773811",
"0.57574904",
"0.56374335",
"0.56098413",
"0.56089914",
"0.5601371",
"0.5556427",
"0.5553871",
"0.5553545",
"0.55280185",
"0.5497093",
"0.5451976",
"0.544849... | 0.82262385 | 0 |
Given `src_lines`, a list of lines of a single record, this will instantiate and populate an object corresponding to the data. | def __init__(self, src_lines):
self.study_id = None
self.citation = None
self.abstract = None
self.authors = []
self.study_matrices = {}
self.history_date = None
self.history_time = None
self.history_person = None
self.history_event = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_lines(cls, lines: List[str], mode: str):\n for line in lines:\n if line.startswith('Original Input'):\n _input = line[line.find(':') + 1 :].strip()\n elif line.startswith('Predicted Str'):\n pred = line[line.find(':') + 1 :].strip()\n e... | [
"0.6313051",
"0.614401",
"0.60776645",
"0.60666007",
"0.5890082",
"0.5835735",
"0.57116175",
"0.56871676",
"0.56600964",
"0.5596233",
"0.5578453",
"0.556857",
"0.556857",
"0.556857",
"0.55126864",
"0.5510738",
"0.54882395",
"0.54770136",
"0.54094434",
"0.5392297",
"0.53723717... | 0.7402475 | 0 |
Return a string representing the key sequence used to get the specified message using the given dictionary | def messagetokeystring(message, keydict):
return ''.join([' ' + str(keydict[char])
if i - 1 >= 0
and str(keydict[char])[0]
== str(keydict[message[i - 1]])[0]
else str(keydict[char])
for i, char in enumerate(mes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _GetKeyString(self):",
"def _GetKeyString(self):",
"def keysequence(value):\r\n return value.toString()",
"def _get_key(self, val: Span) -> str:\n return \"\".join(val._.phonemes)",
"def create_key(message, key):\n if len(key) > len(message):\n return key[0:len(message)]\n ne... | [
"0.6046165",
"0.6046165",
"0.59045553",
"0.5791385",
"0.5728902",
"0.56914884",
"0.56797653",
"0.56692123",
"0.5655976",
"0.56355053",
"0.5619594",
"0.5616496",
"0.55933964",
"0.5576578",
"0.5567661",
"0.55604446",
"0.5541098",
"0.5538641",
"0.5535081",
"0.5518018",
"0.550610... | 0.7381706 | 0 |
Return a dict mapping each alphabet letter to the corresponding T9 number sequence | def getT9dict():
T9dict = {}
all_letters = string.lowercase
T9dict.update(mapkeystoletter(2, all_letters[0:3]))
T9dict.update(mapkeystoletter(3, all_letters[3:6]))
T9dict.update(mapkeystoletter(4, all_letters[6:9]))
T9dict.update(mapkeystoletter(5, all_letters[9:12]))
T9dict.update(ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetAlphabet(self):\n alphabet = list(self._charAlphabet) #Creates a list of the alphabet characters\n numbers = [i for i in range(0,26)] #Creates a list of numbers up to 25\n numberOff = dict( zip(alphabet, numbers)) #Pairs each character with a number in a chronological sequence to number... | [
"0.6782532",
"0.6357176",
"0.63480806",
"0.6239313",
"0.61492985",
"0.613621",
"0.6120783",
"0.6088525",
"0.59723955",
"0.59683824",
"0.5959332",
"0.59540445",
"0.59540445",
"0.59315383",
"0.59235865",
"0.5881295",
"0.58502054",
"0.5826376",
"0.5803708",
"0.5794347",
"0.56974... | 0.7683451 | 0 |
Return a dict mapping each key appropriately to each letter such that each letter is mapped to a string containing the key n number of times, where n is the position of the letter in the given letters string | def mapkeystoletter(key, letters):
return dict((v, ''.join([str(key) for i in range(k)]))
for k, v in enumerate(letters, 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dictionaries(chars):\n return dict((c, i) for i, c in enumerate(chars)), dict((i, c) for i, c in enumerate(chars))",
"def english_dictionary(letters, n): \n assert (isinstance(letters, list)), \"First argument must be a list\"\n assert (isinstance(n, int)), \"Second argument must be an intege... | [
"0.72586536",
"0.7226152",
"0.71658975",
"0.7153065",
"0.71221644",
"0.7014463",
"0.6943903",
"0.68634564",
"0.6783479",
"0.6693765",
"0.66723007",
"0.6574703",
"0.65711844",
"0.6381239",
"0.63740134",
"0.63730866",
"0.63467705",
"0.6322638",
"0.62977695",
"0.6290113",
"0.627... | 0.7698916 | 0 |
Test that the equality dunder method is correct for Resources. | def test_eq(self):
r1 = Resources(4, 2, {"Hadamard": 1, "CNOT": 1}, {1: 1, 2: 1}, 2, Shots(100))
r2 = Resources(4, 2, {"Hadamard": 1, "CNOT": 1}, {1: 1, 2: 1}, 2, Shots(100))
r3 = Resources(4, 2, {"CNOT": 1, "Hadamard": 1}, {2: 1, 1: 1}, 2, Shots(100)) # all equal
r4 = Resources(1, 2, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testEquality(self):\n pass",
"def __eq__(self, other: 'Resource') -> bool:\n if not isinstance(other, self.__class__):\n return False\n return self.__dict__ == other.__dict__",
"def assert_equal_resource(res1, res2):\n assert isinstance(res1, FakedBaseResource)\n asser... | [
"0.7314152",
"0.72189605",
"0.7174685",
"0.7077528",
"0.6794791",
"0.6717936",
"0.67031395",
"0.66849434",
"0.6618718",
"0.6528539",
"0.6495091",
"0.6438724",
"0.6425555",
"0.63503706",
"0.63453996",
"0.6344413",
"0.63160825",
"0.62906426",
"0.6265871",
"0.62443507",
"0.62326... | 0.73252475 | 0 |
Test that a not type error is raised if the class is initialized without a `resources` method. | def test_raise_not_implemented_error(self):
class CustomOpNoResource(ResourcesOperation): # pylint: disable=too-few-public-methods
num_wires = 2
class CustomOPWithResources(ResourcesOperation): # pylint: disable=too-few-public-methods
num_wires = 2
def resources(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_instance(self):\n with self.assertRaises(exceptions.NoInitiation):\n Config()",
"def test_cannot_instantiate(self):\n with self.assertRaises(TypeError):\n Distribution()",
"def raise_init(cls):\r\n def init(self):\r\n raise TypeError(\"Instance crea... | [
"0.6509014",
"0.6454623",
"0.64346546",
"0.64189184",
"0.6415098",
"0.6371529",
"0.6346806",
"0.63281137",
"0.63169825",
"0.63013685",
"0.6288929",
"0.62795115",
"0.6273733",
"0.6269042",
"0.6252056",
"0.62284595",
"0.62220055",
"0.622168",
"0.6193215",
"0.61502784",
"0.61481... | 0.7228034 | 0 |
Test the count resources method. | def test_count_resources(ops_and_shots, expected_resources):
ops, shots = ops_and_shots
computed_resources = _count_resources(QuantumScript(ops=ops, shots=shots))
assert computed_resources == expected_resources | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_resource_license_resource_count_list(self):\n pass",
"def count(self, resource):\n return len(self.all(resource))",
"def test_get_resource_license_resource_count_by_moid(self):\n pass",
"def test_count(self):\n self._test_count_func(count)",
"def test_all_count(self... | [
"0.780781",
"0.7554697",
"0.72033167",
"0.71104103",
"0.7008526",
"0.690465",
"0.6903304",
"0.6899983",
"0.679157",
"0.67801946",
"0.6760998",
"0.6760998",
"0.6760998",
"0.6760998",
"0.67398643",
"0.6697201",
"0.66854256",
"0.66848224",
"0.6672156",
"0.6637181",
"0.6620758",
... | 0.76768863 | 1 |
Clamp value between mini and maxi | def clamp(value, mini, maxi):
if value < mini:
return mini
elif maxi < value:
return maxi
else:
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clamp(value, mn, mx):\n\n return max(min(value, mx), mn)",
"def clamp(n, min_, max_):\n return max(min(max_,n),min_)",
"def clamp(self, value, minv, maxv):\n if value > maxv:\n return maxv\n if value < minv:\n return minv\n return value",
"def clamp(value,... | [
"0.80389065",
"0.7782929",
"0.77185524",
"0.76578045",
"0.76456124",
"0.74849397",
"0.74809366",
"0.7454212",
"0.73672295",
"0.7320122",
"0.72616553",
"0.7163171",
"0.7146835",
"0.71296495",
"0.71129787",
"0.71004564",
"0.7080147",
"0.70638114",
"0.70379007",
"0.70337254",
"0... | 0.8780609 | 0 |
Show a saved search. | def show(ctx, saved_search_id):
r = SavedSearch(ctx.obj['TOKEN'], ctx.obj['DEBUG']).show(saved_search_id)
click.echo(json_dumps(r, ctx.obj['PRETTY'])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_save_search(self, event):\r\n\r\n search = self.m_searchfor_textbox.GetValue()\r\n if search == \"\":\r\n errormsg(_(\"There is no search to save!\"))\r\n return\r\n dlg = SaveSearchDialog(self, search, self.m_regex_search_checkbox.GetValue())\r\n dlg.ShowMo... | [
"0.684537",
"0.66723734",
"0.65726525",
"0.6466039",
"0.62601984",
"0.6245371",
"0.6242621",
"0.62300265",
"0.6214036",
"0.6172219",
"0.6159994",
"0.6143998",
"0.60995394",
"0.6086033",
"0.60684097",
"0.6028625",
"0.59793204",
"0.5916503",
"0.5916453",
"0.5899437",
"0.583377"... | 0.79775244 | 0 |
Create a saved search. | def create(ctx, payload):
payload = parse_payload(ctx, payload)
r = SavedSearch(ctx.obj['TOKEN'], ctx.obj['DEBUG']).create(payload)
click.echo(json_dumps(r, ctx.obj['PRETTY'])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createSearch(self, authenticationToken, search):\r\n pass",
"def saveSearch(self, queryString, searchName):\n facade = self._getFacade()\n if facade.noSaveSearchProvidersPresent():\n return DirectResponse.succeed()\n\n creator = self._getLoggedinUserId()\n\n # save t... | [
"0.6784601",
"0.6628552",
"0.65851784",
"0.6335346",
"0.6261639",
"0.6222785",
"0.61650014",
"0.6154353",
"0.6143282",
"0.60384107",
"0.6017802",
"0.6017802",
"0.60088694",
"0.59932554",
"0.5887634",
"0.58723336",
"0.586306",
"0.5861253",
"0.5856038",
"0.5761087",
"0.57178247... | 0.7173232 | 0 |
Update a saved search. | def update(ctx, saved_search_id, payload):
payload = parse_payload(ctx, payload)
r = SavedSearch(ctx.obj['TOKEN'], ctx.obj['DEBUG']).update(payload)
click.echo(json_dumps(r, ctx.obj['PRETTY'])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateSavedSearch(self, searchName, queryString):\n facade = self._getFacade()\n if facade.noSaveSearchProvidersPresent():\n return DirectResponse.succeed()\n\n # save the search\n facade.updateSavedSearch(searchName, queryString)\n return DirectResponse.succeed()"... | [
"0.7534025",
"0.7301899",
"0.69800997",
"0.68826675",
"0.67916095",
"0.62492573",
"0.62392795",
"0.62191606",
"0.6211305",
"0.60335565",
"0.5985524",
"0.59692556",
"0.59547627",
"0.5949781",
"0.59346545",
"0.5899091",
"0.58907944",
"0.5874972",
"0.5809071",
"0.5713413",
"0.57... | 0.7637842 | 0 |
Delete a saved search. | def delete(ctx, saved_search_id):
r = SavedSearch(ctx.obj['TOKEN'], ctx.obj['DEBUG']).delete(saved_search_id)
click.echo(json_dumps(r, ctx.obj['PRETTY'])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeSavedSearch(self, searchName):\n facade = self._getFacade()\n if facade.noSaveSearchProvidersPresent():\n return DirectResponse.succeed()\n\n # save the search\n facade.removeSavedSearch(searchName)\n return DirectResponse.succeed()",
"def delete(self):\n ... | [
"0.71051794",
"0.6984621",
"0.6617019",
"0.64270055",
"0.62136894",
"0.6194005",
"0.6189915",
"0.61731374",
"0.6161926",
"0.61286575",
"0.6077793",
"0.60397846",
"0.6024016",
"0.6024016",
"0.6024016",
"0.6024016",
"0.60068905",
"0.59796524",
"0.59796524",
"0.59375215",
"0.591... | 0.8261131 | 0 |
Extend the size of an image by adding borders. The sides argument defaults to | def add_border(image: np.ndarray, width=2, value=0, sides='ltrb'):
result = image
sides = sides.upper()
if 'L' in sides: result = add_left(result, width, value)
if 'T' in sides: result = add_top(result, width, value)
if 'R' in sides: result = add_right(result, width, value)
if 'B' in sides: resu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_border(original_img,border_size):\r\n new_image=SimpleImage.blank(2 * border_size + original_img.width ,2 * border_size + original_img.height )\r\n\r\n \"\"\"\r\n Task 2: Creating black border\r\n \r\n \"\"\"\r\n for y in range(new_image.height):\r\n for x in range(new_image.width)... | [
"0.6268577",
"0.62324625",
"0.607379",
"0.597834",
"0.5885386",
"0.58061814",
"0.5716965",
"0.5715706",
"0.5707968",
"0.5658754",
"0.5645058",
"0.56255275",
"0.55907595",
"0.5515744",
"0.543367",
"0.53568774",
"0.5346766",
"0.53422046",
"0.53231376",
"0.5271381",
"0.52616733"... | 0.68208927 | 0 |
Horizontally concatenate a list of images with a border. This is similar to numpy's hstack except that it adds a border around each image. The borders can be controlled with the optional border_width and border_value arguments. See also vstack. | def hstack(images, border_width=2, border_value=0):
if border_width == 0: return np.hstack(images)
T, V = border_width, border_value
result = []
for image in images[:-1]:
result.append(add_border(image, T, V, 'LTB'))
result.append(add_border(images[-1], T, V))
return np.hstack(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vstack(images, border_width=2, border_value=0):\n if border_width == 0: return np.vstack(images)\n T, V = border_width, border_value\n result = []\n for image in images[:-1]:\n result.append(add_border(image, T, V, 'LTR'))\n result.append(add_border(images[-1], T, V))\n return np.vstac... | [
"0.7960261",
"0.69222003",
"0.67834777",
"0.6604934",
"0.6577598",
"0.6484754",
"0.6211543",
"0.61573285",
"0.6119428",
"0.61114365",
"0.61083424",
"0.5949176",
"0.5925623",
"0.59040356",
"0.5842073",
"0.5829911",
"0.581459",
"0.58126813",
"0.5722141",
"0.56652904",
"0.564144... | 0.83008605 | 0 |
Vertically concatenate a list of images with a border. This is similar to numpy's vstack except that it adds a border around each image. The borders can be controlled with the optional border_width and border_value arguments. See also hstack. | def vstack(images, border_width=2, border_value=0):
if border_width == 0: return np.vstack(images)
T, V = border_width, border_value
result = []
for image in images[:-1]:
result.append(add_border(image, T, V, 'LTR'))
result.append(add_border(images[-1], T, V))
return np.vstack(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hstack(images, border_width=2, border_value=0):\n if border_width == 0: return np.hstack(images)\n T, V = border_width, border_value\n result = []\n for image in images[:-1]:\n result.append(add_border(image, T, V, 'LTB'))\n result.append(add_border(images[-1], T, V))\n return np.hstac... | [
"0.7994192",
"0.62722176",
"0.6255651",
"0.61048955",
"0.61031604",
"0.6095366",
"0.6059274",
"0.60569215",
"0.6039915",
"0.58855444",
"0.584056",
"0.5793362",
"0.5777069",
"0.57281417",
"0.57201326",
"0.56275475",
"0.5617591",
"0.5614883",
"0.5610327",
"0.5589554",
"0.558250... | 0.82072884 | 0 |
Compose a source image with alpha onto a destination image. | def compose(dst: np.ndarray, src: np.ndarray) -> np.ndarray:
a, b = ensure_alpha(src), ensure_alpha(dst)
alpha = extract_alpha(a)
result = b * (1.0 - alpha) + a * alpha
if dst.shape[2] == 3:
return extract_rgb(result)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alpha_composite(self, im, dest=(0, 0), source=(0, 0)):\r\n\r\n if not isinstance(source, (list, tuple)):\r\n raise ValueError(\"Source must be a tuple\")\r\n if not isinstance(dest, (list, tuple)):\r\n raise ValueError(\"Destination must be a tuple\")\r\n if not len(s... | [
"0.7422852",
"0.70978785",
"0.6976313",
"0.6866716",
"0.6865255",
"0.68406856",
"0.6805374",
"0.6720108",
"0.6681318",
"0.66069293",
"0.65929514",
"0.65593785",
"0.6482925",
"0.6482741",
"0.6438921",
"0.63782775",
"0.6372395",
"0.63322204",
"0.6287815",
"0.6284114",
"0.623002... | 0.7438169 | 0 |
Calculate bandpass filters with adjustable length for given frequency ranges. This function returns for the given frequency band ranges the filter coefficients with length "filter_len". Thus the filters can be sequentially used for band power estimation. | def calc_band_filters(f_ranges, sfreq, filter_length="1000ms", l_trans_bandwidth=4, h_trans_bandwidth=4):
filter_list = list()
for f_range in f_ranges:
h = mne.filter.create_filter(None, sfreq, l_freq=f_range[0], h_freq=f_range[1], fir_design='firwin',
l_trans_ban... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bandpass_filtfilt(rawsong, samp_freq, freq_cutoffs=(500, 10000)):\n if freq_cutoffs[0] <= 0:\n raise ValueError('Low frequency cutoff {} is invalid, '\n 'must be greater than zero.'\n .format(freq_cutoffs[0]))\n\n Nyquist_rate = samp_freq / 2\n if... | [
"0.6331097",
"0.6286624",
"0.62640613",
"0.6151228",
"0.613698",
"0.60637957",
"0.60447794",
"0.60300845",
"0.60072994",
"0.59426826",
"0.59128374",
"0.58972484",
"0.587391",
"0.5848961",
"0.5806512",
"0.5764639",
"0.57619053",
"0.57331616",
"0.5716473",
"0.57109064",
"0.5686... | 0.78691727 | 0 |
Loads the database of People objects as a specified data type | def load_database(database_type):
f = open("database.p", "rb")
database = pickle.load(f)
f.close()
if database_type is "dict":
return database
elif database_type is "list":
return database.values() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_db(self):\n for type_ in self._types:\n try:\n type_.table(self._metadata)\n except InvalidRequestError:\n pass\n # Reflect metadata so auto-mapping works\n self._metadata.reflect(self._engine)\n # Make sure the tables exist\... | [
"0.6036072",
"0.5892125",
"0.5795159",
"0.5658464",
"0.56407386",
"0.5621719",
"0.54812354",
"0.54151523",
"0.53258556",
"0.5289917",
"0.5287105",
"0.52844226",
"0.52658",
"0.5242722",
"0.5219611",
"0.5181131",
"0.5163433",
"0.5148321",
"0.5140113",
"0.51361847",
"0.5131861",... | 0.61409664 | 0 |
Wait for container to be healthy. | def test_wait_for_healthy(main_container):
# This could take a while
TIMEOUT = 180
for i in range(TIMEOUT):
inspect = main_container.inspect()
status = inspect["State"]["Health"]["Status"]
assert status != "unhealthy", "The container became unhealthy."
if status == "healthy":... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_container():\n for i in xrange(30):\n print(\"Waiting for service to come up\")\n try:\n requests.get(URL).raise_for_status()\n return True\n except Exception as e:\n print e\n sleep(1)\n\n return False",
"def wait_for_container(... | [
"0.70266175",
"0.69631106",
"0.6873483",
"0.68020195",
"0.6711998",
"0.6690538",
"0.6673794",
"0.6620189",
"0.6472391",
"0.6412175",
"0.63628274",
"0.6351408",
"0.63411796",
"0.63291925",
"0.6318016",
"0.63093585",
"0.6306202",
"0.6234826",
"0.6229725",
"0.62052643",
"0.61958... | 0.7739588 | 0 |
Wait for containers to exit. | def test_wait_for_exits(main_container, version_container):
assert (
version_container.wait() == 0
), "Container service (version) did not exit cleanly" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_termination(self):\n self.server.wait_for_termination()",
"def wait(self) -> None:\n self._executor.shutdown(wait=True)",
"def wait_for_termination(self):\n self.server.wait_for_termination()",
"def wait_for_stop(timeout=30):\n starttime = time.time()\n while(time.... | [
"0.7033026",
"0.6967925",
"0.6909914",
"0.68500364",
"0.67150754",
"0.6529941",
"0.6527739",
"0.64836293",
"0.6441292",
"0.64279807",
"0.6425159",
"0.6388",
"0.6388",
"0.6388",
"0.6388",
"0.6386584",
"0.63711345",
"0.6333819",
"0.63210857",
"0.6277999",
"0.62738025",
"0.626... | 0.72377574 | 0 |
Verify the container outputs the correct version to the logs. | def test_log_version(version_container):
version_container.wait() # make sure container exited if running test isolated
log_output = version_container.logs().decode("utf-8").strip()
pkg_vars = {}
with open(VERSION_FILE) as f:
exec(f.read(), pkg_vars) # nosec
project_version = pkg_vars["__v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_version_release(self):\n with self.assertLogs(\"dakara_feeder.version\", \"DEBUG\") as logger:\n with patch.multiple(\n \"dakara_feeder.version\", __version__=\"0.0.0\", __date__=\"1970-01-01\"\n ):\n check_version()\n\n # assert effe... | [
"0.69504476",
"0.6847581",
"0.6835782",
"0.67436117",
"0.66984177",
"0.66706485",
"0.66361153",
"0.66052985",
"0.6452293",
"0.64389616",
"0.63589865",
"0.6269801",
"0.6172591",
"0.616603",
"0.614854",
"0.6137157",
"0.61313576",
"0.61284804",
"0.61186343",
"0.60721433",
"0.603... | 0.78575236 | 0 |
Verify the container version label is the correct version. | def test_container_version_label_matches(version_container):
pkg_vars = {}
with open(VERSION_FILE) as f:
exec(f.read(), pkg_vars) # nosec
project_version = pkg_vars["__version__"]
assert (
version_container.labels["org.opencontainers.image.version"] == project_version
), "Dockerfile... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_version(ctx, _, value):\n if not value or ctx.resilient_parsing:\n return\n\n click.echo(f\"geocube v{importlib.metadata.version('geocube')}\")\n\n ctx.exit()",
"def test_versionString(self):\n self.assertIn(\"%d.%d.%d\" % nevow.__version_info__, nevow.__version__)",
"def test_... | [
"0.66752607",
"0.64611894",
"0.6417991",
"0.6392024",
"0.6365091",
"0.6316447",
"0.6304623",
"0.62754697",
"0.62334216",
"0.6207172",
"0.6132876",
"0.6128137",
"0.61197776",
"0.6101531",
"0.6085407",
"0.60392827",
"0.60341907",
"0.6024869",
"0.6014097",
"0.5978784",
"0.596673... | 0.83354795 | 0 |
Test the main splash page. | def test_splash_page(self):
response = self.testapp.get('/')
self.assertEqual(response.status_int, 200)
response.mustcontain(
'Bite-sized learning journeys',
'Browse the explorations gallery', '100% free!',
'Learn', 'About', 'Contact',
# No navbar ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_login_and_logout_on_splash_page(self):\n response = self.testapp.get('/')\n self.assertEqual(response.status_int, 200)\n response.mustcontain(\n 'Login', 'Create an Oppia account', 'Contribute',\n self.get_expected_login_url('/'),\n no=['Profile', 'Log... | [
"0.70376253",
"0.6987304",
"0.6967448",
"0.68484825",
"0.6787349",
"0.67342925",
"0.66842026",
"0.666418",
"0.6645239",
"0.66426563",
"0.66338295",
"0.6604585",
"0.6584727",
"0.6584727",
"0.6568594",
"0.6441818",
"0.64151394",
"0.6395155",
"0.6382844",
"0.63790137",
"0.629545... | 0.8406544 | 0 |
Accepts list of nested dictionaries and produces a single dictionary containing mean values and estimated errors from these dictionaries. Errors are estimated as confidence intervals lengths. | def dict_recur_mean_err(dlist):
if isinstance(dlist[0], dict):
res_dict = {}
for k in dlist[0]:
n_dlist = [d[k] for d in dlist]
res_dict[k] = dict_recur_mean_err(n_dlist)
return res_dict
else:
n = len(dlist)
mean = float(sum(dlist)) / n
var... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_dictlist(dict_list):\r\n avg=sum(dict_list)/len(dict_list)\r\n return avg",
"def summaries(e_dict, m_dict):\n for key, value in m_dict.items():\n e_dict[key].append(np.mean(value))\n return e_dict",
"def calculate_averages(data):\n def mean(item_key):\n all_items = [i[item_... | [
"0.6419814",
"0.6262054",
"0.61799544",
"0.6119319",
"0.59288824",
"0.5902225",
"0.5875992",
"0.58529663",
"0.5829413",
"0.5736729",
"0.5708193",
"0.5633498",
"0.55455",
"0.5544103",
"0.55197287",
"0.54795134",
"0.5463006",
"0.54573137",
"0.544684",
"0.5438539",
"0.5426526",
... | 0.78539246 | 0 |
Helper function to connect reach from/to wastewater network elements | def connect_reach(self, reach_id, from_id=None, to_id=None):
data = {}
if from_id is not None:
data['rp_from_fk_wastewater_networkelement'] = from_id
if to_id is not None:
data['rp_to_fk_wastewater_networkelement'] = to_id
self.update('vw_qgep_reach', data, reach_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swconnect(localpop, remotepop, mac, vc, meter):\n core = Container.fromAnchor(localpop.properties['CoreRouter'])\n corename = core.resourceName\n (corename,coredom,coreport,corevlan) = getvcnode(vc, corename)\n remotecore = Container.fromAnchor(remotepop.properties['CoreRouter'])\n remotecorenam... | [
"0.6267456",
"0.61050874",
"0.6091898",
"0.5930662",
"0.59238946",
"0.5836637",
"0.5822732",
"0.5821258",
"0.58018726",
"0.58003306",
"0.5727876",
"0.5715374",
"0.5697749",
"0.5681944",
"0.5681944",
"0.5671002",
"0.5660585",
"0.5634978",
"0.562125",
"0.56210154",
"0.56170815"... | 0.6569376 | 0 |
Resolve activelink values into x and y directions. Takes a set of values defined on active links, and returns those values | def resolve_values_on_active_links(grid, active_link_values):
link_lengths = grid.length_of_link[grid.active_links]
return (
np.multiply(
(
(
grid.node_x[grid._activelink_tonode]
- grid.node_x[grid._activelink_fromnode]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve_values_on_links(grid, link_values):\n return (\n np.multiply(\n (\n (\n grid.node_x[grid.node_at_link_head]\n - grid.node_x[grid.node_at_link_tail]\n )\n / grid.length_of_link\n ),\n ... | [
"0.6321813",
"0.56443125",
"0.5429352",
"0.53935385",
"0.52528846",
"0.5167584",
"0.5058837",
"0.5045933",
"0.50244004",
"0.49784845",
"0.49667338",
"0.4963591",
"0.4912155",
"0.4907423",
"0.48758897",
"0.48721966",
"0.48685086",
"0.48672333",
"0.4834237",
"0.4823273",
"0.480... | 0.75788385 | 0 |
Resolve link values into x and y directions. Takes a set of values defined on active links, and returns those values | def resolve_values_on_links(grid, link_values):
return (
np.multiply(
(
(
grid.node_x[grid.node_at_link_head]
- grid.node_x[grid.node_at_link_tail]
)
/ grid.length_of_link
),
link_valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve_values_on_active_links(grid, active_link_values):\n link_lengths = grid.length_of_link[grid.active_links]\n return (\n np.multiply(\n (\n (\n grid.node_x[grid._activelink_tonode]\n - grid.node_x[grid._activelink_fromnode]\n ... | [
"0.7462041",
"0.5736362",
"0.5348133",
"0.5260617",
"0.5245823",
"0.5127555",
"0.5098766",
"0.50402445",
"0.49898282",
"0.49610978",
"0.496048",
"0.49522752",
"0.4950983",
"0.49342787",
"0.48836175",
"0.48753074",
"0.48695916",
"0.48694083",
"0.4847132",
"0.48457292",
"0.4829... | 0.71486044 | 1 |
Temporary fix until master of pyzmq is released | def fix_zmq_exit():
import zmq
ctx = zmq.Context.instance()
ctx.term() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zmq_version():\n return \"%i.%i.%i\" % zmq_version_info()",
"def zmq_version():\n return \"%i.%i.%i\" % zmq_version_info()",
"def __init__(self, ip='127.0.0.1', port='50020'):\n self.ip = ip \n self.port = port\n self.ctx = zmq.Context()\n self.socket = zmq.Socket(self.ctx... | [
"0.6027707",
"0.6027707",
"0.58552617",
"0.58471286",
"0.58471286",
"0.57001704",
"0.56426144",
"0.5506162",
"0.54845864",
"0.540713",
"0.53992295",
"0.5322331",
"0.53118736",
"0.5300016",
"0.5295095",
"0.5244118",
"0.5238676",
"0.52331984",
"0.5188429",
"0.5173681",
"0.51529... | 0.6925526 | 0 |
Applies filters and stores job postings in a database job_list a list of Job_Posting objects avoids saving duplicate job postings into the database by hashing job_description creates the database if it does not exist yet | def store_data(job_list):
if not job_list:
raise ValueError('Job list is empty. To proceed, it must contain at least one item.')
if not isfile('/data/visited_jobs.db'):
print('DB not found')
ds.create_db()
accepted, not_accepted = 0, 0
for job in job_list:
jo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateJobDB(request,Q={}):\n\tuser = request.user\n\t# Get metadata\n\tresponse = agaveRequestMetadataList(user,Q=Q)\n\t# Add job if not in db\n\tfor metadata in response['result']:\n\t\tvalue = metadata['value']\n\t\tif 'jobName' in value and 'parameters' in value:\n\t\t\tlogger.info('SetName: ' + value['jobN... | [
"0.6064062",
"0.5675799",
"0.561844",
"0.55301267",
"0.5519273",
"0.53884274",
"0.5382857",
"0.53754044",
"0.536694",
"0.5362908",
"0.5361829",
"0.53558755",
"0.53386945",
"0.5303524",
"0.52626956",
"0.5243744",
"0.5243744",
"0.5236328",
"0.5209559",
"0.5199003",
"0.5169366",... | 0.6501171 | 0 |
Gets two positive integer numbers m and n (m > n). Returns True if they are coprime, otherwise, returns False. | def coprime(m,n):
# The function uses the Euclid's algorithm for finding the greatest common divisor. The algorithm is recursive.
# If the GCD is 1, when the numbers are coprime. If it is greater than 1, when the numbers aren't coprime.
if n == 0 and m > 1:
return False
elif n == 0 and m ==... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coprime(a: int, b: int):\n\n return euclid(a, b) == 1",
"def coprime(a, b):\n return gcd(a, b) == 1",
"def coprime(self,x,y):\r\n return x == 1 or y == 1 or not bool(self.cofactors(x,y))",
"def is_relatively_prime(n, m):\n result = True\n larger = n\n if m > n:\n larger = m\n... | [
"0.79076767",
"0.7667604",
"0.72574323",
"0.6289784",
"0.59262717",
"0.5853223",
"0.5806163",
"0.5744549",
"0.5737769",
"0.5737769",
"0.5732557",
"0.5720091",
"0.56966656",
"0.56965023",
"0.568913",
"0.5660022",
"0.5632094",
"0.5599034",
"0.5597036",
"0.55894285",
"0.5589392"... | 0.7949466 | 0 |
Create a shift from a datetime. | def from_datetime(cls, position, datetime):
return cls(
position = position,
date = datetime.date(),
name = position.shiftForTime(datetime.time()),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timeshift(self, shift='random'):\n\n if shift == 'random':\n one_month = pd.Timedelta('30 days').value\n two_years = pd.Timedelta('730 days').value\n random_timedelta = - pd.Timedelta(random.uniform(one_month, two_years)).round('min')\n self.timeshift(random_t... | [
"0.6044403",
"0.5398259",
"0.5287457",
"0.51769984",
"0.5132189",
"0.50019145",
"0.49231648",
"0.4896712",
"0.48872542",
"0.48718226",
"0.47676012",
"0.4703589",
"0.46973696",
"0.46934074",
"0.4664867",
"0.46602306",
"0.46434352",
"0.46422106",
"0.46262237",
"0.46083966",
"0.... | 0.62300646 | 0 |
LSTM over tweet only | def get_model_tweetonly(batch_size, max_seq_length, input_size, hidden_size, target_size,
vocab_size, pretrain, tanhOrSoftmax, dropout):
# batch_size x max_seq_length
inputs = tf.placeholder(tf.int32, [batch_size, max_seq_length])
cont_train = True
if pretrain == "pre":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LSTM_train(X_train, Y_train, X_dev, Y_dev, R_train, R_dev, hyperparams):",
"def lstm_infer_vector(lstm_model, txt, stopwords,word_indices, maxlen=10, taillemax=300) :\n \n txt_prep = gensim.utils.simple_preprocess(txt, deacc=True)\n txt_wo_uw = remove_unknown_words(txt_prep, word_indices)\n txt_w... | [
"0.69259703",
"0.6396579",
"0.63238174",
"0.6247593",
"0.6204757",
"0.62018347",
"0.62017447",
"0.6161664",
"0.61093134",
"0.6070913",
"0.6062975",
"0.60444057",
"0.6001166",
"0.5980393",
"0.59802103",
"0.5965758",
"0.5951675",
"0.5950302",
"0.5941786",
"0.5909258",
"0.589360... | 0.65407586 | 1 |
Get teams owned by the account. | def get_teams(self, account_id):
endpoint = '/accounts/{}/teams'.format(account_id)
return self._api_call('get', endpoint) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_teams(self):\n url = 'teams'\n result = self.get(url)\n return result.get('teams', result)",
"def get_teams(self, *args, **kwargs):\n\n teams_data = api.get_teams(\n *args,\n api_key=self.__creds.api_key_v2,\n **kwargs)\n return [en.Team... | [
"0.7548286",
"0.7198719",
"0.7053132",
"0.70429367",
"0.70303184",
"0.6919348",
"0.6908395",
"0.6904372",
"0.68936974",
"0.6875712",
"0.6783006",
"0.67675626",
"0.67675245",
"0.6744305",
"0.6626937",
"0.66002136",
"0.65531397",
"0.64464307",
"0.6432558",
"0.6408208",
"0.63947... | 0.7758869 | 0 |
Get projects owned by the team. | def get_projects(self, team_id):
endpoint = '/teams/{}/projects'.format(team_id)
return self._api_call('get', endpoint) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_projects(self):\n return self._gitlab.owned_projects(per_page=1000)",
"def get_projects(self):\n return self.http_call(\"get\", url=f\"{self.base_url}/projects\").json()",
"def get_projects(self):\n projects = []\n page = 1\n while not len(projects) % 100:\n ... | [
"0.8055631",
"0.71431756",
"0.6982873",
"0.6950596",
"0.69087213",
"0.68157524",
"0.6773247",
"0.6765266",
"0.67424154",
"0.66995823",
"0.66808534",
"0.6675837",
"0.66692793",
"0.6655742",
"0.66494966",
"0.6611001",
"0.66000354",
"0.6599352",
"0.6567951",
"0.65166676",
"0.651... | 0.720342 | 1 |
Get an asset by id. | def get_asset(self, asset_id):
endpoint = '/assets/{}'.format(asset_id)
return self._api_call('get', endpoint) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_asset(self, asset_id):\n text, code = ApiClient(self._config, 'assets/' + asset_id).get()\n return Asset.deserialize(text)",
"def get_asset(self, asset_id, asset_type):\n return self.asset(asset_id, asset_type=asset_type)",
"def asset(self, asset_id):\n headers, items = self... | [
"0.8605014",
"0.8052259",
"0.7977259",
"0.78436553",
"0.7251006",
"0.7176857",
"0.69656426",
"0.6938977",
"0.6917505",
"0.66144365",
"0.65986526",
"0.6570589",
"0.6543234",
"0.6528059",
"0.64717233",
"0.6465809",
"0.6415963",
"0.6392111",
"0.638581",
"0.6384934",
"0.6381671",... | 0.8775442 | 0 |
Get an asset's children. | def get_asset_children(self, asset_id):
endpoint = '/assets/{}/children'.format(asset_id)
return self._api_call('get', endpoint) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children(self) -> \"AssetList\":\n return self._cognite_client.assets.list(parent_ids=[self.id], limit=None)",
"def get_children(self):\r\n\r\n if not self.has_children:\r\n return []\r\n\r\n if getattr(self, '_child_instances', None) is None:\r\n self._child_instan... | [
"0.80006397",
"0.691222",
"0.6860828",
"0.68368614",
"0.68368614",
"0.68368614",
"0.68265384",
"0.6793676",
"0.6740953",
"0.6736009",
"0.6700646",
"0.6693795",
"0.6691179",
"0.6656253",
"0.66030985",
"0.6577579",
"0.655715",
"0.655715",
"0.6483371",
"0.64426744",
"0.64426744"... | 0.8664441 | 0 |
Upload an asset. The method will exit once the file is uploaded. | def upload(self, asset, file):
uploader = FrameioUploader(asset, file)
uploader.upload() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_asset(ctx, asset, release):\n\n try:\n\n gh = ctx.obj.github\n\n log.echo('Uploading {} to release {}...'\n .format(os.path.basename(asset), release), break_line=False)\n asset_url = gh.upload_asset(asset=asset, release=release)\n log.checkmark()\n l... | [
"0.7121886",
"0.6898182",
"0.67980725",
"0.6593342",
"0.6541552",
"0.6339619",
"0.6255667",
"0.6252402",
"0.62079424",
"0.6194437",
"0.6188706",
"0.61695176",
"0.6163366",
"0.61349344",
"0.61055654",
"0.6055838",
"0.6012874",
"0.5993593",
"0.5967045",
"0.59558564",
"0.5932348... | 0.7988663 | 0 |
Get an asset's comments. | def get_comments(self, asset_id):
endpoint = '/assets/{}/comments'.format(asset_id)
return self._api_call('get', endpoint) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comments(self):\n\t\treturn self._client.get_comments(self)",
"def comments(self):\n comments_url = self.data['comments_url']\n return json.load(urllib2.urlopen(comments_url))",
"def comments(self):\n return self.container['comments']",
"def get(self, id):\n return get_com... | [
"0.7266864",
"0.6898062",
"0.67627263",
"0.66801363",
"0.66657114",
"0.66657114",
"0.6650718",
"0.6621939",
"0.65967107",
"0.65728563",
"0.6548351",
"0.6507441",
"0.6507441",
"0.6507441",
"0.63552064",
"0.63516146",
"0.6345878",
"0.6339328",
"0.6319697",
"0.63146293",
"0.6279... | 0.87023836 | 0 |
Get the review links of a project | def get_review_links(self, project_id):
endpoint = '/projects/{}/review_links'.format(project_id)
return self._api_call('get', endpoint) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grab_project_links(soup):\n project_urls = []\n valid_project_url = \"/?archive/?gsoc/\\d+[0-9]/orgs/[a-zA-Z]+/[a-zA-Z]+/[a-zA-Z]+.html\"\n try:\n # Grab links to all the projects\n all_link = soup.find_all(\"a\")\n for link in all_link:\n if re.match(valid_project_url,... | [
"0.6268083",
"0.62558377",
"0.6122463",
"0.6031433",
"0.60285616",
"0.59528255",
"0.5925954",
"0.58337975",
"0.57853",
"0.57034177",
"0.5673401",
"0.56721526",
"0.563363",
"0.56289285",
"0.56215906",
"0.5591778",
"0.5589715",
"0.5549578",
"0.5547254",
"0.55213386",
"0.5512712... | 0.7728808 | 0 |
Create a review link. | def create_review_link(self, project_id, **kwargs):
endpoint = '/projects/{}/review_links'.format(project_id)
return self._api_call('post', endpoint, payload=kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def review_link(self, review_link):\n\n self._review_link = review_link",
"def createLink(context, title, link, exclude_from_nav=False):\n oid = idnormalizer.normalize(title, 'es')\n if not hasattr(context, oid):\n context.invokeFactory('Link', id=oid, title=title, remoteUrl=link)\n li... | [
"0.67446196",
"0.59985214",
"0.58935666",
"0.5819669",
"0.57771635",
"0.57548815",
"0.56993616",
"0.5654442",
"0.5638429",
"0.5629432",
"0.56153315",
"0.56034595",
"0.5595337",
"0.5588098",
"0.558482",
"0.55711055",
"0.5541868",
"0.55295026",
"0.5524608",
"0.5522368",
"0.5497... | 0.77476805 | 0 |
Get a single review link | def get_review_link(self, link_id, **kwargs):
endpoint = '/review_links/{}'.format(link_id)
return self._api_call('get', endpoint, payload=kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_review_page(review_link):\n\n session = r.Session()\n response = session.get(BASE_URL + '/music/albumreviews/' + review_link,\n headers=HEADERS)\n return response",
"def get_review(review_id):\n return get(cls, review_id)",
"def get_content_object_url(self):\n ... | [
"0.6831752",
"0.64643896",
"0.6345438",
"0.6279402",
"0.6228978",
"0.61699647",
"0.61587733",
"0.612717",
"0.6065012",
"0.60605973",
"0.603731",
"0.5991732",
"0.5958937",
"0.5925658",
"0.58885676",
"0.576672",
"0.57320416",
"0.57320416",
"0.57136726",
"0.5682893",
"0.5650391"... | 0.6617292 | 1 |
Add or update assets for a review link. | def update_review_link_assets(self, link_id, **kwargs):
endpoint = '/review_links/{}/assets'.format(link_id)
return self._api_call('post', endpoint, payload=kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def review_link(self, review_link):\n\n self._review_link = review_link",
"def linkAssets(des, Xrc):\n with open(des, 'r') as f:\n body = f.read()\n f.close()\n with open(des, 'w') as f:\n body = body.replace(\"custom.css\", \"\\\\\" + Xrc[\"gh_repo_name\"] + \"/Assets\" + \"/cs... | [
"0.59623325",
"0.5327148",
"0.51797146",
"0.5134346",
"0.49140236",
"0.48908433",
"0.4881912",
"0.48579592",
"0.4842742",
"0.48399702",
"0.4804743",
"0.47892767",
"0.47684696",
"0.47508633",
"0.4741797",
"0.47353303",
"0.47250083",
"0.46850595",
"0.46558216",
"0.4654844",
"0.... | 0.74828833 | 0 |
Get items from a single review link. | def get_review_link_items(self, link_id):
endpoint = '/review_links/{}/items'.format(link_id)
return self._api_call('get', endpoint) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_review_page(review_link):\n\n session = r.Session()\n response = session.get(BASE_URL + '/music/albumreviews/' + review_link,\n headers=HEADERS)\n return response",
"def get_reviews(item_id, shop_id, review_num=10) -> list:\n get_url = f\"{_shopee_base_url}/api/v2/it... | [
"0.6445965",
"0.6111887",
"0.59627175",
"0.59522223",
"0.5802556",
"0.5668858",
"0.56402814",
"0.56334907",
"0.5598594",
"0.5478629",
"0.5376781",
"0.5351566",
"0.5350795",
"0.534827",
"0.53360826",
"0.5320217",
"0.52967834",
"0.5288006",
"0.52783906",
"0.52698594",
"0.525339... | 0.70730585 | 0 |
Given an imaging server fqdn, get its ID; raises NotFound if not found. | def get_id(self, fqdn):
res = self.db.execute(sqlalchemy.select([ model.imaging_servers.c.id ],
whereclause=(model.imaging_servers.c.fqdn==fqdn)))
return self.singleton(res) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id(self):\n if self.cloudserver:\n return self.cloudserver.id\n else:\n return None",
"def get_dnid_by_dnname(self, dnname):\r\n for dn in self.dns:\r\n if dn.name == dnname:\r\n return dn.id\r\n return None",
"def fqdn_identifier(... | [
"0.60768455",
"0.5970655",
"0.5924284",
"0.5919874",
"0.58456326",
"0.5822033",
"0.5815973",
"0.580934",
"0.5719458",
"0.56800956",
"0.56767",
"0.566704",
"0.5608655",
"0.55602825",
"0.5556568",
"0.55522054",
"0.5534244",
"0.55294096",
"0.5518612",
"0.5512121",
"0.5504768",
... | 0.7955763 | 0 |
Return a list of the fqdn's of all imaging servers | def list(self):
res = self.db.execute(select([model.imaging_servers.c.fqdn]))
return self.column(res) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ns_list(self):\n return sorted(self.get_ns_name(ns) for ns in self.profile.authoritative_servers)",
"def ip_addresses(self):\n try:\n return socket.gethostbyaddr(self.fqdn)[-1]\n except socket.error as _:\n return ['127.0.0.1']",
"def list_distributed_cameras(ns_h... | [
"0.6587762",
"0.65380913",
"0.6459177",
"0.6459177",
"0.6430747",
"0.6372296",
"0.6362174",
"0.633885",
"0.6327382",
"0.6309077",
"0.6303938",
"0.62505966",
"0.62255406",
"0.6212317",
"0.6186019",
"0.6185925",
"0.6149783",
"0.6135975",
"0.61257327",
"0.60628873",
"0.60275596"... | 0.77899426 | 0 |
Place various obstacles. E.g. put in rectangles which block the line of site of the towers. | def place_obstacles():
#Randomly generate different sized rectangles
#Soem may overlap, which gives more variety in shape of obstacles
xvals = np.random.randint(0,self.map_dimensions[1],size=self.N_obstacles)
yvals = np.random.randint(0,self.map_dimensions[0],size=self.N_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_obstacles(self):\n for obstacle in self.obstacles:\n obstacle.draw(self.window, Colors.BLACK.value)",
"def draw_obstacles():\n for obstacle in obstacles:\n plt.gca().add_patch(obstacle)",
"def spawn_obstacles(self):\n self.obstacle_sprites.empty()\n number_of_... | [
"0.7180668",
"0.6907903",
"0.66251636",
"0.65257436",
"0.6507786",
"0.6495422",
"0.64418054",
"0.63769335",
"0.6216832",
"0.6200093",
"0.6169618",
"0.6096015",
"0.6086622",
"0.60711867",
"0.601048",
"0.60011566",
"0.59804374",
"0.59804374",
"0.59792244",
"0.5943572",
"0.59333... | 0.79376906 | 0 |
Place the target locations | def place_targets():
coords = []
while len(coords)<self.N_targets:
x = np.random.randint(self.BORDER_MARGIN,self.map_dimensions[1]+1-self.BORDER_MARGIN,size=1)[0]
y = np.random.randint(self.BORDER_MARGIN,self.map_dimensions[0]+1-self.BORDER_MARGIN,si... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_targets(self):\n for ga_main, ga_targ in zip(self.ga.variables, self.ga_.variables):\n ga_targ.assign(ga_main)\n if self.use_lyapunov:\n for lc_main, lc_targ in zip(self.lc.variables, self.lc_.variables):\n lc_targ.assign(lc_main)\n else:\n ... | [
"0.6060867",
"0.5983119",
"0.59704787",
"0.5942067",
"0.5901007",
"0.588003",
"0.58684736",
"0.58369666",
"0.58147174",
"0.58143884",
"0.5814113",
"0.5796882",
"0.5793904",
"0.57164675",
"0.5716242",
"0.57001746",
"0.56815624",
"0.56712925",
"0.5663553",
"0.5660132",
"0.56310... | 0.71361285 | 0 |
Place the potential tower locations. These are the locations where towers can potentially be placed. Not every location is necesarily used (only when N_tower_sites = N_towers). THe optimization problem is to determine which of these possible locations to use. | def place_allowed_tower_sites():
self.coordinates__tower_sites = []
for tk in xrange(self.N_tower_kinds):
#Each kind of tower will have the correct number of sites placed
coords = []
while len(coords)<self.N_tower_sites[tk]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve_environment(self):\n \n #The first problem formulation\n #K kinds of towers\n #See more details about problem formulation in the writeup \n \n #Get a full matrix of the concatenated coverage matrices for \n #each tower type. THis new matrix has... | [
"0.58460766",
"0.57772356",
"0.5284448",
"0.52179706",
"0.5182957",
"0.5147743",
"0.5096863",
"0.50870997",
"0.50867623",
"0.5045977",
"0.502303",
"0.49666467",
"0.49650604",
"0.49317968",
"0.49126053",
"0.49000195",
"0.48980615",
"0.48955286",
"0.4892086",
"0.48821265",
"0.4... | 0.79918706 | 0 |
return True if r1 r2 line of sight is obstrucetd; oherwise False | def check_obstructed(r1,r2):
if r1==r2:
return False
#Densely sample line connecting r1 and r2.
#If any of those sampled points is inside the rectangle, then the
#line of sight intersects the rectangle and the tower's... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_ok_two_lines(line1, line2):\n card1 = line1[0]\n card2 = line1[1]\n card3 = line1[2]\n card4 = line2[0]\n card5 = line2[1]\n card6 = line2[2]\n idents1 = [card.ident for card in line1]\n idents2 = [card.ident for card in line2]\n intersection = list(set(idents1) & set(idents2))\n ... | [
"0.6848249",
"0.64294106",
"0.63830334",
"0.6372023",
"0.6302667",
"0.6286635",
"0.627175",
"0.62661767",
"0.62325734",
"0.6230347",
"0.61978024",
"0.6182168",
"0.6139048",
"0.6096409",
"0.60867286",
"0.6068303",
"0.60645324",
"0.60228837",
"0.60018134",
"0.5998949",
"0.59936... | 0.7739377 | 0 |
Visualize the map environment and solved tower locations. env_state = 'solved', 'initial' | def visualize_environment(self,env_state):
fig=plt.figure(figsize=self.figsize)
ax=plt.subplot(111)
#Plot the targets
plt.plot([i[0] for i in self.coordinates__targets],\
[i[1] for i in self.coordinates__targets],\
marker='x',markersize=15,linestyle='Non... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize_world(self, brain):\n state_str = ' || '.join([str(self.sensors),\n str(self.actions),\n str(self.reward),\n str(self.size),\n str(self.color),\n ... | [
"0.6409097",
"0.6119604",
"0.5912742",
"0.586634",
"0.58319414",
"0.57472837",
"0.5705525",
"0.5673055",
"0.5668513",
"0.5658401",
"0.56487894",
"0.56268203",
"0.5603009",
"0.55793464",
"0.55743",
"0.55685604",
"0.5551185",
"0.5547571",
"0.54791296",
"0.547258",
"0.54570925",... | 0.8492099 | 0 |
Run the whole scenario. Initialize map, solve placement, visualize everything. | def run_scenario(self):
self.initialize_random_map()
self.visualize_environment('initial')
self.get_tower_target_coverages()
self.solve_environment()
self.visualize_environment('solved') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n # Return needed Data Frames to analyze\n data_frame, seasons, col, labels, stats, kaggle = load_frames()\n\n # Create the maps now\n create_shot_maps(data_frame,seasons)\n create_scenario_map()\n \n # Create the Plots\n plot_season_graphs(stats)\n plot_pie_charts(kaggle)\n ... | [
"0.7093898",
"0.6963387",
"0.67339575",
"0.6569679",
"0.61990684",
"0.61964035",
"0.61749303",
"0.6154679",
"0.61539835",
"0.6101129",
"0.60104483",
"0.5999573",
"0.5993726",
"0.5986674",
"0.59698826",
"0.5956886",
"0.5940285",
"0.5927748",
"0.5921149",
"0.5909592",
"0.590016... | 0.8375138 | 0 |
converting from cv2 image class to yolo image class | def _convert_to_yolo_img(self, img):
img = img / 255.0
h, w, c = img.shape
img = img.transpose(2, 0, 1)
outimg = make_image(w, h, c)
img = img.reshape((w*h*c))
data = c_array(c_float, img)
outimg.data = data
rgbgr_image(outimg)
return outimg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yolo_detection(raw_image):\n class_ids = []\n confidences = []\n boxes = []\n height , width ,c= raw_image.shape\n blob = cv2.dnn.blobFromImage(raw_image, 0.00392, (416,416), (0,0,0), True, crop=False)\n net.setInput(blob)\n outs = net.forward(output_layers)\n\n for out in outs:\n ... | [
"0.69979674",
"0.6875691",
"0.6409599",
"0.6264038",
"0.6263965",
"0.62305474",
"0.6210611",
"0.61554116",
"0.6152523",
"0.61343765",
"0.6091251",
"0.60643476",
"0.6000393",
"0.59585893",
"0.59381723",
"0.59326524",
"0.5932447",
"0.591459",
"0.58689374",
"0.5849591",
"0.58300... | 0.73024845 | 0 |
Predicting from cv2 format | def predict_from_cv2(yolo, inputfilepath):
print("call func of predict_from_cv2")
img = cv2.imread(inputfilepath)
yolo_results = yolo.predict(img)
for yolo_result in yolo_results:
print(yolo_result.get_detect_result()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(self, img_path):\n\n img = cv2.imread(img_path)\n img0 = img.copy()\n \n #This happens inside datasets\n # Convert\n img = letterbox(img, new_shape=self.img_size)[0]\n\n # Convert\n img = img[:, :, ::-1].transpose(2, 0, 1) # BGR to RGB, to 3x416x... | [
"0.769187",
"0.7126001",
"0.7057096",
"0.7030363",
"0.70179856",
"0.7012954",
"0.6988399",
"0.696144",
"0.696144",
"0.6959898",
"0.69489837",
"0.6909902",
"0.6900875",
"0.68756694",
"0.6821238",
"0.6792172",
"0.6742851",
"0.67373735",
"0.6706675",
"0.668598",
"0.6666994",
"... | 0.72321135 | 1 |
Predicting from PIL format | def predict_from_pil(yolo, inputfilepath):
print("call func of predict_from_pil")
img = np.array(Image.open(inputfilepath))
yolo_results = yolo.predict(img)
for yolo_result in yolo_results:
print(yolo_result.get_detect_result()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_image(pic_style):\n classes = [\"BAROQUE\", \"EARLY-RENAISSANCE\", \"HIGH-RENAISSANCE\", \"IMPRESSIONISM\", \"MANNERISM\",\n \"MEDIEVAL\", \"MINIMALISM\", \"NEOCLASSICISM\", \"REALISM\", \"ROCOCO\",\n \"ROMANTICISM\", \"SURREALISM\"\n ]\n\n if pic_style.... | [
"0.6664149",
"0.6654456",
"0.65723336",
"0.6510777",
"0.6439882",
"0.6420322",
"0.6417145",
"0.6387115",
"0.6382623",
"0.63690084",
"0.6353849",
"0.6336394",
"0.63333225",
"0.63284427",
"0.63270974",
"0.6322199",
"0.63044155",
"0.6290391",
"0.62887764",
"0.6276978",
"0.624016... | 0.6737026 | 0 |
Fetch a single user's data if a user_id is specified. Otherwise fetch the list of all users. Returned info contains user_id, name, group name,email, admin status, and date_created. | def get(self, user_id):
if user_id:
return get_from_user_id(user_id)
else:
# No user_id given; this is a GET all users request.
if not current_user.is_admin:
error(403, "Logged in user not admin ")
user_db_data = user_db_util.fetchall(g.da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def fetch_user(self, id: str):\n user = await self.http.get_user(id)\n return User(state=self.http, data=user)",
"def get(self, id):\n\t\ttry:\n\t\t\tflask_app.logger.debug('We are getting the user: %d', id)\n\t\t\treturn user_service.get(id)\n\t\texcept AssertionError as e:\n\t\t\tuser_space... | [
"0.72157097",
"0.7131999",
"0.70872533",
"0.7083722",
"0.7074586",
"0.7070638",
"0.7040221",
"0.70230114",
"0.6946631",
"0.69372654",
"0.6927964",
"0.6918322",
"0.69075227",
"0.68962216",
"0.68914783",
"0.688945",
"0.6877585",
"0.6864886",
"0.6854097",
"0.68460727",
"0.681894... | 0.7235378 | 0 |
Create a new user with provided email, password, and admin flag. If required fields are missing in the request, return 400 Password must be 8 or more characters long. Otherwise return 422 Email must not already be in use by an existing user. Otherwise return 422 If success, return 201 with the new user's email, admin f... | def post(self):
data = request.get_json()
if data is None:
error(400, "No json data in request body")
check_data_fields(data, ["email", "name", "group_name", "password", "admin"])
if len(data["password"]) < 8:
error(422, "New password is less than 8 characters... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_user():\n record = request.get_json()\n if record is None:\n return {\"Error\": \"No data Supplied.\"}, 400\n\n schema = user_schema.load(record)\n\n if UserModel.objects(email=schema['email']):\n return {\"Error\": \"User Data already exists.\"}, 400\n user = UserModel(**s... | [
"0.7782959",
"0.76835763",
"0.7680565",
"0.7676472",
"0.76109964",
"0.7539318",
"0.753589",
"0.75105494",
"0.75042003",
"0.74783903",
"0.7470725",
"0.7454548",
"0.7424451",
"0.7331659",
"0.73239493",
"0.7322408",
"0.73050135",
"0.72956514",
"0.7292638",
"0.7289475",
"0.728914... | 0.7710605 | 1 |
Distatches an event to any matching event handlers. The handler which specifically matches the event name will be called first, followed by any handlers with a 'match' method which matches the event name concatenated to the args string. | def dispatch(self, event, args=''):
try:
if event in self.events:
self.events[event](args)
for matcher, action in self.eventmatchers.iteritems():
ary = matcher.match(' '.join((event, args)))
if ary is not None:
action(*a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_handlers(self, event, method=EVENT_CAPTURE):\n if event not in self.events:\n return None\n for handler in self.events[str(event)].with_method(method):\n handler(event)",
"def onEvent(self, event):\n if event is None:\n return\n\n target_class ... | [
"0.6142079",
"0.6090708",
"0.58892405",
"0.57285976",
"0.56782824",
"0.56358707",
"0.56105155",
"0.5587811",
"0.5533092",
"0.55268854",
"0.54496866",
"0.541662",
"0.5377691",
"0.53475493",
"0.53425974",
"0.5300932",
"0.52983147",
"0.5238735",
"0.5219943",
"0.52198094",
"0.515... | 0.73175037 | 0 |
Enters the event loop, reading lines from wmii's '/event' and dispatching them, via dispatch, to event handlers. Continues so long as alive is True. | def loop(self):
keys.mode = 'main'
for line in client.readlines('/event'):
if not self.alive:
break
self.dispatch(*line.split(' ', 1))
self.alive = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run():\n\n while True:\n\n # get event, blah\n event_name, event_data = revent.get_event(block=True, timeout=5)\n\n if event_name is not None:\n print 'received: %s' % event_name\n\n if event_name.endswith('_oembed_details'):\n handle_new_oembed_deta... | [
"0.6532273",
"0.64159447",
"0.61325336",
"0.6103995",
"0.6085888",
"0.60446244",
"0.60411006",
"0.600487",
"0.59969455",
"0.5978081",
"0.5910201",
"0.5910201",
"0.59055114",
"0.5898839",
"0.5848962",
"0.5841019",
"0.5816226",
"0.5811897",
"0.580067",
"0.5787875",
"0.57788646"... | 0.7531345 | 0 |
Binds a number of event handlers for wmii events. Keyword arguments other than 'items' are added to the 'items' dict. Handlers are called by loop when a matching line is read from '/event'. Each handler is called with, as its sole argument, the string read from /event with its first token stripped. | def bind(self, items={}, **kwargs):
kwargs.update(items)
for k, v in flatten(kwargs.iteritems()):
if hasattr(k, 'match'):
self.eventmatchers[k] = v
else:
self.events[k] = v | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _register_handlers(self):\n self.jm.register_handler(\"move_node\", self.move_node)\n self.jm.register_handler(\"copy_node\", self.copy_node)\n self.jm.register_handler(\"push_to_vospace\", self.push_to_vospace)\n self.jm.register_handler(\"push_from_vospace\", self.push_from_vospace)\n self.jm.... | [
"0.55518967",
"0.5541481",
"0.55277866",
"0.5482645",
"0.54119766",
"0.538342",
"0.5349072",
"0.5295835",
"0.5283326",
"0.5205757",
"0.51651305",
"0.5116842",
"0.5108721",
"0.5076696",
"0.5072107",
"0.5070965",
"0.5070048",
"0.5055877",
"0.5042442",
"0.5040995",
"0.50364155",... | 0.66373867 | 0 |
A decorator which binds its wrapped function, as via bind, for the event which matches its name. | def event(self, fn):
self.bind({fn.__name__: fn}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binds(**binds):\n def decorate(func):\n function = to_function(func)\n setattr(function, BINDS, binds)\n return function\n return decorate",
"def bindEvent(obj, name, method):\n setattr(obj, name,\n types.MethodType(method, obj, obj.__class__))",
"def _event_bridge(... | [
"0.66477215",
"0.66141915",
"0.6544321",
"0.64554435",
"0.643344",
"0.6340396",
"0.6323057",
"0.6308433",
"0.61923933",
"0.6147095",
"0.6073753",
"0.601856",
"0.60135686",
"0.59841114",
"0.5885072",
"0.58757806",
"0.5850867",
"0.577973",
"0.577973",
"0.577973",
"0.577973",
... | 0.6808041 | 0 |
Binds a series of keys for the given 'mode'. Keys may be specified as a dict or as a sequence of tuple values and strings. In the latter case, documentation may be interspersed with key bindings. Any value in the sequence which is not a tuple begins a new key group, with that value as a description. A tuple with two va... | def bind(self, mode='main', keys=(), import_={}):
self._add_mode(mode)
mode = self.modes[mode]
group = None
def add_desc(key, desc):
if group not in mode['desc']:
mode['desc'][group] = []
mode['groups'].append(group)
if key not in m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind_modifiers(widget, event:Callable, button='Button-1',\n modes=frozendict({'Shift': KeyModes.SHIFT, 'Control': KeyModes.CONTROL, 'Alt': KeyModes.ALT, })):\n widget.bind(button, event)\n for modifier, keymode in modes.items():\n # We must provide 'keymode' as a default argument... | [
"0.58895165",
"0.58841205",
"0.5588694",
"0.52264315",
"0.48822513",
"0.4842393",
"0.48337808",
"0.48153064",
"0.4735098",
"0.4661002",
"0.45969185",
"0.45763007",
"0.45294526",
"0.4502729",
"0.45009285",
"0.4483334",
"0.44517758",
"0.44213554",
"0.44187143",
"0.4397471",
"0.... | 0.7402634 | 0 |
Calls a method named for the first token of 'args', with the rest of the string as its first argument. If the method doesn't exist, a trailing underscore is appended. | def _call(self, args):
a = args.split(' ', 1)
if a:
getattr(self, a[0])(*a[1:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _func_named(self, arg):\n result = None\n target = 'do_' + arg\n if target in dir(self):\n result = target\n else:\n if self.abbrev: # accept shortened versions of commands\n funcs = [func for func in self.keywords if func.startswith(arg) and fu... | [
"0.61590546",
"0.61256295",
"0.60179985",
"0.5816926",
"0.5688947",
"0.5648416",
"0.5534845",
"0.5470439",
"0.53763974",
"0.53491557",
"0.5341609",
"0.5332069",
"0.5326649",
"0.53201157",
"0.53159",
"0.5265616",
"0.52220535",
"0.5211293",
"0.5182447",
"0.5174981",
"0.5169188"... | 0.75629675 | 0 |
Set the access key as key=your_googlemaps_key. This must be called prior to contacting the API. | def set_api_access_keys(**kwargs):
API_BASE_PARAMS['key'] = kwargs['key'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetAPIKey(self, api_key):\n self._api_key = api_key",
"def SetAPIKey(self, api_key):\n self._api_key = api_key",
"def SetAPIKey(self, api_key):\n self._analyzer.SetAPIKey(api_key)",
"def update_key(self, key):\n self._api_key = key",
"def api_key(self, api_key):\n\n self._api_key... | [
"0.6702951",
"0.6702951",
"0.64656013",
"0.63789594",
"0.63458663",
"0.63154477",
"0.62301403",
"0.62292933",
"0.62059003",
"0.61881185",
"0.60916674",
"0.60765517",
"0.5990251",
"0.5933332",
"0.58120465",
"0.5781521",
"0.57431203",
"0.57308316",
"0.5702196",
"0.56874853",
"0... | 0.6750033 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.