query stringlengths 9 3.4k | document stringlengths 9 87.4k | metadata dict | negatives listlengths 4 101 | negative_scores listlengths 4 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Add 'word' to the sentence. 'word' could be punctuation, treat it accordingly | def add_word_to_sentence(sentence, word, dialog=False):
# In general, add a space before adding this word
# In some instances, do not add a space:
# * word is: . , ; : ! ?
# * word is an ellipsis
# * If the previous word was: \n\n
skip_space = ((word in ('.', ',', ':', ';', '!', '?'))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, word):\r\n if not word or word.strip() == '':\r\n return\r\n self.words.append(word)",
"def add_sentence(self, sentence):\n for word in sentence.split(' '):\n self.add_word(word)",
"def add_sentence(self, sentence):\n for word in sentence.split(' ... | [
"0.723863",
"0.72308135",
"0.72308135",
"0.70532537",
"0.70370543",
"0.7023629",
"0.7000412",
"0.6985124",
"0.6963167",
"0.6880629",
"0.6836367",
"0.6826433",
"0.679377",
"0.6777574",
"0.67711866",
"0.6751843",
"0.67057586",
"0.6701697",
"0.66921616",
"0.6685027",
"0.6638351"... | 0.76089525 | 0 |
Return a generated sentence as a list, given the starting tuple | def sentence_from(word_tuple):
sentence = list()
sentence_endings = ('.', '?', '!')
# Try to match quotes...
dialog = False
# Add the beginning of the sentence
for w in word_tuple:
add_word_to_sentence(sentence, w, dialog)
if w == '"':
dialog = not dialog
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentences(a, b):\n\n # TODO\n return []",
"def generate_sentence(self):\n if self.word_to_index is None:\n self.log.error(\"Need to load a model or data before this step.\")\n return []\n # Start sentence with the start token\n sentence = [self.word_to_index[s... | [
"0.68986154",
"0.6680261",
"0.642735",
"0.63931453",
"0.63931453",
"0.63459456",
"0.63335675",
"0.63187736",
"0.62377805",
"0.62003225",
"0.6195364",
"0.6184517",
"0.6167762",
"0.6116823",
"0.60697603",
"0.6056737",
"0.604705",
"0.60449076",
"0.5960856",
"0.59327054",
"0.5917... | 0.6232826 | 9 |
Generates num_sentences number of sentences. | def write_sentences(num_sentences):
sentence_count = 0
sentences = list()
# Get a starting point
word_tuple = random.choice(list(trigrams.keys()))
value = random.choice(trigrams[word_tuple])
# Find a trigram that'll start a sentence by finding '\n\n'
while word_tuple[0] != '\n\n':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_number_of_sentences(self):\n self.number_of_sentences = int(self.num_sentences.get())",
"def generate_sentences(self, count=5):\n\n with self.open_text_data() as f:\n result = self.read_sentences(f, count=count)\n return result",
"def _get_num_sentences(doc: Doc, min_sen... | [
"0.74095225",
"0.6612392",
"0.6589216",
"0.655897",
"0.63650364",
"0.61993533",
"0.6197445",
"0.61843055",
"0.60508823",
"0.6017097",
"0.60111636",
"0.6007302",
"0.59827065",
"0.59385765",
"0.5907668",
"0.5861528",
"0.58307236",
"0.57782775",
"0.57639855",
"0.5741121",
"0.573... | 0.70788294 | 1 |
Convert plain dictionaries to MutationDict. | def coerce(cls, key, value): # @ReservedAssignment
if not isinstance(value, MutationDict):
if isinstance(value, dict):
return MutationDict(value)
# this call will raise ValueError
return Mutable.coerce(key, value)
else:
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dict_change(binary_dict:dict):\r\n dict_change= {}\r\n for key, value in binary_dict.items():\r\n dict_change[value] = key\r\n return dict_change",
"def values(self) -> Dict[str, Any]:\n return self.dict.copy()",
"def asdict(v: Any) -> Dict[Any, Any]:\n return to_dict(v, reuse_ins... | [
"0.5589519",
"0.5548092",
"0.55288583",
"0.55198234",
"0.54380774",
"0.53876173",
"0.5385113",
"0.53800666",
"0.5363616",
"0.5341232",
"0.5340839",
"0.53195035",
"0.5279707",
"0.527896",
"0.52454096",
"0.52354544",
"0.5224615",
"0.521172",
"0.52049816",
"0.520259",
"0.5202309... | 0.63197917 | 0 |
Detect dictionary set events and emit change events. | def __setitem__(self, key, value):
dict.__setitem__(self, key, value)
self.changed() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_change(key):\n pass",
"def test_dict(self):\n event_cache = []\n\n class A(HasTraits):\n x = EventfulDict({c: c for c in 'abc'})\n a = A()\n a.x.on_events(lambda k, v: event_cache.append('add'), \\\n lambda k, v: event_cache.append('set'), \\\n ... | [
"0.6108648",
"0.6041893",
"0.5883637",
"0.58645636",
"0.58198375",
"0.56819785",
"0.5651902",
"0.56416273",
"0.56320196",
"0.5539737",
"0.5534459",
"0.548702",
"0.5460749",
"0.5460682",
"0.5454028",
"0.5438486",
"0.54261786",
"0.5379148",
"0.53494334",
"0.53379464",
"0.527424... | 0.0 | -1 |
Detect dictionary del events and emit change events. | def __delitem__(self, key):
dict.__delitem__(self, key)
self.changed() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_delete(key):\n pass",
"def _post_del(self, key, bulk_change):\n self._del_callback(key, post=True)\n bulk_change or self._changed()",
"def handle_dict_items(self, object, name, old, new):\n self.handle_dict(object, name, new.removed, new.added)\n\n if len(new.changed) ... | [
"0.6143702",
"0.6062037",
"0.5894277",
"0.58087116",
"0.57233596",
"0.56603885",
"0.56232655",
"0.55866545",
"0.55236316",
"0.55122274",
"0.5433882",
"0.53715676",
"0.5329952",
"0.53061944",
"0.5243309",
"0.5241617",
"0.5238967",
"0.5229182",
"0.521433",
"0.51971745",
"0.5194... | 0.5362011 | 12 |
Convert plain list to MutationList. | def coerce(cls, key, value):
self = MutationList((MutationObj.coerce(key, v) for v in value))
self._key = key
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_list(l):\r\n l = [list(elem) for elem in l]\r\n return l",
"def to_list(ls):\r\n if isinstance(ls, (list, tuple)):\r\n return list(ls)\r\n else:\r\n return [ls]",
"def to_list(x):\n if isinstance(x, list):\n return x\n return [x]",
"def _to_pylist(self):\r\n\t\tpyli... | [
"0.6553225",
"0.62707764",
"0.5875614",
"0.58627445",
"0.585077",
"0.58077997",
"0.57693684",
"0.5765776",
"0.5741986",
"0.5727797",
"0.5705437",
"0.56927955",
"0.5684148",
"0.567436",
"0.56562585",
"0.5626378",
"0.562477",
"0.5623232",
"0.5575543",
"0.55727285",
"0.5551089",... | 0.5824151 | 5 |
A type to encode/decode JSON on the fly. sqltype is the string type for the underlying DB column. | def JSONAlchemy(sqltype):
class _JSONEncodedObj(JSONEncodedObj):
impl = sqltype
return MutationObj.as_mutable(_JSONEncodedObj) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_column_type(cls, **kwargs: Any) -> Any:\n return sqlalchemy.JSON()",
"def sql_to_python_type(sql_type):\n if sql_type.startswith(\"CHAR(\"):\n return str\n\n if sql_type.startswith(\"INTERVAL\"):\n # Calcite will always convert to milliseconds\n # no matter what the actu... | [
"0.7661815",
"0.74991727",
"0.743899",
"0.68335366",
"0.6789992",
"0.6789992",
"0.67713505",
"0.6475594",
"0.6413169",
"0.64099956",
"0.6337696",
"0.6271806",
"0.6241204",
"0.6188259",
"0.60408694",
"0.6027532",
"0.6002539",
"0.5950744",
"0.588287",
"0.58516645",
"0.5842662",... | 0.7874687 | 0 |
For linking manifests to stores. | def _remove_link(self, name, object_id):
if not name in self.data:
return
if self.data[name] and object_id in self.data[name]:
self.data[name] = self.data[name].remove(object_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_manifests_to_collections(self, form):\n context = self.get_context_data()\n manifests = context['manifests']\n if form.is_valid():\n collections = form.cleaned_data['collections']\n for manifest in manifests:\n manifest.collections.add(*collections)\n ... | [
"0.52331376",
"0.5066857",
"0.5059139",
"0.49784532",
"0.4971535",
"0.4942237",
"0.49336964",
"0.49177375",
"0.48738533",
"0.48598063",
"0.48496395",
"0.48303482",
"0.48003998",
"0.47902387",
"0.4776855",
"0.47731015",
"0.47488102",
"0.47289616",
"0.4725865",
"0.47125113",
"0... | 0.0 | -1 |
Copy another files properties into this one. | def update(self, f):
for p in self.__mapper__.attrs:
if p.key == 'oid':
continue
try:
setattr(self, p.key, getattr(f, p.key))
except AttributeError:
# The dict() method copies data property values into the main dict,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self, src_path: str, tgt_path: str) -> None:",
"def _copy_file ( self, source, dest ):\n return",
"def mv_properties(self):\n f = '/coretemp/coretemp.properties'\n b = os.getcwd()\n shutil.copy2(b+f, '/etc/')",
"def override_from_folder(self, other: ItemVariant) -> None:\n ... | [
"0.6303038",
"0.62008184",
"0.59884304",
"0.5814487",
"0.57969534",
"0.5765706",
"0.57573634",
"0.57371336",
"0.57340986",
"0.57030267",
"0.56705135",
"0.56646675",
"0.56646675",
"0.56646675",
"0.56429267",
"0.563187",
"0.5629152",
"0.5626361",
"0.5608226",
"0.55912346",
"0.5... | 0.0 | -1 |
Cast a value to the type of the column. Primarily used to check that a value is valid; it will throw an exception otherwise | def python_cast(self, v):
if self.type_is_time():
import dateutil.parser
dt = dateutil.parser.parse(v)
if self.datatype == Column.DATATYPE_TIME:
dt = dt.time()
if not isinstance(dt, self.python_type):
raise TypeError(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cast_type(cdm_column_type, value):\n if cdm_column_type in ('integer', 'int64'):\n # Regex check only relevant if submission dtype is 'object'\n if not re.match(SCIENTIFIC_NOTATION_REGEX, str(value)):\n return int(value)\n if cdm_column_type in ('character varying', 'text', 'stri... | [
"0.7581383",
"0.7311566",
"0.7192849",
"0.7002419",
"0.6975015",
"0.6907458",
"0.68620867",
"0.67243296",
"0.67042017",
"0.6671973",
"0.66348386",
"0.66248286",
"0.6609004",
"0.66023487",
"0.658655",
"0.6516744",
"0.6507069",
"0.64969116",
"0.64807916",
"0.64645475",
"0.64507... | 0.66101235 | 12 |
Convert a numpy dtype into a Column datatype. Only handles common types. Implemented as a function to decouple from numpy | def convert_numpy_type(cls, dtype):
import numpy as np
m = {
'int64': cls.DATATYPE_INTEGER64,
'float64': cls.DATATYPE_FLOAT,
'object': cls.DATATYPE_TEXT # Hack. Pandas makes strings into object.
}
t = m.get(dtype.name, None)
if not t:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dtype(x, dtype):\n return x.type(dtype)",
"def col(name=None, dtype=None):\r\n if dtype is None:\r\n dtype = config.floatX\r\n type = CudaNdarrayType(dtype=dtype, broadcastable=(False, True))\r\n return type(name)",
"def _astype_internal(self, column: str, numpy_dtype: str) -> None:\n... | [
"0.72403413",
"0.6946642",
"0.6823858",
"0.6764341",
"0.6701959",
"0.6656315",
"0.665516",
"0.66546",
"0.6622384",
"0.6566192",
"0.655135",
"0.6548834",
"0.6538818",
"0.64513427",
"0.6432096",
"0.6430312",
"0.64242333",
"0.63871026",
"0.63726074",
"0.6336595",
"0.6335416",
... | 0.7141431 | 1 |
A dict that holds key/values for all of the properties in the object. | def dict(self):
d = {p.key: getattr(self,p.key) for p in self.__mapper__.attrs
if p.key not in ('table','stats','_codes', 'data')}
if not d:
raise Exception(self.__dict__)
d['schema_type'] = self.schema_type
if self.data:
# Copy data fields into to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json(self):\n rv = {\n prop: getattr(self, prop)\n for prop in self.__properties__\n if prop in vars(self)\n }\n rv.update(self._props)\n return rv",
"def to_dict(self):\n properties = {}\n for k in self.__dict__:\n if k in... | [
"0.70844686",
"0.6941605",
"0.6941605",
"0.6941605",
"0.6907806",
"0.6875907",
"0.68377703",
"0.67412454",
"0.6741137",
"0.6684948",
"0.6674076",
"0.6637555",
"0.66344774",
"0.6552374",
"0.65192205",
"0.64722574",
"0.64526504",
"0.6439939",
"0.6439939",
"0.6411683",
"0.636240... | 0.0 | -1 |
Like dict, but does not hold any null values. | def nonull_dict(self):
return {k: v for k, v in self.dict.items() if v and k != '_codes'} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_empty_values(_dict):\n return {k: v for k, v in list(_dict.items()) if v is not None}",
"def remove_nonetype(dictionary):\n\n return {k: v for k, v in dictionary.items() if v is not None}",
"def remove_none_values(dict_):\r\n\r\n res = {}\r\n res.update((key, value) for key, value in dic... | [
"0.6980913",
"0.68990964",
"0.68517286",
"0.6843782",
"0.6819606",
"0.6797191",
"0.674241",
"0.6687487",
"0.66704786",
"0.659102",
"0.6541672",
"0.64255816",
"0.63741374",
"0.63616335",
"0.6356433",
"0.6352695",
"0.6298491",
"0.628249",
"0.61883426",
"0.6167995",
"0.6152006",... | 0.73098445 | 0 |
Like dict, but properties have the table prefix, so it can be inserted into a row. | def insertable_dict(self):
d = {p.key: getattr(self, p.key) for p in self.__mapper__.attrs if p.key not in ('table', 'stats', '_codes')}
x = {('c_' + k).strip('_'): v for k, v in d.items()}
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_map_row_with_prefix(self):\n writer = BaseTSVWriter([\n ('Prop2', 'prop2'),\n ], field_prefix='prop1')\n\n row = NonCallableMock()\n row.prop1 = NonCallableMock(prop2=145)\n\n assert writer.map_row(row) == {\n 'Prop2': 145,\n }",
"def subsc... | [
"0.62057143",
"0.5901124",
"0.5722158",
"0.5698386",
"0.55880255",
"0.5553864",
"0.5551149",
"0.55233496",
"0.5521515",
"0.54345584",
"0.54306966",
"0.54142743",
"0.53891945",
"0.5362582",
"0.533171",
"0.5326324",
"0.5258037",
"0.5239976",
"0.523355",
"0.5230575",
"0.5229882"... | 0.5545239 | 7 |
Mangles a column name to a standard form, remoing illegal characters. | def mangle_name(name):
import re
try:
return re.sub('_+','_',re.sub('[^\w_]','_',name).lower()).rstrip('_')
except TypeError:
raise TypeError(
'Trying to mangle name with invalid type of: ' + str(type(name))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_column_name(string):\n string = unidecode(string.replace(' ', '_').lower())\n return re.sub(r'[^0-9a-z_]','', string)",
"def _validate_column_name(col_name : str) -> str:\n\n if col_name[0].isdigit():\n return f'\"{col_name}\"'\n return col_name",
"def _valid_column(column_name):\n ... | [
"0.75011533",
"0.71863365",
"0.6850968",
"0.68286157",
"0.67849135",
"0.66737306",
"0.66737306",
"0.6603098",
"0.65745264",
"0.6540453",
"0.6537761",
"0.6483973",
"0.6468041",
"0.6402178",
"0.63911235",
"0.63911235",
"0.63876563",
"0.6334491",
"0.63137543",
"0.6306661",
"0.62... | 0.5826473 | 56 |
Fully Qualified Name. A column Name with the column id as a prefix | def fq_name(self):
return "{}_{}".format(self.id_, self.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name(self):\n return self.col_name",
"def get_qualified_name(self):\r\n return self.__schema + \".\" + self.__name",
"def get_column_name(self) -> str:\n if self.is_shared():\n assert self._shared_id is not None\n return self._shared_id\n else:\n ... | [
"0.68329334",
"0.68293804",
"0.6810465",
"0.67501396",
"0.6709696",
"0.6643566",
"0.6605192",
"0.6542065",
"0.6512222",
"0.64777774",
"0.6414318",
"0.6377383",
"0.6377383",
"0.63540286",
"0.63368183",
"0.6283724",
"0.6218382",
"0.62059516",
"0.6182317",
"0.61647487",
"0.61426... | 0.6076237 | 23 |
Return a map from a code ( usually a string ) to the shorter numeric value | def reverse_code_map(self):
return { c.value:(c.ikey if c.ikey else c.key) for c in self.codes} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_trace_codes_text(codes_text: str) -> Mapping[int, str]:\n return {int(s[0], 16): s[1] for s in map(lambda l: l.split(), codes_text.splitlines())}",
"def _get_codes_helper(tree: HuffmanTree, code: str,\n symbol_dict: Any = None) -> Dict[int, str]:\n\n if tree.is_leaf():\n ... | [
"0.63763434",
"0.60887593",
"0.5878282",
"0.5812264",
"0.5761751",
"0.56965524",
"0.56952506",
"0.5693045",
"0.56928945",
"0.5665367",
"0.5657175",
"0.5650019",
"0.55857587",
"0.5573791",
"0.55579",
"0.55554926",
"0.5542785",
"0.5509366",
"0.5494867",
"0.548941",
"0.5480495",... | 0.56436175 | 12 |
Return a map from the short code to the full value | def forward_code_map(self):
return { c.key:c.value for c in self.codes} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def short_name(self):\n return {\n 0: \"null\",\n 1: \"eng-us\",\n 2: \"eng-gb\",\n 3: \"chi\",\n 4: \"fre\",\n 5: \"ger\",\n 6: \"rus\",\n 7: \"spa\"\n }[self.value]",
"def USCode(self, short):\n states ... | [
"0.7030232",
"0.62377006",
"0.6125831",
"0.58234924",
"0.5798159",
"0.5797581",
"0.57707036",
"0.56753397",
"0.5614182",
"0.5594766",
"0.5542074",
"0.55255014",
"0.5492654",
"0.5489943",
"0.54748416",
"0.54546756",
"0.5444328",
"0.5434999",
"0.54274505",
"0.541996",
"0.541899... | 0.55397546 | 11 |
event.listen method for Sqlalchemy to set the seqience_id for this object and create an ObjectNumber value for the id_ | def before_insert(mapper, conn, target):
#from identity import ObjectNumber
#assert not target.fk_vid or not ObjectNumber.parse(target.fk_vid).revision
if target.sequence_id is None:
# In case this happens in multi-process mode
conn.execute("BEGIN IMMEDIATE")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_id(self):\n raise NotImplementedError()",
"def _set_id(self, value):\n pass",
"def before_update(mapper, conn, target):\n if not target.id_:\n dataset = ObjectNumber.parse(target.d_id)\n target.id_ = str(PartitionNumber(dataset, target.sequence_id))",
"def ... | [
"0.657006",
"0.6410744",
"0.633713",
"0.63043654",
"0.61990416",
"0.6140299",
"0.60958314",
"0.6029619",
"0.6018305",
"0.59702224",
"0.59121996",
"0.58896697",
"0.5884108",
"0.58614206",
"0.58614206",
"0.58614206",
"0.58614206",
"0.58614206",
"0.58614206",
"0.58614206",
"0.58... | 0.580943 | 29 |
Set the column id number based on the table number and the sequence id for the column. | def before_update(mapper, conn, target):
if target.id_ is None:
if target.table:
table_on = ObjectNumber.parse(target.table.vid)
else:
table_on = ObjectNumber.parse(target.t_vid)
if not target.vid:
target.vid = str(ColumnNumb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_number(self, column_number):\n\n self._column_number = column_number",
"def setColumn(self, column_number, column):\n self.data[column_number] = column\n return",
"def before_insert(mapper, conn, target):\n\n #from identity import ObjectNumber\n #assert not target.... | [
"0.58531326",
"0.57902473",
"0.5741451",
"0.5735685",
"0.568962",
"0.5652403",
"0.5552755",
"0.55494297",
"0.54923403",
"0.54375416",
"0.53790486",
"0.5372677",
"0.531518",
"0.52969015",
"0.5286863",
"0.528056",
"0.52542907",
"0.5248752",
"0.52432024",
"0.52194864",
"0.520464... | 0.0 | -1 |
Return columns that can be used to link another table to this one | def link_columns(self, other):
def protos(t):
from identity import ObjectNumber
protos = {}
protos.update({ c.fk_vid:c for c in t.columns if c.fk_vid })
protos.update({ c.proto_vid:c for c in t.columns if c.proto_vid})
# HACK: The numbering in the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_table_columns(self):\n raise NotImplementedError(\"Please implement this method\")",
"def columns(self):\n result = self.execute(self.commands.table_columns(self.name))\n return [x[0] for x in result]",
"def columns(self):\n return self._meta.columns + self.new_columns",
"... | [
"0.74877757",
"0.72248137",
"0.7223993",
"0.70726424",
"0.70474076",
"0.7046264",
"0.69990844",
"0.6994382",
"0.6994382",
"0.6983984",
"0.69615287",
"0.69515544",
"0.688544",
"0.6806569",
"0.67401105",
"0.67401105",
"0.67333984",
"0.6723533",
"0.671475",
"0.67045975",
"0.6700... | 0.66995376 | 21 |
Return a SQL fragment to translate the column names to vids. This allows the identity of the column to propagate through views. | def vid_select(self):
cols = []
raise DeprecationWarning()
return ",".join(["{} AS {}".format(c.name, c.vid)
for c in self.columns]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def colNames_string(self):\n # SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'some_table';\n return \"SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = \"",
"def get_column_names(self):\n # here, creating combined column/volue column names for uniq... | [
"0.59262216",
"0.5894315",
"0.574054",
"0.56851643",
"0.5681624",
"0.5644304",
"0.5625935",
"0.55269486",
"0.54988027",
"0.5494023",
"0.54818374",
"0.54605204",
"0.54546434",
"0.543926",
"0.54041135",
"0.5399145",
"0.53989536",
"0.5346631",
"0.5316943",
"0.5296577",
"0.528737... | 0.6494514 | 0 |
event.listen method for Sqlalchemy to set the seqience_id for this object and create an ObjectNumber value for the id_ | def before_insert(mapper, conn, target):
if target.sequence_id is None:
sql = text(
'''SELECT max(t_sequence_id)+1 FROM tables WHERE t_d_id = :did''')
max_id, = conn.execute(sql, did=target.d_id).fetchone()
if not max_id:
max_id = 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_id(self):\n raise NotImplementedError()",
"def _set_id(self, value):\n pass",
"def before_update(mapper, conn, target):\n if not target.id_:\n dataset = ObjectNumber.parse(target.d_id)\n target.id_ = str(PartitionNumber(dataset, target.sequence_id))",
"def ... | [
"0.657006",
"0.6410744",
"0.633713",
"0.63043654",
"0.61990416",
"0.6140299",
"0.60958314",
"0.6029619",
"0.6018305",
"0.59702224",
"0.59121996",
"0.58896697",
"0.5884108",
"0.58614206",
"0.58614206",
"0.58614206",
"0.58614206",
"0.58614206",
"0.58614206",
"0.58614206",
"0.58... | 0.0 | -1 |
Set the Table ID based on the dataset number and the sequence number for the table. | def before_update(mapper, conn, target):
if isinstance(target, Column):
raise TypeError('Got a column instead of a table')
if target.id_ is None:
dataset_id = ObjectNumber.parse(target.d_id)
target.id_ = str(TableNumber(dataset_id, target.sequence_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_id(self) -> str:\n return pulumi.get(self, \"table_id\")",
"def newid(self, target_table):\n self.new_id[target_table] += 1\n return self.new_id[target_table]",
"def _set_id(self):\n raise NotImplementedError()",
"def __init__(self, name, sequence_number):\n super(SQL... | [
"0.6303707",
"0.61042374",
"0.59887666",
"0.59712815",
"0.5963648",
"0.5951662",
"0.5936735",
"0.5935326",
"0.5924849",
"0.59239405",
"0.5908809",
"0.5890164",
"0.57908034",
"0.57644045",
"0.5749948",
"0.5721006",
"0.56599724",
"0.56337774",
"0.56337774",
"0.5598158",
"0.5590... | 0.586561 | 12 |
Add a column to the table, or update an existing one. | def add_column(self, name, **kwargs):
import sqlalchemy.orm.session
from dbexceptions import NotFoundError
s = sqlalchemy.orm.session.Session.object_session(self)
assert s, "Can't create column with this method unless the table has a session"
name = Column.mangle_name(name)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_column(self, table_name: str, column) -> None:\n sql = 'ALTER TABLE ' + table_name + ' ADD COLUMN ' + column.to_sql()\n self.cursor.execute(sql)",
"def addcolumn(self, column):\n if column not in self.headersindex:\n database = managers.database_manager.get_database(self.o... | [
"0.8044641",
"0.78951424",
"0.7566874",
"0.7563241",
"0.7534224",
"0.74564385",
"0.7398052",
"0.72722125",
"0.7174453",
"0.7119803",
"0.7083992",
"0.7003603",
"0.69655204",
"0.69192994",
"0.6912937",
"0.6809401",
"0.6798886",
"0.67885715",
"0.67860836",
"0.6775129",
"0.669374... | 0.61204374 | 44 |
Using the size values for the columns for the table, construct a regular expression to parsing a fixed width file. | def get_fixed_regex(self):
import re
pos = 0
regex = ''
header = []
for col in self.columns:
size = col.width if col.width else col.size
if not size:
continue
pos += size
regex += "(.{{{}}})".format(size)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _xml_oneliner_re_from_tab_width(tab_width):\r\n return re.compile(r\"\"\"\r\n (?:\r\n (?<=\\n\\n) # Starting after a blank line\r\n | # or\r\n \\A\\n? # the beginning of the doc\r\n )\r\n ( # save i... | [
"0.5282245",
"0.5202611",
"0.51584333",
"0.5112584",
"0.5097661",
"0.50882554",
"0.50331146",
"0.5007031",
"0.5002561",
"0.49994928",
"0.4918503",
"0.48867288",
"0.4848906",
"0.4840389",
"0.48324287",
"0.4815891",
"0.4813815",
"0.48072702",
"0.48031062",
"0.48031032",
"0.4784... | 0.70005393 | 0 |
Using the size values for the columns for the table, construct a regular expression to parsing a fixed width file. | def get_fixed_unpack(self):
from functools import partial
import struct
unpack_str = ''
header = []
length = 0
for col in self.columns:
size = col.width
if not size:
continue
length += size
unpack_str +=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fixed_regex(self):\n import re\n\n pos = 0\n regex = ''\n header = []\n\n for col in self.columns:\n\n size = col.width if col.width else col.size\n\n if not size:\n continue\n\n pos += size\n\n regex += \"(.{{{}}... | [
"0.7001581",
"0.5281998",
"0.520352",
"0.5159071",
"0.51121205",
"0.50972956",
"0.5087772",
"0.5034582",
"0.50080603",
"0.5002775",
"0.49995232",
"0.4918619",
"0.48857585",
"0.48505762",
"0.48408142",
"0.48319057",
"0.48159397",
"0.4813209",
"0.48074836",
"0.48037595",
"0.480... | 0.4605466 | 41 |
Return the column specification suitable for use in the Panads read_fwf function. This will ignore any columns that don't have one or both of the start and width values | def get_fixed_colspec(self):
# Warning! Assuming th start values are sorted. Really should check.
return (
[c.name for c in self.columns if c.start and c.width],
[(c.start, c.start + c.width) for c in self.columns if c.start and c.width]
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cols_dummy():",
"def get_cols_drop():",
"def get_colspecs(self):\n width = 80\n\n total_width = 0.0\n # first see if we get too wide.\n for node in self._col_specs:\n colwidth = float(node['colwidth']+1) / width\n total_width += colwidth\n self._... | [
"0.6024424",
"0.596831",
"0.55173266",
"0.55082816",
"0.5469748",
"0.5435759",
"0.5397927",
"0.53476435",
"0.5337917",
"0.5330196",
"0.52848995",
"0.5283734",
"0.5212504",
"0.519947",
"0.5173507",
"0.5160879",
"0.5160859",
"0.5137145",
"0.5115543",
"0.5109305",
"0.5104314",
... | 0.6883937 | 0 |
Return an array of column names in the same order as the column definitions, to be used zip with a row when reading a CSV file. >> row = dict(zip(table.header, row)) | def header(self):
return [c.name for c in self.columns] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tbl_headers(rows):\n tbl_header = rows.pop(0)\n tbl_headers = {}\n for index, header_name in enumerate(tbl_header.find_all('th')):\n if header_name.text in conf.TABLE_HEADER_COLS:\n tbl_headers[header_name.text] = index\n return tbl_headers",
"def dataset_headers(dataset):\n... | [
"0.70451564",
"0.66638327",
"0.6658011",
"0.66280705",
"0.65749854",
"0.6568336",
"0.6515669",
"0.6511816",
"0.6473769",
"0.6446187",
"0.6435026",
"0.6378579",
"0.6373853",
"0.6346467",
"0.63042295",
"0.62944657",
"0.61811084",
"0.6173236",
"0.6117698",
"0.61152714",
"0.61072... | 0.66301876 | 3 |
Return a lambda function that, when given a row to this table, returns true or false to indicate the validitity of the row. | def _get_validator(self, and_join=True):
f = prior = lambda row: True
first = True
for i, col in enumerate(self.columns):
if col.data.get('mandatory', False):
default_value = col.default
index = i
if and_join:
f =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(self, row):\n raise NotImplementedError",
"def is_valid_row(self):\r\n return self.valid_row",
"def validate(self, field, row):\n raise NotImplementedError",
"def __is_valid_row(self, row_number):\n return self.__is_valid((row_number, 0))",
"def _validate_row(se... | [
"0.71320236",
"0.6811725",
"0.65632015",
"0.6560223",
"0.649287",
"0.60644335",
"0.59481806",
"0.59183645",
"0.58683056",
"0.57997584",
"0.5785376",
"0.56909657",
"0.569078",
"0.56540143",
"0.56372976",
"0.563167",
"0.55817455",
"0.5564339",
"0.55557644",
"0.5549355",
"0.5504... | 0.58476317 | 9 |
Return a function to generate a hash for the row. | def _get_hasher(self):
import hashlib
# Try making the hash set from the columns marked 'hash'
indexes = [i for i, c in enumerate(self.columns) if
c.data.get('hash', False) and not c.is_primary_key]
# Otherwise, just use everything by the primary key.
if len(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def row_hash(self, values):\n\n if self._row_hasher is None:\n self._row_hasher = self._get_hasher()\n\n return self._row_hasher(values)",
"def __hash__(self):\n return hash((self.rowx, self.row_name))",
"def __hash__(self):\n return hash((self.rowx, self.row_name))",
"... | [
"0.7663322",
"0.71563137",
"0.71563137",
"0.70118684",
"0.69970787",
"0.686038",
"0.6825169",
"0.67699486",
"0.6738878",
"0.6705481",
"0.6677108",
"0.65766907",
"0.655196",
"0.651539",
"0.64861447",
"0.645168",
"0.6409274",
"0.6398196",
"0.6374908",
"0.6355639",
"0.6340128",
... | 0.7440421 | 1 |
Calculate a hash from a database row. | def row_hash(self, values):
if self._row_hasher is None:
self._row_hasher = self._get_hasher()
return self._row_hasher(values) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_hasher(self):\n import hashlib\n\n # Try making the hash set from the columns marked 'hash'\n indexes = [i for i, c in enumerate(self.columns) if\n c.data.get('hash', False) and not c.is_primary_key]\n\n # Otherwise, just use everything by the primary key.\n ... | [
"0.68689716",
"0.6646721",
"0.65519816",
"0.6487062",
"0.6475017",
"0.6446482",
"0.642479",
"0.6363834",
"0.6354104",
"0.6345296",
"0.6343771",
"0.6343771",
"0.6314289",
"0.6281258",
"0.6269364",
"0.6265466",
"0.6261672",
"0.62480664",
"0.62444127",
"0.6209676",
"0.61848885",... | 0.7178461 | 0 |
Returns a function that takes a row that can be indexed by positions which returns a new row with all of the values cast to schema types. | def caster(self):
from ambry.transform import CasterTransformBuilder
bdr = CasterTransformBuilder()
for c in self.columns:
bdr.append(c.name, c.python_type)
return bdr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _type_data(self, row, index):\n typed_row = []\n for i, (entry, entry_type) in enumerate(zip(row, self.column_types)):\n try:\n typed_row.append(entry_type(entry))\n except ValueError:\n if (entry_type == int or entry_type == float) and self.mis... | [
"0.65763265",
"0.6544125",
"0.6396888",
"0.63218826",
"0.62765074",
"0.61402804",
"0.6127959",
"0.59268403",
"0.5848075",
"0.5833918",
"0.58321005",
"0.5769623",
"0.56691206",
"0.5616628",
"0.5576541",
"0.55526406",
"0.55392474",
"0.55112904",
"0.5507856",
"0.5482725",
"0.542... | 0.0 | -1 |
Return this partition information as a PartitionId. | def identity(self):
from sqlalchemy.orm import object_session
from identity import PartitionIdentity
if self.dataset is None:
# The relationship will be null until the object is committed
s = object_session(self)
ds = s.query(Dataset).filter(Dataset.id_ == s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def partition_id(self) -> 'outputs.PreventionJobTriggerInspectJobStorageConfigDatastoreOptionsPartitionId':\n return pulumi.get(self, \"partition_id\")",
"def partition_key(self) -> str:\n return pulumi.get(self, \"partition_key\")",
"def partid(self):\n return self._part_id",
"def parti... | [
"0.8057328",
"0.7390952",
"0.70321757",
"0.69646144",
"0.687686",
"0.68489003",
"0.6811906",
"0.67210966",
"0.66453713",
"0.6592296",
"0.65861815",
"0.6463898",
"0.63655233",
"0.62711203",
"0.62711203",
"0.62418884",
"0.62289023",
"0.6222005",
"0.6220053",
"0.6220053",
"0.621... | 0.63677907 | 12 |
Add a statistics records for a column of a table in the partition. | def add_stat(self, c_vid, stats):
from sqlalchemy.orm.session import Session
# Names that come from the Pandas describe() method
stat_map = {'25%': 'p25', '50%': 'p50', '75%': 'p75'}
stats = {stat_map.get(k, k): v for k, v in stats.items()}
cs = ColumnStat(p_vid=self.vid, c_v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_statistics(self, stat_col):\n self.module.add_statistics(stat_col)",
"def add_statistics(self, stat_col):\n # Those will be displayed.\n stat_col.add_statistics(self.key_precision, '{:05.4f}')\n stat_col.add_statistics(self.key_recall, '{:05.4f}')\n stat_col.add_statist... | [
"0.7453789",
"0.657431",
"0.62925833",
"0.608663",
"0.59540206",
"0.59242326",
"0.5804326",
"0.5665088",
"0.56510043",
"0.5571038",
"0.5552709",
"0.5514976",
"0.5467411",
"0.5466439",
"0.54530895",
"0.5405476",
"0.53823245",
"0.5334818",
"0.531649",
"0.53151524",
"0.5309299",... | 0.57129765 | 7 |
event.listen method for Sqlalchemy to set the sequence for this object and create an ObjectNumber value for the id_ | def before_insert(mapper, conn, target):
from identity import Identity
if target.sequence_id is None:
# These records can be added in an multi-process environment, we
# we need exclusive locking here, where we don't for other sequence
# ids.
conn.execute... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id_trigger():\n\tcur = connection.cursor()\n\tcur.execute(\"\"\"\t\n\t\t\t\tCREATE SEQUENCE SANS_SEQ\n\t\t\t\tSTART WITH 1\"\"\")\n\n\tcur.execute(\"\"\"CREATE OR REPLACE TRIGGER SANS_TRG\n\t\t\t\tBEFORE INSERT ON sansanito\n\t\t\t\tFOR EACH ROW\n\t\t\t\tBEGIN\n\t\t\t\tSELECT SANS_SEQ.NEXTVAL\n\t\t\t\tINTO :ne... | [
"0.6049726",
"0.5995905",
"0.59451574",
"0.5942902",
"0.59048593",
"0.5884814",
"0.5861468",
"0.5860749",
"0.58605987",
"0.58384526",
"0.5797676",
"0.5797638",
"0.5797371",
"0.5773382",
"0.56826967",
"0.56655765",
"0.5663389",
"0.56532145",
"0.5622313",
"0.5607789",
"0.560054... | 0.53486884 | 53 |
Set the column id number based on the table number and the sequence id for the column. | def before_update(mapper, conn, target):
if not target.id_:
dataset = ObjectNumber.parse(target.d_id)
target.id_ = str(PartitionNumber(dataset, target.sequence_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_number(self, column_number):\n\n self._column_number = column_number",
"def setColumn(self, column_number, column):\n self.data[column_number] = column\n return",
"def before_insert(mapper, conn, target):\n\n #from identity import ObjectNumber\n #assert not target.... | [
"0.58510375",
"0.5788721",
"0.5742054",
"0.57346386",
"0.5689572",
"0.565299",
"0.5553579",
"0.5550638",
"0.5493455",
"0.5435904",
"0.5378825",
"0.5372855",
"0.5314855",
"0.5296818",
"0.5288099",
"0.52803075",
"0.5254223",
"0.52493805",
"0.5244955",
"0.5218803",
"0.52047116",... | 0.48725554 | 74 |
Copy another files properties into this one. | def update(self, f):
for p in self.__mapper__.attrs:
if p.key == 'oid':
continue
try:
setattr(self, p.key, getattr(f, p.key))
except AttributeError:
# The dict() method copies data property values into the main dict,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self, src_path: str, tgt_path: str) -> None:",
"def _copy_file ( self, source, dest ):\n return",
"def mv_properties(self):\n f = '/coretemp/coretemp.properties'\n b = os.getcwd()\n shutil.copy2(b+f, '/etc/')",
"def override_from_folder(self, other: ItemVariant) -> None:\n ... | [
"0.6303038",
"0.62008184",
"0.59884304",
"0.5814487",
"0.57969534",
"0.5765706",
"0.57573634",
"0.57371336",
"0.57340986",
"0.57030267",
"0.56705135",
"0.56646675",
"0.56646675",
"0.56646675",
"0.56429267",
"0.563187",
"0.5629152",
"0.5626361",
"0.5608226",
"0.55912346",
"0.5... | 0.0 | -1 |
Like dict, but does not move data items into the top level. | def record_dict(self):
return {p.key: getattr(self, p.key) for p in self.__mapper__.attrs} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _full_mapping(self, data):\r\n x = self._empty_mapping()\r\n for key, value in data.items():\r\n x[key] = value\r\n return x",
"def dict(self) -> Dict:\r\n return super().dict()",
"def dict(self) -> Dict:\r\n return super().dict()",
"def inverse_update(self, ... | [
"0.5949598",
"0.5895312",
"0.5895312",
"0.5807073",
"0.5780093",
"0.57786447",
"0.5778516",
"0.5768783",
"0.5755319",
"0.5736754",
"0.57298326",
"0.5649894",
"0.56043136",
"0.5580945",
"0.5555295",
"0.55545205",
"0.5523736",
"0.5523032",
"0.5519638",
"0.54896504",
"0.54883295... | 0.0 | -1 |
Like record_dict, but prefixes all of the keys with 'f_', so it can be used in inserts. | def insertable_dict(self):
# .strip('_') is for type_
return {
'f_' +
p.key.strip('_'): getattr(
self,
p.key) for p in self.__mapper__.attrs} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_to_dict(f_record, key_name: str):\n return_dict = {}\n for record in f_record:\n key = ''\n for f, v in record.items():\n if f == key_name:\n key = v\n else:\n try:\n return_dict[key].update({f: v})\n ... | [
"0.6524796",
"0.6171926",
"0.5934656",
"0.5526384",
"0.5459289",
"0.54094034",
"0.537647",
"0.5306002",
"0.5289019",
"0.5262894",
"0.52101314",
"0.5185907",
"0.50864",
"0.50856215",
"0.507204",
"0.50605714",
"0.5039643",
"0.503194",
"0.50160664",
"0.50160664",
"0.49792796",
... | 0.57374907 | 3 |
Set the column id number based on the table number and the sequence id for the column. | def before_update(mapper, conn, target):
assert bool(target.ref), "File.ref can't be null (before_update)" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_number(self, column_number):\n\n self._column_number = column_number",
"def setColumn(self, column_number, column):\n self.data[column_number] = column\n return",
"def before_insert(mapper, conn, target):\n\n #from identity import ObjectNumber\n #assert not target.... | [
"0.58510375",
"0.5788721",
"0.5742054",
"0.57346386",
"0.5689572",
"0.565299",
"0.5553579",
"0.5550638",
"0.5493455",
"0.5435904",
"0.5378825",
"0.5372855",
"0.5314855",
"0.5296818",
"0.5288099",
"0.52803075",
"0.5254223",
"0.52493805",
"0.5244955",
"0.5218803",
"0.52047116",... | 0.0 | -1 |
Add new features to data | def new_features(df):
print("Add new features ...")
# distinguish Spring, Fall and pregnant females (don't care about juvenilles/unknown)
df["gender_plus"] = df["Gender"]
df.loc[df.Gravid, "gender_plus"] = "f_gra"
df["gender_seasons"] = df["Gender"]
df.loc[df.Gravid, "gender_seasons"] = "f_gra"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_feature(self, feat: Feature) -> None:\n self.data_features.append(feat)",
"def add_feature(self, feature):\n self.features += [feature]\n for stock in self.stocks:\n feature(self.stock_data[stock])",
"def features(self, features):\n\n self._features = features",
... | [
"0.8017567",
"0.72391254",
"0.7115596",
"0.7038888",
"0.70185196",
"0.6979686",
"0.68487906",
"0.67938554",
"0.67895097",
"0.6775989",
"0.6755086",
"0.6746426",
"0.67332476",
"0.67282385",
"0.668105",
"0.6665732",
"0.66464734",
"0.6642401",
"0.6623752",
"0.6611532",
"0.659047... | 0.59399587 | 71 |
Create new fields under Item using Custom Field. | def add_new_item_field(*fields, **keywords):
for field in fields:
print "Creating {0} custom field...".format(field)
doc = frappe.get_doc({
"doctype": "Custom Field",
"dt": "Item",
"fieldtype": "Data",
"label": field,
"insert_after": keywo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, field_create_information):\n field = Field.create_field_from_type(self.context, field_create_information)\n self.add_child(field)\n qry = CreateEntityQuery(self, field, field)\n self.context.add_query(qry)\n return field",
"def __createField(self, field):\n ... | [
"0.6731207",
"0.65036666",
"0.63113326",
"0.6303203",
"0.6252452",
"0.6211109",
"0.61917996",
"0.60896796",
"0.60567904",
"0.6042853",
"0.6004768",
"0.5927914",
"0.5907266",
"0.5865502",
"0.58608884",
"0.58579487",
"0.58533096",
"0.5780834",
"0.577232",
"0.5770017",
"0.574490... | 0.8216481 | 0 |
Checking for white 220 is the threshold 0.8 is the tolerance level | def check_for_white(img):
return white_percentage(img, 220, 0.8) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threshold(self, value):\r\n threshold = 0.5\r\n if value >= threshold:\r\n return 1\r\n else:\r\n return 0",
"def check_if_white_back_black_edge(pred):\n values = np.unique(pred)\n # print(values)\n\n # check if binary\n if len(values) > 2:\n print(\"Your prediction ... | [
"0.67174834",
"0.6487796",
"0.6463961",
"0.6462622",
"0.6449646",
"0.64339715",
"0.6431686",
"0.6416966",
"0.6413505",
"0.6399163",
"0.6366602",
"0.6365009",
"0.63525826",
"0.63525826",
"0.6338424",
"0.6333677",
"0.6312592",
"0.62757385",
"0.6274855",
"0.62545544",
"0.6245186... | 0.74915415 | 1 |
This is a helper method for constructing the transitions probability table. | def transitions(player1_row, player1_column, player2_row, player2_column, player1_possession, player1_action, player2_action):
s = (player1_row, player1_column, player2_row, player2_column, player1_possession)
transitions = []
# Case: Player 1 goes first
next_s, collision = SoccerEnv.r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_transition_probs(self):\n n = len(self.speakers) # TODO why this line ???\n transitions = np.random.randint(5, size=(n, n)) + 1\n transitions += transitions.transpose()\n for i in range(0, math.floor(n / 2)):\n s1 = np.random.randint(n)\n s2 = np.random.r... | [
"0.7122934",
"0.6940506",
"0.66394025",
"0.63094825",
"0.6229575",
"0.6163949",
"0.6124621",
"0.61116207",
"0.6067541",
"0.6034366",
"0.6034286",
"0.6016178",
"0.60043514",
"0.5994777",
"0.5920206",
"0.5917823",
"0.5914002",
"0.59012115",
"0.58852696",
"0.58769065",
"0.587309... | 0.0 | -1 |
dice is a tuple of integers that represent the user's selected dice pulled out from current roll | def calculate_score(dice):
# version_1
if len(dice) > 6:
raise Exception("Cheating Cheater!")
counts = Counter(dice)
if len(counts) == 6:
return 1500
if len(counts) == 3 and all(val == 2 for val in counts.values()):
return 1500
sco... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roll_dice():\n die1 = random.randrange(1, 7)\n die2 = random.randrange(1, 7)\n return (die1, die2) # pack die face values into a tuple",
"def reroll_selected_dice(selected_dice, yatzy_dice):\n for die in selected_dice:\n yatzy_dice[die] = random_die()",
"def roll_dice(self):\n se... | [
"0.7343362",
"0.72463536",
"0.7170235",
"0.706693",
"0.70521915",
"0.7034558",
"0.70005524",
"0.6990264",
"0.6988319",
"0.6976953",
"0.69347584",
"0.69319385",
"0.6905791",
"0.6895495",
"0.68885046",
"0.6874106",
"0.6873275",
"0.68451285",
"0.68268466",
"0.6805733",
"0.675994... | 0.0 | -1 |
Root mean squared error | def rmse(y_hat, y):
if type(y) == list:
pass
else:
y = y.values.tolist()
m = len(y)
sum = 0
for i in range(m):
sum += ((y_hat[i] - y[i]) ** 2 / m)
error = np.sqrt(sum)
return error | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_mean_squared_error(y_true, y_pred):\n return sm.mean_squared_error(y_true, y_pred)**0.5",
"def root_mean_square_value( values ):\n return ma.sqrt(mean_square_value( values ))",
"def calculate_mean_squared_error(self, X, y):\n mserror = 0\n results = self.predict(X)\n \n ... | [
"0.77601796",
"0.7505934",
"0.7417688",
"0.7356519",
"0.72419465",
"0.7076398",
"0.7058924",
"0.70194316",
"0.6937933",
"0.68373495",
"0.6781214",
"0.6781214",
"0.6753893",
"0.6739606",
"0.67230475",
"0.6708266",
"0.66623455",
"0.66586834",
"0.6654446",
"0.6626972",
"0.659908... | 0.60839504 | 85 |
Initialize a new FRDHeader Object. | def __init__(self, in_file=None, code=None):
self.key = 1
self.code = code
self.string = None
if in_file is not None:
self._read(in_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_from_header(self, hdr, nofn=False):\n\n global filtfn, fmtch, ftypes\n\n self.hdr = hdr\n getwcs = False\n\n try:\n self.target = hdr['OBJECT']\n except KeyError:\n pass\n\n for d in ('DATE-OBS', 'DATE', '_ATE'):\n try:\n ... | [
"0.6638182",
"0.644817",
"0.6335222",
"0.6328656",
"0.62861335",
"0.6223387",
"0.6128595",
"0.6094297",
"0.6089856",
"0.60876995",
"0.60872805",
"0.6075808",
"0.60325027",
"0.5998846",
"0.5998846",
"0.5979206",
"0.597892",
"0.5933664",
"0.5932955",
"0.59278345",
"0.58002377",... | 0.0 | -1 |
Read values for this FRDHeader Object from File in_file. | def _read(self, in_file):
self.string = in_file.readline().decode().strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read(self, in_file):\n in_file.read(18) # pad bytes\n self.numnod = int(in_file.read(12))\n in_file.read(37) # pad bytes\n self.format = int(in_file.read(1))\n in_file.read(1) # eol\n self.nodes = []\n\n for _ in range(self.numnod):\n node = FRDNo... | [
"0.69430035",
"0.645093",
"0.6314587",
"0.6279942",
"0.6238229",
"0.60260874",
"0.60183823",
"0.6014261",
"0.59252244",
"0.58921665",
"0.5889549",
"0.58708227",
"0.585829",
"0.58535284",
"0.58466804",
"0.57875276",
"0.5758051",
"0.5743577",
"0.57356155",
"0.5729687",
"0.57261... | 0.6083438 | 5 |
Initialize a new, empty Node Object. | def __init__(self):
self.number = None
self.pos = None
self.key = -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.root = Node(None)",
"def __init__(self):\n self.root = self.Node(None)",
"def __init__(self):\n self.root = Node('')",
"def __init__(self):\n self.root = Node(\"\")",
"def __init__(self):\n self.root = Node(\"\")",
"def __init__(self):\n ... | [
"0.81817526",
"0.81447303",
"0.8005726",
"0.7890686",
"0.7890686",
"0.78388584",
"0.7789606",
"0.77264416",
"0.76918375",
"0.76918375",
"0.76918375",
"0.7667791",
"0.7658282",
"0.7534381",
"0.7456405",
"0.7389766",
"0.7318487",
"0.73128605",
"0.73117876",
"0.7273617",
"0.7251... | 0.0 | -1 |
Initialize a new FRDNodeBlock Object. | def __init__(self, in_file=None):
self.key = 2
self.code = 'C'
self.numnod = None
self.format = None
self.nodes = []
if in_file is not None:
self._read(in_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, node_identifier):\n\t\tself.blockchain = bc.Blockchain(node_identifier)\n\t\tself.BUFFER_MAX_LEN = 20\n\t\tself.MINE_REWARD = 10\n\t\tself.node_identifier = node_identifier",
"def __init__(self, public_key, node_id):\n # Our starting block for the blockchain\n genesis_block = Blo... | [
"0.68633485",
"0.635676",
"0.6279823",
"0.62676376",
"0.624351",
"0.6088152",
"0.60277176",
"0.58723724",
"0.5871171",
"0.5861737",
"0.5832285",
"0.5820672",
"0.580619",
"0.5786449",
"0.5770142",
"0.57678574",
"0.5744416",
"0.5733594",
"0.572058",
"0.56931716",
"0.5689686",
... | 0.0 | -1 |
Read values for this FRDNodeBlock Object from File in_file. | def _read(self, in_file):
in_file.read(18) # pad bytes
self.numnod = int(in_file.read(12))
in_file.read(37) # pad bytes
self.format = int(in_file.read(1))
in_file.read(1) # eol
self.nodes = []
for _ in range(self.numnod):
node = FRDNode()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read (self, file):\n\t\tself.unpack (file.read (self.size()))",
"def _read(self, in_file):\n #\n # I know this function is long, but the FRD block is long as well...\n # Splitting this into multiple functions would not help in my opinion.\n # Therefore -> shut up pylint\n #... | [
"0.64550364",
"0.64484376",
"0.6424904",
"0.6268296",
"0.61367387",
"0.6080603",
"0.5937796",
"0.5892623",
"0.5884091",
"0.5808201",
"0.5802144",
"0.5770803",
"0.57474285",
"0.57171625",
"0.5675041",
"0.5671114",
"0.5668935",
"0.565586",
"0.56404734",
"0.5631533",
"0.56228155... | 0.7449321 | 0 |
Write values for this FRDNodeBlock Object to File out_file. | def _write(self, out_file):
out_file.write(' '.encode()) # pad byte
out_file.write('{:4d}'.format(self.key).encode())
out_file.write(self.code.encode())
out_file.write((' '*18).encode()) # pad bytes
out_file.write('{:12d}'.format(self.numnod).encode())
out_file.write(('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, values, file_obj, format=None):\n pass",
"def writeto(self, fileout):\n \n dump_pkl(self.data, fileout)",
"def save_elem_file(self, output):\n with open(output, 'wb') as fid:\n self._write_elem_header(fid)\n self._write_nodes(fid)\n s... | [
"0.6591418",
"0.64783424",
"0.6462935",
"0.6330725",
"0.62985307",
"0.61702406",
"0.6119897",
"0.60821617",
"0.5991285",
"0.59766537",
"0.59522337",
"0.5909448",
"0.5902016",
"0.59000134",
"0.5897125",
"0.5889185",
"0.58372414",
"0.58228594",
"0.5813089",
"0.5809512",
"0.5777... | 0.6387504 | 3 |
Initialize a new, empty Element Object. | def __init__(self):
self.number = None
self.nodes = []
self.type = None
self.group = None
self.material = None
self.key = -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.elementName = \"\"\n self.elementText = \"\"\n self.attrib = {}\n self.xml = \"\"",
"def __init__(self):\n self.elementName=\"\"\n self.elementText=\"\"\n self.attrib={}\n self.xml=\"\"",
"def __init__(self):\n self.eleme... | [
"0.77045256",
"0.7549686",
"0.7163453",
"0.7132002",
"0.7103204",
"0.70793086",
"0.70757264",
"0.68185246",
"0.6796506",
"0.67779833",
"0.67506087",
"0.6749332",
"0.67091495",
"0.66926855",
"0.66815424",
"0.6660955",
"0.66371644",
"0.6599562",
"0.65991473",
"0.657103",
"0.656... | 0.0 | -1 |
Initialize a new FRDElemBlock Object. | def __init__(self, in_file=None):
self.key = 3
self.code = 'C'
self.numelem = None
self.format = None
self.elems = []
if in_file is not None:
self._read(in_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n\n pyxel.init(windowWidth, windowHeight)\n\n # generates randomly ordered list of [0, 1, 2, 3, 4, 5, 6, 7]\n self.bag = sample(list(range(7)), 7)\n\n # generates a block from last element of self.bag into self.blocks\n self.block = Block(blockData[self.bag.po... | [
"0.6948698",
"0.64371574",
"0.6058388",
"0.60476387",
"0.6040565",
"0.588369",
"0.5882288",
"0.5821484",
"0.5820389",
"0.5816653",
"0.58090854",
"0.5806304",
"0.5804953",
"0.579172",
"0.57610935",
"0.57541573",
"0.57521653",
"0.5744387",
"0.57340753",
"0.57297313",
"0.5726398... | 0.0 | -1 |
Read values for this FRDElemBlock Object from File in_file. | def _read(self, in_file):
in_file.read(18) # pad bytes
self.numelem = int(in_file.read(12))
in_file.read(37) # pad bytes
self.format = int(in_file.read(1))
in_file.read(1) # eol
self.elems = []
for _ in range(self.numelem):
elem = FRDElem()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read(self, in_file):\n #\n # I know this function is long, but the FRD block is long as well...\n # Splitting this into multiple functions would not help in my opinion.\n # Therefore -> shut up pylint\n # pylint: disable=too-many-branches\n # pylint: disable=too-many-... | [
"0.71370447",
"0.71107733",
"0.66957563",
"0.64064467",
"0.6363881",
"0.63242257",
"0.6193135",
"0.6170903",
"0.6128073",
"0.6073713",
"0.60608464",
"0.603351",
"0.59812",
"0.5954918",
"0.59542364",
"0.5926478",
"0.58932245",
"0.58608294",
"0.58608294",
"0.5852376",
"0.584663... | 0.67943084 | 2 |
Write values for this FRDElemBlock Object to File out_file. | def _write(self, out_file):
out_file.write(' '.encode()) # pad byte
out_file.write('{:4d}'.format(self.key).encode())
out_file.write(self.code.encode())
out_file.write((' '*18).encode()) # pad bytes
out_file.write('{:12d}'.format(self.numelem).encode())
out_file.write((... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_elem_file(self, output):\n with open(output, 'wb') as fid:\n self._write_elem_header(fid)\n self._write_nodes(fid)\n self._write_elements(fid)\n self._write_neighbors(fid)",
"def write(self, values, file_obj, format=None):\n pass",
"def to_file... | [
"0.6919973",
"0.68080693",
"0.66649777",
"0.6653902",
"0.66312677",
"0.6519394",
"0.6513908",
"0.6489514",
"0.63893247",
"0.63631946",
"0.6332206",
"0.6309536",
"0.6268099",
"0.6263838",
"0.62601405",
"0.62456125",
"0.62347865",
"0.62206966",
"0.62059945",
"0.61989707",
"0.61... | 0.6477133 | 8 |
Initialize a new, empty FRDEntity Object. | def __init__(self):
self.key = None
self.name = None
self.menu = None
self.ictype = None
self.icind1 = None
self.icind2 = None
self.iexist = None
self.icname = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init(self):\n # IMPORTANT: create a new gob database model entry for this object\n self.gobify()",
"def __init__(self, entity):\n self.entity = entity\n self.entityId = entity.id\n self.graph = entity.graph",
"def __init__(self):\n\n # declare db-internal attribut... | [
"0.65820634",
"0.6275472",
"0.61604565",
"0.61220497",
"0.60016924",
"0.5957472",
"0.59306866",
"0.5929827",
"0.59204507",
"0.5916811",
"0.5875814",
"0.585855",
"0.58508474",
"0.5819042",
"0.57957417",
"0.5745292",
"0.5735321",
"0.56955427",
"0.5695075",
"0.5680392",
"0.56768... | 0.0 | -1 |
Initialize a new, empty FRDNodeResult Object. | def __init__(self):
self.node = None
self.data = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, node_id=None, status=None, start=None, end=None, error=None, error_code=None, progress=None, stats=None, out=None): # noqa: E501 # noqa: E501\n self._node_id = None\n self._status = None\n self._start = None\n self._end = None\n self._error = None\n se... | [
"0.5605116",
"0.5539629",
"0.54903704",
"0.54672277",
"0.5418657",
"0.5374813",
"0.5334075",
"0.5329896",
"0.5311689",
"0.5285782",
"0.5279636",
"0.5247463",
"0.52471167",
"0.51801866",
"0.5131627",
"0.50988954",
"0.50881505",
"0.50881505",
"0.50859207",
"0.5028726",
"0.50262... | 0.5184914 | 13 |
Initialize a new FRDResultBlock Object. | def __init__(self, in_file=None):
self.key = 100
self.code = 'C'
self.setname = None
self.value = None
self.numnod = None
self.text = None
self.ictype = None
self.numstep = None
self.analys = None
self.format = None
self.name = None... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dataset, block):\n super().__init__(dataset, block)\n\n # these are results for display in the Tab\n self.freq_summed = None\n self.freq_current = None\n\n self.reset_results_arrays()",
"def __init__(self, result_code=None, message=None, value=None): # noqa... | [
"0.5401331",
"0.539294",
"0.5232692",
"0.52209604",
"0.5200635",
"0.5200635",
"0.51396316",
"0.51370955",
"0.5079849",
"0.5054977",
"0.5013498",
"0.49825",
"0.49679428",
"0.4955351",
"0.49491957",
"0.49361867",
"0.49157205",
"0.4913417",
"0.4884147",
"0.4884147",
"0.4883492",... | 0.0 | -1 |
Read values for this FRDResultBlock Object from File in_file. | def _read(self, in_file):
#
# I know this function is long, but the FRD block is long as well...
# Splitting this into multiple functions would not help in my opinion.
# Therefore -> shut up pylint
# pylint: disable=too-many-branches
# pylint: disable=too-many-statements
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read(self, in_file):\n in_file.read(18) # pad bytes\n self.numnod = int(in_file.read(12))\n in_file.read(37) # pad bytes\n self.format = int(in_file.read(1))\n in_file.read(1) # eol\n self.nodes = []\n\n for _ in range(self.numnod):\n node = FRDNo... | [
"0.6502384",
"0.6426364",
"0.6385165",
"0.6195763",
"0.61836416",
"0.6074389",
"0.59815764",
"0.5937535",
"0.5821172",
"0.579809",
"0.57559633",
"0.57559633",
"0.5739333",
"0.5734783",
"0.57300544",
"0.5699614",
"0.56957716",
"0.5684997",
"0.5681445",
"0.5677181",
"0.56592095... | 0.6228577 | 3 |
Write values for this FRDResultBlock Object to File out_file. | def _write(self, out_file):
#
# I know this function is long, but the FRD block is long as well...
# Splitting this into multiple functions would not help in my opinion.
# Therefore -> shut up pylint
# pylint: disable=too-many-branches
# pylint: disable=too-many-statement... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_result(self, file_name):\n f = file(file_name, \"w\")\n f.write(self.m_result)\n f.close()",
"def to_file(self, outfile):\n\n with open(outfile, \"w\") as outf:\n outf.write(self.to_string())",
"def write(self, values, file_obj, format=None):\n pass",
"... | [
"0.6410371",
"0.634919",
"0.63408077",
"0.62029773",
"0.6154219",
"0.60774153",
"0.6032174",
"0.6001302",
"0.5977394",
"0.5949576",
"0.59400624",
"0.5929911",
"0.5911469",
"0.590188",
"0.587897",
"0.5862855",
"0.5838318",
"0.5788639",
"0.5780187",
"0.57633805",
"0.5731983",
... | 0.56008756 | 36 |
Initialize a new FRDFile Object. | def __init__(self, file_name=None):
self.blocks = []
self.headers = []
self.node_block = None
self.elem_block = None
self.result_blocks = []
self.file_name = file_name
if file_name is not None:
self.load(file_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, fileobject, filename=''):\n self.fh = fileobject\n self.filename = filename\n self.header = {}\n self.data = None\n self._data_corr = None\n self._bo = ''",
"def __init__(self, file_object):\n # Read object or file.\n if not hasattr(file_... | [
"0.70592713",
"0.6694294",
"0.6642081",
"0.6626612",
"0.6544814",
"0.6490792",
"0.640771",
"0.6362197",
"0.63094985",
"0.63040966",
"0.62799966",
"0.627403",
"0.6247114",
"0.62336445",
"0.62233293",
"0.61664134",
"0.61640054",
"0.6158735",
"0.6144715",
"0.6142226",
"0.6136255... | 0.0 | -1 |
Read content of .frd file at file_name into this FRDFile object. | def load(self, file_name):
self.file_name = file_name
with open(file_name, 'rb') as in_file:
eof = (in_file.read(1) == b'')
while not eof:
key = int(in_file.read(4))
code = in_file.read(1).decode()
block = None
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self, file_name):\n self.file_name = file_name\n self.frd = FRDFile(file_name)\n self._build_node_kon()\n self._build_step_idx()",
"def read_file(self, file_name):\n f = file(file_name, \"r\")\n temp = f.read()\n f.close()",
"def read_file(self, file_na... | [
"0.67018384",
"0.6318946",
"0.63110256",
"0.6101249",
"0.60530573",
"0.6052063",
"0.59483385",
"0.59376913",
"0.58921003",
"0.58904785",
"0.58904785",
"0.58143395",
"0.57983696",
"0.5744066",
"0.5725705",
"0.57159245",
"0.5706403",
"0.5704132",
"0.56743497",
"0.5661764",
"0.5... | 0.6547037 | 1 |
Save/Overwrite the .frd file at (previously) specified location. | def save(self, file_name=None):
if file_name is not None:
self.file_name = file_name
if self.file_name is not None:
with open(file_name, 'wb') as out_file:
for block in self.blocks:
# Rather not have the write methods public,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, fname):\n pass",
"def save(self, file_name=None, as_copy=False):\n if self.frd is not None:\n if file_name is not None:\n self.frd.save(file_name)\n if as_copy:\n self.frd.file_name = self.file_name\n else:\n ... | [
"0.6310442",
"0.6156046",
"0.6060814",
"0.593852",
"0.5908818",
"0.59070665",
"0.58914673",
"0.58629125",
"0.5793969",
"0.5783339",
"0.578081",
"0.57623756",
"0.57549787",
"0.57502997",
"0.57502997",
"0.5750211",
"0.5750211",
"0.5750211",
"0.57404494",
"0.5704946",
"0.5700524... | 0.0 | -1 |
Initialize a new FRDParser Object. | def __init__(self, file_name=None):
self.file_name = file_name
self.frd = None
self._steps = []
if file_name is not None:
self.load(file_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n\n self.prim_parser = parser.Parser()",
"def __init__(self):\n this = _libsbml.new_RDFAnnotationParser()\n try: self.this.append(this)\n except: self.this = this",
"def __init__(self):\n\t\tself.parsed = False\n\t\tdir_path = os.path.dirname(os.path.realpath(__f... | [
"0.6579444",
"0.6568029",
"0.64635086",
"0.6460575",
"0.6395747",
"0.6334298",
"0.6265272",
"0.6254834",
"0.61850774",
"0.6170244",
"0.6133477",
"0.61251074",
"0.60753757",
"0.6068975",
"0.6027146",
"0.6026113",
"0.59403074",
"0.5938747",
"0.5917108",
"0.591067",
"0.59033746"... | 0.0 | -1 |
Load a .frd file into the parser. | def load(self, file_name):
self.file_name = file_name
self.frd = FRDFile(file_name)
self._build_node_kon()
self._build_step_idx() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self, filename=None):\n importer = aspecd.io.AdfImporter()\n importer.source = filename\n importer.import_into(self)",
"def parse_from_file (path):\n with open(path) as f:\n return NFFG.parse(f.read())",
"def parse_data(fp):\n pass",
"def parser(path):\n\t\n\tdata = A... | [
"0.5935266",
"0.59271276",
"0.5809597",
"0.5808671",
"0.57380855",
"0.570663",
"0.56843936",
"0.5647207",
"0.56359386",
"0.5616617",
"0.55926186",
"0.55878085",
"0.5581737",
"0.55808693",
"0.557875",
"0.55486715",
"0.55269253",
"0.5493946",
"0.54497474",
"0.5449209",
"0.54446... | 0.6210889 | 0 |
Saves/Overwrites the .frd file in the parser. | def save(self, file_name=None, as_copy=False):
if self.frd is not None:
if file_name is not None:
self.frd.save(file_name)
if as_copy:
self.frd.file_name = self.file_name
else:
self.frd.save(self.file_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self):\n file = open(self.path, 'w')\n self.parser.write(file)\n file.close()",
"def save(self):\n with open(self.fkit.path) as fp:\n for processor in self._field.processors:\n fp = processor(fp)\n storage = FileStorage(fp)\n st... | [
"0.64988834",
"0.6217683",
"0.61250305",
"0.595477",
"0.59500873",
"0.57399184",
"0.5704593",
"0.57016116",
"0.5572399",
"0.5563962",
"0.5515632",
"0.551169",
"0.5471263",
"0.54683167",
"0.54669386",
"0.54650617",
"0.5435051",
"0.542817",
"0.5419484",
"0.5413624",
"0.54072523... | 0.55903727 | 8 |
Get a (filtered) list of FRDResultBlock objects in the .frd File. | def get_results_block(self, names=None, steps=None):
if steps is not None:
steps = self._confirm_step_selection(steps)
r_blocks = self.frd.result_blocks[:]
i_start = len(r_blocks) - 1
i_end = -1
for idx in range(i_start, i_end, -1):
r_block = r_blocks[id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def read_block_types(self) -> List[BlockType]:\n response = await self._client.post(\"/block_types/filter\", json={})\n return pydantic.parse_obj_as(List[BlockType], response.json())",
"def getCbsdRecords(self, filters=[]):\n return self._getRecords('cbsd', filters)",
"async def read_blo... | [
"0.5660276",
"0.5650933",
"0.5501279",
"0.54004866",
"0.5396059",
"0.5343954",
"0.523452",
"0.5204076",
"0.5151139",
"0.50949097",
"0.5079294",
"0.50541824",
"0.5029018",
"0.50061685",
"0.49820152",
"0.49646333",
"0.4959345",
"0.4951458",
"0.49265814",
"0.49245754",
"0.488375... | 0.5107588 | 9 |
Return time and date of the .frd File as dateTime object. | def get_time_and_date(self):
date_str = ''
time_str = ''
for header in self.frd.headers:
if header.code != 'U':
continue
elif header.string.startswith('DATE'):
date_str = header.string.replace('DATE', '').strip()
elif header.str... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_date(self, file: str) -> date:",
"def get_reference_datetime(file):\n date_string = file.root.discharge1._f_getAttr('reference_datetime')[0]\n ref_date = datetime.datetime.strptime(date_string, '%d-%b-%Y;%H:%M:%S.%f')\n\n return ref_date",
"def fileTime(ft):\n return datetime(1601, 1, ... | [
"0.7005805",
"0.67642593",
"0.63170445",
"0.6281667",
"0.62567914",
"0.6216308",
"0.6198236",
"0.61430544",
"0.6116791",
"0.61078763",
"0.6100694",
"0.6098714",
"0.6086509",
"0.60758436",
"0.6074926",
"0.60441864",
"0.60393834",
"0.6037444",
"0.60246754",
"0.6000636",
"0.5949... | 0.71200657 | 0 |
Get a list of result values in the .frd File for specified nodes. If no name or step is specified, all results are returned in a list ordered by steps and names in order of appearance in the .frd file. Note that the returned list entries are always iterables, even if the result has only one component (e.g. the return v... | def get_results_node(self, number, names=None, steps=None):
results = []
if steps is not None:
steps = self._confirm_step_selection(steps)
for r_block in self.frd.result_blocks:
if names is not None and r_block.name not in names:
continue
eli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getResults():\n return declList",
"def reduce_file_nodes(self, nodes, names=None, steps=None):\n if steps is not None:\n steps = self._confirm_step_selection(steps)\n\n idx_start = len(self.frd.node_block.numnod) - 1\n idx_end = -1\n\n for idx in range(idx_start, idx... | [
"0.5681287",
"0.54788417",
"0.53779167",
"0.5319097",
"0.52856684",
"0.52736264",
"0.5220714",
"0.51983696",
"0.50550765",
"0.5038064",
"0.5021821",
"0.5014237",
"0.4971941",
"0.493412",
"0.49338633",
"0.49247366",
"0.49199513",
"0.49097717",
"0.48912197",
"0.4874564",
"0.485... | 0.660576 | 0 |
Get a list of result values in the .frd File for specified coords. If the given coords do not match a single node, the result is interpolated within the closest element. If no name or step is specified, all results are returned in a list ordered by steps and names in order of appearance in the .frd file. Note that the ... | def get_results_pos(self, pos, names=None, steps=None):
results = []
if steps is not None:
steps = self._confirm_step_selection(steps)
for r_block in self.frd.result_blocks:
if names is not None and r_block.name not in names:
continue
elif st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_results_node(self, number, names=None, steps=None):\n results = []\n\n if steps is not None:\n steps = self._confirm_step_selection(steps)\n\n for r_block in self.frd.result_blocks:\n if names is not None and r_block.name not in names:\n continue\n ... | [
"0.5653371",
"0.55662644",
"0.5507174",
"0.5180463",
"0.51406765",
"0.5003665",
"0.49956143",
"0.48708457",
"0.4850714",
"0.48479825",
"0.48446918",
"0.482175",
"0.48052558",
"0.4792894",
"0.4790502",
"0.4779765",
"0.47455412",
"0.47317955",
"0.47205234",
"0.47185212",
"0.469... | 0.65983754 | 0 |
Peform a given test on a subset of all result values. If the test fails on a node, an AssertionError, showing node, name and step information is raised. | def assert_node_results(self, func, nodes=None, names=None, steps=None):
if steps is not None:
steps = self._confirm_step_selection(steps)
for r_block in self.frd.result_blocks:
if names is not None and r_block.name not in names:
continue
elif steps i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _test(self, **kwargs):\n raise ValueError(\"This function is not available in lazy results evaluation as it would \"\n \"require all pairwise tests to be performed.\")",
"def run_tests():\n def print_result(result, correct):\n if result == correct:\n print(... | [
"0.609516",
"0.5704925",
"0.56402946",
"0.56204367",
"0.5566396",
"0.55041707",
"0.548175",
"0.548175",
"0.5443711",
"0.54336387",
"0.54155505",
"0.54101396",
"0.5401243",
"0.5401163",
"0.5395193",
"0.53657943",
"0.535768",
"0.5350234",
"0.5317045",
"0.5309218",
"0.5298009",
... | 0.6197507 | 0 |
Convert the loaded .frd file to a different storage format. | def convert_format(self, new_format):
if new_format not in [0, 1, 2, 3]:
raise ValueError("Unknown format specified")
inp_format = new_format
if inp_format == 3:
new_format = 2
for block in self.frd.blocks:
if hasattr(block, 'format'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convert(self, filepath):\n raise NotImplementedError()",
"def preprocess_sf(bd, var):\n filepath_svf = f\"team67-ptp/data/{var}.ftr\"\n filepath = bd\n data = feather.read_dataframe(filepath)\n df = data.copy()\n df2 = df[var]\n df2 = df2.to_frame()\n if df2[var].dtype is \"categ... | [
"0.56992745",
"0.55378634",
"0.55097324",
"0.5505084",
"0.5419199",
"0.53168136",
"0.527664",
"0.52127683",
"0.51760536",
"0.51425034",
"0.5105935",
"0.5098017",
"0.5094348",
"0.50735486",
"0.50104237",
"0.50100654",
"0.500842",
"0.4993144",
"0.49657446",
"0.4938456",
"0.4936... | 0.5250901 | 7 |
Reduce the .frd file to only the specified node numbers. Unspecified nodes and their results , as well as all elements and irrelevant parameter headers will be removed. | def reduce_file_nodes(self, nodes, names=None, steps=None):
if steps is not None:
steps = self._confirm_step_selection(steps)
idx_start = len(self.frd.node_block.numnod) - 1
idx_end = -1
for idx in range(idx_start, idx_end, -1):
node = self.frd.node_block.nodes[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce_file_xyz(self, positions, names=None, steps=None):\n if steps is not None:\n steps = self._confirm_step_selection(steps)\n\n new_result_blocks = []\n for r_block in self.frd.result_blocks:\n\n if steps is not None and r_block.numstep not in steps:\n ... | [
"0.4992362",
"0.485108",
"0.48227835",
"0.47917888",
"0.4737131",
"0.47243077",
"0.47234166",
"0.47175255",
"0.46770194",
"0.46455526",
"0.46138802",
"0.4606024",
"0.4602345",
"0.45982596",
"0.45940492",
"0.45859158",
"0.45589364",
"0.45575878",
"0.45548314",
"0.45547643",
"0... | 0.6279778 | 0 |
Reduce the .frd file to only the specified coordinates. Nodes and nodal results not at the coordinates, as well as all elements and irrelevant parameter headers will be removed. If the coordinates are not nodes already, new nodes will be added, with the result data interpolated from existing nodes. | def reduce_file_xyz(self, positions, names=None, steps=None):
if steps is not None:
steps = self._confirm_step_selection(steps)
new_result_blocks = []
for r_block in self.frd.result_blocks:
if steps is not None and r_block.numstep not in steps:
self._rem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reduce_file_nodes(self, nodes, names=None, steps=None):\n if steps is not None:\n steps = self._confirm_step_selection(steps)\n\n idx_start = len(self.frd.node_block.numnod) - 1\n idx_end = -1\n\n for idx in range(idx_start, idx_end, -1):\n node = self.frd.node... | [
"0.5718647",
"0.5148735",
"0.5044131",
"0.49771503",
"0.4973383",
"0.46994126",
"0.46815512",
"0.46652865",
"0.46373084",
"0.46176004",
"0.46161243",
"0.4591282",
"0.45868823",
"0.45721558",
"0.45531732",
"0.4538066",
"0.45342803",
"0.45301354",
"0.45250836",
"0.4520615",
"0.... | 0.6120035 | 0 |
Get component/entity names for the supplied result names. | def get_comp_names(self, names):
names = names[:]
comp_names = {}
for r_block in self.frd.result_blocks:
if r_block.name in names and r_block.name not in comp_names:
comp_names[r_block.name] = []
for ent in r_block.entities:
if ent.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_organism_names(results):\r\n\r\n organism_names = []\r\n\r\n for result in results:\r\n organism_names.append(result)\r\n\r\n return organism_names",
"def get_results(self, case_names, params):\n results = []\n for name in case_names:\n results.append(self.get_res... | [
"0.63385856",
"0.60410285",
"0.5936411",
"0.58623135",
"0.5808179",
"0.57885474",
"0.5764268",
"0.5759296",
"0.5756003",
"0.57452196",
"0.5718865",
"0.5609413",
"0.5596123",
"0.5576773",
"0.5566023",
"0.55454105",
"0.5527062",
"0.5521235",
"0.55142796",
"0.5489114",
"0.548573... | 0.6814703 | 0 |
Insert a user header with the supplied text into the .frd file. | def add_user_header(self, text):
new_header = FRDHeader()
new_header.key = 1
new_header.code = 'U'
new_header.string = text
last_user_idx = -1
last_user_header = self.frd.headers[last_user_idx]
while last_user_header.code != 'U':
last_user_idx -= 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_header(self, text):\n with self.doc:\n h3(text)",
"def insert_header(path: Path, header: str, docx_name: str) -> None:\n content = path.read_text()\n context = {\"docx\": docx_name}\n content = \"\\n\\n\".join((header.format(**context), content))\n path.write_text(content)",... | [
"0.70682687",
"0.6929386",
"0.66683954",
"0.6630516",
"0.629352",
"0.6228307",
"0.6223019",
"0.62177575",
"0.6174613",
"0.61320055",
"0.6083003",
"0.60484314",
"0.6041748",
"0.6036281",
"0.6013078",
"0.60023844",
"0.5999925",
"0.5946964",
"0.593472",
"0.5887463",
"0.58262044"... | 0.8074849 | 0 |
Get the first user header that matches the given prefix. | def get_user_header(self, prefix):
for header in self.frd.headers:
if header.string.startswith(prefix):
return header.string.replace(prefix, '').strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_uri_matching_prefix(xia, prefix):\n\n if xia is not None:\n for uri in xia:\n if uri.startswith(prefix):\n return uri\n return None",
"def GetHeader(header, sample_prefixes):\n if len(sample_prefixes) == 0: return [header]\n else:\n header_items = []\... | [
"0.6507488",
"0.6271171",
"0.5968171",
"0.59664214",
"0.58222866",
"0.57355654",
"0.5670779",
"0.5636987",
"0.55947244",
"0.5565466",
"0.5565466",
"0.5565466",
"0.5559555",
"0.55540806",
"0.55477965",
"0.5546304",
"0.5541036",
"0.5533869",
"0.55178684",
"0.5500421",
"0.549736... | 0.8432813 | 0 |
on_start is called when a Locust start before any task is scheduled Used to generate user specific credentials for testing. | def on_start(self):
# TODO: do the opposite of pop here, cut?
new_user = next(users)
self.user_data = new_user
self.signup()
# self.login() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_start(self):\n admin_user = os.environ['ADMIN_USER']\n admin_password = os.environ['ADMIN_PASSWORD']\n admin_domain_name = os.environ['ADMIN_DOMAIN_NAME']\n admin_project_id = os.environ['ADMIN_PROJECT_ID']\n HEADERS['X-Auth-Token'] = self._get_token(admin_user,\n ... | [
"0.75037843",
"0.7115758",
"0.648172",
"0.648172",
"0.648172",
"0.648172",
"0.63583016",
"0.6277575",
"0.62409043",
"0.6137479",
"0.60776657",
"0.6060888",
"0.60249996",
"0.60188735",
"0.60188735",
"0.60135734",
"0.5901303",
"0.5873579",
"0.58508795",
"0.5831289",
"0.5830979"... | 0.5762986 | 32 |
Load the benchmark results located in the input subfolder | def load_data(input_date: str, skip_iter=0, remove_inf=True, remove_time_zero=True, benchmark="", phases=None) -> pd.DataFrame:
input_path = os.path.join(DEFAULT_RES_DIR, input_date)
# Load results as JSON;
data_dict = {}
for res in os.listdir(input_path):
with open(os.path.join(input_path, res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_results(self):\n self.find_benchmark_directories()\n for (benchmark, producer), result in self.results.items():\n print('Reading results for ' + benchmark + ' ' + producer)\n if not result.directory:\n print('No results found for ' + benchmark + ' ' + pro... | [
"0.73089683",
"0.6628345",
"0.6517706",
"0.63006085",
"0.6267418",
"0.6163222",
"0.6145546",
"0.61124057",
"0.6103304",
"0.6095526",
"0.6005894",
"0.59565485",
"0.59527457",
"0.59484833",
"0.5925158",
"0.5915983",
"0.5915556",
"0.5903471",
"0.5897003",
"0.58925015",
"0.586199... | 0.0 | -1 |
Load the benchmark results located in the input subfolder | def load_data_cuda(input_date: str, skip_iter=0, remove_inf=True, remove_time_zero=True, add_prefetch_as_policy=True) -> pd.DataFrame:
input_path = os.path.join(DEFAULT_RES_DIR, input_date)
# Load results as pd.DataFrames;
data_tmp = []
for f in os.listdir(input_path):
# Parse filename;
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_results(self):\n self.find_benchmark_directories()\n for (benchmark, producer), result in self.results.items():\n print('Reading results for ' + benchmark + ' ' + producer)\n if not result.directory:\n print('No results found for ' + benchmark + ' ' + pro... | [
"0.73089683",
"0.6628345",
"0.6517706",
"0.63006085",
"0.6267418",
"0.6163222",
"0.6145546",
"0.61124057",
"0.6103304",
"0.6095526",
"0.6005894",
"0.59565485",
"0.59527457",
"0.59484833",
"0.5925158",
"0.5915983",
"0.5915556",
"0.5903471",
"0.5897003",
"0.58925015",
"0.586199... | 0.0 | -1 |
Gets package.json info for package_name on npm | def get_package_info(package_name):
r = requests.get(f'https://api.npms.io/v2/search?q={package_name}&size=1')
response_json = r.json()
if 'results' in response_json:
result = response_json['results'][0]
return result['package'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getpackinfo(package_name: str) -> Dict[str, str]:\n\t# execute command\n\tproc = subprocess.Popen(['pip', 'show', package_name], stdout=subprocess.PIPE)\n\tproc.wait()\n\n\t# get and treate return\n\tlines = proc.stdout.read().decode('utf8')\n\tinfo = {}\n\tlines = list(map(lambda inf: inf.split(': '), lines.s... | [
"0.7172648",
"0.6824519",
"0.67997897",
"0.67524683",
"0.6733202",
"0.67256707",
"0.6668096",
"0.6578985",
"0.6556825",
"0.64765173",
"0.6442397",
"0.6345317",
"0.6151867",
"0.6151222",
"0.6085146",
"0.60696775",
"0.60617155",
"0.60091126",
"0.60039485",
"0.5971188",
"0.59132... | 0.73230517 | 0 |
Finds repo url from package.json on npm | def get_repo_url(package_name):
package_info = get_package_info(package_name)
if package_info and package_info.get('links'):
links = package_info['links']
if links.get('repository'):
return links['repository'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_npm_install_url_referenced_package(modules, npm, npm_version, states):\n ret = npm.installed(\n name=\"request/request#v2.88.2\",\n registry=\"https://registry.npmjs.org/\",\n )\n assert ret.result is True\n ret = npm.removed(\n name=\"git://github.com/request/request\",\n... | [
"0.6731666",
"0.67079645",
"0.66061264",
"0.6503107",
"0.64749205",
"0.64322865",
"0.64107394",
"0.6360064",
"0.62021106",
"0.6196629",
"0.61961335",
"0.61955965",
"0.6158084",
"0.60941887",
"0.6052495",
"0.6032884",
"0.5994147",
"0.5987307",
"0.59768474",
"0.5894701",
"0.583... | 0.7634042 | 0 |
Fetches package and version from npmjs.com. Since there is no API to fetch this, we scrape it off the page (not ideal, yes). | def get_most_depended_upon_npm_packages(page):
offset = (page - 1) * 36 # page length is 36
r = requests.get(f'https://www.npmjs.com/browse/depended?offset={offset}')
soup = bs4.BeautifulSoup(r.content, 'html.parser')
sections = soup.find_all('section')
return list(map(_parse_section, sections)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_npm_data_from_purl(purl):\n purl = PackageURL.from_string(purl)\n base_path = \"http://registry.npmjs.org\"\n name = purl.name\n version = purl.version\n api_url = f\"{base_path}/{name}\"\n response = get_response(api_url)\n vcs_data = response.get(\"repository\") or {}\n bugs = res... | [
"0.7092136",
"0.6947501",
"0.6411587",
"0.63694555",
"0.63101745",
"0.6150547",
"0.61432844",
"0.61253875",
"0.60667175",
"0.5961047",
"0.5925132",
"0.5852545",
"0.5850637",
"0.57418424",
"0.56858957",
"0.56325394",
"0.56167185",
"0.55650723",
"0.55539167",
"0.55469894",
"0.5... | 0.64619875 | 2 |
Apply the noise channel to specified qubits of a state `rho`. | def apply_to(self, rho, qubit_indices, *args, **kwargs): # additional functionality e.g. for different ways to define channels may be added here
assert len(qubit_indices) == self.n_qubits
if self.n_qubits == 1:
return apply_single_qubit_map(map_func=self, qubit_index=qubit_indices[0], rho=r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _apply_observation_noise(self, state: RobotState,\n config: RobotGroupConfig):\n if config.sim_observation_noise is None or self.random_state is None:\n return\n\n # Define the noise calculation.\n def noise(value_range: np.ndarray):\n ... | [
"0.6017946",
"0.58513236",
"0.58152527",
"0.57647073",
"0.5672989",
"0.5606827",
"0.5456302",
"0.54271275",
"0.53528816",
"0.53246325",
"0.53246",
"0.53221905",
"0.5287915",
"0.5278017",
"0.52511585",
"0.5244897",
"0.52155817",
"0.5209202",
"0.5127589",
"0.51240385",
"0.50949... | 0.4715519 | 91 |
Hook to ensure object is owned by request.user. | def get_object(self, queryset=None):
result = super(ResultPlot, self).get_object()
if not result.job.owner == self.request.user:
raise Http404("The user {} is not the owner of {}.".format(
self.request.user, result))
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_ownership(self):\n user = self.request.user\n object = self.get_object()\n if object.owned_by(user):\n return True\n else:\n return False",
"def has_object_permission(self, request, view, obj):\n return request.user.id == obj.user_id",
"def has_o... | [
"0.7492899",
"0.7263095",
"0.720622",
"0.715437",
"0.71168154",
"0.7060507",
"0.7052732",
"0.70177627",
"0.7009931",
"0.7006181",
"0.69574875",
"0.6948073",
"0.692198",
"0.6901764",
"0.6897051",
"0.6883162",
"0.68580794",
"0.6827206",
"0.68249476",
"0.6810537",
"0.6810537",
... | 0.0 | -1 |
Text is an array of letter names. | def __init__(self, text):
self.text = text
self.letters = [letters[c] for c in self.text]
self.width = sum(let.width + 1 for let in self.letters)
self._offset = width
self.is_done = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sliptText(text):\n\treturn [char for char in text]",
"def alpha_chars (text):\n for letter in text:\n if letter.isalpha ():\n yield letter",
"def decode(self, text_index):\n texts = []\n for idx, text_idx in enumerate(text_index):\n text = ''\n text_... | [
"0.64200485",
"0.62519914",
"0.62188864",
"0.610214",
"0.5947807",
"0.5887099",
"0.585839",
"0.584361",
"0.5813401",
"0.58005047",
"0.579861",
"0.57970905",
"0.5780962",
"0.5780962",
"0.5780962",
"0.576717",
"0.57570744",
"0.57534766",
"0.5750919",
"0.5732509",
"0.571092",
... | 0.6061835 | 4 |
Step one pixel to the left. | def step(self, delta=1):
self._offset -= delta
if self._offset < -self.width:
self.is_done = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_left(self, step: int = 1) -> None:\n if self.cursor_pos.y == 0:\n self.cursor_pos = Point(self.cursor_pos.x, self.width-step)\n else:\n self.cursor_pos = Point(self.cursor_pos.x, self.cursor_pos.y-step)",
"def shift_left(self):\n self.pointer = (self.pointer - ... | [
"0.7928519",
"0.75478077",
"0.7453782",
"0.7372932",
"0.73297393",
"0.73297393",
"0.72831464",
"0.7276859",
"0.7245116",
"0.7234374",
"0.70816076",
"0.7071769",
"0.7064034",
"0.7015732",
"0.698934",
"0.69884396",
"0.68827",
"0.6871533",
"0.68613535",
"0.68564945",
"0.6773133"... | 0.0 | -1 |
Rounds a percentage value and checks it against a reference value. | def check_compare(change, reference_value):
rounded_change = round(change, 2)
compare_values(reference_value, rounded_change) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value_to_percent(value):\n return ...",
"def percentage(value, arg):\n try:\n percent_value = float( arg )\n if percent_value:\n return round(value / 100 * percent_value, 2)\n except Exception:\n pass\n return ''",
"def rel_value(value, pct):\n return(value*(1... | [
"0.7043765",
"0.67897713",
"0.6642766",
"0.6497637",
"0.64910877",
"0.6461374",
"0.6431763",
"0.6406734",
"0.63966894",
"0.6387158",
"0.63469666",
"0.62840885",
"0.6216531",
"0.62084854",
"0.6196612",
"0.61909807",
"0.61885804",
"0.6185412",
"0.6176981",
"0.61626035",
"0.6158... | 0.58770716 | 46 |
Collects the last price from the output fields and checks whether it is a float larger than zero. | def check_iterate(out_fields):
last_price = out_fields[LAST_PRICE_FLD]
check_float_value(last_price, LAST_PRICE_FLD) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_last_price(market_data):\n print(\"Consultando el último precio\")\n if market_data[\"marketData\"][\"LA\"]:\n last_price = market_data[\"marketData\"][\"LA\"][\"price\"]\n print(\n f\"Último precio operado: ${last_price:,.2f}\".replace('.', ','))\n ... | [
"0.6271355",
"0.5933679",
"0.5800997",
"0.5691686",
"0.5648853",
"0.5623907",
"0.55060756",
"0.5500531",
"0.548454",
"0.54823565",
"0.5472537",
"0.54640615",
"0.5459817",
"0.5458082",
"0.5448156",
"0.54064983",
"0.5397893",
"0.53619856",
"0.5348598",
"0.5334264",
"0.5305329",... | 0.7075779 | 0 |
Collects the percentage change fom the output fields, checks whether it is a float, rounds it and checks it against a reference value. | def check_compare_grow(out_fields):
change = out_fields[CHANGE_FLD]
expected_change = 50.00
check_compare(change, expected_change)
check_float_value(change, CHANGE_FLD) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percentage_change(old_value, new_value):\n\n result = float(100 * (new_value - old_value) / old_value)\n\n return result",
"def stretch_pct(cube,out,pct):\n\n try:\n isis.percent(from_=cube, to=out, percentage=pct)\n val = isis.getkey(from_=out, grpname=\"Results\", keyword=\"Value\").... | [
"0.67220515",
"0.65994745",
"0.6594381",
"0.6460531",
"0.6423196",
"0.63694155",
"0.6328795",
"0.6280766",
"0.61413723",
"0.61347663",
"0.61270046",
"0.6125613",
"0.60906345",
"0.6073758",
"0.606276",
"0.604564",
"0.59941375",
"0.5950496",
"0.5878949",
"0.5869736",
"0.5862491... | 0.6102684 | 12 |
Collects the percentage change fom the output fields, checks whether it is a float, rounds it and checks it against a reference value. | def check_compare_decrease(out_fields):
change = out_fields[CHANGE_FLD]
expected_change = -25.00
check_compare(change, expected_change)
check_float_value(change, CHANGE_FLD) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percentage_change(old_value, new_value):\n\n result = float(100 * (new_value - old_value) / old_value)\n\n return result",
"def stretch_pct(cube,out,pct):\n\n try:\n isis.percent(from_=cube, to=out, percentage=pct)\n val = isis.getkey(from_=out, grpname=\"Results\", keyword=\"Value\").... | [
"0.67214686",
"0.6598218",
"0.659436",
"0.646117",
"0.6422313",
"0.63685286",
"0.63295907",
"0.62811506",
"0.61410147",
"0.61344606",
"0.6126567",
"0.61046356",
"0.6089975",
"0.6074072",
"0.60641044",
"0.6045655",
"0.5993072",
"0.59505206",
"0.5878273",
"0.58696103",
"0.58620... | 0.6127159 | 10 |
Applies mason yaml (Config, Operator, Workflow) | def apply(file: str, overwrite: bool = False, log_level: Optional[str] = None):
from mason.api.apply import apply as api_apply
api_apply(file, overwrite, log_level) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_to_logic(self):\n \n raise NotImplementedError",
"def logic_to_config(self):\n raise NotImplementedError",
"def apply_configs(task):\n\n if \"3750X\" in task.host[\"sw_model\"]:\n # run 3750X function\n aaa_3750x(task)\n\n # apply global config file for each ... | [
"0.56445193",
"0.55314183",
"0.5444807",
"0.54158854",
"0.5335775",
"0.52977014",
"0.52788395",
"0.522225",
"0.5122187",
"0.50839776",
"0.5080446",
"0.5061245",
"0.50135297",
"0.49976707",
"0.4972664",
"0.4972348",
"0.49705082",
"0.49576566",
"0.4914602",
"0.490503",
"0.49034... | 0.0 | -1 |
ignoring all possible errors | def clear_or_create_directory(dir_name):
shutil.rmtree(dir_name, ignore_errors=True)
cntr = 0
while True:
try:
os.makedirs(dir_name, exist_ok=True)
return
except OSError:
if cntr < 10:
# some windows bug?
cntr += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_errors(self) -> None:",
"def unexpected_error(self, exception):",
"def unexpectedException(self):",
"def check_errors(self):\n raise NotImplementedError(\"Implement it in a subclass.\")",
"def handle_err(self):\n pass",
"def ERR(self):",
"def errors_fatal(self) -> List[Error]:",... | [
"0.72692907",
"0.69507754",
"0.6704027",
"0.6643107",
"0.660557",
"0.65300596",
"0.644394",
"0.63833773",
"0.6374554",
"0.6374554",
"0.63713545",
"0.63237876",
"0.6300828",
"0.6289434",
"0.6265812",
"0.62376565",
"0.62294567",
"0.6226507",
"0.61934954",
"0.6155259",
"0.613836... | 0.0 | -1 |
much faster than call lemmatize_sentence_rus in cycle | def lemmatize_sentences_rus(sentences):
split = 'fks2hwras1ma39hka766gbk'
chunk_size = 10000
def handle_chunk(sentences_chunk):
all_sents = (' ' + split + ' ').join(sentences_chunk)
all_lemmas = lemmatize_sentence_rus(all_sents).split()
chunk_res = [[]]
for lemma in all_lemm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lemmatize_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = None\n if self.lemmatize_method == 'wordnet':\n cleaned_tokens = [self.lemmatizer.lemmatize(token) for token in tokens]\n else:\n cleaned_tokens = [self.lemmatizer.stem(token) for token in... | [
"0.73487616",
"0.7322892",
"0.7273643",
"0.7251521",
"0.7078697",
"0.70461565",
"0.69745123",
"0.69706315",
"0.6929691",
"0.68823695",
"0.6881043",
"0.686045",
"0.68522346",
"0.682739",
"0.68168205",
"0.6789751",
"0.6773865",
"0.67352444",
"0.66651434",
"0.6639106",
"0.661367... | 0.7187565 | 4 |
split each text to sentences and lemmatize them | def lemmatize_texts_rus(texts):
sentenized = [[s.text for s in razdel.sentenize(t)] for t in texts]
texts_lengths = [len(t) for t in sentenized]
sentences = [s for t in sentenized for s in t]
sentences_lemm = lemmatize_sentences_rus(sentences)
texts_lemm = []
pos = 0
for text_length in tex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(text):\n tokens = nltk.word_tokenize(text)\n lemmatizer = nltk.WordNetLemmatizer()\n \n lemmatized_words = []\n for word in tokens:\n lemmatized_words.append(lemmatizer.lemmatize(word).lower().strip())\n \n return lemmatized_words",
"def lemmatize(text, nlp):\n\n r... | [
"0.74349856",
"0.73827",
"0.73166144",
"0.7313327",
"0.72395587",
"0.7236935",
"0.7212994",
"0.7168978",
"0.7167267",
"0.71459424",
"0.7134891",
"0.71328896",
"0.71247697",
"0.7122165",
"0.70692074",
"0.7052754",
"0.70327723",
"0.6982322",
"0.6970459",
"0.69619834",
"0.696016... | 0.7229475 | 6 |
split text to sentences and lemmatize them | def lemmatize_text_rus(text):
text_lemm, text_sent = lemmatize_texts_rus([text])
text_lemm, text_sent = text_lemm[0], text_sent[0]
return text_lemm, text_sent | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(text):\n tokens = nltk.word_tokenize(text)\n lemmatizer = nltk.WordNetLemmatizer()\n \n lemmatized_words = []\n for word in tokens:\n lemmatized_words.append(lemmatizer.lemmatize(word).lower().strip())\n \n return lemmatized_words",
"def lemmatize(text, nlp):\n\n r... | [
"0.74687606",
"0.7379463",
"0.7352364",
"0.7350641",
"0.73457325",
"0.7255446",
"0.7248259",
"0.72482115",
"0.72330636",
"0.7232925",
"0.7229702",
"0.7224981",
"0.7206296",
"0.72050154",
"0.71733004",
"0.7151718",
"0.7150805",
"0.71412253",
"0.7116664",
"0.7115599",
"0.711261... | 0.6754644 | 41 |
Test the importer FMI PGM. | def test_io_import_fmi_pgm_shape():
root_path = pysteps.rcparams.data_sources["fmi"]["root_path"]
filename = os.path.join(root_path, "20160928",
"201609281600_fmi.radar.composite.lowest_FIN_SUOMI1.pgm.gz")
R, _, _ = pysteps.io.import_fmi_pgm(filename, gzipped=True)
assert R.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_io_import_fmi_pmg_metadata(variable, expected):\n root_path = pysteps.rcparams.data_sources[\"fmi\"][\"root_path\"]\n filename = os.path.join(root_path, \"20160928\",\n \"201609281600_fmi.radar.composite.lowest_FIN_SUOMI1.pgm.gz\")\n metadata = pysteps.io.importers._imp... | [
"0.65615994",
"0.63812834",
"0.6067058",
"0.60490984",
"0.60159093",
"0.57693243",
"0.5769277",
"0.57227415",
"0.5713535",
"0.5707837",
"0.56939757",
"0.5692267",
"0.5684236",
"0.5674629",
"0.56721985",
"0.56546754",
"0.5646513",
"0.5639076",
"0.56190664",
"0.56031495",
"0.55... | 0.64258885 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.