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 |
|---|---|---|---|---|---|---|
Format the integer or float n to 3 significant digits + SI prefix. | def formatSI(n: float) -> str:
s = ''
if n < 0:
n = -n
s += '-'
if type(n) is int and n < 1000:
s = str(n) + ' '
elif n < 1e-22:
s = '0.00 '
else:
assert n < 9.99e26
log = int(math.floor(math.log10(n)))
i, j = divmod(log, 3)
for _try in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def latex_format(n,u, precision = 1):\n if u<0:\n raise ValueError(\"uncertainty cannot be negative\")\n x = ufloat(n,u)\n s = (\"{:.\"+str(precision)+\"uS}\").format(x)\n # s = (\"{:.\"+str(precision)+\"L}\").format(x)\n # This removes a decimal point in uncertainty\n... | [
"0.6529589",
"0.6387098",
"0.6276692",
"0.6250865",
"0.62094367",
"0.61977804",
"0.6188658",
"0.6156867",
"0.61521316",
"0.6117687",
"0.5953543",
"0.5893946",
"0.58391106",
"0.5821518",
"0.58209115",
"0.57774335",
"0.5764024",
"0.57295644",
"0.5717522",
"0.57083654",
"0.56867... | 0.7876433 | 0 |
Iterator that waits periodically until certain time points are reached while yielding those time points. | def timeRange(start: Time_t, end: Time_t, step: float) \
-> Iterator[dt.datetime]:
assert step > 0
delta = dt.timedelta(seconds=step)
t = _fillDate(start)
tz = dt.timezone.utc if t.tzinfo else None
now = dt.datetime.now(tz)
while t < now:
t += delta
while t <= _fillDate(end):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n while True:\n results = self.poll()\n for x in results:\n yield x\n if not results:\n time.sleep(self.poll_delay)",
"def __iter__(self):\n if len(self) == 0:\n return\n current = self.first_timest... | [
"0.70366013",
"0.6857739",
"0.6853601",
"0.6686377",
"0.6295998",
"0.62546414",
"0.62527335",
"0.62436473",
"0.6134309",
"0.6000369",
"0.59103787",
"0.58841205",
"0.5822339",
"0.5808399",
"0.57665455",
"0.57383204",
"0.5712836",
"0.5680578",
"0.5657702",
"0.5649888",
"0.56334... | 0.5685418 | 17 |
Returns an interval from the cache. If you request a region that is larger than what has been previously stored before, the method will normally return None to signify that you need to compute for the larger region. This behavior can be overriden by supplying force_subinterval=True, which causes this method to return a... | def retrieve(self,key,start,end,force_subinterval=False):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interval(self):\n if self.keep_interval:\n return self._interval\n else:\n # Updating the interval and then returning the new value\n self._update_interval()\n # Setting the flag to keep the new interval until it is exceeded the next time\n s... | [
"0.61862695",
"0.5913008",
"0.58144355",
"0.5736964",
"0.572915",
"0.572915",
"0.56576884",
"0.56202894",
"0.5595529",
"0.55750674",
"0.5564712",
"0.55135614",
"0.54518163",
"0.5438921",
"0.5438697",
"0.5393431",
"0.52717894",
"0.51505005",
"0.5114337",
"0.50717777",
"0.50587... | 0.5397497 | 15 |
Convenience method to enable 3D texturing state so the texture may be used by the ffpnoise shader function | def enable(self):
glEnable(GL_TEXTURE_3D)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri(GL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_texture_mode():\n for area in bpy.context.screen.areas:\n if area.type == \"VIEW_3D\":\n for space in area.spaces:\n if space.type == \"VIEW_3D\":\n space.viewport_shade = \"TEXTURED\"\n return",
"def enable_any_tex_mode(context):\n props = ... | [
"0.6677809",
"0.6549969",
"0.6369659",
"0.60743153",
"0.60502696",
"0.5923465",
"0.5839737",
"0.5796139",
"0.57651645",
"0.57099813",
"0.5701912",
"0.5625515",
"0.54661834",
"0.53850794",
"0.5383814",
"0.5382028",
"0.5381315",
"0.5330395",
"0.5309261",
"0.5309261",
"0.5303246... | 0.7033388 | 0 |
Stellar mass and its error from the empirical relation by Schweitzer et al. 2019 (2019A&A...625A..68S), based on masses and radii of eclipsing binaries. | def Mass_sch19(Radius, eRadius):
a = -0.024048024
b = 1.0552427
a_err = 0.007592668
b_err = 0.017044148
M = a + b * Radius
eM = np.sqrt((a_err)**2 + (Radius * b_err)**2 + (b * eRadius)**2)
return(M, eM) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_effective_mass():\n\n H_BAR = 6.582119514e-16 # eV*s\n M_0 = 9.10938356e-31 # kg\n N_KPTS = 6 # Number of k-points included in the parabola.\n\n spin_up = Spin(1)\n\n band_structure = Vasprun('vasprun.xml').get_band_structure()\n\n # Locations of CBM and VBM in band_structure.bands\n ... | [
"0.6621091",
"0.6590921",
"0.62865424",
"0.6074964",
"0.6052183",
"0.6031175",
"0.6031175",
"0.60079646",
"0.59804773",
"0.59599847",
"0.5940864",
"0.5908501",
"0.5873281",
"0.5854262",
"0.5840292",
"0.5816133",
"0.580081",
"0.5789584",
"0.5772424",
"0.5763479",
"0.576089",
... | 0.6668691 | 0 |
Add a scheme document to the document cache. Schema element which are added to the schema without a file on have their target namespace accounted for. | def add_doc(self, et):
if et.target_namespace not in self.docs:
self.docs[et.target_namespace] = set()
if et.target_namespace not in self.types:
self.types[et.target_namespace] = {}
if et.target_namespace not in self.elements:
self.elements[et.target_namespace... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_document(self, document: Document) -> None:\n self._index[document.url] = document",
"def add_schema(self, schema, db):\n self._dbs[schema.typename] = db\n return None",
"def addSchemaFile(self, newSchemaFile):\n\t\tself.schemaFile.append(newSchemaFile)",
"def store(self, doc):\n... | [
"0.5833771",
"0.5703108",
"0.5666816",
"0.53958666",
"0.5294575",
"0.5218828",
"0.51365197",
"0.5132061",
"0.5114596",
"0.5075275",
"0.5049462",
"0.50488544",
"0.5034838",
"0.5025878",
"0.5008115",
"0.50059134",
"0.49971506",
"0.49827003",
"0.49542782",
"0.49476612",
"0.49131... | 0.5594734 | 3 |
Get a sample action for the environment. | def SampleAction(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_action(self, state):\n return self.env.action_space.sample()",
"def choose_random_action(env):\n return env.action_space.sample()",
"def sample(self):\n return self._action_out(self._env.action_space.sample())",
"def random_action(self, observation):\n return self.env.action_space... | [
"0.76185215",
"0.7404975",
"0.7299461",
"0.7100204",
"0.7080212",
"0.6916834",
"0.67209744",
"0.6720714",
"0.66695344",
"0.6587704",
"0.6509922",
"0.63664025",
"0.6364884",
"0.6349804",
"0.6345511",
"0.6314598",
"0.6290537",
"0.62873936",
"0.62548965",
"0.6246563",
"0.6223951... | 0.0 | -1 |
Converts string formatted as 'YYYYmmdd' to datetime.date object. | def date_json_to_py(iso_date):
return date.fromisoformat(iso_date) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_to_date(string):\n params = string.strip().split('-')\n year = int(params[0])\n month = int(params[1])\n day = int(params[2])\n d = date(year, month, day)\n return d",
"def convert_str2date(date):\n import datetime\n date = str(date)\n year = int(date... | [
"0.7793274",
"0.75733477",
"0.7341959",
"0.72478265",
"0.7221537",
"0.72005725",
"0.70459044",
"0.7018539",
"0.70141387",
"0.7005967",
"0.7004115",
"0.6984018",
"0.69427",
"0.6921662",
"0.6917369",
"0.69118243",
"0.6894727",
"0.6870697",
"0.685416",
"0.6826443",
"0.6769292",
... | 0.0 | -1 |
Returns the Path object corresponding to the project root directory. | def get_project_dir():
return Path(settings.PROJECT_DIR) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_root() -> Path:\n return PROJECT_ROOT",
"def get_project_root() -> Path:\n return Path(__file__).parent.parent",
"def get_project_root() -> Path:\n return Path(__file__).parent.parent",
"def get_project_root() -> Path:\n return Path(__file__).parent.parent",
"def get_project_root() ... | [
"0.85226953",
"0.7955894",
"0.7955894",
"0.7955894",
"0.7955894",
"0.79055315",
"0.78976744",
"0.7883186",
"0.7732845",
"0.7560384",
"0.7528911",
"0.7432359",
"0.7427349",
"0.7427349",
"0.7394236",
"0.7378838",
"0.73414433",
"0.7335685",
"0.7301656",
"0.72662354",
"0.72585154... | 0.72627217 | 20 |
Returns the Path object corresponding to the data directory (by convention located right under the project root directory). | def get_data_dir():
data_dir = Path(get_project_dir() / 'data')
data_dir.mkdir(parents=True, exist_ok=True)
return data_dir | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDataPath():\n\treturn \"..\" + os.sep + \"data\" + os.sep",
"def get_data_path():\n\treturn _paths[_DATA_DIRECTORY_KEY]",
"def get_data_path():\n\n # Get pathname absolute or relative.\n path = os.path.join(\n os.path.dirname(__file__), __malstor_data_directory__)\n\n abs_data_path = os.... | [
"0.8220762",
"0.81921494",
"0.81650573",
"0.80827177",
"0.8011862",
"0.77588266",
"0.7678774",
"0.76734823",
"0.76482904",
"0.7619793",
"0.7598886",
"0.758206",
"0.7473098",
"0.7468629",
"0.7436914",
"0.74270844",
"0.73810446",
"0.7364241",
"0.7353846",
"0.7353846",
"0.735000... | 0.7887209 | 5 |
Implement a dropout layer. | def dropout(x, key, keep_rate):
# The shenanigans with np.where are to avoid having to re-jit if
# keep rate changes.
keys = random.split(key, 2)
do_keep = random.bernoulli(keys[0], keep_rate, x.shape)
kept_rates = np.where(do_keep, x / keep_rate, 0.0)
return np.where(keep_rate < 1.0, kept_rates, x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dropout_layer(self):\n return tf.keras.layers.Dropout(rate=self.dropout)",
"def _dropout(self,components,dropout=None):\r\n \r\n if dropout is not None:\r\n components.append(nn.Dropout(dropout))",
"def add_drop_out_layer(self, input_layer):\n return tf.nn.drop... | [
"0.8178678",
"0.7669445",
"0.74932045",
"0.7487789",
"0.72926784",
"0.7138666",
"0.70125777",
"0.6966694",
"0.69610095",
"0.69550097",
"0.68795216",
"0.6819968",
"0.68178874",
"0.6765736",
"0.668942",
"0.6682834",
"0.6611335",
"0.6544647",
"0.6475342",
"0.64671147",
"0.646221... | 0.0 | -1 |
Instantiate random LFADS parameters. | def lfads_params(key, lfads_hps):
keys = random.split(key, 9)
data_dim = lfads_hps['data_dim']
ntimesteps = lfads_hps['ntimesteps']
enc_dim = lfads_hps['enc_dim']
con_dim = lfads_hps['con_dim']
ii_dim = lfads_hps['ii_dim']
gen_dim = lfads_hps['gen_dim']
factors_dim = lfads_hps['factors_dim']
batch_si... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random():\n # Define lattice spacing as a multiple of the particle radius\n # using the formula a = 4 r/sqrt(3). Systems which are ordered\n # are probably mostly filled, so use a distribution which goes from\n # zero to one, but leaving 90% of them within 80% of the\n # maximum bcc packing. L... | [
"0.64740753",
"0.6240033",
"0.6196234",
"0.6183743",
"0.6085013",
"0.602552",
"0.598905",
"0.5984561",
"0.5884209",
"0.5836884",
"0.58205914",
"0.5800904",
"0.5794623",
"0.5788215",
"0.57541484",
"0.57278126",
"0.5709481",
"0.5696416",
"0.56947577",
"0.56926215",
"0.5672331",... | 0.53945327 | 60 |
Return the full zmq adress of this TargetPod | def full_address(self) -> str:
return f'{self.host}:{self.port}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def host(self) -> str:\n return self.first_pod_args.host",
"def address(self):\n \n return self.__ip",
"def address(self) -> str:\n return self._backend.address",
"def full_out_address(self) -> str:\n return f'{self.host}:{self.port_out}'",
"def address(self):\n return... | [
"0.6192749",
"0.6182428",
"0.6154282",
"0.61490655",
"0.59441143",
"0.5927812",
"0.5911011",
"0.5891114",
"0.5867627",
"0.57722616",
"0.5733227",
"0.5714705",
"0.5696146",
"0.5681227",
"0.56665075",
"0.56661963",
"0.56632304",
"0.5659315",
"0.56486464",
"0.56266415",
"0.56193... | 0.5819245 | 9 |
Return the `out_edges` field of this TargetPod | def out_edges(self) -> List[str]:
return list(self.proto.out_edges) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getOutEdges(self):\n edges = []\n for edict in mm.G[self].values():\n for k in edict.keys():\n edges.append(edict.get(k).get(\"edge\"))\n \n return edges",
"def _get_out_segments(self):\n return self.__out_segments",
"def get_connections_out(self) ->... | [
"0.7513375",
"0.64858174",
"0.64319706",
"0.6328241",
"0.6209141",
"0.61408705",
"0.6107665",
"0.6038455",
"0.6024965",
"0.6024965",
"0.6024965",
"0.6024965",
"0.6024965",
"0.6024965",
"0.59724236",
"0.5941938",
"0.59382355",
"0.593236",
"0.59132075",
"0.5885706",
"0.58560854... | 0.8083852 | 0 |
Adds an edge to the graph. | def add_edge(self, from_pod: str, to_pod: str, send_as_bind: bool = False) -> None:
self._get_target_pod(from_pod).add_edge(to_pod, send_as_bind)
self._get_target_pod(to_pod).expected_parts += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, edge):\n if(self.has_edge(edge) == 0):\n self.__graph_dict[edge[0]].append(edge[1])",
"def addEdge(self, edge: Edge):\n self.edges.append(edge)",
"def add_edge(self, edge):\n assert edge not in self.edges\n self.edges.append(edge)",
"def add_edge(self... | [
"0.841144",
"0.83919084",
"0.8347221",
"0.8330175",
"0.82800245",
"0.8196861",
"0.81965816",
"0.81554943",
"0.806904",
"0.7990693",
"0.79418606",
"0.79395586",
"0.79385245",
"0.7935002",
"0.7914147",
"0.7814346",
"0.77845144",
"0.7768525",
"0.7742754",
"0.7682856",
"0.7616938... | 0.0 | -1 |
Adds a Pod vertex to the graph. | def add_pod(
self, pod_name: str, head_host, head_port_in, tail_port_out, head_zmq_identity
) -> None:
if pod_name in self.pods:
raise ValueError(
f'Vertex with name {pod_name} already exists. Please check your configuration for unique Pod names.'
)
ta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, vertex):\n raise NotImplementedError",
"def add_vertex(self, vertex):\n self.vertices.append(vertex)\n self.vertex_edge[vertex] = []",
"def __add__(self, vertex):\n\n if isinstance(vertex, Vertex):\n vName = vertex.name\n self._vertices[vNa... | [
"0.7485833",
"0.73174775",
"0.7305458",
"0.7236868",
"0.7225561",
"0.7184499",
"0.7165623",
"0.7161254",
"0.6994475",
"0.6994475",
"0.69344044",
"0.6928072",
"0.6909965",
"0.6897245",
"0.6893523",
"0.688598",
"0.68799144",
"0.684037",
"0.6832085",
"0.6824606",
"0.68227196",
... | 0.6820241 | 21 |
Test the `create_family_from_archive` utility function. | def test_create_family_from_archive(clear_db, get_pseudo_archive, sssp_parameter_filepath):
from aiida_sssp.data import SsspParameters
from aiida_sssp.groups import SsspFamily
filepath_archive, exception, message = get_pseudo_archive
label = 'SSSP/0.0/LDA/extreme'
if exception is not None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_make_fna(self):\r\n fna_fp = os.path.join(self.sff_dir, 'test.fna')\r\n fna_gz_fp = os.path.join(self.gz_sff_dir, 'test_gz.fna')\r\n make_fna(self.sff_fp, fna_fp)\r\n make_fna(self.sff_gz_fp, fna_gz_fp)\r\n self.assertEqual(open(fna_fp).read(), fna_txt)\r\n self.a... | [
"0.59001476",
"0.58907086",
"0.54964745",
"0.54425323",
"0.5414196",
"0.5383591",
"0.5317491",
"0.52587354",
"0.5235035",
"0.5157961",
"0.5147798",
"0.51425356",
"0.5109094",
"0.5101278",
"0.5082643",
"0.5081116",
"0.50675404",
"0.50433546",
"0.50284106",
"0.5020544",
"0.5012... | 0.75291246 | 0 |
Sets the gender of this HumanProperties. | def gender(self, gender):
self._gender = gender | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gender(self, gender):\n if gender is None:\n raise ValueError(\"Invalid value for `gender`, must not be `None`\") # noqa: E501\n\n self._gender = gender",
"def gender(self, gender: str):\n allowed_values = [\"male\", \"female\", \"unknown\"] # noqa: E501\n if gender n... | [
"0.75239986",
"0.7425739",
"0.6993064",
"0.6490646",
"0.63583153",
"0.62948114",
"0.6004537",
"0.59596694",
"0.59596694",
"0.58688724",
"0.5770474",
"0.5770474",
"0.5716314",
"0.5682937",
"0.565219",
"0.55008",
"0.5496496",
"0.54080206",
"0.53884447",
"0.53606254",
"0.5316272... | 0.77409106 | 3 |
Sets the is_long_sleeve of this HumanProperties. | def is_long_sleeve(self, is_long_sleeve):
self._is_long_sleeve = is_long_sleeve | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setIsLong(self, value):\n return self._set(isLong=value)",
"def set_is_watering(valve: Valve, value: bool) -> None:\n valve.is_watering = value",
"def SetLongHelp(self, s):\r\n\r\n self.long_help = s",
"def setLong(self, name: unicode, value: long) -> None:\n ...",
"def set_long... | [
"0.6274345",
"0.5518907",
"0.54605395",
"0.52524024",
"0.5240169",
"0.5117591",
"0.49670202",
"0.48811704",
"0.48720768",
"0.485832",
"0.47985044",
"0.47866216",
"0.47752094",
"0.47620523",
"0.47442243",
"0.46899542",
"0.4667595",
"0.46543428",
"0.46432644",
"0.46174517",
"0.... | 0.8383738 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, HumanProperties):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.80891633",
"0.80891633",
"0.8055254",
"0.7983334",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
"0.7967544",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Init with Key & Secret. | def __init__(self, apiKey, apiSecret):
self.apiKey = apiKey
self.apiSecret = apiSecret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, access_key, secret_key, **kwargs):\r\n pass",
"def __init__(self, auth_key, auth_secret):\n\n self._auth_key = auth_key\n self._auth_secret = auth_secret",
"def __init__(self, apikey, secret):\n self.apikey = apikey\n self.secret = secret",
"def __init__(... | [
"0.7203251",
"0.7168211",
"0.7060145",
"0.6797724",
"0.6735708",
"0.6697619",
"0.66877854",
"0.6655526",
"0.6640612",
"0.6640612",
"0.6640612",
"0.66304076",
"0.6590751",
"0.65891945",
"0.6531262",
"0.6499382",
"0.64528936",
"0.6377827",
"0.63693947",
"0.6337156",
"0.630693",... | 0.6505151 | 15 |
Plot prediction against target. | def plot_pred(y, yhat, name, output_dir):
ax = pd.DataFrame(y, columns=["y%s" % LOOK_AHEAD]).plot(figsize=(15, 10))
pd.DataFrame(yhat, columns=["yhat%s" % LOOK_AHEAD]).plot(ax=ax)
plt.title("%s" % name)
plt.tight_layout()
plt.savefig(f"{output_dir / name}.png")
pd.DataFrame(y-yhat, columns=[f"y... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_predictions(self):\n\n plt.title(\"Targets vs. Predictions\")\n plt.plot(self.T, label=\"Targets\")\n plt.plot(self.Y, label=\"Predictions\")\n plt.xlabel(\"Sample number\")\n plt.legend()\n plt.show()",
"def plot_result(data, gt_y, pred_y):\n assert data... | [
"0.8443108",
"0.7034533",
"0.7034533",
"0.7009303",
"0.6999596",
"0.6971293",
"0.6953517",
"0.6945872",
"0.6929676",
"0.6912065",
"0.688605",
"0.68140537",
"0.6790176",
"0.67810327",
"0.6772181",
"0.66834694",
"0.66312796",
"0.66306835",
"0.6558689",
"0.6545303",
"0.6509803",... | 0.61086226 | 41 |
Filters resources by given resource age in minutes. | def _filter_resources_by_age(self, resources: [], resource_age_minutes: int):
all_resources = []
for resource in resources:
if resource_age_minutes:
start = self._to_utc_datetime(resource.updated_on)
end = datetime.utcnow().replace(tzinfo=pytz.UTC)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_by_age(files, comparator):\n today = date.today()\n results = []\n for f in files:\n m = DATE_REGEX.search(f)\n if not m:\n continue\n f_date = date(int(m.group(1)), int(m.group(2)), int(m.group(3)))\n\n if comparator(today - f_date):\n results.... | [
"0.56945246",
"0.56207496",
"0.53699774",
"0.5265094",
"0.52016294",
"0.5154099",
"0.5149396",
"0.51413107",
"0.513546",
"0.5112312",
"0.5016751",
"0.5009684",
"0.4980972",
"0.4951849",
"0.49517897",
"0.49176037",
"0.4917213",
"0.49077666",
"0.48246667",
"0.4819532",
"0.48178... | 0.82798904 | 0 |
Returns true in case if dependent template is listed in command line. | def _is_dependent_template_listed(self, cfn_template_names: [], dependent_template_names: []) -> bool:
for dependent_template in dependent_template_names:
if dependent_template not in cfn_template_names:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _has_template(self, target):\n\t\tif target.has_key('use'):\n\t\t\treturn True\n\t\telse:\n\t\t\treturn None",
"def is_template(self):\n\t\treturn bool(call_sdk_function('PrlVmCfg_IsTemplate', self.handle))",
"def is_template(self):\n\t\treturn bool(call_sdk_function('PrlFoundVmInfo_IsTemplate', self.handl... | [
"0.63289666",
"0.6144923",
"0.60574156",
"0.60284775",
"0.59596926",
"0.5956603",
"0.58326936",
"0.5691765",
"0.56398195",
"0.5595131",
"0.558176",
"0.5581468",
"0.5564117",
"0.55474675",
"0.5527098",
"0.5521296",
"0.5512544",
"0.5450551",
"0.5397598",
"0.5397598",
"0.5394962... | 0.71113324 | 0 |
Send a text to the telegram chat defined by chatID, using the bot defined by token. | def send_message(text, chatID=chatID, token=token, time=10):
url = f'https://api.telegram.org/bot{token}/sendMessage'
com = f'curl -s --max-time {time} '
com += f'-d "chat_id={chatID}&disable_web_page_preview=1&text={text}" {url}'
resp = os.popen(com).read().strip()
return json.loads(resp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_message(self, chat_id, text):\n self.updater.bot.sendMessage(chat_id=chat_id, text=text)\n log.info(\"Send msg @%s: %s..\", chat_id, text[:20])",
"def send_to_telegram(text):\n\n bot = telegram.Bot(token='')\n # chat_id = -1001371737931\n chat_id = ''\n bot.send_message(chat_id... | [
"0.7712212",
"0.76326084",
"0.7613906",
"0.749241",
"0.7476107",
"0.7354592",
"0.69569176",
"0.69276875",
"0.68829226",
"0.6862093",
"0.6830384",
"0.68245775",
"0.6725747",
"0.657819",
"0.64787465",
"0.64349604",
"0.64338166",
"0.64260566",
"0.6422062",
"0.6415245",
"0.632759... | 0.71962994 | 6 |
Send a text to the telegram chat defined by chatID, using the bot defined by token. | def send_picture(pic, text='', chatID=chatID, token=token,time=10):
url = f'https://api.telegram.org/bot{token}/sendPhoto'
com = f'curl -s -X POST {url}'
com += f' -F chat_id={chatID} -F photo=@{pic} -F caption="{text}"'
resp = os.popen(com).read().strip()
return json.loads(resp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_message(self, chat_id, text):\n self.updater.bot.sendMessage(chat_id=chat_id, text=text)\n log.info(\"Send msg @%s: %s..\", chat_id, text[:20])",
"def send_to_telegram(text):\n\n bot = telegram.Bot(token='')\n # chat_id = -1001371737931\n chat_id = ''\n bot.send_message(chat_id... | [
"0.7712212",
"0.76326084",
"0.7613906",
"0.749241",
"0.7476107",
"0.7354592",
"0.71962994",
"0.69569176",
"0.69276875",
"0.68829226",
"0.6862093",
"0.6830384",
"0.68245775",
"0.6725747",
"0.657819",
"0.64787465",
"0.64349604",
"0.64338166",
"0.64260566",
"0.6422062",
"0.64152... | 0.0 | -1 |
Send a text to the telegram chat defined by chatID, using the bot defined by token. | def send_file(fname, text='', chatID=chatID, token=token,time=10):
url = f'https://api.telegram.org/bot{token}/sendDocument'
com = f'curl -s -X POST {url}'
com += f' -F chat_id={chatID} -F document=@{fname} -F caption="{text}"'
resp = os.popen(com).read().strip()
return json.loads(resp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_message(self, chat_id, text):\n self.updater.bot.sendMessage(chat_id=chat_id, text=text)\n log.info(\"Send msg @%s: %s..\", chat_id, text[:20])",
"def send_to_telegram(text):\n\n bot = telegram.Bot(token='')\n # chat_id = -1001371737931\n chat_id = ''\n bot.send_message(chat_id... | [
"0.7711832",
"0.763301",
"0.76137704",
"0.74929494",
"0.7476594",
"0.73550326",
"0.71967673",
"0.69575894",
"0.692773",
"0.68828005",
"0.6861662",
"0.6830775",
"0.682482",
"0.67256427",
"0.65787005",
"0.64792186",
"0.64351135",
"0.64338857",
"0.6425949",
"0.6422014",
"0.64145... | 0.0 | -1 |
Send a text to the telegram chat defined by chatID, using the bot defined by token. | def send_video(vid, text='', chatID=chatID, token=token,time=10):
url = f'https://api.telegram.org/bot{token}/sendVideo'
com = f'curl -s -X POST {url}'
com += f' -F chat_id={chatID} -F video=@{vid} -F caption="{text}"'
resp = os.popen(com).read().strip()
return json.loads(resp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_message(self, chat_id, text):\n self.updater.bot.sendMessage(chat_id=chat_id, text=text)\n log.info(\"Send msg @%s: %s..\", chat_id, text[:20])",
"def send_to_telegram(text):\n\n bot = telegram.Bot(token='')\n # chat_id = -1001371737931\n chat_id = ''\n bot.send_message(chat_id... | [
"0.7711314",
"0.76334524",
"0.7614409",
"0.74934894",
"0.74773306",
"0.73552173",
"0.71970767",
"0.6958888",
"0.6929296",
"0.6882096",
"0.686202",
"0.6831577",
"0.6824231",
"0.6724769",
"0.6579513",
"0.6480164",
"0.6435269",
"0.64342",
"0.64244556",
"0.64219946",
"0.6413758",... | 0.5756889 | 63 |
Send a text to the telegram chat defined by chatID, using the bot defined by token. | def send_audio(audio, text='', chatID=chatID, token=token,time=10):
url = f'https://api.telegram.org/bot{token}/sendAudio'
com = f'curl -s -X POST {url}'
com += f' -F chat_id={chatID} -F audio=@{audio} -F caption="{text}"'
resp = os.popen(com).read().strip()
return json.loads(resp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_message(self, chat_id, text):\n self.updater.bot.sendMessage(chat_id=chat_id, text=text)\n log.info(\"Send msg @%s: %s..\", chat_id, text[:20])",
"def send_to_telegram(text):\n\n bot = telegram.Bot(token='')\n # chat_id = -1001371737931\n chat_id = ''\n bot.send_message(chat_id... | [
"0.7712212",
"0.76326084",
"0.7613906",
"0.749241",
"0.7476107",
"0.7354592",
"0.71962994",
"0.69569176",
"0.69276875",
"0.68829226",
"0.6862093",
"0.6830384",
"0.68245775",
"0.6725747",
"0.657819",
"0.64787465",
"0.64349604",
"0.64338166",
"0.64260566",
"0.6422062",
"0.64152... | 0.0 | -1 |
Validate password against the hash in SQL | def _validate_password(self, user, password):
valid, new_hash = self.pwd_context.verify_and_update(str(password), user['users_auth'])
if not valid:
logger.error('Invalid password for %(users_name)s', user)
raise YKAuthError("Invalid password for %(users_name)s" % user)
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_password(self, password):\n return check_password_hash(self.password_hash, password)",
"def valid_pw(password, h):\n salt = h.split(',')[0]\n return h == make_pw_hash(password, salt)",
"def valid_pw(name, password, h):\n salt = h.split(',')[0]\n return h == make_pw_hash(name, password... | [
"0.7673136",
"0.7588931",
"0.7512637",
"0.7510455",
"0.7457767",
"0.7440227",
"0.7418322",
"0.741745",
"0.7416979",
"0.73959875",
"0.73959875",
"0.7366982",
"0.73518187",
"0.732669",
"0.7292097",
"0.72817844",
"0.72692806",
"0.72612107",
"0.7259947",
"0.725657",
"0.72445816",... | 0.0 | -1 |
Evaluates the model on a new input. The registered forward hooks will save all the data that is necessary to compute the relevance per neuron per layer. | def evaluate(self, in_tensor):
# Reset module list. In case the structure changes dynamically,
# the module list is tracked for every forward pass.
self.inverter.reset_module_list()
self.prediction = self.model(in_tensor)
return self.prediction | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, inp):\n if self.mode=='pre':\n return self.pretrain_forward(inp)\n elif self.mode=='meta':\n data_shot, label_shot, data_query, val = inp\n return self.meta_forward(data_shot, label_shot, data_query, val)\n elif self.mode=='preval':\n ... | [
"0.6471578",
"0.6365001",
"0.6337203",
"0.6303294",
"0.61864054",
"0.6095717",
"0.6092909",
"0.60436773",
"0.6035971",
"0.5976409",
"0.5966742",
"0.59402627",
"0.59209967",
"0.5886627",
"0.5868091",
"0.58577186",
"0.5845039",
"0.5843236",
"0.58341706",
"0.5823958",
"0.5820561... | 0.59011 | 13 |
Render the main page. | def home():
if request.method == "GET":
return render_template("index.html", result=False)
# if there is post data, we have the form and need to encode the SQL
# to pass to the results route.
#
# this encoding dance is to protect against the possibility of getting a very
# long SQL stri... | {
"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 main():\n return render_template(\"main.html\")",
"def main():\n return render_template(\"main.html\")",
"def renderPage():\n return render_template(\"index.html\")... | [
"0.8244045",
"0.80660653",
"0.77612364",
"0.77612364",
"0.76640457",
"0.76616615",
"0.7500369",
"0.74810046",
"0.7464349",
"0.7427967",
"0.7378952",
"0.73345315",
"0.73345315",
"0.7309027",
"0.7309027",
"0.72957826",
"0.7287541",
"0.7259883",
"0.722883",
"0.721577",
"0.718252... | 0.0 | -1 |
Find the index (with respect to array) of the median of the first, last, and middle values. Used in quick_median(), quick_inplace_median(), and quick_inplace_repeat(). | def median_of_three(array, left, right):
mid = (left+right)//2
if array[left] > array[mid]:
if array[mid] > array[right]:
return mid
elif array[left] > array[right]:
return right
return left
elif array[left] > array[right]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def median(arr):\n indices = []\n\n list_size = len(arr)\n median = 0\n if list_size % 2 == 0:\n indices.append(int(list_size / 2) - 1) # -1 because index starts from 0\n indices.append(int(list_size / 2))\n median = (arr[indices[0]] + arr[indices[1]]) / 2\n else:\n indi... | [
"0.7988514",
"0.7803164",
"0.7736163",
"0.7719672",
"0.7542702",
"0.74649537",
"0.7442782",
"0.7337539",
"0.7332045",
"0.73006344",
"0.72986174",
"0.7170138",
"0.7115831",
"0.7114024",
"0.7113509",
"0.70860296",
"0.70819414",
"0.7063987",
"0.70117074",
"0.6986442",
"0.6985024... | 0.71094555 | 15 |
Take an array and put it in heap order. Operates inplace. Used in heap_sort(). Uses sift_down(). | def heapify(array, highest_index):
first = (highest_index-1)//2
for start in range(first, -1, -1):
Heap.sift_down(array, start, highest_index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heap_sort(array):\n highest_index = len(array)-1\n Heap.heapify(array, highest_index)\n for end in range(highest_index, 0, -1):\n array[end], array[0] = array[0], array[end]\n Heap.sift_down(array, 0, end-1)",
"def build_heap(arr):\n for i in range(len(arr)-1, -1... | [
"0.84089077",
"0.8053701",
"0.7922342",
"0.7725338",
"0.7705888",
"0.75993884",
"0.7520603",
"0.7480076",
"0.7462997",
"0.74388134",
"0.74160355",
"0.7370213",
"0.7345395",
"0.73398787",
"0.7333361",
"0.72831184",
"0.7270901",
"0.7197215",
"0.71026945",
"0.70997256",
"0.70955... | 0.79103863 | 3 |
Change position of item in list until it is correctly placed in heap. Used by heap_sort() (and heapify()). | def sift_down(array, start, end):
root = start
while root*2+1 <= end:
child = root*2+1
swap = root
if array[swap] < array[child]:
swap = child
if child+1 <= end and array[swap] < array[child+1]:
swap = child+1
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift_item_up(self, index):\n while index > 0:\n parent_index = index // 2\n if parent_index > 0 and self.heaplist[parent_index] < self.heaplist[index]:\n self.heaplist[parent_index], self.heaplist[index] = self.heaplist[index], self.heaplist[parent_index]\n ... | [
"0.74729395",
"0.67565596",
"0.67273504",
"0.67273504",
"0.657409",
"0.6520025",
"0.6519884",
"0.6510009",
"0.65052843",
"0.65020937",
"0.64885044",
"0.64481914",
"0.64133036",
"0.6340108",
"0.6339687",
"0.6328895",
"0.63008386",
"0.62924886",
"0.6235628",
"0.62298685",
"0.62... | 0.0 | -1 |
Returns loss and softmax output symbols given logits and integercoded labels. | def get_loss(self, logits: mx.sym.Symbol, labels: mx.sym.Symbol) -> List[mx.sym.Symbol]:
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_loss(logits, labels):\n predictions = tf.nn.softmax(logits)\n cost = tf.losses.softmax_cross_entropy(onehot_labels=labels,\n logits=logits,\n )\n return predictions, cost",
"def get_loss(self, logits: mx.sym.Sy... | [
"0.6545345",
"0.6399525",
"0.6255027",
"0.6205115",
"0.619023",
"0.6149457",
"0.6141253",
"0.59420794",
"0.5928294",
"0.5905454",
"0.5887399",
"0.5879356",
"0.58532184",
"0.5849394",
"0.5800557",
"0.5785446",
"0.5783505",
"0.5765924",
"0.5764461",
"0.5726306",
"0.57120687",
... | 0.6156791 | 5 |
Returns loss and softmax output symbols given logits and integercoded labels. | def get_loss(self, logits: mx.sym.Symbol, labels: mx.sym.Symbol) -> List[mx.sym.Symbol]:
if self.loss_config.normalization_type == C.LOSS_NORM_VALID:
normalization = "valid"
elif self.loss_config.normalization_type == C.LOSS_NORM_BATCH:
normalization = "null"
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_loss(logits, labels):\n predictions = tf.nn.softmax(logits)\n cost = tf.losses.softmax_cross_entropy(onehot_labels=labels,\n logits=logits,\n )\n return predictions, cost",
"def get_loss(self, logits: mx.sym.Sy... | [
"0.6545345",
"0.6399525",
"0.6255027",
"0.6205115",
"0.619023",
"0.6156791",
"0.6149457",
"0.59420794",
"0.5928294",
"0.5905454",
"0.5887399",
"0.5879356",
"0.58532184",
"0.5849394",
"0.5800557",
"0.5785446",
"0.5783505",
"0.5765924",
"0.5764461",
"0.5726306",
"0.57120687",
... | 0.6141253 | 7 |
Returns loss and softmax output symbols given logits and integercoded labels. | def get_loss(self, logits: mx.sym.Symbol, labels: mx.sym.Symbol) -> List[mx.sym.Symbol]:
probs = mx.sym.softmax(data=logits)
on_value = 1.0 - self._alpha
off_value = self._alpha / (self._vocab_size - 1.0)
cross_entropy = mx.sym.one_hot(indices=mx.sym.cast(data=labels, dtype='int32'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_loss(logits, labels):\n predictions = tf.nn.softmax(logits)\n cost = tf.losses.softmax_cross_entropy(onehot_labels=labels,\n logits=logits,\n )\n return predictions, cost",
"def loss(labels, logits):\n retur... | [
"0.6545345",
"0.6255027",
"0.6205115",
"0.619023",
"0.6156791",
"0.6149457",
"0.6141253",
"0.59420794",
"0.5928294",
"0.5905454",
"0.5887399",
"0.5879356",
"0.58532184",
"0.5849394",
"0.5800557",
"0.5785446",
"0.5783505",
"0.5765924",
"0.5764461",
"0.5726306",
"0.57120687",
... | 0.6399525 | 1 |
Given a list of text data, return a list of text that has no parentheses only alhpabet characters and spaces. Then, we stem the text using a porter 2 stemmer and append each cleaned text to a list that we return | def processText(text_data):
clean_texts = []
for text in text_data:
no_parens = removeParentheses(text)
only_alpha_spaces = removeNonAlphabet(no_parens)
one_space = removeExtraSpaces(only_alpha_spaces)
stemmed_text = stemWords(one_space)
clean_texts.append(stemmed_text.lower())
return clean_texts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stem_words(text):\n try:\n text = [stemmer.stem(word) for word in text]\n text = [word for word in text if len(word) > 1] # no single letter words\n except IndexError:\n pass\n\n return text",
"def stemming(lista, stemmer):\n lista_out = list()\n for text in lista:\n ... | [
"0.75092083",
"0.7438072",
"0.7425269",
"0.7374089",
"0.734849",
"0.7343562",
"0.73393446",
"0.73371583",
"0.7284016",
"0.7237463",
"0.71553564",
"0.7142604",
"0.7138744",
"0.7137906",
"0.7126351",
"0.70571214",
"0.7043008",
"0.7025774",
"0.70231926",
"0.70154375",
"0.6998541... | 0.8237104 | 0 |
Remove anything that's not an alphabet character or a space from text | def removeNonAlphabet(text):
alpha = re.compile('[a-zA-Z .]*')
only_alphabet_list = alpha.findall(text)
only_alphabet = ''.join(only_alphabet_list)
return only_alphabet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_letter_removal(text):\n return re.sub('[^a-zA-Z]', ' ', text)",
"def replace_any_non_letter_or_number_character(text):\n text = text.strip()\n text = re.sub('[^A-Za-z0-9 ]+', '', text)\n return text",
"def remove_non_alphabetic_text(text):\n return RegexFilters.replace_non_alphabetic... | [
"0.8954562",
"0.8641455",
"0.85712093",
"0.85675484",
"0.8557319",
"0.8336912",
"0.8287351",
"0.79518515",
"0.790018",
"0.78991276",
"0.787843",
"0.785203",
"0.7847697",
"0.7815753",
"0.7775478",
"0.7736409",
"0.77117395",
"0.7710151",
"0.7695048",
"0.7655187",
"0.76430225",
... | 0.7982726 | 7 |
Gets parent directory of this file (and subsequently, the project). | def get_proj_dir(path: Union[pathlib.PurePath, str] = __file__) -> str:
return str(pathlib.Path(path).parent.absolute()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getParentDirectory():\n path = os.path.dirname(os.path.realpath(__file__))\n path = '/'.join( path.split('/')[:-1] )\n return path",
"def get_parent_dir(path):\n return os.path.dirname(path)",
"def _get_parent_path(self):\n return os.path.join(os.getcwd(), \"src\", \"data\", \"genes\")",... | [
"0.82566184",
"0.8090856",
"0.80121166",
"0.80055994",
"0.7889913",
"0.785325",
"0.7827623",
"0.7691862",
"0.76535445",
"0.7653493",
"0.7567486",
"0.75357455",
"0.75080067",
"0.75076336",
"0.75076336",
"0.7498596",
"0.74759984",
"0.74759984",
"0.74759984",
"0.74759984",
"0.73... | 0.6923478 | 35 |
Creates a screen aligned quad using two triangles with normals and texture coordinates. | def quad_fs(attr_names=AttributeNames, normals=True, uvs=True, name=None) -> VAO:
return quad_2d(
size=(2.0, 2.0), normals=normals, uvs=uvs, attr_names=attr_names, name=name,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quad_2d(\r\n size=(1.0, 1.0),\r\n pos=(0.0, 0.0),\r\n normals=True,\r\n uvs=True,\r\n attr_names=AttributeNames,\r\n name=None,\r\n) -> VAO:\r\n width, height = size\r\n xpos, ypos = pos\r\n\r\n # fmt: off\r\n pos_data = numpy.array([\r\n xpos - width / 2.0, ypos + height /... | [
"0.6595708",
"0.6467021",
"0.62314165",
"0.5977625",
"0.5938748",
"0.57873476",
"0.5746167",
"0.5685066",
"0.56437856",
"0.5621656",
"0.56196475",
"0.5567472",
"0.5559844",
"0.55326164",
"0.5481492",
"0.5459319",
"0.54551905",
"0.54518175",
"0.54370296",
"0.542963",
"0.542445... | 0.57835853 | 6 |
Check if songzaUsername is a syntactically valid username. Valid usernames have between 3 and 16 alphanumeric characters. (This method does not check if username exists.) | def isValidSongzaUsername( self, songzaUsername ):
import re
# validation pattern that matches between 3 and 16 alphanumeric
# characters (ignoring leading and trailing spaces)
pattern = "^\s*\w{3,16}\s*$"
# test the username against the... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_username(username):\n import string\n\n if not (len(username) > 2 and len(username) < 65):\n return False\n if not username[0] in string.letters:\n return False\n m = re_valid_username.match(username)\n return m.start() == 0 and m.end() == len(username)",
"def is_valid_u... | [
"0.822737",
"0.8205075",
"0.8113907",
"0.8070537",
"0.7900303",
"0.7800327",
"0.77135634",
"0.77084684",
"0.76741415",
"0.76623285",
"0.7654128",
"0.7640411",
"0.7634227",
"0.7634112",
"0.7612969",
"0.76",
"0.75525016",
"0.7547874",
"0.746313",
"0.7452427",
"0.74165404",
"0... | 0.8999434 | 0 |
Calculate the great circle distance between two points on the earth (specified in decimal degrees) | def haversine(coordinate_1, coordinate_2):
lat1, lon1, lat2, lon2 = coordinate_1[0], coordinate_1[1], coordinate_2[0], coordinate_2[1]
# convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def great_circle(lat_1, long_1, lat_2, long_2):\n long_1 = m.radians(long_1)\n lat_1 = m.radians(lat_1)\n long_2 = m.radians(long_2)\n lat_2 = m.radians(lat_2)\n\n d = 2 * 6367.45 * m.asin(\n m.sqrt(haversine(lat_2 - lat_1)\n + m.cos(lat_1)*m.cos(lat_2) *\n haversine(long... | [
"0.81450045",
"0.7863265",
"0.76322985",
"0.76064754",
"0.75978696",
"0.75965863",
"0.75944835",
"0.75720793",
"0.75630087",
"0.7555095",
"0.7528691",
"0.7517629",
"0.7492963",
"0.7467739",
"0.7452678",
"0.7434477",
"0.73914117",
"0.7357736",
"0.73484355",
"0.73318124",
"0.73... | 0.0 | -1 |
Determine if a file is allowed to be renamed. | def is_file_allowed(filename):
allowed = False
file_ext = get_extension_from_filename(filename)
for ext in extension_allowed:
if file_ext == ext:
allowed = True
break
return allowed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_file(filename: str) -> bool:\n return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS",
"def allowed_file(filename: str) -> bool:\n if filename is None or filename.strip() is None:\n return False\n\n return '.' in filename and \\\n filename.rspli... | [
"0.68316686",
"0.6816872",
"0.68132085",
"0.67624897",
"0.67624897",
"0.67583025",
"0.67497116",
"0.67497116",
"0.6740839",
"0.6740839",
"0.6740839",
"0.6740839",
"0.6740839",
"0.6740839",
"0.6740839",
"0.6740839",
"0.6740839",
"0.6740839",
"0.67052335",
"0.6668858",
"0.66361... | 0.64839184 | 39 |
Remove pattern from filename." | def remove_url_patterns(filename, pattern):
name = get_name_from_filename(filename)
ext = get_extension_from_filename(filename)
repl = " "
new_name = re.sub(pattern, repl, name)
return new_name + ext | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanFilename(fname):\n return re.sub(\"_$\", \"\", re.sub(\"[ _\\n\\t/()*,&:;@.]+\", \"_\", fname))",
"def fix_filename(self):\n if not self.remove_path:\n return\n self.filename = re.sub(\".+\\/\", \".../\", self.filename)",
"def _clean_filename(name):\n return re.sub(\"[^\... | [
"0.7514802",
"0.74387807",
"0.7329037",
"0.71784914",
"0.699023",
"0.6970876",
"0.69604516",
"0.69569504",
"0.69103765",
"0.68613833",
"0.6758374",
"0.6750685",
"0.6724387",
"0.671578",
"0.66970533",
"0.66297066",
"0.6625077",
"0.6617101",
"0.6613936",
"0.6580057",
"0.6556644... | 0.8084264 | 0 |
A decorator marking the decorated function as typing and implementing classmethod attr for the given Numba type in nopython mode. Similar to ``overload_method``. Here is an example implementing a classmethod on the Array type to call | def overload_classmethod(typ, attr, **kwargs):
return _overload_method_common(types.TypeRef(typ), attr, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autojit_class_wrapper(py_class, compiler_impl, cache):\n from numba import numbawrapper\n\n if utils.is_numba_class(py_class):\n raise error.NumbaError(\"Subclassing not yet supported \"\n \"for autojit classes\")\n\n # runtime_args -> specialized extension type in... | [
"0.6790635",
"0.6344906",
"0.6325228",
"0.616811",
"0.603147",
"0.6016829",
"0.575311",
"0.57494795",
"0.55419666",
"0.5484532",
"0.5459981",
"0.5414739",
"0.5414739",
"0.535572",
"0.534066",
"0.5286945",
"0.52384365",
"0.5220414",
"0.5212142",
"0.520919",
"0.5181714",
"0.5... | 0.5493425 | 9 |
Creates a unique combination of provided facets. A cross product of an initial set of starting facets with a new set of facets. | def cross(start, facets):
new = [[facet] for facet in facets]
result = []
for x in start:
for n in new:
result.append(x + n)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_combinations(items):\n\n def inner(items, r):\n \"\"\"\n recursively yields partitioned remainders of original partition lists\n \"\"\"\n items = set(items)\n if not len(items):\n yield ()\n ... | [
"0.5223084",
"0.5158795",
"0.49904937",
"0.49005884",
"0.48808607",
"0.48382875",
"0.48325536",
"0.47913063",
"0.4774069",
"0.47096157",
"0.47039112",
"0.46495903",
"0.46405163",
"0.46353674",
"0.46331802",
"0.46265408",
"0.45947975",
"0.45747232",
"0.45727205",
"0.45607942",
... | 0.7082943 | 0 |
Use this data source to get the ARN of a State Machine in AWS Step Function (SFN). By using this data source, you can reference a state machine without having to hard code the ARNs as input. | def get_state_machine(name=None,opts=None):
__args__ = dict()
__args__['name'] = name
if opts is None:
opts = pulumi.InvokeOptions()
if opts.version is None:
opts.version = utilities.get_version()
__ret__ = pulumi.runtime.invoke('aws:sfn/getStateMachine:getStateMachine', __args__, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_source_arn(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"event_source_arn\")",
"def event_source_arn(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"event_source_arn\")",
"def arn(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"arn\"... | [
"0.5352309",
"0.53268343",
"0.52876115",
"0.51382464",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",
"0.49550775",... | 0.47064173 | 57 |
Construct a new instance, validating that the label matches the required format. | def __init__(self, label=None, **kwargs):
if label not in self.get_valid_labels():
raise ValueError(f'the label `{label}` is not a valid SSSP configuration label.')
super().__init__(label=label, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, label: str):\n pass",
"def __init__(self, data_label: str, data_value: any,\r\n timestamp: int=0,\r\n labeling_version: int=0):\r\n\r\n if self.validateLabel(data_label, labeling_version=labeling_version):\r\n self.__label = data_label\r... | [
"0.64871734",
"0.61981344",
"0.601716",
"0.6009823",
"0.5987827",
"0.5909101",
"0.5892108",
"0.5861215",
"0.584804",
"0.5804862",
"0.5802334",
"0.5747449",
"0.574242",
"0.5718712",
"0.5717158",
"0.5710103",
"0.56848204",
"0.56792074",
"0.56678915",
"0.5667256",
"0.56548935",
... | 0.60499835 | 2 |
Helper for running MultiAP WPS tests dev[0] does multi_ap WPS, dev[1] does normal WPS. apdev[0] is the fronthaul BSS. If there is a separate backhaul BSS, it must have been set up by the caller. params are the normal SSID parameters, they will be extended with the WPS parameters. multi_ap_bssid must be given if it is n... | def run_multi_ap_wps(dev, apdev, params, params_backhaul=None, add_apdev=False,
run_csa=False, allow_csa_fail=False):
wpas_apdev = None
if params_backhaul:
hapd_backhaul = hostapd.add_ap(apdev[1], params_backhaul)
multi_ap_bssid = hapd_backhaul.own_addr()
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_multi_ap_wps_shared(dev, apdev):\n ssid = \"multi-ap-wps\"\n passphrase = \"12345678\"\n params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)\n params.update({\"multi_ap\": \"3\",\n \"multi_ap_backhaul_ssid\": '\"%s\"' % ssid,\n \"multi_ap_backhaul... | [
"0.73993677",
"0.72910196",
"0.7108865",
"0.70682853",
"0.70623255",
"0.70233256",
"0.69408715",
"0.62323457",
"0.60942864",
"0.6040791",
"0.60329103",
"0.5906286",
"0.5796224",
"0.55930877",
"0.5471905",
"0.5400495",
"0.5365376",
"0.5358049",
"0.53563696",
"0.53440726",
"0.5... | 0.7917617 | 0 |
make sure it hasn't expired or been used | def valid(self):
return (self.expiry is None or self.expiry > timezone.now()) and (
self.use_limit is None or self.times_used < self.use_limit
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isExpired(self):\n return True/False",
"def has_expired(self) -> bool:\n raise NotImplementedError() # pragma: nocover",
"def has_expired(self):\n self.ensure_one()\n return datetime.now() > fields.Datetime.from_string(self.expires)",
"def is_expired(self):\n\n if self... | [
"0.7446819",
"0.73482054",
"0.7172215",
"0.7129515",
"0.7116598",
"0.71071863",
"0.70767975",
"0.7071265",
"0.70700157",
"0.70610774",
"0.70559376",
"0.7053329",
"0.7049923",
"0.69831675",
"0.6932716",
"0.6917434",
"0.6912507",
"0.6879721",
"0.68631226",
"0.6858308",
"0.68303... | 0.65545714 | 41 |
don't create a request for a registered email | def save(self, *args, **kwargs):
if not self.id and User.objects.filter(email=self.email).exists():
raise IntegrityError()
super().save(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_email(self):\n user = self.make_user()\n data: dict = {}\n\n with self.login(user):\n response = self.post(\"referrals:create\", data=data)\n\n message = list(get_messages(response.wsgi_request))[0]\n assert str(message) == \"'missing email' is an invalid e... | [
"0.7271563",
"0.70657194",
"0.67145085",
"0.664434",
"0.6637145",
"0.66345966",
"0.6593339",
"0.6582378",
"0.65095794",
"0.64875335",
"0.6472271",
"0.64596486",
"0.6433578",
"0.6432903",
"0.6429512",
"0.64203155",
"0.6416101",
"0.63988143",
"0.63831127",
"0.6374527",
"0.63729... | 0.0 | -1 |
make sure it hasn't expired or been used | def valid(self):
return self.expiry > timezone.now() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isExpired(self):\n return True/False",
"def has_expired(self) -> bool:\n raise NotImplementedError() # pragma: nocover",
"def has_expired(self):\n self.ensure_one()\n return datetime.now() > fields.Datetime.from_string(self.expires)",
"def is_expired(self):\n\n if self... | [
"0.7446819",
"0.73482054",
"0.7172215",
"0.7129515",
"0.7116598",
"0.71071863",
"0.70767975",
"0.70700157",
"0.70610774",
"0.70559376",
"0.7053329",
"0.7049923",
"0.69831675",
"0.6932716",
"0.6917434",
"0.6912507",
"0.6879721",
"0.68631226",
"0.6858308",
"0.683039",
"0.682616... | 0.7071265 | 7 |
Saves a model's state and it's embedding dic by piggybacking torch's save function | def save(net, txt_dict, path):
dict_m = net.state_dict()
_ = txt_dict
torch.save(dict_m,path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, filename):\n model_dict = {'model_state_dict': self.state_dict(),\n 'init_args': {\"vocab_size\": self.vocab_size,\n \"embeddings_size\": self.embeddings_size,\n \"hidden_size\": self.hidden_size,\n ... | [
"0.7830054",
"0.7672989",
"0.7634294",
"0.7529348",
"0.7494107",
"0.74758816",
"0.7415177",
"0.74094504",
"0.73635685",
"0.7322403",
"0.7322403",
"0.729868",
"0.723931",
"0.7221203",
"0.7219663",
"0.719143",
"0.7160213",
"0.7125645",
"0.71007663",
"0.70595336",
"0.7042465",
... | 0.7046696 | 20 |
Convert from a BED row to an immutable BaseInterval object. | def bed_to_interval(contig, bed_start, bed_end, name='', score='', strand='',
block_ids='', superblock_ids=''):
try:
# assure positions to be integers
# convert from 0,1-based to 1,1-based positions
start = int(bed_start) + 1
end = int(bed_end)
except ValueError:
raise ValueE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_string(cls, value: str):\n # Expects a string with exactly one comma.\n tokens = value.split(',')\n if len(tokens) != 2:\n raise ValueError(\"invalid interval '{}'\".format(value))\n leftside, rightside = tokens[0].strip(), tokens[1].strip()\n # The left side ... | [
"0.56674397",
"0.5589117",
"0.52700174",
"0.51611406",
"0.49801382",
"0.49412447",
"0.4934894",
"0.4891182",
"0.48297453",
"0.47974023",
"0.47851297",
"0.4779299",
"0.4719899",
"0.47190937",
"0.4713461",
"0.46875063",
"0.46467575",
"0.4637924",
"0.46313342",
"0.4604167",
"0.4... | 0.60759693 | 0 |
Randomly generate an id of length N (size) we can recognize. Think Italian or Japanese or Native American. | def id_generator(size=8):
variables = 'aeiou'
consonants = 'bdfghklmnprstvw'
return ''.join([random.choice(variables if i % 2 else consonants)
for i in range(size)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id_generator(size=15, chars=string.ascii_uppercase + string.digits):\n return ''.join(random.choice(chars) for x in range(size))",
"def id_generator(size=7, chars=string.ascii_uppercase + string.digits):\n return ''.join(random.choice(chars) for _ in range(size))",
"def id_generator(size=6, chars=str... | [
"0.83254606",
"0.8324936",
"0.8309996",
"0.82580405",
"0.8195587",
"0.79753214",
"0.7957458",
"0.7926925",
"0.79060256",
"0.7887611",
"0.7807349",
"0.76666033",
"0.7629297",
"0.76052105",
"0.7495102",
"0.74627537",
"0.7387696",
"0.7354797",
"0.734266",
"0.72469634",
"0.706471... | 0.7728246 | 11 |
r"""Split string based on a delimiter/separator. This wrapper around ``str.split`` harmonize Python 2/3 syntax. | def split(string, sep='\t'):
return text_type.split(string, sep) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __split_for_delimiter__(self, string):\n if not self.__delimiter__ == '':\n return string.split(self.__delimiter__)\n return string.split()",
"def split(value, delimiter):\n return value.split(delimiter)",
"def safe_split(string, sep=','):\n regex = re.escape(sep) + r'\\s*(?!... | [
"0.8030143",
"0.72689456",
"0.7151636",
"0.7131167",
"0.7017812",
"0.6992419",
"0.69921666",
"0.69284534",
"0.6917595",
"0.689079",
"0.6883223",
"0.6880686",
"0.6830895",
"0.6719127",
"0.6717432",
"0.66997856",
"0.6693518",
"0.6682929",
"0.6662894",
"0.6629831",
"0.6586085",
... | 0.7461075 | 1 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, CreditCardIdentificationCreditCard):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Return the integer represented by the given array of bytes. bytes Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of builtin objects that support the buffer protocol. byteorder The byte order used to rep... | def from_bytes(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytesToInt(bytes, byteorder='little', signed=False):\n return int.from_bytes(bytes, byteorder=byteorder, signed=signed)",
"def bytes_to_int(byte_array, big_endian=True, signed=False):\n if six.PY3:\n order = 'little'\n if big_endian:\n order = 'big'\n return int.from_byt... | [
"0.7650478",
"0.76184446",
"0.70863914",
"0.70028114",
"0.68281853",
"0.6731419",
"0.66147834",
"0.6607387",
"0.6563736",
"0.6560838",
"0.6533282",
"0.6528622",
"0.6466856",
"0.63951576",
"0.6331328",
"0.6178813",
"0.61582655",
"0.610728",
"0.6077142",
"0.60355407",
"0.596254... | 0.0 | -1 |
Return an array of bytes representing an integer. length Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. byteorder The byte order used to represent the integer. If byteorder is 'big', the most significant byte is at the beginning of the byte ... | def to_bytes(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _int_to_bytes(integer, endian = 'little'):\n size = 1\n while 1<<(8*size) <= integer:\n size += 1\n\n return integer.to_bytes(size, endian)",
"def int_to_bytes(val, bit=32, signed=False, big_endian=True):\n val = int(val) #ensure it is an int\n\n if six.PY3:\n order = 'little'\n ... | [
"0.7394239",
"0.64819914",
"0.64516103",
"0.6352235",
"0.629003",
"0.62405205",
"0.61800677",
"0.6170674",
"0.6157904",
"0.6146537",
"0.61131847",
"0.57722163",
"0.57660985",
"0.5684201",
"0.56833696",
"0.5663",
"0.56514335",
"0.55456555",
"0.5538383",
"0.5531538",
"0.5530636... | 0.0 | -1 |
Return the integer represented by the given array of bytes. bytes Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of builtin objects that support the buffer protocol. byteorder The byte order used to rep... | def from_bytes(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytesToInt(bytes, byteorder='little', signed=False):\n return int.from_bytes(bytes, byteorder=byteorder, signed=signed)",
"def bytes_to_int(byte_array, big_endian=True, signed=False):\n if six.PY3:\n order = 'little'\n if big_endian:\n order = 'big'\n return int.from_byt... | [
"0.7652321",
"0.7619455",
"0.7087375",
"0.7004154",
"0.68299264",
"0.67329735",
"0.66168606",
"0.6609719",
"0.65652376",
"0.65594465",
"0.65344334",
"0.65285057",
"0.6469213",
"0.6393301",
"0.63298506",
"0.6180583",
"0.61584795",
"0.6107819",
"0.6077974",
"0.60370475",
"0.596... | 0.0 | -1 |
Return an array of bytes representing an integer. length Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. byteorder The byte order used to represent the integer. If byteorder is 'big', the most significant byte is at the beginning of the byte ... | def to_bytes(self, *args, **kwargs): # real signature unknown
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _int_to_bytes(integer, endian = 'little'):\n size = 1\n while 1<<(8*size) <= integer:\n size += 1\n\n return integer.to_bytes(size, endian)",
"def int_to_bytes(val, bit=32, signed=False, big_endian=True):\n val = int(val) #ensure it is an int\n\n if six.PY3:\n order = 'little'\n ... | [
"0.73937124",
"0.64825076",
"0.6451981",
"0.6350696",
"0.62888193",
"0.6239706",
"0.6179007",
"0.6169797",
"0.6156917",
"0.614535",
"0.61122805",
"0.57704246",
"0.5764038",
"0.56830466",
"0.56810176",
"0.5660641",
"0.5650066",
"0.55439603",
"0.5537944",
"0.55319905",
"0.55319... | 0.0 | -1 |
Hashing function if salt is not provided, create a new user with new hash otherwise take hex into salt and return dict with hash, and salt | def create_hash(password, salt=None):
if not salt:
salt = os.urandom(8)
else:
salt = bytes.fromhex(salt)
return {'hash': hashlib.pbkdf2_hmac(
'sha256', # The hash digest algorithm for HMAC
password.encode('utf-8'), # Convert the password to bytes
salt, # Provide t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_hash_with_salt(self):\n self.assertEqual(get_user_hash(\"johndoe\", salt=\"jane\").hex()[:6], \"fb0bf4\")",
"def generate_hash(password, salt):\n # encode the password/salt in utf-8\n bytes_string = password.encode(encoding='utf-8')\n salt = salt.encode(encoding='utf-8')\n\n # cr... | [
"0.73387235",
"0.6935993",
"0.67630464",
"0.66744417",
"0.64758337",
"0.645302",
"0.6427404",
"0.6411962",
"0.6384789",
"0.63550085",
"0.63003236",
"0.6281475",
"0.6257764",
"0.62125343",
"0.6209279",
"0.62014943",
"0.61152166",
"0.60857445",
"0.6084569",
"0.6077427",
"0.6069... | 0.69985926 | 1 |
Returns a list of Question objects TODO change to user_id questions gets all questions of username answers get all answers for all the questions asked by the user | def get_my_questions(user_id):
questions = select_query(
"SELECT q_id,question FROM question WHERE question.user_id = (%s) ORDER BY create_time DESC ", user_id)
answers = select_query(
"SELECT answer.q_id, answer.answer, answer.a_id,answer.is_answer FROM answer Left JOIN question on answer.q_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_questions(user_id):\n questions = select_query(\n \"SELECT q_id,question, user_id FROM question\")\n my_questions = {q[0]: copy.deepcopy(\n Question(q[1], q_id=q[0], user_id=q[2])) for q in questions}\n\n answers = select_query(\n \"SELECT answer.q_id, answer.answer, answe... | [
"0.7453409",
"0.7404859",
"0.7125625",
"0.71247303",
"0.69590074",
"0.6931924",
"0.6877714",
"0.6808449",
"0.6756044",
"0.6703758",
"0.6616065",
"0.66108555",
"0.6593239",
"0.65884566",
"0.6550325",
"0.6546063",
"0.6537713",
"0.65038085",
"0.64862615",
"0.6469681",
"0.64578",... | 0.7261492 | 2 |
Ensures Full Input Path ends with ``/`` Example >>> _fix_suffix(u'/user/furia_salamandra_faerfax/data/18/01/01') u'/user/furia_salamandra_faerfax/data/18/01/01/' | def fix_suffix(path):
if path[-2:] == "/*":
cleaned_path = path
else:
cleaned_path = os.path.join(path, "*")
spooq_logger.debug("fix_suffix: input: {inp}, output: {outp}".format(inp=path, outp=cleaned_path))
return cleaned_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_url_path(url: str) -> str:\n return url if url.endswith(\"/\") else url + \"/\"",
"def remove_suffix(input_string, suffix):\n if suffix and input_string.endswith(suffix):\n return input_string[:-len(suffix)]\n return input_string",
"def standardize_path(path):\n path.rstrip('/')\n ... | [
"0.69025594",
"0.6748137",
"0.6701195",
"0.6677919",
"0.66658235",
"0.6665528",
"0.6661921",
"0.6608794",
"0.6586295",
"0.65607655",
"0.64469475",
"0.64428055",
"0.6428288",
"0.64030695",
"0.63466406",
"0.6311808",
"0.63078314",
"0.6301498",
"0.6288454",
"0.62266314",
"0.6224... | 0.81063855 | 0 |
Writes a chart's html to a file | def _write_file(self, slug, folderpath, html):
# check directories
if not os.path.isdir(folderpath):
try:
os.makedirs(folderpath)
self.info("Creating directory " + folderpath)
except Exception as e:
self.err(e)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SaveWeeklyChart(self, chart, file):\n with open(os.path.join(self.HTML_DIR, file), 'w') as f:\n f.write(chart)",
"def to_html(self, result_dir):\n png_path = self.png_path(result_dir)\n data_table = self.html_data_table()\n return \"XXX figure html\"",
"def save(self, filename)... | [
"0.760428",
"0.6602479",
"0.65683776",
"0.6548275",
"0.64693683",
"0.6464094",
"0.6446035",
"0.6444865",
"0.63668585",
"0.6343577",
"0.6299603",
"0.62777096",
"0.6258571",
"0.62224287",
"0.62006176",
"0.61221164",
"0.61201864",
"0.6100858",
"0.6097943",
"0.60760176",
"0.60744... | 0.56397253 | 46 |
Read from a JSON using JsonSource. | def test_read_json1():
s = JsonSource()
g = s.parse(os.path.join(RESOURCE_DIR, 'valid.json'))
nodes = {}
edges = {}
for rec in g:
if rec:
if len(rec) == 4:
edges[(rec[0], rec[1])] = rec[3]
else:
nodes[rec[0]] = rec[1]
assert len(no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_json(self, kind, source, **kwargs):\n if source is None:\n raise exceptions.invalid_json_map[kind](f\"Cannot load {kind} - no data source specified.\")\n\n # Decode the json string and deserialize to objects.\n try:\n data = load_json(source, **kwargs)\n ... | [
"0.72825646",
"0.71280426",
"0.6986767",
"0.687738",
"0.68678147",
"0.68678147",
"0.6811519",
"0.6811519",
"0.67957664",
"0.6711954",
"0.6710924",
"0.6691571",
"0.6674023",
"0.66681874",
"0.6594951",
"0.65685576",
"0.65585023",
"0.6540461",
"0.65340227",
"0.6462589",
"0.64464... | 0.0 | -1 |
Read from a JSON using JsonSource. This test also supplies the provided_by parameter. | def test_read_json2():
s = JsonSource()
g = s.parse(os.path.join(RESOURCE_DIR, 'valid.json'), provided_by='Test JSON')
nodes = {}
edges = {}
for rec in g:
if rec:
if len(rec) == 4:
edges[(rec[0], rec[1])] = rec[3]
else:
nodes[rec[0]] = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_json(self, kind, source, **kwargs):\n if source is None:\n raise exceptions.invalid_json_map[kind](f\"Cannot load {kind} - no data source specified.\")\n\n # Decode the json string and deserialize to objects.\n try:\n data = load_json(source, **kwargs)\n ... | [
"0.66479355",
"0.64022267",
"0.63812864",
"0.6369558",
"0.63640517",
"0.630996",
"0.6233745",
"0.61611164",
"0.61611164",
"0.6136584",
"0.6132109",
"0.6111831",
"0.6092036",
"0.6092036",
"0.6069206",
"0.6062403",
"0.6043168",
"0.60050446",
"0.6001116",
"0.5998785",
"0.5994256... | 0.6440394 | 1 |
Read from a gzip compressed JSON using JsonSource. | def test_read_json_compressed():
s = JsonSource()
g = s.parse(os.path.join(RESOURCE_DIR, 'valid.json.gz'), compression='gz')
nodes = {}
edges = {}
for rec in g:
if rec:
if len(rec) == 4:
edges[(rec[0], rec[1])] = rec[3]
else:
nodes[rec[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_file(file_path):\n with gzip.open(file_path, \"rb\") as fp:\n return json.loads(fp.read().decode('utf-8'))",
"def load_data(fname):\n # load the json in gzip format\n with gzip.open(fname, 'r') as fin:\n data = json.loads(fin.read().decode('utf-8'))\n return data",
"def conve... | [
"0.66668963",
"0.666316",
"0.6291533",
"0.6183633",
"0.60846126",
"0.607153",
"0.60307795",
"0.599002",
"0.5961681",
"0.5957198",
"0.59519196",
"0.59519196",
"0.59493065",
"0.5935066",
"0.5791114",
"0.57791203",
"0.5776172",
"0.57593197",
"0.57593197",
"0.5730916",
"0.5716028... | 0.6872663 | 0 |
Maximum output length supported by the encoder. | def max_positions(self):
return min(self.args.max_positions, self.model.config.max_position_embeddings - 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setMaxOutputLength(self, value):\n return self._set(maxOutputLength=value)",
"def setMaxOutputLength(self, value):\n return self._set(maxOutputLength=value)",
"def setMaxOutputLength(self, value):\n return self._set(maxOutputLength=value)",
"def len_max(self):\n return 16 + 16... | [
"0.761554",
"0.761554",
"0.761554",
"0.75845206",
"0.7364795",
"0.7340533",
"0.7268281",
"0.72500485",
"0.7244087",
"0.70455",
"0.70181966",
"0.70042694",
"0.70007545",
"0.6991749",
"0.69536597",
"0.6952096",
"0.69393617",
"0.69274753",
"0.69184226",
"0.6898335",
"0.6890571",... | 0.0 | -1 |
Converting tzaware datetime object to local tz string with offset | def convert_to_timezone_with_offset(date_val: datetime, tz: str, converted: bool = False, isoformat: bool = True,
no_offset: bool = True):
try:
if not isinstance(date_val, datetime):
date_val = datetime.strptime(date_val, '%Y-%m-%dT%H:%M:%S.%f%z')
if n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def localize(dt):\n if dt.tzinfo is UTC:\n return (dt + LOCAL_UTC_OFFSET).replace(tzinfo=None)\n # No TZ info so not going to assume anything, return as-is.\n return dt",
"def _format_timezone_offset(converted_time):\n\n # Windows treats %z in the format string as %Z, so we compute the hou... | [
"0.67501193",
"0.6701646",
"0.668043",
"0.66613716",
"0.65766686",
"0.65751505",
"0.6397249",
"0.6394014",
"0.63891953",
"0.6387073",
"0.63593614",
"0.63545173",
"0.6336814",
"0.63054556",
"0.6286896",
"0.6250781",
"0.6249233",
"0.6233245",
"0.6225213",
"0.62214726",
"0.62166... | 0.6166816 | 24 |
Return a list of actions. | def get_actions(self, status='all', plan=None, tags=None):
if plan is not None:
list_ = plan.actions
else:
list_ = qlist()
list_.extend(dal.actions.all())
list_.extend(dal.plans.filter(type='option', actions__count__gt=0))
if status in ('active',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list_of_actions(self):\n return self.actions",
"def get_actions(self):\n return []",
"def actions(self):\n return self._action_list",
"def get_actions(self):\n return self.agent.get_actions()",
"def actions(self):\n\n return self._actions.getSlice(0)",
"def acti... | [
"0.88302803",
"0.8703013",
"0.8697641",
"0.82608515",
"0.8219257",
"0.8219257",
"0.82093024",
"0.8201354",
"0.8187794",
"0.8119534",
"0.8042842",
"0.80217546",
"0.8017804",
"0.79884714",
"0.7960888",
"0.7919015",
"0.79093635",
"0.78971034",
"0.78971034",
"0.78971034",
"0.7890... | 0.0 | -1 |
Return minimum, maximum, and stepping value for a range. | def parse_range(spec):
colons = spec.count(':')
if colons == 2:
low, high, step = spec.split(':')
elif colons == 1:
low, high = spec.split(':')
step = '1' # parsed to int or float later on
elif colons == 0:
low = high = spec
step = '1' # parsed to int or float l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_min_max_value(min, max, value=None, step=None):\n # Either min and max need to be given, or value needs to be given\n if value is None:\n if min is None or max is None:\n raise ValueError('unable to infer range, value from: ({0}, {1}, {2})'.format(min, max, value))\n diff = ... | [
"0.80031246",
"0.73807055",
"0.7305801",
"0.71562856",
"0.7143796",
"0.70966774",
"0.7085053",
"0.6935078",
"0.68667656",
"0.6825321",
"0.6820786",
"0.6817906",
"0.6714806",
"0.6673749",
"0.6671547",
"0.6671135",
"0.66498816",
"0.66307664",
"0.66211474",
"0.65613204",
"0.6527... | 0.0 | -1 |
Return a positive integer, whose value is guaranteed to be monotonically increasing across different invocations of this function, and also across separate instances of the calling program. This is accomplished by using a systemwide file which holds the "next available" ID. The location of this file can be set using th... | def progressive_number(qty=None, id_filename=None):
assert qty is None or qty > 0, \
"Argument `qty` must be a positive integer"
if id_filename is None:
id_filename = os.environ.get('GC3PIE_ID_FILE',
os.path.expanduser('~/.gc3/next_id.txt'))
# ensure dire... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_id():\n global _lock, _counter\n with _lock:\n if _counter == 65535:\n _counter = 1\n else:\n _counter += 1\n\n return str(_counter)",
"def idGenerate(fileName):\n idRegistry = readFile(fileName)\n try:\n idRegistry += 1\n except:\n ... | [
"0.7132827",
"0.67509985",
"0.6664161",
"0.6646398",
"0.66185105",
"0.6600548",
"0.6599068",
"0.6564119",
"0.65575594",
"0.6550596",
"0.6543228",
"0.65423465",
"0.6512651",
"0.6510387",
"0.646259",
"0.6452903",
"0.6452903",
"0.64390147",
"0.6363842",
"0.63576376",
"0.635129",... | 0.70480376 | 1 |
Return a (shallow) copy of this `Struct` instance. | def copy(self):
return Struct(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shallow_copy(self):\n # TODO: Rename this to __copy__()?\n raise NotImplementedError(\"shallow_copy is not implemented\")",
"def deepcopy(self):\n return self.copy()",
"def copy(self):\n cls = type(self)\n # Create a new instance without calling __init__: parameters are\n... | [
"0.7161071",
"0.70587754",
"0.6900697",
"0.6876317",
"0.687192",
"0.68647516",
"0.6843045",
"0.6837291",
"0.68043196",
"0.6774794",
"0.6749245",
"0.6749245",
"0.6749245",
"0.6749245",
"0.67402995",
"0.6739818",
"0.67339414",
"0.672899",
"0.6717386",
"0.6717386",
"0.6717386",
... | 0.88025063 | 0 |
Iterate over lines in `iterable` and return each of them stripped of leading and trailing blanks. | def stripped(iterable):
for item in iterable:
yield item.strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanStrings(iterable,CC=None):\n if CC is not None:\n iterable = ( line.split(CC)[0] for line in iterable )\n iterable = ( line.strip() for line in iterable )\n iterable = ( line for line in iterable if line )\n iterable = ( line.lower() for line in iterable )\n return iterable",
"def ... | [
"0.6607268",
"0.6514533",
"0.6450976",
"0.6448855",
"0.64329845",
"0.6403828",
"0.63710845",
"0.63319886",
"0.63206255",
"0.6290142",
"0.6155615",
"0.6054748",
"0.60107005",
"0.5996157",
"0.59149253",
"0.58226615",
"0.5819894",
"0.57857233",
"0.56368524",
"0.56294525",
"0.557... | 0.8038426 | 0 |
A context manager for creating and then deleting a temporary directory. All arguments are passed unchanged to the `tempfile.mkdtemp` standand library function. | def tempdir(**kwargs):
tmpdir = tempfile.mkdtemp(**kwargs)
try:
yield tmpdir
finally:
if os.path.isdir(tmpdir):
shutil.rmtree(tmpdir, ignore_errors=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mkdtemp(*args, **kwargs):\n import tempfile\n dir_name = tempfile.mkdtemp(*args, **kwargs)\n import atexit, shutil\n ignore_errors = True\n atexit.register(shutil.rmtree, dir_name, ignore_errors)\n return dir_name",
"def temp_dir(**kwargs):\n temp_dir = tempfile.mkdtemp(**kwargs)\n t... | [
"0.86446106",
"0.8444373",
"0.83503264",
"0.81677383",
"0.80900854",
"0.8076442",
"0.8074244",
"0.8010386",
"0.79966956",
"0.795482",
"0.7913095",
"0.79105306",
"0.782305",
"0.7819975",
"0.7763077",
"0.77489454",
"0.7713523",
"0.7640135",
"0.7631938",
"0.7603079",
"0.75673264... | 0.845876 | 1 |
Iterate over all unique elements in sequence `seq`. Distinct values are returned in a sorted fashion. | def uniq(seq):
return sorted(set(seq)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unique(seq):\n return list(set(seq))",
"def uniq(seq):\r\n #TODO: consider building a set out of seq so that the if condition\r\n #is constant time -JB\r\n return [x for i, x in enumerate(seq) if seq.index(x) == i]",
"def unique_ordered(seq):\n\tvals = set()\n\treturn [x for x in seq if not (x ... | [
"0.75994635",
"0.75159013",
"0.74595594",
"0.7385903",
"0.7266428",
"0.7140849",
"0.70555896",
"0.7007962",
"0.6954724",
"0.68912864",
"0.67117333",
"0.66650826",
"0.66469574",
"0.6604121",
"0.6286002",
"0.6251432",
"0.6244778",
"0.6210425",
"0.6188838",
"0.60305905",
"0.6011... | 0.7626998 | 0 |
Works like default_params, but for convenience allows grouping parameters into subdictionaries. If a named parameter is given which matches the name of a subdictionary and whose value is a dictionary, the default dictionary and the given dictionary will be merged, instead of overwriting the default subdictionary (if th... | def twolevel_default_params(defaults):
def wrap(function):
def withargs(*args, **kwargs):
merged = {}
merged.update(defaults)
for k, v in kwargs.items():
if type(v) == dict and k in merged and type(merged[k]) == dict:
merged[k].update(v)
else:
merged[k] = v
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setdefault(*dicts):\n param_complete = dict(dicts[0])\n for d in dicts[1:]:\n for k,v in d.items():\n param_complete.setdefault(k, v)\n\n return param_complete",
"def merge_config(user: dict, default: dict) -> dict:\n\n if isinstance(user, dict) and isinstance(default, dict):\n ... | [
"0.64294463",
"0.6398259",
"0.63895047",
"0.630195",
"0.6193579",
"0.6189458",
"0.5926945",
"0.5909719",
"0.58540964",
"0.58180463",
"0.57332724",
"0.57268095",
"0.5702041",
"0.56668323",
"0.56609714",
"0.565968",
"0.5649187",
"0.55940115",
"0.5544784",
"0.55287725",
"0.55253... | 0.7143888 | 0 |
Computes a filename for a cache value of the given type. | def cache_name(name, typ="pkl"):
return os.path.join(CACHE_DIR, name + '.' + typ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cache_filename(typ, dumpname, address=None):\n fname = typ\n if address is not None:\n fname = '%x.%s' % (address, typ)\n return os.path.sep.join([get_cache_folder_name(dumpname), fname])",
"def _cachefilename(self, cachedir):\n\n return cachedir / \"filename\"",
"def _get_filena... | [
"0.7411133",
"0.6874516",
"0.6733833",
"0.66989446",
"0.6614053",
"0.6498675",
"0.61661047",
"0.61661047",
"0.61661047",
"0.6124312",
"0.60989636",
"0.6094987",
"0.60322076",
"0.60008824",
"0.5986326",
"0.5986326",
"0.5976975",
"0.59567297",
"0.5939237",
"0.5930659",
"0.59275... | 0.7032913 | 1 |
Get the unique terms across the text in received tweets and output as three groups. We separate words in sentences using regex. We split words by any characters which are not , @, alphanumeric, single or double quotes or a hyphen. Essentially we split by remaining punctuation and white spaces. Though by keeping hyphen ... | def getHashtagsAndMentions(tweets):
hashtags = Counter()
mentions = Counter()
plain = Counter()
pattern = re.compile(r"[^#@\w'-]+")
for t in tweets:
words = pattern.split(t.message)
for word in words:
# Ignore null strings caused by split characters at the end of a
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(self, text):\n split = []\n terms = []\n for term in re.split('\\s', text):\n # If the term is empty, skip it, since we probably just have\n # multiple whitespace cahracters.\n if term == '':\n continue\n # Now, a word can... | [
"0.6669178",
"0.6581531",
"0.6547369",
"0.6540348",
"0.65368605",
"0.6534315",
"0.6495982",
"0.6486845",
"0.6465529",
"0.6465529",
"0.6462578",
"0.6460408",
"0.64409333",
"0.6388948",
"0.6367203",
"0.6357462",
"0.63344157",
"0.6312621",
"0.6292938",
"0.6275091",
"0.62743217",... | 0.62529 | 24 |
Checks if a node is contained in a face Return the local node index if found in the face Gives the first index if multiple (there should not be multiple for a valid mesh) | def check_in_face(self, node_num, face_num):
for i, node_global_ind in enumerate(self.faces[face_num]):
if node_global_ind == node_num:
return (True, i)
return (False, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMeshIndex(gltf, idname):\n\n if gltf.get('meshes') is None:\n return -1\n\n index = 0\n for mesh in gltf['meshes']:\n key = 'id' if mesh.get('id') != None else 'name'\n if mesh.get(key) == idname:\n return index\n\n index += 1\n\n return -1",
"def neighbo... | [
"0.60940945",
"0.5794519",
"0.57887036",
"0.56676614",
"0.56393915",
"0.5619399",
"0.5608121",
"0.5585266",
"0.552419",
"0.551562",
"0.5511793",
"0.54896045",
"0.5472748",
"0.5432701",
"0.541635",
"0.5383229",
"0.53685564",
"0.53472453",
"0.53403014",
"0.5328364",
"0.53250885... | 0.7777686 | 0 |
Remove color codes from input text | def remove_color(text):
color_reg = re.compile(r"\033\[\d*(;\d*)*m")
return re.sub(color_reg, "", text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _remove_text_colors(text) -> StyledStr:\n return _remove_regex(FOREGROUND_COLORS_REGEX, text)",
"def strip_ansi_color(data):\n if isinstance(data, bytes):\n data = data.decode(\"utf-8\")\n\n # Taken from tabulate\n invisible_codes = re.compile(r\"\\x1b\\[\\d*m\")\n\n return re.sub(invis... | [
"0.7301121",
"0.70891196",
"0.7027733",
"0.6929002",
"0.6775761",
"0.67008615",
"0.66931397",
"0.66061866",
"0.65510416",
"0.65122557",
"0.648625",
"0.64378804",
"0.6347886",
"0.6341688",
"0.6321839",
"0.6296648",
"0.62281924",
"0.622401",
"0.6210272",
"0.6179865",
"0.615918"... | 0.7637727 | 0 |
Ensure we can create a new product object. | def test_create_product(self):
url = reverse('products:list')
data = {
'name': 'Banana',
'description': '''
Bananas are one of the most widely consumed fruits in the
world for good reason. Eating them could help lower blood
pressure... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_01_product_create(self):\n # Create new product with a replacement product\n product = self.create_product()\n\n # Check recently was created product with default 'In Development'\n # value state and that the replacement was assigned. This case also\n # check the read te... | [
"0.7750057",
"0.76509434",
"0.73122835",
"0.72073627",
"0.71966124",
"0.70265263",
"0.6964693",
"0.69091284",
"0.69064957",
"0.6867335",
"0.68420285",
"0.68166935",
"0.68023586",
"0.6776348",
"0.6699295",
"0.6686237",
"0.66644645",
"0.66606146",
"0.66315293",
"0.6626657",
"0.... | 0.6599606 | 21 |
Ensure created product objects are returned. | def test_list_product(self):
url = reverse('products:list')
response = self.client.get(url)
self.assertEqual(len(response.data), 1)
self.assertEqual(response.data[0]['name'], 'Eggs') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_products():\n try:\n # Instantiate the class and separate objects into two lists\n challenge = Challenge()\n # Get all products\n product_base = challenge.get_products(\"product_groups.json\")\n # Divide the products into independent (no parent) and dependent (with ... | [
"0.76835716",
"0.71772695",
"0.67874676",
"0.6709017",
"0.6681837",
"0.6667027",
"0.6536434",
"0.64481217",
"0.6392697",
"0.63535756",
"0.63013506",
"0.6280245",
"0.6276846",
"0.6247466",
"0.6232976",
"0.61780953",
"0.6168151",
"0.615804",
"0.614262",
"0.613467",
"0.61256975"... | 0.0 | -1 |
Ensure we cannot update a product object without a required value. | def test_update_product_required_fields(self):
data = {
'pk': 1,
'name': None,
'description': '''
Yogurt also spelled yoghurt, yogourt or yoghourt,
is a food produced by bacterial fermentation of milk.
'''
}
url = re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_nonexistant_product(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product_update = dict(\n prod_name='NY_jeans',\n category='denims',\n stock=50,\n price=180\n )\n r... | [
"0.6858474",
"0.6539858",
"0.6504811",
"0.64279",
"0.63721395",
"0.630006",
"0.6271217",
"0.6187618",
"0.61517346",
"0.61487615",
"0.6102605",
"0.6095026",
"0.60840935",
"0.60634136",
"0.60610586",
"0.6052031",
"0.6025971",
"0.6018435",
"0.59484875",
"0.5940664",
"0.5926653",... | 0.6758621 | 1 |
Ensure we can retrieve a product object. | def test_retrieve_product(self):
product_pk = 1
url = reverse('products:detail', kwargs={'pk': product_pk})
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['id'], product_pk) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_product(self):\n # get the id of a product\n test_product = self._create_products(1)[0]\n resp = self.app.get(\n \"/products/{}\".format(test_product.id), content_type=\"application/json\"\n )\n self.assertEqual(resp.status_code, status.HTTP_200_OK)\n ... | [
"0.6728869",
"0.6544774",
"0.64300364",
"0.6280355",
"0.616119",
"0.61093605",
"0.60606",
"0.6055613",
"0.60533905",
"0.60302293",
"0.6021884",
"0.60153896",
"0.59756356",
"0.5963409",
"0.59586644",
"0.595791",
"0.5955534",
"0.593957",
"0.5910057",
"0.5905302",
"0.5904873",
... | 0.6265791 | 4 |
Required by UserPassesTestMixin. Used to determine if the user is the post's author | def test_func(self):
post = self.get_object()
if self.request.user == post.author:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_func(self):\r\n post = self.get_object()\r\n if self.request.user == post.author:\r\n return True\r\n return False",
"def test_func(self):\r\n post = self.get_object()\r\n if self.request.user == post.author:\r\n return True\r\n return Fals... | [
"0.82481396",
"0.82481396",
"0.82481396",
"0.8129531",
"0.8129531",
"0.75717956",
"0.75703967",
"0.72330797",
"0.72330797",
"0.70377123",
"0.68906224",
"0.68682307",
"0.6862221",
"0.6857728",
"0.6840125",
"0.6815075",
"0.67987746",
"0.67764294",
"0.6648219",
"0.65935385",
"0.... | 0.82284826 | 3 |
Updates relu activation functions so that 1 stores output in forward pass 2 imputes zero for gradient values that are less than zero | def update_relus(self):
def relu_backward_hook_function(module, grad_in, grad_out):
"""
If there is a negative gradient, change it to zero
"""
# Get last forward output
corresponding_forward_output = self.forward_relu_outputs[-1]
correspond... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_relus(self):\n def relu_backward_hook_function(module, grad_in, grad_out):\n \"\"\"\n If there is a negative gradient, change it to zero\n \"\"\"\n # Get last forward output\n corresponding_forward_output = self.forward_relu_outputs[-1]\n corresponding_forward_output[c... | [
"0.7100333",
"0.7058471",
"0.70514506",
"0.7016183",
"0.69800603",
"0.6970446",
"0.6891995",
"0.6884671",
"0.6851853",
"0.6762686",
"0.6735883",
"0.6601431",
"0.6566213",
"0.6560501",
"0.65268946",
"0.64769137",
"0.64734256",
"0.64673173",
"0.64647084",
"0.6449747",
"0.641947... | 0.69368 | 6 |
Saves a numpy matrix of shape D(1 or 3) x W x H as an image | def save_image(im, path):
if isinstance(im, np.ndarray):
if len(im.shape) == 2:
im = np.expand_dims(im, axis=0)
print('A')
print(im.shape)
if im.shape[0] == 1:
# Converting an image with depth = 1 to depth = 3, repeating the same values
# F... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_image(filename, matrix):\n im = Image.new('L', list(reversed(matrix.shape)))\n data = np.floor(np.ravel(matrix) * 256)\n im.putdata(data)\n im.save(filename)",
"def save_reconstructed_images(self, filename, rows, cols):\n # print(filename)\n num_images = self.reconstructed.shap... | [
"0.705154",
"0.6232312",
"0.62307554",
"0.60396045",
"0.5971052",
"0.59563744",
"0.5929307",
"0.589202",
"0.5874667",
"0.58503026",
"0.58503026",
"0.58300304",
"0.5826351",
"0.580099",
"0.5783836",
"0.577069",
"0.57415926",
"0.5703839",
"0.56920254",
"0.5688331",
"0.5671938",... | 0.5791287 | 14 |
Returns the event given a filename. | def getevent(self, name):
return self.events[name.lower()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getevent(self, filename):\n return self.events[filename.lower()]",
"def event_specifier(self, event_name):\n event_file = os.path.join(self.events_dir, event_name)\n if os.path.isfile(event_file):\n return utils.file_word(event_file)\n else:\n return None",
... | [
"0.8657537",
"0.69001484",
"0.66389483",
"0.65169996",
"0.61778605",
"0.61574984",
"0.6132738",
"0.6004449",
"0.5997125",
"0.589666",
"0.58965075",
"0.58734703",
"0.58438706",
"0.58191633",
"0.581425",
"0.5796045",
"0.57793486",
"0.5770477",
"0.5750548",
"0.5692956",
"0.56758... | 0.6525911 | 3 |
Returns the event given a filename. | def getevent(self, filename):
return self.events[filename.lower()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_specifier(self, event_name):\n event_file = os.path.join(self.events_dir, event_name)\n if os.path.isfile(event_file):\n return utils.file_word(event_file)\n else:\n return None",
"def get_file_validation_event(file_events):\n file_validation_event = file_e... | [
"0.69001484",
"0.66389483",
"0.6525911",
"0.65169996",
"0.61778605",
"0.61574984",
"0.6132738",
"0.6004449",
"0.5997125",
"0.589666",
"0.58965075",
"0.58734703",
"0.58438706",
"0.58191633",
"0.581425",
"0.5796045",
"0.57793486",
"0.5770477",
"0.5750548",
"0.5692956",
"0.56758... | 0.8657537 | 0 |
The groundtruth trajectory as absolute poses. | def ground_truth_trajectory(self):
return self._ground_truth_trajectory | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ground_truth_camera_poses(self):\n return self._ground_truth_trajectory",
"def ground_amp(self) -> torch.Tensor:\n return torch.abs(self.ground_vis)",
"def get_GroundTruth(self):\n\n # set first pose to identity\n # first_pose = self.dataset.oxts[0].T_w_imu\n # first_... | [
"0.6765868",
"0.6603803",
"0.6599658",
"0.65702444",
"0.60967803",
"0.5828267",
"0.58172274",
"0.5724312",
"0.56197137",
"0.55483526",
"0.5531694",
"0.5514",
"0.54430574",
"0.54178333",
"0.54023176",
"0.53969103",
"0.53911406",
"0.5388463",
"0.5358827",
"0.53451616",
"0.53341... | 0.7627083 | 0 |
View function for home page of site. | def index(request):
# Generate counts of some of the main objects
num_orgs=Organization.objects.count()
num_contacts=Contact.objects.count()
# Get the number of Volunteers
num_volunteers=ContactTypeTag.objects.filter(tag_type__exact='vo').count()
num_projects=Project.objects.count() # The 'all(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(request):\n\treturn render(request, \"compta/home.html\")",
"def home_page(request):\r\n return render(request, 'ez_main/home_page.html')",
"def home(request):\r\n return render(request, 'home.html')",
"def homepage(request):\n\treturn render(request, 'core/homepage.html')",
"def homepage(req... | [
"0.8493426",
"0.84268916",
"0.83415145",
"0.83306193",
"0.82976943",
"0.8295291",
"0.8276345",
"0.82545686",
"0.82155704",
"0.8132563",
"0.81246215",
"0.81224865",
"0.8121264",
"0.81049734",
"0.8098485",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0... | 0.0 | -1 |
colors_tuple contains color count and color RGB we want to sort the tuple by RGB tuple[1] | def sort_by_rgb(colors_tuple):
sorted_tuple = sorted(colors_tuple, key=lambda x:x[1])
return sorted_tuple | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ordered_colors():\n\n return [(\"yellow\",0.263) ,(\"orange\", 0.047), (\"red\",0.0),(\"green\", 0.444), (\"purple\", 0.972)]",
"def sortColors(self, nums: List[int]) -> None:\n\n red = 0\n white = 1\n blue = 2\n\n (redp, whitep, bluep) = (0, 0, len(nums) - 1)\n\n while ... | [
"0.73057824",
"0.6715163",
"0.659019",
"0.65718055",
"0.6554891",
"0.6513611",
"0.65068257",
"0.64852744",
"0.6476646",
"0.6446672",
"0.6437227",
"0.6434518",
"0.64283127",
"0.64269793",
"0.6415569",
"0.64137036",
"0.63663346",
"0.6353963",
"0.6353518",
"0.63507",
"0.6346661"... | 0.88446194 | 0 |
Initialize the weights of model. | def init_weights(self, pretrained=None):
self.online_backbone.init_weights() # backbone
for online_neck in self.online_necks:
online_neck.init_weights(init_linear='kaiming') # projection
for param_ol, param_tgt in zip(self.online_backbone.parameters(),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(model):\n ...",
"def _initialize_weights(self):\n pass",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def initialize_weights(self):\n weights_initializer.WeightsInitializer.initialize_layer_or_model(\n self._batch)"... | [
"0.90901464",
"0.8925572",
"0.8857049",
"0.8845922",
"0.8692089",
"0.8623104",
"0.839182",
"0.8375357",
"0.83207476",
"0.8201005",
"0.8182173",
"0.8153451",
"0.8152008",
"0.8152008",
"0.8152008",
"0.81428635",
"0.8120445",
"0.8108976",
"0.8095916",
"0.8055329",
"0.8045609",
... | 0.76560736 | 47 |
Construct the Nasbench201 class. | def __init__(self):
super(Nasbench201, self).__init__()
self.args.data_path = FileOps.download_dataset(self.args.data_path)
self.nasbench201_api = API('self.args.data_path') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dataset: str,\n rng: Union[np.random.RandomState, int, None] = None, **kwargs):\n\n super(NasBench201BaseBenchmark, self).__init__(rng=rng)\n\n data_manager = NASBench_201Data(dataset=dataset)\n\n self.data = data_manager.load()\n\n self.config_to_stru... | [
"0.6607941",
"0.59671456",
"0.5869722",
"0.585219",
"0.5845626",
"0.5747821",
"0.5736726",
"0.5727834",
"0.56604826",
"0.5639249",
"0.56330985",
"0.5564503",
"0.55565447",
"0.555099",
"0.55415773",
"0.55343646",
"0.5533971",
"0.55332655",
"0.5528303",
"0.55212843",
"0.5520394... | 0.6830579 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.