query stringlengths 9 3.4k | document stringlengths 9 87.4k | metadata dict | negatives listlengths 4 101 | negative_scores listlengths 4 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Takes a datetime object and returns POSIX UTC in nanoseconds | def date_to_nano(ts):
return calendar.timegm(ts.utctimetuple()) * int(1e3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unix_time_nanos(dt):\n return timedelta_to_micros(dt - epoch)",
"def get_epoch_time(utc_datetime=None):\n if not utc_datetime:\n utc_datetime = datetime.datetime.utcnow()\n return math.ceil((utc_datetime - EPOCH_START).total_seconds())",
"def datetime_to_gpstimestamp_nanoseconds(date):\n ... | [
"0.7196696",
"0.6794556",
"0.67814964",
"0.6744819",
"0.6744819",
"0.67223793",
"0.6684839",
"0.6624673",
"0.65977186",
"0.6539144",
"0.6514163",
"0.65055406",
"0.64669174",
"0.64562154",
"0.63818485",
"0.6372414",
"0.6349268",
"0.62804013",
"0.62467533",
"0.6239043",
"0.6236... | 0.6813911 | 1 |
Create a random image from the passed files | def combine(filenames, size=None, number=None, dimensions=None):
# some guards
if filenames is None or len(filenames) == 0:
print('Not enough files provided')
return
if number is None:
number = 1
# dimensions overrules number
if dimensions is None:
dimensions = Dimensions(1, number)
else:
number = dimensions.rows * dimensions.columns
if size is None:
size = Size(400, 200)
# copy and shuffle
shuffled = filenames[:]
random.shuffle(shuffled)
# pick one base image to fill the canvas
base = shuffled[0]
rest = shuffled[1:]
# create grayscale versions
images = map(image, shuffled)
grayscales = list(map(make_grayscale, images))
# create a new image and paste the grayscales
combined = list()
for _ in range(number):
combined.append(combine_images(grayscales, size=size))
show_collage(combined, dimensions) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genrandimg(args) -> None:\n\n size = (int(args.x), int(args.y))\n fp = Image.new(\"RGB\", size)\n data = []\n\n if not args.c: # If color\n for i in range(size[0]*size[1]):\n r = random.choice([0x00, 0xff])\n data.append((r, r, r)) # Each RGB value is the same random ... | [
"0.7213311",
"0.7048324",
"0.68658197",
"0.67537504",
"0.6742094",
"0.6648611",
"0.66101664",
"0.6598174",
"0.6413809",
"0.6400469",
"0.6399509",
"0.6385771",
"0.63828856",
"0.63731104",
"0.63583726",
"0.6349746",
"0.6326436",
"0.6324452",
"0.63108253",
"0.62726486",
"0.62457... | 0.0 | -1 |
crop a square from a random location in image | def crop_square(image, size):
width, height = image.size
top = random.randint(0, max(0, height-size))
left = random.randint(0, max(0, width-size))
bottom = min(top + size, height)
right = min(left + size, width)
return image.crop((left, top, right, bottom)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __randomCrop(self, img):\n limit = self.PROCESSING_DIM - self.INPUT_DIM\n # pick 2 random integers less than this limit as the origin of the cropped image\n x_start = np.random.randint(limit)\n y_start = np.random.randint(limit)\n return img.crop((x_start, y_start, x_start + ... | [
"0.7516474",
"0.7385669",
"0.7284761",
"0.72695327",
"0.7268751",
"0.7198979",
"0.71195275",
"0.709904",
"0.70559186",
"0.69418275",
"0.6898815",
"0.6874871",
"0.68389267",
"0.6755586",
"0.67538106",
"0.6685173",
"0.66399777",
"0.66174954",
"0.65900636",
"0.65848845",
"0.6583... | 0.82719237 | 0 |
Generates an SGF file with the game provided within the temp directory | def _get_input_filepath(self, game_id: int) -> str:
with self._db_connection as connection:
with connection.cursor() as cursor:
cursor.execute('SELECT sgf_content FROM games WHERE id=%s', (game_id,))
if cursor.rowcount == 0:
raise GameNotFoundError()
sgf_content, = cursor.fetchone()
file_descriptor, filepath = tempfile.mkstemp('.sgf')
with open(file_descriptor, 'wb') as file:
file.write(sgf_content)
return filepath | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instantiate_for_spirv_args(self, testcase):\n shader, self.filename = tempfile.mkstemp(\n dir=testcase.directory, suffix=self.suffix)\n shader_object = os.fdopen(shader, 'w')\n shader_object.write(self.source)\n shader_object.close()\n return self.filename",
"def main():\n\n args = p... | [
"0.5956804",
"0.59355676",
"0.59196234",
"0.586338",
"0.5857218",
"0.58492386",
"0.5716386",
"0.57071114",
"0.5694615",
"0.565109",
"0.56128067",
"0.56030047",
"0.55999684",
"0.5515769",
"0.54997516",
"0.54982835",
"0.5453069",
"0.5453069",
"0.54357845",
"0.5433838",
"0.53828... | 0.6236334 | 0 |
Generate the flow chart. | def flow_chart(FLOW_CHART=POSYDON_FLOW_CHART, CHANGE_FLOW_CHART=None):
if CHANGE_FLOW_CHART is not None:
for key in CHANGE_FLOW_CHART.keys():
if key in FLOW_CHART.keys():
# this assume CHANGE_FLOW_CHART[key] = 'step_XXX'
FLOW_CHART[key] = CHANGE_FLOW_CHART[key]
return FLOW_CHART | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate(self, diagram):",
"def make_flow_diagram_png(self, png):\n\n try:\n from graphviz import Digraph\n except:\n print(\"Cannot make flow-chart as graphviz was not loaded\")\n return\n\n styles = {\n 'graph': {\n 'fontsize':... | [
"0.65753615",
"0.6409763",
"0.62430334",
"0.6241974",
"0.62222016",
"0.6200155",
"0.610594",
"0.6080388",
"0.6074078",
"0.6023732",
"0.60021436",
"0.5970771",
"0.5950799",
"0.5891337",
"0.57867914",
"0.5776768",
"0.57413834",
"0.57351696",
"0.570756",
"0.5675835",
"0.56559193... | 0.56465495 | 22 |
return a tuple of (isHit, hitResult). isHit is a Boolean with is true in case of hit and false in case of miss. in case of hit hitResult is HPA if request.addr is cached in the tlb, otherwise hitResult is None | def lookup(self, request):
if request.addr in self._addressMap:
return (True, self._addressMap[request.addr])
else:
return (False, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _checkHit( self , bp ):\n hit = 0\n if bp.jpyhits != 0 :\n # check hits context\n bp.hitted = bp.hitted + 1\n if bp.hitStyle == HIT_EQUALS_TO and \\\n bp.hitted == bp.jpyhits :\n hit = 1\n elif bp.hitStyle == HIT_... | [
"0.59976083",
"0.5989675",
"0.5826117",
"0.5499163",
"0.54839325",
"0.5301686",
"0.52203494",
"0.516528",
"0.5153411",
"0.5124234",
"0.50933915",
"0.5003426",
"0.4978922",
"0.49499053",
"0.49425858",
"0.4921342",
"0.4921074",
"0.49039856",
"0.48851854",
"0.48693472",
"0.48693... | 0.64621645 | 0 |
update the tlb with the translation address from updateObj | def update(self, updateObj):
#if we've allocated all free entries in tlb
if len(self._allocatedQ) == self._maxSize:
#remove the old entries from the tlb (fifo order)
oldUpdateObj = self._allocatedQ.popleft()
del self._addressMap[oldUpdateObj.requestAddr]
reqAddr,tranAddr = updateObj.requestAddr, updateObj.translatedAddr
self._addressMap[reqAddr] = tranAddr
self._allocatedQ.append(updateObj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, obj):\n self.identity_map[obj._instance_key] = obj\n self.register_dirty(obj)",
"def _update_object(self, data_dict):\r\n pass",
"def gen_update(self, TL):\r\n pass",
"def update(self, obj):\n self._updater.update(obj)",
"def rs_edit_upd(obj):\n verts ... | [
"0.57816815",
"0.56557685",
"0.55526066",
"0.5421197",
"0.5410602",
"0.53786093",
"0.5346271",
"0.53038764",
"0.52939814",
"0.5269879",
"0.5261274",
"0.52505845",
"0.52505845",
"0.5190733",
"0.5168241",
"0.51626116",
"0.515856",
"0.51562643",
"0.5152305",
"0.51184386",
"0.508... | 0.68263865 | 0 |
Create asset, need correct type, title, label and url | def create(self) -> requests.request:
# Check needed values
if None in [self.args.type, self.args.title, self.args.label, self.args.url]:
raise Exception('Provide all parameters for asset creation')
# Check type
if self.args.type not in ['photo', 'video']:
raise Exception('Asset can only be of type photo or video')
# Check URL validity
if self.check_url_invalidity():
raise Exception('Provided URL is not valid')
# Send POST request
return requests.post(
self.REQUEST_URL,
{'type': self.args.type, 'title': self.args.title, 'label': self.args.label, 'url': self.args.url}
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_system_asset(self):\n pass",
"def createAsset(assFolder, *args):\n createAssetUI(assFolder)",
"def GenerateAssetForCreateRequest(args):\n module = dataplex_api.GetMessageModule()\n resource_spec_field = module.GoogleCloudDataplexV1AssetResourceSpec\n resource_spec = module.GoogleCl... | [
"0.671682",
"0.64737254",
"0.6421837",
"0.62232536",
"0.6000631",
"0.59809226",
"0.5915411",
"0.5874975",
"0.5862183",
"0.583357",
"0.580872",
"0.57912344",
"0.5771107",
"0.5771107",
"0.57580495",
"0.56909776",
"0.56909263",
"0.5686929",
"0.5659839",
"0.56492126",
"0.56392914... | 0.6872285 | 0 |
Read single asset or all of them, depending if ID is provided | def read(self) -> requests.request:
# Check if id is set,
if self.args.id is not None:
self.REQUEST_URL += str(self.args.id)
# Send GET request
return requests.get(self.REQUEST_URL) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_asset(self, asset_id):\n endpoint = '/assets/{}'.format(asset_id)\n return self._api_call('get', endpoint)",
"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_typ... | [
"0.6951302",
"0.67110074",
"0.66501635",
"0.662902",
"0.6581352",
"0.65655005",
"0.6426896",
"0.63660824",
"0.6286953",
"0.62688595",
"0.62399113",
"0.60289276",
"0.5941439",
"0.5891376",
"0.58774966",
"0.586067",
"0.5850253",
"0.58426815",
"0.5842644",
"0.5815659",
"0.580382... | 0.0 | -1 |
Update asset, needs ID, title, label and url | def update(self) -> requests.request:
# Check if id is set
if self.args.id is None:
raise Exception('Provide id of asset you want to update')
# Check URL validity
if self.args.url is not None and self.check_url_invalidity():
raise Exception('Provided URL is not valid')
# Send PUT request
return requests.put(
self.REQUEST_URL + str(self.args.id),
{'title': self.args.title, 'label': self.args.label, 'url': self.args.url}
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_asset(cls, id, asset_data):\n\n return ph_base._update_record('asset', id, asset_data)",
"def test_update_asset(self):\n pass",
"def test_update(self):\n obj = self.provision_single_asset()\n test_string = \"testing this thing\"\n p = {'id': obj.id, 'description': ... | [
"0.73195666",
"0.6679826",
"0.6523849",
"0.6501261",
"0.6478999",
"0.6240539",
"0.6233769",
"0.61489034",
"0.6104539",
"0.60541105",
"0.59750587",
"0.58513236",
"0.5828668",
"0.580936",
"0.5783961",
"0.5755456",
"0.5726288",
"0.571024",
"0.56786734",
"0.5664309",
"0.56492716"... | 0.73020154 | 1 |
Delete asset, needs ID | def delete(self) -> requests.request:
# Check if id is set
if self.args.id is None:
raise Exception('Provide id of asset you want to delete')
# Send DELETE request
return requests.delete(self.REQUEST_URL + str(self.args.id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_asset(self, asset_id, asset_type):\n return self.asset(asset_id, asset_type=asset_type, action='DELETE')",
"def test_delete_asset(self):\n pass",
"def delete(self, _id):",
"def delete_url_asset(self, asset_id):\n return self.delete_asset(asset_id, 'URL')",
"def test_delete(s... | [
"0.79241407",
"0.7676571",
"0.7436167",
"0.7214911",
"0.7157785",
"0.7132754",
"0.6974048",
"0.6962282",
"0.69503105",
"0.6911497",
"0.68340725",
"0.6808648",
"0.6807498",
"0.6734712",
"0.6727808",
"0.67007345",
"0.669589",
"0.6653962",
"0.6645524",
"0.6641693",
"0.6624981",
... | 0.7802429 | 1 |
Returns True if URL is invalid, False if it is not | def check_url_invalidity(self) -> bool:
validate = URLValidator()
try:
validate(self.args.url)
return False
except ValidationError:
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_url(value):\n\n valid = validators.url(value)\n if valid != True:\n return False",
"def is_valid_url(url: str) -> bool:\n try:\n requests.get(url)\n except requests.exceptions.RequestException:\n return False\n return True",
"def check_url(value):\n\n valid = va... | [
"0.830075",
"0.8289973",
"0.82301325",
"0.82217",
"0.81955594",
"0.8174947",
"0.8111032",
"0.81069154",
"0.81027186",
"0.80677193",
"0.8043112",
"0.8043112",
"0.80158013",
"0.79966223",
"0.79324365",
"0.78702646",
"0.78689444",
"0.7865635",
"0.7850163",
"0.7827034",
"0.780993... | 0.8617458 | 0 |
Create a new Predicate to represent unary predicate f. | def __init__(self, f):
self._f = f | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predicate(f):\n wrapper = Predicate(f)\n update_wrapper(wrapper, f)\n return wrapper",
"def predicate (self, X, * args, ** kw) :\n self.lhs = self.lhs.predicate (X, * args, ** kw)\n return self",
"def _build_unary_op(op):\n def unary_op(self):\n \"\"\"`plist` unary operation; app... | [
"0.7325501",
"0.6114964",
"0.59238136",
"0.5898684",
"0.56512576",
"0.56399626",
"0.5532869",
"0.5505957",
"0.5475041",
"0.5462972",
"0.5391374",
"0.5389804",
"0.5385157",
"0.53825283",
"0.5350967",
"0.5252026",
"0.5249999",
"0.52445775",
"0.5229073",
"0.52238727",
"0.5215285... | 0.0 | -1 |
Return this Predicate composed with other. | def __matmul__(self, other):
if not isinstance(other, Callable):
return NotImplemented
return Predicate(lambda x: self(other(x))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __or__(self, other):\n intersection = proto.FilterExpression()\n domains = [self.filter, other.filter]\n intersection.filter_intersection.filter_expressions.extend(domains)\n self.filter = intersection\n return self",
"def __and__(self, other):\n assert isinstance(ot... | [
"0.71648806",
"0.69496894",
"0.69073856",
"0.6863349",
"0.6848381",
"0.6689735",
"0.6651311",
"0.6630762",
"0.6501289",
"0.6454304",
"0.64342827",
"0.64284235",
"0.6410507",
"0.6387207",
"0.63404816",
"0.63197625",
"0.6313173",
"0.6309717",
"0.63047457",
"0.6297845",
"0.62906... | 0.635807 | 14 |
Return other composed with this Predicate. | def __rshift__(self, other):
if isinstance(other, Composable):
return other @ self
elif isinstance(other, Callable):
return Function(lambda x: other(self(x)))
else:
return NotImplemented | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __or__(self, other):\n @AccessFilter\n def f(*args, **kwargs):\n first = self(*args, **kwargs)\n if first is None:\n return other(*args, **kwargs)\n return first\n return f",
"def __or__(self, other):\n intersection = proto.FilterExp... | [
"0.68858445",
"0.68836015",
"0.66963625",
"0.6683108",
"0.66076714",
"0.6575702",
"0.6492694",
"0.6471044",
"0.63135135",
"0.63019264",
"0.62777",
"0.62699765",
"0.62626326",
"0.62601894",
"0.62160033",
"0.62152016",
"0.617807",
"0.61720514",
"0.61433095",
"0.614303",
"0.6123... | 0.0 | -1 |
Return other composed with this Predicate. | def __rmatmul__(self, other):
if not isinstance(other, Callable):
return NotImplemented
return self >> other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __or__(self, other):\n @AccessFilter\n def f(*args, **kwargs):\n first = self(*args, **kwargs)\n if first is None:\n return other(*args, **kwargs)\n return first\n return f",
"def __or__(self, other):\n intersection = proto.FilterExp... | [
"0.68858445",
"0.68836015",
"0.66963625",
"0.6683108",
"0.66076714",
"0.6575702",
"0.6492694",
"0.6471044",
"0.63135135",
"0.63019264",
"0.62777",
"0.62699765",
"0.62626326",
"0.62601894",
"0.62160033",
"0.62152016",
"0.617807",
"0.61720514",
"0.61433095",
"0.614303",
"0.6123... | 0.0 | -1 |
Return this Predicate composed with other. | def __rrshift__(self, other):
if isinstance(other, Callable):
return self @ other
else:
return self(other) # Function application | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __or__(self, other):\n intersection = proto.FilterExpression()\n domains = [self.filter, other.filter]\n intersection.filter_intersection.filter_expressions.extend(domains)\n self.filter = intersection\n return self",
"def __and__(self, other):\n assert isinstance(ot... | [
"0.71648806",
"0.69496894",
"0.69073856",
"0.6863349",
"0.6848381",
"0.6689735",
"0.6651311",
"0.6630762",
"0.6501289",
"0.6454304",
"0.64342827",
"0.64284235",
"0.6410507",
"0.6387207",
"0.635807",
"0.63404816",
"0.63197625",
"0.6313173",
"0.6309717",
"0.63047457",
"0.629784... | 0.0 | -1 |
Decorator that lifts an unary predicate into a Predicate. | def predicate(f):
wrapper = Predicate(f)
update_wrapper(wrapper, f)
return wrapper | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predicate (self, X, * args, ** kw) :\n self.lhs = self.lhs.predicate (X, * args, ** kw)\n return self",
"def visit_unbound_predicate(self, predicate) -> T:",
"def _generate_unary_deferer(op_func):\n\n def deferer(self, *args, **kwargs):\n return type(self)._defer_unary_elementwise(\... | [
"0.61001146",
"0.59637415",
"0.58849007",
"0.58419997",
"0.5755853",
"0.5751772",
"0.5665722",
"0.5661092",
"0.5583315",
"0.55070066",
"0.5454716",
"0.5451329",
"0.53772974",
"0.5363552",
"0.53583723",
"0.53360695",
"0.5334606",
"0.531459",
"0.52997607",
"0.52853334",
"0.5235... | 0.6924056 | 0 |
Prints a few recipes from each src for visual spotcheck of functionality | def check(out):
counts = {'ar': 0,
'fn': 0,
'epi': 0}
for recipe in out.values():
if counts[recipe['src']] < 10:
print(recipe)
counts[recipe['src']] += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showData(self, recipes):\n for recipe in recipes:\n json.dump(recipe, self.stdout, indent=2)\n print\n print '/' + '*' * 50 + '/'",
"def txt_of_sources_in_run (ins, exp, run) :\n list_of_detectors = detectors(ins, exp, run)\n txt = '\\nList of detectors for inst... | [
"0.62353206",
"0.62227947",
"0.5890203",
"0.5839911",
"0.5721225",
"0.5711892",
"0.5675986",
"0.565802",
"0.56565994",
"0.5596076",
"0.5542771",
"0.5537064",
"0.55224365",
"0.55221796",
"0.5515002",
"0.546948",
"0.54653454",
"0.5446445",
"0.54346985",
"0.5389686",
"0.53591204... | 0.49848267 | 90 |
Remove previous transaction DB and reinitialize the action objects so we don't have to worry about conflicts from reusing PDS ID's/DOI's between tests. | def setUp(self) -> None:
if os.path.isfile(self.db_name):
os.remove(self.db_name)
self._list_action = DOICoreActionList(db_name=self.db_name)
self._reserve_action = DOICoreActionReserve(db_name=self.db_name)
self._release_action = DOICoreActionRelease(db_name=self.db_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset():\n teardown_db()\n build()",
"def tearDown(self):\n\t\tTransaction.transaction_list = []",
"def tearDown(self):\r\n\r\n db.session.rollback()\r\n db.drop_all()",
"def tearDown(self):\n db.session.commit()\n db.drop_all()",
"def tearDown(self):\n model.DB... | [
"0.69345915",
"0.6716611",
"0.66229075",
"0.6542029",
"0.65316594",
"0.6505639",
"0.64698505",
"0.6453844",
"0.6446514",
"0.6446514",
"0.64258087",
"0.64258087",
"0.63932043",
"0.6385942",
"0.636722",
"0.636722",
"0.636722",
"0.636722",
"0.636722",
"0.636722",
"0.636722",
"... | 0.6570783 | 3 |
Patch for DOIWebClient.submit_content(). Allows a reserve to occur without actually submitting anything to the service provider's test server. | def webclient_submit_patch(
self, payload, url=None, username=None, password=None, method=WEB_METHOD_POST, content_type=CONTENT_TYPE_XML
):
# Parse the DOI's from the input label, add a dummy DOI value,
# and create the output label
dois, _ = ListActionTestCase._web_parser.parse_dois_from_label(payload, content_type=CONTENT_TYPE_JSON)
doi = dois[0]
doi.doi = "10.17189/abc123"
o_doi_label = ListActionTestCase._record_service.create_doi_record(doi, content_type=CONTENT_TYPE_JSON)
return doi, o_doi_label | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submitRequestForTesting(self, request, renameRequestForTesting = True):\n raise NotImplementedError",
"def test_post_cve_id_reserve_priority(reg_user_headers):\n res = requests.post(\n f'{env.AWG_BASE_URL}{CVE_ID_URL}',\n headers=reg_user_headers,\n params={\n 'amoun... | [
"0.55728",
"0.54935604",
"0.5323035",
"0.5286645",
"0.5229979",
"0.5175934",
"0.5139684",
"0.50914127",
"0.5047542",
"0.50234425",
"0.4988",
"0.49536908",
"0.49397418",
"0.49372005",
"0.4893216",
"0.48902392",
"0.4881569",
"0.48794812",
"0.4870254",
"0.48354614",
"0.4760686",... | 0.46863896 | 26 |
Test listing of entries, querying by workflow status | def test_list_by_status(self):
# Submit a reserve, then query by draft status to retrieve
reserve_kwargs = {
"input": join(self.input_dir, "pds4_bundle_with_contributors.xml"),
"node": "img",
"submitter": "my_user@my_node.gov",
"force": True,
}
doi_label = self._reserve_action.run(**reserve_kwargs)
dois, _ = self._web_parser.parse_dois_from_label(doi_label)
doi = dois[0]
list_kwargs = {"status": DoiStatus.Draft}
list_result = json.loads(self._list_action.run(**list_kwargs))
self.assertEqual(len(list_result), 1)
list_result = list_result[0]
self.assertEqual(list_result["status"], doi.status)
self.assertEqual(list_result["title"], doi.title)
self.assertEqual(list_result["subtype"], doi.product_type_specific)
self.assertEqual(list_result["identifier"], doi.pds_identifier)
# Now move the draft to review, use JSON as the format to ensure
# this test works for both DataCite and OSTI
doi_label = self._record_service.create_doi_record(dois, content_type=CONTENT_TYPE_JSON)
with tempfile.NamedTemporaryFile(mode="w", suffix=".json") as temp_file:
temp_file.write(doi_label)
temp_file.flush()
review_kwargs = {
"input": temp_file.name,
"node": "img",
"submitter": "my_user@my_node.gov",
"force": True,
"review": True,
}
review_json = self._release_action.run(**review_kwargs)
dois, _ = self._web_parser.parse_dois_from_label(review_json, content_type=CONTENT_TYPE_JSON)
doi = dois[0]
# Now query for review status
list_kwargs = {"status": DoiStatus.Review}
list_result = json.loads(self._list_action.run(**list_kwargs))
self.assertEqual(len(list_result), 1)
list_result = list_result[0]
self.assertEqual(list_result["status"], doi.status)
self.assertEqual(list_result["title"], doi.title)
self.assertEqual(list_result["subtype"], doi.product_type_specific)
self.assertEqual(list_result["identifier"], doi.pds_identifier)
# Run the same query again using the label format
list_kwargs = {"status": DoiStatus.Review, "format": FORMAT_LABEL}
list_result = self._list_action.run(**list_kwargs)
dois, _ = self._web_parser.parse_dois_from_label(list_result)
self.assertEqual(len(dois), 1)
output_doi = dois[0]
self.assertEqual(doi.pds_identifier, output_doi.pds_identifier)
self.assertEqual(doi.title, output_doi.title)
self.assertEqual(doi.doi, output_doi.doi)
self.assertEqual(doi.status, output_doi.status)
# Finally, query for draft status again, should get no results back
list_kwargs = {"status": DoiStatus.Draft, "format": FORMAT_RECORD}
list_result = json.loads(self._list_action.run(**list_kwargs))
self.assertEqual(len(list_result), 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_workflows_list(self):\n pass",
"def test_cron_workflow_service_list_cron_workflows(self):\n pass",
"def test_workflows_get(self):\n pass",
"def test_workflows_get(self):\n pass",
"def test_cron_workflow_service_list_cron_workflows2(self):\n pass",
"def test_ent... | [
"0.6941432",
"0.6510107",
"0.64596826",
"0.64596826",
"0.6431431",
"0.6180101",
"0.6043863",
"0.6035261",
"0.6024292",
"0.6019159",
"0.6010688",
"0.59458965",
"0.5945369",
"0.58769286",
"0.58736396",
"0.58419627",
"0.5841523",
"0.58330303",
"0.57939965",
"0.5787372",
"0.57515... | 0.61235964 | 6 |
Test the transaction_for_doi method | def test_get_transaction_for_doi(self):
# Submit a reserve, then use the assigned doi to get the transaction record
reserve_kwargs = {
"input": join(self.input_dir, "pds4_bundle_with_contributors.xml"),
"node": "img",
"submitter": "my_user@my_node.gov",
"force": True,
}
doi_label = self._reserve_action.run(**reserve_kwargs)
dois, _ = self._web_parser.parse_dois_from_label(doi_label)
doi = dois[0]
transaction_record = self._list_action.transaction_for_doi(doi.doi)
self.assertIsInstance(transaction_record, dict)
# Make sure the transaction record aligns with the Doi record
self.assertEqual(doi.doi, transaction_record["doi"])
self.assertEqual(doi.pds_identifier, transaction_record["identifier"])
self.assertEqual(doi.status, transaction_record["status"])
self.assertEqual(doi.title, transaction_record["title"])
# Ensure we get an exception when searching for an unknown DOI value
with self.assertRaises(UnknownDoiException):
self._list_action.transaction_for_doi("unknown/doi") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_transaction_for_identifier(self):\n # Submit a reserve, then use the PDS identifier to get the transaction record\n reserve_kwargs = {\n \"input\": join(self.input_dir, \"pds4_bundle_with_contributors.xml\"),\n \"node\": \"img\",\n \"submitter\": \"my_use... | [
"0.7132114",
"0.59276116",
"0.58578324",
"0.5844066",
"0.5840851",
"0.58291525",
"0.57940173",
"0.57708603",
"0.5729419",
"0.5708635",
"0.569995",
"0.5694162",
"0.56870985",
"0.5622052",
"0.5576013",
"0.55612105",
"0.55599636",
"0.5553421",
"0.5456069",
"0.54547375",
"0.53775... | 0.8255177 | 0 |
Test the transaction_for_identifier method | def test_get_transaction_for_identifier(self):
# Submit a reserve, then use the PDS identifier to get the transaction record
reserve_kwargs = {
"input": join(self.input_dir, "pds4_bundle_with_contributors.xml"),
"node": "img",
"submitter": "my_user@my_node.gov",
"force": True,
}
doi_label = self._reserve_action.run(**reserve_kwargs)
dois, _ = self._web_parser.parse_dois_from_label(doi_label)
doi = dois[0]
transaction_record = self._list_action.transaction_for_identifier(doi.pds_identifier)
self.assertIsInstance(transaction_record, dict)
# Make sure the transaction record aligns with the Doi record
self.assertEqual(doi.doi, transaction_record["doi"])
self.assertEqual(doi.pds_identifier, transaction_record["identifier"])
self.assertEqual(doi.status, transaction_record["status"])
self.assertEqual(doi.title, transaction_record["title"])
# Ensure we get an exception when searching for an unknown ID value
with self.assertRaises(UnknownIdentifierException):
self._list_action.transaction_for_identifier("urn:unknown_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_transaction_details_request(self):\n self.trans_details.get_transaction_details(\n trans_id = 123456,\n )",
"def test_get_uniqueId():\n rep=RentRepository()\n rep.store(\"12\",\"23\",\"1\", \"1\")\n try:\n\n idBook=\"13\"\n idCustomer=\"54\"\n f... | [
"0.61464214",
"0.60946786",
"0.6051062",
"0.5957183",
"0.5921026",
"0.5911639",
"0.589465",
"0.586385",
"0.5855458",
"0.5846576",
"0.5818048",
"0.5764767",
"0.57319367",
"0.5727006",
"0.57104456",
"0.5699692",
"0.5688432",
"0.5681126",
"0.567688",
"0.56671363",
"0.5657053",
... | 0.75881815 | 0 |
Test the output_label_for_transaction method | def test_get_output_label_for_transaction(self):
# Submit a reserve, then use the PDS identifier to get the transaction record
reserve_kwargs = {
"input": join(self.input_dir, "pds4_bundle_with_contributors.xml"),
"node": "img",
"submitter": "my_user@my_node.gov",
"force": True,
}
doi_label = self._reserve_action.run(**reserve_kwargs)
dois, _ = self._web_parser.parse_dois_from_label(doi_label)
doi = dois[0]
transaction_record = self._list_action.transaction_for_identifier(doi.pds_identifier)
# Now use the transaction record to get the label associated to the transaction
output_label_path = self._list_action.output_label_for_transaction(transaction_record)
# Ensure the path returned corresponds to an actual file
self.assertTrue(os.path.exists(output_label_path))
# Read the output label, its contents should match what was returned from
# the reserve request
with open(output_label_path, "r") as infile:
output_label = infile.read()
self.assertEqual(doi_label, output_label)
# Make sure we get an exception when the transaction record references
# a path that does not exist
transaction_record["transaction_key"] = "/fake/path/output.json"
with self.assertRaises(NoTransactionHistoryForIdentifierException):
self._list_action.output_label_for_transaction(transaction_record) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_output(self, workunit, label, s):\r\n pass",
"def handle_output(self, workunit, label, s):\r\n pass",
"def test_labels(self):\n self.compliance_tester.test_labels(self.oi)",
"def test_label(self):\n xs = t.Label(t.Exactly(\"x\"), 'CustomLabel')\n self.assertEqual(writePy... | [
"0.6840131",
"0.6840131",
"0.6280704",
"0.60962415",
"0.6002755",
"0.5660651",
"0.5654368",
"0.5635582",
"0.5635582",
"0.5635582",
"0.5634114",
"0.562665",
"0.55732125",
"0.5569116",
"0.55691105",
"0.5563312",
"0.5546234",
"0.5544815",
"0.55269396",
"0.5515246",
"0.5514803",
... | 0.7726957 | 0 |
Continuously run inference on images acquired from the camera. | def run(model: str, display_mode: str, num_threads: int, enable_edgetpu: bool,
camera_id: int, width: int, height: int) -> None:
# Initialize the image segmentation model.
base_options = core.BaseOptions(
file_name=model, use_coral=enable_edgetpu, num_threads=num_threads)
segmentation_options = processor.SegmentationOptions(
output_type=processor.SegmentationOptions.OutputType.CATEGORY_MASK)
options = vision.ImageSegmenterOptions(
base_options=base_options, segmentation_options=segmentation_options)
segmenter = vision.ImageSegmenter.create_from_options(options)
# Variables to calculate FPS
counter, fps = 0, 0
start_time = time.time()
# Start capturing video input from the camera
cap = cv2.VideoCapture(camera_id)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
# Continuously capture images from the camera and run inference.
while cap.isOpened():
success, image = cap.read()
if not success:
sys.exit(
'ERROR: Unable to read from webcam. Please verify your webcam settings.'
)
counter += 1
image = cv2.flip(image, 1)
# Convert the image from BGR to RGB as required by the TFLite model.
rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# Create TensorImage from the RGB image
tensor_image = vision.TensorImage.create_from_array(rgb_image)
# Segment with each frame from camera.
segmentation_result = segmenter.segment(tensor_image)
# Convert the segmentation result into an image.
seg_map_img, found_colored_labels = utils.segmentation_map_to_image(
segmentation_result)
# Resize the segmentation mask to be the same shape as input image.
seg_map_img = cv2.resize(
seg_map_img,
dsize=(image.shape[1], image.shape[0]),
interpolation=cv2.INTER_NEAREST)
# Visualize segmentation result on image.
overlay = visualize(image, seg_map_img, display_mode, fps,
found_colored_labels)
# Calculate the FPS
if counter % _FPS_AVERAGE_FRAME_COUNT == 0:
end_time = time.time()
fps = _FPS_AVERAGE_FRAME_COUNT / (end_time - start_time)
start_time = time.time()
# Stop the program if the ESC key is pressed.
if cv2.waitKey(1) == 27:
break
cv2.imshow('image_segmentation', overlay)
cap.release()
cv2.destroyAllWindows() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infinite_infer_run():\n try:\n # This cat-dog model is implemented as binary classifier, since the number\n # of labels is small, create a dictionary that converts the machine\n # labels to human readable labels.\n model_type = 'classification'\n output_map = {0: 'dog', 1:... | [
"0.7201383",
"0.7166809",
"0.6941723",
"0.6620557",
"0.653115",
"0.6395781",
"0.6394687",
"0.63232785",
"0.63152456",
"0.6313723",
"0.62553",
"0.6244509",
"0.62352383",
"0.623384",
"0.6219073",
"0.6191145",
"0.6188543",
"0.61679995",
"0.6158043",
"0.61451375",
"0.6117609",
... | 0.6359815 | 7 |
Visualize segmentation result on image. | def visualize(
input_image: np.ndarray, segmentation_map_image: np.ndarray,
display_mode: str, fps: float,
colored_labels: List[processor.Segmentation.ColoredLabel]) -> np.ndarray:
# Show the input image and the segmentation map image.
if display_mode == 'overlay':
# Overlay mode.
overlay = cv2.addWeighted(input_image, _OVERLAY_ALPHA,
segmentation_map_image, _OVERLAY_ALPHA, 0)
elif display_mode == 'side-by-side':
# Side by side mode.
overlay = cv2.hconcat([input_image, segmentation_map_image])
else:
sys.exit(f'ERROR: Unsupported display mode: {display_mode}.')
# Show the FPS
fps_text = 'FPS = ' + str(int(fps))
text_location = (_FPS_LEFT_MARGIN, _LEGEND_ROW_SIZE)
cv2.putText(overlay, fps_text, text_location, cv2.FONT_HERSHEY_PLAIN,
_LEGEND_FONT_SIZE, _LEGEND_TEXT_COLOR, _LEGEND_FONT_THICKNESS)
# Initialize the origin coordinates of the label.
legend_x = overlay.shape[1] + _LABEL_MARGIN
legend_y = overlay.shape[0] // _LEGEND_ROW_SIZE + _LABEL_MARGIN
# Expand the frame to show the label.
overlay = cv2.copyMakeBorder(overlay, 0, 0, 0, _PADDING_WIDTH_FOR_LEGEND,
cv2.BORDER_CONSTANT, None,
_LEGEND_BACKGROUND_COLOR)
# Show the label on right-side frame.
for colored_label in colored_labels:
rect_color = (colored_label.r, colored_label.g, colored_label.b)
start_point = (legend_x, legend_y)
end_point = (legend_x + _LEGEND_RECT_SIZE, legend_y + _LEGEND_RECT_SIZE)
cv2.rectangle(overlay, start_point, end_point, rect_color,
-_LEGEND_FONT_THICKNESS)
label_location = legend_x + _LEGEND_RECT_SIZE + _LABEL_MARGIN, legend_y + _LABEL_MARGIN
cv2.putText(overlay, colored_label.class_name, label_location,
cv2.FONT_HERSHEY_PLAIN, _LEGEND_FONT_SIZE, _LEGEND_TEXT_COLOR,
_LEGEND_FONT_THICKNESS)
legend_y += (_LEGEND_RECT_SIZE + _LABEL_MARGIN)
return overlay | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_visualization(image):\n original_im = Image.fromarray(image)\n seg_map = model.run(original_im)\n seg_image = label_to_color_image(seg_map).astype(np.uint8)\n\n return seg_image",
"def vis_segmentation(image, seg_map):\n plt.figure(figsize=(20, 20))\n \n seg_image = label_to_color_image... | [
"0.7556288",
"0.7192041",
"0.71200585",
"0.71015465",
"0.706243",
"0.6990507",
"0.6886198",
"0.67751426",
"0.67732537",
"0.67344666",
"0.66918963",
"0.66245836",
"0.6601413",
"0.649651",
"0.64486897",
"0.63977766",
"0.6357956",
"0.6344634",
"0.6343034",
"0.6306382",
"0.630115... | 0.0 | -1 |
Returns count of open changes per reviewer per project Fetches all open changes from gerrit, and returns a dictionary containing all projects with open changes, and for each project, all reviewers and the count of changes they are reviewing. e.g. { | def get_open_change_reviewers_per_project():
config = GerritFetchConfig()
open_changes = fetch.fetch_open_changes(
config.hostname(), config.username(), config.port())
open_change_reviewers_per_project = {}
for gerrit_change in open_changes:
project = gerrit_change.project
reviewers = gerrit_change.reviewers
if not reviewers:
continue
# Skip Jenkins
reviewers[:] = [
reviewer
for reviewer in reviewers
if reviewer.name and "Jenkins" not in reviewer.name]
if project in open_change_reviewers_per_project:
reviewer_open_count = open_change_reviewers_per_project[project]
for reviewer in reviewers:
if reviewer.name in reviewer_open_count:
reviewer_open_count[reviewer.name] += 1
else:
reviewer_open_count[reviewer.name] = 1
else:
reviewer_open_count = {}
for reviewer in reviewers:
reviewer_open_count[reviewer.name] = 1
open_change_reviewers_per_project[project] = reviewer_open_count
return open_change_reviewers_per_project | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_current_reviewers_and_counts(project_name):\n reviewer_change_count_per_project = current_load_fetcher.\\\n get_open_change_reviewers_per_project()\n\n if project_name not in reviewer_change_count_per_project and \\\n project_name != PROJECT_ALL:\n logging.warning(\"Project ... | [
"0.6898937",
"0.6401227",
"0.62829226",
"0.61762327",
"0.61221975",
"0.6012132",
"0.58491695",
"0.56204873",
"0.5591274",
"0.5577237",
"0.54595",
"0.54480326",
"0.54340416",
"0.53901017",
"0.5334617",
"0.52910286",
"0.52823967",
"0.5252443",
"0.5237763",
"0.5233384",
"0.52304... | 0.87611914 | 0 |
Return an UTCaware datetime in case of USE_TZ=True. | def tz_aware(value: datetime) -> datetime:
if settings.USE_TZ:
value = value.replace(tzinfo=timezone.utc)
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_freeze_with_timezone_aware_datetime_in_utc():\n utc_now = datetime.datetime.utcnow()\n assert utc_now.tzinfo is None",
"def test_freeze_with_timezone_aware_datetime_in_non_utc():\n utc_now = datetime.datetime.utcnow()\n assert utc_now.tzinfo is None\n assert utc_now == datetime.datetime(1... | [
"0.7496584",
"0.72608817",
"0.71937054",
"0.71411216",
"0.71222836",
"0.7066944",
"0.7022482",
"0.6987124",
"0.6978549",
"0.696762",
"0.6947956",
"0.6856145",
"0.6847567",
"0.68384445",
"0.6833825",
"0.6821648",
"0.6819736",
"0.6792303",
"0.67815375",
"0.6744564",
"0.67071795... | 0.77953434 | 0 |
Adds a step into calculated metrics | def add_step(self):
assert self.y_real is not None and self.y_predicted is not None
# Calculates some metrics
rmse = Metrics.rmse_loss(self.y_real, self.y_predicted)
mse = Metrics.mse_loss(self.y_real, self.y_predicted)
cm = Metrics.confusion_matrix(self.y_real, self.y_predicted)
accuracy = Metrics.accuracy(cm)
# Store them
self.summary['rmse'].append(rmse)
self.summary['accuracy'].append(accuracy)
self.summary['mse'].append(mse)
self.summary['cm'].append(cm) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_metric(self, metric):\n self.metrics.append(metric)\n self.estimate()",
"def add_step(self, step):\n if not step:\n return\n temp = {Result.__STEP: step.get_name(),\n Result.__STATUS: step.get_status(),\n Result.__MESSAGE: step.get_mess... | [
"0.6825129",
"0.68105835",
"0.6705063",
"0.66030556",
"0.6589102",
"0.64661735",
"0.64505416",
"0.63579696",
"0.63276815",
"0.6287285",
"0.62792087",
"0.62393504",
"0.621419",
"0.61822873",
"0.61751336",
"0.6074285",
"0.60637534",
"0.6020474",
"0.59689176",
"0.59689176",
"0.5... | 0.7380234 | 0 |
setup any state tied to the execution of the given method in a class. setup_method is invoked for every test method of a class. | def setUp(self):
self.sc = init_orca_context(cores=4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_method(self, method):\n pass",
"def setup_method(self, method):\n pass",
"def _decorate_setup(self, setup_method):\n @wraps(setup_method)\n def setup_method_wrapper(*args, **kwargs):\n \"\"\"setup method wrapper.\n\n * Locks the required resources for... | [
"0.75783396",
"0.75783396",
"0.7401872",
"0.7324081",
"0.72980446",
"0.7223305",
"0.7029075",
"0.6968911",
"0.68208426",
"0.6795071",
"0.6794884",
"0.6695681",
"0.6685688",
"0.6649251",
"0.659954",
"0.65970254",
"0.65609777",
"0.6541885",
"0.65291595",
"0.64909536",
"0.648552... | 0.0 | -1 |
teardown any state that was previously setup with a setup_method call. | def tearDown(self):
stop_orca_context() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teardown_method(self, method) -> None:",
"def teardown_method(self, method):\n pass",
"def teardown_method(self, method):\n pass",
"def teardown_method(self, test_method):\n self.wo_obj = None\n self.config_data = None",
"def teardown_method(self):",
"def teardown_method(s... | [
"0.79968005",
"0.78846675",
"0.78846675",
"0.7871643",
"0.7792453",
"0.7720631",
"0.7659778",
"0.7625319",
"0.757913",
"0.757913",
"0.75738186",
"0.75738186",
"0.7567817",
"0.7567817",
"0.7567817",
"0.7565642",
"0.7565642",
"0.7565642",
"0.7450825",
"0.7437996",
"0.7437996",
... | 0.0 | -1 |
Format value as USD. | def usd(value):
return f"${value:,.2f}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def usd(value):\r\n return f\"${Decimal(value):,.2f}\"",
"def usd(value):\r\n try:\r\n value = float(value)\r\n except:\r\n return value\r\n if value >= 0:\r\n return \"${:,.2f}\".format(value)\r\n value *= (-1)\r\n return \"(\" + \"${:,.2f}\".format(value) + \")\"",
"def... | [
"0.76879483",
"0.7582937",
"0.755743",
"0.7244131",
"0.71441686",
"0.6954996",
"0.6748754",
"0.6710644",
"0.6710644",
"0.65929615",
"0.65800935",
"0.65752834",
"0.65752834",
"0.65752834",
"0.65752834",
"0.65752834",
"0.6558027",
"0.65126926",
"0.6468342",
"0.6307524",
"0.6275... | 0.69737035 | 6 |
Render message as an apology to user. | def apology(message, code=400):
def escape(s):
"""
Escape special characters.
https://github.com/jacebrowning/memegen#special-characters
"""
for old, new in [("-", "--"), (" ", "-"), ("_", "__"), ("?", "~q"),
("%", "~p"), ("#", "~h"), ("/", "~s"), ("\"", "''")]:
s = s.replace(old, new)
return s
return render_template("apology.html", top=code, bottom=escape(message)), code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apology(message, code=400):\n return render_template(\"apology.html\", top=code, bottom=message), code",
"def apology(message, code=400):\n return render_template(\"error.html\", top=code, bottom=message.upper()), code",
"def horde_message(self, message):",
"def display_message(self, message):\n\t\... | [
"0.74742544",
"0.6289285",
"0.6278975",
"0.6158758",
"0.60953355",
"0.6080088",
"0.59537864",
"0.5929055",
"0.58016074",
"0.563379",
"0.55908906",
"0.55648655",
"0.5527848",
"0.5515716",
"0.54746526",
"0.5456844",
"0.5433086",
"0.5424035",
"0.5416325",
"0.5407209",
"0.5403514... | 0.7279314 | 5 |
Look up quote for symbol. | def lookup(symbol):
# Contact API
try:
api_key = os.environ.get("API_KEY")
response = requests.get(f"https://cloud-sse.iexapis.com/stable/stock/{urllib.parse.quote_plus(str(symbol))}/quote?token={api_key}")
response.raise_for_status()
except requests.RequestException:
flash("Please set API_KEY", 'danger')
return None
# Parse response
try:
quote = response.json()
return {
"name": quote["companyName"],
"price": float(quote["latestPrice"]),
"symbol": quote["symbol"],
"change": quote["change"],
"changePercent": quote["changePercent"],
"volume": quote["volume"],
"week52High": quote["week52High"],
"week52Low": quote["week52Low"],
"open" :quote["open"],
"high" :quote['high'],
"low" : quote["low"]
}
except (KeyError, TypeError, ValueError):
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_symbol(symbol):\n st = Stock(symbol)\n return st.get_quote()",
"def get_quote(symbol):\n\tsymbol = symbol.upper()\n\tif symbol not in settings.SYMBOLS:\n\t\treturn {}\n\tif '.' in symbol:\n\t\tsymbol = symbol.replace('.', '-')\n\tq = caches[\"quotes\"].get(symbol)\n\t# Try yahoo, yql, google, finvi... | [
"0.77724737",
"0.71573526",
"0.6696971",
"0.66310436",
"0.6500589",
"0.6414494",
"0.63421476",
"0.6292875",
"0.626399",
"0.6208056",
"0.61752456",
"0.609538",
"0.60931844",
"0.60736805",
"0.60423803",
"0.602131",
"0.5973954",
"0.59609634",
"0.59431195",
"0.5923931",
"0.586661... | 0.6057747 | 14 |
Create and return a new user | def create_user(fname, lname, email, password, phone_number):
user = User(fname = fname, lname = lname , email = email ,password = password, phone_number = phone_number)
#setting password hash
user.set_password(password)
db.session.add(user)
db.session.commit()
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_user(self):\n if not self.is_valid():\n return None\n # generate a username \n ids = User.objects.values_list('id', flat=True).order_by('-id')[:1]\n if len(ids) > 0:\n # ids[0] will be the maximum value (due to order_by: '-id')\n idnum = ids[0... | [
"0.85978043",
"0.8441793",
"0.84317064",
"0.83086956",
"0.82664645",
"0.8260977",
"0.8254565",
"0.8254421",
"0.8219172",
"0.8196001",
"0.81478876",
"0.8140804",
"0.81115663",
"0.8108405",
"0.80929077",
"0.80836815",
"0.8059754",
"0.8050577",
"0.8027217",
"0.80225056",
"0.8016... | 0.0 | -1 |
Create and return a new event | def create_event(user_id, event_title, event_text, reminder_status, created_at):
event = Event(user_id = user_id, event_title = event_title, event_text = event_text, reminder_status =reminder_status, created_at=created_at)
db.session.add(event)
db.session.commit()
return event | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_new_event(self):\n pass",
"async def createEvent(self, event: Event) -> None:",
"def create_event() -> abc.Event:\n return get_asynclib().Event()",
"def create_event():\n json_data = request.get_json()\n data, error = EventSchema().load(json_data)\n if error:\n return mak... | [
"0.8598986",
"0.8378206",
"0.79282635",
"0.7553991",
"0.75199896",
"0.74393505",
"0.7426032",
"0.7387793",
"0.73809534",
"0.73771966",
"0.73233",
"0.73009956",
"0.7242335",
"0.7199746",
"0.71362734",
"0.713342",
"0.71015835",
"0.7090096",
"0.7079175",
"0.70640576",
"0.7017005... | 0.66051376 | 40 |
Get all Event by user_id | def get_event_by_user_id(user_id):
return Event.query.filter(Event.user_id == user_id).order_by(Event.created_at.desc()).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n return Event.objects.all().filter(user_id=self.request.user)",
"def event_get(tenant_id, user_id=None):",
"async def retrieve_user_events(self, user_id: int) -> Dict[int, BaseEvent]:\n user_events: Dict[int, BaseEvent] = {}\n event: BaseEvent\n for event_id... | [
"0.7322746",
"0.7310857",
"0.72287333",
"0.7047232",
"0.67568713",
"0.6709224",
"0.67006856",
"0.63310444",
"0.62991863",
"0.6286739",
"0.62130445",
"0.62024057",
"0.6089561",
"0.6088284",
"0.6058859",
"0.6029098",
"0.60218024",
"0.6001406",
"0.5960545",
"0.59485763",
"0.5944... | 0.8250652 | 0 |
Return a user by primary key. | def get_user_by_id(user_id):
return User.query.get(user_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user(id):\n pass",
"def get_a_user(public_id):\n return User.query.filter_by(public_id=public_id).first()",
"def user_by_id(user_id):\n user = User.query.filter(User.id == user_id).one_or_none()\n return user",
"def get_user_from_id(user_id):\n return Users.query.filter_by(id=user_... | [
"0.75475955",
"0.7417716",
"0.7407572",
"0.74037224",
"0.73990387",
"0.73675454",
"0.7360707",
"0.73393166",
"0.73393166",
"0.73242134",
"0.7307737",
"0.72689074",
"0.72521853",
"0.72384864",
"0.7193011",
"0.71916515",
"0.7153275",
"0.71368295",
"0.7114498",
"0.709593",
"0.70... | 0.7256318 | 15 |
Return a user by email. | def get_user_by_email(email):
return User.query.filter(User.email == email).first() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user(email):\r\n return User.objects.get(email=email)",
"def helper_get_by_email(user_email):\n user = heart_rate_databases_starter.models.User.objects.raw({\"_id\": user_email}).first() # Get the first user where _id=email\n return user",
"def get_user_by_email(email):\n\n user = User.query.fi... | [
"0.88993454",
"0.8664163",
"0.8543522",
"0.8523675",
"0.8501863",
"0.8466647",
"0.84565693",
"0.8412734",
"0.83376825",
"0.8334499",
"0.820757",
"0.8203786",
"0.81872195",
"0.807034",
"0.80346245",
"0.7973689",
"0.79726994",
"0.7971305",
"0.79690415",
"0.7951832",
"0.79250455... | 0.8563616 | 3 |
Create and return Job Details | def create_job_detail(company_name, job_title, application_deadline, job_listing_url, state, city, application_listed, salary):
job_detail = JobDetail(company_name = company_name, job_title = job_title, application_deadline = application_deadline, job_listing_url = job_listing_url, state = state , city = city, application_listed = application_listed, salary = salary)
db.session.add(job_detail)
db.session.commit()
return job_detail | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def created_job(new_job, bulk_request):\n bulk_request.return_value = '''<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <jobInfo xmlns=\"http://www.force.com/2009/06/asyncapi/dataload\">\n <id>THEJOBID</id>\n <operation>update</operation>\n <object>Lead</object>\n </... | [
"0.7009168",
"0.6943577",
"0.66033685",
"0.6572269",
"0.65686125",
"0.6561279",
"0.6561279",
"0.6559106",
"0.64874846",
"0.64813113",
"0.6469618",
"0.6463148",
"0.6453288",
"0.64453775",
"0.64210135",
"0.6420657",
"0.641971",
"0.6398805",
"0.6393895",
"0.6366971",
"0.6274766"... | 0.75051147 | 0 |
Return all job detail. | def get_job_detail():
return JobDetail.query.all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_job_list(self):\n return self.job_list",
"def get_job_list(self):\n return self.job_list",
"def getJobList_impl(self):\n my_infos = TestJob.objects.filter(\n (Q(job_status='Running')|Q(job_status='Submitted')|Q(job_status='Incomplete'))\n &Q(check_or_not=True)... | [
"0.7248316",
"0.7248316",
"0.7240961",
"0.72205126",
"0.7180172",
"0.7098997",
"0.70902854",
"0.7087385",
"0.7077205",
"0.70463014",
"0.7011621",
"0.7009996",
"0.6946961",
"0.6840078",
"0.68360656",
"0.680167",
"0.67841136",
"0.67203075",
"0.6700369",
"0.6699724",
"0.66963166... | 0.8332733 | 0 |
Return a job detail by primary key. | def get_job_detail_by_id(job_detail_id):
return JobDetail.query.get(job_detail_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_job(self, identifier: str):\n self._log_operation('Getting job {i}'.format(i=identifier))\n return self._job_queue.get_job_details(identifier)",
"def get_job_detail():\n\n return JobDetail.query.all()",
"def jobid(self):\n return self.get_db('jobid')",
"def get_object(self, pk):\n... | [
"0.72874004",
"0.7173427",
"0.71372676",
"0.6959532",
"0.6943279",
"0.692583",
"0.6852095",
"0.6842035",
"0.67910886",
"0.67829704",
"0.6779413",
"0.67499465",
"0.6748419",
"0.6660234",
"0.65764666",
"0.6566741",
"0.656614",
"0.6525582",
"0.64881426",
"0.6479494",
"0.647201",... | 0.77013654 | 0 |
Create and return job application completed | def create_job_applied(user_id, job_id, application_date_submitted):
job_applied = JobCompletedApplication( user_id = user_id, job_id = job_id, application_date_submitted = application_date_submitted)
db.session.add(job_applied)
db.session.commit()
return job_applied | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createJobLatest(appName):\n logger.debug('[FLASKWEB /jobs/<appName>] Redirect to current version of /jobs/%s' % appName)\n app = db.getApp(appName)\n if app:\n return createJob(appName, app['uid'])\n else:\n return returnError(\"Application %s does not exist\" % appName, 404)",
"def _finish_job_co... | [
"0.6192003",
"0.6101351",
"0.6100192",
"0.60482365",
"0.60133827",
"0.5905657",
"0.5883656",
"0.5854838",
"0.5832155",
"0.5749336",
"0.5738393",
"0.57316905",
"0.5725886",
"0.57126486",
"0.57115126",
"0.5703316",
"0.56890416",
"0.5683779",
"0.5659944",
"0.56541795",
"0.563873... | 0.5971301 | 5 |
Return all job applied. | def get_job_applied():
return JobCompletedApplication.query.all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jobs(self):\n return self.get_jobs()",
"def jobs(self):\n return self._jobs",
"def get_jobs(self):\n return list(self._jobs.values())",
"def get_all_jobs(self):\n all_jobs = self.job_set.all().order_by(\"-time_last_updated\", \"project__name\", \"-id\")\n # for job in a... | [
"0.7738957",
"0.73770744",
"0.7349059",
"0.7263708",
"0.71636105",
"0.71636105",
"0.7105789",
"0.7049187",
"0.69864005",
"0.69775003",
"0.6923545",
"0.68921167",
"0.68604153",
"0.6717858",
"0.6713856",
"0.661173",
"0.6611498",
"0.65968645",
"0.6593661",
"0.65781695",
"0.65622... | 0.76446235 | 1 |
Return a job applied by primary key. | def get_job_applied_by_id(job_applied_id):
return JobCompletedApplication.query.get(job_applied_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def job(self):\n return self.batch[self.job_id]",
"def get_job(self) -> Job:\n return self.jobs_list[self.sel_idx]",
"def get_job_by_id(self, job_id):\n return self.get_resource(category=SYSTEM, resource_level=JOB,\n resource_level_id=job_id)",
"def getJob... | [
"0.6870237",
"0.677873",
"0.67248523",
"0.6657384",
"0.65837944",
"0.65639716",
"0.65449315",
"0.64623064",
"0.63978744",
"0.6393528",
"0.634517",
"0.63417614",
"0.626415",
"0.6250264",
"0.6247968",
"0.62478703",
"0.6244572",
"0.62316567",
"0.6195981",
"0.61914694",
"0.615615... | 0.66399556 | 4 |
Return a job applied by job id. | def get_job_applied_by_job_id(job_id):
return JobCompletedApplication.query.filter(JobCompletedApplication.job_id == job_id).first().job_applied_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_job_by_id(self, job_id):\n return self.get_resource(category=SYSTEM, resource_level=JOB,\n resource_level_id=job_id)",
"def get_job_applied_by_id(job_applied_id):\n\n return JobCompletedApplication.query.get(job_applied_id)",
"def get_job(self, job_id):\n\n ... | [
"0.77378917",
"0.7632125",
"0.7465325",
"0.7188449",
"0.715539",
"0.7043636",
"0.6927355",
"0.6892371",
"0.68905514",
"0.6852687",
"0.6848821",
"0.6789124",
"0.67766374",
"0.67155415",
"0.66451055",
"0.65906435",
"0.65832335",
"0.6499773",
"0.6458737",
"0.6456007",
"0.6417066... | 0.7639219 | 1 |
create and return note | def create_note(job_applied_id, user_id, note_title, note_text, note_category, note_date_created):
note = Note(job_applied_id =job_applied_id, user_id = user_id , note_title = note_title , note_text = note_text,note_category = note_category, note_date_created = note_date_created)
db.session.add(note)
db.session.commit()
return note | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createNote(self, authenticationToken, note):\r\n pass",
"def create_note(self, owner, title, text, note_type, important):\r\n note = self.create(owner=owner, title=title, text=text, note_type=note_type, important=important)\r\n return note",
"def createNote(self, authenticationToken, note)... | [
"0.80400944",
"0.7955958",
"0.7910323",
"0.7604859",
"0.75727963",
"0.75134474",
"0.7455621",
"0.7378897",
"0.73776084",
"0.7318963",
"0.7293564",
"0.7167817",
"0.70275676",
"0.6862869",
"0.6862411",
"0.68283254",
"0.67700315",
"0.6756851",
"0.66674083",
"0.6639888",
"0.66204... | 0.7635383 | 3 |
Return all note created. | def get_note():
return Note.query.all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listNotes() -> list:\n list_of_notes = []\n for note in Note.objects.all():\n list_of_notes.append({\n 'uuid': note.uuid, 'title': note.title,\n 'author': note.author, 'body': note.body, 'created_at': localtime(note.created_at)\n })\n return list_of_notes",
"def n... | [
"0.77602446",
"0.7531043",
"0.70795774",
"0.7064056",
"0.70277685",
"0.7003691",
"0.6970311",
"0.69562006",
"0.6907323",
"0.6907323",
"0.6899866",
"0.6882427",
"0.6856624",
"0.6796058",
"0.678864",
"0.66967875",
"0.66869307",
"0.66006863",
"0.6593107",
"0.65787625",
"0.653431... | 0.7753266 | 1 |
Return all notes for job applied id. | def all_note_by_job_applied_id(job_applied_id):
return Note.query.filter(Note.job_applied_id == job_applied_id, Note.note_category == 'Note' ).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_jd_by_job_applied_id(job_applied_id): \n return Note.query.filter(Note.job_applied_id == job_applied_id, Note.note_category == 'Job Description' ).order_by(Note.note_date_created.desc()).first()",
"def all_recruiter_by_job_applied_id(job_applied_id): \n return Note.query.filter(Note.job_applied... | [
"0.73608685",
"0.70325047",
"0.7020432",
"0.673755",
"0.66720706",
"0.65655774",
"0.64068127",
"0.6329673",
"0.63007534",
"0.62201124",
"0.61646885",
"0.61219245",
"0.61209005",
"0.6072345",
"0.6039921",
"0.5995878",
"0.59537804",
"0.5936029",
"0.587913",
"0.5855434",
"0.5827... | 0.8214903 | 0 |
Return all job description for job applied id. | def all_jd_by_job_applied_id(job_applied_id):
return Note.query.filter(Note.job_applied_id == job_applied_id, Note.note_category == 'Job Description' ).order_by(Note.note_date_created.desc()).first() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def describe_job(self):\n # GET /jobs/{job_id}\n pass",
"def get_job_description(self, job, context=None):\n return self._client.call_method(\n 'UserAndJobState.get_job_description',\n [job], self._service_ver, context)",
"def all_resume_by_job_applied_id(job_applied_... | [
"0.682056",
"0.63486063",
"0.60984653",
"0.6051572",
"0.598966",
"0.5974383",
"0.5968253",
"0.5953331",
"0.59054095",
"0.58386207",
"0.58320206",
"0.58077645",
"0.57883066",
"0.57619286",
"0.56843454",
"0.56843454",
"0.55897605",
"0.5587414",
"0.5582129",
"0.5572485",
"0.5552... | 0.6539759 | 1 |
Return all recruiter details for job applied id. | def all_recruiter_by_job_applied_id(job_applied_id):
return Note.query.filter(Note.job_applied_id == job_applied_id, Note.note_category == 'Recruiter Contact' ).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_resume_by_job_applied_id(job_applied_id): \n return Note.query.filter(Note.job_applied_id == job_applied_id, Note.note_category == 'Resume' ).all()",
"def scrape_recruitment(self):\n d = self.driver\n recruitment_page = self.guildwork_url + '/recruitment'\n d.get(recruitment_pag... | [
"0.6490853",
"0.602824",
"0.5831629",
"0.57851154",
"0.5604668",
"0.55976665",
"0.55698776",
"0.5514874",
"0.5397591",
"0.5368741",
"0.53621614",
"0.53491193",
"0.5341995",
"0.52119046",
"0.51713234",
"0.5159437",
"0.5067528",
"0.50574297",
"0.50168747",
"0.5014782",
"0.50143... | 0.76523733 | 0 |
Return all Resume for job applied id. | def all_resume_by_job_applied_id(job_applied_id):
return Note.query.filter(Note.job_applied_id == job_applied_id, Note.note_category == 'Resume' ).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_recruiter_by_job_applied_id(job_applied_id): \n return Note.query.filter(Note.job_applied_id == job_applied_id, Note.note_category == 'Recruiter Contact' ).all()",
"def get_job_applied():\n\n return JobCompletedApplication.query.all()",
"def resume(self, job_id):\n job = Job.get_job_by_i... | [
"0.5769213",
"0.56241286",
"0.55435765",
"0.54594284",
"0.5418937",
"0.53563815",
"0.53016",
"0.5262021",
"0.5253391",
"0.5253391",
"0.5225734",
"0.521197",
"0.51903236",
"0.5136629",
"0.51281595",
"0.51190066",
"0.5110543",
"0.5109377",
"0.50861925",
"0.5067618",
"0.50420934... | 0.8092352 | 0 |
Return all Follow up Template for job applied id. | def all_followup_by_job_applied_id(job_applied_id):
return Note.query.filter(Note.job_applied_id == job_applied_id, Note.note_category == 'Follow-up').all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def job_templates(self):\n return self._tower.job_templates.filter({'project__exact': self.id})",
"def get_templates(self):\n return [{\"id\": tmplt[\"template_id\"], \"name\": tmplt[\"name\"]}\n for tmplt in Template.objects(user_id=self.user_id, active=True)]",
"def get_template_... | [
"0.59492767",
"0.545359",
"0.5385648",
"0.52259356",
"0.5178491",
"0.51286674",
"0.5078213",
"0.5043155",
"0.49889243",
"0.4969203",
"0.49352974",
"0.49056143",
"0.48956487",
"0.48870766",
"0.487659",
"0.48737434",
"0.48275462",
"0.482688",
"0.47788817",
"0.47703582",
"0.4743... | 0.64399916 | 0 |
Return all Interview question by job applied id. | def all_interview_by_job_applied_id(job_applied_id):
return Note.query.filter(Note.job_applied_id == job_applied_id, ((Note.note_category == 'Interview Question Technical') | (Note.note_category == 'Interview Question Informational') | (Note.note_category == 'Interview Question Behavioral'))).order_by(Note.note_category).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_resume_by_job_applied_id(job_applied_id): \n return Note.query.filter(Note.job_applied_id == job_applied_id, Note.note_category == 'Resume' ).all()",
"def get_questions(self, obj):\n queryset = Question.objects.filter(sheet=obj)\n questions = []\n for q in queryset:\n ... | [
"0.60519505",
"0.60223424",
"0.5880214",
"0.57323456",
"0.5701403",
"0.5560641",
"0.5559024",
"0.5552572",
"0.54993796",
"0.5482854",
"0.5401203",
"0.53886664",
"0.52820504",
"0.5280837",
"0.52447784",
"0.5219957",
"0.5178943",
"0.51773167",
"0.51404804",
"0.5137996",
"0.5107... | 0.73461443 | 0 |
Return all Interview question by job user id. | def all_interview_by_user_id(user_id):
return Note.query.filter(Note.user_id == user_id, ((Note.note_category == 'Interview Question Technical') | (Note.note_category == 'Interview Question Informational') | (Note.note_category == 'Interview Question Behavioral'))).order_by(Note.note_date_created.desc()).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_interview_by_job_applied_id(job_applied_id): \n return Note.query.filter(Note.job_applied_id == job_applied_id, ((Note.note_category == 'Interview Question Technical') | (Note.note_category == 'Interview Question Informational') | (Note.note_category == 'Interview Question Behavioral'))).order_by(Note... | [
"0.64423734",
"0.6284777",
"0.62319624",
"0.59722936",
"0.5878626",
"0.5869722",
"0.5776599",
"0.5703998",
"0.5643334",
"0.55415744",
"0.55246925",
"0.5491793",
"0.54882145",
"0.5477339",
"0.54560447",
"0.5452791",
"0.5439329",
"0.53813064",
"0.5355762",
"0.52801436",
"0.5280... | 0.66224235 | 0 |
create and return Application Progress | def create_application_progress(application_state, job_applied_id , created_at):
app_progress = ApplicationProgress(application_state = application_state, job_applied_id = job_applied_id, created_at = created_at)
db.session.add(app_progress)
db.session.commit()
return app_progress | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getProgress(self):",
"def GetProgress(self):\n return self.new_progress",
"def get_progress(self):\n\t\treturn call_sdk_function('PrlJob_GetProgress', self.handle)",
"def progress(self, *args, **kwargs):\n kwargs['logger'] = self\n return Progress(*args, **kwargs)",
"def reportProgress... | [
"0.6922813",
"0.6465331",
"0.62213963",
"0.6202986",
"0.6198377",
"0.61496395",
"0.6125598",
"0.61032665",
"0.6076108",
"0.5990762",
"0.5978565",
"0.5978565",
"0.59583265",
"0.5951946",
"0.58782065",
"0.58567727",
"0.58351296",
"0.58163893",
"0.58163893",
"0.58061016",
"0.578... | 0.6606787 | 1 |
Return all Application Progress created. | def get_application_progress():
return ApplicationProgress.query.all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getProgress(self):",
"def get_progress(self, asc=True):\n\n # block until system is ready\n while not self.ready.isSet():\n self.ready.wait(0.1)\n\n events = self.get_all_events()\n if not asc:\n events = reversed(list(events))\n\n return [(event, self... | [
"0.6268866",
"0.6009856",
"0.6005044",
"0.5949115",
"0.591462",
"0.58448476",
"0.57968134",
"0.5741962",
"0.57029724",
"0.57012784",
"0.56873035",
"0.56828934",
"0.5674864",
"0.56605846",
"0.55666447",
"0.55653167",
"0.55082387",
"0.55082387",
"0.5501211",
"0.54991305",
"0.54... | 0.801629 | 0 |
Return a Application Progress by primary key. | def get_application_progress_by_id(app_progress_id):
return ApplicationProgress.query.get(app_progress_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_application_progress():\n\n return ApplicationProgress.query.all()",
"def get_result_by_primary_key(self, pk):\n session = self.session_factory()\n result = session.query(PipelineRun).filter_by(id=pk).first()\n session.close()\n return result",
"def find(self, primary_key... | [
"0.63571316",
"0.584929",
"0.5738413",
"0.56607336",
"0.5591691",
"0.5382415",
"0.52425617",
"0.5224627",
"0.519701",
"0.5172489",
"0.5172489",
"0.5164485",
"0.5137614",
"0.51188457",
"0.5116484",
"0.51071393",
"0.51062864",
"0.5100811",
"0.50962",
"0.50886536",
"0.508539",
... | 0.7809704 | 0 |
get a list of all the jobs a user applied | def get_user_job_detail(user_id):
return JobDetail.query.filter(JobCompletedApplication.user_id == user_id).join(JobCompletedApplication).order_by(JobCompletedApplication.application_date_submitted.desc()).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_job_list(self):\n return self.job_list",
"def get_job_list(self):\n return self.job_list",
"def get(self):\n # TODO: auth\n return list(self.app.db.jobs.find())",
"def jobs(self):\n return self.get_jobs()",
"def get_jobs(self):\n return list(self._jobs.valu... | [
"0.7470961",
"0.7470961",
"0.74664974",
"0.7350829",
"0.7286375",
"0.7162109",
"0.7135177",
"0.71263033",
"0.7109876",
"0.7054321",
"0.69995",
"0.69974905",
"0.69860625",
"0.6982899",
"0.69643867",
"0.6921593",
"0.6909927",
"0.6902652",
"0.6885108",
"0.6849189",
"0.6846889",
... | 0.6459101 | 38 |
Return the latest application state object | def get_application_state_by_applied(job_applied_id):
return ApplicationProgress.query.filter(JobCompletedApplication.job_applied_id == job_applied_id).join(JobCompletedApplication).order_by(ApplicationProgress.app_progress_id.desc()).first() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(self) -> ApplicationState:\n return self.state",
"def appstate(self) -> NamedAppState:\n return self._appstate",
"def _get_state(self):\n return self.__state",
"def _get_state(self):\n return self.__state",
"def _get_state(self):\n return self.__state",
"def _get_stat... | [
"0.7602669",
"0.7460222",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
"0.68979424",
... | 0.0 | -1 |
Get the last job_id record | def get_last_job_id():
return JobDetail.query.with_entities(JobDetail.job_id).order_by(JobDetail.job_id.desc()).first()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_job_applied_id():\n\n return JobCompletedApplication.query.with_entities(JobCompletedApplication.job_applied_id).order_by(JobCompletedApplication.job_applied_id.desc()).first()[0]",
"def jobid(self):\n return self.get_db('jobid')",
"def last_job(self): # TOFIX model the job and return an ob... | [
"0.768667",
"0.75634575",
"0.75450337",
"0.7345317",
"0.7155515",
"0.71417",
"0.7064087",
"0.69970345",
"0.69467616",
"0.693553",
"0.6832919",
"0.68281484",
"0.6805035",
"0.67877",
"0.67750955",
"0.67263293",
"0.6711748",
"0.6658601",
"0.6635541",
"0.661187",
"0.65753484",
... | 0.8820396 | 0 |
Get the last job applied id record | def get_last_job_applied_id():
return JobCompletedApplication.query.with_entities(JobCompletedApplication.job_applied_id).order_by(JobCompletedApplication.job_applied_id.desc()).first()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_job_id():\n\n return JobDetail.query.with_entities(JobDetail.job_id).order_by(JobDetail.job_id.desc()).first()[0]",
"def last_job(self): # TOFIX model the job and return an object instead of dictionary\n return self._data.get('summary_fields', {}).get('last_job')",
"def latest_id(self):... | [
"0.7888452",
"0.7109309",
"0.6963653",
"0.68734276",
"0.6839119",
"0.6704593",
"0.6665769",
"0.6628784",
"0.65945107",
"0.65694714",
"0.6464214",
"0.64519495",
"0.644685",
"0.64032155",
"0.63841957",
"0.6373546",
"0.6372956",
"0.6369404",
"0.63560134",
"0.63174295",
"0.631160... | 0.8291623 | 0 |
Initializes the MLP with a number of inputs and outputs. Weights are initialized randomly with the specified seed. | def __init__(self, bias, weights, hidden_activation, output_activation):
if bias is None:
self.weights = weights
self.has_bias = False
else:
self.weights = [numpy.vstack([bias[k], weights[k]]) for k in range(len(bias))]
self.has_bias = True
self.hidden_activation = hidden_activation
self.output_activation = output_activation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_weights(self, seed=None):\r\n if seed!=None:\r\n np.random.seed(seed)\r\n self.weights = np.random.randn(self.number_of_nodes,self.input_dimensions)",
"def initialize_weights(self, seed=None):\n if seed != None:\n np.random.seed(seed)\n self.weight... | [
"0.7367139",
"0.7290737",
"0.6733939",
"0.66796666",
"0.66537523",
"0.6579989",
"0.64707845",
"0.6466867",
"0.6453057",
"0.64230084",
"0.6421071",
"0.6394768",
"0.6393354",
"0.6384965",
"0.6360607",
"0.6356197",
"0.6325219",
"0.63211054",
"0.63164985",
"0.63026685",
"0.628809... | 0.0 | -1 |
Executes the forward step of the Nlayer neural network. | def forward(self, X):
if self.has_bias:
self.a = [numpy.hstack([numpy.ones((len(X),1)), X])]
else:
self.a = [X]
self.z = []
for w in self.weights[:-1]:
self.z.append(numpy.dot(self.a[-1], w))
self.a.append(self.hidden_activation(self.z[-1]))
if self.has_bias:
self.a[-1] = numpy.hstack([numpy.ones((len(self.a[-1]),1)), self.a[-1]])
self.z.append(numpy.dot(self.a[-1], self.weights[-1]))
self.a.append(self.output_activation(self.z[-1]))
return self.a[-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feedForward(self, inputs):\n\n\t\tinputs = np.atleast_1d(inputs)\n\n\t\tif not len(inputs) == self.nInputs:\n\n\t\t\traise ValueError(\"The input vector is the wrong length for this network\")\n\n\t\t#don't forget we have a bias unit in here too\n\t\tfor i in range(1,self.nInputs+1):\n\t\t\tself.inputLayer[i].... | [
"0.6877743",
"0.68574786",
"0.6782571",
"0.6746644",
"0.66924095",
"0.6675286",
"0.66507876",
"0.66504323",
"0.66488916",
"0.6638583",
"0.6637277",
"0.6637277",
"0.6631678",
"0.6617905",
"0.6611763",
"0.6592438",
"0.6590996",
"0.6517339",
"0.65155137",
"0.65103996",
"0.651023... | 0.0 | -1 |
Executes the backward step for training. In this phase, we calculate the error on the output layer and then use backpropagation to estimate the error on the hidden layer. We then use this estimated error to calculate the differences between what the layer output and the expected value. | def backward(self, b):
self.b = [b]
# calculate the estimated errors on each layer ($\delta$)
for k,w in reversed(list(enumerate(self.weights[1:]))):
if self.has_bias:
delta = numpy.dot(self.b[0], w[1:].T)
act = self.a[k+1][:,1:]
else:
delta = numpy.dot(self.b[0], w.T)
act = self.a[k+1]
self.b.insert(0, delta*self.hidden_activation.f_prime_from_f(act))
self.d = []
for a,b in zip(self.a[:-1], self.b):
self.d.append(numpy.dot(a.T, b) / len(b))
return self.d | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backward(self, inputs): \n self.error = self.error * sigmoid(self.output, der=True) # because the activation function of last layer must be sigmoid\n delta3_weights = np.dot(self.z2.T, self.error)\n\n self.error = np.dot(self.error, self.output3_weights.T) * self.af(self.z2, der=True... | [
"0.7721167",
"0.7601871",
"0.74604684",
"0.7341675",
"0.7340948",
"0.72407854",
"0.72127664",
"0.71170765",
"0.70980763",
"0.7034998",
"0.70217544",
"0.7019568",
"0.6962774",
"0.69619286",
"0.6953446",
"0.6893019",
"0.689292",
"0.68692243",
"0.6866258",
"0.68468297",
"0.68175... | 0.68683493 | 18 |
Calculates the cost given the target. This method must be called after `forward` has been called. | def cost(self, cost_object, target):
return cost_object.f(self.a[-1], target).mean(axis=0).sum() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cost(self) -> float:",
"def __compute_cost(self, x, y):\n\n predictions = self.__compute_prediction(x)\n cost = np.mean(-y * np.log(predictions) - (1 - y) * np.log(1 - predictions))\n\n return cost",
"def calculate_total_cost(state):\r\n return state.cost()",
"def cost(self):\n\t\... | [
"0.7035611",
"0.6710912",
"0.67076313",
"0.670511",
"0.66524404",
"0.66274863",
"0.6589824",
"0.6588693",
"0.6582186",
"0.6582186",
"0.6580311",
"0.6567873",
"0.6526451",
"0.6509514",
"0.6483877",
"0.6477303",
"0.64738995",
"0.64710313",
"0.6433443",
"0.6429381",
"0.6400443",... | 0.7270355 | 0 |
Unroll its own parameters so it becomes a linear vector | def unroll(self):
return numpy.hstack([k.flat for k in self.weights]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feed(self, vector):\n return vector",
"def __rmul__(self,a):\n return Vector(self.x*a,self.y*a)\n pass",
"def __call__(self, x):\n if self.W.data is None:\n in_size = functools.reduce(operator.mul, x.shape[1:], 1)\n self._initialize_params(in_size)\n ... | [
"0.6112024",
"0.60965115",
"0.60781777",
"0.59979",
"0.5994758",
"0.5971627",
"0.5909083",
"0.58948725",
"0.5855013",
"0.5855013",
"0.58467925",
"0.5815045",
"0.5805558",
"0.57679266",
"0.57517254",
"0.5751406",
"0.5744771",
"0.57267994",
"0.57211614",
"0.5717576",
"0.5710939... | 0.5720596 | 19 |
Rollup the parameters again, undoes ``unroll()`` above. | def roll(self, v):
retval = []
marks = list(numpy.cumsum([k.size for k in self.weights]))
marks.insert(0, 0)
for k,w in enumerate(self.weights):
retval.append(v[marks[k]:marks[k+1]].reshape(w.shape))
return retval | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unroll(self) -> None:\n\n for flat in self.params:\n if self.global_ref_rank != self.global_rank and self.gradients_based:\n # this rank is not the owner, release the grad\n flat.param.grad = None\n else:\n if self.gradients_based:\n ... | [
"0.6107971",
"0.59822226",
"0.5820029",
"0.57104546",
"0.54406637",
"0.5412581",
"0.53881454",
"0.5376864",
"0.51637256",
"0.51405406",
"0.50803703",
"0.50803703",
"0.50630724",
"0.5057517",
"0.4990582",
"0.4938398",
"0.48879898",
"0.48774016",
"0.48518872",
"0.482993",
"0.48... | 0.0 | -1 |
Get Enrollment Dataframe (enrollment_.csv) | def get_enrollment_df(ftype):
assert ftype=='train' or ftype=='test'
enroll_df = pd.read_csv('data/%s/enrollment_%s.csv' % (ftype, ftype))
return enroll_df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_education() -> pd.DataFrame:\n\n school_df = pd.read_csv(\"data/Expected years of schooling (years).csv\", header=2, usecols=[1, 32], names=[\"Country\", \"Education\"])\n\n index = school_df[school_df[\"Country\"]==\"Iran (Islamic Republic of)\"].index.values[0]\n school_df.loc[index, \"Country\... | [
"0.62597656",
"0.6190843",
"0.60569084",
"0.60142833",
"0.59021455",
"0.5870558",
"0.58594114",
"0.58429956",
"0.58184737",
"0.5782017",
"0.57763255",
"0.5766798",
"0.57097375",
"0.5647704",
"0.55870324",
"0.5583758",
"0.5578448",
"0.55618584",
"0.55554485",
"0.5553673",
"0.5... | 0.79547787 | 0 |
Get Log Dataframe (log_.csv) | def get_log_df(ftype):
assert ftype=='train' or ftype=='test'
log_df = pd.read_csv('data/%s/log_%s.csv' % (ftype, ftype))
log_df['time'] = pd.to_datetime(log_df['time'])
log_df['action_date'] = log_df.time.apply(lambda x: x.date())
log_df['action_dow'] = log_df['time'].apply(lambda x: x.weekday())
return log_df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_log(dir_):\n df = pandas.read_csv(os.path.join(dir_, 'log.csv'),\n error_bad_lines=False,\n warn_bad_lines=True)\n if not len(df):\n print(\"empty df at {}\".format(dir_))\n return\n df['model'] = dir_\n return df",
"def hoomdlog(... | [
"0.7406182",
"0.7205137",
"0.7000645",
"0.6835169",
"0.68185526",
"0.67984",
"0.66380084",
"0.65209377",
"0.63542926",
"0.6274999",
"0.6213813",
"0.61862767",
"0.61492324",
"0.6118362",
"0.60789824",
"0.6058416",
"0.60430205",
"0.5994365",
"0.59824306",
"0.59578943",
"0.59532... | 0.77047133 | 0 |
Get Trainning Labels Dataframe (truth_train.csv) | def get_labels_df():
labels_df = pd.read_csv('data/train/truth_train.csv', header=None)
return labels_df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def df():\n path, _ = os.path.split(os.path.abspath(__file__))\n project_path = os.path.join(path, os.pardir, os.pardir)\n\n values_path = os.path.join(project_path, \"data\", \"raw\", \"pumps_train_values.csv\")\n labels_path = os.path.join(project_path, \"data\", \"raw\", \"pumps_train_labels.csv\")\... | [
"0.6975254",
"0.67474806",
"0.66706246",
"0.655183",
"0.64902073",
"0.64812607",
"0.64470786",
"0.64456475",
"0.64414805",
"0.6425497",
"0.6413294",
"0.6360745",
"0.63333935",
"0.6317695",
"0.6304125",
"0.622412",
"0.62197214",
"0.6218117",
"0.621556",
"0.6214037",
"0.6212466... | 0.875425 | 0 |
Get Date Dataframe (date.csv) | def get_date_df():
dt_df = pd.read_csv('data/date.csv')
dt_df['from'] = pd.to_datetime(dt_df['from'])
dt_df['from_year'] = dt_df['from'].apply(lambda x: x.year)
dt_df['from_month'] = dt_df['from'].apply(lambda x: x.month)
dt_df['to'] = pd.to_datetime(dt_df['to'])
dt_df['to_year'] = dt_df['from'].apply(lambda x: x.year)
dt_df['to_month'] = dt_df['from'].apply(lambda x: x.month)
return dt_df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dataframe_for_date(date: dt.date = INITIAL_DATE) -> pd.DataFrame:\n\n url = (\n \"https://raw.githubusercontent.com/\"\n \"CSSEGISandData/COVID-19/master/\"\n \"csse_covid_19_data/\"\n \"csse_covid_19_daily_reports/\"\n \"{date}.csv\"\n ).format(date=date.strftime(\... | [
"0.73871845",
"0.7380805",
"0.73196715",
"0.6718518",
"0.6664022",
"0.66199845",
"0.6560007",
"0.6533404",
"0.6513927",
"0.64988214",
"0.649138",
"0.64546615",
"0.6425166",
"0.63724774",
"0.6363566",
"0.6360149",
"0.6342642",
"0.6329855",
"0.6300381",
"0.6282578",
"0.627477",... | 0.73533404 | 2 |
Get Object Dataframe (object.csv) | def get_obj_df():
obj_df = pd.read_csv('data/object.csv')
obj_df = obj_df.drop_duplicates()[['course_id', 'module_id', 'category', 'start']]
obj_df['start'] = pd.to_datetime(obj_df[obj_df['start'] != 'null']['start'])
return obj_df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataframe():\r\n\r\n df = pd.read_csv('data/data.csv', header=0)\r\n return df",
"def get_obj_df(self) -> pd.DataFrame:\n df = pd.DataFrame(self.obj, columns=[\"x\", \"y\", \"m\", \"dx\", \"dy\"])\n df['iter'] = self.current_iteration\n return df",
"def cif_df(cif_object) ... | [
"0.6555708",
"0.64185214",
"0.6270231",
"0.62557626",
"0.62464267",
"0.61960536",
"0.6175627",
"0.61419046",
"0.6131568",
"0.6105312",
"0.609715",
"0.6067034",
"0.6055361",
"0.5941004",
"0.5922465",
"0.58321035",
"0.5826193",
"0.58045596",
"0.5778079",
"0.57685983",
"0.576500... | 0.6709269 | 0 |
Replaces the given province's tradegood with the new one defined in the tradegoods.bmp map. | def replace_tradegood(prov_num, new_tradegood):
directory = os.getcwd()+"\\shatterednippon\\history\\provinces\\"
for file in os.listdir(directory):
if file.startswith(str(prov_num)):
old_tradegood = find_tradegood(directory+file)
if old_tradegood is None:
print("Province: %s has no \"trade_goods\" variable" % file)
return
elif new_tradegood == old_tradegood:
return
for line in fileinput.input(directory+file, inplace=True):
line = line.rstrip().replace(old_tradegood, new_tradegood)
print(line)
print("Province %d: changed tradegood from %s to %s" % (prov_num, old_tradegood, new_tradegood))
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_city(self, code, key, val):\r\n if key == \"code\":\r\n self.vertices[val] = self.vertices.pop(code)\r\n setattr(self.vertices[val], key, val)\r\n else:\r\n setattr(self.vertices[code], key, val)",
"def update_province_info(self, data):\n\n prov = {d... | [
"0.49456048",
"0.4688628",
"0.46635583",
"0.465411",
"0.4610733",
"0.46057832",
"0.4569795",
"0.4563333",
"0.45383635",
"0.4537916",
"0.45238334",
"0.4523624",
"0.45051134",
"0.4464374",
"0.44389847",
"0.44224742",
"0.44107935",
"0.44045115",
"0.43949524",
"0.438784",
"0.4384... | 0.67790896 | 0 |
Finds the given province file's tradegood and returns it, else returns None. | def find_tradegood(filepath):
with open(filepath) as f:
for line in f:
if "trade_good" in line:
return line.replace("trade_goods = ", "").strip()
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_purity_from_filename(fn):\n # type: (str) -> float\n for k in PURITY_DICT.keys():\n if fn.find(k) != -1:\n return PURITY_DICT[k]\n return None",
"def replace_tradegood(prov_num, new_tradegood):\n\tdirectory = os.getcwd()+\"\\\\shatterednippon\\\\history\\\\provinces\\\\\"\n\tf... | [
"0.61429954",
"0.5806887",
"0.5357879",
"0.5357617",
"0.53102237",
"0.52028406",
"0.51881367",
"0.51809806",
"0.49570414",
"0.49463305",
"0.4909227",
"0.4857346",
"0.4817479",
"0.4806995",
"0.47705704",
"0.47592556",
"0.4758116",
"0.47489792",
"0.47389686",
"0.47359687",
"0.4... | 0.737722 | 0 |
Checks definition.csv if provinces.bmp's corresponding pixel's RBG value is in the definition list. Returns the province number if it finds the pixel in the list, returns None otherwise. | def get_province_number(corr_pixel):
corr_pixel = str(corr_pixel).strip("()").replace(", ", ";") #Reformats the pixel to ensure it can be compared.
with open(os.getcwd()+"\\shatterednippon\\map\\definition.csv", "r") as definitions:
prov_num = 1
for line in definitions:
if corr_pixel in line:
return prov_num
prov_num += 1
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def region_of_province(province_in: str) -> str:\n region = None\n for r in ITALY_MAP:\n for p in ITALY_MAP[r]:\n if province_in == p:\n region = r\n return region",
"def get_layers(filen, flist):\n lay_lim =()\n if (filen in flist[0]) or (filen in flist[1]) or \\\... | [
"0.5004101",
"0.48853442",
"0.48022938",
"0.47766182",
"0.4772715",
"0.46768475",
"0.46313435",
"0.4620217",
"0.46167162",
"0.4558334",
"0.45415226",
"0.45321065",
"0.45184773",
"0.4518011",
"0.44653592",
"0.44647416",
"0.44464013",
"0.44451034",
"0.44309643",
"0.44243097",
"... | 0.6695489 | 0 |
Returns the names of the tradegoods and the RGB color values for each defined tradegood in 00_tradegoods.txt as two seperate lists. | def get_defined_tradegoods():
names = []
colors = []
with open(os.getcwd()+"\\shatterednippon\\common\\tradegoods\\00_tradegoods.txt", "r") as f:
for line in f:
if line[0].isalpha():
names.append(line.strip("={} \n"))
elif "color" in line:
numbers = tuple(map(int, re.sub("[^\d. ]\s*", "", line).split()))
colors.append(tuple(round(i * 255) for i in numbers))
return names, colors | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_player_colors() -> List[Tuple[float, float, float]]:\n return PLAYER_COLORS",
"def colors(self):\n\t\treturn [(0, 30, 255),(0, 30, 120)]",
"def materials_list_from_file(filename):\n color_data = []\n with open(filename, 'r', newline='') as csvfile:\n reader = csv.reader(csvfile)\n ... | [
"0.5856119",
"0.57543385",
"0.5730062",
"0.566281",
"0.5610903",
"0.5603703",
"0.55331224",
"0.5490069",
"0.5385997",
"0.53710496",
"0.52969",
"0.52936643",
"0.5287496",
"0.52840865",
"0.5262353",
"0.5247332",
"0.5247332",
"0.5245796",
"0.5244358",
"0.5224747",
"0.5222103",
... | 0.86052763 | 0 |
Convert the modifier to its response format. | def to_response_data(self) -> typing.Any:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_response(reaction):\n user = Profile.objects.get(user=reaction.user)\n # Formatted reaction\n reaction = {\n 'id': reaction.id,\n 'article': reaction.article.slug,\n 'reaction': reaction.reaction,\n 'set_on': reaction.set_on,\n 'user': {\n 'username... | [
"0.5830189",
"0.54968446",
"0.5436791",
"0.5408932",
"0.5308021",
"0.52954525",
"0.52450234",
"0.52399683",
"0.52015156",
"0.5157684",
"0.5134368",
"0.5111666",
"0.5065381",
"0.5047462",
"0.5009973",
"0.5009973",
"0.500757",
"0.49876443",
"0.49620473",
"0.49337187",
"0.492125... | 0.0 | -1 |
Get the yaml identifier representation for the class. | def label(cls) -> str:
return "!lobotomy.unknown" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cls_identifier(cls):\n if hasattr(cls, 'get_cls_identifier'):\n return cls.get_cls_identifier()\n return Encoder.default_identifier(cls)",
"def identifier(cls):\r\n\r\n logger = utils.get_logger()\r\n\r\n # FIXME: this is temporary warning\r\n info = get_node_inf... | [
"0.7133083",
"0.68832743",
"0.6708577",
"0.668277",
"0.668277",
"0.6615869",
"0.65500784",
"0.6493111",
"0.64726925",
"0.6472294",
"0.64717734",
"0.6457169",
"0.64294267",
"0.64131653",
"0.6406268",
"0.6404759",
"0.6404759",
"0.6399139",
"0.63884515",
"0.6379985",
"0.63798535... | 0.0 | -1 |
Load an internal yaml node parsing, defaulting to a scalar value. | def _from_yaml(cls, loader: yaml.Loader, node: yaml.Node) -> "YamlModifier":
value = loader.construct_scalar(typing.cast(yaml.ScalarNode, node))
return cls(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_(self, node):\n yamal_name = os.path.join(self._root, self.construct_scalar(node))\n\n with open(yamal_name, 'r') as yamal_file:\n return yaml.load(yamal_file, ImportLoader)",
"def _from_yaml(cls, loader: yaml.Loader, node: yaml.Node) -> \"InjectString\":\n raw = loader... | [
"0.73322433",
"0.63728184",
"0.61908674",
"0.61466956",
"0.6134764",
"0.6104053",
"0.6015713",
"0.59930307",
"0.598406",
"0.59112525",
"0.5903671",
"0.5833151",
"0.5768858",
"0.5761115",
"0.57025176",
"0.5649191",
"0.5563314",
"0.55608124",
"0.5558609",
"0.5475866",
"0.542939... | 0.7018517 | 1 |
Parse yaml node into this class object for Lobotomy processing. | def parse_yaml(cls, loader: yaml.Loader, node: yaml.Node) -> "YamlModifier":
return cls._from_yaml(loader, node) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, node: yaml.Node) -> None:\n self.yaml_node = node",
"def from_yaml(cls, y):\n return cls(yaml.load(y, AttrLoader))",
"def FromYAML(cls, source):\n\n # Late import to avoid a circular dependency.\n try:\n import bulletml.bulletyaml\n import ya... | [
"0.7190225",
"0.68135875",
"0.6604197",
"0.6597981",
"0.65922415",
"0.65773606",
"0.6518172",
"0.65123314",
"0.6395062",
"0.6377166",
"0.6372749",
"0.6344428",
"0.6335441",
"0.6274441",
"0.6237253",
"0.60822874",
"0.60467535",
"0.6043854",
"0.6027036",
"0.5990031",
"0.5938824... | 0.73717535 | 0 |
Convert to a yaml node representation for writing to file. | def _dump_yaml(cls, dumper: yaml.Dumper, source: "YamlModifier") -> typing.Any:
return dumper.represent_scalar(source.label(), source.value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_yaml(self, **kwargs):\n if not self._is_graph_network:\n raise NotImplementedError\n\n if yaml is None:\n raise ImportError('Requires yaml module installed.')\n return yaml.dump(self._updated_config(), **kwargs)",
"def write(self, file=sys.stdout):\n d = self.to_dict()\n i... | [
"0.67945427",
"0.6693929",
"0.6608675",
"0.6555659",
"0.6387414",
"0.63593584",
"0.6286696",
"0.6257734",
"0.6242797",
"0.6238155",
"0.6233442",
"0.6199108",
"0.61879206",
"0.6161596",
"0.6161503",
"0.61410135",
"0.61214316",
"0.6116343",
"0.6093326",
"0.6073838",
"0.6060863"... | 0.0 | -1 |
Dump to a yaml node representation for writing to file. | def dump_yaml(cls, dumper: yaml.Dumper, source: "YamlModifier") -> typing.Any:
return cls._dump_yaml(dumper, source) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, file=sys.stdout):\n d = self.to_dict()\n if d:\n yaml.dump([d], file, default_flow_style=False)",
"def to_yaml(self, **kwargs):\n if not self._is_graph_network:\n raise NotImplementedError\n\n if yaml is None:\n raise ImportError('Requires yaml module inst... | [
"0.70246464",
"0.6802063",
"0.6747669",
"0.67123574",
"0.6547303",
"0.6536986",
"0.65061665",
"0.64999473",
"0.64919853",
"0.6442486",
"0.640802",
"0.63804394",
"0.637673",
"0.63666886",
"0.63395387",
"0.63104755",
"0.6310447",
"0.630666",
"0.62830526",
"0.6247327",
"0.623897... | 0.5623769 | 79 |
Register the comparator with the PyYaml loader. | def register(cls):
yaml.add_constructor(cls.label(), cls.parse_yaml)
yaml.add_representer(cls, cls.dump_yaml) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setComparator(self, comparator: dict):\n self._comparator = comparator",
"def set_result_comparator(self, comparator):\n\n self._comparator = comparator",
"def register_loader(key, module):\n register(key, module, loader_dict)",
"def _yaml_ordering_support():\n _mapping_tag = yaml.resol... | [
"0.58455926",
"0.5207403",
"0.51714724",
"0.5046912",
"0.49322683",
"0.48709297",
"0.47904545",
"0.4760413",
"0.46908015",
"0.46855125",
"0.4660275",
"0.4592575",
"0.45680568",
"0.44943762",
"0.44933996",
"0.44847608",
"0.44837308",
"0.4481726",
"0.4451131",
"0.44410124",
"0.... | 0.5855883 | 0 |
Handle unknown values to the standard JSON encoder. | def default(self, value: typing.Any) -> typing.Any:
if isinstance(value, ToJson):
return value.to_response_data() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_type_fixer(series):\n\tfor k,v in series.items():\n\t\tif type(v) == dict: json_type_fixer(v)\n\t\telif type(v)in str_types and v.isdigit(): series[k] = int(v)\n\t\telif type(v)in str_types and v=='None': series[k] = None",
"def handle_missing_objects(exc):\n return jsonify(dict(\n message=str... | [
"0.6443003",
"0.61551327",
"0.6147646",
"0.6055261",
"0.5941976",
"0.59257066",
"0.58801675",
"0.5791325",
"0.5771343",
"0.5761818",
"0.5742696",
"0.5731473",
"0.5719577",
"0.5717677",
"0.57129604",
"0.5708662",
"0.57066745",
"0.56790423",
"0.56680447",
"0.5664627",
"0.565209... | 0.5210304 | 56 |
Convert the modifier to its response format. | def to_response_data(self) -> typing.Any:
return json.dumps(self.value, cls=ToJsonEncoder) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_response(reaction):\n user = Profile.objects.get(user=reaction.user)\n # Formatted reaction\n reaction = {\n 'id': reaction.id,\n 'article': reaction.article.slug,\n 'reaction': reaction.reaction,\n 'set_on': reaction.set_on,\n 'user': {\n 'username... | [
"0.5830189",
"0.54968446",
"0.5436791",
"0.5408932",
"0.5308021",
"0.52954525",
"0.52450234",
"0.52399683",
"0.52015156",
"0.5157684",
"0.5134368",
"0.5111666",
"0.5065381",
"0.5047462",
"0.5009973",
"0.5009973",
"0.500757",
"0.49876443",
"0.49620473",
"0.49337187",
"0.492125... | 0.0 | -1 |
Get the yaml identifier representation for the class. | def label(cls) -> str:
return "!lobotomy.to_json" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cls_identifier(cls):\n if hasattr(cls, 'get_cls_identifier'):\n return cls.get_cls_identifier()\n return Encoder.default_identifier(cls)",
"def identifier(cls):\r\n\r\n logger = utils.get_logger()\r\n\r\n # FIXME: this is temporary warning\r\n info = get_node_inf... | [
"0.7133083",
"0.68832743",
"0.6708577",
"0.668277",
"0.668277",
"0.6615869",
"0.65500784",
"0.6493111",
"0.64726925",
"0.6472294",
"0.64717734",
"0.6457169",
"0.64294267",
"0.64131653",
"0.6406268",
"0.6404759",
"0.6404759",
"0.6399139",
"0.63884515",
"0.6379985",
"0.63798535... | 0.0 | -1 |
Load an internal yaml node parsing. | def _from_yaml(cls, loader: yaml.Loader, node: yaml.Node) -> "ToJson":
try:
value = loader.construct_mapping(node, deep=True)
except yaml.constructor.ConstructorError:
value = loader.construct_sequence(node, deep=True)
return cls(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_(self, node):\n yamal_name = os.path.join(self._root, self.construct_scalar(node))\n\n with open(yamal_name, 'r') as yamal_file:\n return yaml.load(yamal_file, ImportLoader)",
"def parse_yaml(cls, loader: yaml.Loader, node: yaml.Node) -> \"YamlModifier\":\n return cls._... | [
"0.73915166",
"0.71310484",
"0.673423",
"0.66889703",
"0.6588866",
"0.65676856",
"0.6481034",
"0.64551365",
"0.63675475",
"0.6336091",
"0.631003",
"0.6225353",
"0.6186448",
"0.61831933",
"0.61275",
"0.60967654",
"0.6024105",
"0.6010759",
"0.6009358",
"0.60079056",
"0.59998393... | 0.6249713 | 11 |
Convert to a yaml node representation for writing to file. | def _dump_yaml(cls, dumper: yaml.Dumper, source: "YamlModifier") -> typing.Any:
if isinstance(source.value, (list, tuple)):
return dumper.represent_sequence(source.label(), source.value)
return dumper.represent_mapping(source.label(), source.value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_yaml(self, **kwargs):\n if not self._is_graph_network:\n raise NotImplementedError\n\n if yaml is None:\n raise ImportError('Requires yaml module installed.')\n return yaml.dump(self._updated_config(), **kwargs)",
"def write(self, file=sys.stdout):\n d = self.to_dict()\n i... | [
"0.67945427",
"0.6693929",
"0.6608675",
"0.6555659",
"0.6387414",
"0.63593584",
"0.6286696",
"0.6257734",
"0.6242797",
"0.6238155",
"0.6233442",
"0.6199108",
"0.61879206",
"0.6161596",
"0.6161503",
"0.61410135",
"0.61214316",
"0.6116343",
"0.6093326",
"0.6073838",
"0.6060863"... | 0.0 | -1 |
Convert the modifier to its response format. | def to_response_data(self) -> typing.Any:
return pathlib.Path(self.value["absolute"]).expanduser().absolute().read_text() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_response(reaction):\n user = Profile.objects.get(user=reaction.user)\n # Formatted reaction\n reaction = {\n 'id': reaction.id,\n 'article': reaction.article.slug,\n 'reaction': reaction.reaction,\n 'set_on': reaction.set_on,\n 'user': {\n 'username... | [
"0.5830189",
"0.54968446",
"0.5436791",
"0.5408932",
"0.5308021",
"0.52954525",
"0.52450234",
"0.52399683",
"0.52015156",
"0.5157684",
"0.5134368",
"0.5111666",
"0.5065381",
"0.5047462",
"0.5009973",
"0.5009973",
"0.500757",
"0.49876443",
"0.49620473",
"0.49337187",
"0.492125... | 0.0 | -1 |
Get the yaml identifier representation for the class. | def label(cls) -> str:
return "!lobotomy.inject_string" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cls_identifier(cls):\n if hasattr(cls, 'get_cls_identifier'):\n return cls.get_cls_identifier()\n return Encoder.default_identifier(cls)",
"def identifier(cls):\r\n\r\n logger = utils.get_logger()\r\n\r\n # FIXME: this is temporary warning\r\n info = get_node_inf... | [
"0.7133083",
"0.68832743",
"0.6708577",
"0.668277",
"0.668277",
"0.6615869",
"0.65500784",
"0.6493111",
"0.64726925",
"0.6472294",
"0.64717734",
"0.6457169",
"0.64294267",
"0.64131653",
"0.6406268",
"0.6404759",
"0.6404759",
"0.6399139",
"0.63884515",
"0.6379985",
"0.63798535... | 0.0 | -1 |
Load an internal yaml node parsing. | def _from_yaml(cls, loader: yaml.Loader, node: yaml.Node) -> "InjectString":
raw = loader.construct_scalar(typing.cast(yaml.ScalarNode, node))
value = json.loads(typing.cast(str, raw).strip("\"'"))
return cls(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_(self, node):\n yamal_name = os.path.join(self._root, self.construct_scalar(node))\n\n with open(yamal_name, 'r') as yamal_file:\n return yaml.load(yamal_file, ImportLoader)",
"def parse_yaml(cls, loader: yaml.Loader, node: yaml.Node) -> \"YamlModifier\":\n return cls._... | [
"0.73915166",
"0.71310484",
"0.673423",
"0.66889703",
"0.6588866",
"0.65676856",
"0.6481034",
"0.64551365",
"0.63675475",
"0.6336091",
"0.631003",
"0.6249713",
"0.6225353",
"0.6186448",
"0.61831933",
"0.61275",
"0.60967654",
"0.6024105",
"0.6010759",
"0.6009358",
"0.60079056"... | 0.55722076 | 63 |
Convert to a yaml node representation for writing to file. | def _dump_yaml(cls, dumper: yaml.Dumper, source: "YamlModifier") -> typing.Any:
return dumper.represent_scalar(source.label(), source.value["original"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_yaml(self, **kwargs):\n if not self._is_graph_network:\n raise NotImplementedError\n\n if yaml is None:\n raise ImportError('Requires yaml module installed.')\n return yaml.dump(self._updated_config(), **kwargs)",
"def write(self, file=sys.stdout):\n d = self.to_dict()\n i... | [
"0.67945427",
"0.6693929",
"0.6608675",
"0.6555659",
"0.6387414",
"0.63593584",
"0.6286696",
"0.6257734",
"0.6242797",
"0.6238155",
"0.6233442",
"0.6199108",
"0.61879206",
"0.6161596",
"0.6161503",
"0.61410135",
"0.61214316",
"0.6116343",
"0.6093326",
"0.6073838",
"0.6060863"... | 0.0 | -1 |
Convert the modifier to its response format. | def to_response_data(self) -> typing.Any:
v = self.value or {}
error_code = v.get("code", "GenericLobotomyError")
error_message = v.get("message", "There was an error.")
return {"Error": {"Code": error_code, "Message": error_message}} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_response(reaction):\n user = Profile.objects.get(user=reaction.user)\n # Formatted reaction\n reaction = {\n 'id': reaction.id,\n 'article': reaction.article.slug,\n 'reaction': reaction.reaction,\n 'set_on': reaction.set_on,\n 'user': {\n 'username... | [
"0.5830189",
"0.54968446",
"0.5436791",
"0.5408932",
"0.5308021",
"0.52954525",
"0.52450234",
"0.52399683",
"0.52015156",
"0.5157684",
"0.5134368",
"0.5111666",
"0.5065381",
"0.5047462",
"0.5009973",
"0.5009973",
"0.500757",
"0.49876443",
"0.49620473",
"0.49337187",
"0.492125... | 0.0 | -1 |
Get the yaml identifier representation for the class. | def label(cls) -> str:
return "!lobotomy.error" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cls_identifier(cls):\n if hasattr(cls, 'get_cls_identifier'):\n return cls.get_cls_identifier()\n return Encoder.default_identifier(cls)",
"def identifier(cls):\r\n\r\n logger = utils.get_logger()\r\n\r\n # FIXME: this is temporary warning\r\n info = get_node_inf... | [
"0.7133083",
"0.68832743",
"0.6708577",
"0.668277",
"0.668277",
"0.6615869",
"0.65500784",
"0.6493111",
"0.64726925",
"0.6472294",
"0.64717734",
"0.6457169",
"0.64294267",
"0.64131653",
"0.6406268",
"0.6404759",
"0.6404759",
"0.6399139",
"0.63884515",
"0.6379985",
"0.63798535... | 0.0 | -1 |
Load an internal yaml node parsing. | def _from_yaml(cls, loader: yaml.Loader, node: yaml.Node) -> "BotoError":
value = loader.construct_mapping(node, deep=True)
return cls(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_(self, node):\n yamal_name = os.path.join(self._root, self.construct_scalar(node))\n\n with open(yamal_name, 'r') as yamal_file:\n return yaml.load(yamal_file, ImportLoader)",
"def parse_yaml(cls, loader: yaml.Loader, node: yaml.Node) -> \"YamlModifier\":\n return cls._... | [
"0.73915166",
"0.71310484",
"0.673423",
"0.66889703",
"0.6588866",
"0.65676856",
"0.64551365",
"0.63675475",
"0.6336091",
"0.631003",
"0.6249713",
"0.6225353",
"0.6186448",
"0.61831933",
"0.61275",
"0.60967654",
"0.6024105",
"0.6010759",
"0.6009358",
"0.60079056",
"0.59998393... | 0.6481034 | 6 |
Convert to a yaml node representation for writing to file. | def _dump_yaml(cls, dumper: yaml.Dumper, source: "YamlModifier") -> typing.Any:
return dumper.represent_mapping(source.label(), source.value or {}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_yaml(self, **kwargs):\n if not self._is_graph_network:\n raise NotImplementedError\n\n if yaml is None:\n raise ImportError('Requires yaml module installed.')\n return yaml.dump(self._updated_config(), **kwargs)",
"def write(self, file=sys.stdout):\n d = self.to_dict()\n i... | [
"0.67945427",
"0.6693929",
"0.6608675",
"0.6555659",
"0.6387414",
"0.63593584",
"0.6286696",
"0.6257734",
"0.6242797",
"0.6238155",
"0.6233442",
"0.6199108",
"0.61879206",
"0.6161596",
"0.6161503",
"0.61410135",
"0.61214316",
"0.6116343",
"0.6093326",
"0.6073838",
"0.6060863"... | 0.5493692 | 81 |
A ultra fast implementation of Quadratic Weighted Kappa (QWK) | def cpmp_qwk(a1, a2, max_rat=3) -> float:
assert (len(a1) == len(a2))
a1 = np.asarray(a1, dtype=int)
a2 = np.asarray(a2, dtype=int)
hist1 = np.zeros((max_rat + 1,))
hist2 = np.zeros((max_rat + 1,))
o = 0
for k in range(a1.shape[0]):
i, j = a1[k], a2[k]
hist1[i] += 1
hist2[j] += 1
o += (i - j) * (i - j)
e = 0
for i in range(max_rat + 1):
for j in range(max_rat + 1):
e += hist1[i] * hist2[j] * (i - j) * (i - j)
e = e / a1.shape[0]
return 1 - o / e | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kappa(self):\n a, c, d, b = self.to_ccw()\n p1, q1 = a + b, c + d\n p2, q2 = a + c, b + d\n n = p1 + q1\n\n if n == 0:\n return np.nan\n elif a == n or d == n:\n # only one (diagonal) cell is non-zero\n return 0.5\n\n return _div... | [
"0.67367417",
"0.6686095",
"0.65990496",
"0.65807045",
"0.6571537",
"0.65466547",
"0.65466547",
"0.6379139",
"0.63352853",
"0.6298216",
"0.6234822",
"0.62071073",
"0.62018716",
"0.61931247",
"0.61725694",
"0.6155287",
"0.61405534",
"0.61073667",
"0.610646",
"0.6102626",
"0.61... | 0.5431753 | 86 |
Returns the closed form of a '_{side}_inline.nii.gz' mask in numpy array and also the clipped array | def close_mask_in(im_slice_2d, side):
new_slice = im_slice_2d.copy()
x_no_0, y_no_0 = np.nonzero(im_slice_2d)
if len(x_no_0) == 0: return new_slice, new_slice
#breakpoint()
x1 = x_no_0.min()
x2 = x_no_0.max()
if side == "l":
x_mid = x2; x_aux1 = x_mid - 9 + 1; x_aux2 = x2 + 1
elif side == "r":
x_mid = x1; x_aux2 = x_mid + 9; x_aux1 = x1
y_mid = y_no_0[np.where(x_no_0==x_mid)[0]].min()
y_min = y_no_0.min()
# inferior line
new_slice[x1:x2+1, y_min] = 1
# medial line
new_slice[x_mid, y_min:y_mid+1] = 1
new_slice = binary_fill_holes(new_slice)
# in_short array:
other_slice = new_slice.copy()
other_slice[x_aux1:x_aux2, :] = 0
return new_slice, other_slice | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _source_mask(self, ilens):\n x_masks = make_non_pad_mask(ilens)\n return x_masks.unsqueeze(-2)",
"def crop_to_nonzero(arrayin, mask=None):\r\n\r\n if type(arrayin) == np.ndarray :\r\n array = arrayin\r\n elif type(arrayin) == list :\r\n array = arrayin[0]\r\n\r\n if mask=... | [
"0.5911587",
"0.5905847",
"0.5815674",
"0.5776319",
"0.56993324",
"0.56690925",
"0.5630956",
"0.5623893",
"0.56130314",
"0.55582917",
"0.55565006",
"0.5489081",
"0.548841",
"0.5459489",
"0.5441693",
"0.5441693",
"0.54369754",
"0.543186",
"0.541298",
"0.5378559",
"0.5376243",
... | 0.64788425 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.