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
Validate that the children values, passed as either a file or a json string, are correct.
def validate_children(self, source, **kwargs): # TODO cache this loaded data keyed on a hashed version of kwargs children = self._load_json("children", source, **kwargs) self._validate_against_schema("children", children) strand = getattr(self, "children", []) # Loop the childr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_json(self):\n pass", "def validate_data(self, data):\n # TODO use schema\n assert \"file_contents\" in data, data\n assert \"type\" in data, data", "def _validate(self, path, obj):\r\n if isinstance(obj, str):\r\n if path[-1] != \"pattern\":\r\n ...
[ "0.6158009", "0.6144193", "0.5932691", "0.5760641", "0.56944185", "0.56927955", "0.5685668", "0.56744194", "0.56555223", "0.5653026", "0.5635682", "0.559688", "0.55957067", "0.5592181", "0.5564809", "0.5561077", "0.55481446", "0.55238324", "0.551551", "0.5502962", "0.5483416"...
0.6725077
0
Validate that all credentials required by the twine are present. Credentials must be set as environment variables, or defined in a '.env' file. If stored remotely in a secrets manager (e.g. Google Cloud Secrets), they must be loaded into the environment before validating the credentials strand. If not present in the en...
def validate_credentials(self, *args, dotenv_path=None, **kwargs): if not hasattr(self, "credentials"): return set() # Load any variables from the .env file into the environment. dotenv_path = dotenv_path or os.path.join(".", ".env") load_dotenv(dotenv_path) for cre...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_credentials(self):\n\n # There should be a client_id and client secret\n return \"client_id\" in self.credentials.keys() and \"client_secret\" in self.credentials.keys() \\\n and self.credentials[\"client_id\"] and self.credentials[\"client_secret\"]", "def check_credent...
[ "0.661287", "0.64161855", "0.6251266", "0.61858857", "0.61782354", "0.6148377", "0.61406416", "0.6052758", "0.6034112", "0.6033556", "0.60107875", "0.60107875", "0.60083914", "0.6002498", "0.5968834", "0.59106755", "0.5909878", "0.5885369", "0.585459", "0.5849183", "0.5843529...
0.7446492
0
Validate that the configuration values, passed as either a file or a json string, are correct.
def validate_configuration_values(self, source, **kwargs): return self._validate_values("configuration_values", source, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate(self, config_json):\n pass", "def validate_config(\n json_schema: JsonDict, config: Any, config_path: StrSequence\n) -> None:\n try:\n jsonschema.validate(config, json_schema)\n except jsonschema.ValidationError as e:\n raise json_error_to_config_error(e, config_path)",...
[ "0.7649231", "0.68019813", "0.6770367", "0.6684895", "0.6678061", "0.66503954", "0.66342115", "0.6629598", "0.6629598", "0.66133463", "0.6548915", "0.6533521", "0.6527717", "0.6519201", "0.65179867", "0.6504512", "0.64998895", "0.64800966", "0.6476303", "0.64425457", "0.64190...
0.6064642
50
Validate that the input values, passed as either a file or a json string, are correct.
def validate_input_values(self, source, **kwargs): return self._validate_values("input_values", source, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_input(update_file):\n try:\n json.load(open(update_file))\n print \"\\nValid JSON\"\n return True\n except ValueError:\n print \"\\nInvalid JSON\"\n exit(-1)\n return False", "def validate_input(update_file):\n try:\n json.load(open(update_fi...
[ "0.7035887", "0.7005028", "0.69904476", "0.6892422", "0.68914765", "0.66186786", "0.6573325", "0.65226805", "0.64924496", "0.6450398", "0.64263535", "0.63742745", "0.6305237", "0.62949204", "0.6228534", "0.6220705", "0.618344", "0.6172133", "0.61165553", "0.61000866", "0.6090...
0.0
-1
Validate that the output values, passed as either a file or a json string, are correct.
def validate_output_values(self, source, **kwargs): return self._validate_values("output_values", source, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_output(out: Union[str, bytes], fmt: str) -> None:\n if fmt in [\"png\", \"pdf\"]:\n assert isinstance(out, bytes)\n elif fmt in [\"vega\", \"vega-lite\"]:\n assert isinstance(out, str)\n dct = json.loads(out)\n assert len(dct) > 0\n else:\n assert isinstance(ou...
[ "0.6843762", "0.6608919", "0.65803474", "0.6542176", "0.64707804", "0.6435956", "0.6402429", "0.6313526", "0.6293885", "0.61496603", "0.6148562", "0.613426", "0.6072376", "0.60628194", "0.6022932", "0.59941685", "0.59931684", "0.59114295", "0.5907436", "0.58949924", "0.589358...
0.5906991
19
Validate monitor message against the monitor message schema strand.
def validate_monitor_message(self, source, **kwargs): return self._validate_values(kind="monitor_message", source=source, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate(self):\n\n # Check if motherboard record exists\n motherboard_record_exists = False\n board_info_records = self.groups[constants.RecordType.BASEBOARD_RECORD]\n for handle_id in board_info_records:\n record = self.records[handle_id]\n if 'Type' in record.props and record.props['Ty...
[ "0.6137711", "0.60649383", "0.60399437", "0.60151976", "0.5827821", "0.5748296", "0.5649671", "0.56458515", "0.550159", "0.54282165", "0.5421623", "0.54128164", "0.54105055", "0.5404401", "0.5385656", "0.5354246", "0.53523284", "0.5333825", "0.5331712", "0.53300637", "0.53206...
0.73682123
0
Validate the input manifest, passed as either a file or a json string.
def validate_configuration_manifest(self, source, **kwargs): return self._validate_manifest("configuration_manifest", source, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_manifest(manifest_json):\n manifest_json = copy.deepcopy(manifest_json)\n for field in [\"schemes\", \"host\", \"basePath\", \"info\"]:\n if field not in manifest_json:\n raise exceptions.ValidationError(\n click.style(\"Field '{}' is missing from the manifest fi...
[ "0.75632393", "0.69152206", "0.6795271", "0.6775537", "0.6771405", "0.6737948", "0.6733013", "0.6731521", "0.6577707", "0.65763694", "0.63452816", "0.6327808", "0.62367785", "0.6152708", "0.6118632", "0.61025196", "0.60380036", "0.5982197", "0.5943263", "0.5929421", "0.587526...
0.5375063
65
Validate the input manifest, passed as either a file or a json string.
def validate_input_manifest(self, source, **kwargs): return self._validate_manifest("input_manifest", source, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_manifest(manifest_json):\n manifest_json = copy.deepcopy(manifest_json)\n for field in [\"schemes\", \"host\", \"basePath\", \"info\"]:\n if field not in manifest_json:\n raise exceptions.ValidationError(\n click.style(\"Field '{}' is missing from the manifest fi...
[ "0.75632393", "0.69152206", "0.6795271", "0.6771405", "0.6737948", "0.6733013", "0.6731521", "0.6577707", "0.65763694", "0.63452816", "0.6327808", "0.62367785", "0.6152708", "0.6118632", "0.61025196", "0.60380036", "0.5982197", "0.5943263", "0.5929421", "0.587526", "0.5874747...
0.6775537
3
Validate the output manifest, passed as either a file or a json string.
def validate_output_manifest(self, source, **kwargs): return self._validate_manifest("output_manifest", source, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_manifest(manifest_json):\n manifest_json = copy.deepcopy(manifest_json)\n for field in [\"schemes\", \"host\", \"basePath\", \"info\"]:\n if field not in manifest_json:\n raise exceptions.ValidationError(\n click.style(\"Field '{}' is missing from the manifest fi...
[ "0.689081", "0.67470354", "0.6491389", "0.6478711", "0.64743024", "0.6428948", "0.642016", "0.6391841", "0.63199776", "0.6262872", "0.5994585", "0.59788805", "0.5946266", "0.5936269", "0.5893858", "0.58807135", "0.58602494", "0.5850808", "0.5838025", "0.5832804", "0.5797433",...
0.7151388
0
Getter that will return cls[name] if cls is a dict or cls otherwise
def _get_cls(name, cls): return cls.get(name, None) if isinstance(cls, dict) else cls
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(cls, name):\n cls.initialize()\n if isinstance(name, cls):\n return name\n else:\n return cls.mapping[name]", "def getInstacefromcls(cls, clsname, valuedict=None):\n for i in range(len(clslist)):\n if clsname == clslist[i]:\n ret...
[ "0.7089814", "0.68150103", "0.6775328", "0.6689568", "0.65000015", "0.6219528", "0.6086408", "0.60403633", "0.6031711", "0.6026237", "0.5955669", "0.5954231", "0.5952677", "0.5952677", "0.59358865", "0.5935747", "0.59133816", "0.5905671", "0.58998924", "0.5898058", "0.5878466...
0.8500315
0
Validate strands from sources provided as keyword arguments
def validate(self, allow_missing=False, allow_extra=False, cls=None, **kwargs): # pop any strand name:data pairs out of kwargs and into their own dict source_kwargs = tuple(name for name in kwargs.keys() if name in ALL_STRANDS) sources = dict((name, kwargs.pop(name)) for name in source_kwargs) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_strand(self, name, source, **kwargs):\n return self.validate({name: source}, **kwargs)[name]", "def validate(cls, **kwargs: Any) -> None: # pragma no cover", "def validate_source(cls, source_data: Dict[str, dict], verbose: bool = True):\n cls._validate_source_data(source_data=source...
[ "0.65343577", "0.6175937", "0.6175629", "0.60430217", "0.58976775", "0.5827241", "0.580448", "0.57669264", "0.57641464", "0.57474285", "0.57235986", "0.5695725", "0.5665001", "0.56555843", "0.56499135", "0.5635747", "0.5620332", "0.5607189", "0.55930436", "0.55805653", "0.555...
0.6043267
3
Validate a single strand by name.
def validate_strand(self, name, source, **kwargs): return self.validate({name: source}, **kwargs)[name]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid(name):\n return bool(name)", "def validated_name(cls, name):\n if (name[:5] == 'hive-'\n and name[5] in ['1', '2', '3']\n and re.match(r'^hive-[123]\\d{4,6}$', name)):\n return name\n return None", "def check_schema_name(name: str):\n if...
[ "0.62414205", "0.6123533", "0.60466254", "0.59945595", "0.5968563", "0.5950491", "0.5935591", "0.5917729", "0.5904584", "0.58871233", "0.5855124", "0.5852563", "0.58318865", "0.5813858", "0.5813858", "0.58076316", "0.57668716", "0.576247", "0.5755813", "0.57409114", "0.573586...
0.67900914
0
Prepare instance for strand data using a class map.
def prepare(self, *args, cls=None, **kwargs): prepared = {} for arg in args: if arg not in ALL_STRANDS: raise exceptions.UnknownStrand(f"Unknown strand '{arg}'") elif arg not in self.available_strands: prepared[arg] = None else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare(self, class_map=None):\n def clean_name(name):\n \"\"\"Returns a shorter version of object names for cleaner display.\"\"\"\n return \",\".join(name.split(\",\")[:1])\n\n # Build (or rebuild) everything else from the info dicts.\n self.num_classes = len(self.c...
[ "0.70301276", "0.7003586", "0.6602486", "0.6218813", "0.61369634", "0.612211", "0.5974682", "0.5971825", "0.59364706", "0.59063816", "0.5905724", "0.5905724", "0.5896591", "0.58913803", "0.58463514", "0.5846305", "0.58299506", "0.57877094", "0.57877094", "0.5729577", "0.56788...
0.6651037
2
Evaluates the model based on classsification accuracy. Receives the logits that are output from the network and saves the result in the given output directory file.
def evaluate(model, tokenizer, dataset, lines, output_test_file, batch_size=32): sampler = SequentialSampler(dataset) dataloader = DataLoader(dataset, sampler=eval_sampler, batch_size=batch_size) print("*** Evaluating ***") eval_loss = 0.0 num_steps = 0 preds = None out_label_ids = None ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate_model(self, model, testX_norm, testY_bin, batch_size, label_names, n_epochs, output_filename):\n # Predictions\n predictions = model.predict(testX_norm, batch_size=batch_size)\n \n # Classification report\n classification = classification_report(testY_bin.argmax(axis=1),...
[ "0.7298459", "0.6623584", "0.6488723", "0.6457983", "0.6437241", "0.6381797", "0.6377442", "0.6340089", "0.6337451", "0.63357455", "0.63341504", "0.6327298", "0.6297221", "0.62892634", "0.62823796", "0.62763405", "0.6274694", "0.6269606", "0.6268752", "0.6253955", "0.6247242"...
0.65427065
2
custom function to remove the stopwords
def remove_stopwords(self,text): return " ".join([word for word in str(text).split() if word not in self.STOPWORDS])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_stopwords_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = [token for token in tokens\n if token.lower() not in self.stopword_list]\n self.doc = ' '.join(cleaned_tokens)", "def remove_stopwords(text):\n stopwords = [\"i\", \"me\", \"my\", ...
[ "0.8823565", "0.8401623", "0.8289207", "0.8228253", "0.82197374", "0.8181915", "0.8181915", "0.8181915", "0.8181915", "0.8164255", "0.81541234", "0.81183577", "0.8115647", "0.81121063", "0.8105464", "0.8080783", "0.8072988", "0.806302", "0.80382043", "0.80332667", "0.7997704"...
0.8248563
3
Default b64_encode adds padding, jwt spec removes padding
def base64url_encode(msg): encoded_input = base64.urlsafe_b64encode(to_bytes(msg)) stripped_input = to_bytes(to_string(encoded_input).replace('=', '')) return stripped_input
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def b64_json_enc(data):\n json_str = json.dumps(data)\n return base64.b64encode(json_str.encode()).decode()", "def encode_payload(payload):\n jwt_secret = app.config['SECRET_KEY']\n # expiry = 60 * 60 * 24 * 100 # 100 days\n # payload['exp'] = datetime.datetime.utcnow() + datetime.timedelta(second...
[ "0.71889275", "0.71519893", "0.7149377", "0.71148413", "0.699144", "0.6853686", "0.683355", "0.68118036", "0.6764185", "0.6760017", "0.6730485", "0.672144", "0.66806155", "0.6677432", "0.66706085", "0.6628703", "0.6622796", "0.66124743", "0.65830743", "0.6532523", "0.6522085"...
0.59093267
77
JWT spec doesn't allow padding characters. base64url_encode removes them, base64url_decode, adds them back in before trying to base64 decode the message
def base64url_decode(msg): bmsg = to_bytes(msg) pad = len(bmsg) % 4 if pad > 0: bmsg += b'=' * (4 - pad) return base64.urlsafe_b64decode(bmsg)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base64url_encode(msg):\n encoded_input = base64.urlsafe_b64encode(to_bytes(msg))\n stripped_input = to_bytes(to_string(encoded_input).replace('=', ''))\n return stripped_input", "def _url_base64_encode(msg):\r\n msg_base64 = base64.b64encode(msg)\r\n msg_base64 = msg_base64.replace('+'...
[ "0.7315336", "0.69865996", "0.6815715", "0.6786328", "0.6752276", "0.6739659", "0.667964", "0.663198", "0.66216433", "0.6594801", "0.655502", "0.6553585", "0.6501903", "0.64332056", "0.64272547", "0.64245147", "0.6410119", "0.6359167", "0.63350207", "0.63240933", "0.6308579",...
0.68548036
2
Create a nonce with timestamp included
def make_nonce(): time_format = '%Y-%m-%dT%H:%M:%SZ' time_component = time.strftime(time_format, time.gmtime()) valid_chars = '' # iterate over all the aschii characters for a list of all alpha-numeric characters for char_index in range(0, 128): if chr(char_index).isalpha() or chr(char_inde...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_nonce():\n default_seed = 'ifh2847fhsn\"lqOEYd@#Djh(&'\n hash = sha.new(default_seed)\n hash.update(str(datetime.utcnow()))\n return hash.hexdigest()", "def generate_nonce():\n return str(int(round(time.time() * 1000)))", "def _nonce():\n return str(round(100000 * time.time()) ...
[ "0.81308687", "0.808096", "0.78753763", "0.7763684", "0.7712205", "0.7655275", "0.7655275", "0.7587932", "0.7550162", "0.7538623", "0.7479432", "0.74498117", "0.74498117", "0.7414203", "0.7234778", "0.713928", "0.69921154", "0.6871529", "0.6782506", "0.6731106", "0.66884166",...
0.8013038
2
Ensure that the nonce is correct, less than one hour old, and not more than two minutes in the future Callers should also store used nonces and reject messages with previouslyused ones.
def verify_and_burn_nonce(nonce): ret = re.match(r'^001[2-9][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])' r'T([01][0-9]|2[0-3])(:[0-5][0-9]){2}Z[A-Za-z0-9]{6}$', nonce) if ret: date = parser.parse(nonce[3:-6]) now = datetime.utcnow().replace(tzinfo=tz.tzutc()) ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validateNonce(lastNonce, lastHash, nonce):\n sha = hashlib.sha256(f'{lastNonce}{lastHash}{nonce}'.encode())\n return sha.hexdigest()[:4] == '0000'", "def nonce():\n return random.randint(0, 4294967295)", "def nonce():\n return random.randint(0, 4294967295)", "def _nonce():\n re...
[ "0.65487677", "0.6318106", "0.6318106", "0.63045347", "0.623894", "0.618787", "0.61794573", "0.6055988", "0.59781826", "0.59658813", "0.59374857", "0.59365934", "0.59196234", "0.5910003", "0.5893382", "0.5891976", "0.58326024", "0.5790357", "0.5772316", "0.5751489", "0.573236...
0.694894
0
Map Juniper SRX Policy Object into xml config element
def to_xml(self): policy_element = create_element('policy') create_element('name', text=self.name, parent=policy_element) match_element = create_element('match', parent=policy_element) for s in self.src_addresses: create_element('source-address', text=s.name, parent=match_el...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _wrap_policy(policy_doc):\n return {\"IAMPolicy\": policy_doc}", "def get_config(self):\n config = super(Sc2Policy, self).get_config()\n config['eps'] = self.eps\n config['testing'] = self.testing\n return config", "def translate_policy(policy: dict):\n if 'PolicyN...
[ "0.58459353", "0.57357043", "0.52592963", "0.52169687", "0.5177298", "0.5132841", "0.5117141", "0.5053394", "0.50252014", "0.50223446", "0.5019244", "0.50055027", "0.49536827", "0.4945237", "0.49375263", "0.49065456", "0.49007678", "0.48749763", "0.48602158", "0.48564184", "0...
0.6687791
0
Creates a new ColumnInfo and update the size
def update(self, size) -> 'ColumnInfo': return ColumnInfo( size, self.directive, self.period )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AddColumnInfo(self, colInfo):\r\n \r\n self._columns.append(colInfo)\r\n self._total_col_width += colInfo.GetWidth()\r\n self._owner.AdjustMyScrollbars()\r\n self._owner._dirty = True", "def AddColumnInfo(self, colInfo):\r\n\r\n self._header_win.AddColumnInfo(colInfo...
[ "0.6953581", "0.6563744", "0.63662314", "0.62849265", "0.6020931", "0.5901503", "0.5833289", "0.58037275", "0.5675224", "0.5647959", "0.56247205", "0.5617577", "0.55949396", "0.5576177", "0.55671567", "0.5556555", "0.5535544", "0.55261594", "0.55159014", "0.5498711", "0.54230...
0.76685566
0
Simply copy metadata from source to target
def copy_stock_metas( meta_source, target, copy_columns_info=True, ) -> None: set_attr( target, KEY_ALIAS_MAP, copy(getattr(meta_source, KEY_ALIAS_MAP)) ) if copy_columns_info: set_attr( target, KEY_COLUMNS_INFO_MAP, deepcopy(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _copy_metadata(from_dir, to_dir):\n if not FLAGS.dry_run:\n tf.io.gfile.makedirs(to_dir)\n for fname in tfds.core.utils.list_info_files(from_dir):\n from_path = os.path.join(from_dir, fname)\n to_path = os.path.join(to_dir, fname)\n logging.info('cp %s %s', from_path, to_path)\n if not FLAGS.d...
[ "0.7023326", "0.6726561", "0.65834624", "0.6537077", "0.64390403", "0.62709254", "0.62083226", "0.61535376", "0.60626066", "0.60160655", "0.60077727", "0.59770507", "0.59708804", "0.5922094", "0.5846591", "0.57966024", "0.57608265", "0.57467353", "0.56573725", "0.56544816", "...
0.7013717
1
Saves ciphers or keys or any text to the given file path; more efficient than manual saving.
def save(string, file): save_file = open(file, 'w') save_file.write(string) save_file.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_file(path, text):\n with path.open(mode='w') as f_stream:\n f_stream.write(text)", "def store_file(text: str, file_path: str) -> None:\n with open(file=file_path, mode='w', encoding='utf8') as f:\n f.write(text)", "def save_text_file(text, path):\n os.makedirs(os.path.dirname(pa...
[ "0.68838364", "0.6661782", "0.65330315", "0.6515433", "0.6431692", "0.64074653", "0.6158728", "0.61471856", "0.6121656", "0.6058847", "0.6049562", "0.60482824", "0.60414743", "0.6010596", "0.598768", "0.59727114", "0.59727114", "0.59727114", "0.59499484", "0.5907642", "0.5892...
0.55175346
68
Returns number of permutations of size r from population of size n; accurate for arbitrarily large integers, unlike standard formula n! / (nr)!
def permute(n, r): product = 1 for i in range(n - r + 1, n + 1): product *= i return product
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def r_permutations(n, r):\n return math.factorial(n) / math.factorial(n - r)", "def permutations_(n, r):\n return factorial(n) / factorial(n-r)", "def permutations(n, r):\n result = 1\n for i in range(n, n-r, -1):\n result *= i\n return result", "def r_combinations(n,r):\n return r_p...
[ "0.77895117", "0.7716931", "0.7273337", "0.72685605", "0.69712794", "0.6970604", "0.6709193", "0.66836315", "0.6649834", "0.6625802", "0.6509674", "0.6436063", "0.641432", "0.6391373", "0.63186556", "0.63137746", "0.6243626", "0.62363577", "0.62117946", "0.61875135", "0.61524...
0.7123683
4
Returns the default collector settings
def get_default_config(self): config = super(YammerCollector, self).get_default_config() config.update({ 'path': 'yammer', 'url': 'http://127.0.0.1:8081/metrics', 'username': '', 'password': '', }) return config
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_default_config(self):\r\n config = super(CMDCollector, self).get_default_config()\r\n config.update({\r\n 'enabled': 'True',\r\n 'fs': ',',\r\n 'timeout': 300,\r\n })\r\n return config", "def getDefaultSettings():\n return {}", "def ge...
[ "0.70514023", "0.7008024", "0.69490683", "0.6713433", "0.65743333", "0.65309024", "0.6521635", "0.6515402", "0.6466526", "0.6447688", "0.641337", "0.6397818", "0.6380512", "0.63683224", "0.6357208", "0.6331759", "0.63120294", "0.62353724", "0.6231899", "0.62074906", "0.620161...
0.63517016
15
Setup authorization for whole API. Can be redefined for an endpoint. OpenAPI Authorization Specs
async def authorization(request): # Decode tokens, load/check users and etc # ... # in the example we just ensure that the authorization header exists return request.headers.get("authorization", "")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorization():\n pass", "def authn_and_authz():\n authentication()\n authorization()", "def ProcessApiAuthorization(self, msg):\n policy = self.server.GetPolicies()\n\n # Return the auth code from the config file if it's defined. Default to an\n # empty auth code, which will instruct th...
[ "0.6254318", "0.61565816", "0.60597587", "0.59296864", "0.58683383", "0.58554614", "0.5855057", "0.5846915", "0.57419527", "0.56949556", "0.56878364", "0.5677218", "0.5673581", "0.5643289", "0.5643289", "0.5630589", "0.56278825", "0.5616754", "0.5615052", "0.5611695", "0.5590...
0.49864846
98
A simple endpoint to get current API token. By default authorization is only awailable for class based endpoints. So the endpoint supports anonimous access. If you would like to use API authorization for the simple endpoints, you have to
async def token(request) -> ResponseText: return ResponseText( "".join(random.choices(string.ascii_uppercase + string.digits, k=42)) # noqa: S311 )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_token():\n if g.current_user.is_anonymous or g.token_used:\n return unauthorized('Invalid credentials')\n return jsonify({'token': g.current_user.generate_auth_token(\n expiration=3600), 'expiration': 3600})", "def get_token():\n if g.current_user.is_anonymous or g.token_used:\n ...
[ "0.7302796", "0.7302796", "0.71899337", "0.7180431", "0.7098359", "0.69854575", "0.696279", "0.68940157", "0.6877278", "0.68370014", "0.67778414", "0.6764868", "0.67499906", "0.6745955", "0.67155045", "0.6713305", "0.6693445", "0.66762966", "0.6661236", "0.6643763", "0.661104...
0.0
-1
Checks that the email has a User object associated with it and that the User object is active
def clean_email(self): e = self.cleaned_data['email'] try: user = User.objects.get(email=e) if not user.is_active: msg = 'This user account has not been confirmed yet' raise forms.ValidationError(msg) except User.DoesNotExist: p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkIsEmailAvailable(self, email):\n\n return User.objects.filter(email=email).exists()", "def has_validated_email(self):\n return self.user.email_user is not None", "def ref_user_flag(self):\n try:\n ref = User.objects.get(\n associated_emails__email__iexact...
[ "0.76105195", "0.7152086", "0.71156937", "0.7044124", "0.6917909", "0.69042623", "0.6899563", "0.68861634", "0.6773868", "0.67668664", "0.67640114", "0.67633206", "0.67286646", "0.6708247", "0.6693293", "0.6690005", "0.66814554", "0.66811293", "0.6654798", "0.6637169", "0.662...
0.68864995
7
Returns the User object if the form is valid
def get_username(self): if not self.is_valid(): return None try: # NOTE: all emails stored in lower-case email = self.clean_email().lower() return User.objects.get(email=email).username except User.DoesNotExist: pass return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean(self):\n c = super(UserForm, self).clean()\n if (self.instance.pk is None and\n c.get('email') and\n user_exists(c.get('email'),\n c.get('last_name'),\n c.get('first_name'),\n self.current_round_name)...
[ "0.6947391", "0.6922856", "0.67644674", "0.66740084", "0.657634", "0.65609896", "0.65185124", "0.649799", "0.64326835", "0.64067334", "0.640667", "0.6404592", "0.6355719", "0.6345825", "0.6341826", "0.63241357", "0.632235", "0.6290305", "0.62621236", "0.62143874", "0.62017405...
0.0
-1
Checks that the email is not already in use
def clean_email(self): # NOTE: all emails are stored in lower case e = self.cleaned_data['email'].lower() if User.objects.filter(email=e).count() > 0: raise forms.ValidationError('An existing account is using that email address.') return e
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_duplicate_email(self, email):\r\n request = self.req_factory.post('unused_url', data={\r\n 'new_email': email,\r\n 'password': 'test',\r\n })\r\n request.user = self.user\r\n self.assertFailedRequest(self.run_request(request), 'An account with this e-mail...
[ "0.7703849", "0.69526696", "0.6862401", "0.6811217", "0.6774223", "0.67012995", "0.6641258", "0.6557139", "0.65535825", "0.6535207", "0.6535207", "0.6481211", "0.64502555", "0.63732386", "0.63573235", "0.63533545", "0.633444", "0.63318545", "0.63180923", "0.6309124", "0.63064...
0.6098911
40
Checks that the passwords are the same
def clean_password2(self): password1 = self.cleaned_data.get('password1', '') password2 = self.cleaned_data['password2'] if password1 != password2: raise forms.ValidationError('The passwords did not match.') return password2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_passwords_match(self, password1, password2):\n return password1 == password2", "def test_password_salts_are_random(self):\n self.user.password = '123456'\n self.user2.password = '123456'\n self.assertTrue(self.user.password_hash != self.user2.password_hash)", "def check_pass(...
[ "0.77910745", "0.7613175", "0.7546211", "0.7338358", "0.7300746", "0.7270298", "0.7236492", "0.7210182", "0.7177891", "0.716393", "0.71617705", "0.715105", "0.7121701", "0.7119943", "0.70778507", "0.70771366", "0.7053473", "0.704067", "0.70307827", "0.70246506", "0.7013039", ...
0.6925312
34
Creates a User object (it will be inactive)
def create_user(self): if not self.is_valid(): return None # generate a username ids = User.objects.values_list('id', flat=True).order_by('-id')[:1] if len(ids) > 0: # ids[0] will be the maximum value (due to order_by: '-id') idnum = ids[0] + 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_user_object():\n user = User.objects.get_or_create(username='testuser',\n first_name='Test',\n last_name='User',\n email='test@test.com')[0]\n user.set_password('testabc123')\n user.sa...
[ "0.8247268", "0.82456094", "0.8141204", "0.81273985", "0.80339557", "0.8026633", "0.80089855", "0.7969125", "0.7943305", "0.792896", "0.7926916", "0.79243636", "0.78791255", "0.7877891", "0.7829092", "0.7828892", "0.77510595", "0.77483684", "0.77474916", "0.7718734", "0.77142...
0.8240706
2
Checks that the passwords are the same
def clean_password2(self): password1 = self.cleaned_data.get('password1', '') password2 = self.cleaned_data['password2'] if password1 != password2: raise forms.ValidationError('The passwords did not match.') return password2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_passwords_match(self, password1, password2):\n return password1 == password2", "def test_password_salts_are_random(self):\n self.user.password = '123456'\n self.user2.password = '123456'\n self.assertTrue(self.user.password_hash != self.user2.password_hash)", "def check_pass(...
[ "0.77910745", "0.7613175", "0.7546211", "0.7338358", "0.7300746", "0.7270298", "0.7236492", "0.7210182", "0.7177891", "0.716393", "0.71617705", "0.715105", "0.7121701", "0.7119943", "0.70778507", "0.70771366", "0.7053473", "0.704067", "0.70307827", "0.70246506", "0.7013039", ...
0.6925312
35
Changes the password for the given user
def change_password(self, user): if not self.is_valid(): return None password = self.clean_password2() user.set_password(password) user.save() return user
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_password(self, user, password):\n user.password = hashers.make_password(password)", "def change_user_password(self, user, new_pass):\n return self.update(user, password=new_pass)", "def change_user_password(self, instance, user, new_pass):\n return instance.change_user_password(...
[ "0.8684988", "0.8561367", "0.83150464", "0.8308839", "0.81240356", "0.8089846", "0.7987024", "0.79581326", "0.79197747", "0.79159844", "0.79039943", "0.78411984", "0.78052634", "0.7772818", "0.7770018", "0.77554065", "0.774026", "0.77302045", "0.77212405", "0.77205837", "0.77...
0.82297784
4
Checks that the email is valid
def clean_email(self): # NOTE: all emails are stored in lower-case e = self.cleaned_data['email'].lower() try: user = User.objects.get(email=e) if not user.is_active: msg = 'This user account has not been confirmed yet' raise forms.Validati...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_email(self, email):\n rex = \"^[\\w]+[\\d]?@[\\w]+\\.[\\w]+$\"\n return re.match(rex, email)", "def validate_email(self):\n # source: https://docs.python.org/2/howto/regex.html\n if not re.match(r\"[^@.]+@[A-Za-z]+\\.[a-z]+\", self.email):\n return 'Invalid ema...
[ "0.800048", "0.799266", "0.78625476", "0.78314734", "0.77968144", "0.77801484", "0.7779725", "0.7750616", "0.7714883", "0.7691427", "0.7665794", "0.76622987", "0.7633775", "0.762817", "0.7609659", "0.76070136", "0.75767475", "0.7563735", "0.7555903", "0.75257874", "0.7525405"...
0.0
-1
Returns the User object for the email address
def get_user(self): if not self.is_valid(): return None # error checking done in: clean_email # NOTE: all emails are stored in lower-case e = self.clean_email().lower() return User.objects.get(email=e)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user(email):\r\n return User.objects.get(email=email)", "def lookup_email(email):\n user = User.objects(email=email).first()\n return user", "def find_by_email(cls, email):\n return User.objects.filter(email=email).first()", "def get_by_email(self, email):\n user = (\n s...
[ "0.84499913", "0.83574003", "0.82821196", "0.818987", "0.81825906", "0.81438047", "0.8139404", "0.81299245", "0.81272453", "0.81272453", "0.8071784", "0.8008092", "0.8000772", "0.79462504", "0.78996384", "0.7887486", "0.7843716", "0.77918035", "0.77474326", "0.7740562", "0.77...
0.8178796
5
Determines if a filename is a valid Python module. Assumes if is just the end of a path (i.e. does not contain ``os.path.sep``.
def is_valid_module(filename): if not filename.endswith('.py'): return False if filename == '__init__.py': return True for prefix in IGNORED_PREFIXES: if filename.startswith(prefix): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_module(path: str) -> bool:\n return os.path.isfile(path) and path.endswith(\".py\")", "def is_module(path):\n\n fname, ext = os.path.splitext(path)\n if ext == \".py\":\n return True\n elif os.path.exists(os.path.join(path, \"__init__.py\")):\n return True\n else:\n ret...
[ "0.78435075", "0.7644184", "0.7453708", "0.74041945", "0.72734565", "0.7177794", "0.7162914", "0.6941581", "0.688582", "0.68661207", "0.68447286", "0.68002564", "0.66656727", "0.6652094", "0.6552671", "0.6495056", "0.6463849", "0.6461724", "0.63578534", "0.62999207", "0.62551...
0.73747915
4
Get list of all public modules relative to a path.
def get_public_modules(path, base_package=None): result = [] for subdir, _, files in os.walk(path): # Skip folders that start with _. if any([part.startswith('_') for part in subdir.split(os.path.sep)]): continue _, rel_dir = subdir.split(path) rel_dir...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def moduleList(path):\n\n if os.path.isdir(path):\n folder_list = os.listdir(path)\n elif path.endswith('.egg'):\n try:\n folder_list = [f for f in zipimporter(path)._files]\n except:\n folder_list = []\n else:\n folder_list = []\n #folder_list = glob.g...
[ "0.68155396", "0.6617278", "0.6521537", "0.6507804", "0.64241713", "0.6303963", "0.62988365", "0.62711245", "0.6268034", "0.62417346", "0.62394094", "0.61733466", "0.61073136", "0.60500586", "0.60428715", "0.6029033", "0.60251296", "0.600245", "0.59671587", "0.5930028", "0.59...
0.81640553
0
Main script to verify modules included.
def main(): mock_uri = '' inventory = fetch_inventory(SphinxApp, mock_uri, OBJECT_INVENTORY_RELPATH) sphinx_mods = set(inventory['py:module'].keys()) library_dir = os.path.join(BASE_DIR, 'gcloud') public_mods = get_public_modules(library_dir, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_import():\n print('[GenHub] Checking Python modules.')\n\n basemod = [('yaml', 'pyyaml'), ('pycurl', 'pycurl')]\n devmod = ['pep8', 'pytest', 'pytest-cov', 'coverage']\n\n packages = dict()\n for importname, packagename in basemod:\n try:\n importlib.import_module(importn...
[ "0.6922173", "0.6404539", "0.639195", "0.6359169", "0.6339818", "0.6293124", "0.6275313", "0.61491907", "0.6106056", "0.6074857", "0.60627216", "0.602918", "0.5958757", "0.5958374", "0.5927664", "0.59225035", "0.5901187", "0.58883744", "0.58760595", "0.584319", "0.5842419", ...
0.58290154
23
Initialise parameters for MARL training
def __init__( self, state_size, action_size, hidden_dim=128, state_rep_size=64, learning_rate=1e-5, eta=2 ): super(RND, self).__init__(state_size, action_size, eta) self.hidden_dim = hidden_dim self.state_rep_size = state_rep_size self.learning_rate = learning_rate s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_parameters(self):\n for i in range(1, self.L):\n self.W[i - 1] = np.random.randn(self.layer_dims[i], self.layer_dims[i - 1]) * 0.01\n self.b[i - 1] = np.zeros((self.layer_dims[i], 1))", "def params_init(self) -> None:\n # Initialize weights and biases with uniform d...
[ "0.7397329", "0.7190591", "0.7161128", "0.7092822", "0.7059068", "0.6987178", "0.6977974", "0.69458026", "0.6906171", "0.68707854", "0.6857603", "0.6851031", "0.6840059", "0.6775705", "0.6761099", "0.6754401", "0.67539597", "0.6738152", "0.6727141", "0.6707005", "0.6685758", ...
0.0
-1
Compute intrinsic reward for given input
def compute_intrinsic_reward(self, state, action, next_state, use_cuda, train=False): if use_cuda: fn = lambda x: x.cuda() device = "gpu" else: fn = lambda x: x.cpu() device = "cpu" if not self.predictor_dev == device: self.predictor_mo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reward(input):\n state = np.array([input[0], input[1]])\n action = input[2]\n action = np.clip(action, -2.0, 2.0)\n costs = angle_normalize(state[0])**2 + .1 * state[1]**2 + .001 * (action**2)\n\n return - costs", "def _compute_reward(self): \n reward = -1\n return reward"...
[ "0.83368236", "0.76844054", "0.7681588", "0.7373235", "0.72947526", "0.7241712", "0.72022116", "0.7160538", "0.7067619", "0.7058791", "0.70559245", "0.7047685", "0.70335954", "0.70237744", "0.70136887", "0.70136887", "0.70136887", "0.70136887", "0.70136887", "0.70136887", "0....
0.6941467
22
Get losses of last computation if existing
def get_losses(self): if self.loss is not None: return [self.loss] else: return []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def losses(self):\n pass", "def compute_loss(self):", "def build_losses(self):\n self.batch_losses = tf.squared_difference(self.predicted_rv, self.label)\n self.total_loss = tf.reduce_mean(self.batch_losses)", "def build_losses(self):\n self.batch_losses = tf.squared_difference(se...
[ "0.7297349", "0.69542986", "0.6948095", "0.6948095", "0.68919253", "0.6775551", "0.665083", "0.66488665", "0.6633766", "0.6528974", "0.6520181", "0.65189093", "0.6494421", "0.64789355", "0.64417124", "0.64047754", "0.6394247", "0.639117", "0.6388315", "0.631335", "0.62982076"...
0.7003179
1
Compute any branch of the stable or unstable submanifolds of a saddle. Accepts fixed point instances of class fixedpoint_2D.
def find_saddle_manifolds(fp, xname, ds=None, ds_gamma=None, ds_perp=None, tmax=None, max_arclen=None, ic=None, eps=None, ev_dirn=1, ic_ds=None, max_pts=1000, directions=(1,-1), which=('s', 'u'), other_pts=None, rel_scale=None, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exact_saddle(V,X,Y,Z,dim,Z0=None):\n #from all_functions import find_saddle,sum_of_e_field\n if dim==3:\n print \"here\"\n print find_saddle(V,X,Y,Z,3)\n [I,J,K]=find_saddle(V,X,Y,Z,3) # guess saddle point; Z0 not needed\n print I,J,K\n r0=[X[I],Y[J],Z[K]]\n if I...
[ "0.58253855", "0.56931674", "0.54437244", "0.5257577", "0.52070004", "0.51921296", "0.5183743", "0.5179858", "0.51775", "0.51654345", "0.5148147", "0.51285076", "0.51230913", "0.5090722", "0.5089123", "0.50647557", "0.5053416", "0.5052067", "0.50175494", "0.50117624", "0.4977...
0.57671916
1
A more traditional view that also demonstrate an alternative way to use Haystack. Useful as an example of for basing heavily custom views off of. Also has the benefit of threadsafety, which the ``SearchView`` class may not be.
def search(request): query = '' results = [] qs = create_queryset(request.user) form = DateAuthorSearchForm(request.GET, searchqueryset=qs, load_all=True) if form.is_valid(): results = form.search() context = { ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_view(self, h, *args):\n return self.view(h)", "def search(request):\n raise NotImplementedError", "def shared_view(request):\n return view(shared_view, template=\"a_shared_view\")", "def a_shared_view(request):\n return view(a_shared_view)", "def search(request):\n return render(r...
[ "0.6344785", "0.57771486", "0.56842697", "0.5668535", "0.56558794", "0.56173635", "0.5589077", "0.5574361", "0.5421331", "0.540091", "0.5397322", "0.5366973", "0.5350704", "0.5332693", "0.533061", "0.53137857", "0.53135633", "0.5257664", "0.52448064", "0.5209895", "0.5179522"...
0.0
-1
Returned data frame should have trading_pair as index and include usd volume, baseAsset and quoteAsset
async def get_active_exchange_markets(cls) -> pd.DataFrame: async with aiohttp.ClientSession() as client: trading_pairs_response = await client.get(ASSET_PAIRS_URL) trading_pairs_response: aiohttp.ClientResponse = trading_pairs_response if trading_pairs_response.status != 2...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def account_df(self, typ='trades', improve=False):\n cols = ['date_open', 'date_close', 'symbol', 'style', 'volume', 'price_open', 'price_stop', 'price_limit', 'price_close', 'comment', 'magic', 'order_id_master', 'order_id_stop', 'order_id_limit', 'direction', 'price_diff', 'price_diff', 'price_diff_d', 'p...
[ "0.5413317", "0.5374446", "0.5327119", "0.5326608", "0.52844787", "0.5255842", "0.52381635", "0.52032465", "0.51819", "0.5160164", "0.5140268", "0.5139721", "0.5139721", "0.51213753", "0.50929576", "0.50690424", "0.50472456", "0.50343525", "0.501496", "0.49923664", "0.4983564...
0.56753194
0
Prompts a user for input. If the user aborts the input by sending an interrupt signal,
def prompt( text: str, default: Optional[str] = None, hide_input: bool = False, confirmation_prompt: bool = False, type: Optional[_ConvertibleType] = None, # noqa: A002 # pylint: disable=redefined-builtin value_proc: Optional[Callable[[Optional[str]], Any]] = None, prompt_suffix: str = ": ", show_defa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pause(question='PRESS ENTER TO CONTINUE ...'):\n try: input(question)\n except KeyboardInterrupt:\n global shutDown\n shutDown = True\n except: pass", "def cont():\n\n try:\n input = raw_input()\n except Exception:\n pass", "def wait_for_user_input():\n\n input...
[ "0.7238744", "0.68656516", "0.6854231", "0.67521363", "0.67260265", "0.6714292", "0.6679884", "0.6577005", "0.65114206", "0.64484817", "0.6370928", "0.6356066", "0.63458174", "0.62438965", "0.62413186", "0.62225163", "0.61820346", "0.6136225", "0.6091857", "0.6065281", "0.604...
0.0
-1
Prompts for confirmation (yes/no question). If the user aborts the input by sending a interrupt signal this
def confirm( text: str, default: bool = False, abort: bool = False, prompt_suffix: str = ": ", show_default: bool = True, err: bool = False, ): prompt = _build_prompt(text, prompt_suffix, show_default, "Y/n" if default else "y/N") while True: try: value = _prompt(prompt, err=err, hide_input=False...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confirmation(self, question, answer):\n confirm_flag = False\n while confirm_flag not in ['y', 'n']:\n confirm_flag = raw_input(question + ' [y/n]: ')\n if confirm_flag == 'y':\n print answer\n elif confirm_flag == 'n':\n print 'The u...
[ "0.7569344", "0.7401378", "0.72859263", "0.7283516", "0.7266474", "0.719268", "0.71785426", "0.7086956", "0.70464075", "0.7021681", "0.6976385", "0.69672275", "0.69638824", "0.6946273", "0.6888155", "0.6809539", "0.6780994", "0.67785114", "0.66649485", "0.6664532", "0.6661782...
0.62040895
47
Read a string from standard input, but prompt to standard error. The trailing newline is stripped.
def stderr_input(prompt: str = '', file: IO = sys.stdout) -> str: # pragma: no cover if file is sys.stdout: return input(prompt) try: stdin = sys.stdin except AttributeError: raise RuntimeError("stderr_input: lost sys.stdin") file.write(prompt) try: flush = file.flush except AttributeError: pass e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def safe_input(prompt=\"\"):\n\n\ttry:\n\t\tresult = input(prompt)\n\t\treturn result\n\texcept KeyboardInterrupt:\n\t\tsys.exit()\n\texcept:\n\t\treturn \"\"", "def get_input(prompt):\n try:\n try:\n return raw_input(prompt)\n except NameError:\n return input(prompt)\n ...
[ "0.7439654", "0.723748", "0.70752895", "0.6913516", "0.68963534", "0.6866671", "0.68438375", "0.6834515", "0.67756915", "0.6763464", "0.6721034", "0.6602405", "0.65703905", "0.65552646", "0.65077746", "0.64992315", "0.64948124", "0.64894426", "0.64843607", "0.64575666", "0.64...
0.76236886
0
Prompts a user for input. If the user aborts the input by sending an interrupt signal, this
def choice( options: Union[List[str], Mapping[str, str]], text: str = '', default: Optional[str] = None, prompt_suffix: str = ": ", show_default: bool = True, err: bool = False, start_index: int = 0 ) -> Union[str, int]: # TODO: completer for numbers? type_: click.ParamType if isinstance(options, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pause(question='PRESS ENTER TO CONTINUE ...'):\n try: input(question)\n except KeyboardInterrupt:\n global shutDown\n shutDown = True\n except: pass", "def wait_for_user_input():\n\n input(\"Pulse ENTER para continuar...\")", "def cont():\n\n try:\n input = raw_input()\n...
[ "0.7103245", "0.6709058", "0.6595114", "0.6572123", "0.65524346", "0.6543129", "0.65140307", "0.6374105", "0.63740534", "0.631756", "0.6300449", "0.628559", "0.6279168", "0.6268421", "0.62003326", "0.61359113", "0.6018758", "0.6006392", "0.5985524", "0.5977991", "0.5903809", ...
0.0
-1
Return canonical form for control state.
def canonical_ctrl_state(ctrl_state, num_qubits): if not num_qubits: return '' if isinstance(ctrl_state, CtrlAll): if ctrl_state == CtrlAll.One: return '1' * num_qubits return '0' * num_qubits if isinstance(ctrl_state, int): # If the user inputs an integer, conv...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_state(self):\n return self.cleaned_data['state'].upper()", "def state(self) -> str:", "def native_value(self) -> str:\n if isinstance(self._state, Enum):\n return self._state.name.lower()\n return self._state.lower()", "def reflect_state(self, s):\n s[2:8] = r...
[ "0.6335245", "0.5661792", "0.56419164", "0.56038505", "0.55594033", "0.55442035", "0.5506558", "0.54213786", "0.54014575", "0.5394251", "0.5330471", "0.5314586", "0.52940786", "0.5290036", "0.52667534", "0.5218633", "0.5182664", "0.5157008", "0.5146271", "0.511659", "0.511659...
0.61829215
1
Return True if command cmd has a compute/uncompute tag.
def _has_compute_uncompute_tag(cmd): for tag in cmd.tags: if tag in [UncomputeTag(), ComputeTag()]: return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _isCmdStandalone(tgen):\n features = getattr(tgen, 'features', [])\n otherFeatures = set(features) - set(('runcmd', ))\n return not otherFeatures and getattr(tgen, 'rule', None) is None", "def isOp(self):\n return True", "def is_cmd(self, name):\n \n return name in self.cmds",...
[ "0.581931", "0.5786073", "0.57732224", "0.5759559", "0.5728099", "0.5650557", "0.5638925", "0.5607169", "0.56052583", "0.55509794", "0.5506383", "0.55021065", "0.5499619", "0.54725796", "0.54692024", "0.546461", "0.5463064", "0.5448807", "0.5434303", "0.5420862", "0.5408913",...
0.9016012
0
Initialize the control engine.
def __init__(self, qubits, ctrl_state=CtrlAll.One): super().__init__() self._qubits = qubits self._state = ctrl_state
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def controls_setup(self):\n pass", "def _initialize(self):\n self.send_init_command()", "def _initialize(self):\n \n self.view.lineEdit_3.setText(\"C,H,N,O,P,S\")\n self.view.spin_hit.setValue(20)\n self.view.lineEdit_2.setValue(10.)\n self.view.checkBox_8.setCh...
[ "0.6916761", "0.6699283", "0.6575671", "0.6537157", "0.6448048", "0.6433576", "0.6422153", "0.64024854", "0.64004904", "0.64004904", "0.64004904", "0.64004904", "0.64004904", "0.64004904", "0.64004904", "0.64004904", "0.63673574", "0.63242495", "0.6309775", "0.63037765", "0.6...
0.0
-1
Receive a list of commands.
def receive(self, command_list): for cmd in command_list: self._handle_command(cmd)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def receive(self, command_list):\n for cmd in command_list:\n self._send_cmd_with_mapped_ids(cmd)", "def receive(self, command_list):\n for cmd in command_list:\n if not cmd.gate == FlushGate():\n self._add_cmd(cmd)\n\n # (try to) send on\n ...
[ "0.7666051", "0.7365854", "0.6984754", "0.69481695", "0.6923602", "0.6804654", "0.6704374", "0.6583639", "0.6574708", "0.6483976", "0.6443524", "0.6436", "0.64315933", "0.64236295", "0.6422955", "0.63806427", "0.63790524", "0.6377476", "0.63279116", "0.6277306", "0.62516063",...
0.8273917
0
Enter a controlled section.
def __init__(self, engine, qubits, ctrl_state=CtrlAll.One): self.engine = engine if isinstance(qubits, tuple): raise TypeError('Control qubits must be a list, not a tuple!') if isinstance(qubits, BasicQubit): qubits = [qubits] self._qubits = qubits self._s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enter():\n pass", "def enter(self):\r\n self.turnOffLightboxes()\r\n self.installShortcutKeys()\r\n\r\n # Set parameter set node if absent\r\n self.selectParameterNode()\r\n self.editor.updateWidgetFromMRML()\r\n \r\n # If no segmentation node exists then create one so that th...
[ "0.63331175", "0.6145211", "0.6034579", "0.5901067", "0.5828898", "0.5818313", "0.578652", "0.57040715", "0.5648721", "0.56081504", "0.54907554", "0.54647225", "0.5463961", "0.5425503", "0.5409415", "0.5407325", "0.5397818", "0.5397088", "0.5397088", "0.5394315", "0.53922415"...
0.0
-1
Context manager enter function.
def __enter__(self): if len(self._qubits) > 0: engine = ControlEngine(self._qubits, self._state) insert_engine(self.engine, engine)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __enter__(self):\n self._logger.debug(\"__enter__()\")\n self.install(\"PRE\")", "def enter():\n pass", "def main_thread_enter(self):\n ...", "def enter_context(self, cm):\n # We look up the special methods on the type to match the with\n # statement\n ...
[ "0.73215747", "0.70834184", "0.6925852", "0.69022465", "0.6660981", "0.6605945", "0.6528679", "0.6526397", "0.65165555", "0.64868927", "0.64753264", "0.64307684", "0.6430514", "0.6430324", "0.6379566", "0.6323365", "0.6323365", "0.6295275", "0.6294278", "0.62788516", "0.62653...
0.59952956
38
Context manager exit function.
def __exit__(self, exc_type, exc_value, exc_traceback): # remove control handler from engine list (i.e. skip it) if len(self._qubits) > 0: drop_engine_after(self.engine)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exit(context):\n return _nfc.exit(context)", "def __exit__(self, *args, **kwargs):\n\n pass", "def exit(self):\n pass", "def exit(self):\n self.current.exit()", "def __exit__(self, *args):\n pass", "def __exit__(self, exc_type, exc_val, exc_tb):\n\n self.quit()", ...
[ "0.79426813", "0.76409006", "0.7519487", "0.7436684", "0.7398033", "0.7334061", "0.7196403", "0.714664", "0.7124016", "0.7124016", "0.7095566", "0.70946825", "0.70733523", "0.70722145", "0.70669067", "0.7063392", "0.70594615", "0.70451325", "0.69709545", "0.69591916", "0.6957...
0.0
-1
Return the number of control qubits of the command object cmd.
def get_control_count(cmd): return len(cmd.control_qubits)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_commands(self):\n return len(self.commands)", "def count(self):\n return len(self._commands)", "def __len__(self):\n return len(self.commands)", "def length(self):\n return len(self._commands)", "def get_count_of_controls(self, recurse: bool) -> int:\n return len(...
[ "0.71016645", "0.7081369", "0.659699", "0.63224685", "0.6274492", "0.6267259", "0.6065778", "0.5953152", "0.59503293", "0.59498817", "0.5925458", "0.58802515", "0.5851433", "0.58106935", "0.5802685", "0.5787972", "0.57744926", "0.57360053", "0.5724881", "0.5709863", "0.569576...
0.91298246
0
Return whether a command has negatively controlled qubits.
def has_negative_control(cmd): return get_control_count(cmd) > 0 and '0' in cmd.control_state
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_available(self, cmd):\n num_qubits = 0\n for qureg in cmd.all_qubits:\n num_qubits += len(qureg)\n return num_qubits <= 2", "def is_use_qps(self) -> bool:\n if self.qps > 0 and self.second > 0:\n return True\n else:\n return False", "de...
[ "0.6443017", "0.62384444", "0.6159438", "0.59778637", "0.59440106", "0.59436524", "0.5875699", "0.5865012", "0.5853049", "0.5851665", "0.58293706", "0.582807", "0.5757742", "0.5732011", "0.5711578", "0.56456465", "0.56133777", "0.5585858", "0.55658156", "0.55565083", "0.55423...
0.69478786
0
Recursively yield DirEntry objects for given directory.
def scantree(path): for entry in os.scandir(path): if entry.is_dir(follow_symlinks=False): yield from scantree(entry.path) else: yield entry
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _recursive_scan(directory=None, file_extension='.dvl'):\n directory = directory or app.config['DEVICE_LOG_DRIVE']\n\n for entry in os.scandir(directory):\n if entry.is_dir(follow_symlinks=False):\n yield from _recursive_scan(entry)\n elif os.path.splitext(entry.name)[1] == file_e...
[ "0.7087995", "0.703418", "0.6827286", "0.6822487", "0.67192256", "0.6643409", "0.66230345", "0.6553806", "0.63341504", "0.6309465", "0.6306312", "0.62912905", "0.62335205", "0.6217654", "0.61574435", "0.61347914", "0.612545", "0.6041788", "0.60254", "0.6016495", "0.6011201", ...
0.59717333
23
Creates a starboard. A starboard is a channel which has messages with some stars. To configure this starboard (such as max age and threshold, which are 7 days and 5 stars by default), use starconfig's subcommands. See the help for details.
async def starboard(self, ctx): if self.bot.db.execute("SELECT * FROM starboards WHERE guild_id = ?",(ctx.guild.id,)).fetchone(): return await ctx.say("star.already") async with ctx.typing(): await ctx.channel.edit( topic=TOPIC.format(mention=self.bot.user.mention...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def add_starboard(self, ctx):\n channel = await ctx.get_text_channel(embed=CustomEmbeds.add(author=\"Channel\",\n description=\"Send a channel to add it to the starboard!\"))\n emotes = await ctx.get_emotes(embed=CustomEmbeds.ad...
[ "0.74559045", "0.6628303", "0.64687115", "0.6309718", "0.6219598", "0.59351027", "0.59275556", "0.586937", "0.5743689", "0.5702885", "0.56899554", "0.56740135", "0.558157", "0.5522696", "0.53798324", "0.53583425", "0.52350324", "0.5224017", "0.52115166", "0.52085984", "0.5154...
0.7119598
1
Enables a disabled starboard.
async def enable(self, ctx): self.bot.db.execute("UPDATE starboards SET enabled = 1 WHERE channel_id = ?", (ctx.channel.id,)) await ctx.say("star.enabled")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enable(self):\r\n self.update(enabled=True)", "def enable(self):\n self.enabled = True", "def enable(self):\n self.enabled = True", "async def starboard_toggle(self, ctx, value: bool):\n await queries.update_setting(ctx, \"starboard_settings\", \"is_enabled\", value)\n ...
[ "0.69257647", "0.673253", "0.673253", "0.6605978", "0.65678227", "0.6538243", "0.64849865", "0.6334245", "0.6330517", "0.6330517", "0.63191867", "0.62614286", "0.6255469", "0.6149117", "0.6149117", "0.6149117", "0.6149117", "0.6149117", "0.6149117", "0.6149117", "0.6149117", ...
0.7405919
0
Sets "max age" for the starboard messages. If a message is older than the specified days, the message is ignored. Note that existing messages are not affected. Defaults to 7 (one week).
async def maxage(self, ctx, age: int): if age > 0: self.bot.db.execute("UPDATE starboards SET age = ? WHERE channel_id = ?", (age,ctx.channel.id)) await ctx.say("star.age", age) await self.set_topic(ctx.channel.id) else: await ctx.say("star.unsigned", age)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_age(self, max_age):\n self._max_age = max_age", "def max_age(self, max_age):\n\n self._max_age = max_age", "def max_age(self, max_age):\n if (max_age is not None and max_age < -1): # noqa: E501\n raise ValueError(\"Invalid value for `max_age`, must be a value greater th...
[ "0.6970839", "0.6911315", "0.61830574", "0.6088173", "0.60299325", "0.58305186", "0.58305186", "0.57887924", "0.56967527", "0.5692167", "0.5583454", "0.5548023", "0.5548023", "0.55217004", "0.54962564", "0.54864573", "0.5448077", "0.5405468", "0.5401819", "0.53459024", "0.530...
0.6915784
1
Sets "threshold" for the starboard messages. The specified number of stars are required to put the message on the starboard. Note that existing messages are not affected. Defaults to 5.
async def threshold(self, ctx, threshold: int): if threshold > 0: self.bot.db.execute("UPDATE starboards SET threshold = ? WHERE channel_id = ?", (threshold, ctx.channel.id)) await ctx.say("star.threshold", threshold) await self.set_topic(ctx.channel.id) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def set_star_thresh(self, ctx: commands.Context, thresh: int):\n self.check_if_exist(ctx.guild)\n\n self.starboard_guilds = self.starboard_info.find(\"guilds\")\n\n self.starboard_guilds[str(ctx.guild.id)][\"thresh\"] = thresh\n\n self.starboard_info.update(\"guilds\", self.starbo...
[ "0.71225744", "0.59684855", "0.5927058", "0.58108085", "0.576199", "0.57090366", "0.5671583", "0.5666817", "0.5666817", "0.5666817", "0.5666817", "0.5666817", "0.5508571", "0.5468851", "0.5445576", "0.5442838", "0.538356", "0.53599596", "0.5337971", "0.5335528", "0.5254369", ...
0.7315309
0
Shows a starboard item. The argument can be either original message ID or starboard item ID.
async def star_show(self, ctx, item: Star): board = self.bot.db.execute("SELECT * FROM starboards WHERE guild_id = ?", (ctx.guild.id,)).fetchone() try: board_msg = await self.bot.get_channel(board["channel_id"]).fetch_message(item["item_id"]) except discord.NotFound: retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show(self, item_id):\n pass", "async def star_random(self, ctx):\n board = self.bot.db.execute(\"SELECT * FROM starboards WHERE guild_id = ?\", (ctx.guild.id,)).fetchone()\n item = self.bot.db.execute(\n \"SELECT item_id FROM starboard_items WHERE visible = 1 \" \\\n ...
[ "0.6767876", "0.62626845", "0.6151777", "0.6020385", "0.5975807", "0.58423346", "0.57976115", "0.5691685", "0.5685633", "0.5602847", "0.5571166", "0.5512835", "0.5495824", "0.54660666", "0.54644984", "0.54629415", "0.545546", "0.54352176", "0.541161", "0.541123", "0.54102796"...
0.8043702
0
Shows a random item.
async def star_random(self, ctx): board = self.bot.db.execute("SELECT * FROM starboards WHERE guild_id = ?", (ctx.guild.id,)).fetchone() item = self.bot.db.execute( "SELECT item_id FROM starboard_items WHERE visible = 1 " \ "ORDER BY random() LIMIT 1" ).fetchone() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show(self, item_id):\n pass", "def showItem(category_item_id):\n return render_template('item.html', item=db.findItem(id=category_item_id))", "async def random(self, ctx):\n response = await self.api.random()\n await ctx.send(embed=self._build_embed(response))", "def random_page(r...
[ "0.6923737", "0.6476034", "0.6428087", "0.64086896", "0.6310771", "0.6269286", "0.61964685", "0.6074963", "0.6051741", "0.60236067", "0.6007453", "0.59758556", "0.5961581", "0.59291637", "0.5912427", "0.58934987", "0.5885808", "0.5869903", "0.5858481", "0.58508587", "0.584529...
0.6175574
7
Enables/disables DM when your message was stared. If the parameter is not given, this returns current status. Can be used anywhere including DM.
async def star_dm(self, ctx, enable: bool = None): if enable is None: result = self.bot.db.execute("SELECT starboard_dm FROM users WHERE user_id = ?", (ctx.author.id,)).fetchone() enabled = result["starboard_dm"] if result else 0 status_str = ctx._(f"star.dm{['Disabled', 'Ena...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def moderation(self, ctx):\n\n new_value = await self.toggle_dm_setting(ctx.author.id, \"ban_kick_mute\")\n\n if new_value:\n message = \":white_check_mark: You will now receive DMs when you get muted, kicked or banned by me.\"\n else:\n message = \":white_check_mar...
[ "0.64651364", "0.59721977", "0.5788894", "0.5637827", "0.559156", "0.55866206", "0.5582838", "0.5560499", "0.5545492", "0.5535075", "0.55287397", "0.5520025", "0.5509821", "0.5500232", "0.5459743", "0.54503405", "0.544722", "0.54312956", "0.5386221", "0.5380486", "0.53682333"...
0.6530001
0
Return the minimum and maximum values in the input.
def minmax(seq, *, key=lambda x: x): iterator1, iterator2 = tee(seq) return MinMax(min(iterator1, key=key), max(iterator2, key=key))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_max(xs):\n return min(xs), max(xs)", "def get_min_max(ints):\n if len(ints) <= 0:\n return ()\n min_value = ints[0]\n max_value = ints[0]\n for i in range(len(ints)):\n temp = ints[i]\n if temp <= min_value:\n min_value = temp\n if temp >= max_value:\...
[ "0.7975695", "0.77930915", "0.7780894", "0.7709472", "0.76314646", "0.7625426", "0.7577489", "0.7568", "0.75583875", "0.74224806", "0.7407902", "0.7383869", "0.7375017", "0.73552513", "0.7351573", "0.72896475", "0.72671056", "0.7245023", "0.721607", "0.72126466", "0.72114575"...
0.0
-1
Finds the postion that a value of weight "weight" would fall in the weight_list, where weight_list is sorted by smallest to largest. Newer inputs win in ties.
def find_pos(weight, weight_list): bool_list = [weight >= x for x in weight_list] pos = bool_list.count(True) - 1 return pos
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getByWeight(list, w):\n itemId = 0\n partialWeight = list[0][1]\n while partialWeight < w:\n itemId += 1\n partialWeight += list[itemId][1]\n return list[itemId]", "def solve_brute_force(n: int, W: int, weight: List[int], value: List[int]) -> int:\n mapped_items = [{\"w\": w, \"v...
[ "0.7426046", "0.6773496", "0.6738176", "0.6716903", "0.67166317", "0.6681879", "0.6489452", "0.647155", "0.6244381", "0.6119967", "0.6119967", "0.6119967", "0.6103172", "0.5987175", "0.59611946", "0.5952065", "0.5946552", "0.594247", "0.59135944", "0.5880885", "0.5846692", ...
0.7051767
1
Adjusts top10 list in ascending order, by inserting a new item in appropriate place and adjusting others appropriately
def adjust_top10(value, pos, weight, top10, top10weights): # Create new top10 to be adjusted newtop10 = top10 newtop10weights = top10weights # Keep higher ones, shift lower ones left one newtop10[0:pos] = top10[1:pos + 1] newtop10weights[0:pos] = top10weights[1:pos + 1] # add new ones ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top10(self, top10: List[Word]):\n\n self._top10 = top10", "def move_top ( self ):\n list, index = self.get_info()\n self.value = [ list[index] ] + list[:index] + list[index+1:]", "def test_sorting(sort=selection_sort, num_items=20, max_value=50):\n # TODO: Repeat until all items ar...
[ "0.69200873", "0.61177766", "0.6019761", "0.5785143", "0.574743", "0.56948155", "0.5632971", "0.5610252", "0.5595934", "0.557611", "0.5559975", "0.5536772", "0.5520824", "0.5512247", "0.5477111", "0.54510283", "0.54510283", "0.54265624", "0.5416262", "0.5411289", "0.54062337"...
0.72702825
0
Calculates the next state of a given 'board' following the classic rules of Conway's Game Of Life
def original(arr): height = np.shape(arr)[0] width = np.shape(arr)[1] result = np.array(arr) for row in range(height): for col in range(width): neighbors = 0 val = result[row][col] for i in range(-1, 2): for j in range(-1, 2): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_next_board_state(self):\n new_board_state = np.zeros_like(self.board_state)\n\n for x in range(self.board_size[0]):\n for y in range(self.board_size[0]):\n new_board_state[x][y] = self.next_state_of_cell(x,y)\n \n self.set_state(new_board_state)",...
[ "0.8105419", "0.74080914", "0.7388347", "0.73284864", "0.7323322", "0.72788733", "0.7252915", "0.7215804", "0.72030765", "0.72030765", "0.7184667", "0.70937914", "0.70153326", "0.7014133", "0.7008801", "0.7003514", "0.7002293", "0.69419354", "0.693517", "0.69348997", "0.69085...
0.0
-1
receive from whichever address, echo to certain address
def run(self): super().run() echo = self.echo local = self.local remote = self.remote transport = Transceiver(local) transport.set_timeout(0.5) self.__result: list[Entry] = [] while True: try: packet = transport.recv(None) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _receive(self, what, address='localhost:44818', **kwargs):\n\n tag_string = ''\n tag_string = EnipProtocol._tuple_to_cpppo_tag(what)\n\n # print(\"DEBUG \" + tag_string)\n\n cmd = shlex.split(\n self._client_cmd +\n '--log ' + self._client_log +\n ' ...
[ "0.6488217", "0.627662", "0.61385673", "0.6084831", "0.6061891", "0.6032116", "0.59276605", "0.587819", "0.58575743", "0.58568585", "0.57779133", "0.57538867", "0.57408154", "0.57389486", "0.5735249", "0.5732271", "0.572568", "0.571604", "0.5709182", "0.5708799", "0.56972384"...
0.0
-1
Runs the unit tests without test coverage.
def test(): tests = unittest.TestLoader().discover('project/tests', pattern='test*.py') result = unittest.TextTestRunner(verbosity=2).run(tests) if result.wasSuccessful(): return 0 return 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _run_ci_test():\n _run_install(False)\n _run_coverage_html(False)\n _run_typecheck_xml(False)\n _run_lint(True)", "def main():\n import coverage\n import nose\n import os\n from shutil import rmtree\n rmtree('./covhtml', ignore_errors=True)\n try:\n os.remove('./.coverage...
[ "0.7740198", "0.7395665", "0.73899317", "0.73077023", "0.7184236", "0.71184987", "0.7116021", "0.7049126", "0.695683", "0.6951264", "0.6858743", "0.682145", "0.6820713", "0.6819008", "0.6809791", "0.67945355", "0.6780462", "0.6756857", "0.6749489", "0.671787", "0.6669164", ...
0.0
-1
Runs the unit tests with coverage.
def cov(): tests = unittest.TestLoader().discover('project/tests') result = unittest.TextTestRunner(verbosity=2).run(tests) if result.wasSuccessful(): COV.stop() COV.save() print('Coverage Summary:') COV.report() basedir = os.path.abspath(os.path.dirname(__file__)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n cmd = 'coverage run setup.py test && coverage report -m'\n check_call(cmd, shell=True)", "def coverage(ctx):\n ctx.run(\"coverage run --source {PROJECT_NAME} -m pytest\".format(PROJECT_NAME=PROJECT_NAME))\n ctx.run(\"coverage report -m\")\n ctx.run(\"coverage html\")", "...
[ "0.8225887", "0.8197109", "0.8087866", "0.8035677", "0.79417413", "0.78974116", "0.77752006", "0.7715321", "0.7702348", "0.7699923", "0.7665237", "0.7642242", "0.7576189", "0.75723445", "0.7559191", "0.75513554", "0.7547175", "0.7532325", "0.75018466", "0.74963635", "0.746709...
0.76248956
12
Creates the db tables.
def create_db(): database.db.create_all() get_ulm() for fixture_file in glob.glob(config.DevelopmentConfig.FIXTURES_DIRS + '/*.json'): fixtures = JSONLoader().load(fixture_file) load_fixtures(database.db, fixtures) MigrationManager().stamp_db()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_tables():\n db.create_all()", "def create_tables():\n db.create_all()", "def create_tables():\n db.create_all()", "def create_db_tables():\n\n try:\n webapp.dbsql.create_all()\n webapp.dbsql.session.commit()\n except Exception as e:\n # TODO: melhorar o ...
[ "0.90999454", "0.90999454", "0.8910174", "0.86784077", "0.8614145", "0.8553592", "0.8508828", "0.845593", "0.8445083", "0.8376737", "0.83389515", "0.82984424", "0.8226738", "0.8191471", "0.81631696", "0.8158732", "0.81120193", "0.80407983", "0.7961357", "0.7934169", "0.793311...
0.7389031
100
Drops the db tables.
def drop_db(): database.db.reflect() database.db.drop_all() print('Dropped the database')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drop_database_tables(cls):\n cursor = Database.connect_to_db()\n # drop users table\n sql_command = \"\"\" DROP TABLE IF EXISTS users CASCADE;\n \"\"\"\n cursor.execute(sql_command)\n # drop parties table\n sql_command = \"\"\" DROP TABLE IF EXISTS parties C...
[ "0.8613892", "0.85542655", "0.8401308", "0.8334024", "0.829665", "0.82727927", "0.8257214", "0.8239192", "0.8230405", "0.8215113", "0.8172018", "0.8147676", "0.8134603", "0.8033471", "0.80164933", "0.7996094", "0.7996094", "0.7996094", "0.7996094", "0.7996094", "0.7996094", ...
0.766048
35
Write the workflow info dict to the output stream.
def __call__(info, output_stream, config_variant=u""):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_info_to_file(self):\n\n self.info.write_mission_info()\n\n self.logger.info(\"Mission instance write succeeded.\")", "def dump(self, output_stream):\n raise NotImplementedError", "def save(self, context_dir: ContextDir) -> None:\n logger.info(\"Writing workflow data into %...
[ "0.60342133", "0.60284674", "0.58762455", "0.5604245", "0.55985683", "0.5569691", "0.55344164", "0.5529275", "0.55062336", "0.5501112", "0.545062", "0.5405541", "0.5363541", "0.5357599", "0.53369945", "0.5332138", "0.52984995", "0.52809745", "0.527305", "0.52714384", "0.52711...
0.48797187
76
Read CSV from the given input stream and return a workflow info dict.
def __call__(input_stream, config_variant=u""):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(self, stream):\n rows = [row for row in csv.reader(stream)]\n if args.headings and rows:\n \"\"\"\n Turn the list of lists into a list of dictionaries making use of the heading row\n \"\"\"\n ret = []\n order = rows[0]\n for row in rows[1:]:\n ret.append({name:...
[ "0.6305087", "0.616394", "0.59998536", "0.57927126", "0.5764348", "0.56994", "0.56341255", "0.5578651", "0.5536898", "0.55146277", "0.5498734", "0.5492436", "0.54921895", "0.5491747", "0.5480112", "0.5363468", "0.5362126", "0.5310172", "0.5305016", "0.5297404", "0.52790266", ...
0.4873241
71
Return a list of messages.
def __call__():
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_messages(self):", "def get_messages(self):\n res = self.conn.cursor().execute(\"SELECT * FROM messages\")\n return res.fetchall()", "def get_msgs(self):\n msgs = []\n while True:\n try:\n msgs.append(self.get_msg(block=False))\n except E...
[ "0.8454096", "0.8423979", "0.8322954", "0.8322954", "0.8192126", "0.8162427", "0.8145105", "0.81278396", "0.8071668", "0.8057453", "0.80292755", "0.7976051", "0.79759413", "0.7859721", "0.78407884", "0.77565014", "0.77484095", "0.770216", "0.7694379", "0.7694379", "0.7694379"...
0.0
-1
Calculates the correction factor for ambient air temperature and relative humidity Based on the linearization of the temperature dependency curve under and above 20 degrees Celsius, asuming a linear dependency on humidity,
def get_correction_factor(self, temperature, humidity): if temperature < 20: return self.CORA * temperature * temperature - self.CORB * temperature + self.CORC - (humidity - 33.) * self.CORD return self.CORE * temperature + self.CORF * humidity + self.CORG
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_corrected_resistance(self, temperature, humidity):\n return self.get_resistance()/ self.get_correction_factor(temperature, humidity)", "def get_corrected_resistance(self, temperature, humidity):\n return self.get_resistance()/ self.get_correction_factor(temperature, humidity)", "def corre...
[ "0.67288923", "0.67288923", "0.63658255", "0.6330217", "0.6249179", "0.61254853", "0.60804427", "0.591038", "0.5909975", "0.58495927", "0.58438057", "0.58438057", "0.57863986", "0.57804346", "0.5774944", "0.5772292", "0.5767601", "0.5738072", "0.5698512", "0.56778646", "0.564...
0.7517804
1
Returns the resistance of the sensor in kOhms // 1 if not value got in pin
def get_resistance(self): adc = ADC(self.pin) value = adc.read() if value == 0: return -1 return (4095./value - 1.) * self.RLOAD
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_resistance(self):\n adc = ADC(self.pin)\n value = adc.read()\n if value == 0:\n return -1\n\n return (4095./value - 1.) * self.RLOAD # ESP32 maksimi, ESP8266:lle arvo on 1023", "def get_distance():\n \n GPIO.output(pinTrigger, False) # pulse off\n time.sle...
[ "0.7418249", "0.64756715", "0.63563746", "0.62588537", "0.6185685", "0.6180163", "0.61774236", "0.5992633", "0.59730357", "0.59586394", "0.5931926", "0.5876045", "0.58549595", "0.58542717", "0.5832019", "0.5829989", "0.58182263", "0.5806874", "0.5794576", "0.5794576", "0.5763...
0.71054703
1
Gets the resistance of the sensor corrected for temperature/humidity
def get_corrected_resistance(self, temperature, humidity): return self.get_resistance()/ self.get_correction_factor(temperature, humidity)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_resistance(self):\n adc = ADC(self.pin)\n value = adc.read()\n if value == 0:\n return -1\n\n return (4095./value - 1.) * self.RLOAD # ESP32 maksimi, ESP8266:lle arvo on 1023", "def get_resistance(self):\n adc = ADC(self.pin)\n value = adc.read()\n ...
[ "0.7635503", "0.74764", "0.69839656", "0.68464166", "0.6839649", "0.67363864", "0.6672957", "0.663751", "0.65953994", "0.65851945", "0.6578019", "0.65570176", "0.65442514", "0.6527985", "0.64984643", "0.64984643", "0.6488228", "0.6481326", "0.6471587", "0.646373", "0.639092",...
0.7932213
1
Returns the ppm of CO2 sensed (assuming only CO2 in the air)
def get_ppm(self): return self.PARA * math.pow((self.get_resistance()/ self.RZERO), -self.PARB)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def p2(self) -> float:\n return self.distortion_coefficients[4]", "def read_ch2_pressure(self):\n sensor = self.ch2_index + 1\n return self.vgc.read_sensor(sensor)", "def m2(self):\n return self.mass[1]", "def Pp(nccd):\n return (128.1-56.9) * (nccd - 1) / (6-1) + 56.9", "def...
[ "0.69014174", "0.614412", "0.61084104", "0.59173745", "0.5897229", "0.5883357", "0.5818302", "0.5813648", "0.57905394", "0.572007", "0.5702351", "0.5689262", "0.5672273", "0.56600434", "0.5656385", "0.5643109", "0.5642826", "0.55892974", "0.55835027", "0.5540734", "0.5529631"...
0.6490881
2
Returns the ppm of CO2 sensed (assuming only CO2 in the air) corrected for temperature/humidity
def get_corrected_ppm(self, temperature, humidity): return self.PARA * math.pow((self.get_corrected_resistance(temperature, humidity)/ self.RZERO), -self.PARB)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_ch2_pressure(self):\n sensor = self.ch2_index + 1\n return self.vgc.read_sensor(sensor)", "def p2(self) -> float:\n return self.distortion_coefficients[4]", "def get_pressure(self): # This function implements the equations needed to convert the digital data into mbars\n sel...
[ "0.68633485", "0.64311475", "0.6035399", "0.601689", "0.5868461", "0.5868461", "0.58088636", "0.5721188", "0.56800145", "0.56064653", "0.55609304", "0.55468017", "0.5532125", "0.55313677", "0.5518863", "0.55117184", "0.54998475", "0.5495386", "0.5493003", "0.54853326", "0.548...
0.6452072
2
Returns the resistance RZero of the sensor (in kOhms) for calibratioin purposes
def get_rzero(self): return self.get_resistance() * math.pow((self.ATMOCO2/self.PARA), (1./self.PARB))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_corrected_rzero(self, temperature, humidity):\n return self.get_corrected_resistance(temperature, humidity) * math.pow((self.ATMOCO2/self.PARA), (1./self.PARB))", "def get_corrected_rzero(self, temperature, humidity):\n return self.get_corrected_resistance(temperature, humidity) * math.pow(...
[ "0.75763285", "0.75763285", "0.72106373", "0.70308226", "0.6785906", "0.6573991", "0.6407301", "0.62468076", "0.61387134", "0.60672534", "0.6046186", "0.6046186", "0.59931934", "0.5981607", "0.5975342", "0.5957084", "0.59491", "0.59407234", "0.5909753", "0.58624816", "0.58089...
0.7964137
1
Returns the resistance RZero of the sensor (in kOhms) for calibration purposes corrected for temperature/humidity
def get_corrected_rzero(self, temperature, humidity): return self.get_corrected_resistance(temperature, humidity) * math.pow((self.ATMOCO2/self.PARA), (1./self.PARB))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_rzero(self):\n return self.get_resistance() * math.pow((self.ATMOCO2/self.PARA), (1./self.PARB))", "def get_rzero(self):\n return self.get_resistance() * math.pow((self.ATMOCO2/self.PARA), (1./self.PARB))", "def get_resistance(self):\n adc = ADC(self.pin)\n value = adc.read(...
[ "0.7580876", "0.7580876", "0.6772141", "0.6595775", "0.627289", "0.627289", "0.6242239", "0.62241274", "0.5995406", "0.5957256", "0.59282094", "0.5875282", "0.58737624", "0.57592624", "0.5742674", "0.5665439", "0.56521314", "0.5646416", "0.5641885", "0.56370544", "0.56231505"...
0.78341985
1
Find and create a configuration for Boost. prefix Where to find sofiasip, should sofiasip/sip.h.
def __init__(self, prefix = None): # Compute the search path. if prefix is None: test = [Path('/usr'), Path('/usr/local')] else: test = [Path(prefix)] self.__prefix = self._search_all('include/sofia-sip-1.12/sofia-sip/sip.h', test)[0] self.__config = drake...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup():\n\tglobal config_parser, config_file\n\tglobal prefix\n\n\tif os.path.islink(sys.argv[0]):\n\t\tlink = os.readlink(sys.argv[0])\n\n\t\tif not os.path.isabs(link):\n\t\t\tlink = os.path.join(os.path.dirname(sys.argv[0]), link)\n\n\t\tprefix = os.path.dirname(os.path.abspath(link))\n\telse:\n\t\tprefix ...
[ "0.5301707", "0.52438116", "0.51499075", "0.5118139", "0.50677866", "0.5059345", "0.5040578", "0.50159454", "0.49063885", "0.48804155", "0.48284978", "0.4827175", "0.4806287", "0.4769773", "0.47503495", "0.47349274", "0.47349274", "0.47349274", "0.47349274", "0.4719681", "0.4...
0.67315805
0
Transliterate and clean username by removing any unsupported character
def clean_username(value): if NO_ASCII_REGEX.search(value): value = unidecode(value) value = NO_ASCII_REGEX.sub('', value) value = NO_SPECIAL_REGEX.sub('', value) return value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_username(username):\n\n regex = compile(UnicodeUsernameValidator.regex)\n normalized_username = \"\"\n for char in username:\n if not regex.match(char):\n continue\n normalized_username += char\n return normalized_username", "def clean_username(self, username):\...
[ "0.8276948", "0.7640557", "0.748814", "0.7462814", "0.6971219", "0.6806881", "0.6668218", "0.6659604", "0.6582828", "0.6548192", "0.6532645", "0.65318185", "0.65207565", "0.6505552", "0.6473751", "0.64688873", "0.6456", "0.64483285", "0.64419836", "0.64402777", "0.6427039", ...
0.8559825
0
Replacement of ore.alchemist.container.stringKey The difference is that here the primary_key is not determined by sqlalchemy.orm.mapper.primary_key_from_instance(obj) but by doing the logically equivalent (but a little more laborious) [ getattr(instance, c.name) for c in mapper.primary_key ]. This is because, in some h...
def stringKey(obj): unproxied = proxy.removeSecurityProxy(obj) mapper = orm.object_mapper(unproxied) #primary_key = mapper.primary_key_from_instance(unproxied) identity_values = [ getattr(unproxied, c.name) for c in mapper.primary_key ] identity_key = "-".join(map(str, identity_values)) return "...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key(self):\n def validate(name):\n '''Compute the key if necessary and validate'''\n found = getattr(self, name)\n value = found() if callable(found) else found\n if value is None:\n raise BadKeyError(\"The key for %s cannot be None\" % self)\n ...
[ "0.69380665", "0.67975974", "0.6636642", "0.6627335", "0.64218795", "0.6354907", "0.6309344", "0.62846273", "0.622991", "0.62281317", "0.61777174", "0.61190313", "0.6101327", "0.6091566", "0.6083226", "0.6061366", "0.6051213", "0.6004258", "0.5950747", "0.5949102", "0.5949088...
0.7004091
0
Generator of all [zope.schema] fields that will be displayed in a container listing. Redefines alchemist.ui.container.getFields, making use of the property of the ModelDescriptor class.
def getFields(context, interface=None, annotation=None): if interface is None: domain_model = proxy.removeSecurityProxy(context.domain_model) interface = utils.get_derived_table_schema(domain_model) if annotation is None: annotation = utils.get_descriptor(interface) for field_name in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _fields(self, doclet):\n FIELD_TYPES = OrderedDict([('params', _params_formatter),\n ('properties', _params_formatter),\n ('exceptions', _exceptions_formatter),\n ('returns', _returns_formatter)])\n ...
[ "0.6986266", "0.6902756", "0.6768921", "0.6752611", "0.6708141", "0.66911685", "0.66597337", "0.66597337", "0.66573167", "0.6641873", "0.65973717", "0.65927196", "0.6563586", "0.65375286", "0.6519489", "0.6499071", "0.64926445", "0.6473653", "0.646271", "0.64609843", "0.64545...
0.67437035
4
An implementation of zope.app.container.contained.contained that doesn't generate events, for internal use. copied from SQLOS / z3c.zalchemy (via ore.alchemist.container)
def contained(obj, parent, name=None): if (parent is None): raise TypeError("Must provide a parent") if not IContained.providedBy(obj): if ILocation.providedBy(obj): interface.directlyProvides(obj, IContained, interface.directlyProvidedBy(obj)) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _containment_onAdd( self, item, container ):\n # Not calling base class's methods from here avoids reinitialization\n # of all the content objects after product version change.\n # Setup is carried by generator anyway.\n\n # need to realize same as Scheduler schema to provide non-co...
[ "0.5968703", "0.5593695", "0.5585771", "0.5165978", "0.50236136", "0.49452823", "0.49268574", "0.48931044", "0.4875816", "0.478532", "0.47574094", "0.46905568", "0.46905568", "0.4670254", "0.46697664", "0.4660797", "0.4616566", "0.46158904", "0.46091568", "0.45892322", "0.458...
0.5526841
3
This method pulls a subset/batch of values for paging through a container.
def batch(self, order_by=(), offset=0, limit=20, filter=None): query = self._query if filter: query = query.filter(filter) if order_by: query = query.order_by(order_by) #limit and offset must be applied after filter and order_by query =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_full_container_list(container_name, **kwargs):\n limit = 10000\n kwargs['limit'] = limit\n page = []\n seed = []\n _, page = get_conn().get_container(container_name, **kwargs)\n seed.extend(page)\n\n while len(page) == limit:\n # keep getting pages..\n kwargs['marker'] = ...
[ "0.6219603", "0.5777015", "0.56956834", "0.5685915", "0.5678526", "0.56506056", "0.5633514", "0.5525495", "0.54748476", "0.5472662", "0.5422143", "0.54113364", "0.539315", "0.5385653", "0.53844", "0.5360519", "0.5335842", "0.5334678", "0.53321403", "0.5319961", "0.5312008", ...
0.56218
7
Parse arguments from commandline RETURNS
def parseArgs(): parser = ap.ArgumentParser() parser.add_argument("-cf", "--controlfile", metavar="FILE", type=str, help="path to control file") args = parser.parse_args() controlfile = args.controlfile return controlfile
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_arguments(args):", "def process_command_line_arguments() -> Namespace:\n\n parser = build_parser()\n arguments = parser.parse_args()\n\n return arguments", "def parse_args():\n parser = argparse.ArgumentParser(\n description=\"Reads datapacket pcds, interpolates quaternions and gen...
[ "0.85394055", "0.76848423", "0.76680905", "0.7588562", "0.75848377", "0.7569822", "0.75066495", "0.7421597", "0.7406338", "0.7390177", "0.7364632", "0.7349577", "0.7346166", "0.73298585", "0.7313611", "0.7307958", "0.7288206", "0.7281204", "0.72765344", "0.72620463", "0.72527...
0.0
-1
Tests that multiple serial `get`s perform only a single actual call to batch_get
def test_batch_get_lazy_load(): t = VersionedTransaction(dict()) table_a = ItemTable("a") table_b = ItemTable("b") a1_k = dict(id="a1") a2_k = dict(id="a2") b1_k = dict(id="b1") a3_k = dict(id="a3") def triple_get(t: VersionedTransaction) -> VersionedTransaction: a1 = table_a....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_batch(self):\n pass", "async def test_batch_get_data(container_requester):\n async with container_requester as requester:\n await requester(\n 'POST', '/db/guillotina', data=json.dumps({\n '@type': 'Item',\n 'id': 'foobar1'\n }))\n ...
[ "0.65004903", "0.63475984", "0.61924875", "0.6180004", "0.6172568", "0.6104523", "0.60755324", "0.60726875", "0.60234624", "0.5951735", "0.5937699", "0.59353304", "0.5891406", "0.588716", "0.5864232", "0.58354574", "0.5834128", "0.5820583", "0.58080596", "0.57994694", "0.5795...
0.6140659
5
Write a function that adds 2 integers.
def add_integer(a, b=98): if not isinstance(a, (int, float)): raise TypeError('a must be an integer') if not isinstance(b, (int, float)): raise TypeError('b must be an integer') if type(a) or type(b) is float: a, b = int(a), int(b) return a + b
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_numbers(a: int, b: int) -> int:\n return a + b", "def add_numbers(x,y):\n return x + y", "def add_numbers(a,b):\r\n return a+ b", "def add_numbers(x, y):\n return x + y", "def add_numbers(x, y):\r\n return x + y", "def add_ints(num1, num2):\n print(int(num1) + int(num2))", "de...
[ "0.8246698", "0.8066365", "0.80515903", "0.8043867", "0.8028387", "0.8026784", "0.79746944", "0.79707396", "0.7965914", "0.79455554", "0.79455554", "0.79455554", "0.79455554", "0.79455554", "0.7943379", "0.79035944", "0.78871435", "0.7832339", "0.7813779", "0.7810564", "0.780...
0.72065014
81
To test the list of contributing centers
def test_ls_contributing(self): sv = nao(gto=mol) pb = prod_basis() pb.sv = sv pb.sv.ao_log.sp2rcut[0] = 10.0 pb.prod_log = sv.ao_log pb.prod_log.sp2rcut[0] = 10.0 pb.ac_rcut = max(sv.ao_log.sp2rcut) pb.ac_npc_max = 10 lsc = pb.ls_contributing(0,1) self.assertEqual(len(lsc),10) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_distribution_centers(self):\n pass", "def test_center(self):\n\n self.assertTrue((self.cs.center == np.array([[0], [0]])).all())", "def generate_centers(self):\n\t\tcenters = []\n\t\tsize = self.config.image_size\n\t\tfor i in range(self.config.num_obj):\n\t\t\tflag = True\n\t\t\twhi...
[ "0.7282083", "0.7242888", "0.6997606", "0.677467", "0.6724305", "0.6636216", "0.65077364", "0.6447535", "0.641797", "0.6415763", "0.626583", "0.6246309", "0.62288153", "0.6155707", "0.61542696", "0.6153966", "0.6150618", "0.6147836", "0.6143063", "0.6143059", "0.61429036", ...
0.0
-1
Initialize puzzle with default height and width Returns a Puzzle object
def __init__(self, puzzle_height, puzzle_width, initial_grid=None): self._height = puzzle_height self._width = puzzle_width self._grid = [[col + puzzle_width * row for col in range(self._width)] for row in range(self._height)] if initial_grid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, puzzle_height, puzzle_width, initial_grid=None):\r\n self._height = puzzle_height\r\n self._width = puzzle_width\r\n self._grid = [[col + puzzle_width * row\r\n for col in range(self._width)]\r\n for row in range(self._height)]\r\n\...
[ "0.7760379", "0.7760379", "0.7760379", "0.7755133", "0.77309585", "0.72809523", "0.6797846", "0.6736831", "0.6706259", "0.66702473", "0.6657214", "0.6637784", "0.6606009", "0.6548512", "0.6464826", "0.6438714", "0.6434132", "0.6341456", "0.63368994", "0.6271822", "0.6270025",...
0.7743432
5
Generate string representaion for puzzle Returns a string
def __str__(self): ans = "" for row in range(self._height): ans += str(self._grid[row]) ans += "\n" return ans
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n puzzle_string = '—' * 13 + '\\n'\n for i in range(self.PUZZLE_NUM_ROWS):\n for j in range(self.PUZZLE_NUM_COLUMNS):\n puzzle_string += '│{0: >2}'.format(str(self.position[i][j]))\n if j == self.PUZZLE_NUM_COLUMNS - 1:\n ...
[ "0.7646727", "0.7117016", "0.71114206", "0.7055232", "0.6831262", "0.6665103", "0.6616839", "0.6554321", "0.6554", "0.6470969", "0.646938", "0.6457912", "0.6453044", "0.64245826", "0.6423748", "0.6408869", "0.63958913", "0.6389163", "0.6384862", "0.6339044", "0.6336588", "0...
0.62557524
29
Getter for puzzle height Returns an integer
def get_height(self): return self._height
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def height(self) -> int:", "def height(self) -> int:", "def height(self) -> int:", "def tileHeight(self):\n return self._tileHeight", "def height(self):\n yy = self.yy\n return max(yy) - min(yy)", "def height(self):\n return self[\"height\"]", "def height(self):\n ret...
[ "0.77167135", "0.77167135", "0.77167135", "0.74308836", "0.735531", "0.7349286", "0.7349286", "0.7335078", "0.7335078", "0.7335078", "0.7335078", "0.7335078", "0.7335078", "0.7335078", "0.7335078", "0.7335078", "0.7335078", "0.7335078", "0.7335078", "0.7335078", "0.7335078", ...
0.70786816
60
Getter for puzzle width Returns an integer
def get_width(self): return self._width
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_grid_width(puzzle: str) -> int:\r\n return int(len(puzzle) ** (1 / 2))", "def width(self) -> int:", "def width(self) -> int:", "def width(self):\n return self.board.shape[1]", "def tileWidth(self):\n return self._tileWidth", "def expected_width(self):\n\t\treturn self.expected_ti...
[ "0.8019565", "0.7344483", "0.7344483", "0.7160062", "0.7134164", "0.70831394", "0.70282716", "0.6884904", "0.68540174", "0.68540174", "0.68540174", "0.68540174", "0.68540174", "0.68540174", "0.68540174", "0.68540174", "0.68540174", "0.68540174", "0.68540174", "0.68540174", "0...
0.66701204
43
Getter for the number at tile position pos Returns an integer
def get_number(self, row, col): return self._grid[row][col]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetTileIndex(self, pos):\r\n #pixel = rpg_image.GetPixel(self.image, pos)\r\n try:\r\n pixel = self.image_buffer[pos[0]][pos[1]]\r\n except IndexError, e:\r\n pixel = -1\r\n \r\n return pixel", "def tile_index_at(self, position: TilePosition) -> int:\r\n tile_index: int = pyxe...
[ "0.8069442", "0.76283735", "0.744377", "0.7299405", "0.7299405", "0.7299405", "0.71124285", "0.700416", "0.69980204", "0.686322", "0.6761352", "0.67372394", "0.6710306", "0.67092806", "0.67069876", "0.66530937", "0.6636823", "0.66345775", "0.6570085", "0.65366554", "0.6534921...
0.7249243
9