query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
transform basis_0 into basis_1. Each basis is given by a matrix with basis vectors as columns. | def local_basis_transform(basis1, basis0):
U_local = np.conj(basis1).T @ basis0
return(U_local)
"""what bases? For each qubit sig_x sig_y sig_z""" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_coordinate(basis_vector_list, original_basis_vector_list=None):\n\n new_basis = basis_vector_matrix(*basis_vector_list)\n\n original = np.eye(\n *new_basis.shape) if original_basis_vector_list is None else basis_vector_matrix(*original_basis_vector_list)\n\n transform_matrix = np.lina... | [
"0.62653255",
"0.5880005",
"0.5821347",
"0.5809387",
"0.5731825",
"0.5679616",
"0.5646678",
"0.5592812",
"0.55275893",
"0.5480845",
"0.546837",
"0.5431843",
"0.54287106",
"0.54053915",
"0.53973544",
"0.5397155",
"0.5388353",
"0.5385137",
"0.535694",
"0.53531295",
"0.53493744"... | 0.7561553 | 0 |
Concatenate all .nc files found in the directory set by path. | def concatenate_weather_files(dir_path):
# import all the files as datasets
fnames = get_weather_files(dir_path)
ds_list = []
for f in fnames:
with xr.open_dataset(f, engine='netcdf4') as ds:
ds_list.append(ds)
ds_main = xr.concat(ds_list, dim='time')
groups = ds_main.groupby... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat(files, out_file):\n # TODO: Deal with long file lists by writing to stdin of ncrcat\n if not files:\n raise ValueError('List of files to concat is empty.')\n return subprocess.call(['ncrcat', '-h'] + files + ['-O', out_file])",
"def setup_ncfile_list(self):\n self.ncfilelist = [... | [
"0.6077744",
"0.5919777",
"0.5578698",
"0.55496675",
"0.5469511",
"0.5451311",
"0.5433077",
"0.541949",
"0.5347396",
"0.53005445",
"0.529148",
"0.5255915",
"0.52046883",
"0.5115151",
"0.51068336",
"0.510619",
"0.5091688",
"0.5071932",
"0.5057258",
"0.50557595",
"0.5050274",
... | 0.6614267 | 0 |
Generate yearly weather data. | def generate_year_weather_data(directory, new_fname):
ds_whole = concatenate_weather_files(directory)
print(ds_whole.last())
ds_whole.last().to_netcdf(directory+new_fname+".nc") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_polynesian_weather_data():\n weather_path = os.path.dirname(os.path.realpath(__file__))\n low_fp = weather_path + \"/polynesia_weather/low/1976/\"\n med_fp = weather_path + \"/polynesia_weather/med/1985/\"\n high_fp = weather_path + \"/polynesia_weather/high/1982/\"\n low_name = \"polyn... | [
"0.72123104",
"0.64947665",
"0.63906455",
"0.62107384",
"0.61851335",
"0.6076339",
"0.5953477",
"0.59413636",
"0.5903867",
"0.5900672",
"0.5898883",
"0.5863625",
"0.5853418",
"0.58457875",
"0.57923204",
"0.5756051",
"0.5742416",
"0.5711562",
"0.5694768",
"0.5660596",
"0.56394... | 0.6878405 | 1 |
Generate the 14 month long weather scenarios required for the Polynesian voyaging case study. | def generate_polynesian_weather_data():
weather_path = os.path.dirname(os.path.realpath(__file__))
low_fp = weather_path + "/polynesia_weather/low/1976/"
med_fp = weather_path + "/polynesia_weather/med/1985/"
high_fp = weather_path + "/polynesia_weather/high/1982/"
low_name = "polynesia_1976"
me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genWeather():\n\n weather = random.choice(weather_conditions.keys())\n condition = weather_conditions[weather]\n (tMax, tMin) = condition[\"temperature\"]\n (pMax, pMin) = condition[\"pressure\"]\n (hMax, hMin) = condition[\"humidity\"]\n\n return weather + \"|\" + str(round(random.uniform(tM... | [
"0.58741105",
"0.5515104",
"0.53864247",
"0.5307548",
"0.52754146",
"0.5256484",
"0.51793635",
"0.517663",
"0.5175533",
"0.51306146",
"0.5115513",
"0.5085327",
"0.5064879",
"0.50637335",
"0.50539565",
"0.5053406",
"0.50467163",
"0.5032078",
"0.5029004",
"0.5014744",
"0.501140... | 0.66603565 | 0 |
Returns True if this is a record_id for an original record in the given subdomain (a record originally created in this subdomain's repository). | def is_original(subdomain, record_id):
try:
domain, local_id = record_id.split('/', 1)
return domain == subdomain + '.' + HOME_DOMAIN
except ValueError:
raise ValueError('%r is not a valid record_id' % record_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_original(self):\n return is_original(self.subdomain, self.record_id)",
"def is_clone(subdomain, record_id):\n return not is_original(subdomain, record_id)",
"def _is_record_status(self, status_id):\n return status_id == self.record_status",
"def filter(self, record: LogRecord) -> bool... | [
"0.7419207",
"0.7321421",
"0.59872353",
"0.5790102",
"0.57485324",
"0.5571445",
"0.5525837",
"0.5388121",
"0.53777045",
"0.5266979",
"0.51531965",
"0.5150227",
"0.5116856",
"0.51115614",
"0.50956744",
"0.50860584",
"0.50371826",
"0.50348437",
"0.49916115",
"0.49829006",
"0.49... | 0.83027816 | 0 |
Returns True if this is a record_id for a clone record (a record created in another repository and copied into this one). | def is_clone(subdomain, record_id):
return not is_original(subdomain, record_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_clone(self):\n return not self.is_original()",
"def is_original(self):\n return is_original(self.subdomain, self.record_id)",
"def _is_clone_snapshot_name(self, snapshot):\n name = snapshot.split('@')[-1]\n return name.startswith('cinder-clone-snapshot-')",
"def clone_recor... | [
"0.6673406",
"0.5904524",
"0.58371603",
"0.58270663",
"0.5803306",
"0.5743126",
"0.56958985",
"0.5615784",
"0.55651015",
"0.5487205",
"0.54350823",
"0.54330474",
"0.52972907",
"0.52061427",
"0.5168266",
"0.5164037",
"0.5159738",
"0.51514626",
"0.5103755",
"0.50920224",
"0.508... | 0.7906699 | 0 |
Filters a query for key_names that have the given prefix. If root_kind is specified, filters the query for children of any entities that are of that kind with the given prefix; otherwise, the results are assumed to be toplevel entities of the kind being queried. | def filter_by_prefix(query, key_name_prefix):
root_kind = query._model_class.__name__
min_key = db.Key.from_path(root_kind, key_name_prefix)
max_key = db.Key.from_path(root_kind, key_name_prefix + u'\uffff')
return query.filter('__key__ >=', min_key).filter('__key__ <=', max_key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_by_prefix(query, key_name_prefix, root_kind=None):\n root_kind = root_kind or query._model_class.__name__\n min_key = db.Key.from_path(root_kind, key_name_prefix)\n max_key = db.Key.from_path(root_kind, key_name_prefix + u'\\uffff')\n return query.filter('__key__ >=', min_key).filter('__key_... | [
"0.7997235",
"0.6018624",
"0.5781563",
"0.55401695",
"0.5490488",
"0.53805095",
"0.5360448",
"0.5327734",
"0.53170335",
"0.53108567",
"0.53094167",
"0.5301765",
"0.52492964",
"0.52480257",
"0.5233597",
"0.5233597",
"0.520773",
"0.51999706",
"0.51984674",
"0.5195172",
"0.51682... | 0.675667 | 1 |
Gets a query for all entities in a given subdomain's repository. | def all_in_subdomain(cls, subdomain):
return cls.all().filter('subdomain =', subdomain) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_in_subdomain(cls, subdomain):\n root_kind = getattr(cls, 'ROOT_KIND', None)\n return filter_by_prefix(cls.all(), subdomain + ':', root_kind)",
"def query_repositories():\n return buildapi.query_repositories()",
"def search(subdomain):\n\tsub = searchByDomain(subdomain)\n\tif sub :\n\t\... | [
"0.65086675",
"0.5952783",
"0.53782755",
"0.5293379",
"0.52829707",
"0.52601385",
"0.5245156",
"0.5228416",
"0.521312",
"0.5146122",
"0.50989133",
"0.5001128",
"0.49979806",
"0.49448696",
"0.49421996",
"0.49399757",
"0.4939568",
"0.49319008",
"0.49311128",
"0.49270552",
"0.48... | 0.6724696 | 0 |
Returns the domain name of this record's original repository. | def get_original_domain(self):
return self.record_id.split('/', 1)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_domain_name(self):\n return self.domain_name.get_text()",
"def domain_name(self) -> str:\n return pulumi.get(self, \"domain_name\")",
"def domain_name(self) -> str:\n return pulumi.get(self, \"domain_name\")",
"def domain_name(self) -> pulumi.Output[str]:\n return pulumi.g... | [
"0.7204359",
"0.71684253",
"0.71684253",
"0.7134341",
"0.7134341",
"0.7134341",
"0.7065999",
"0.69433486",
"0.6934701",
"0.6835912",
"0.6835912",
"0.6787384",
"0.6767813",
"0.67428905",
"0.67346776",
"0.67301166",
"0.6703863",
"0.6703863",
"0.6703863",
"0.66975677",
"0.669756... | 0.7980775 | 0 |
Returns True if this record was copied from another repository. | def is_clone(self):
return not self.is_original() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_clone(subdomain, record_id):\n return not is_original(subdomain, record_id)",
"def __eq__(self, other):\n if not isinstance(other, BlogAuthorCloneRequestVNext):\n return False\n\n return self.to_dict() == other.to_dict()",
"def is_original(self):\n return is_original(s... | [
"0.6556766",
"0.6091322",
"0.6068405",
"0.6007544",
"0.5956192",
"0.59438497",
"0.58938015",
"0.58595747",
"0.5846363",
"0.5781687",
"0.5763227",
"0.5747814",
"0.57412183",
"0.5724109",
"0.5717058",
"0.56910574",
"0.5673016",
"0.5662498",
"0.56571317",
"0.5656993",
"0.5655955... | 0.6484457 | 1 |
Creates an original entity with the given record_id and field values, overwriting any existing entity with the same record_id. This should be rarely used in practice (e.g. for an administrative import into a home repository), hence the long method name. | def create_original_with_record_id(cls, subdomain, record_id, **kwargs):
key_name = subdomain + ':' + record_id
return cls(key_name=key_name, subdomain=subdomain, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_record(\n self, id_: str, fields: Dict[str, Union[str, list, None]]\n ) -> None:\n instance = self._get(id_)\n instance.update(fields)\n self.db.session.commit()",
"def updated_full_record(full_record):\n full_record[\"access\"][\"status\"] = \"embargoed\"\n ful... | [
"0.6308641",
"0.60073376",
"0.5665999",
"0.5560646",
"0.55416715",
"0.552323",
"0.5501001",
"0.5495429",
"0.5492081",
"0.54836327",
"0.54736656",
"0.54445446",
"0.5440043",
"0.5433077",
"0.5429249",
"0.54044837",
"0.5387187",
"0.5383316",
"0.53676736",
"0.5361117",
"0.5351958... | 0.6674886 | 0 |
Retrieve notes for a person record, ordered by source_date. | def get_by_person_record_id(subdomain, person_record_id, limit=200):
query = Note.all_in_subdomain(subdomain)
query = query.filter('person_record_id =', person_record_id)
query = query.order('source_date')
return query.fetch(limit) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_issue_notes(request, pk):\n if request.user.is_coordinator_or_better:\n note_types = IssueNote.COORDINATOR_NOTE_TYPES\n else:\n note_types = IssueNote.PARALEGAL_NOTE_TYPES\n\n return (\n IssueNote.objects.filter(issue=pk)\n .prefetch_related(\"creator__groups\")\n ... | [
"0.6045474",
"0.59539753",
"0.58769345",
"0.5717555",
"0.5710305",
"0.56847554",
"0.55791664",
"0.55658644",
"0.5529334",
"0.5509714",
"0.5508599",
"0.5442838",
"0.53981555",
"0.52307075",
"0.52283955",
"0.5188376",
"0.5186007",
"0.51505023",
"0.5131347",
"0.5128829",
"0.5118... | 0.6012566 | 1 |
Gets the Authorization entity for a subdomain and key. | def get(cls, subdomain, key):
key_name = subdomain + ':' + key
return cls.get_by_key_name(key_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_apiauth_object_by_key(key):\n return model.APIAuth.query.filter_by(key=key).first()",
"def test_get_organization_from_api_key(self):\n pass",
"def authorization(self, authorization_id):\r\n return authorizations.Authorization(self, authorization_id)",
"def get(cls, subdomain, name):\... | [
"0.5451472",
"0.5232192",
"0.52312917",
"0.51885384",
"0.5172325",
"0.5129461",
"0.5126537",
"0.5072558",
"0.4983112",
"0.4928183",
"0.4901766",
"0.4856244",
"0.48279372",
"0.48249835",
"0.47875807",
"0.47476146",
"0.47353816",
"0.4727011",
"0.47245175",
"0.46879536",
"0.4681... | 0.6478564 | 0 |
Creates an Authorization entity for a given subdomain and key. | def create(cls, subdomain, key, **kwargs):
key_name = subdomain + ':' + key
return cls(key_name=key_name, subdomain=subdomain, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_original(cls, subdomain, **kwargs):\n record_id = '%s.%s/%s.%d' % (\n subdomain, HOME_DOMAIN, cls.__name__.lower(), UniqueId.create_id())\n key_name = subdomain + ':' + record_id\n return cls(key_name=key_name, subdomain=subdomain, **kwargs)",
"def get(cls, subdomain, k... | [
"0.55057573",
"0.53538924",
"0.529331",
"0.5285363",
"0.525037",
"0.5247734",
"0.5053974",
"0.50156724",
"0.48542792",
"0.48390943",
"0.48103714",
"0.48016262",
"0.4750739",
"0.47416082",
"0.4657119",
"0.46547574",
"0.46275133",
"0.46245822",
"0.46156368",
"0.46080568",
"0.46... | 0.7063448 | 0 |
Gets the latest finished count for the given subdomain and name. 'name' should be in the format scan_name + '.' + count_name. | def get_count(cls, subdomain, name):
scan_name, count_name = name.split('.')
counter_key = subdomain + ':' + scan_name
# Get the counts from memcache, loading from datastore if necessary.
counter_dict = memcache.get(counter_key)
if not counter_dict:
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_unfinished_or_create(cls, subdomain, scan_name):\n counter = cls.all().filter('subdomain =', subdomain\n ).filter('scan_name =', scan_name\n ).order('-timestamp').get()\n if not counter or not counter.last_key:\n counter = Counter(s... | [
"0.6443136",
"0.62389874",
"0.54993737",
"0.53677297",
"0.5360753",
"0.50657755",
"0.50468224",
"0.49642366",
"0.49579385",
"0.49296474",
"0.49008244",
"0.47790855",
"0.47453865",
"0.4704103",
"0.47013152",
"0.46733955",
"0.4632451",
"0.45103323",
"0.44980088",
"0.4463026",
"... | 0.72744155 | 0 |
Gets a query for all finished counters for the specified scan. | def all_finished_counters(cls, subdomain, scan_name):
return cls.all().filter('subdomain =', subdomain
).filter('scan_name =', scan_name
).filter('last_key =', '') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vulnerability_scan_history():\n number = request.args.get(\"number\")\n time_unit = request.args.get(\"time_unit\")\n\n if number:\n try:\n number = int(number)\n except ValueError:\n raise InvalidUsage(\"Number should be an integer value.\")\n\n if bool(number i... | [
"0.52757996",
"0.5087557",
"0.5080313",
"0.50137043",
"0.5000964",
"0.4963959",
"0.4961445",
"0.4952041",
"0.4864716",
"0.48600686",
"0.47794256",
"0.47780466",
"0.47718108",
"0.47648123",
"0.4711214",
"0.4711214",
"0.4711214",
"0.4711214",
"0.47107774",
"0.46997803",
"0.4668... | 0.7398652 | 0 |
Gets the latest unfinished Counter entity for the given subdomain and scan_name. If there is no unfinished Counter, create a new one. | def get_unfinished_or_create(cls, subdomain, scan_name):
counter = cls.all().filter('subdomain =', subdomain
).filter('scan_name =', scan_name
).order('-timestamp').get()
if not counter or not counter.last_key:
counter = Counter(subdomain=s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_count(cls, subdomain, name):\n scan_name, count_name = name.split('.')\n counter_key = subdomain + ':' + scan_name\n\n # Get the counts from memcache, loading from datastore if necessary.\n counter_dict = memcache.get(counter_key)\n if not counter_dict:\n try:\... | [
"0.6604365",
"0.650468",
"0.5030696",
"0.4788548",
"0.4590879",
"0.45835647",
"0.43353865",
"0.43162912",
"0.4287255",
"0.42773154",
"0.4248989",
"0.4175153",
"0.41617846",
"0.4158627",
"0.40879765",
"0.40725407",
"0.40195325",
"0.39910716",
"0.3984474",
"0.3969142",
"0.39455... | 0.8273667 | 0 |
Migrates the submissions with onebyone. | def migrate_submissions(apps, schema_editor):
SavedTicket = apps.get_model('poll', 'SavedTicket')
OpenQuestionAnswer = apps.get_model('poll', 'OpenQuestionAnswer')
MultipleChoiceQuestionAnswer = apps.get_model('poll', 'MultipleChoiceQuestionAnswer')
SingleChoiceQuestionAnswer = apps.get_model('poll', '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def migrate(self):\n\tpass",
"def exportToDB(self, submissions):\n for p in range(len(submissions)):\n for x in range(len(submissions[p])):\n doc_ref = self.fs_db.collection(u'reddit').document(str(submissions[p][4]))\n doc_ref.set({\n u'content'... | [
"0.62467176",
"0.60177845",
"0.5829366",
"0.57222146",
"0.5713008",
"0.5650286",
"0.5630166",
"0.553647",
"0.53965014",
"0.5366273",
"0.53558695",
"0.53100896",
"0.52495867",
"0.52187186",
"0.51402134",
"0.51399225",
"0.5114449",
"0.50971967",
"0.50705975",
"0.50159144",
"0.5... | 0.62964135 | 0 |
Restores the polls from POLL_ARCHIVE. The poll objects are going to survive the migrations, but the details need to be restored. | def restore_polls(apps, schema_editor):
Poll = apps.get_model('poll', 'Poll')
for key, dump in POLL_ARCHIVE.items():
poll = Poll.objects.get(id=key)
poll.group_id = dump['group']
poll.course_id = dump['course']
poll.semester_id = dump['semester']
poll.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __restoreBackup(self):\n pass #FIXME!!!",
"def reloadpolls(self, irc, msg, args):\n try:\n self.polls = yaml.load(open(self.pollFile, 'r'), Loader=yamlordereddictloader.Loader)\n\n except FileNotFoundError as e:\n log.warning(\"Couldn't open file: %s\" % e)\n ... | [
"0.574214",
"0.57180446",
"0.5696982",
"0.5630815",
"0.5550668",
"0.5523531",
"0.5489483",
"0.5457118",
"0.5416798",
"0.53799653",
"0.5347173",
"0.53220534",
"0.53002214",
"0.5298628",
"0.52960825",
"0.5278704",
"0.5277454",
"0.5277282",
"0.5258292",
"0.5190558",
"0.51815957"... | 0.8314576 | 0 |
The tests will fork another process, if the test run is itself an mpi process, the tests may fail. For the hydra process manager the tests will fail. So skip the tests if we detect hydra | def check_not_in_mpiexec(self):
if 'HYDRA_CONTROL_FD' in os.environ or 'PMI_FD' in os.environ:
self.skip('cannot run the socket tests under mpi process manager') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_startProcessAlreadyStarted(self):\r\n self.pm.addProcess(\"foo\", [\"foo\"])\r\n self.pm.startProcess(\"foo\")\r\n self.assertIdentical(None, self.pm.startProcess(\"foo\"))",
"def test_subprocess_fork_pid0(self, mocker):\n mocker.stopall()\n\n test_command = [\"who\", ... | [
"0.65887606",
"0.6402738",
"0.6379104",
"0.63728493",
"0.63230944",
"0.6290607",
"0.62756467",
"0.6270239",
"0.61608493",
"0.61505336",
"0.602438",
"0.6011515",
"0.6004231",
"0.5991807",
"0.5988589",
"0.59511745",
"0.5946526",
"0.594648",
"0.593677",
"0.5927035",
"0.59239423"... | 0.67027515 | 0 |
Go through all empty positions and initialize their possible values, according to the constraints. Called once when the board is first created. | def init_constraints(self):
for (row, col), curr_value in np.ndenumerate(self.final_values):
self.possible_values[row][col] = [] # Initialize empty list
if curr_value == 0: # If the final value is 0 then the position is vacant
for value in range(1, 10): # Iterate throu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, final_values):\n self.final_values = final_values # Holds the final values on the board\n self.possible_values = np.empty(shape=(9, 9), dtype=list) # Holds the possible values each empty slot can take",
"def initialize_board(self):\n self.board = np.zeros(shape=(BOARD_SI... | [
"0.69556713",
"0.69445854",
"0.6928109",
"0.6829788",
"0.68030906",
"0.67487305",
"0.66930026",
"0.6672037",
"0.66359526",
"0.6585402",
"0.652841",
"0.65129584",
"0.650719",
"0.6502183",
"0.64733964",
"0.64556843",
"0.6449356",
"0.6448072",
"0.6445054",
"0.642698",
"0.637587"... | 0.76460886 | 0 |
Check if the given value is allowed to be placed in the specified position (target_row, target_col). Checks that no duplicate values are in the same row, column or 3x3 block. | def __is_valid_value(self, target_row, target_col, value):
if value == 0:
return True # 0's are always a valid value since they are a placeholder (signify empty position)
# Check row and column:
for i in range(9):
if self.final_values[i][target_col] == value and i != ta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_possible_grid(self,row,col,user_value):\n start_row = row - (row % 3)\n start_col = col - (col % 3)\n for x in range(3):\n for y in range(3):\n if self.arr[x+start_row][y+start_col] == user_value:\n logging.debug(f\"is_posssible_grid(): (Fals... | [
"0.70291823",
"0.70111966",
"0.69805837",
"0.68119913",
"0.6805325",
"0.6768768",
"0.6756712",
"0.67476773",
"0.674651",
"0.67087626",
"0.67041796",
"0.66794616",
"0.6659835",
"0.658669",
"0.65123135",
"0.650326",
"0.6500818",
"0.6488185",
"0.64631",
"0.64548117",
"0.64129066... | 0.7895606 | 0 |
Checks if the board is solvable, i.e. each empty position has at least one possible value. | def is_solvable(self):
for row, col in np.ndindex(9, 9):
if len(self.possible_values[row][col]) < 1 and self.final_values[row][col] == 0:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_if_solved(self):\n for cell in self.board.values():\n if not cell.value:\n return False\n return True",
"def is_solved(self):\n # Asserting board is valid.\n if not self.is_legal():\n return False\n\n # Asserting board is filled.\n... | [
"0.8226037",
"0.7956708",
"0.77154416",
"0.7613739",
"0.76123434",
"0.75807106",
"0.7487948",
"0.7479519",
"0.73125523",
"0.72673947",
"0.72199494",
"0.71548647",
"0.71472603",
"0.7147121",
"0.7127494",
"0.70912015",
"0.7089305",
"0.7081779",
"0.7027587",
"0.701583",
"0.70122... | 0.83548516 | 0 |
Generates a list with the coordinates of all the empty slots that have only 1 possible value (singletons). Called after assignment (generate of new board). | def get_singletons(self):
singleton_list = [] # List holding singleton positions (row, col)
for row in range(9):
for col in range(9):
if len(self.possible_values[row][col]) == 1 and self.final_values[row][col] == 0:
singleton_list.append((row, col)) # If... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty_spots(self):\n\t\tret = []\n\t\tfor i in range(0, self.size):\n\t\t\tfor j in range(0, self.size):\n\t\t\t\tif(self.grid[i][j] == self.terminal):\n\t\t\t\t\tret.append((i,j))\n\t\treturn ret",
"def get_empty_squares(self):\n empty = []\n for row in range(self._dim):\n for col i... | [
"0.73838145",
"0.71295583",
"0.7018735",
"0.6972191",
"0.6946488",
"0.6906955",
"0.6903224",
"0.6879551",
"0.68740577",
"0.68387556",
"0.6811779",
"0.674936",
"0.6731642",
"0.672649",
"0.67142946",
"0.67014825",
"0.66878414",
"0.66877687",
"0.6650112",
"0.6625762",
"0.6603511... | 0.7582303 | 0 |
Update the board's possible values, following an assignment to the given position (row, col). Find and update the affected positions, updating their constraints. | def update_constraints(self, target_row, target_col, value):
for i in range(9):
if value in self.possible_values[target_row][i]: # Update the column
self.possible_values[target_row][i].remove(value)
if value in self.possible_values[i][target_col]: # Update the row
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_board(self, value, row=-1, col=-1, cell=-1):\n\n if row != -1 and col != -1 and cell == -1:\n _row,_col = row,col\n\n elif row == -1 and col == -1 and type(cell) == tuple:\n _row,_col = cell\n\n else:\n raise Exception(\"you must provide either row a... | [
"0.686709",
"0.65157264",
"0.6438615",
"0.642101",
"0.6321089",
"0.628985",
"0.6236595",
"0.6201088",
"0.6197843",
"0.6067722",
"0.60666823",
"0.6047244",
"0.6039162",
"0.5978862",
"0.59731704",
"0.59632504",
"0.5948823",
"0.5894865",
"0.58589655",
"0.5846067",
"0.58406985",
... | 0.6802855 | 1 |
Creates and returns a copy of the current state. Copies the final_values and possible_values of the object. Used to overcome the overheads associated with __deepcopy__. | def copy_state(self):
new_state = SudokuState(np.ndarray.copy(self.final_values)) # Copy final values using numpy's built-in copy
for (row, col), values in np.ndenumerate(self.possible_values):
new_state.possible_values[row][col] = values[:] # Copy over each list of possible values
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone(self):\n # make copies of my state\n beta = self.beta\n theta = self.theta.clone()\n sigma = self.sigma.clone()\n likelihoods = self.prior.clone(), self.data.clone(), self.posterior.clone()\n\n # make one and return it\n return type(self)(beta=beta, theta=... | [
"0.6952725",
"0.6744611",
"0.6578743",
"0.65592104",
"0.6517688",
"0.6516348",
"0.6488528",
"0.6463176",
"0.644145",
"0.64302146",
"0.6404329",
"0.63613015",
"0.6360104",
"0.6359571",
"0.63535255",
"0.63474476",
"0.6326772",
"0.62826145",
"0.627195",
"0.6237758",
"0.6228722",... | 0.74367905 | 0 |
Generate minimal control body | def generate_minimal_control_body():
return {
"title": factories.random_str(),
"external_id": factories.SynchronizableExternalId.next(),
"external_slug": factories.random_str(),
"context": None,
"review_status": all_models.Review.STATES.UNREVIEWED,
"review_status_disp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def design_body(self):\n pass",
"def body(self):",
"def _make_halocomp(self, body):\n return",
"def generateBody(self):\n # get the anims\n animDict = self.generateAnimDict()\n \n # NOTE: It is always phase 3.5 because the models are there\n # while everything... | [
"0.59357363",
"0.5904845",
"0.5598308",
"0.55545646",
"0.5548888",
"0.55466706",
"0.54583657",
"0.54506683",
"0.54015",
"0.53512824",
"0.53219813",
"0.5318445",
"0.53160655",
"0.5283576",
"0.5272465",
"0.5243749",
"0.52421653",
"0.5202798",
"0.5170928",
"0.5165113",
"0.516021... | 0.73878604 | 0 |
Create Person objects specified in access_control_list. | def setup_people(access_control_list):
all_users = set()
for users in access_control_list.values():
all_users.update({(user["email"], user["name"]) for user in users})
with factories.single_commit():
for email, name in all_users:
factories.PersonFactory(email=email, name=name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_control_acl_new_people_create(self):\n control_body = self.prepare_control_request_body()\n access_control_list = {\n \"Admin\": [\n {\n \"email\": \"user1@example.com\",\n \"name\": \"user1\",\n },\n {\n \"email\":... | [
"0.72629267",
"0.6959985",
"0.64053476",
"0.6307461",
"0.6007624",
"0.5974393",
"0.55802417",
"0.5500215",
"0.54698735",
"0.54515356",
"0.5450089",
"0.5442127",
"0.534723",
"0.52996904",
"0.5294482",
"0.5274786",
"0.52746904",
"0.5243264",
"0.5241386",
"0.51900834",
"0.518806... | 0.77560586 | 0 |
Validate correctness of object access_control_list. | def assert_obj_acl(self, obj, access_control_list):
actual_acl = {
(user.acl_item.ac_role.name, user.person.email)
for user in obj.access_control_list
}
expected_acl = {
(role, person["email"])
for role, people in access_control_list.items()
for person in people
}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_access(self, view, rights, prefix, scope_path, field):\n\n access_level = self.cleaned_data[field]\n\n if not has_access(rights, access_level, scope_path, prefix):\n self._errors[field] = ErrorList([DEF_NO_RIGHTS_FOR_ACL_MSG])\n del self.cleaned_data[field]",
"def test_control_invalid_acl_fo... | [
"0.69009715",
"0.67286897",
"0.6488112",
"0.6269406",
"0.6145455",
"0.600952",
"0.59939504",
"0.59306365",
"0.59181774",
"0.58943146",
"0.58516145",
"0.57590455",
"0.5756208",
"0.5752419",
"0.5733303",
"0.57091933",
"0.56687933",
"0.56561464",
"0.56500584",
"0.5612034",
"0.55... | 0.6739785 | 1 |
Asserts that CAV fields are correct. | def assert_cav_fields(self, cav, expected_body):
self.assertEqual(
cav.custom_attribute_id,
expected_body["custom_attribute_id"]
)
self.assertEqual(
cav.attributable_id,
expected_body["attributable_id"]
)
self.assertEqual(
cav.attributable_type,
expect... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_verify_attrs_customer(self):\n self.assertEqual(self.customer.name, 'Customer Test')\n self.assertEqual(self.customer.document, '000.000.000-00')",
"def test_invalid_fields(self):\n\n user = login(self.client)\n client = create_client('test')\n client.write_access = Tr... | [
"0.6645006",
"0.64147377",
"0.6405993",
"0.6380995",
"0.6252206",
"0.6177087",
"0.6164105",
"0.6152685",
"0.6129052",
"0.6127314",
"0.60922444",
"0.6061825",
"0.60601795",
"0.60501224",
"0.6024988",
"0.5988683",
"0.597838",
"0.5969008",
"0.5962449",
"0.59518003",
"0.59380853"... | 0.8131172 | 0 |
Test create control with CADs/CAVs. | def test_create_control_with_cads(self):
factories.CustomAttributeDefinitionFactory(
id=444,
attribute_type="Text",
definition_type="control"
)
control_body = self.prepare_control_request_body()
cad_body = self.prepare_external_cad_body("Text", "Control")
cav_body = self.prep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_add_control(perfectModelEnsemble_initialized_control):\n assert perfectModelEnsemble_initialized_control.get_control()",
"def test_control_acl_create(self, access_control_list):\n control_body = self.prepare_control_request_body()\n control_body.update({\n \"access_control_list\": access... | [
"0.69433093",
"0.6757999",
"0.65509456",
"0.63416165",
"0.62268734",
"0.6197708",
"0.61197823",
"0.6081271",
"0.6031721",
"0.6012296",
"0.6003516",
"0.5946394",
"0.5911167",
"0.58932805",
"0.58817995",
"0.58757114",
"0.5856636",
"0.58452624",
"0.57914156",
"0.57901704",
"0.57... | 0.7642904 | 0 |
Test update control with CADs/CAVs. | def test_update_control_with_cads(self):
ext_user_email = "external@example.com"
factories.CustomAttributeDefinitionFactory(
id=444,
attribute_type="Text",
definition_type="control"
)
external_user = factories.PersonFactory(email=ext_user_email)
control = factories.ControlFac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update(self):\n # this is tested graphically, as it is UI\n pass",
"def test_update_case(self):\n pass",
"def test_update(self):\n pass",
"def test_update(self):\n pass",
"def test_update(self):\n pass",
"def test_control_update(self):\n test_date = d... | [
"0.69931376",
"0.6938615",
"0.6897302",
"0.6897302",
"0.6897302",
"0.6808741",
"0.67770493",
"0.6744766",
"0.6592524",
"0.6583964",
"0.6424519",
"0.6381306",
"0.61976933",
"0.61960423",
"0.61916226",
"0.6182466",
"0.61800146",
"0.6174492",
"0.6142678",
"0.6142678",
"0.6121508... | 0.71354306 | 0 |
Check control creation with assertions pass | def test_create_with_asserts(self):
control_body = self.prepare_control_request_body()
response = self.api.post(all_models.Control, data={
"control": control_body,
})
self.assertEqual(response.status_code, 201)
control = all_models.Control.query.first()
self.assertIsNotNone(control)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check(cls, control_instance):\n pass",
"def test_add_control(perfectModelEnsemble_initialized_control):\n assert perfectModelEnsemble_initialized_control.get_control()",
"def testConditionChecking(self):\n\n state = State.from_problem(self.prob)\n \n drive = self.dom.get_acti... | [
"0.70860404",
"0.684488",
"0.6418592",
"0.63580966",
"0.63387406",
"0.6260843",
"0.6257174",
"0.62388486",
"0.6215416",
"0.60838884",
"0.60795635",
"0.6066761",
"0.6066556",
"0.604975",
"0.604975",
"0.604975",
"0.604975",
"0.6021662",
"0.60082537",
"0.5945009",
"0.59232295",
... | 0.69762564 | 1 |
Test query endpoint for ExternalComments collection. | def test_query_external_comment(self):
with factories.single_commit():
control = factories.ControlFactory()
comment = factories.ExternalCommentFactory(description="test comment")
factories.RelationshipFactory(source=control, destination=comment)
request_data = [{
"filters": {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_comments(self):\n self.resource._request.register_uri(\n 'GET', '/users/dotzero/comments?page=2', 'fixture_user.json')\n\n response = self.resource.comments('dotzero', 2)\n\n self.assertTrue('data' in response)\n self.assertTrue('server_time' in response)",
"def te... | [
"0.6643376",
"0.6432952",
"0.6405201",
"0.62504363",
"0.6235968",
"0.61005056",
"0.59966856",
"0.5959923",
"0.5958919",
"0.5905994",
"0.58596253",
"0.58463955",
"0.5786502",
"0.57241446",
"0.56995094",
"0.56881416",
"0.56712097",
"0.5657438",
"0.56550455",
"0.5606461",
"0.559... | 0.7617005 | 0 |
Test order of ExternalComments returned by /query. | def test_external_comments_order(self, order_by_attr):
with factories.single_commit():
control = factories.ControlFactory()
for _ in range(5):
comment = factories.ExternalCommentFactory(
description=factories.random_str()
)
factories.RelationshipFactory(source=control... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_query_external_comment(self):\n with factories.single_commit():\n control = factories.ControlFactory()\n comment = factories.ExternalCommentFactory(description=\"test comment\")\n factories.RelationshipFactory(source=control, destination=comment)\n request_data = [{\n \"filters... | [
"0.7089441",
"0.6435584",
"0.62819415",
"0.62208265",
"0.6208567",
"0.60752714",
"0.60502255",
"0.6033374",
"0.5925397",
"0.5853359",
"0.58321196",
"0.5813381",
"0.5785427",
"0.5702853",
"0.56935304",
"0.5685173",
"0.5685115",
"0.56263196",
"0.55783224",
"0.5520285",
"0.54655... | 0.77446896 | 0 |
Check control creation with nonunique external_id | def test_create_unique_external_id(self):
request1 = self.prepare_control_request_body()
request2 = self.prepare_control_request_body()
response1 = self.api.post(all_models.Control, data={'control': request1})
prev_external_id = response1.json['control']['external_id']
request2['external_id'] = pre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_id(self, id):",
"def check_unique(self):\n pass",
"def is_valid_pid_for_create(did):\n if not d1_gmn.app.did.is_valid_pid_for_create(did):\n raise d1_common.types.exceptions.IdentifierNotUnique(\n 0,\n 'Identifier is already in use as {}. did=\"{}\"'.format(\n ... | [
"0.64262426",
"0.6171642",
"0.5954803",
"0.590862",
"0.57225925",
"0.57055897",
"0.5669865",
"0.56420714",
"0.5634869",
"0.56297827",
"0.557453",
"0.5561447",
"0.5547046",
"0.5538301",
"0.55379975",
"0.55366987",
"0.5531126",
"0.5520247",
"0.55075854",
"0.54964036",
"0.549543... | 0.69170666 | 0 |
Check control creation with empty 'field' | def test_control_create_with_empty_field(self, field):
request = self.prepare_control_request_body()
request[field] = None
response = self.api.post(all_models.Control, data=request)
self.assert400(response) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validar_no_vacio(self):\n if len(self.get()) == 0:\n return False\n return True",
"def is_empty(self):\n return len(self.fields) == 0",
"def fields_not_empty(self, request, fields):\r\n for field in fields:\r\n if request.form.get(field) == \"\":\r\n ... | [
"0.64302856",
"0.6374986",
"0.6316243",
"0.6280641",
"0.627122",
"0.62499297",
"0.6227734",
"0.6196846",
"0.6185639",
"0.6088163",
"0.6088163",
"0.60660964",
"0.60621583",
"0.6027815",
"0.6018925",
"0.5993931",
"0.5946365",
"0.59334207",
"0.5930197",
"0.5915749",
"0.59069216"... | 0.72115695 | 0 |
Test querying '{0}' field for control. | def test_control_query_string(self, field, possible_values, search_value):
with factories.single_commit():
for val in possible_values:
factories.ControlFactory(**{field: val})
request_data = [{
'fields': [],
'filters': {
'expression': {
'left': field,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_control_query_json(self, field, possible_values, search_value):\n with factories.single_commit():\n for val in possible_values:\n factories.ControlFactory(**{field: val})\n request_data = [{\n \"fields\": [],\n \"object_name\": \"Control\",\n \"type\": \"values\",\n ... | [
"0.67015666",
"0.64465517",
"0.60087484",
"0.58792484",
"0.5815947",
"0.57504094",
"0.5723745",
"0.5723745",
"0.5723745",
"0.5723745",
"0.5606825",
"0.5512961",
"0.5504728",
"0.5455316",
"0.54156715",
"0.5391235",
"0.53751117",
"0.5359765",
"0.53501165",
"0.53280824",
"0.5323... | 0.74013126 | 0 |
Test querying '{0}' field for control. | def test_control_query_json(self, field, possible_values, search_value):
with factories.single_commit():
for val in possible_values:
factories.ControlFactory(**{field: val})
request_data = [{
"fields": [],
"object_name": "Control",
"type": "values",
"filters": {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_control_query_string(self, field, possible_values, search_value):\n with factories.single_commit():\n for val in possible_values:\n factories.ControlFactory(**{field: val})\n request_data = [{\n 'fields': [],\n 'filters': {\n 'expression': {\n 'lef... | [
"0.7401574",
"0.6444578",
"0.60049766",
"0.5876728",
"0.5818022",
"0.5748239",
"0.57230157",
"0.57230157",
"0.57230157",
"0.57230157",
"0.5603516",
"0.55120265",
"0.5504571",
"0.54528296",
"0.5415471",
"0.5389351",
"0.53734326",
"0.53574395",
"0.5348626",
"0.5326759",
"0.5324... | 0.6702179 | 1 |
Test creation of new object with acl in invalid format. | def test_control_invalid_acl_format(self, access_control_list):
control_body = self.prepare_control_request_body()
control_body.update({
"access_control_list": access_control_list,
})
response = self.api.post(all_models.Control, data={
"control": control_body
})
self.assert400(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_control_acl_new_people_create(self):\n control_body = self.prepare_control_request_body()\n access_control_list = {\n \"Admin\": [\n {\n \"email\": \"user1@example.com\",\n \"name\": \"user1\",\n },\n {\n \"email\":... | [
"0.6768742",
"0.66590464",
"0.66106504",
"0.6564545",
"0.6465465",
"0.646398",
"0.64163667",
"0.634921",
"0.63404334",
"0.63272554",
"0.6302592",
"0.6254254",
"0.62254536",
"0.62236",
"0.6217911",
"0.61080575",
"0.61080575",
"0.6094041",
"0.60832566",
"0.6082493",
"0.60674727... | 0.71888447 | 0 |
Test updating of Control mapped to TaskGroup. | def test_control_with_tg_update(self):
with factories.single_commit():
control = factories.ControlFactory()
task_group = wf_factories.TaskGroupFactory()
factories.RelationshipFactory(
source=task_group,
destination=control
)
response = self.api.put(control, control.i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_group(self):\n pass",
"def test_update_resource_group(self):\n pass",
"def test_user_group_controller_update(self):\n pass",
"def test_update(self):\n # this is tested graphically, as it is UI\n pass",
"def test_update_port_sub_group(self):\n pass",... | [
"0.74069417",
"0.7073989",
"0.6962448",
"0.65486664",
"0.6506072",
"0.6462568",
"0.637457",
"0.6350449",
"0.62732947",
"0.62660986",
"0.62660986",
"0.62660986",
"0.62646806",
"0.62646806",
"0.62442523",
"0.62187123",
"0.6199687",
"0.60965675",
"0.6068736",
"0.5996808",
"0.597... | 0.73789185 | 1 |
Test control with duplicated title. | def test_control_with_duplicated_title(self):
control_1 = self.generate_minimal_control_body()
control_2 = self.generate_minimal_control_body()
control_2["title"] = control_1["title"]
response = self.api.post(all_models.Control, data={
"control": control_1
})
self.assert201(response)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_title(self):\n currenttitle = self.driver.title\n assert self.TITLE in currenttitle, 'Title not expected. Actual: ' + currenttitle + ', Expected: ' + self.TITLE",
"def checkTitle(self,event=None):\r\n if self.title.getVal() not in self.titleList:\r\n self.titleList.appen... | [
"0.66295063",
"0.65222216",
"0.65047514",
"0.6129341",
"0.6071205",
"0.6062984",
"0.60331243",
"0.6032251",
"0.5989188",
"0.59614193",
"0.59568167",
"0.5949856",
"0.5941983",
"0.59325004",
"0.59306127",
"0.59233946",
"0.5914359",
"0.5901164",
"0.589336",
"0.588484",
"0.587738... | 0.73684675 | 0 |
Test creation of control with non empty acl. | def test_control_acl_create(self, access_control_list):
control_body = self.prepare_control_request_body()
control_body.update({
"access_control_list": access_control_list,
})
self.setup_people(access_control_list)
response = self.api.post(all_models.Control, data={
"control": contr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_control_acl_new_people_create(self):\n control_body = self.prepare_control_request_body()\n access_control_list = {\n \"Admin\": [\n {\n \"email\": \"user1@example.com\",\n \"name\": \"user1\",\n },\n {\n \"email\":... | [
"0.7019176",
"0.6779225",
"0.6519726",
"0.62185526",
"0.62144804",
"0.6170364",
"0.61313826",
"0.6124175",
"0.6089439",
"0.6067789",
"0.6045215",
"0.59953856",
"0.59729034",
"0.5962363",
"0.5951074",
"0.5851114",
"0.5849822",
"0.58416915",
"0.5818034",
"0.58094597",
"0.580149... | 0.73099786 | 0 |
Test creation of control with acl which contain new people. | def test_control_acl_new_people_create(self):
control_body = self.prepare_control_request_body()
access_control_list = {
"Admin": [
{
"email": "user1@example.com",
"name": "user1",
},
{
"email": "user2@example.com",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_control_acl_new_people_update(self):\n person = factories.PersonFactory()\n add_person_global_role(person, 'Creator')\n with factories.single_commit():\n control = factories.ControlFactory()\n control.add_person_with_role_name(person, \"Admin\")\n access_control_list = {\n \"A... | [
"0.8220614",
"0.79208636",
"0.7458537",
"0.69470334",
"0.6738839",
"0.668453",
"0.66798365",
"0.66753286",
"0.6593749",
"0.65198064",
"0.64575464",
"0.6447271",
"0.64329296",
"0.63869524",
"0.63616127",
"0.63432693",
"0.63325924",
"0.627574",
"0.62557375",
"0.62407404",
"0.62... | 0.8667488 | 0 |
Test updating of control with non empty acl. | def test_control_acl_update(self):
with factories.single_commit():
control = factories.ControlFactory()
person = factories.PersonFactory()
control.add_person_with_role_name(person, "Admin")
access_control_list = {
"Admin": [
{
"email": "user1@example.com",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_wrong_role_controle_acl_update(self):\n with factories.single_commit():\n control = factories.ControlFactory()\n person = factories.PersonFactory(name=\"user1\", email=\"user1@example.com\")\n control.add_person_with_role_name(person, \"Admin\")\n access_control_list = {\n \"No... | [
"0.7433625",
"0.7163732",
"0.65706617",
"0.6394397",
"0.6290865",
"0.62499243",
"0.62359655",
"0.61851794",
"0.617883",
"0.61338216",
"0.606182",
"0.6007574",
"0.59970295",
"0.5990325",
"0.5960358",
"0.5954578",
"0.5950954",
"0.59187347",
"0.58927464",
"0.5849802",
"0.5848916... | 0.79456687 | 0 |
Test updating of control with acl which contain new people. | def test_control_acl_new_people_update(self):
person = factories.PersonFactory()
add_person_global_role(person, 'Creator')
with factories.single_commit():
control = factories.ControlFactory()
control.add_person_with_role_name(person, "Admin")
access_control_list = {
"Admin": [
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_control_acl_update(self):\n with factories.single_commit():\n control = factories.ControlFactory()\n person = factories.PersonFactory()\n control.add_person_with_role_name(person, \"Admin\")\n access_control_list = {\n \"Admin\": [\n {\n \"email\": \"u... | [
"0.84633005",
"0.7396866",
"0.7212828",
"0.7195517",
"0.7072633",
"0.6819983",
"0.67620134",
"0.6641285",
"0.6628652",
"0.6612402",
"0.65917313",
"0.65647155",
"0.6554818",
"0.6543949",
"0.65101933",
"0.6496851",
"0.64935565",
"0.64896077",
"0.6458961",
"0.642454",
"0.6421584... | 0.87283975 | 0 |
Test updating of control with non empty acl. | def test_wrong_role_controle_acl_update(self):
with factories.single_commit():
control = factories.ControlFactory()
person = factories.PersonFactory(name="user1", email="user1@example.com")
control.add_person_with_role_name(person, "Admin")
access_control_list = {
"Non-existing role": ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_control_acl_update(self):\n with factories.single_commit():\n control = factories.ControlFactory()\n person = factories.PersonFactory()\n control.add_person_with_role_name(person, \"Admin\")\n access_control_list = {\n \"Admin\": [\n {\n \"email\": \"u... | [
"0.79450536",
"0.71634597",
"0.65700936",
"0.63948715",
"0.6289958",
"0.62495995",
"0.6238282",
"0.6185508",
"0.6178922",
"0.61361426",
"0.6060944",
"0.6008456",
"0.599834",
"0.598877",
"0.5960314",
"0.59549314",
"0.5952444",
"0.59208995",
"0.58950865",
"0.5851347",
"0.585015... | 0.74334836 | 1 |
Returns the actual subclassed object that is redirected to, instead of the VoiceServiceElement superclass object (which does not have specific fields and methods). | def redirect(self):
if self._redirect:
return VoiceServiceElement.objects.get_subclass(id=self._redirect.id)
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cast(self):\n # If the method has already been called\n if self._subobject is not None:\n return self._subobject\n for field in self.subclass_fields:\n try:\n self._subobject = getattr(self, field)\n # If an exception is not thrown, we've... | [
"0.6341318",
"0.6251485",
"0.6178236",
"0.6171231",
"0.6131328",
"0.6115653",
"0.60072017",
"0.59931076",
"0.59839636",
"0.59743017",
"0.59460604",
"0.5910778",
"0.58892936",
"0.5886315",
"0.5881477",
"0.5851913",
"0.58517206",
"0.5804841",
"0.5789723",
"0.5737953",
"0.573240... | 0.6431812 | 0 |
Handle a generic bulk task, blocking until the task is done or the timeout is up | def handle_bulk_task(self, task_uuid, retrieve_bulk_result_url, *, timeout, additional_checks: List[Check] = None) \
-> Json:
retrieve_bulk_result_url = retrieve_bulk_result_url.format(task_uuid=task_uuid)
spinner = None
if logger.isEnabledFor(logging.INFO):
spinner = Ha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_bulk_complete():\n data = flask.request.json\n parameters = {\"data\": data}\n\n if _detect_files(data):\n try:\n gdrive.get_http_auth()\n except gdrive.GdriveUnauthorized:\n response = app.make_response((\"auth\", 401,\n [(\"Content-Type\", \"text/html... | [
"0.61678344",
"0.60942495",
"0.60639125",
"0.60463053",
"0.59531254",
"0.5688339",
"0.5675812",
"0.555594",
"0.5535473",
"0.5527498",
"0.54675895",
"0.5441862",
"0.54364544",
"0.54258716",
"0.53894",
"0.5380936",
"0.5380278",
"0.5377423",
"0.5312239",
"0.52690107",
"0.526528"... | 0.7682569 | 0 |
Create a new HackernewsCrawlJob object | def __init__(self, config, processors):
source = HackernewsStories()
source.configure(config)
super(HackernewsCrawlJob, self).__init__(source, processors) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_job(script, args, inputs, outputs, tools):\n job = Job(script)\n for arg in args:\n job.addArguments(arg)\n\n # all jobs will have access to python scripts\n for tool in tools:\n job.uses(tools[tool], link=Link.INPUT)\n\n for input in inputs:\n job.uses(input, link=Li... | [
"0.6098407",
"0.59963673",
"0.59820426",
"0.5926948",
"0.59179217",
"0.5903726",
"0.5861638",
"0.58096874",
"0.57624173",
"0.5755816",
"0.57552946",
"0.5750373",
"0.56613344",
"0.5661115",
"0.5658414",
"0.56519157",
"0.5641945",
"0.5641933",
"0.56241703",
"0.56214416",
"0.561... | 0.69872683 | 0 |
Run training for af model (with tf model generating ref att) | def train(self, train_set, model_af, num_epochs=5, resume=False, optimizer=None, dev_set=None):
torch.cuda.empty_cache()
dropout_rate = model_af.dropout_rate
print('dropout {}'.format(dropout_rate))
# load tf model
latest_checkpoint_path = self.load_tf_dir
resume_checkpoint_tf = Checkpoint.load(latest_ch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self, train_set, model_tf, model_af, num_epochs=5, resume=False, dev_set=None):\n\n\t\ttorch.cuda.empty_cache()\n\t\tself.resume = resume\n\t\tif resume:\n\n\t\t\t# ------------------------------------------------------------------------------------\n\t\t\t# -------------------------- teacher forcing mod... | [
"0.71464294",
"0.7085732",
"0.7055494",
"0.70515716",
"0.70047545",
"0.6984172",
"0.69600517",
"0.69441557",
"0.6908894",
"0.68771863",
"0.68701965",
"0.68640095",
"0.68548036",
"0.6838802",
"0.68366057",
"0.6805508",
"0.6799314",
"0.678751",
"0.6753795",
"0.674154",
"0.67274... | 0.75616324 | 0 |
Function that sets a style to the given layer | def set_style(_layer, _color=None):
if _color is None:
_color = QColor("white")
_layer.renderer().symbol().setColor(_color) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def style(self, style):\n\n self.container['style'] = style",
"def _set_style(style):\n if isinstance(style, (str, dict)):\n return Style(style)\n elif isinstance(style, Style):\n return style\n else:\n return Style()",
"def SetLayer(self, *args):\n return _XCAFDoc.X... | [
"0.68680966",
"0.6668023",
"0.6569574",
"0.6504395",
"0.64060795",
"0.6384371",
"0.63598907",
"0.626454",
"0.62620175",
"0.62362725",
"0.62362725",
"0.61596227",
"0.5990436",
"0.5985012",
"0.5977809",
"0.59312946",
"0.59223217",
"0.58742857",
"0.5860345",
"0.5852422",
"0.5795... | 0.74359083 | 0 |
Gather function metadata for graph nodes | def build_nodes(graph):
acc = {}
for k, v in graph.items():
if callable(v):
acc[k] = util.fninfo(v)
else:
acc[k] = v
return acc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_metadata(*args, **kwargs):\n meta = None\n\n g = args[0]\n if not hasattr(g, 'meta'):\n g.meta = meta = nx.Graph()\n\n meta.add_node('start', {\n 'args': args,\n 'kwargs': kwargs,\n 'time': datetime.... | [
"0.6245158",
"0.618503",
"0.59313935",
"0.5872216",
"0.58362895",
"0.5802586",
"0.5661602",
"0.56439024",
"0.5624296",
"0.5624296",
"0.55875015",
"0.5500538",
"0.54911864",
"0.5452387",
"0.54031307",
"0.5402211",
"0.5384417",
"0.53743356",
"0.5372143",
"0.53510016",
"0.534708... | 0.66716796 | 0 |
Find all dependencies for a key in a given graph | def deps_for(nodes, key):
def _deps(key, path):
if key not in nodes:
return [key]
if key in path:
msg = "Cycle detected between {} and {}".format(
path[0], path[-1])
raise GraphError(msg)
deps = nodes[key]["required"]
trans = [_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dependencies(self, target, graph, dep_list):\n \n if graph == OrderedDict(): return\n if target in graph:\n dep_list.append(graph)\n return dep_list\n for key in graph:\n self.get_dependencies(target, graph[key], dep_list)\n return dep_lis... | [
"0.7390911",
"0.68917257",
"0.68018776",
"0.63598084",
"0.6352516",
"0.62921184",
"0.6227604",
"0.6217036",
"0.61638373",
"0.61505705",
"0.60679215",
"0.6026683",
"0.5975241",
"0.5963012",
"0.59365904",
"0.5936293",
"0.59102255",
"0.5893464",
"0.5889792",
"0.58837837",
"0.586... | 0.8042431 | 0 |
Compile a graph descriptor into a graph | def compile_graph(descriptor):
nodes = build_nodes(keys.simplify(descriptor))
deps = build_dependency_tree(nodes)
node_names = graph_nodes(deps)
req, opt, out = graph_parameters(nodes)
return {
"descriptor": descriptor,
"nodes": nodes,
"dependencies": deps,
"require... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_graph(self):",
"def _construct_graph(self):\n raise NotImplementedError",
"def _build_graph(self):\n pass",
"def build_graph(self):\n pass",
"def build_graph(self):\n for node in self.graph.nodes():\n self.c2py[node] = PyNode(node)\n for _input in node.... | [
"0.68475187",
"0.6742627",
"0.6564191",
"0.65137035",
"0.6469153",
"0.6403842",
"0.63968194",
"0.6232574",
"0.6228952",
"0.610447",
"0.6066316",
"0.6049528",
"0.6042246",
"0.59991974",
"0.59941417",
"0.5991287",
"0.59506553",
"0.59430754",
"0.5852257",
"0.58508307",
"0.583668... | 0.7985207 | 0 |
Call a node in the graph with the correct subset of required and optional keys from the inputs | def call_graph(graph, key, inputs):
node = graph["nodes"][key]
acceptable = node["required"] | set(node["optional"])
req = util.select_keys(lambda k, _: k in acceptable, inputs)
args = util.merge(node["optional"], req)
return node["fn"](**args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_graph(graph, inputs, *keys):\n\n if inputs is None:\n inputs = {}\n\n required = strategy.find_requirements(graph, inputs, keys)\n\n runner = lambda inputs: run_once(graph, inputs, required)\n solved = util.fixpoint(runner, inputs)\n\n if set(solved) < required:\n raise GraphEr... | [
"0.6215375",
"0.6104981",
"0.5518993",
"0.5467367",
"0.5416956",
"0.53942984",
"0.5363678",
"0.53398937",
"0.53089875",
"0.53063357",
"0.52424324",
"0.52014333",
"0.51566136",
"0.5152697",
"0.5124758",
"0.50996464",
"0.5097615",
"0.5082324",
"0.5062477",
"0.504182",
"0.503785... | 0.7859304 | 0 |
Run a graph given a set of inputs and, optionally, a subset of keys from the graph | def run_graph(graph, inputs, *keys):
if inputs is None:
inputs = {}
required = strategy.find_requirements(graph, inputs, keys)
runner = lambda inputs: run_once(graph, inputs, required)
solved = util.fixpoint(runner, inputs)
if set(solved) < required:
raise GraphError("Unsatisfiab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_graph(graph, key, inputs):\n\n node = graph[\"nodes\"][key]\n acceptable = node[\"required\"] | set(node[\"optional\"])\n req = util.select_keys(lambda k, _: k in acceptable, inputs)\n args = util.merge(node[\"optional\"], req)\n\n return node[\"fn\"](**args)",
"def run_once(graph, inputs... | [
"0.749599",
"0.6726465",
"0.5540672",
"0.5413521",
"0.53904617",
"0.53457654",
"0.5339591",
"0.5258085",
"0.5249572",
"0.52320313",
"0.5217663",
"0.5177643",
"0.51688343",
"0.5163516",
"0.5158834",
"0.51469874",
"0.5146237",
"0.5131132",
"0.5122548",
"0.510112",
"0.50868297",... | 0.741309 | 1 |
Process files for each field that is a multifilefield. | def process_files(self):
if not self.is_valid():
raise FormNotValidException
for (fieldname, field) in self.fields:
if isinstance (field, MultiFileField):
self.process_files_for(fieldname)
return self.cleaned_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_files_for(self, fieldname):\n\n\n if not self.is_valid():\n raise FormNotValidException\n\n\n field = self.fields[fieldname]\n storage = field.storage\n\n if not storage:\n raise NoStorageException\n\n field_data = self.cleaned_data.pop(fieldname... | [
"0.6112194",
"0.59885496",
"0.58400065",
"0.5771806",
"0.56620646",
"0.56580436",
"0.56520313",
"0.5569259",
"0.55260426",
"0.55072564",
"0.5501521",
"0.5396921",
"0.5386096",
"0.53734475",
"0.53042626",
"0.5296735",
"0.52898544",
"0.5253372",
"0.5212793",
"0.5206958",
"0.520... | 0.66723007 | 0 |
Cleaned multifilefield data structure is a tuple (arg1, arg2). arg1 (to_add) = [file_obj] (list of uploaded file objects to add), arg2 (to_remove) [file_id] (list of file_ids to remove). Currently this only works with queryset argument. | def process_files_for(self, fieldname):
if not self.is_valid():
raise FormNotValidException
field = self.fields[fieldname]
storage = field.storage
if not storage:
raise NoStorageException
field_data = self.cleaned_data.pop(fieldname, None)
o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clean_datafile_set(self):\n file_list = self._meta['sets']['data file']['items']\n for item in file_list[:]:\n collection = item.split('@')[0]\n variable = item.split('@')[1]\n if not variable in self:\n file_list.remove(item)\n elif col... | [
"0.63236666",
"0.5698625",
"0.56133837",
"0.53911656",
"0.53887737",
"0.5330391",
"0.532132",
"0.5304173",
"0.5234486",
"0.51293516",
"0.51022744",
"0.50739855",
"0.5047619",
"0.5040034",
"0.5027847",
"0.5009377",
"0.5000067",
"0.4992929",
"0.4940558",
"0.4936283",
"0.4901647... | 0.61166567 | 1 |
This function returns the coordinates of the button clicked. | def get_coordinates(button):
global buttons
for x in range(len(buttons)):
for y in range(len(buttons[x])):
if buttons[x][y] == button:
return x, y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Canvas_onclick(event):\n global ix, iy\n ix, iy = event.xdata, event.ydata\n print 'x = %f -> i = %d, y = %f' % (ix,ix/0.5*fig.Fulllength, iy)\n\n global coords\n coords = [ix, iy]\n\n return coords",
"def clickCell(self, event):\n position = self.input.checkMouseInput(event)\n ... | [
"0.71394116",
"0.6926403",
"0.6879231",
"0.682607",
"0.67914844",
"0.6791456",
"0.67369324",
"0.66710997",
"0.6649575",
"0.66152775",
"0.66025096",
"0.65994275",
"0.6565372",
"0.6529181",
"0.65277857",
"0.6512412",
"0.64976925",
"0.6433969",
"0.6370441",
"0.6335972",
"0.63053... | 0.7391261 | 0 |
This function returns the button memory location corresponding to a coordinate. | def get_button(x, y):
global buttons
return buttons[x][y] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_coordinates(button):\n global buttons\n for x in range(len(buttons)):\n for y in range(len(buttons[x])):\n if buttons[x][y] == button:\n return x, y",
"def _get_field_coords_placement_buttons(button_number):\r\n # calculates first coordinate\r\n start_coord = ... | [
"0.6926194",
"0.6622084",
"0.6349022",
"0.61486614",
"0.5985558",
"0.5879508",
"0.5851864",
"0.58371025",
"0.5763457",
"0.5709562",
"0.56370944",
"0.56301534",
"0.5611733",
"0.56105906",
"0.5608016",
"0.5587461",
"0.55421996",
"0.552089",
"0.5507225",
"0.5500345",
"0.54831445... | 0.6956459 | 0 |
This function will exit the game by killing the root. | def exit_game(root):
root.destroy() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exit(self):\n \t\troot.destroy()\n \t\tpass",
"def quit_game(self):\n pg.quit()\n sys.exit()",
"def terminate():\r\n pygame.quit()\r\n os._exit(1)",
"def quit_program():\n sys.exit()",
"def exit_program():\n quit()",
"def end_game():\n pygame.quit()\n exit()",
... | [
"0.7048221",
"0.6904934",
"0.684387",
"0.677202",
"0.6672508",
"0.66466427",
"0.66433334",
"0.66124266",
"0.6581606",
"0.65747094",
"0.6539335",
"0.6506314",
"0.65061086",
"0.6442426",
"0.64409506",
"0.64384145",
"0.64357513",
"0.6426525",
"0.64063627",
"0.63786685",
"0.63659... | 0.7916451 | 0 |
Return the VSCode Symbol Type | def _kind(d):
return _SYMBOL_KIND_MAP.get(d.type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTypeCode(self):\n return _libsbml.GeneralGlyph_getTypeCode(self)",
"def getTypeCode(self):\n return _libsbml.FunctionTerm_getTypeCode(self)",
"def getTypeCode(self):\n return _libsbml.DefaultTerm_getTypeCode(self)",
"def getTypeCode(self):\n return _libsbml.ReferenceGlyph_g... | [
"0.6649018",
"0.6562573",
"0.65576017",
"0.65546024",
"0.64838475",
"0.64048684",
"0.6372233",
"0.635279",
"0.63372135",
"0.63341576",
"0.6328279",
"0.63185334",
"0.6316299",
"0.6314363",
"0.6309112",
"0.6247674",
"0.62342894",
"0.6220359",
"0.61798155",
"0.61741465",
"0.6172... | 0.6846838 | 0 |
Sets the seed for this env's random number generator(s). Returns Returns the list of seeds used in this env's random number generators | def seed(self, seed=None):
self.np_random, seed = gym.utils.seeding.np_random(seed)
return [seed] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seed (self, seed=None):\n self.np_random, seed = seeding.np_random(seed)\n return [seed]",
"def seed(self, seed=None):\n self.np_random, seed = seeding.np_random(seed)\n return [seed]",
"def seed(self, seed=None):\n self.np_random, seed = seeding.np_random(seed)\n ... | [
"0.84853697",
"0.8463831",
"0.8463831",
"0.8447249",
"0.8351227",
"0.8250413",
"0.80403525",
"0.796306",
"0.7315629",
"0.72712773",
"0.7259946",
"0.7238558",
"0.7234487",
"0.7211908",
"0.7199528",
"0.7169771",
"0.714234",
"0.71165854",
"0.71165854",
"0.70867884",
"0.69960344"... | 0.8513289 | 0 |
Uses ``dill`` to pickle an object and returns the SHA512 hash of the returned bytes. | def pickle_and_hash(obj: Any) -> str:
try:
s = dill.dumps(obj)
except:
raise UnpickleableError()
return hashlib.sha512(s).hexdigest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sha512(data):\r\n return hashlib.sha512(data).hexdigest()",
"def _hash(data):\n return hashlib.sha512(data).hexdigest()",
"def get_sha512_from_stream(src: io.IOBase) -> str:\n if not isinstance(src, io.IOBase) or not src.readable():\n raise Exception(\"src is not stream or unreadable\")\n ... | [
"0.6868303",
"0.6776941",
"0.6536217",
"0.6359011",
"0.6346144",
"0.63309836",
"0.6308165",
"0.6300291",
"0.6158991",
"0.6065953",
"0.6015633",
"0.5908083",
"0.58114564",
"0.58099896",
"0.5809814",
"0.58072025",
"0.5806456",
"0.58024085",
"0.5771051",
"0.57026136",
"0.5697317... | 0.78864163 | 0 |
Removes all elements from a list that cannot be pickled with ``dill``. | def filter_pickleable_list(lst: List[Any]) -> None:
to_delete = []
for i, v in enumerate(lst):
try:
dill.dumps(v)
except:
to_delete.append(i)
to_delete.reverse()
for i in to_delete:
lst.pop(i) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wipe():\n try:\n inputlist *= 0\n except NameError:\n pass\n try:# is not None and len(outputlist) > 0:\n outputlist *= 0\n except NameError:\n pass\n try:# is not None and len(partlist) > 0:\n partlist *= 0\n except NameError:\n pass\n tagged = 0\... | [
"0.62287337",
"0.59059364",
"0.58538765",
"0.5773916",
"0.56907654",
"0.56907654",
"0.5662878",
"0.56608725",
"0.5629401",
"0.5628219",
"0.553688",
"0.55198175",
"0.55127347",
"0.5479325",
"0.5472791",
"0.54622316",
"0.5436917",
"0.5411757",
"0.53441554",
"0.53180534",
"0.531... | 0.7419867 | 0 |
Converts a Jupyter Notebook to a string of executable Python code. | def notebook_to_string(nb_path: Union[str, nbformat.NotebookNode]) -> str:
if isinstance(nb_path, str):
with open(nb_path) as f:
nb = json.load(f)
elif isinstance(nb_path, nbformat.NotebookNode):
nb = nb_path
else:
raise TypeError("invalid notebook type")
sour... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jupyter():",
"def pull_code(notebook):\n cells = notebook[\"cells\"]\n code = []\n for cell in cells:\n if cell[\"cell_type\"] == \"code\":\n code.extend(cell[\"source\"] + [\"\\n\"])\n return ''.join(code)",
"def convert_to_py(fname):\n exec_command(\"ipython nbconvert --t... | [
"0.63278925",
"0.628687",
"0.5959532",
"0.5790771",
"0.5718281",
"0.5670384",
"0.56037426",
"0.5544599",
"0.553377",
"0.5532818",
"0.55107915",
"0.54593736",
"0.5435314",
"0.5416309",
"0.53870696",
"0.5368081",
"0.535116",
"0.53343385",
"0.5320606",
"0.53144354",
"0.5285109",... | 0.6452459 | 0 |
Returns the stem of a filepath. | def get_stem(fp) -> str:
return os.path.splitext(os.path.split(fp)[1])[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stem(self) -> str:",
"def getFileStem(fPath):\n\tfor ext in [\".gz\", \".xz\", \".bz2\", \".Z\", \".z\"]:\n\t\tif fPath.endswith(ext):\n\t\t\tfPath = fPath[:-len(ext)]\n\t\t\tbreak\n\treturn os.path.splitext(os.path.basename(fPath))[0]",
"def filepath_name_only(filepath: str) -> str:\n return pathlib.Pa... | [
"0.76394767",
"0.7310701",
"0.723801",
"0.6771063",
"0.65446395",
"0.64882344",
"0.6461557",
"0.64049494",
"0.64049494",
"0.6389588",
"0.6381453",
"0.6351304",
"0.63297206",
"0.6262806",
"0.61740637",
"0.6112027",
"0.6098938",
"0.6073575",
"0.60364956",
"0.60245854",
"0.59903... | 0.8015169 | 0 |
Default destination path for the ``dump`` method | def _default_dump_dest(self) -> str:
... # pragma: no cover | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_file_path(self) -> str:\n return pulumi.get(self, \"dump_file_path\")",
"def dump(self, dest: Optional[str] = None) -> None:\n if dest is None:\n dest = self._default_dump_dest\n with open(dest, \"wb+\") as f:\n dill.dump(self, f)",
"def dump_file_path(self) ... | [
"0.7201567",
"0.696964",
"0.67627716",
"0.6337058",
"0.6323232",
"0.6323232",
"0.6316314",
"0.6135335",
"0.6104636",
"0.60738903",
"0.5985102",
"0.59354335",
"0.5933713",
"0.5884853",
"0.5844185",
"0.58255124",
"0.5806035",
"0.579896",
"0.5779398",
"0.5742656",
"0.5737665",
... | 0.8588375 | 0 |
Pickles this object to a base64encoded string. | def dumps(self) -> str:
bits = dill.dumps(self)
return base64.b64encode(bits).decode("ascii") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(self) -> bytes:\n return pickle.dumps(self)",
"def data64(self) -> str:\n return Image.encode64(self.data)",
"def base64(self):\n image = self.png.getvalue()\n return base64.encodestring(image).decode('utf-8')",
"def serialize(obj):\n result = base64.urlsafe_b64en... | [
"0.75595284",
"0.7114297",
"0.7059105",
"0.69777167",
"0.69380856",
"0.6869259",
"0.68347937",
"0.66593164",
"0.6650304",
"0.6650304",
"0.6623535",
"0.6589259",
"0.6587201",
"0.65742165",
"0.6570581",
"0.65289354",
"0.65117747",
"0.6510954",
"0.6477406",
"0.64643013",
"0.6464... | 0.8186574 | 0 |
Creates validators generator for the spec resolver. | def from_spec_resolver(cls, spec_resolver):
deref = DerefValidatorDecorator(spec_resolver)
for key, validator_callable in iteritems(cls.validators):
yield key, deref(validator_callable) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_validators__(cls) -> Generator:\n yield cls.validate_type\n yield cls.validate_strip\n yield cls.validate_allow_empty\n yield cls.validate_max_length\n yield cls.validate_min_length\n yield cls.validate_regex",
"def from_resolver(cls, spec_resolver):\n s... | [
"0.68738085",
"0.67296714",
"0.62502265",
"0.58731",
"0.5784427",
"0.564984",
"0.56412154",
"0.5432075",
"0.5428979",
"0.5409628",
"0.5394603",
"0.5376655",
"0.5323605",
"0.52081186",
"0.51969",
"0.5192181",
"0.51859254",
"0.51851594",
"0.5167256",
"0.516368",
"0.5154187",
... | 0.77401423 | 0 |
This function initializes the radios, each radio being the NRF24 transceivers. It gets 3 arguments, csn = Chip Select, ce = Chip Enable and the channel that will be used to transmit or receive the data. | def initialize_radios(csn, ce, channel):
radio = NRF24(GPIO, spidev.SpiDev())
radio.begin(csn, ce)
time.sleep(2)
radio.setRetries(15, 15)
radio.setPayloadSize(32)
radio.setChannel(channel)
radio.setDataRate(NRF24.BR_250KBPS)
radio.setPALevel(NRF24.PA_MIN)
radio.setAutoAck(False)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n GPIO.setmode(GPIO.BCM)\n pipes = [[0xC2, 0xC2, 0xC2, 0xC2, 0x01],\n [0xC2, 0xC2, 0xC2, 0xC2, 0x02],\n [0xC2, 0xC2, 0xC2, 0xC2, 0x03],\n [0xC2, 0xC2, 0xC2, 0xC2, 0x04],\n [0xC2, 0xC2, 0xC2, 0xC2, 0x05],\n ... | [
"0.5652461",
"0.53511095",
"0.52509475",
"0.52499574",
"0.518633",
"0.51654124",
"0.5140248",
"0.5131349",
"0.5119922",
"0.5038761",
"0.5037373",
"0.5001759",
"0.4943187",
"0.4940103",
"0.4872619",
"0.48649645",
"0.48528293",
"0.48431507",
"0.48374632",
"0.48181954",
"0.48097... | 0.84867877 | 1 |
Gets the provided file and reads its content as bytes, after that, it stores everything in the variable payload_list, which it returns. | def read_file(file_path):
payload_list = list()
if os.path.isfile(file_path):
print("Loading File in: " + file_path)
with open(file_path, 'rb') as f:
count = 0
while True:
chunk = f.read(25)
if chunk:
if count == 100... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_payload(path):\n with open(path, 'rb') as f:\n return f.read()",
"def get_payload(self):\n # go to the end find the filesize\n self.buf.seek(0, 2)\n size = self.buf.tell() - self.header_offset\n\n # go to the beginning\n self.buf.seek(self.header_offset)\n ... | [
"0.6325435",
"0.60830796",
"0.59684616",
"0.59459096",
"0.58606714",
"0.58342016",
"0.5794988",
"0.572984",
"0.56785774",
"0.56563747",
"0.56342447",
"0.5633453",
"0.56229866",
"0.5600665",
"0.5595041",
"0.55823386",
"0.55751693",
"0.5574575",
"0.5566808",
"0.5565724",
"0.556... | 0.71457636 | 0 |
This main function initializes the radios and sends all the data gathered from the file. | def main():
radio = initialize_radios(0, 25, 0x60)
radio.openWritingPipe(pipes[1])
radio.openReadingPipe(0, pipes[0])
print("Sender Information")
radio.printDetails()
payload_list = read_file(sys.argv[1])
count = 0
while count < len(payload_list):
# send a packet to receiver... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n radio = initialize_radios(0, 25, 0x60)\n\n radio.openWritingPipe(pipes[0])\n radio.openReadingPipe(0, pipes[1])\n\n print(\"Sender Information\")\n radio.printDetails()\n\n payload_list = list()\n\n out = False\n count = 0\n actual_ack = None\n while not out:\n ... | [
"0.6160801",
"0.5723876",
"0.5656814",
"0.5635107",
"0.5584961",
"0.5564952",
"0.552277",
"0.54999053",
"0.54908663",
"0.542653",
"0.54165506",
"0.539131",
"0.53328377",
"0.53283954",
"0.531352",
"0.52858764",
"0.5283814",
"0.52611727",
"0.52379",
"0.52142626",
"0.51999044",
... | 0.66098106 | 0 |
Provide a Djime statusbar. Displays the running timer, the current task, total time today, etc. | def statusbar(request):
templatevars = {}
if request.user.is_authenticated():
current_slice = TimeSlice.objects.filter(end=None, user=request.user)[:1]
if current_slice:
# Unpack the QuerySet to get the model object.
cslice = current_slice[0]
slice_time = {'ye... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def StatusbarTimer(self):\r\n\t\ttime.sleep(self.statusmsgTimeout)\r\n\t\tself.statusbar.SetStatusText(self.statusmsg)",
"def statusBar():\n\tmain_window = MainWindow()\n\treturn main_window.statusBar()",
"def display_status(self):\n time = float2str(self.scheduler.time, '10.2f')\n tx = float2str... | [
"0.6955959",
"0.6589621",
"0.6579346",
"0.6455984",
"0.637577",
"0.63108176",
"0.62792844",
"0.6239581",
"0.62159467",
"0.6211811",
"0.6208953",
"0.6163392",
"0.6143376",
"0.6092898",
"0.6041318",
"0.6037242",
"0.6029641",
"0.6022052",
"0.601987",
"0.6016798",
"0.5986081",
... | 0.7080678 | 0 |
Truncates/pads a float to num_decimals decimal places without rounding. | def truncate(input_float, num_decimals):
s = '{}'.format(input_float)
if 'e' in s or 'E' in s:
return '{0:.{1}f}'.format(input_float, num_decimals)
i, p, d = s.partition('.')
return '.'.join([i, (d + '0' * num_decimals)[:num_decimals]]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def float_padding(length, val, decimals=2):\n return '{0:0>{fill}.{precision}f}'.format(float(val), fill=length, precision=decimals)",
"def FIXED(number, decimals=2, no_commas=False):\n comma_flag = '' if no_commas else ','\n return \"{:{}.{}f}\".format(round(number, decimals), comma_flag, max(0, decimals))... | [
"0.68755686",
"0.6789368",
"0.6673552",
"0.65843624",
"0.64771795",
"0.64566827",
"0.64037097",
"0.6316747",
"0.6296527",
"0.62955606",
"0.6274286",
"0.62178266",
"0.6109919",
"0.6065427",
"0.60518914",
"0.60475236",
"0.60145974",
"0.59458596",
"0.59154713",
"0.5901654",
"0.5... | 0.76069707 | 0 |
Generates a random and pseudounique string. ``seed`` None if `None` the seed is generated from the current time and a random value. | def generate_unique(seed=None):
if not seed:
seed = str(time() * random())
return unicode(abs(hash(sha(seed).hexdigest()))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Randomize(seed=None):\n random.seed()",
"def gen_random(\n l: list,\n n: int,\n seed: int = None\n ) -> str:\n\n # Initialisations\n s = \"\"\n\n # Loop for the desired length of the string\n for i in range(0, n):\n\n if seed is not None:\n\n numpy.random.seed... | [
"0.68625",
"0.63870114",
"0.61879915",
"0.6127082",
"0.61231",
"0.6101993",
"0.6100532",
"0.60254854",
"0.60024655",
"0.5995402",
"0.5950897",
"0.5866808",
"0.58658016",
"0.5830108",
"0.5826502",
"0.5812559",
"0.57719857",
"0.57678384",
"0.57608855",
"0.57091254",
"0.5693168"... | 0.69099563 | 0 |
Computes the SASL handshake ``stanza_id`` stanza identifier ``secret`` the secret value to be hashed with the stanza identifier. | def compute_handshake(stanza_id, secret):
return unicode(sha(str(stanza_id) + str(secret)).hexdigest().lower()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_secret(secret):\n\n hashed = hashlib.sha256(secret.encode('UTF-8')).hexdigest()\n return hashed",
"def hash_secret(secret: str) -> Tuple[bytes, bytes]:\n secret_bytes = secret.encode(SECRET_ENCODING)\n secret_salt = os.urandom(CRYPTO_SALT_LEN)\n secret_hash = hash_secret_raw(secret_bytes,... | [
"0.6468007",
"0.6209297",
"0.56370544",
"0.54836625",
"0.54201484",
"0.53535616",
"0.5315813",
"0.5294368",
"0.52557147",
"0.52286136",
"0.51601905",
"0.5145181",
"0.5128153",
"0.49765128",
"0.49546483",
"0.49522695",
"0.494328",
"0.4940987",
"0.4940987",
"0.49154478",
"0.491... | 0.7842187 | 0 |
Removes the BOM from the provided `text`. | def remove_BOM(text):
if codecs.BOM_UTF8.decode("utf-8") in text:
return text.replace(codecs.BOM_UTF8.decode("utf-8"), '')
if codecs.BOM.decode("utf-16") in text:
return text.replace(codecs.BOM.decode("utf-16"), '')
if codecs.BOM_BE.decode("utf-16-be") in text:
return text.replace(co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_bom(file):\n bufsize = 4096\n bomlen = len(codecs.BOM_UTF8)\n\n with open(file, \"r+b\") as fp:\n chunk = fp.read(bufsize)\n if chunk.startswith(codecs.BOM_UTF8):\n i = 0\n chunk = chunk[bomlen:]\n while chunk:\n ... | [
"0.71478003",
"0.6548835",
"0.6533167",
"0.6349936",
"0.6169597",
"0.60927975",
"0.5953555",
"0.5915183",
"0.58960986",
"0.5893658",
"0.5816142",
"0.5804233",
"0.58033854",
"0.577794",
"0.5765889",
"0.576588",
"0.5747115",
"0.5735876",
"0.5728184",
"0.57193863",
"0.5689397",
... | 0.8721163 | 0 |
Find the bin edges given the bin centres. | def find_bin_edges(bin_centres):
if not isinstance(bin_centres, np.ndarray):
bin_centres = np.asarray(bin_centres)
edges = bin_centres[:-1] + 0.5 * (bin_centres[1:] - bin_centres[:-1])
bins = np.concatenate(([2 * bin_centres[0] - edges[0]], edges,
[2 * bin_centres[-1] - ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bin_center_to_edges(centers):\n edges = bin_edges_to_center(centers)\n edges = np.append(centers[0]-(edges[0]-centers[0]), edges)\n edges = np.append(edges, centers[-1]+(centers[-1]-edges[-1]))\n return edges",
"def _get_bin_edges(a, bins, range):\n # parse the overloaded bins argument\n n_... | [
"0.7446626",
"0.7235217",
"0.6906606",
"0.6849931",
"0.6581265",
"0.65642935",
"0.6515859",
"0.64016193",
"0.63928217",
"0.6363073",
"0.63319844",
"0.63212705",
"0.6314931",
"0.62476146",
"0.6239668",
"0.6232608",
"0.6232608",
"0.6198153",
"0.60947776",
"0.6072682",
"0.605867... | 0.8652303 | 0 |
Normalises the spectrum to match the flux equivalent to the given AB magnitude in the given passband. | def normalise_to_magnitude(self, magnitude, band):
from ..photometry import mag2flux
mag_flux = mag2flux(magnitude, band)
spec_flux = self.calculate_flux(band)
norm = mag_flux / spec_flux
self.flux *= norm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def norm_band(band):\n b_min, b_max = band.min(), band.max()\n return (band - b_min) / (b_max - b_min)",
"def normalise(self, spectrum):\n\n return spectrum",
"def normalise(self, spectrum):\n\n return spectrum",
"def calculate_flux(self, band):\n\n if (self.wavelength[0] > band.wa... | [
"0.6974019",
"0.6329584",
"0.6329584",
"0.58575153",
"0.5744298",
"0.57064956",
"0.56873137",
"0.5681218",
"0.56723785",
"0.5411331",
"0.53969234",
"0.53928864",
"0.5356929",
"0.5321028",
"0.531087",
"0.5299926",
"0.52493846",
"0.5239136",
"0.5224336",
"0.5219534",
"0.5219534... | 0.7744449 | 0 |
Calculate the mean flux for a passband, weighted by the response and wavelength in the given passband. | def calculate_flux(self, band):
if (self.wavelength[0] > band.wavelength[0] or
self.wavelength[-1] < band.wavelength[-1]):
warn('Spectrum does not cover the whole bandpass, '
'extrapolating...')
dw = np.median(np.diff(self.wavelength.value))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_tod(self,d,feed_tod,feed_weights,mask): \n\n frequency = d['level1/spectrometer/frequency'][...]\n # This becomes (nBands, 64) \n self.frequency = np.mean(np.reshape(frequency,(frequency.shape[0],frequency.shape[1]//16,16)) ,axis=-1)\n all_tod = np.zeros((8, fe... | [
"0.60364336",
"0.5998705",
"0.59372216",
"0.58633137",
"0.5791854",
"0.57410866",
"0.56994116",
"0.5697505",
"0.56591386",
"0.5612077",
"0.55279833",
"0.5498874",
"0.5495158",
"0.54695207",
"0.54493624",
"0.5395612",
"0.5393538",
"0.53913325",
"0.53875065",
"0.5379907",
"0.53... | 0.77326393 | 0 |
Calculates the magnitude in a given passband. | def calculate_magnitude(self, band, system='AB'):
if system not in ('AB', 'Vega'):
raise ValueError('`system` must be one of `AB` or `Vega`')
f1 = self.calculate_flux(band)
if f1 > 0:
magnitude = -2.5 * log10(f1 / band.flux[system])
if system == 'Vega':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalise_to_magnitude(self, magnitude, band):\n\n from ..photometry import mag2flux\n\n mag_flux = mag2flux(magnitude, band)\n spec_flux = self.calculate_flux(band)\n norm = mag_flux / spec_flux\n self.flux *= norm",
"def waveform_2_magnitude(waveform, frame_length=512, fr... | [
"0.7158013",
"0.6311868",
"0.6217596",
"0.61581296",
"0.6152565",
"0.61128145",
"0.61058253",
"0.6005203",
"0.59781146",
"0.5939756",
"0.5926593",
"0.58984876",
"0.5890583",
"0.5858499",
"0.5842892",
"0.5836618",
"0.5806482",
"0.58059347",
"0.5795638",
"0.5794579",
"0.5746308... | 0.7367935 | 0 |
Rebin the spectrum onto a new dispersion axis. | def rebin(self, dispersion):
if isinstance(dispersion, float):
dispersion = np.arange(
self.dispersion.value[0], self.dispersion.value[-1],
dispersion)
old_bins = find_bin_edges(self.dispersion.value)
new_bins = find_bin_edges(dispersion)
wi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resample(self, new_dispersion, inplace=False, force=False):\n\n # Mapping of the SpecOneD object variables to the function\n # variables\n\n old_spec_wavs = self.dispersion\n spec_fluxes = self.flux\n if self.flux_err is not None:\n spec_errs = self.flux_err\n ... | [
"0.61891925",
"0.5981273",
"0.5789036",
"0.57539487",
"0.56286407",
"0.56075656",
"0.5544638",
"0.54767305",
"0.54767305",
"0.5441754",
"0.5369923",
"0.53443944",
"0.5149824",
"0.5148976",
"0.51433593",
"0.51103723",
"0.5097697",
"0.5094881",
"0.50897753",
"0.5086159",
"0.508... | 0.7852937 | 0 |
Calculates the optical depth profile for a given spectral dispersion array. | def optical_depth(self, dispersion):
from ..calculations import optical_depth, tau_peak
if isinstance(dispersion, Quantity):
dispersion = dispersion.to(angstrom)
elif hasattr(dispersion, 'unit'):
if dispersion.unit is not None:
dispersion = dispersion.t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_depth(depth, calibration_extrinsics, intrinsics_color,\n intrinsics_depth_inv):\n img_height, img_width = depth.shape[0], depth.shape[1]\n depth_ = np.zeros_like(depth)\n x = np.linspace(0, img_width-1, img_width)\n y = np.linspace(0, img_height-1, img_height)\n xx, yy = np.mesh... | [
"0.6158681",
"0.57736975",
"0.57220364",
"0.5670999",
"0.5376958",
"0.52336186",
"0.52073723",
"0.51507497",
"0.5131838",
"0.50880295",
"0.5075388",
"0.5060786",
"0.50519574",
"0.5032107",
"0.5022151",
"0.5013911",
"0.49698007",
"0.4940918",
"0.49297845",
"0.49221352",
"0.492... | 0.59393317 | 1 |
Test that all ships are placed. | def test_places_all_ships(self):
player = TestPlayer()
self.ai.place_ships(player)
sorted_ships = sorted(player.placed_ships)
self.assertEqual([2, 3, 3, 4, 5], sorted_ships) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sink(self):\n ship = Ship([self.hit])\n self.assertEqual([self.hit], ship.location)\n self.assertEqual(2, ship.check_hit(self.hit))\n self.assertEqual(0, len(ship.location))",
"def placeShips(self):\n\n self.ships = [] # Canvas co-ordinates for the ships\n self... | [
"0.68614626",
"0.68251735",
"0.68129474",
"0.6551621",
"0.65051997",
"0.63404155",
"0.62845504",
"0.62626433",
"0.6245454",
"0.6234668",
"0.6234668",
"0.62172675",
"0.6212564",
"0.6211277",
"0.62067705",
"0.6200432",
"0.619267",
"0.618957",
"0.6185617",
"0.6173209",
"0.614332... | 0.81689227 | 0 |
Test that the AI takes a shot. | def test_takes_shot(self):
player = TestPlayer()
self.ai.take_shot(player)
self.assertEqual(1, player.shots_taken) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_single_shot(self) -> None:\n trigger = auraxium.Trigger(auraxium.event.Death, single_shot=True)\n flag = asyncio.Event()\n\n async def wait_for(event: auraxium.event.Event) -> None:\n _ = event\n self.assertGreaterEqual(event.age, 0.0, 'event age is negativ... | [
"0.67549264",
"0.67382467",
"0.66291815",
"0.6592713",
"0.6544942",
"0.6492198",
"0.6329987",
"0.6326388",
"0.6295496",
"0.62563074",
"0.62296647",
"0.6184767",
"0.6184517",
"0.618448",
"0.61547095",
"0.6137742",
"0.6131026",
"0.61153305",
"0.61110663",
"0.606092",
"0.6047564... | 0.86101365 | 0 |
Test converting files with different range settings across frequency. | def test_convert_azfp_01a_different_ranges(azfp_path):
azfp_01a_path = azfp_path / '17031001.01A'
azfp_xml_path = azfp_path / '17030815.XML'
# Convert file
echodata = open_raw(
raw_file=azfp_01a_path, sonar_model='AZFP', xml_path=azfp_xml_path
)
assert echodata["Sonar/Beam_group1"].back... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_simsam_range_to_files(self):\r\n qiime.simsam.simsam_range_to_files(self.tutorial_otu_table,\r\n self.tutorial_tree,\r\n [2],\r\n [0.1],\r\n ... | [
"0.6079145",
"0.59959686",
"0.58200115",
"0.5548766",
"0.55080825",
"0.54831004",
"0.53988516",
"0.53674597",
"0.5335733",
"0.5329678",
"0.5266946",
"0.5254497",
"0.52481544",
"0.5224682",
"0.5218362",
"0.52122545",
"0.5195291",
"0.51725334",
"0.515655",
"0.5146331",
"0.51363... | 0.6175704 | 0 |
Test converting file with no valid temperature or tilt data. | def test_convert_azfp_01a_notemperature_notilt(azfp_path):
azfp_01a_path = azfp_path / 'rutgers_glider_notemperature/22052500.01A'
azfp_xml_path = azfp_path / 'rutgers_glider_notemperature/22052501.XML'
echodata = open_raw(
raw_file=azfp_01a_path, sonar_model='AZFP', xml_path=azfp_xml_path
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_convert_invalid_unit():\n with pytest.raises(ValueError):\n pressure_util.convert(5, INVALID_SYMBOL, VALID_SYMBOL)\n\n with pytest.raises(ValueError):\n pressure_util.convert(5, VALID_SYMBOL, INVALID_SYMBOL)",
"def test_temperature(self):\r\n self.assertEqual(Converter.Tempera... | [
"0.6557191",
"0.645616",
"0.6440721",
"0.6420493",
"0.63698214",
"0.6219654",
"0.6180978",
"0.61737883",
"0.6159273",
"0.6124087",
"0.6123235",
"0.61169326",
"0.6077729",
"0.6055841",
"0.60345423",
"0.60162026",
"0.6014198",
"0.60062915",
"0.5984679",
"0.5957662",
"0.59262973... | 0.70200545 | 0 |
r"""Create a lock object. The actual lock is acquired once the ``with`` context is entered. fname Filename to lock. This file may or may not exist. It will not be modified at all and is just used to signal the intention to coordinate access to this file. The actual lock file will be called ``"{fname}.lock"``, where ``{... | def __init__(self, fname, lockduration=10, verbosity=0):
self._verbosity = verbosity
self._lockduration = lockduration
fname = op.normpath(fname)
self._basedir = op.dirname(fname)
self._lockfilename = "%s.lock" % op.basename(fname)
self._uniquename = ",".join((
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_lock_file():\n\n print(\"Creating lock file\")",
"def create_lock(self):\n self.check_lock()\n lockfile = open(self._lockfilename, \"w\")\n lockfile.write(str(os.getpid()))",
"def __init__(self, lockfile, lifetime=DEFAULT_LOCK_LIFETIME):\n self.__lockfile = lockfil... | [
"0.6446042",
"0.62238336",
"0.6096234",
"0.60594165",
"0.6045065",
"0.6026343",
"0.5882793",
"0.5879895",
"0.5781617",
"0.5753848",
"0.5738176",
"0.5734948",
"0.57312196",
"0.56899637",
"0.568272",
"0.5676964",
"0.5619683",
"0.5579398",
"0.5547726",
"0.5546562",
"0.55420136",... | 0.73400015 | 0 |
r"""The unique file used as second link target. | def uniquefile(self):
return op.join(self._basedir, self._uniquename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link(self, fname):\n return fname",
"def target(self):\n if self._security_class == \"lnk_file\":\n return self._target\n else:\n return None",
"def get_file_url(self):\n return ('/user-media/addons/3615/delicious_bookmarks-2.1.072-fx.xpi?'\n ... | [
"0.6755908",
"0.62209255",
"0.6171731",
"0.6155458",
"0.61264646",
"0.60556626",
"0.60408294",
"0.6037479",
"0.6008012",
"0.59945405",
"0.5934283",
"0.5916542",
"0.59159076",
"0.5913472",
"0.5896633",
"0.5846552",
"0.58372045",
"0.5809676",
"0.57855684",
"0.5770819",
"0.57429... | 0.68793374 | 0 |
r"""Enter the `with` context and establish the lock. | def __enter__(self):
try:
self._lock()
except:
self._unlock()
raise
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __enter__(self):\r\n if not self.is_locked:\r\n self.acquire()\r\n return self",
"def __enter__(self):\n return self._lock.__enter__()",
"def __enter__(self):\n if not self.is_locked:\n self.acquire()\n return self",
"def __enter__(self):\r\n ... | [
"0.76581836",
"0.76339316",
"0.7623075",
"0.7319065",
"0.7253262",
"0.7253262",
"0.7221099",
"0.7182054",
"0.7058474",
"0.69339734",
"0.6864672",
"0.67241794",
"0.6691287",
"0.66766244",
"0.6671094",
"0.6660148",
"0.6616258",
"0.6596494",
"0.6570964",
"0.6552947",
"0.65470046... | 0.76636004 | 0 |
r"""Find out if we currently have the lock. The condition to have the lock is that our unique file and the lock file are two hard links to the same file. This is checked by making sure the hard link count of our unique file is 2 and that their contents are equal. No check for expiration of the lock is done here. | def is_locked(self):
if not self._uniquefile_created:
return False
links = self._count_links()
return links == 2 and self._read_lockfile() == self._uniquename | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locked(self):\n # Discourage breaking the lock for a while.\n try:\n self.__touch()\n except OSError, e:\n if e.errno == errno.EPERM:\n # We can't touch the file because we're not the owner. I\n # don't see how we can own the lock if we'... | [
"0.7670033",
"0.7582659",
"0.75311595",
"0.72090715",
"0.7118613",
"0.701926",
"0.697991",
"0.69244826",
"0.689455",
"0.685791",
"0.6776215",
"0.6734711",
"0.6730927",
"0.66941524",
"0.6606851",
"0.6585343",
"0.65615815",
"0.6466519",
"0.6460064",
"0.6401198",
"0.6400434",
... | 0.8366861 | 0 |
r"""Acquire the lock. This creates the unique file (if it doesn't exist) and then tries to create the second hard link. If unsuccessful, we wait a bit and try again until the "foreign" lock has expired or has been removed. | def _lock(self):
self._create_unique_file()
while True:
try:
self._extend_expiration_time() # in case we had to wait...
os.link(self.uniquefile, self.lockfile)
self._p("Lock successfully acquired.")
return
except OSE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acquire(self, timeout=None):\r\n try:\r\n open(self.unique_name, \"wb\").close()\r\n except IOError:\r\n raise LockFailed\r\n\r\n end_time = time.time()\r\n if timeout is not None and timeout > 0:\r\n end_time += timeout\r\n\r\n while True:\r\... | [
"0.81198674",
"0.7904824",
"0.78126377",
"0.7488853",
"0.7417729",
"0.7144241",
"0.7117167",
"0.7102071",
"0.7061276",
"0.68602425",
"0.68495977",
"0.68495977",
"0.6829876",
"0.6827711",
"0.6811304",
"0.6791493",
"0.67156905",
"0.66920817",
"0.6662029",
"0.66395855",
"0.66278... | 0.79817706 | 1 |
r"""Count the number of hard links to our unique file. | def _count_links(self):
try:
return os.stat(self.uniquefile).st_nlink
except OSError as e:
if e.errno in self.NOT_EXIST_ERRORS:
return 0 # no links, i.e. file does not exist
raise | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFileCount(self) -> int:\n ...",
"def fileCount(self):\n pass",
"def fileCounter(directory):",
"def n_file(self):\n self.assert_is_dir_and_exists()\n n = 0\n for _ in self.select_file(recursive=True):\n n += 1\n return n",
"def get_total_link_num(t... | [
"0.71317583",
"0.7000584",
"0.6996162",
"0.6681487",
"0.66141593",
"0.65153754",
"0.65066326",
"0.6499038",
"0.6426049",
"0.63551885",
"0.63335747",
"0.632912",
"0.6300456",
"0.6300275",
"0.62941545",
"0.62905335",
"0.62770724",
"0.62756026",
"0.62466997",
"0.62406355",
"0.62... | 0.80322653 | 0 |
r"""Check if the currently active lock has expired. Returns `False` if there is no lock. This checks the actual lock file, i.e. it applies if we have the lock or a different process has it. | def _has_expired(self):
try:
expires = datetime.fromtimestamp(
os.stat(self.lockfile).st_mtime
)
except OSError as e:
if e in self.NOT_EXIST_ERRORS:
return False
raise
return datetime.now() > expires | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isExpired(self):\n if self.timeout is None:\n return not self.exists()\n try:\n lock_age = time.time() - os.stat(self.lockDir).st_mtime\n return lock_age > self.timeout\n except OSError, err:\n if err.errno == errno.ENOENT:\n # No ... | [
"0.8514852",
"0.7758838",
"0.73962533",
"0.7389456",
"0.7364336",
"0.7292818",
"0.7252852",
"0.7244929",
"0.72382694",
"0.7224797",
"0.701862",
"0.700516",
"0.6939799",
"0.6935549",
"0.6928223",
"0.6854559",
"0.6854304",
"0.6837133",
"0.6807596",
"0.6789169",
"0.6783816",
"... | 0.8408925 | 1 |
r"""Break a lock of a different process. This should be called when the lock has expired, though no check is made here to ensure it actually has expired. It will remove the lock file and also the unique file that this lock file pointed to (if possible). | def _break_foreign_lock(self):
# If the foreign process did not crash and just takes a bit longer
# than expected, this may pull the rug from under their feet by
# removing the lock they think they're perfectly fine with. As
# everywhere in this class, we have to be quite fault tolerant ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def break_lock(self):\n remove_existing_pidfile(self.path)",
"def release_lock():\n lock_file = get_lock_file()\n if exists(lock_file):\n LOG.info('Removing lock file %r' % lock_file)\n os.unlink(lock_file)\n else:\n LOG.warning('Lock file %r did not exist.' % lock_file)",
... | [
"0.7696889",
"0.7053433",
"0.6995074",
"0.6931736",
"0.68632114",
"0.677512",
"0.67577136",
"0.67411655",
"0.6738901",
"0.6690569",
"0.6674217",
"0.6665299",
"0.66548675",
"0.665162",
"0.6626696",
"0.6413683",
"0.63757896",
"0.637546",
"0.6374937",
"0.6327749",
"0.631204",
... | 0.73801 | 1 |
r"""Validate that the given filename is a valid "unique" file name. We don't ever want to delete a file not managed by this class. We therefore check that the unique file name adheres to our naming convention by starting with the lock file name (without path) but being longer than that. This should remove any chance of... | def _is_valid_unique_fname(self, fname):
return (fname.startswith(self._lockfilename)
and len(fname) > len(self._lockfilename)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_unique_filename(containing_folder, filename):\n return not os.path.exists(join_path(containing_folder, filename))",
"def check_filename(basename):\n return len(basename) <= MAXIMUM_FILENAME_LENGTH",
"def validate_filename(\n filename: PathType,\n platform: Optional[PlatformType] = None,\n ... | [
"0.6688671",
"0.6663694",
"0.663029",
"0.6603494",
"0.64498216",
"0.6441576",
"0.637367",
"0.63708323",
"0.6368463",
"0.633483",
"0.63184965",
"0.6301388",
"0.6260003",
"0.6234287",
"0.6205698",
"0.61945635",
"0.6160527",
"0.6159596",
"0.61459434",
"0.61304307",
"0.6129222",
... | 0.77422434 | 0 |
r"""Return the contents of the current lock file. If there is no lock file, returns `None`. If we created the lock file, the contents equals the name (without path) of our unique file. | def _read_lockfile(self):
try:
with open(self.lockfile) as f:
return f.read()
except EnvironmentError as e:
if e.errno in self.NOT_EXIST_ERRORS:
return None
raise | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lockfile(self):\n return op.join(self._basedir, self._lockfilename)",
"def get_current_lockfile(self, package_build_base):\n return get_previous_lockfile(package_build_base, self.verb_name)",
"def _getLockFile(self):\n if self.baseFilename.endswith(\".log\"):\n lock_file = s... | [
"0.712671",
"0.69151723",
"0.69036615",
"0.6892721",
"0.6633274",
"0.6511246",
"0.63984597",
"0.630757",
"0.6292086",
"0.6281876",
"0.62011",
"0.61929333",
"0.60636425",
"0.6054659",
"0.6016299",
"0.59986717",
"0.59937555",
"0.59440815",
"0.5908795",
"0.5907353",
"0.58606523"... | 0.7888202 | 0 |
r"""Set the expiration time of the unique file to the future. This also affects the lock file in case we currently have the lock. The optional parameter can be used to extend the expiration time of e.g. a foreign lock file. | def _extend_expiration_time(self, fname=None):
if fname is None:
fname = self.uniquefile
future = datetime.now() + timedelta(seconds=self._lockduration)
expires = time.mktime(future.timetuple())
try:
os.utime(fname, (expires, expires))
except OSError as e:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flow_file_expiration(self, flow_file_expiration):\n\n self._flow_file_expiration = flow_file_expiration",
"def set_expiration_date(dirpath_build_cms,\n identifier,\n current_time,\n timedelta_expiration):\n # Make sure the expirat... | [
"0.67981446",
"0.65152586",
"0.64966667",
"0.6144058",
"0.6127075",
"0.6078739",
"0.60193044",
"0.5906692",
"0.58597034",
"0.5792519",
"0.5747189",
"0.5692322",
"0.5690266",
"0.56396616",
"0.5616774",
"0.55814123",
"0.5575253",
"0.5569798",
"0.552633",
"0.5524599",
"0.5511288... | 0.8155418 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.