query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Wrapper for tensorflow.keras.losses.categorical_crossentropy for unified interface with selfguided earth mover distance loss. | def cross_entropy(
**kwargs
) -> Callable:
return categorical_crossentropy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crossentropy_loss(y_true, y_pred):\n ce = tf.keras.losses.categorical_crossentropy(y_true, y_pred, from_logits=True) \n return ce",
"def categorical_crossentropy(predictions, targets):\n return theano.tensor.nnet.categorical_crossentropy(predictions, targets)",
"def categorical_crossentropy(pre... | [
"0.80598766",
"0.76704156",
"0.76704156",
"0.7292305",
"0.72176355",
"0.719906",
"0.7076324",
"0.7021379",
"0.6995996",
"0.6908647",
"0.6884818",
"0.6753981",
"0.67477375",
"0.66915345",
"0.66791546",
"0.6649806",
"0.66247964",
"0.6568192",
"0.65657145",
"0.65216553",
"0.6482... | 0.7192498 | 6 |
Returns True is obj is a reference to a type. >>> is_type(1) False >>> is_type(object) True | def is_type(obj):
return type(obj) is type or type(obj) is types.ClassType | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_type(obj: Any) -> bool:\n return type(obj).__name__ == \"type\"",
"def verify_type(self, obj):\n return isinstance(obj, self.type_)",
"def has_exactly_type(obj, tpe):\r\n return type(obj) == tpe",
"def _isinstancetype(an_obj):\n if an_obj is None: return False\n if not PY3K:\n ... | [
"0.791339",
"0.7387892",
"0.7010945",
"0.6943464",
"0.6870494",
"0.68617153",
"0.68305147",
"0.6828325",
"0.67018855",
"0.66557115",
"0.6645049",
"0.6580793",
"0.65725607",
"0.65243757",
"0.64704484",
"0.6450948",
"0.64284396",
"0.6380083",
"0.6344656",
"0.63404536",
"0.63287... | 0.808517 | 0 |
Returns True is obj is a reference to an object instance. >>> is_object(1) True >>> is_object(object()) True | def is_object(obj):
return (isinstance(obj, object) and
type(obj) is not type and
type(obj) is not types.FunctionType) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsObjectReference(object_id):\n rhobj = rhutil.coercerhinoobject(object_id, True, True)\n return rhobj.IsReference",
"def IsObject(object_id):\n return rhutil.coercerhinoobject(object_id, True, False) is not None",
"def is_object(space, w_obj):\n return space.wrap(space.is_object(w_obj))",
"d... | [
"0.7468232",
"0.73197794",
"0.72269255",
"0.6879951",
"0.6802244",
"0.67232734",
"0.64855975",
"0.6451984",
"0.64154863",
"0.62765783",
"0.61777854",
"0.61642814",
"0.61642814",
"0.6127504",
"0.61242884",
"0.60844016",
"0.6053116",
"0.60480267",
"0.6020916",
"0.60170317",
"0.... | 0.7734988 | 0 |
Helper method to see if the object is a basic data type. Strings, integers, longs, floats, booleans, and None are considered primitive and will return True when passed into is_primitive() >>> is_primitive(3) True >>> is_primitive([4,4]) False | def is_primitive(obj):
if obj is None:
return True
elif type(obj) in PRIMITIVES:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_basic_type(self, objtype):\n if not hasattr(objtype, '_type_'):\n # could be python types\n return objtype in [int, long, float, bool]\n return self.is_basic_ctype(objtype)",
"def test_is_primitive_returns_true(self):\n for primitive_type in (535, \"test_string\"... | [
"0.79031056",
"0.7398652",
"0.73961365",
"0.7393698",
"0.7353975",
"0.73247886",
"0.6896635",
"0.6829993",
"0.673652",
"0.6556259",
"0.648209",
"0.64195037",
"0.6398852",
"0.63926184",
"0.6378206",
"0.62249726",
"0.61391526",
"0.60943526",
"0.6040481",
"0.59672046",
"0.596686... | 0.74452585 | 1 |
Helper method to see if the object is a Python collection (list, set, or tuple). >>> is_collection([4]) True | def is_collection(obj):
return type(obj) in COLLECTIONS_SET | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_collection_subclass(obj):\n #TODO add UserDict\n return ((issubclass(obj.__class__, COLLECTIONS) or\n is_list_like(obj)) and\n not is_collection(obj))",
"def is_collection(var):\n return isinstance(var, Iterable) and not isinstance(var, str)",
"def isCollection(self):\... | [
"0.8260522",
"0.78678584",
"0.73681325",
"0.7262765",
"0.70221525",
"0.7021473",
"0.65363497",
"0.64900017",
"0.6382033",
"0.63326865",
"0.62610656",
"0.6208034",
"0.6162035",
"0.6145411",
"0.61411995",
"0.6115035",
"0.6077727",
"0.60110456",
"0.5977089",
"0.5959623",
"0.5927... | 0.84770554 | 0 |
Helper method to see if the object is a Python list. >>> is_list([4]) True | def is_list(obj):
return type(obj) is list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isList(data):\n\ttry:\n\t\tfrom types import ListType\n\t\tif type(data) == ListType:\n\t\t\treturn True\n\texcept ImportError:\n\t\tif type(data) == type([]):\n\t\t\treturn True\n\treturn False",
"def _is_list(item):\n return isinstance(item, list)",
"def isList(obj):\n return type(obj)==types.ListTy... | [
"0.8442964",
"0.8376786",
"0.8311924",
"0.830583",
"0.82700586",
"0.8251966",
"0.81997067",
"0.81977147",
"0.8097914",
"0.8094664",
"0.78864336",
"0.78753334",
"0.78445375",
"0.77541244",
"0.7615006",
"0.7410618",
"0.7396422",
"0.7375246",
"0.73741853",
"0.73629355",
"0.72911... | 0.87735677 | 0 |
Returns True if obj is a subclass of list, set or tuple. obj must be a subclass and not the actual builtin, such as list, set, tuple, etc.. | def is_collection_subclass(obj):
#TODO add UserDict
return ((issubclass(obj.__class__, COLLECTIONS) or
is_list_like(obj)) and
not is_collection(obj)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_list(obj):\n return type(obj) is list",
"def isList(obj):\n return type(obj)==types.ListType",
"def type_check(typ, obj):\n type_s = type_str(typ) # convert to string if necessary\n\n nest_depth = type_s.count(\"List\")\n assert type_s.count(\"[\") == nest_depth, \"type_check only support... | [
"0.7147075",
"0.71085155",
"0.6974685",
"0.681954",
"0.6817514",
"0.6765451",
"0.6727528",
"0.671393",
"0.6700237",
"0.6659976",
"0.66541415",
"0.66493607",
"0.664676",
"0.66411483",
"0.663225",
"0.66282433",
"0.66225743",
"0.66203415",
"0.661844",
"0.6607744",
"0.6591619",
... | 0.7164753 | 0 |
Returns True if obj is a special (weird) class, that is more complex | def is_noncomplex(obj):
if type(obj) is time.struct_time:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isclassinstance(object):\n if not hasattr(object, \"__class__\"):\n return False\n if isbuiltin(object.__class__):\n return False\n return True",
"def is_dataclass_instance(obj: Any) -> bool:\n return dataclasses.is_dataclass(obj) and not isinstance(obj, type)",
"def is_child_clas... | [
"0.71667075",
"0.71147746",
"0.69153434",
"0.6908728",
"0.68993634",
"0.6893631",
"0.6861276",
"0.6840176",
"0.6838236",
"0.68376714",
"0.68376714",
"0.6833158",
"0.6828304",
"0.6820547",
"0.6803409",
"0.67869216",
"0.67861944",
"0.6762696",
"0.675223",
"0.6748474",
"0.674797... | 0.6549571 | 47 |
Return True if an object cannot be pickled >>> import os >>> is_picklable('os', os) True | def is_picklable(name, value):
if name in tags.RESERVED:
return False
return not is_function(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_picklable(obj):\n try:\n pickle.dumps(obj)\n\n except pickle.PicklingError:\n return False\n return True",
"def can_be_pickled(x):\n try:\n s = BytesIO() \n pickle.dump(x, s) \n return True\n except:\n return False",
"def is_object(self, name: str) ... | [
"0.85166097",
"0.78606915",
"0.6729656",
"0.65293086",
"0.62020314",
"0.6198074",
"0.6111126",
"0.6106467",
"0.59374523",
"0.5719179",
"0.5693285",
"0.56175345",
"0.553347",
"0.54608434",
"0.5449504",
"0.5390889",
"0.5382938",
"0.53372186",
"0.5323035",
"0.53207034",
"0.53068... | 0.59385574 | 8 |
Get projects of user | def get_projects_by_username(username): # noqa: E501
result = []
try:
value = ref.child("users/%s"%username).get()
if 'project_index' in value:
for key in value["project_index"]:
proj = ref.child("projects/%s"%key).get()
if proj is None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_projects_of_user(self, user_id):\n res = self.conn.cursor().execute(\"\"\"SELECT * FROM projects p JOIN users_projects up \n ON p.id = up.project_id \n WHERE owner=? OR up.user_id=?\n GROUP BY p.id\n ORDER BY last_update DESC\"\"\", (user_id, user_id,))\n return re... | [
"0.84227496",
"0.82517576",
"0.804769",
"0.7926223",
"0.77041376",
"0.76710916",
"0.76028585",
"0.75088835",
"0.7460393",
"0.74276555",
"0.73983717",
"0.7385052",
"0.7343898",
"0.7341461",
"0.7337472",
"0.73101056",
"0.7303128",
"0.7272241",
"0.7193392",
"0.71912986",
"0.7165... | 0.7330072 | 15 |
Method called to set the client's name. | def __set_name(self, name):
self.__name = name
self._window.chat_panel.place_name = name
self.encode_message(action="NO", selected_name=name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_client_name(self, name, client):\n if self.name_is_unique(name):\n client.set_name(name)\n self.send_message('Usuario actualizado exitosamente.', client.get_socket())\n else:\n self.send_message('Nombre repetido.', client.get_socket())",
"def svn_client_c... | [
"0.80215865",
"0.7751605",
"0.7565856",
"0.7203643",
"0.7203643",
"0.71981955",
"0.69989085",
"0.6944729",
"0.69077426",
"0.6889327",
"0.68495977",
"0.68416435",
"0.68377745",
"0.6812275",
"0.6810859",
"0.6810859",
"0.6810859",
"0.6810859",
"0.6810859",
"0.6798633",
"0.678767... | 0.67023957 | 32 |
generated source for method getHome | def getHome(self):
# host = getHostWithPort(url)
# ui = UrlInfo(url)
# host = url[ui.getHostHead():ui.getHostTail()]
host = self.url[self.host_head:self.host_tail]
return "http://" + host + "/" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_home(self):\n return self.home",
"def GetHomeFolder(self): # real signature unknown; restored from __doc__\n pass",
"def getHomePage(self):\n return self.home_url",
"def home(self, *args, **kwargs):\n pass",
"def home() -> Any:\n return home_page()",
"def gohome(sel... | [
"0.811916",
"0.79175884",
"0.7601972",
"0.7563043",
"0.75163716",
"0.7130797",
"0.6968598",
"0.6846898",
"0.6827225",
"0.6817982",
"0.6763875",
"0.6686223",
"0.6614228",
"0.65909207",
"0.6586324",
"0.6567089",
"0.6546231",
"0.65179783",
"0.6492359",
"0.64821094",
"0.64449996"... | 0.6691287 | 11 |
Returns file size in KB. | def size_kb(path):
size = os.path.getsize(path)
return '{:.2f}'.format(size / 1000.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_size(self) -> int:\n return self.get_main_information()['FileSize']",
"def get_size(file):\n size_in_bytes = os.path.getsize(file)\n size_in_megabytes = size_in_bytes / 1000000\n return size_in_megabytes",
"def file_size():\n return os.path.getsize(FILE_NAME)",
"def file_size(... | [
"0.8458789",
"0.8404989",
"0.83733505",
"0.82816774",
"0.8268154",
"0.81772405",
"0.8157656",
"0.8119022",
"0.8073503",
"0.8063257",
"0.8055653",
"0.8046322",
"0.80349934",
"0.801686",
"0.798756",
"0.79860276",
"0.79828596",
"0.7980973",
"0.7980973",
"0.7980973",
"0.7948388",... | 0.80924153 | 8 |
Returns a set of requirements that are defined in `requirements_file`, without versions | def get_parsed_requirements(requirements_file: str) -> Set:
requirements_set = set()
parsed_requirements = parse_requirements(requirements_file, session=False)
separators = ("=", "<", ">", "[")
for req in parsed_requirements:
requirement = req.requirement
for separator in separators:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_dependencies(requirements_file: Path) -> List[str]:\n lines = requirements_file.read_text().strip().split('\\n')\n return [line for line in lines if not line.startswith('#')]",
"def findRequirements():\n return [\n line.strip()\n for line in open(\"requirements.txt\").readlines()\n if no... | [
"0.82415545",
"0.813241",
"0.81053686",
"0.8000438",
"0.7981304",
"0.79583406",
"0.7907496",
"0.78128254",
"0.7795061",
"0.778891",
"0.77822506",
"0.77343833",
"0.77295756",
"0.7715063",
"0.76591295",
"0.76359296",
"0.7615231",
"0.75511235",
"0.75434804",
"0.752997",
"0.75122... | 0.76021177 | 17 |
remove any white space | def remove_white_space(ls):
for i in range(len(ls)):
ls[i] = re.sub(r'\s+', '', ls[i])
return ls | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_space():\n pass",
"def del_whitespace(selfs, text):\n\t\treturn text.replace(' ', '')",
"def removeMultipleSpaces(self) -> None:\n self.text = re.sub('\\s+', ' ', self.text)",
"def removeSingleChars(self) -> None:\n self.text = re.sub('\\s[^\\n\\s]\\s', ' ', self.text)",
"def _r... | [
"0.8438603",
"0.81502515",
"0.7875083",
"0.78410953",
"0.7829858",
"0.777944",
"0.77414465",
"0.77311254",
"0.77111334",
"0.77081054",
"0.766668",
"0.7657448",
"0.7654829",
"0.76396036",
"0.76009005",
"0.76009005",
"0.7580781",
"0.75354224",
"0.75125444",
"0.74910736",
"0.746... | 0.7294412 | 27 |
Euclidean distance between this and other | def euclidean(self, other):
return linalg.norm([self.x - other.x, self.y - other.y]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(self, other):\n xd, yd = self.x-other.x, self.y-other.y\n return math.sqrt(xd**2 + yd**2)",
"def distance(self,other):\n return math.sqrt((self.x - other.x)**2 +(self.y - other.y)**2)",
"def distance(self, other):\n return math.sqrt((self.x - other.x)**2 + (self.y - oth... | [
"0.8179104",
"0.81120116",
"0.8068012",
"0.8031966",
"0.80238307",
"0.80083776",
"0.7997179",
"0.7963617",
"0.7920559",
"0.7919298",
"0.79116815",
"0.7905978",
"0.7902945",
"0.78874314",
"0.78831",
"0.78543276",
"0.77549237",
"0.7711358",
"0.7704861",
"0.7697606",
"0.7691205"... | 0.84480786 | 0 |
Get a connection block ID. | def get_id(connection):
if connection is None:
return None
return connection.id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_block_id(self):\n return self._block_id",
"def SaaSessionBlockId(self):\n if self.force_auto_sync:\n self.get('SaaSessionBlockId')\n return self._SaaSessionBlockId",
"def connection_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"connection_id\")",
"... | [
"0.75690824",
"0.67081314",
"0.65562147",
"0.6314481",
"0.63095534",
"0.6296897",
"0.6296537",
"0.62865657",
"0.6196766",
"0.61526275",
"0.6149997",
"0.60899556",
"0.6076141",
"0.60537815",
"0.6045492",
"0.59969467",
"0.59662706",
"0.5894705",
"0.58773893",
"0.5868735",
"0.57... | 0.618471 | 9 |
JSON dump a string. | def data_to_string(data):
return json_dump(data).replace(']], ', ']],\n') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_json(self, string):\n return json.dumps(string)",
"def string2json(self, string):\n kwargs = {\n 'cls': BytesEncoder, # use the IPython bytes encoder\n 'indent': 1,\n 'sort_keys': True,\n 'separators': (',', ': '),\n }\n retu... | [
"0.76443094",
"0.76181805",
"0.66817296",
"0.6537304",
"0.6531794",
"0.6476015",
"0.64486194",
"0.64096475",
"0.6395297",
"0.6334097",
"0.63286424",
"0.6242508",
"0.62305313",
"0.61401904",
"0.61360085",
"0.6092913",
"0.6060817",
"0.6037397",
"0.60260874",
"0.60130656",
"0.60... | 0.0 | -1 |
Dock strings only if they convert to numbers. Avoid /0 and root(1) | def arithmetic_check(blk1, blk2, dock1, dock2):
if blk1 == None or blk2 == None:
return True
if blk1.name in ['sqrt', 'number', 'string'] and\
blk2.name in ['sqrt', 'number', 'string']:
if blk1.name == 'number' or blk1.name == 'string':
if not numeric_arg(blk1.values[0]) or ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fix_surprising_number(val, s):\n if (\n isinstance(val, (int, float)) and \"!!\" not in s\n and _contains_non_numeric_chars(s)\n ):\n return s\n return val",
"def formatCoordinates(string):\n if string == 'N/A':\n return 0\n else:\n return float(string)",
... | [
"0.56220216",
"0.5488573",
"0.5430639",
"0.54106253",
"0.5306939",
"0.53026676",
"0.5263703",
"0.52631605",
"0.5257628",
"0.52558744",
"0.52527916",
"0.52271265",
"0.51972127",
"0.51866883",
"0.51726633",
"0.5165894",
"0.5156772",
"0.5156592",
"0.5155036",
"0.512953",
"0.5112... | 0.0 | -1 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
tick_marks = np.arange(len(classes))
plt.xticks... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.7917871",
"0.791609... | 0.7934962 | 11 |
Returns the sequential serial number that represents a particular date. | def DATE(
year: func_xltypes.XlNumber,
month: func_xltypes.XlNumber,
day: func_xltypes.XlNumber
) -> func_xltypes.XlDateTime:
if not (0 < year < 9999):
raise xlerrors.NumExcelError(
f'Year must be between 1 and 9999, got {year}')
if year < 1900:
year = 1900 +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_serial(self):\n T = time.gmtime()\n base = T[0] * 10000 + T[1] * 100 + T[2]\n s_base = self.serial // 100\n if s_base < base:\n return base * 100 # New day\n else:\n return self.serial + 1 # May cause future lap",
"def serial_number(self) ->... | [
"0.66022766",
"0.65611565",
"0.6326017",
"0.63022614",
"0.6295826",
"0.6287588",
"0.62082916",
"0.6184591",
"0.61796135",
"0.61796135",
"0.60857105",
"0.59542125",
"0.5876401",
"0.58438075",
"0.5836313",
"0.58199716",
"0.5816556",
"0.5790853",
"0.57762975",
"0.5743495",
"0.56... | 0.0 | -1 |
Returns the day of a date, represented by a serial number. The day is given as an integer ranging from 1 to 31. | def DAY(
serial_number: func_xltypes.XlNumber
) -> func_xltypes.XlNumber:
date = utils.number_to_datetime(int(serial_number))
return int(date.strftime("%d")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DAY(date):\n return _make_datetime(date).day",
"def get_date_day(date):\n cut_date = date.split('-')\n return cut_date[2]",
"def date_day(date):\n return date_day_of_month(date)",
"def get_day(self):\n\n # First we get the first 8 bits stored in the day register\n # and tr... | [
"0.75094163",
"0.68820107",
"0.68608266",
"0.68543416",
"0.6842634",
"0.6794882",
"0.6770856",
"0.6744484",
"0.6639107",
"0.6532474",
"0.6528437",
"0.64861405",
"0.63666",
"0.63230574",
"0.631975",
"0.62611413",
"0.62399435",
"0.6199375",
"0.6140222",
"0.6111929",
"0.6073561"... | 0.8530884 | 0 |
Returns the number of days between two dates. | def DAYS(
end_date: func_xltypes.XlDateTime,
start_date: func_xltypes.XlDateTime
) -> func_xltypes.XlNumber:
days = end_date - start_date
return days | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def days_between(self, d1, d2):\n self.is_not_used()\n try:\n d1 = self.format_date(d1)\n d2 = self.format_date(d2)\n d1 = datetime.strptime(d1, '%Y-%m-%d')\n d2 = datetime.strptime(d2, '%Y-%m-%d')\n return abs((d2 - d1).days)\n except Exc... | [
"0.8285177",
"0.825683",
"0.81270593",
"0.80479735",
"0.80295044",
"0.8012088",
"0.80055386",
"0.7893747",
"0.78872097",
"0.782132",
"0.7678929",
"0.7665893",
"0.75952554",
"0.7585435",
"0.7536408",
"0.7400894",
"0.7321065",
"0.72761923",
"0.7117498",
"0.7109541",
"0.7101482"... | 0.7619281 | 12 |
Returns the serial number that represents the date that is the indicated number of months before or after a specified date (the start_date) | def EDATE(
start_date: func_xltypes.XlDateTime,
months: func_xltypes.XlNumber
) -> func_xltypes.XlDateTime:
delta = relativedelta(months=int(months))
edate = utils.number_to_datetime(int(start_date)) + delta
if edate <= utils.EXCEL_EPOCH:
raise xlerrors.NumExcelError(
f"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ceil_start_month(date):\n if date.month == 12:\n date = datetime(date.year + 1, 1, 1)\n else:\n date = datetime(date.year, date.month + 1, 1)\n return date",
"def start_month(d):\n return date(d.year, d.month, 1)",
"def effective_invoice_month(self) -> pulumi.Input['GoogleTypeDate... | [
"0.6496438",
"0.6180055",
"0.60394514",
"0.600491",
"0.5974207",
"0.58408254",
"0.5810796",
"0.57881445",
"0.5734235",
"0.57038325",
"0.5680332",
"0.56578046",
"0.56111413",
"0.5596714",
"0.55790526",
"0.5573294",
"0.5557663",
"0.55233175",
"0.549865",
"0.5476547",
"0.5470482... | 0.56211865 | 12 |
Returns the serial number for the last day of the month that is the indicated number of months before or after start_date. | def EOMONTH(
start_date: func_xltypes.XlDateTime,
months: func_xltypes.XlNumber
) -> func_xltypes.XlNumber:
delta = relativedelta(months=int(months))
edate = utils.number_to_datetime(int(start_date)) + delta
if edate <= utils.EXCEL_EPOCH:
raise xlerrors.NumExcelError(
f"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def floor_end_month(date):\n return datetime(date.year, date.month, 1) + timedelta(days=-1)",
"def end_month(d):\n return date(d.year, d.month, monthrange(d.year, d.month)[1])",
"def get_end_month(month):\n return datetime(2020, month, 28)",
"def _get_last_date_month(self, date_find):\n day =... | [
"0.6887431",
"0.6753189",
"0.6579611",
"0.6384442",
"0.6377608",
"0.6313313",
"0.62549496",
"0.6222332",
"0.6156236",
"0.61529213",
"0.61529213",
"0.6106549",
"0.61044925",
"0.6093002",
"0.5966115",
"0.5962716",
"0.5947614",
"0.59262943",
"0.58437514",
"0.57685935",
"0.571669... | 0.5610097 | 29 |
Returns number of the ISO week number of the year for a given date. | def ISOWEEKNUM(
date: func_xltypes.XlDateTime
) -> func_xltypes.XlNumber:
datetime_date = utils.number_to_datetime(int(date))
isoweeknum = datetime_date.isocalendar()[1]
return isoweeknum | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetWeekNum(self, date):\n (y, m, d) = date.split('-')\n return (dt.date(int(y), int(m), int(d)) - self.START_DATE).days / 7",
"def get_week(date):\n\n # TODO: the API seems broken. It returns week, year not year, week as documentef\n # why not use date.isocalendar() from the stdlib?\n\n date =... | [
"0.7689929",
"0.75421417",
"0.7513008",
"0.7494453",
"0.73564196",
"0.7075879",
"0.7074813",
"0.6916116",
"0.6815475",
"0.6793665",
"0.66957754",
"0.65802777",
"0.6554721",
"0.6545535",
"0.65019614",
"0.6280024",
"0.62691706",
"0.6132038",
"0.6114491",
"0.6022619",
"0.5980099... | 0.71484226 | 5 |
Returns the month of a date represented by a serial number. The month is given as an integer, ranging from 1 (January) to 12 (December). | def MONTH(
serial_number: func_xltypes.XlNumber
) -> func_xltypes.XlNumber:
date = utils.number_to_datetime(int(serial_number))
return int(date.strftime("%m")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MONTH(date):\n return _make_datetime(date).month",
"def date_month(date):\n return date.month",
"def month(self, month: str):\n return get_from_list(self.months, \"month\", month)",
"def getMonth(num):\n\n months = {\n '01': 'January',\n '02': 'February',\n ... | [
"0.7629",
"0.74563485",
"0.7338108",
"0.7152897",
"0.7121106",
"0.7110391",
"0.70654064",
"0.70519125",
"0.6986605",
"0.69298065",
"0.69133335",
"0.690376",
"0.6854037",
"0.68275785",
"0.6798793",
"0.6771319",
"0.6738992",
"0.6728494",
"0.6727914",
"0.6666149",
"0.65723515",
... | 0.876099 | 0 |
Returns the serial number of the current date and time. | def NOW() -> func_xltypes.XlDateTime:
return utils.datetime_to_number(now()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_serial(self):\n T = time.gmtime()\n base = T[0] * 10000 + T[1] * 100 + T[2]\n s_base = self.serial // 100\n if s_base < base:\n return base * 100 # New day\n else:\n return self.serial + 1 # May cause future lap",
"def serial_number(self) ->... | [
"0.73336643",
"0.7316327",
"0.7192099",
"0.702219",
"0.69481325",
"0.6945059",
"0.68689",
"0.6858294",
"0.6763856",
"0.67397267",
"0.669843",
"0.6662579",
"0.6647956",
"0.6604528",
"0.6600162",
"0.65788484",
"0.6559291",
"0.65082675",
"0.6500693",
"0.6461435",
"0.6461435",
... | 0.0 | -1 |
Returns the serial number of the current date. | def TODAY() -> func_xltypes.XlDateTime:
date_and_time = now()
date = date_and_time.replace(
hour=0, minute=0, second=0, microsecond=0)
return utils.datetime_to_number(date) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serial_number(self) -> str:\n return pulumi.get(self, \"serial_number\")",
"def serial_number(self):\n version_data = self._raw_version_data()\n if self._serial_number is None:\n self._serial_number = version_data[\"serial\"]\n\n return self._serial_number",
"def get_... | [
"0.73160756",
"0.7241172",
"0.7063082",
"0.69923073",
"0.69186425",
"0.6908373",
"0.6686096",
"0.6608836",
"0.64926183",
"0.64926183",
"0.64204603",
"0.64204603",
"0.64020807",
"0.635582",
"0.6343414",
"0.63368654",
"0.6325623",
"0.6292808",
"0.62877005",
"0.62111324",
"0.619... | 0.0 | -1 |
Return the main page. | def index():
# get random 3 places for display
places = get_place(db, count=3)
# return with template
return render_template('index.html',
count=len(places),
places=places) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_page():\n return render_template(\"main_page.html\")",
"def main_page():\n return render_template(\"index.html\")",
"def home():\n return render_template('Main_Page.html')",
"def main():\n page = get_page_arg()\n\n items = load_data(page)\n total_pages = get_total_pages()\n cont... | [
"0.82845694",
"0.8143359",
"0.77520114",
"0.7678913",
"0.76491636",
"0.7477202",
"0.74368745",
"0.74368745",
"0.7415956",
"0.7336081",
"0.7303977",
"0.7234337",
"0.7207475",
"0.7207475",
"0.71984005",
"0.7193869",
"0.713179",
"0.71184117",
"0.71184117",
"0.7114224",
"0.711049... | 0.0 | -1 |
Return the about page. | def about():
return render_template('about.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def about():\n return render_template('about.html', title='About')",
"def about():\n\n\treturn render_template(\"about.html\")",
"def about():\n\n return render_template('about_page.html', title='About')",
"def about():\n\n\treturn render_template('about.html', title='About',\n\t\t\t\t\t\t year=d... | [
"0.85650903",
"0.85443485",
"0.85230863",
"0.8494638",
"0.8469827",
"0.84001523",
"0.83943474",
"0.83943474",
"0.83943474",
"0.83943474",
"0.83943474",
"0.83943474",
"0.83943474",
"0.83943474",
"0.83943474",
"0.83943474",
"0.83943474",
"0.83943474",
"0.83943474",
"0.8357133",
... | 0.809435 | 33 |
Given an action, make state transition and observe reward. | def make_step(self, action_index):
# Randomly sample action_index if world is stochastic
if np.random.uniform(0, 1) < self.random_move_probability:
action_indices = np.arange(self.num_actions, dtype=int)
action_indices = np.delete(action_indices, action_index)
action_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, action):\n res = self.reward_table.get(self.curr_state, action)\n\n self.curr_state = res['result']\n\n return res",
"def step(self, action):\r\n s = self.get_state()\r\n\r\n elements = np.arange(self.S)\r\n # weights = np.squeeze(self.nextStateProbability[s,action])\... | [
"0.7485294",
"0.74373305",
"0.7386105",
"0.7372976",
"0.72845864",
"0.72733206",
"0.72685844",
"0.71875054",
"0.71726376",
"0.7170161",
"0.71582",
"0.71346724",
"0.7124485",
"0.71015763",
"0.70898825",
"0.7083155",
"0.70738685",
"0.7065874",
"0.70622146",
"0.70525545",
"0.700... | 0.0 | -1 |
Renders the home page. | def home():
return render_template(
'index.html',
title='Home Page',
year=datetime.now().year,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_home():\r\n\treturn render_template(\"index.html\")",
"def home():\n\n return render_template('home_page.html')",
"def home():\n\n return render_template(\"home.html\")",
"def home():\n return render_template('home.html')",
"def home():\n return render_template('home.html')",
"def ... | [
"0.85574406",
"0.853399",
"0.8351404",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.827363",
"... | 0.8061255 | 39 |
Renders the about page. | def about():
return render_template(
'about.html',
title='About',
year=datetime.now().year,
message='Your application description page.'
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def about():\n return render_template('about.html', title='About')",
"def about():\n\n return render_template('about_page.html', title='About')",
"def about():\n\n\treturn render_template(\"about.html\")",
"def on_about(self):\n render_about_window()",
"def about():\n return render_temp... | [
"0.85650355",
"0.85034525",
"0.84489655",
"0.84044397",
"0.8394454",
"0.82935613",
"0.82680845",
"0.8243358",
"0.8239194",
"0.8224137",
"0.82079816",
"0.8204868",
"0.8173699",
"0.8172736",
"0.80967313",
"0.80501616",
"0.80501616",
"0.80501616",
"0.80501616",
"0.80501616",
"0.... | 0.82709616 | 11 |
Return a dict mapping id to string name for all global variables | def all_globals_dict(self):
return self.module_node.used_vars | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_global_variable_names(self):\n return [b\"\".join(_i).strip().decode()\n for _i in self._f.variables[\"name_glo_var\"][:]]",
"def global_values(self):\n return self.globals.values()",
"def variables_declared (self) :\r\n\t\tresult = {}\r\n\r\n\t\tfor var in self.variables :... | [
"0.6912686",
"0.6838243",
"0.6743445",
"0.6642719",
"0.66283077",
"0.65740776",
"0.6490776",
"0.6437585",
"0.6416777",
"0.64092",
"0.63613534",
"0.633619",
"0.6316035",
"0.6260247",
"0.6258549",
"0.6246101",
"0.6241849",
"0.6233003",
"0.62268966",
"0.6211455",
"0.61730105",
... | 0.69046956 | 1 |
A string representation of the model. | def __str__(self):
return self.comment | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __repr__(self):\n\n mod = f\"{self.__class__.__name__} Model\"\n try:\n mod += f': {self.filename}'\n except AttributeError:\n pass\n s = [mod]\n for name, v in self.metadat... | [
"0.8567286",
"0.80320746",
"0.7939547",
"0.78144956",
"0.78115743",
"0.7782607",
"0.7757796",
"0.7757796",
"0.773894",
"0.77152467",
"0.7714009",
"0.7679083",
"0.7661709",
"0.765754",
"0.7645759",
"0.7645759",
"0.7628557",
"0.762749",
"0.75903344",
"0.75903344",
"0.7569605",
... | 0.0 | -1 |
A `tf.Operation` that should be run to initialize this iterator. | def initializer(self):
if self._initializer is not None:
return self._initializer
else:
# TODO(mrry): Consider whether one-shot iterators should have
# initializers that simply reset their state to the beginning.
raise ValueError(
"The iterator does not have an initializer. Thi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_train_op(self):\n hparams = self.hparams\n tvars = tf.trainable_variables()\n grads = tf.gradients(self.cost, tvars)\n if hparams.gradient_clipping_by_global_norm > 0.0:\n grads, norm = tf.clip_by_global_norm(\n grads, hparams.gradient_clipping_by_global_norm)\n tf.summary... | [
"0.63732797",
"0.6372677",
"0.61928415",
"0.61928415",
"0.6183827",
"0.61515856",
"0.61282384",
"0.60020703",
"0.5993488",
"0.59929574",
"0.59447944",
"0.59418595",
"0.58725953",
"0.58582807",
"0.5853859",
"0.5841829",
"0.58366185",
"0.5829517",
"0.58191735",
"0.58134913",
"0... | 0.5500446 | 55 |
Returns the next element. >>> dataset = tf.data.Dataset.from_tensors(42) >>> iterator = iter(dataset) >>> print(iterator.get_next()) tf.Tensor(42, shape=(), dtype=int32) | def get_next(self):
raise NotImplementedError("Iterator.get_next()") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next(self, name=None):\n self._get_next_call_count += 1\n if self._get_next_call_count > GET_NEXT_CALL_WARNING_THRESHOLD:\n warnings.warn(GET_NEXT_CALL_WARNING_MESSAGE)\n\n # TODO(b/169442955): Investigate the need for this colocation constraint.\n with ops.colocate_with(self._iterator_res... | [
"0.7010407",
"0.64563787",
"0.6298481",
"0.62972987",
"0.6241756",
"0.6191541",
"0.6160718",
"0.6134648",
"0.61189985",
"0.61013645",
"0.60707587",
"0.60537446",
"0.6034525",
"0.59972167",
"0.59648746",
"0.59382707",
"0.593443",
"0.5933434",
"0.589824",
"0.5875894",
"0.587463... | 0.6571849 | 1 |
Returns the next element wrapped in `tf.experimental.Optional`. If the iterator has reached the end of the sequence, the returned `tf.experimental.Optional` will have no value. >>> dataset = tf.data.Dataset.from_tensors(42) >>> iterator = iter(dataset) >>> optional = iterator.get_next_as_optional() >>> print(optional.h... | def get_next_as_optional(self):
raise NotImplementedError("Iterator.get_next_as_optional()") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_as_optional(iterator):\n return iterator.get_next_as_optional()",
"def first(self):\n try:\n return self.next()\n except StopIteration:\n return None",
"def get_next(self):\n try:\n return self.the_input[self.index]\n except IndexError:... | [
"0.7879689",
"0.63527375",
"0.62644297",
"0.6205212",
"0.6166065",
"0.5992998",
"0.59687847",
"0.5950846",
"0.59332424",
"0.5909193",
"0.5904805",
"0.5860199",
"0.5836594",
"0.5813866",
"0.58055085",
"0.5783859",
"0.5741394",
"0.5681748",
"0.5665594",
"0.5649734",
"0.56365746... | 0.7580918 | 1 |
Returns a `tf.experimental.Optional` with the next element of the iterator. If the iterator has reached the end of the sequence, the returned `tf.experimental.Optional` will have no value. | def get_next_as_optional(iterator):
return iterator.get_next_as_optional() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_as_optional(self):\n raise NotImplementedError(\"Iterator.get_next_as_optional()\")",
"def _peek(iter: Iterable, index: int) -> Optional[any]:\r\n if index < len(iter):\r\n return iter[index]\r\n return None",
"def first(self):\n try:\n return self.next()\n ... | [
"0.7409302",
"0.69344676",
"0.67602026",
"0.6540311",
"0.6472368",
"0.6347067",
"0.63168347",
"0.62889636",
"0.6276383",
"0.62265646",
"0.6221217",
"0.6214293",
"0.61614627",
"0.61393565",
"0.61228245",
"0.6073923",
"0.60564023",
"0.604784",
"0.59702075",
"0.59295785",
"0.591... | 0.8235539 | 0 |
Helper method to see if filename ends with certain extension | def match_extensions(filename):
return any(filename.endswith(e) for e in extensions) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_suffix_right(file: Path, extension: str):\n ext = extension.lower()\n fext = file.suffix.lower()[1:]\n jpgs = {\"jpg\", \"jpeg\"}\n if fext in jpgs and ext in jpgs:\n return True\n elif fext == ext:\n return True\n return False",
"def is_good_file(filename):\n for e ... | [
"0.78286934",
"0.7715419",
"0.7690795",
"0.75723946",
"0.75723946",
"0.7541415",
"0.7531205",
"0.7429993",
"0.73595744",
"0.7353166",
"0.72853684",
"0.72138846",
"0.7159781",
"0.71052444",
"0.7104127",
"0.709392",
"0.7090864",
"0.7074538",
"0.70362025",
"0.7028646",
"0.702864... | 0.78229445 | 1 |
Get the height of the board. | def get_grid_height(self):
# replace with your code
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def height(self):\n return self.board.shape[0]",
"def getHeight(self):\n return self.height",
"def getHeight(self):\n return self.height",
"def getHeight(self):\n return self._height",
"def get_grid_height(self):\n return self._height",
"def get_grid_height(self):\n ... | [
"0.8506178",
"0.7828281",
"0.7828281",
"0.7792005",
"0.7788401",
"0.7788401",
"0.77683884",
"0.77683884",
"0.77683884",
"0.77683884",
"0.77662206",
"0.7763028",
"0.776071",
"0.77545404",
"0.7742475",
"0.77377915",
"0.7721646",
"0.769687",
"0.76945823",
"0.76945823",
"0.769458... | 0.0 | -1 |
get_processed_path Return the path of the processed image. | def get_processed_path(self):
return self.processed_img_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_processed_path(self):\n location = self.get_storage().location\n return self.get_processed_key_name()[len(location):]",
"def get_raw_path(self):\n\n return self.raw_img_path",
"def get_processed_flow_paths(self) -> Path:\n return self.flow_data_paths.processed_flow_path",
... | [
"0.7148072",
"0.7044103",
"0.69271433",
"0.68576616",
"0.6614305",
"0.6582985",
"0.65731406",
"0.6437839",
"0.63826907",
"0.61899906",
"0.6160464",
"0.6144508",
"0.61177987",
"0.6117216",
"0.6071506",
"0.602279",
"0.60207313",
"0.598378",
"0.5957673",
"0.59549123",
"0.5914848... | 0.9124141 | 0 |
reset the network parameters using xavier init | def reset_parameters(self):
for p in self.parameters():
if len(p.shape) > 1 and p.size(-1) != 2:
nn.init.xavier_normal_(p) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters(self):\n logger.info('===== Initialize %s with Xavier u... | [
"0.7137537",
"0.7137537",
"0.70319754",
"0.7009362",
"0.6990484",
"0.69618165",
"0.69261223",
"0.6893333",
"0.6796462",
"0.6796462",
"0.6796462",
"0.67606765",
"0.6713357",
"0.6697281",
"0.6693835",
"0.6693835",
"0.66392934",
"0.66078997",
"0.6584755",
"0.6584032",
"0.6552471... | 0.67024213 | 14 |
reset the network parameters using xavier init | def reset_parameters(self):
for p in self.parameters():
if len(p.shape) > 1 and p.size(-1) != 2:
nn.init.xavier_normal_(p) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters(self):\n logger.info('===== Initialize %s with Xavier uniform distribution =====' % self.__class__.__name__)\n for n, p in self.named_parameters():\n init_with_xavier_uniform(n, p)",
"def reset_parameters(self):\n logger.info('===== Initialize %s with Xavier u... | [
"0.7137537",
"0.7137537",
"0.70319754",
"0.7009362",
"0.6990484",
"0.69618165",
"0.69261223",
"0.6893333",
"0.6796462",
"0.6796462",
"0.6796462",
"0.67606765",
"0.6713357",
"0.6697281",
"0.6693835",
"0.6693835",
"0.66392934",
"0.66078997",
"0.6584755",
"0.6584032",
"0.6552471... | 0.67024213 | 13 |
Base utility class for a 3D object | def __init__(self, radius: float, location: tuple, name: str):
self.loc = location
self.radius = radius
self.name = name
self.verts = []
self.edges = []
self.faces = []
self.mesh_data = None
self.obj = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, _x, _y, _z):\n self.position = Position3d(int(_x), int(_y), int(_z))\n self.velocity = Velocity3d(0, 0, 0)",
"def D3(self, *args):\n return _Adaptor3d.Adaptor3d_Surface_D3(self, *args)",
"def plot_3d_object(object_):\n \n # Initialize renderer instance\n r = Ren... | [
"0.6517773",
"0.65008557",
"0.6297051",
"0.61934984",
"0.6189151",
"0.61820394",
"0.6121362",
"0.6065915",
"0.606356",
"0.6036464",
"0.6034633",
"0.60264176",
"0.60030615",
"0.6002801",
"0.597907",
"0.597907",
"0.59410536",
"0.594044",
"0.59030646",
"0.5880547",
"0.5867427",
... | 0.0 | -1 |
(list of ClassRecorder) > str Return dot node and relationship string from list of ClassRecorder | def write(self, classes):
assert isinstance(classes, list)
dot_string = "digraph \"class\" {\n"
dot_string = self.write_node(dot_string, classes)
dot_string = self.write_edge(dot_string, classes)
dot_string += "}"
print(dot_string)
return dot_string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_node(self, dot_string, classes):\n assert isinstance(classes, list) and isinstance(dot_string, str)\n for cls in classes:\n assert isinstance(cls, ClassRecorder)\n dot_string = self._write_class(dot_string, cls.name)\n dot_string = self._write_members(dot_st... | [
"0.677315",
"0.6288453",
"0.6200629",
"0.61379313",
"0.6048865",
"0.59876096",
"0.5975047",
"0.5916194",
"0.5914346",
"0.58823943",
"0.58641964",
"0.5822125",
"0.58183676",
"0.5778875",
"0.5769247",
"0.5767818",
"0.5737888",
"0.5737888",
"0.5719834",
"0.57124996",
"0.56566143... | 0.5640032 | 22 |
(str, list of ClassRecorder) > str Return dot node string from list of ClassRecorder. >>> writer = DotWriter() >>> writer.write_node('dot_string', 1) | def write_node(self, dot_string, classes):
assert isinstance(classes, list) and isinstance(dot_string, str)
for cls in classes:
assert isinstance(cls, ClassRecorder)
dot_string = self._write_class(dot_string, cls.name)
dot_string = self._write_members(dot_string, cls.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, classes):\n assert isinstance(classes, list)\n dot_string = \"digraph \\\"class\\\" {\\n\"\n dot_string = self.write_node(dot_string, classes)\n dot_string = self.write_edge(dot_string, classes)\n dot_string += \"}\"\n print(dot_string)\n return dot_... | [
"0.6175634",
"0.6106742",
"0.6038707",
"0.5997778",
"0.59966487",
"0.5970593",
"0.58346593",
"0.5713313",
"0.56094396",
"0.5526045",
"0.54803103",
"0.5478874",
"0.5442519",
"0.53971756",
"0.5386999",
"0.5315951",
"0.5302441",
"0.5302441",
"0.52937675",
"0.5286204",
"0.5285468... | 0.7733519 | 0 |
Initialize the Calculator frame. This frame contains frames for other calculator types. | def __init__(self, master, _type=REGULAR, **kw):
Frame.__init__(self, master, **kw)
self.main_frame = Frame(self, bd=1)
self.main_frame.pack() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n\n #Creates the window.\n EasyFrame.__init__(self, \"Calculator\", resizable = False)\n\n #Creates the data model Calculator.\n self.calculator = Calculator()\n\n #Keeps track of when the user enters an input.\n self.operatorEntered = False\n\n ... | [
"0.67058825",
"0.64705867",
"0.6338738",
"0.6195571",
"0.6167947",
"0.6119221",
"0.6107527",
"0.59098125",
"0.58212906",
"0.57819384",
"0.57573354",
"0.5733919",
"0.5732447",
"0.57315475",
"0.57264185",
"0.5703008",
"0.5633254",
"0.561861",
"0.56053686",
"0.560241",
"0.560175... | 0.54168886 | 35 |
Plots transformed word embeddings with some given cluster labels. | def plot_word_embeddings_clustered(
transformed_word_embeddings: dict,
words: np.ndarray,
cluster_labels: np.ndarray,
embedder_labels: Optional[dict] = None,
embedder_keys: Optional[list] = None,
print_words_in_clusters: bool = False,
continuous_word_colors: bool = False,
) -> None:
if e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize_embedding(embeddings, idx2word, num_words=300, title=\"\"):\n tsne = TSNE()\n embed_tsne = tsne.fit_transform(embeddings[:num_words, :])\n fig, ax = plt.subplots(figsize=(14, 14))\n for idx in range(num_words):\n plt.scatter(*embed_tsne[idx, :], color='steelblue')\n plt.anno... | [
"0.73643863",
"0.7026746",
"0.69125473",
"0.6783121",
"0.67311496",
"0.64863634",
"0.6378388",
"0.6281596",
"0.6258286",
"0.6249376",
"0.62302804",
"0.61491436",
"0.61248475",
"0.60913694",
"0.6073896",
"0.60533696",
"0.6050925",
"0.6039259",
"0.6011604",
"0.59520876",
"0.593... | 0.76622856 | 0 |
Returns the organization name associated with the project or an empty string if no organization is set. | def organization_name(self):
if self.organization is not None:
return self.organization.name
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def organization(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"organization\")",
"def vpp_organization_name(self):\n if \"vppOrganizationName\" in self._prop_dict:\n return self._prop_dict[\"vppOrganizationName\"]\n else:\n return None",
"def get_o... | [
"0.78841555",
"0.7617757",
"0.74921674",
"0.7478675",
"0.7334929",
"0.72538245",
"0.7246963",
"0.7246963",
"0.70083797",
"0.69322044",
"0.6905932",
"0.68770164",
"0.68595076",
"0.68595076",
"0.6849413",
"0.6849413",
"0.67948025",
"0.6753732",
"0.6753732",
"0.67186034",
"0.669... | 0.8445462 | 0 |
Turn the relay off. | async def async_turn_off(self, **kwargs: Any) -> None:
self._attr_is_on = await self.relay.set_active(False)
self.async_write_ha_state() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_off(self, **kwargs):\n set_sonoff_state(self._host, \"off\")\n self._state = False",
"def turn_off(self):\n print(\"Turning the lights off\")\n self.led.all_off()\n self.client.publish(STATE_TOPIC, OFF) #publish",
"def turn_off(self, **kwargs):\n self.smartplu... | [
"0.8096829",
"0.7890653",
"0.7842926",
"0.77896625",
"0.77758825",
"0.7774262",
"0.7712081",
"0.7640466",
"0.7614276",
"0.76131517",
"0.76007503",
"0.75667477",
"0.7547972",
"0.74837375",
"0.7462361",
"0.7458294",
"0.7433815",
"0.7398294",
"0.7373427",
"0.7372174",
"0.7362091... | 0.75073 | 13 |
Normalize the list with given max value. If the max_ is default value, and it is automatically assigned the maximun value in the list. | def normalize(li, max_=0):
if type(li) == list:
if max_ == 0:
max_ = max(li)
return [e/float(max_) for e in li]
elif type(li) == dict:
if max_ == 0:
max_ = max(li.values())
return dict([(k, v/float(max_)) for (k,v) in li.items()]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(list, max_value=1):\n maxi = max(list)\n mini = min(list)\n\n if maxi == mini or len(list) == 1:\n return list\n \n norm = []\n\n for item in list:\n new = max_value * ((item - mini) / (maxi - mini))\n norm.append(new)\n\n return norm",
"def max_normalize(v... | [
"0.75630575",
"0.70214725",
"0.66076034",
"0.6392074",
"0.63734424",
"0.63646644",
"0.63362056",
"0.6264399",
"0.6224984",
"0.61147344",
"0.60855836",
"0.6060915",
"0.5983791",
"0.59730875",
"0.59521365",
"0.59400845",
"0.59232664",
"0.5903608",
"0.5896476",
"0.5893984",
"0.5... | 0.75798833 | 0 |
Computes the outereye corner normalised rmse error. | def outer_eye_corner_68(prediction, ground_truth):
num_landmarks = 68
assert prediction.points.shape[0] == num_landmarks
assert ground_truth.points.shape[0] == num_landmarks
interocular_dist = np.linalg.norm(ground_truth.points[36] - ground_truth.points[45])
rmse_error = np.sum(np.linalg.n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rmse (lmse) :\n return np.sqrt(2*lmse)",
"def compute_RMSE(e):\n \"\"\"Corresponds to sqrt(2*MSE)\"\"\"\n \n return np.sqrt(2*compute_MSE(e))",
"def root_square_error(input_img, output_img):\n rse = np.sqrt(np.sum(np.power(output_img - input_img, 2)))\n\n return rse",
"def inrse(self) -... | [
"0.67534137",
"0.65286773",
"0.647784",
"0.647524",
"0.6470162",
"0.6423531",
"0.64027965",
"0.6352728",
"0.63381714",
"0.6277581",
"0.6261508",
"0.6260215",
"0.62589383",
"0.62534255",
"0.6250657",
"0.624107",
"0.6235428",
"0.6222021",
"0.6222021",
"0.6219185",
"0.620392",
... | 0.0 | -1 |
Return an iterable of `seq` with `el` added to the end | def caboose(seq: Iterable[TItem], el: TElement) -> Iterable[Union[TElement, TItem]]:
yield from seq
yield el | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cons(el, seq):\n yield el\n for s in seq:\n yield s",
"def extend(self, seq):\n for element in seq:\n self.append(element)",
"def interpose(el, seq):\n return rest(mapcat(lambda x: [el, x], seq))",
"def append(l):\n while True:\n x = yield\n l.append(x)"... | [
"0.68907595",
"0.6866106",
"0.6426324",
"0.6409817",
"0.6101",
"0.6071541",
"0.5917339",
"0.5833091",
"0.58219445",
"0.5798548",
"0.57672757",
"0.5682871",
"0.5679354",
"0.5675059",
"0.5648116",
"0.56096643",
"0.55766773",
"0.554685",
"0.55368954",
"0.55049795",
"0.5498552",
... | 0.7085079 | 0 |
Create a new temporary diractory in self.tempdir. | def setUp(self):
super(TestCaseWithTempDir, self).setUp()
self.tempdir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.tempdir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mktemp(self):\n newDir = tempfile.mkdtemp(dir=tempfile.gettempdir())\n self.addCleanup(shutil.rmtree, newDir)\n return newDir",
"def makeTempDir(self):\n try:\n os.mkdir(self.temp_dir)\n except FileExistsError:\n pass",
"def make_tempdir():\n retu... | [
"0.81288224",
"0.79946566",
"0.79593354",
"0.7931041",
"0.7836506",
"0.7821261",
"0.7753192",
"0.7722916",
"0.7560119",
"0.7502192",
"0.74321467",
"0.7423052",
"0.73303294",
"0.7321855",
"0.73091966",
"0.7287271",
"0.72400796",
"0.7220534",
"0.7215599",
"0.7201676",
"0.717171... | 0.677739 | 49 |
Draws an ellipse on the input image. The input image is modified. | def draw_ellipse(mat, radius_x, radius_y, angle, color=(0, 0, 255), thickness=1):
cv2.ellipse(mat, (radius_x, radius_y), angle, 0, 0, color, thickness=thickness) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drawEllipse(img, center, axes, angle, startAngle=0, endAngle=360, color = (0,0,255), fill = -1):\n\tcv2.ellipse(img, center, axes, angle, startAngle, endAngle, color, fill)",
"def ellipse(self):\n f = self.img\n x = self.x\n y = self.y\n x2 = self.x2\n y2 = self.y2\n xy = ... | [
"0.7968521",
"0.76760113",
"0.7426522",
"0.7189586",
"0.7176237",
"0.7028311",
"0.7021333",
"0.6984966",
"0.6980804",
"0.6956461",
"0.6932573",
"0.6857018",
"0.6803738",
"0.6801288",
"0.6792579",
"0.6777636",
"0.6730455",
"0.6581335",
"0.652445",
"0.6515943",
"0.6478726",
"... | 0.7104427 | 5 |
Draws a line on the input image. The input image is modified. | def draw_line(mat, pt1, pt2, color=(0, 0, 255), thickness=1):
cv2.line(mat, pt1, pt2, color, thickness=thickness) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _plot_line(self, image, x1, y1, x2, y2, width, color):\n\n draw = ImageDraw.Draw(image, \"RGBA\")\n draw.line([x1, y1, x2, y2], fill=color, width=width)\n del draw\n\n return image",
"def drawLine(img, start, end, color = (0,0,255), thickness = 3):\n\tcv2.line(img, start, end, col... | [
"0.81148785",
"0.8084203",
"0.77066904",
"0.7629203",
"0.7558556",
"0.7557498",
"0.7303508",
"0.71972847",
"0.7088559",
"0.7084591",
"0.7080822",
"0.6986955",
"0.6985987",
"0.69286364",
"0.69033414",
"0.68686634",
"0.68118477",
"0.6805751",
"0.6804198",
"0.6755652",
"0.674397... | 0.706975 | 11 |
Selects the default database to read from. | def db_for_read (self, model, **hints):
return 'default' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default_database(self):\n attr_name = mangle_delegate_name(self.__class__, '__default_database_name')\n default_db_name = getattr(self.delegate, attr_name)\n if default_db_name is None:\n raise ConfigurationError('No default database defined')\n\n return self[default_... | [
"0.7641834",
"0.72926277",
"0.70955354",
"0.69750404",
"0.689882",
"0.68569404",
"0.68512577",
"0.6848048",
"0.6848048",
"0.68361837",
"0.682213",
"0.67958754",
"0.67927223",
"0.67827547",
"0.67798424",
"0.6760515",
"0.6749613",
"0.6737524",
"0.6690064",
"0.66689086",
"0.6666... | 0.62248117 | 80 |
Selects the default database to write to. | def db_for_write (self, model, **hints):
return 'default' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_for_write(self, model, **hints):\n if hasattr(model, 'db_name'):\n return model.db_name\n return 'default'",
"def db_for_write(self, model, **hints):\n\n return self.db_name",
"def get_default_database(self):\n attr_name = mangle_delegate_name(self.__class__, '__de... | [
"0.7240018",
"0.7208571",
"0.7115788",
"0.70552236",
"0.69855934",
"0.6930045",
"0.6913946",
"0.6886706",
"0.68777436",
"0.68030727",
"0.6732081",
"0.66004777",
"0.65598935",
"0.6556607",
"0.65395784",
"0.6536706",
"0.65269434",
"0.64586145",
"0.64245456",
"0.64245456",
"0.64... | 0.65468967 | 14 |
Return path to the test directory | def tests_dirpath():
execdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
return os.path.join(execdir, "tests") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dir():\n return os.path.abspath(os.path.dirname(__file__))",
"def get_test_path():\n path, name = os.path.split(__file__)\n return os.path.join(path,\"..\", 'test-data')",
"def get_tests_directory() -> str:\n module_file_path = os.path.abspath(__file__)\n return os.path.dirname(module_f... | [
"0.8819322",
"0.86364067",
"0.8501037",
"0.8232057",
"0.80929565",
"0.794459",
"0.7903542",
"0.78988165",
"0.7842125",
"0.77695835",
"0.7729441",
"0.76458263",
"0.7572866",
"0.75215024",
"0.75057584",
"0.7486256",
"0.7429015",
"0.74271524",
"0.734008",
"0.7297556",
"0.7274416... | 0.84717315 | 3 |
Computes the covariance between any two tomographic power spectra. | def cl_cov(self,cls=None, zs_indx=[],tracers=[],Win=None):
cov={}
cov['final']=None
cov['G1324'],cov['G1423']=self.cov_utils.gaussian_cov_window(cls,
self.SN,tracers,zs_indx,self.do_xi)
if self.use_window:
cov['G']=cov['G1324']*Win... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_covariance(self, lc1, lc2):\n return np.cov(lc1.counts, lc2.counts)[0][1]",
"def covariance(self, x1, x2, lengths):\n z = self.dist(x1, x2, lengths)\n return (self.a**2) * exp(-0.5*z)",
"def covariance(x, y):\n n = len(x)\n return dot(deviations_from_mean(x), deviations_... | [
"0.69835603",
"0.68673015",
"0.6833794",
"0.6754418",
"0.67513084",
"0.66696286",
"0.66470736",
"0.6613608",
"0.6582763",
"0.6521231",
"0.63750935",
"0.63698626",
"0.6263693",
"0.624292",
"0.62353176",
"0.61951077",
"0.61516654",
"0.61491805",
"0.6117908",
"0.6114703",
"0.605... | 0.0 | -1 |
Create a logger, if no handlers already exist attach to stdout | def get_named_logger(name, debug=False):
logger = logging.getLogger(name)
if debug:
logger.setLevel(logging.DEBUG)
else:
logger.setLevel(logging.INFO)
if not len(logger.handlers):
handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter('[ %(asctime)s ] [... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_logger():\n root = logging.getLogger()\n root.setLevel(LOGGING_LEVEL)\n formatter = logging.Formatter('%(asctime)s - %(message)s')\n ch = logging.StreamHandler(sys.stdout)\n ch.setLevel(LOGGING_LEVEL)\n ch.setFormatter(formatter)\n root.addHandler(ch)",
"def loggerSetup(logLevel=lo... | [
"0.70456314",
"0.7036956",
"0.6946839",
"0.68466294",
"0.6770619",
"0.6769743",
"0.675371",
"0.67341554",
"0.6699235",
"0.6679251",
"0.66725564",
"0.6670188",
"0.6638229",
"0.662195",
"0.66205055",
"0.6617076",
"0.6603178",
"0.6601915",
"0.6601364",
"0.65997493",
"0.65987885"... | 0.0 | -1 |
Determine if this task is past its due date. Notice that we compare to `utcnow` since dates are stored in UTC. | def past_due(self):
return self.due_date and self.due_date < datetime.utcnow() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_past_due(self):\n return self.due_date < timezone.now()",
"def _is_past_due(self):\n if self.due is None:\n return False\n\n if timezone.now() > self.due:\n return True",
"def is_past_due(self):\r\n return (self.close_date is not None and\r\n ... | [
"0.82955945",
"0.8173227",
"0.8090583",
"0.76816714",
"0.7349426",
"0.71316403",
"0.7013289",
"0.69788814",
"0.6905287",
"0.68328774",
"0.6497983",
"0.6448556",
"0.64226174",
"0.6393358",
"0.6335383",
"0.6275599",
"0.61151165",
"0.6099794",
"0.60855603",
"0.6041135",
"0.59142... | 0.86733425 | 0 |
Read four bytes of binary data and return as a 32 bit int | def read_int32(ucode_file):
return int.from_bytes(ucode_file.read(4), 'little') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read32(bytestream):\n dt = np.dtype(np.uint32).newbyteorder('>')\n return np.frombuffer(bytestream.read(4), dtype=dt)[0]",
"def read32(bytestream):\n dt = np.dtype(np.uint32).newbyteorder('>')\n return np.frombuffer(bytestream.read(4), dtype=dt)[0]",
"def read_int(data):\n s_type = \"=%s\" % get_typ... | [
"0.7753421",
"0.7753421",
"0.7585085",
"0.7465604",
"0.741474",
"0.735282",
"0.72837627",
"0.724818",
"0.71922505",
"0.7114247",
"0.7072084",
"0.705126",
"0.69336444",
"0.69229895",
"0.68644994",
"0.68215275",
"0.68191624",
"0.6803573",
"0.67872685",
"0.6757109",
"0.66871524"... | 0.74436736 | 4 |
get random motivational quotation from sqlite database | def get_random_quotation(sqlite_file, sqlite_table):
connect = sqlite3.connect(sqlite_file)
cursor = connect.cursor()
cursor.execute("SELECT quotation, author FROM %s ORDER BY RANDOM() LIMIT 1" % sqlite_table)
row = cursor.fetchone()
cursor.close()
quotation_info = {
'text': row[0],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_quote():\n with open (\"./data/quotes.txt\", \"r\") as quotes:\n\n all_quotes = quotes.read().rstrip(\"\\n\").split(\"\\n\\n\")\n\n quote = choice(all_quotes)\n\n return quote",
"def get_random_inspirational_quote(self):\n return random.choice(self.inspirational_quot... | [
"0.6833337",
"0.66944295",
"0.64457434",
"0.6430225",
"0.6417233",
"0.6393828",
"0.636747",
"0.6185865",
"0.6067244",
"0.60219467",
"0.5991006",
"0.5987696",
"0.5964066",
"0.5857848",
"0.58065057",
"0.57925695",
"0.5771633",
"0.5762404",
"0.57619345",
"0.5720552",
"0.5647435"... | 0.79220015 | 0 |
Gated recurrent unit (GRU) with nunits cells. | def call(self, inputs, state):
gate_inputs = math_ops.matmul(
array_ops.concat([inputs, state], 1), self._gate_kernel)
gate_inputs = nn_ops.bias_add(gate_inputs, self._gate_bias)
value = math_ops.sigmoid(gate_inputs)
r, u = array_ops.split(value=value, num_or_size_splits=2, axis=1)
r_state... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_gru_cell(num_units, dropout):\n cell = tf.nn.rnn_cell.GRUCell(num_units)\n if dropout:\n result = tf.nn.rnn_cell.DropoutWrapper(cell,\n output_keep_prob=1-dropout)\n return result",
"def _initialize_gru_cell(self, num_units):\n return gru_cell.Laye... | [
"0.7217025",
"0.6654688",
"0.6297134",
"0.62698615",
"0.58967686",
"0.5840164",
"0.570657",
"0.56824994",
"0.5670167",
"0.56192416",
"0.56141967",
"0.560903",
"0.55835325",
"0.5581533",
"0.55483365",
"0.55423665",
"0.5536661",
"0.55100894",
"0.54998815",
"0.54421973",
"0.5382... | 0.0 | -1 |
Takes a FileStorage or string and returns the file name. Allows other helper functions to call this with either FileStorage or filename strings and will always return the file name. | def _retrieve_filename(file: Union[str, FileStorage]) -> str:
if isinstance(file, FileStorage):
return file.filename
return file | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_filename(\n cls, file_or_path: Union[BinaryIO, Path]\n ) -> Optional[str]:\n if cls._is_unnamed_or_directory(file_or_path):\n return None\n\n # TODO: test this\n # If a file object given, ensure its a filename, not a path\n if isinstance(file_or_path, Path)... | [
"0.6972356",
"0.65693176",
"0.6494945",
"0.64581746",
"0.6434845",
"0.64114755",
"0.6394964",
"0.63226295",
"0.63175285",
"0.62881225",
"0.6250836",
"0.6244421",
"0.6211824",
"0.62044847",
"0.61956215",
"0.6167831",
"0.6163881",
"0.615894",
"0.61529964",
"0.61411536",
"0.6137... | 0.8336512 | 0 |
Return full name of image in a path get_basename(some/folder/image.jpg) > image.jpg | def get_basename(file: Union[str, FileStorage]) -> str:
filename = _retrieve_filename(file)
# split will split at the final part of the path(image.jpg) and everything
# before it is at index 0
return os.path.split(filename)[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_filename(img_path):\n filename = os.path.splitext(img_path)\n return os.path.basename(filename[0])",
"def path_to_name(img):\n\n return os.path.dirname(img) + '_' + os.path.basename(img)",
"def get_basename(absolute_file_path):\r\n return absolute_file_path.split('/')[-1]",
"def basename(... | [
"0.80524117",
"0.757646",
"0.74535257",
"0.7421472",
"0.7395322",
"0.73813665",
"0.73792607",
"0.73611146",
"0.72903275",
"0.7262436",
"0.71666396",
"0.7116766",
"0.707401",
"0.7037713",
"0.70340395",
"0.70300144",
"0.6948239",
"0.6931499",
"0.69060385",
"0.6896113",
"0.68785... | 0.7971051 | 1 |
Checks if point is in collision with object | def is_in_collision_point(self, pos):
x, y = pos
return sqrt((self.x - x)**2 + (self.y - y)**2) < self.r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isPointCollide(self, point):\n return self.p[0] <= point <= self.p[2]",
"def isNearTo(self, point):\n # BBB: I'm using a majored version of the collide rect to fix a problem with a charas-bouncing-effect on movement... :-|\n x, y = self.currentLevel.transformToScreenCoordinate(point)\n ... | [
"0.7555956",
"0.7492395",
"0.7437317",
"0.7393058",
"0.7268073",
"0.71651256",
"0.71326554",
"0.70738",
"0.70709044",
"0.70513666",
"0.7024929",
"0.69892174",
"0.6984759",
"0.6984759",
"0.696955",
"0.69483286",
"0.693722",
"0.69221646",
"0.69192505",
"0.6912864",
"0.69124764"... | 0.82696104 | 0 |
Assumes 'list_' is sorted. Returns closest item index to 'value'. If two numbers are equally close, return the smallest index. | def get_closest_value_index_in_sorted_list(value, list_):
if value <= list_[0]:
return 0
if value >= list_[-1]:
return len(list_) - 1
pos = bisect.bisect_left(list_, value)
before = list_[pos - 1]
after = list_[pos]
if after - value < value - befor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closest_value_index(val, lst):\n index = 0\n for item in lst:\n if item > val:\n return index\n index += 1\n return index-1",
"def _get_index_closest_val(list, val):\n\n return min(range(len(list)), key=lambda i: abs(list[i]-val))",
"def getnearest(iterable, value):... | [
"0.85056037",
"0.8431343",
"0.7838559",
"0.7453381",
"0.72658235",
"0.7246142",
"0.7205541",
"0.7192864",
"0.7171713",
"0.7167309",
"0.7141918",
"0.7136888",
"0.71289957",
"0.7095902",
"0.7095902",
"0.70308524",
"0.70114267",
"0.6984104",
"0.69587326",
"0.6913206",
"0.6891542... | 0.8970342 | 0 |
Evaluates the desired mapmask combinations on a predicted subject. | def evaluate(self, maps_prediction: np.ndarray, maps_reference: np.ndarray, masks: dict, subject_id: str):
# for masking we use np.extract, which works only on 1-D arrays --> reshape
maps_prediction_flattened = np.reshape(maps_prediction, (-1, maps_prediction.shape[-1]))
maps_reference_flattene... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, maps_prediction: np.ndarray, roi_masks: dict, masks: dict, subject_id: str):\n\n # get possible labels of the current region\n if defs.REGION_THIGH in subject_id:\n labels = self.labels[defs.REGION_THIGH]\n elif defs.REGION_LEG in subject_id:\n labels =... | [
"0.72606725",
"0.61629915",
"0.6060688",
"0.6006843",
"0.5975923",
"0.5950671",
"0.5922005",
"0.58513385",
"0.5811893",
"0.5745711",
"0.5707898",
"0.56806594",
"0.567957",
"0.5653155",
"0.5611047",
"0.5604188",
"0.5601255",
"0.56009567",
"0.5583448",
"0.5571036",
"0.5542716",... | 0.7116468 | 1 |
Evaluates the desired mapmask combinations on a predicted subject. | def evaluate(self, maps_prediction: np.ndarray, roi_masks: dict, masks: dict, subject_id: str):
# get possible labels of the current region
if defs.REGION_THIGH in subject_id:
labels = self.labels[defs.REGION_THIGH]
elif defs.REGION_LEG in subject_id:
labels = self.label... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, maps_prediction: np.ndarray, maps_reference: np.ndarray, masks: dict, subject_id: str):\n\n # for masking we use np.extract, which works only on 1-D arrays --> reshape\n maps_prediction_flattened = np.reshape(maps_prediction, (-1, maps_prediction.shape[-1]))\n maps_reference... | [
"0.7116468",
"0.61629915",
"0.6060688",
"0.6006843",
"0.5975923",
"0.5950671",
"0.5922005",
"0.58513385",
"0.5811893",
"0.5745711",
"0.5707898",
"0.56806594",
"0.567957",
"0.5653155",
"0.5611047",
"0.5604188",
"0.5601255",
"0.56009567",
"0.5583448",
"0.5571036",
"0.5542716",
... | 0.72606725 | 0 |
Callaback function for when the user checks/unchecks a type item in the UI Updates the checkbox if necessary | def on_type_check(self, type_item):
# don't bother for non-checked events
if not type_item.has_checked_changed():
return
# leave checked while search is running
if self.is_searching():
type_item.setCheckState(Qt.Checked)
return
# keep to same i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DoCheck(self,event):\r\n index = event.GetSelection()\r\n item = self.items[index]\r\n if self.list.IsChecked(index):\r\n self.data.check(item)\r\n else:\r\n self.data.uncheck(item)\r\n #self.list.SetSelection(index)\r",
"def on_checkBox_duotouping_sta... | [
"0.6908596",
"0.64106315",
"0.6377018",
"0.6338921",
"0.6330147",
"0.62341684",
"0.62125576",
"0.62037027",
"0.61856914",
"0.61624014",
"0.6148764",
"0.6102489",
"0.60765696",
"0.60276335",
"0.60276335",
"0.60276335",
"0.6023052",
"0.599243",
"0.5984409",
"0.59594554",
"0.592... | 0.76766413 | 0 |
Gets the current state of the checkbox | def current_state(self):
return self.checkState() == Qt.Checked | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCheckBoxState( self, cCtrlName ):\n oControl = self.getControl( cCtrlName )\n return oControl.getState();",
"def checkbox(self):\r\n return self._checkbox",
"def get_checked(self):\n return self._checked",
"def get_value(self):\n return bool(self._chb_bool.isChecked(... | [
"0.7906425",
"0.7770742",
"0.76799875",
"0.74128896",
"0.6956726",
"0.69238573",
"0.6872148",
"0.6860064",
"0.6857549",
"0.6815851",
"0.68058956",
"0.68058956",
"0.67969",
"0.6755268",
"0.6717551",
"0.6717551",
"0.6717551",
"0.6710777",
"0.6710777",
"0.6710777",
"0.6709759",
... | 0.7784258 | 3 |
Gets the current checkbox state | def current_state(self):
return self.checkState() == Qt.Checked | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCheckBoxState( self, cCtrlName ):\n oControl = self.getControl( cCtrlName )\n return oControl.getState();",
"def checkbox(self):\r\n return self._checkbox",
"def get_checked(self):\n return self._checked",
"def get_value(self):\n return bool(self._chb_bool.isChecked(... | [
"0.80592144",
"0.77395254",
"0.7632776",
"0.714012",
"0.6857726",
"0.6844055",
"0.6811307",
"0.6804947",
"0.6749232",
"0.6749232",
"0.6730263",
"0.67047757",
"0.66626805",
"0.6643624",
"0.66350573",
"0.6605067",
"0.6605067",
"0.6605067",
"0.6577856",
"0.6577856",
"0.6577856",... | 0.7805551 | 2 |
Updates the is_checked property with the current state | def update_checked(self):
self._is_checked = self.checkState() == Qt.Checked | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_state(self):\n\n if self._explicit:\n state = Qt.Checked\n elif self._implicit:\n state = Qt.PartiallyChecked\n else:\n state = Qt.Unchecked\n\n self.setCheckState(state)",
"def set_checked(self, checked):\n self._checked = checked",... | [
"0.8069439",
"0.76891726",
"0.76768994",
"0.6929486",
"0.67402196",
"0.6705569",
"0.6670801",
"0.6629853",
"0.6629853",
"0.6629853",
"0.66213095",
"0.65725267",
"0.65725267",
"0.65725267",
"0.6519899",
"0.64423424",
"0.64380443",
"0.6377638",
"0.6310595",
"0.6301731",
"0.6289... | 0.8861618 | 1 |
Gets the current checkbox state | def current_state(self):
return self.checkState() == Qt.Checked | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCheckBoxState( self, cCtrlName ):\n oControl = self.getControl( cCtrlName )\n return oControl.getState();",
"def checkbox(self):\r\n return self._checkbox",
"def get_checked(self):\n return self._checked",
"def get_value(self):\n return bool(self._chb_bool.isChecked(... | [
"0.80592144",
"0.77395254",
"0.7632776",
"0.714012",
"0.6857726",
"0.6844055",
"0.6811307",
"0.6804947",
"0.6749232",
"0.6749232",
"0.6730263",
"0.67047757",
"0.66626805",
"0.6643624",
"0.66350573",
"0.6605067",
"0.6605067",
"0.6605067",
"0.6577856",
"0.6577856",
"0.6577856",... | 0.7805551 | 1 |
Updates the is_checked property with the current state | def update_checked(self):
self._is_checked = self.checkState() == Qt.Checked | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_state(self):\n\n if self._explicit:\n state = Qt.Checked\n elif self._implicit:\n state = Qt.PartiallyChecked\n else:\n state = Qt.Unchecked\n\n self.setCheckState(state)",
"def set_checked(self, checked):\n self._checked = checked",... | [
"0.8069439",
"0.76891726",
"0.76768994",
"0.6929486",
"0.67402196",
"0.6705569",
"0.6670801",
"0.6629853",
"0.6629853",
"0.6629853",
"0.66213095",
"0.65725267",
"0.65725267",
"0.65725267",
"0.6519899",
"0.64423424",
"0.64380443",
"0.6377638",
"0.6310595",
"0.6301731",
"0.6289... | 0.8861618 | 2 |
Sets the encryption password globally on the VPSA using the KMIP protocol. This encryption is used when enabling the encryption option for a volume. | def set_encryption_password_kmip(session, host, ca_cert_file, key_id, key_name, connect_via, port=5696,
cert_file_content=None, key_file_content=None, version='1.2',
user=None, password=None, current_encryption_pwd=None,
proxy_host=None, proxyport=0, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def passwd_encryption(self):\n key = Fernet.generate_key()\n cipher_suite = Fernet(key)\n bin_passwd = bytes(self.password, 'utf-8')\n ciphered_text = cipher_suite.encrypt(bin_passwd)\n with open(self.pass_path, 'wb') as pass_output:\n pass_output.write(ciphered_text)\... | [
"0.697702",
"0.68216634",
"0.6718895",
"0.6713073",
"0.652941",
"0.6512176",
"0.6419611",
"0.63241786",
"0.6298737",
"0.62744856",
"0.6273186",
"0.624397",
"0.62248766",
"0.62031364",
"0.61877877",
"0.6134824",
"0.6127729",
"0.612252",
"0.61053133",
"0.60563487",
"0.6051972",... | 0.6613558 | 4 |
Sets the encryption password globally on the VPSA. This password is used | def use_aws_kms_store(session, region, kmskeyid, access_id, secret,
encryption_pwd=None, old_encryption_pwd=None,
return_type=None, **kwargs):
body_values = {'region': region, 'kmskeyid': kmskeyid,
'access_id': access_id, 'secret': secret}
if encry... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_password(self, password):\n from kalon.auth import encrypt_password\n self.document.password = encrypt_password(password)",
"def _encryptDBPass():\n #run encrypt tool on user given password\n controller.CONF[\"ENCRYPTED_DB_PASS\"] = utils.encryptEngineDBPass(password=controller.CONF[\... | [
"0.7278221",
"0.72454524",
"0.7127046",
"0.7072377",
"0.70716023",
"0.6993648",
"0.6946236",
"0.6909053",
"0.68453807",
"0.68268585",
"0.6814286",
"0.67810374",
"0.67810374",
"0.67810374",
"0.67810374",
"0.67711484",
"0.6751656",
"0.6742394",
"0.67163503",
"0.6701117",
"0.669... | 0.0 | -1 |
Sets the encryption password globally on the VPSA. This password is used | def set_encryption_password(session, password, old_password=None,
return_type=None, **kwargs):
verify_not_none(password, "password")
body_values = {'encryption_pwd': password}
if old_password:
body_values['old_encryption_pwd'] = old_password
path = '/api/settings/en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_password(self, password):\n from kalon.auth import encrypt_password\n self.document.password = encrypt_password(password)",
"def _encryptDBPass():\n #run encrypt tool on user given password\n controller.CONF[\"ENCRYPTED_DB_PASS\"] = utils.encryptEngineDBPass(password=controller.CONF[\... | [
"0.7278221",
"0.72454524",
"0.7127046",
"0.7072377",
"0.70716023",
"0.6993648",
"0.6946236",
"0.6909053",
"0.68453807",
"0.6814286",
"0.67810374",
"0.67810374",
"0.67810374",
"0.67810374",
"0.67711484",
"0.6751656",
"0.6742394",
"0.67163503",
"0.6701117",
"0.6694503",
"0.6691... | 0.68268585 | 9 |
Like `izip` but yields `None` for missing items. | def longzip(a, b):
aiter = iter(a)
biter = iter(b)
try:
for item1 in aiter:
yield item1, next(biter)
except StopIteration:
for item1 in aiter:
yield item1, None
else:
for item2 in biter:
yield None, item2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_none(iterable: Iterable[Optional[_T]]) -> Iterable[_T]:\n return (x for x in iterable if x is not None)",
"def _assert_non_empty(iterable):\n first_elem = six.next(iterable, None)\n assert first_elem is not None, first_elem\n return itertools.chain([first_elem], iterable)",
"def _peek(iter:... | [
"0.55708754",
"0.54751974",
"0.54717046",
"0.5437567",
"0.5393389",
"0.5365301",
"0.5181093",
"0.5169455",
"0.5106901",
"0.50707704",
"0.505495",
"0.5002499",
"0.49963647",
"0.4958859",
"0.4939255",
"0.4922513",
"0.49008194",
"0.48883992",
"0.48761016",
"0.4870314",
"0.484743... | 0.47507876 | 24 |
Check if the box is between those lines, upper < lower (0,0, is leftupper corner) | def isInShelf(box, upperLine, lowerLine):
p = box['box_points']
box_height = p[3] - p[1]
box_height
cut_box_height = min(lowerLine, p[3]) - max(upperLine, p[1])
if box_height - cut_box_height > 1/4*box_height: ## how much I cut, too much cut -> not in this shelf
return False
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def box_valid(self):\n return ((self.lt.x >= 0)\n and (self.lt.y >= 0)\n and (self.rb.x >= self.lt.x)\n and (self.rb.y >= self.lt.y))",
"def within(point: tuple, box: tuple) -> bool:\r\n \r\n return box[0] < point[0] < box[2] and box[1] < point[1] < box[3... | [
"0.7176622",
"0.71188885",
"0.70608234",
"0.6954129",
"0.69337076",
"0.6922412",
"0.68934184",
"0.6892242",
"0.68778855",
"0.68745995",
"0.6821398",
"0.6764585",
"0.6756607",
"0.6721663",
"0.6698344",
"0.66670895",
"0.6643482",
"0.66420877",
"0.66158086",
"0.6565832",
"0.6564... | 0.6629573 | 18 |
Whether this spectrum has a report for metadata. | def has_report(self):
return self.report is not None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_metadata(self):\n if self.mimetype in Config.mimes_metadata:\n return True\n return False",
"def HasAnalysisReports(self):\n for name in self._GetStreamNames():\n if name.startswith('analysis_report_data.'):\n return True\n\n return False",
"def has_metas(self... | [
"0.8033374",
"0.70121706",
"0.69412804",
"0.6735023",
"0.65451646",
"0.65358233",
"0.6530026",
"0.64078444",
"0.635866",
"0.635866",
"0.63127375",
"0.62697756",
"0.6192341",
"0.61648583",
"0.6104409",
"0.6103236",
"0.5975198",
"0.5961022",
"0.5959195",
"0.5959088",
"0.5953198... | 0.7341982 | 1 |
First derivative of spherical harmonics with respect to theta. | def sph_harm_diff_theta(m, l, theta, phi):
check_degree_and_order(m, l)
return (m * _sph_harm(m, l, theta, phi) / np.tan(theta) +
np.sqrt( (l - m) * (l + m + 1) ) * np.exp( -1j*phi ) *
_sph_harm(m+1, l, theta, phi)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Psi(l,m,theta,phi):\n if numpy.isscalar(theta): \n theta=numpy.array([[theta]])\n phi=numpy.array([[phi]])\n Psilm_th=numpy.zeros(theta.shape,dtype=complex)\n Psilm_ph=numpy.zeros(theta.shape,dtype=complex)\n x=numpy.cos(theta)\n thetaNonZerosIdx=numpy.where(theta!=0.0)\n if len(thetaNonZerosIdx[0]... | [
"0.6723069",
"0.66028106",
"0.65008193",
"0.65008193",
"0.6483161",
"0.63856214",
"0.63841516",
"0.633962",
"0.633962",
"0.6324032",
"0.6308926",
"0.61864007",
"0.61864007",
"0.61392105",
"0.61076754",
"0.59627134",
"0.59126836",
"0.5850438",
"0.5844406",
"0.58318514",
"0.582... | 0.6333515 | 9 |
Runs through generating starting parameters and writes to a new .csv | def Param_gen_and_write(self):
SF_start_params = self.source_df.groupby(
"FinalID").apply(self.start_params)
SF_start_params.reset_index(level=0, inplace=True)
self.source_df = pd.merge(
self.source_df,
SF_start_params,
on="FinalID")
self.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_initial_csv():\n\tif os.path.exists(args.train):\n\t\tprint(\"--Training data input found: \", args.train)\n\t\t#quick and dirty create csv file\n\t\theaders = os.system(\"echo idorigh,idresph,origbytes,respbytes,origpkts,resppkts,duration > log.csv\")\n\t\tbrocut = os.system(\"cat \"+str(args.train)+\"... | [
"0.67874193",
"0.6599302",
"0.64288837",
"0.6316135",
"0.6268118",
"0.62620926",
"0.6216667",
"0.6196554",
"0.61947405",
"0.61873657",
"0.6186433",
"0.6182692",
"0.6157247",
"0.61296403",
"0.61256015",
"0.60949767",
"0.6067805",
"0.60490745",
"0.60175455",
"0.5987955",
"0.594... | 0.75607616 | 0 |
Initialize a model, tokenizer and config. | def __init__(
self,
args: argparse.Namespace
):
super().__init__()
format = '%(asctime)s - %(name)s - %(message)s'
if isinstance(args, argparse.Namespace):
self.save_hyperparameters(args)
self.args = args
logging.basicConfig(format=format, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, model, tokenizer):\n self.model = model\n self.tokenizer = tokenizer\n self.max_context_size = max_context\n self.predict_len = steps\n self.beam_size = beam_size\n self.beam_steps = beam_steps",
"def basic_model_init(model_args... | [
"0.7721862",
"0.75269216",
"0.71541077",
"0.7110465",
"0.7072716",
"0.7058341",
"0.70387423",
"0.69877243",
"0.6955412",
"0.6924358",
"0.68692195",
"0.6806762",
"0.6740265",
"0.67386603",
"0.67232543",
"0.6722358",
"0.6664681",
"0.66439635",
"0.6599982",
"0.65382737",
"0.6530... | 0.0 | -1 |
Use sparse categorical cross entropy as loss function. | def loss(labels, logits):
return sparse_categorical_crossentropy(labels, logits, from_logits=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss_function(self, probs, labels):\n return tf.keras.losses.sparse_categorical_crossentropy(labels, probs)",
"def sparse_cross_entropy(true, pred, axis=-1, epsilon=1e-7):\n true = ivy.one_hot(true, pred.shape[axis])\n return cross_entropy(true, pred, axis, epsilon)",
"def sparse_cross_entropy... | [
"0.7455099",
"0.7392348",
"0.720489",
"0.71162844",
"0.7081335",
"0.7067923",
"0.70173305",
"0.6987153",
"0.69319147",
"0.6791545",
"0.67459244",
"0.6739871",
"0.67333215",
"0.6671784",
"0.66447204",
"0.6614296",
"0.6614296",
"0.66070217",
"0.6596359",
"0.6546515",
"0.6546515... | 0.77340156 | 0 |
Find the largest element <= x and its index, or None if it doesn't exist. | def bisect_le(sorted_array: List[int], value: int):
if sorted_array[0] <= value:
index: int = bisect_right(sorted_array, value) - 1
return index, sorted_array[index]
return None, None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_max_index(A: List[int], x: int) -> int:\n max_index = -1\n start = 0\n end = len(A) - 1\n\n while start <= end:\n mid = start + (end - start) // 2\n\n if A[mid] == x:\n max_index = mid\n start = mid + 1\n elif x < A[mid]:\n end = mid - 1\n ... | [
"0.74406403",
"0.73229516",
"0.7112889",
"0.7047993",
"0.701128",
"0.6789947",
"0.6770878",
"0.6762415",
"0.6762415",
"0.6742658",
"0.6732595",
"0.6538072",
"0.652945",
"0.6493635",
"0.6456616",
"0.6393692",
"0.63888896",
"0.63864756",
"0.6323231",
"0.6271007",
"0.6258358",
... | 0.0 | -1 |
Mock load function through get_coin_market_chart_by_id. Mock returns a dict saved as .json | def test_coin_api_load(self):
self.assertEqual(self.coin.coin_symbol, "bitcoin")
self.assertIsInstance(self.coin, Coin) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_coin_api_load_df_for_ta(self, mock_load):\n\n with open(\"tests/data/btc_usd_test_data.json\", encoding=\"utf8\") as f:\n sample_return = json.load(f)\n\n mock_load.return_value = sample_return\n mock_return, vs = dd_pycoingecko_view.load_ta_data(\n self.coin, [\... | [
"0.63153726",
"0.55486876",
"0.54873693",
"0.546261",
"0.54414046",
"0.54371285",
"0.5415836",
"0.5403564",
"0.53540754",
"0.53132725",
"0.52940863",
"0.52865505",
"0.52794284",
"0.5256536",
"0.52534026",
"0.5238468",
"0.51939774",
"0.51650435",
"0.51603633",
"0.5145276",
"0.... | 0.5486687 | 3 |
Mock load function through get_coin_market_chart_by_id. Mock returns a dict saved as .json | def test_coin_api_load_df_for_ta(self, mock_load):
with open("tests/data/btc_usd_test_data.json", encoding="utf8") as f:
sample_return = json.load(f)
mock_load.return_value = sample_return
mock_return, vs = dd_pycoingecko_view.load_ta_data(
self.coin, ["--vs", "usd", "-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_historical_prices(self, mock_requests_get):\n from grand_exchanger.resources.graph import Graph\n\n result = resources.get_historical_prices(1)\n\n assert result == Graph(\n daily={\n datetime(2020, 7, 27, 0, 0): 100,\n datetime(2020, 7, 26... | [
"0.5547547",
"0.54876",
"0.54873735",
"0.54638904",
"0.5438209",
"0.5437497",
"0.54143524",
"0.53998196",
"0.5354111",
"0.531285",
"0.52945495",
"0.528529",
"0.52804875",
"0.52571297",
"0.5253167",
"0.52391243",
"0.51900905",
"0.5164156",
"0.51586217",
"0.5143233",
"0.5137573... | 0.6314383 | 0 |
Returns True if work in (value, work) tuple subInfo1 is LESS than than work in (value, work) tuple in subInfo2 | def cmpWork(subInfo1, subInfo2):
work1 = subInfo1[WORK]
work2 = subInfo2[WORK]
return work1 < work2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmpValue(subInfo1, subInfo2):\n val1 = subInfo1[VALUE]\n val2 = subInfo2[VALUE]\n return val1 > val2",
"def cmpValue(subInfo1, subInfo2):\n val1 = subInfo1[VALUE]\n val2 = subInfo2[VALUE]\n return val1 > val2",
"def cmpRatio(subInfo1, subInfo2):\n val1 = subInfo1[VALUE]\n val2 = s... | [
"0.6943174",
"0.6943174",
"0.65169805",
"0.65169805",
"0.59217775",
"0.59182584",
"0.58530134",
"0.5807177",
"0.57864374",
"0.5756254",
"0.57268536",
"0.5663306",
"0.5660879",
"0.5657832",
"0.5651383",
"0.5642464",
"0.56196254",
"0.5609372",
"0.5586101",
"0.556165",
"0.556078... | 0.78410697 | 0 |
Returns True if value/work in (value, work) tuple subInfo1 is GREATER than value/work in (value, work) tuple in subInfo2 | def cmpRatio(subInfo1, subInfo2):
val1 = subInfo1[VALUE]
val2 = subInfo2[VALUE]
work1 = subInfo1[WORK]
work2 = subInfo2[WORK]
return float(val1) / work1 > float(val2) / work2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmpWork(subInfo1, subInfo2):\n work1 = subInfo1[WORK]\n work2 = subInfo2[WORK]\n return work1 < work2",
"def cmpWork(subInfo1, subInfo2):\n work1 = subInfo1[WORK]\n work2 = subInfo2[WORK]\n return work1 < work2",
"def cmpValue(subInfo1, subInfo2):\n val1 = subInfo1[VALUE]\n val2 =... | [
"0.7637799",
"0.7637799",
"0.75713205",
"0.75713205",
"0.6257448",
"0.6045726",
"0.6001168",
"0.5963079",
"0.59313416",
"0.5890132",
"0.58559775",
"0.5830476",
"0.58277094",
"0.58276546",
"0.5824466",
"0.582157",
"0.58163685",
"0.5810858",
"0.5785559",
"0.57619303",
"0.576020... | 0.65051675 | 4 |
Test the client when there is no Vault configuration performed, but there is a empty vault_secrets section in the configuration file | def test_no_vault_secrets(mock_load, localhost_client, gen_input_config):
mock_load.return_value = gen_input_config(vault_secrets={})
localhost_client.load("in.json")
mock_load.assert_called_with("in.json") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_load_no_vault_with_secrets(mock_load, gen_input_config):\n mock_load.return_value = gen_input_config()\n\n input_config_edited = gen_input_config()\n del input_config_edited[\"vault_secrets\"]\n\n client = VaultAnyConfig()\n\n with pytest.warns(UserWarning):\n assert client.load(\"in... | [
"0.66967833",
"0.6286257",
"0.6281223",
"0.6222612",
"0.61467016",
"0.6137791",
"0.61343914",
"0.6109751",
"0.60867536",
"0.6019046",
"0.6011417",
"0.6002008",
"0.5995329",
"0.59579414",
"0.5950455",
"0.5905957",
"0.58807576",
"0.58787274",
"0.58074594",
"0.5807061",
"0.57933... | 0.7333393 | 0 |
Creates a list of convolutional blocks similar to VGG network. The last layer is used to downsample by the given strategy. Only by 2 is supported. | def create_vgg_down_block(filters, in_features, activation, kernel_size=3, strategy='stride', batch_norm=False):
layers = []
if isinstance(filters, int):
filters = [filters]
if not isinstance(filters, list):
raise ValueError("Filters has to be a list")
in_feat = in_features
for n i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_block(self, block_ix, downsample, ker_size, block_len):\n stride = int(downsample) + 1\n n_in_filters = self.filters[block_ix]\n n_filters = self.filters[block_ix+1]\n mult_fact = 1 if block_ix == 0 else 6\n\n block = [MBConv(n_in_filters, n_filters, ker_size, stride, mu... | [
"0.6579815",
"0.6422183",
"0.6204242",
"0.6010239",
"0.5991196",
"0.59536743",
"0.5934313",
"0.59201366",
"0.5913944",
"0.588918",
"0.5881274",
"0.5867184",
"0.5855983",
"0.5849031",
"0.5841944",
"0.58329105",
"0.58295125",
"0.5828082",
"0.5828082",
"0.58219576",
"0.5819283",... | 0.63877416 | 2 |
Creates a list of convolutional blocks similar to VGG network. The first layer in the block upsamples. | def create_vgg_up_block(filters, in_features, activation, kernel_size=3, batch_norm=False):
layers = []
if isinstance(filters, int):
filters = [filters]
if not isinstance(filters, list):
raise ValueError("Filters has to be a list")
in_feat = in_features
layers.append(Conv2d_Up(in_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_block(self, block_ix, downsample, ker_size, block_len):\n stride = int(downsample) + 1\n n_in_filters = self.filters[block_ix]\n n_filters = self.filters[block_ix+1]\n mult_fact = 1 if block_ix == 0 else 6\n\n block = [MBConv(n_in_filters, n_filters, ker_size, stride, mu... | [
"0.7125747",
"0.6374126",
"0.6312226",
"0.6282175",
"0.6198989",
"0.6119378",
"0.60657424",
"0.60434395",
"0.6013098",
"0.6008731",
"0.6000163",
"0.5988429",
"0.5987975",
"0.59825575",
"0.5969249",
"0.5952087",
"0.5948968",
"0.5941893",
"0.5931205",
"0.59017116",
"0.5895259",... | 0.6589851 | 1 |
Return the path to the app configuration file. | def _app_config_file() -> str:
if 'AISCALATOR_HOME' in os.environ:
home = os.environ['AISCALATOR_HOME']
file = os.path.join(home, "config", "aiscalator.conf")
if os.path.exists(file):
return file
return os.path.join(os.path.expanduser("~"), '.aiscalator',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configPath(self):\n return os.path.dirname(__file__)",
"def get_config_path():\n\n root = os.path.dirname(os.path.abspath(__file__))[:-5]\n config_path = os.path.join(root, 'config.ini')\n\n return config_path",
"def path(self):\n return os.path.join(self.config.get('path', os.getcwd... | [
"0.8260517",
"0.80767614",
"0.80577785",
"0.799528",
"0.79654837",
"0.7899265",
"0.78866684",
"0.77370465",
"0.7732678",
"0.7729263",
"0.77015555",
"0.767465",
"0.76332635",
"0.76020646",
"0.7462885",
"0.7433802",
"0.7422051",
"0.7414486",
"0.73960364",
"0.73727596",
"0.73452... | 0.8098231 | 1 |
Return the path to the app configuration folder. | def app_config_home(self) -> str:
if self.app_config_has("app_config_home_directory"):
return self.app_config()["app_config_home_directory"]
return os.path.join(os.path.expanduser("~"), '.aiscalator') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configPath(self):\n return os.path.dirname(__file__)",
"def config_dir(self) -> Path:\n return self._config_dir",
"def path(self):\n return os.path.join(self.config.get('path', os.getcwd()))",
"def config_directory(self):\n\n return self.get_raw(\"config_directory\")",
"def ... | [
"0.8435535",
"0.8150194",
"0.8106352",
"0.808336",
"0.80401015",
"0.7924039",
"0.78733736",
"0.7863576",
"0.7803082",
"0.77969885",
"0.7689492",
"0.76589066",
"0.763021",
"0.761566",
"0.75550413",
"0.75032574",
"0.7497391",
"0.74973243",
"0.74802446",
"0.7416295",
"0.73787946... | 0.7772802 | 10 |
Depending on how the timezone is configured, returns the timestamp for this instant. | def _timestamp_now(self) -> str:
date_now = datetime.utcnow().replace(tzinfo=timezone("UTC"))
if self._app_conf["aiscalator"]:
pst = timezone(self.app_config().timezone)
else:
pst = timezone('Europe/Paris')
return date_now.astimezone(pst).strftime("%Y%m%d%H%M%S") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_datetime_timestamp():\n KST = datetime.timezone(datetime.timedelta(hours=9))\n return datetime.datetime.now(tz=KST).strftime(\"%Y%m%d%H%M%S\")[2:]",
"def timestamp(self) -> dt.datetime:\n ts = self.json_data['timestamp']\n # Extract the datetime object from the `ts` string\n ts... | [
"0.7671235",
"0.7609368",
"0.72287756",
"0.70299375",
"0.6993708",
"0.68767005",
"0.6874762",
"0.6874762",
"0.6860605",
"0.6776589",
"0.6738684",
"0.67311805",
"0.67091924",
"0.66995466",
"0.66862124",
"0.6635904",
"0.6621197",
"0.65977114",
"0.6561746",
"0.6560399",
"0.65458... | 0.6976468 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.