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 |
|---|---|---|---|---|---|---|
r""" Initialize a collision with two wavefunctions, presumably a nucleus and a proton. One must implement the wilson line, though the order of the arguments does not matter. In the case that both wavefunctions implement the wilson line, the first (wavefunction1) will be used as such. In the case that neither implement ... | def __init__(self, wavefunction1: Wavefunction, wavefunction2: Wavefunction):
# Make sure that at least one has a wilson line
wilsonLineExists1 = callable(getattr(wavefunction1, "wilsonLine", None))
wilsonLineExists2 = callable(getattr(wavefunction2, "wilsonLine", None))
if not wilsonL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_library_charges_to_two_waters(self):\n ff = ForceField(\n get_data_file_path(\"test_forcefields/test_forcefield.offxml\"),\n get_data_file_path(\"test_forcefields/tip3p.offxml\"),\n )\n mol = Molecule.from_file(\n get_data_file_path(os.path.join(\"syst... | [
"0.5363549",
"0.53437185",
"0.5282484",
"0.4975989",
"0.49336395",
"0.49139965",
"0.4913422",
"0.4866941",
"0.485196",
"0.4840935",
"0.4831913",
"0.48300686",
"0.48231012",
"0.48094025",
"0.47987574",
"0.47694734",
"0.47500825",
"0.47249275",
"0.47237548",
"0.4697747",
"0.467... | 0.781818 | 0 |
r""" Calculate the field omega at each point on the lattice. If the field already exists, it is simply returned and no calculation is done. | def omega(self, forceCalculate=False, verbose=0):
if self._omegaExists and not forceCalculate:
return self._omega
self.incidentWavefunction.gaugeField(verbose=verbose)
self.targetWavefunction.adjointWilsonLine(verbose=verbose)
if verbose > 0:
print(f'Calculatin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calculateOmegaOpt(N, gluonDOF, delta, incidentGaugeField, targetAdjointWilsonLine):\n\n # 2,2 is for the 2 dimensions, x and y\n omega = np.zeros((N, N, 2, 2, gluonDOF), dtype='complex') # 2 is for two dimensions, x and y\n\n derivs = [_x_deriv, _y_deriv]\n\n for i in range(N):\n for j in r... | [
"0.61966604",
"0.61015",
"0.6020752",
"0.5965969",
"0.5809604",
"0.5785809",
"0.5762362",
"0.56903183",
"0.5675721",
"0.566216",
"0.562489",
"0.5606232",
"0.5581973",
"0.5539443",
"0.5505453",
"0.5466363",
"0.5453032",
"0.5429813",
"0.5425745",
"0.5405547",
"0.53965545",
"0... | 0.6339087 | 0 |
r""" Compute the fourier transform of the field omega on the lattice. If the fft of the field already exists, it is simply returned and no calculation is done. | def omegaFFT(self, forceCalculate=False, verbose=0):
if self._omegaFFTExists and not forceCalculate:
return self._omegaFFT
# Make sure omega exists
self.omega(verbose=verbose)
if verbose > 0:
print(f'Calculating {type(self).__name__} omega fourier transform' + '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fourier_transform(hamiltonian, grid, spinless):\n return _fourier_transform_helper(hamiltonian=hamiltonian,\n grid=grid,\n spinless=spinless,\n phase_factor=+1,\n v... | [
"0.63342255",
"0.63339674",
"0.6287672",
"0.62734646",
"0.62432265",
"0.61635166",
"0.61274135",
"0.60326177",
"0.60305816",
"0.5935891",
"0.59015477",
"0.5884128",
"0.58474153",
"0.58341295",
"0.58334965",
"0.57607025",
"0.57455075",
"0.5744383",
"0.57404006",
"0.5733641",
"... | 0.64539677 | 0 |
Evaluate the systematic uncertainty of the fit model. Each signal shape in fitting.lambdac_mass.shapes_sig is fitted with each background shape in fitting.lambdac_mass.shapes_bkg. The systematic uncertainty is taken as the largest fractional deviation from the nominal yield, which is the yield obtained from the nominal... | def fit_systematics(mode, polarity, year):
n = ntuples.get_ntuple(mode, polarity, year)
sel_path = "{0}/selected-{1}.root".format(config.output_dir, n)
sel_n = n.__class__("DecayTree", n.polarity, n.year)
sel_n.add(sel_path)
w_name = "{0}-{1}-{2}-workspace"
# Nominal shapes
# Nom nom nom
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit_power_law_MMEN_per_system_observed_and_physical(sssp_per_sys, sssp, n_mult_min=2, max_core_mass=10., prescription='CL2013', n=10., a0=1., p0=1., p1=-1.5, scale_up=False):\n fit_per_sys_dict = {'n_pl_true':[], 'n_pl_obs':[], 'Mp_tot_true':[], 'Mp_tot_obs':[], 'sigma0_true':[], 'sigma0_obs':[], 'scale_fac... | [
"0.54107773",
"0.53992355",
"0.5390711",
"0.5299261",
"0.5136206",
"0.5134165",
"0.5129948",
"0.5105046",
"0.5085043",
"0.5083824",
"0.50725913",
"0.5069007",
"0.504954",
"0.50494796",
"0.50400126",
"0.50268537",
"0.49904805",
"0.49638087",
"0.49399418",
"0.49384803",
"0.4933... | 0.54793423 | 0 |
Check record name. The record name must be the same as getTime() function return. | def isRecordNameValid(record):
# Split the string with the record separator ':'
splitted = record.split(':')
# There must be 5 values - year:month:day:hour:minute
if len(splitted) != 5:
# Not valid - more or less than 5 values
return False
# There are 5 values - check each one if is ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_record_name(self):\n zone = Zone('test.example.com')\n record = Record(zone, 'test-record', {'type': 'A', 'ttl': 300})\n self.assertEqual(record.name, 'test-record')",
"def check_base_filename(self, record):\n time_tuple = time.localtime()\n\n if self.file_name_format:... | [
"0.71127087",
"0.6416714",
"0.62757695",
"0.6255716",
"0.5947194",
"0.5886621",
"0.58701205",
"0.58524096",
"0.5753524",
"0.56767505",
"0.56354964",
"0.5626901",
"0.5602901",
"0.55897135",
"0.55889857",
"0.54834104",
"0.547835",
"0.54688334",
"0.54676193",
"0.54560345",
"0.54... | 0.64312017 | 1 |
Check if a record is older than value. | def olderThan(record, value=Constants.older_than):
# Check first if the record is valid
if isRecordNameValid(record):
# Get the record values and split them - year:month:day:hour:minute
splitted_record = record.split(':')
# Get the current date and time from the system and split them
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def older(self, timestamp):\r\n return self._added < timestamp",
"def match_Older(self, object, options) :\n\t\tif options.has_key(\"older\") :\n\t\t\tobjolder = self.toObject(self.__context, options[\"older\"])\n\t\t\tif objolder is not None :\n\t\t\t\tif object.bobobase_modification_time() >= objolder.b... | [
"0.71754",
"0.6400666",
"0.6392453",
"0.6271246",
"0.62259823",
"0.6223402",
"0.6223402",
"0.62114763",
"0.6195353",
"0.61886394",
"0.5976829",
"0.5961276",
"0.5923364",
"0.59210014",
"0.59175354",
"0.5868831",
"0.58493334",
"0.5846879",
"0.5807692",
"0.5804501",
"0.5777203",... | 0.79310864 | 0 |
Take the dictionary from database and return it as two lists of and . The will be a list of lists. Each region in list will have a list of records in list. | def getDataBaseLists(data, db):
# The list of regions - ex: "46 60 26 23" for region of coordinates 46.60 26.23
regions = []
# The list of lists of records - each region can have multiple records
records = []
try:
# Loop through all data in database dictionary
for reg, rec in data:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def common_blocks_records(self):\n if self.records is None:\n raise ValueError(\"\")\n records = []\n for block_name, data in self.common_blocks.items():\n cst, (start, end, strand) = data[\"locations\"][0]\n record = self.records[cst][start:end]\n i... | [
"0.5845994",
"0.5654632",
"0.55073863",
"0.5502603",
"0.5475942",
"0.54431844",
"0.54248035",
"0.5393792",
"0.53916633",
"0.52849215",
"0.52630603",
"0.52412134",
"0.5224337",
"0.5203017",
"0.51666725",
"0.5165008",
"0.5107521",
"0.50934386",
"0.506704",
"0.5066681",
"0.50605... | 0.70710075 | 0 |
Get the average weather condition from all records of a region. A region is a string (its name) representing the coordinates of it. | def calculateWeatherForEachRegion(regions, records):
if not bool(regions) or not bool(records):
return None, None
try:
weather_list = []
danger_list = []
for index in range(len(regions)):
weather, mean_weather_code = Machine_learning.getWeatherForRegion(records[index]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def region_stats(ds, mask, region_name):\n agg = ds.where(mask == arctic_mask_region[region_name]).mean(dim=['x','y'])\n if 'latitude' in agg:\n agg = agg.drop('latitude')\n if 'longitude' in agg:\n agg = agg.drop('longitude')\n return agg",
"def avg_based_on_forecast(city):\n wparam... | [
"0.6348331",
"0.6154541",
"0.6068361",
"0.59449464",
"0.5889889",
"0.5856748",
"0.5781751",
"0.5741478",
"0.56861424",
"0.5669117",
"0.56116873",
"0.55883586",
"0.55631655",
"0.5545508",
"0.53814787",
"0.5365397",
"0.5356737",
"0.5309372",
"0.5306273",
"0.5302752",
"0.5234683... | 0.618818 | 1 |
Get the index of the weather using the weather code. Weather code can be from 100 to 499. | def getWeatherIndex(code, return_if_none=Constants.return_value_index_of_weather_not_found):
# Start the index with 0
index = 0
for i in [100, 200, 300, 400]:
for j in [0, 33, 66]:
if inWeatherCodeRange(code, i + j, i + j + 33):
return index
index += 1
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_index(weather_data: dict, date: datetime) -> int:\n weather_list = weather_data['list']\n for index, weather in enumerate(weather_list):\n if weather['dt_txt'] == date.strftime('%Y-%m-%d %H:%M:%S'):\n return index\n return 0",
"def get_index(identify):\n\n ... | [
"0.66678154",
"0.62248325",
"0.61293477",
"0.59989315",
"0.5930833",
"0.58119816",
"0.57981074",
"0.57821745",
"0.5711183",
"0.5681351",
"0.5678698",
"0.5635346",
"0.56227213",
"0.5618192",
"0.561285",
"0.5601398",
"0.55593145",
"0.5548384",
"0.55290467",
"0.55117786",
"0.550... | 0.8678492 | 0 |
Check if the code is in range. | def inWeatherCodeRange(code, _min, _max):
# Example: code = 120
# _min = 0 _max = 133
# return 0 <= 120 <= 133 => true
return _min <= code <= _max | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def icd9_in_code_range(val, code_ranges):\n return any(val <= code_range[1] and val >= code_range[0] for code_range in code_ranges)",
"def isRangeValid(self) -> bool:\n ...",
"def IsInRange(self, id, start, isStartInclusive, end, isEndInclusive):\r\n if isStartInclusive == False:\r\n ... | [
"0.7484409",
"0.7367147",
"0.7140791",
"0.70511144",
"0.70411056",
"0.6920733",
"0.68506825",
"0.6842587",
"0.6837561",
"0.68176687",
"0.6816321",
"0.68019915",
"0.676852",
"0.6762765",
"0.6742773",
"0.6739405",
"0.67343843",
"0.66643924",
"0.6628126",
"0.6624612",
"0.6607039... | 0.7409259 | 1 |
Returns the weather string (name) from the file using the index of the weather. The weather titles are wrote in a dictionary, where the keys are the index. | def getWeatherString(index):
return Texts.weather_titles[index] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_index(index_file):\n index_dict = {}\n with open(index_file) as f:\n for line in f:\n title, path = line.strip().split()\n index_dict[title] = path\n return index_dict",
"def read_weatherstationnames(path_to_data):\n\n nr, name = np.loadtxt(os.path.join(path_to_d... | [
"0.58560216",
"0.57427657",
"0.5587316",
"0.54862076",
"0.5465274",
"0.53827",
"0.53461164",
"0.53260946",
"0.5280319",
"0.5268441",
"0.5262383",
"0.5219673",
"0.521099",
"0.51767963",
"0.51703185",
"0.51631576",
"0.5161624",
"0.51347274",
"0.5134441",
"0.5131381",
"0.5129603... | 0.7401113 | 0 |
Get box regression transformation deltas (dx, dy, dw, dh) that can be used to transform the `src_boxes` into the `target_boxes`. That is, the relation ``target_boxes == self.apply_deltas(deltas, src_boxes)`` is true (unless any delta is too large and is clamped). | def get_deltas(self, src_boxes, target_boxes):
assert isinstance(src_boxes, torch.Tensor), type(src_boxes)
assert isinstance(target_boxes, torch.Tensor), type(target_boxes)
TO_REMOVE = 1 # TODO remove
src_widths = src_boxes[:, 2] - src_boxes[:, 0] + TO_REMOVE
src_heights ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_deltas(self, deltas, boxes):\r\n assert torch.isfinite(deltas).all().item(), \"Box regression deltas become infinite or NaN!\"\r\n boxes = boxes.to(deltas.dtype)\r\n\r\n TO_REMOVE = 1 # TODO remove\r\n widths = boxes[:, 2] - boxes[:, 0] + TO_REMOVE\r\n heights = boxes[... | [
"0.699108",
"0.6511962",
"0.645136",
"0.6319423",
"0.6214895",
"0.6214895",
"0.61235464",
"0.60987717",
"0.56899726",
"0.55584025",
"0.55373454",
"0.54795",
"0.54542905",
"0.54477835",
"0.5432317",
"0.54260546",
"0.537766",
"0.5244466",
"0.523219",
"0.5218577",
"0.51628095",
... | 0.84701025 | 0 |
Reconstruct file sequence of objects from index, sorted by absolute position | def inspect(filename):
bfile = open(filename, 'rb')
bdata = bfile.read()
bfile.close()
doc = loads(bdata)
file_seq = []
second = None
for ver, snapshot in enumerate(doc.index):
nb_obj = len(snapshot)
cache = nb_obj * [None]
mini_index = nb_obj * [None]
for i i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indexed(filename):\n\n with tempfile.NamedTemporaryFile() as tmp:\n with gzip.open(filename, \"r\") as raw:\n SeqIO.write(corrected_records(raw), tmp, \"fasta\")\n\n tmp.flush()\n yield SeqIO.index(tmp.name, \"fasta\")",
"def sort_index(self):\n def s(t):\n ... | [
"0.5764997",
"0.572877",
"0.56066453",
"0.5589324",
"0.55742806",
"0.54208404",
"0.54207265",
"0.5403319",
"0.53931236",
"0.5381334",
"0.5358659",
"0.53422064",
"0.5331138",
"0.5320528",
"0.528979",
"0.52894425",
"0.52819306",
"0.5266695",
"0.5228879",
"0.5205095",
"0.5189061... | 0.60294557 | 0 |
Set up babybuddy select entities for feeding and diaper change. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
async_add_entities([BabyBuddySelect(entity) for entity in SELECTOR_TYPES]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick_up(self):",
"def __init__(self, entity_description: BabyBuddySelectDescription) -> None:\n self._attr_unique_id = entity_description.key\n self._attr_options = entity_description.options\n self.entity_description = entity_description\n self._attr_current_option = None",
"de... | [
"0.5553327",
"0.5431278",
"0.533167",
"0.532243",
"0.5231893",
"0.51908284",
"0.51467603",
"0.5063082",
"0.5009682",
"0.49979505",
"0.49765864",
"0.49712533",
"0.49513426",
"0.49345365",
"0.49092245",
"0.48547655",
"0.48247764",
"0.48069692",
"0.47705767",
"0.47544596",
"0.47... | 0.65842026 | 0 |
Initialize the Babybuddy select entity. | def __init__(self, entity_description: BabyBuddySelectDescription) -> None:
self._attr_unique_id = entity_description.key
self._attr_options = entity_description.options
self.entity_description = entity_description
self._attr_current_option = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args, **kwargs):\n super(ChoiceFieldType, self).__init__(*args, **kwargs)\n\n self.choices = self.get_field_info_key('choices')",
"def init(self):\n # IMPORTANT: create a new gob database model entry for this object\n self.gobify()",
"def initialize(self):\n\n ... | [
"0.6092637",
"0.60616356",
"0.58840305",
"0.5762157",
"0.57082224",
"0.56701213",
"0.5660541",
"0.5595342",
"0.55679876",
"0.55628157",
"0.5492031",
"0.54903996",
"0.54903996",
"0.54903996",
"0.54903996",
"0.54903996",
"0.54903996",
"0.54903996",
"0.54903996",
"0.54722273",
"... | 0.7361549 | 0 |
Your extreme ghosthunting, pelletnabbing, foodgobbling, unstoppable evaluation function (question 5). | def betterEvaluationFunction(currentGameState):
"*** YOUR CODE HERE ***"
pos = currentGameState.getPacmanPosition()
score1 = currentGameState.getScore()
Food = currentGameState.getFood()
foodlist = list(Food.asList())
dist = []
score2 = 0
if len(foodlist) != 0:
for food in foodlist:
dist.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def betterEvaluationFunction(currentGameState):\n \"*** YOUR CODE HERE ***\"\n next_pacman_position = currentGameState.getPacmanPosition()\n next_food = [food for food in currentGameState.getFood().asList() if food]\n next_ghosts_states = currentGameState.getGhostStates()\n next_ghosts_scared_timers... | [
"0.73445916",
"0.7206647",
"0.7201176",
"0.7178031",
"0.71601456",
"0.71585554",
"0.7139828",
"0.71391654",
"0.71090144",
"0.7050158",
"0.70279783",
"0.7020684",
"0.70147085",
"0.69905776",
"0.69860834",
"0.6977059",
"0.6974314",
"0.69628817",
"0.6937865",
"0.6931714",
"0.692... | 0.72288746 | 1 |
Returns the timezone as an hour/minute offset in the form "+HHMM" or "HHMM". | def _format_timezone_offset(converted_time):
# Windows treats %z in the format string as %Z, so we compute the hour/minute offset
# manually.
if converted_time.tm_isdst == 1 and time.daylight:
utc_offset_secs = time.altzone
else:
utc_offset_secs = time.timezone
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_timezone_offset():\n timezone = get_localzone()\n offset_minutes = timezone.utcoffset(datetime.datetime.now()).total_seconds() // SECONDS_IN_MINUTE\n return parse_int(offset_minutes)",
"def get_fixed_timezone(offset):\n if isinstance(offset, timedelta):\n offset = offset.total_seconds(... | [
"0.7235955",
"0.67034847",
"0.6700693",
"0.66685057",
"0.6638393",
"0.66248596",
"0.6586953",
"0.6572008",
"0.65655357",
"0.64952195",
"0.64378357",
"0.6383715",
"0.6347221",
"0.63229084",
"0.6319341",
"0.62767327",
"0.62652457",
"0.6222787",
"0.62033075",
"0.61946964",
"0.61... | 0.71226084 | 1 |
Returns the executable path of a py_binary. This returns the executable path of a py_binary that is in another Bazel target's data dependencies. On Linux/macOS, the path and __file__ has the same root directory. On Windows, bazel builds an .exe file and we need to use the MANIFEST file the location the actual binary. | def get_executable_path(py_binary_name):
if os.name == 'nt':
py_binary_name += '.exe'
manifest_file = os.path.join(FLAGS.test_srcdir, 'MANIFEST')
workspace_name = os.environ['TEST_WORKSPACE']
manifest_entry = '{}/{}'.format(workspace_name, py_binary_name)
with open(manifest_file, 'r') as manifest... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_exec_path(self):\n bin_name = 'test_hint_time'\n # Look for in place build\n script_dir = os.path.dirname(os.path.realpath(__file__))\n bin_path = os.path.join(script_dir, '.libs', bin_name)\n if not os.path.exists(bin_path):\n # Look for out of place build fro... | [
"0.70611286",
"0.69784385",
"0.67366946",
"0.6704762",
"0.6694283",
"0.6644212",
"0.66146284",
"0.65615684",
"0.6532665",
"0.6474591",
"0.6446678",
"0.6406514",
"0.6392812",
"0.6340146",
"0.632116",
"0.6318753",
"0.6304325",
"0.6299277",
"0.62937576",
"0.62814784",
"0.628113"... | 0.80735695 | 0 |
output thread function for getting inference results from Movidius NCS running graph specific post processing of inference result queuing the results for main thread callbacks | def output_thread():
global gRunning
try:
while gRunning:
try:
inference_result, user_data = gGraph.GetResult()
print (postprocess(inference_result))
#print(user_data)
# gUpdateq.put((postprocess(inference_result), user_data))
except KeyError:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inference(self):\n for i in range(len(self.nodes)):\n for j in range(len(self.nodes[i])):\n self.pipes[i][j].send(\"inference\")\n \n ## wait for the finalization to be completed\n for i in range(len(self.nodes)):\n for j in range(len(sel... | [
"0.7058547",
"0.6675076",
"0.63437945",
"0.61934835",
"0.60070735",
"0.59801656",
"0.59527904",
"0.59318507",
"0.59288776",
"0.5920665",
"0.5890297",
"0.5875667",
"0.58533645",
"0.58358604",
"0.5832103",
"0.5815753",
"0.58027357",
"0.5774473",
"0.5759439",
"0.57552284",
"0.57... | 0.75303006 | 0 |
Purge the queue of all of its messages. | def purge(self):
self._rpc(specification.Queue.Purge()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clearQueueAll():",
"def clear_queue(self):\n while not self.queue.empty():\n self.queue.get()",
"def clear_queue(self):\n\t\t\tself.message_queue.clear()\n\t\t\treturn self.message_queue",
"def clear_messages(self):\n self.redis_client.delete(self.message_list)",
"def flush_msg... | [
"0.7505619",
"0.72489685",
"0.7197505",
"0.7081021",
"0.70500505",
"0.7026544",
"0.6947277",
"0.692343",
"0.69218075",
"0.68953866",
"0.6863806",
"0.6734934",
"0.66792786",
"0.66656256",
"0.6581635",
"0.6553705",
"0.65511155",
"0.6539296",
"0.65362954",
"0.65359545",
"0.65193... | 0.8184247 | 0 |
Unbind queue from the specified exchange where it is bound the routing key. If routing key is None, use the queue name. | def unbind(self, source, routing_key=None):
if hasattr(source, 'name'):
source = source.name
self._rpc(specification.Queue.Bind(queue=self.name,
exchange=source,
routing_key=routing_key or
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def bind(\n self,\n exchange: ExchangeParamType,\n routing_key: Optional[str] = None,\n *,\n arguments: Arguments = None,\n timeout: TimeoutType = None,\n ) -> aiormq.spec.Queue.BindOk:\n\n if routing_key is None:\n routing_key = self.name\n\n ... | [
"0.5841196",
"0.5779545",
"0.5448614",
"0.5320331",
"0.52993155",
"0.5290274",
"0.51541996",
"0.51409155",
"0.5094225",
"0.4963937",
"0.49457547",
"0.4868611",
"0.48207507",
"0.48195007",
"0.48154044",
"0.48097736",
"0.4786163",
"0.47184947",
"0.47171628",
"0.47167245",
"0.46... | 0.77533823 | 0 |
Return a specification.Queue.Declare class precomposed for the rpc method since this can be called multiple times. | def _declare(self, passive=False):
arguments = dict(self._arguments)
if self._expires:
arguments['x-expires'] = self._expires
if self._message_ttl:
arguments['x-message-ttl'] = self._message_ttl
if self._max_length:
arguments['x-max-length'] = self._ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def declare(self) -> 'Queue':\n # we are relying to this in other functions\n self._channel = await self._backend.channel()\n self.log.debug(\"Channel acquired CHANNEL%i\",\n self._channel.channel_number)\n\n if self.exchange:\n await self.declare_... | [
"0.67236507",
"0.66197556",
"0.64929247",
"0.6260047",
"0.6201118",
"0.5973525",
"0.59200746",
"0.5897509",
"0.5897299",
"0.5760605",
"0.5723684",
"0.57159436",
"0.57159436",
"0.57159436",
"0.57159436",
"0.57159436",
"0.57159436",
"0.57159436",
"0.57159436",
"0.57159436",
"0.... | 0.6956101 | 0 |
Retrieve the nest message from the queue as an iterator, blocking until the next message is available. | def next_message(self):
while self.queue.consuming:
yield self.queue.channel._consume_message() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next(self): # wait for 5 minutes after sending message\n if self.queue:\n messages = self.queue.get_messages(1,visibility_timeout=self.visibility_timeout)\n if messages:\n for m in messages:\n return m\n raise StopIteration",
"def read(sel... | [
"0.7556442",
"0.7009815",
"0.6816463",
"0.674572",
"0.6724379",
"0.66346157",
"0.660066",
"0.64881974",
"0.63246495",
"0.63130015",
"0.62896055",
"0.6209126",
"0.6189926",
"0.61867803",
"0.60752857",
"0.60651827",
"0.6057777",
"0.6036472",
"0.5981971",
"0.59722316",
"0.596316... | 0.7156374 | 1 |
This method receives the neighbours of the test data and takes a tally of the votes and makes a decision. The decision is based on the label with the highest count. | def count_votes(self, neighbours=()):
labels = []
data = neighbours
# create the list made up of labels.
for x in range(len(data)):
labels.append(data[x][-1])
# count the appearance of labels.
count = [[x, labels.count(x)] for x in set(labels)]
# Sort... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _vote(self, neighbor_labels):\n counts= torch.bincount(neighbor_labels.int())\n return torch.argmax(counts)",
"def _tally_votes(self, labels, distances):\n votes = collections.defaultdict(int)\n for i, index in enumerate(distances.order(ascending=True).index):\n if i < ... | [
"0.7076513",
"0.6492986",
"0.63586086",
"0.6339451",
"0.62436193",
"0.61596376",
"0.6038543",
"0.598995",
"0.59895474",
"0.5984259",
"0.5975959",
"0.5975312",
"0.5897305",
"0.58957624",
"0.58957624",
"0.58913827",
"0.5873205",
"0.5868879",
"0.5822922",
"0.5816393",
"0.5770653... | 0.7605235 | 0 |
Handles the HTTPS POST request. It was copied out from SimpleXMLRPCServer.py and modified to shutdown the socket cleanly. | def do_POST(self):
try:
# get arguments
data = self.rfile.read(int(self.headers["content-length"]))
# In previous versions of SimpleXMLRPCServer, _dispatch
# could be overridden in this class, instead of in
# SimpleXMLRPCDispatcher. To maintain backw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_POST(self):\r\n SimpleXMLRPCRequestHandler.do_POST(self)\r\n try:\r\n # shut down the connection\r\n self.connection.shutdown()\r\n except:\r\n pass",
"def do_POST(self):\n\n try:\n # get arguments\n data = self.rfile.read(... | [
"0.7406314",
"0.67461973",
"0.64566195",
"0.63029206",
"0.6072018",
"0.6066601",
"0.6046328",
"0.5997497",
"0.59290093",
"0.58769035",
"0.58373576",
"0.57971627",
"0.573956",
"0.57225776",
"0.5698153",
"0.5666174",
"0.563702",
"0.56157655",
"0.5584676",
"0.55648243",
"0.55317... | 0.72129786 | 1 |
Return the contents of file f_relative_path as a string, or a list of strings if read_lines is True. | def read(f_relative_path: str) -> str:
here = path.dirname(path.abspath(__file__))
with io.open(path.join(here, f_relative_path), mode="rt", encoding="utf8") as f:
return f.read() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_txt_file(relative_path_to_txt_file: str):\n with open(file=relative_path_to_txt_file) as f:\n lines = f.read()\n return lines",
"def read(rel_path):\n here = os.path.abspath(os.path.dirname(__file__))\n with open(os.path.join(here, rel_path), \"r\") as fp:\n return ... | [
"0.70846015",
"0.6535189",
"0.6128279",
"0.6120097",
"0.60881114",
"0.60569876",
"0.60376364",
"0.60376364",
"0.6030412",
"0.6026531",
"0.60046923",
"0.5990986",
"0.59522074",
"0.5950833",
"0.5945287",
"0.5945108",
"0.59425455",
"0.5916451",
"0.5888799",
"0.58768487",
"0.5855... | 0.7501114 | 0 |
Given a document, compute a sourcespecific id for the job posting. To be implemented by subclasses | def _id(self, document):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resourceDocumentId(self, resource: Resource) -> str:",
"def getDocumentId(self): #$NON-NLS-1$\r",
"def doc_id(self):\n return self._id",
"def get_doc_id(self):\n return self.__doc_id",
"def source_id(self) -> str:\n return self._source_id",
"def source_id(self) -> str:\n r... | [
"0.6282072",
"0.60269284",
"0.5852061",
"0.5735901",
"0.5694973",
"0.5694973",
"0.5641792",
"0.5626624",
"0.562359",
"0.56151587",
"0.56097937",
"0.55504596",
"0.5522015",
"0.5411822",
"0.5347779",
"0.5347779",
"0.5342647",
"0.5319721",
"0.5319721",
"0.52834874",
"0.52826506"... | 0.694908 | 0 |
Given a quarter, yield all relevant raw job posting documents. To be implemented by subclasses | def _iter_postings(self, quarter):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postings(self, quarter, stats_counter=None):\n logging.info('Finding postings for %s', quarter)\n for posting in self._iter_postings(quarter):\n transformed = self._transform(posting)\n transformed['id'] = '{}_{}'.format(\n self.partner_id,\n se... | [
"0.73558885",
"0.51440305",
"0.5119742",
"0.49251112",
"0.48970717",
"0.48621002",
"0.48428088",
"0.47837812",
"0.4715076",
"0.47008112",
"0.4682589",
"0.46730265",
"0.46716323",
"0.46703556",
"0.46643853",
"0.4660238",
"0.4606574",
"0.46021757",
"0.45960665",
"0.45927292",
"... | 0.72257715 | 1 |
Look up the numerical gate representation and a proposed 'noisy' name. | def get_modified_noisy_gate(gate_name: str, params: Iterable[ParameterDesignator]) -> Tuple[np.ndarray, str]:
params = tuple(params)
if gate_name == "I":
assert params == ()
return np.eye(2), "NOISY-I"
if gate_name == "RX":
angle, = params
if np.isclose(angle, np.pi / 2, atol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_nonphylogenetic_metric(name):\r\n # looks for name, inserting possible dist_ to find functions\r\n # in distance_transform.py named e.g.:\r\n # binary_dist_chisq / dist_bray_curtis\r\n try:\r\n return getattr(distance_transform, 'dist_' + name.lower())\r\n except AttributeError:\r\n ... | [
"0.6031811",
"0.6019712",
"0.5505304",
"0.5480643",
"0.5449328",
"0.53937733",
"0.53687114",
"0.53385764",
"0.5300645",
"0.5300645",
"0.5279134",
"0.52615255",
"0.5232032",
"0.5215277",
"0.51930237",
"0.515612",
"0.51222146",
"0.50935143",
"0.5086529",
"0.5076165",
"0.5069962... | 0.6819791 | 0 |
The default noise parameters T1 = 30 us T2 = 30 us 1q gate time = 50 ns 2q gate time = 150 ns are currently typical for nearterm devices. This function will define new gates and add Kraus noise to these gates. It will translate the input program to use the noisy version of the gates. | def _modified_decoherence_noise_model(
gates: Sequence[Gate],
T1: Union[Dict[int, float], float] = 30e-6,
T2: Union[Dict[int, float], float] = 30e-6,
gate_time_1q: float = 50e-9,
gate_time_2q: float = 150e-09,
ro_fidelity: Union[Dict[int, float], float] = 0.95,
) -> NoiseModel:
all_qubits = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_modified_decoherence_noise(\n prog: \"Program\",\n T1: Union[Dict[int, float], float] = 30e-6,\n T2: Union[Dict[int, float], float] = 30e-6,\n gate_time_1q: float = 50e-9,\n gate_time_2q: float = 150e-09,\n ro_fidelity: Union[Dict[int, float], float] = 0.95,\n) -> \"Program\":\n gates ... | [
"0.6628927",
"0.58579427",
"0.5831026",
"0.56987023",
"0.55713624",
"0.5551751",
"0.5513629",
"0.54612297",
"0.5435982",
"0.53606707",
"0.53522336",
"0.53512543",
"0.5348637",
"0.5332393",
"0.53229153",
"0.52960086",
"0.5282946",
"0.52718014",
"0.52508575",
"0.5249883",
"0.52... | 0.7118521 | 0 |
Generate the header for a pyquil Program that uses ``noise_model`` to overload noisy gates. | def _modified_noise_model_program_header(noise_model: NoiseModel) -> "Program":
from pyquil.quil import Program
p = Program()
defgates: Set[str] = set()
for k in noise_model.gates:
# obtain ideal gate matrix and new, noisy name by looking it up in the NOISY_GATES dict
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_model_header(env: jinja2.environment.Environment, model: onnx.ModelProto) -> str:\n header_template = env.get_template(\"model_header.dml.jinja\")\n header_infos = dict()\n\n header_infos[\"ir_version\"] = model.ir_version\n opset_import = list()\n for opset in model.opset_import:\n i... | [
"0.6443",
"0.60880536",
"0.5795828",
"0.56925726",
"0.56897265",
"0.56873477",
"0.5668974",
"0.5653915",
"0.5571958",
"0.5570082",
"0.55554986",
"0.55474067",
"0.55420685",
"0.5530725",
"0.550911",
"0.54856914",
"0.5472454",
"0.5466979",
"0.5424813",
"0.5413869",
"0.54122144"... | 0.79720664 | 0 |
Apply a noise model to a program and generated a 'noisyfied' version of the program. | def apply_modified_noise_model(prog: "Program", noise_model: NoiseModel) -> "Program":
new_prog = _modified_noise_model_program_header(noise_model)
for i in prog:
if isinstance(i, Gate) and noise_model.gates:
try:
_, new_name = get_modified_noisy_gate(i.name, tuple(i.params))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _modified_noise_model_program_header(noise_model: NoiseModel) -> \"Program\":\n from pyquil.quil import Program\n\n p = Program()\n defgates: Set[str] = set()\n for k in noise_model.gates:\n\n # obtain ideal gate matrix and new, noisy name by looking it up in the NOISY_GATES dict\n tr... | [
"0.71081764",
"0.6942209",
"0.67204815",
"0.65276885",
"0.6525033",
"0.6456866",
"0.63153213",
"0.6242626",
"0.6212918",
"0.61854535",
"0.6173296",
"0.61590374",
"0.6148146",
"0.61058336",
"0.60990524",
"0.6093618",
"0.6059789",
"0.6057936",
"0.6054125",
"0.6036168",
"0.60214... | 0.73493963 | 0 |
Add generic damping and dephasing noise to a program. This highlevel function is provided as a convenience to investigate the effects of a generic noise model on a program. For more finegrained control, please investigate the other methods available in the ``pyquil.noise`` module. In an attempt to closely model the QPU... | def add_modified_decoherence_noise(
prog: "Program",
T1: Union[Dict[int, float], float] = 30e-6,
T2: Union[Dict[int, float], float] = 30e-6,
gate_time_1q: float = 50e-9,
gate_time_2q: float = 150e-09,
ro_fidelity: Union[Dict[int, float], float] = 0.95,
) -> "Program":
gates = _get_program_ga... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _modified_decoherence_noise_model(\n gates: Sequence[Gate],\n T1: Union[Dict[int, float], float] = 30e-6,\n T2: Union[Dict[int, float], float] = 30e-6,\n gate_time_1q: float = 50e-9,\n gate_time_2q: float = 150e-09,\n ro_fidelity: Union[Dict[int, float], float] = 0.95,\n) -> NoiseModel:\n ... | [
"0.6818638",
"0.61347294",
"0.6079218",
"0.58847916",
"0.58088034",
"0.57671183",
"0.5764723",
"0.5756611",
"0.5714665",
"0.5685358",
"0.56427485",
"0.561027",
"0.56034786",
"0.5563276",
"0.5559172",
"0.5557005",
"0.5536149",
"0.5534381",
"0.5500958",
"0.5471309",
"0.54573405... | 0.70419616 | 0 |
Give the zerobased index of first occurrence of object in queryset. Return 1 if not found | def index(queryset, obj):
for index, item in enumerate(queryset):
if item == obj:
return index
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_index(self, obj):\n return self.model.indexlist[obj]",
"def _get_first_occurrence_for(iterable, wanted_object):\n for i, value in enumerate(iterable):\n if value is wanted_object:\n return i",
"def _findIndex(self, x):\n if x< self[0][0] or x> self[-1][0]:\n return ... | [
"0.66508794",
"0.66319877",
"0.6196297",
"0.60581875",
"0.60506517",
"0.60432094",
"0.5979738",
"0.5903687",
"0.5892405",
"0.5842994",
"0.58137876",
"0.5810193",
"0.57849294",
"0.5744563",
"0.57441866",
"0.5736628",
"0.57161486",
"0.56848454",
"0.5655904",
"0.56100047",
"0.56... | 0.77490765 | 0 |
Test converting color text codes to integer trios. | def test_color_str_to_trio(self):
for case in self.__class__.TEXTS:
with self.subTest(case=case):
self.assertEqual(colors.color_str_to_trio(case[0]), case[1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_toInt(self):\r\n self.assertEqual(self.black.toInt(), 0)\r\n self.assertEqual(self.red.toInt(), 16711680)\r\n self.assertEqual(self.pink.toInt(), 6553600)",
"def test_color_trio_to_str(self):\n for case in self.__class__.TRIOS:\n with self.subTest(case=case):\n ... | [
"0.68440133",
"0.668924",
"0.63109994",
"0.6197401",
"0.61614543",
"0.61015356",
"0.6036581",
"0.6017181",
"0.6007153",
"0.5982131",
"0.5978146",
"0.5911295",
"0.58729845",
"0.58344436",
"0.5826692",
"0.5734345",
"0.57341844",
"0.5688235",
"0.56828016",
"0.564937",
"0.5624364... | 0.7008089 | 0 |
Test converting integer trios to color text codes. | def test_color_trio_to_str(self):
for case in self.__class__.TRIOS:
with self.subTest(case=case):
self.assertEqual(colors.color_trio_to_str(case[0]), case[1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_color_str_to_trio(self):\n for case in self.__class__.TEXTS:\n with self.subTest(case=case):\n self.assertEqual(colors.color_str_to_trio(case[0]), case[1])",
"def test_toInt(self):\r\n self.assertEqual(self.black.toInt(), 0)\r\n self.assertEqual(self.red.to... | [
"0.69274575",
"0.6589749",
"0.63529044",
"0.63369346",
"0.62156",
"0.61823004",
"0.6172301",
"0.61215353",
"0.6078759",
"0.6035878",
"0.6024409",
"0.59644485",
"0.5952612",
"0.59047055",
"0.5881229",
"0.58397704",
"0.58161825",
"0.5805346",
"0.5793865",
"0.5763105",
"0.576165... | 0.69545627 | 0 |
Return random coordinate for an object rounded to accuracy of delta (float). | def RandomCoordinate():
return ReturnRounded(np.random.uniform(-10,10)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __randomize_coord((ref_x, ref_y)):\n radius = numpy.random.normal(scale=DataGen.stdev_distance)\n angle = random.uniform(0, 2 * math.pi)\n rand_x = ref_x + radius * math.cos(angle)\n rand_y = ref_y + radius * math.sin(angle)\n return rand_x, rand_y",
"def randomize_position... | [
"0.6204",
"0.60160416",
"0.59795004",
"0.5935111",
"0.5867318",
"0.5796637",
"0.5642895",
"0.5557663",
"0.5556598",
"0.5540177",
"0.55266476",
"0.55259424",
"0.5512448",
"0.5476977",
"0.54743147",
"0.54636455",
"0.5447325",
"0.54414725",
"0.5432466",
"0.5425684",
"0.5400466",... | 0.69313 | 0 |
Return F_att for point q, from finish_point q_k | def AttractionForce(q,q_k):
return k_p*CalculateDistance(q,q_k) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigma_xx_to_a_to_ff(self, Q, f):\n if f == \"e\":\n mf = me\n # gall = self.gaee\n elif f == \"mu\":\n mf = mmu\n # gall = self.gamumu\n mx = self.mx\n if Q >= 2.0 * mf and Q >= 2.0 * mx:\n # gaxx = self.gaxx\n # ma =... | [
"0.5644244",
"0.53550917",
"0.5309267",
"0.5231378",
"0.5200815",
"0.5191348",
"0.5150725",
"0.4982281",
"0.4951254",
"0.4942593",
"0.4912569",
"0.4855299",
"0.48428315",
"0.4836259",
"0.483546",
"0.48336896",
"0.48231852",
"0.48079002",
"0.47921115",
"0.47866088",
"0.4777043... | 0.6347686 | 0 |
Return repulsion force on point q, from obstacle q_oi | def RepulsionForceFromObstacle(q,q_oi):
d_i = CalculateDistance(q,q_oi) # Distance to the obstacle
if (d_i < d_0): # Point within obstacle influence
F_oi = k_o * (1/d_i - 1/d_0) /d_i**2
if (F_oi > F_rep_MaxValue): # F_rep won't exceed set constant
return F_rep_MaxVal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RepulsionForcesInAPoint(q,ObstVector):\r\n F_rep = 0\r\n for q_oi in ObstVector: # For each obstacle...\r\n F_rep += RepulsionForceFromObstacle(q,q_oi) #... add its repulsion to net F_rep\r\n return F_rep",
"def ban_Force(q):\n \n x = q[0]\n y = q[1]\n dx =... | [
"0.67056006",
"0.66570973",
"0.6394435",
"0.6346173",
"0.61297435",
"0.6093138",
"0.6078021",
"0.5982097",
"0.5887824",
"0.58862346",
"0.5841583",
"0.5840448",
"0.5832472",
"0.5810463",
"0.5783585",
"0.57715243",
"0.57642233",
"0.5764123",
"0.5747722",
"0.57469237",
"0.570358... | 0.8176501 | 0 |
Return net repulsion force acting on a point q, based on a list of obstacles ObstVector | def RepulsionForcesInAPoint(q,ObstVector):
F_rep = 0
for q_oi in ObstVector: # For each obstacle...
F_rep += RepulsionForceFromObstacle(q,q_oi) #... add its repulsion to net F_rep
return F_rep | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RepulsionForceFromObstacle(q,q_oi):\r\n d_i = CalculateDistance(q,q_oi) # Distance to the obstacle\r\n if (d_i < d_0): # Point within obstacle influence\r\n F_oi = k_o * (1/d_i - 1/d_0) /d_i**2 \r\n if (F_oi > F_rep_MaxValue): # F_rep won't exceed set constant\r\n retu... | [
"0.61033577",
"0.59260166",
"0.58975464",
"0.5893999",
"0.58747244",
"0.57450384",
"0.5693517",
"0.55875623",
"0.5544491",
"0.5539944",
"0.55349374",
"0.55225456",
"0.5517202",
"0.5507373",
"0.5500563",
"0.54926264",
"0.54701596",
"0.5453624",
"0.5442819",
"0.5395531",
"0.536... | 0.7295841 | 0 |
Endpoint processes a post request from the form to get the weather for the specified city | async def city_weather(request: web.Request):
data = await request.post()
current_city = data["city"]
return await collect_info(request, city=current_city) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, city: str):\n # Make a call to the OpenWeatherMap API and check the units inserted at the query parameter.\n units = request.args.get('unit', '').casefold()\n weather_data, query_units = self.get_weather(city, units)\n temp = self.check_unit(query_units)\n\n # Get t... | [
"0.72298294",
"0.67077965",
"0.6676318",
"0.6553933",
"0.6520883",
"0.6472788",
"0.64574057",
"0.6442259",
"0.6378601",
"0.62982494",
"0.62931186",
"0.6264356",
"0.6211222",
"0.6193483",
"0.613255",
"0.61181283",
"0.61084616",
"0.60750145",
"0.60643506",
"0.60150003",
"0.5989... | 0.78677696 | 0 |
Function sends a request to obtain information about the weather in current city and returns a data dictionary or False | async def weather(url, session, city):
params = {"q": city, "lang": "ru", "units": "metric", "mode": "json"}
headers = {
'x-rapidapi-key': API_KEY,
'x-rapidapi-host': "community-open-weather-map.p.rapidapi.com"
}
response = await session.get(url, params=params, headers=headers)
if re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def city_weather(request: web.Request):\n data = await request.post()\n current_city = data[\"city\"]\n return await collect_info(request, city=current_city)",
"def get(self, city: str):\n # Make a call to the OpenWeatherMap API and check the units inserted at the query parameter.\n ... | [
"0.78325963",
"0.75393945",
"0.73343176",
"0.7309696",
"0.7283628",
"0.7208504",
"0.7185058",
"0.7183764",
"0.7180932",
"0.71728384",
"0.70717156",
"0.7044659",
"0.70226324",
"0.7012848",
"0.69257617",
"0.68630844",
"0.6844851",
"0.68423885",
"0.68418497",
"0.67672926",
"0.67... | 0.7699957 | 1 |
This function creates a partial function for sampling random clients. | def randomly_select_clients_for_round(
population: int, num_of_clients: int, replace: bool = False, seed: int = None
) -> functools.partial:
def select(round_number, seed, replace):
return np.random.RandomState().choice(
population, num_of_clients, replace=replace
)
return func... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_client_dataset_fn(\n dataset: tf.data.Dataset,\n number_of_clients_per_round: int,\n seed: int = None,\n) -> Callable[[], tf.data.Dataset]:\n sample_clients = randomly_select_clients_for_round(\n dataset.client_ids,\n num_of_clients=number_of_clients_per_round,\n replace=Fa... | [
"0.6248188",
"0.57352465",
"0.56887686",
"0.5630404",
"0.5566855",
"0.55375606",
"0.5520642",
"0.5461235",
"0.54593724",
"0.5446919",
"0.54420066",
"0.54274714",
"0.5406328",
"0.5400366",
"0.5398023",
"0.5383204",
"0.53441745",
"0.53429705",
"0.5331215",
"0.5330419",
"0.53158... | 0.6496539 | 0 |
This function generates a function for selecting clientdatasets for each round number. | def get_client_dataset_fn(
dataset: tf.data.Dataset,
number_of_clients_per_round: int,
seed: int = None,
) -> Callable[[], tf.data.Dataset]:
sample_clients = randomly_select_clients_for_round(
dataset.client_ids,
num_of_clients=number_of_clients_per_round,
replace=False,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_client_fn(dataset_partitions):\n\n def client_fn(cid: str) -> fl.client.Client:\n \"\"\"Construct a FlowerClient with its own dataset partition.\"\"\"\n\n # Extract partition for client with id = cid\n x_train, y_train = dataset_partitions[int(cid)]\n # Use 10% of the client'... | [
"0.57062846",
"0.5575745",
"0.54757863",
"0.5445093",
"0.5359454",
"0.5346562",
"0.5344329",
"0.5338417",
"0.5323915",
"0.5321573",
"0.5308771",
"0.52902603",
"0.52606547",
"0.5251963",
"0.5250017",
"0.5224285",
"0.51744944",
"0.51469755",
"0.51442826",
"0.51338434",
"0.51288... | 0.71754587 | 0 |
Returns the casing of a word | def get_casing(word):
if len(word) == 0:
return "other"
elif word.isdigit(): # Is a digit
return "numeric"
elif word.islower(): # All lower case
return "allLower"
elif word.isupper(): # All upper case
return "allUpper"
# is a tit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCasing(word):\n casing = 'other'\n \n numDigits = 0\n for char in word:\n if char.isdigit():\n numDigits += 1\n \n digitFraction = numDigits / float(len(word))\n \n if word.isdigit(): #Is a digit\n casing = 'numeric'\n elif digitFraction > 0.5:\n ... | [
"0.77150095",
"0.7627981",
"0.75995153",
"0.7345379",
"0.70581454",
"0.70581454",
"0.70366627",
"0.70266676",
"0.6998077",
"0.6934372",
"0.68606347",
"0.68557906",
"0.68520325",
"0.6814516",
"0.680668",
"0.67812794",
"0.678011",
"0.67116076",
"0.67093617",
"0.67058736",
"0.66... | 0.8539075 | 0 |
Checks the sanity of the sentence. If the sentence is for example all uppercase, it is rejected | def check_sentence_sanity(self, sentence):
case_dist = nltk.FreqDist()
for token in sentence:
case_dist[self.get_casing(token)] += 1
if case_dist.most_common(1)[0][0] != "allLower":
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_sentence_input(self, sentence):\n if len(sentence.strip()) == 0:\n return False\n # Decode unicode, mainly to normalize fancy quotation marks\n decoded = unidecode(sentence)\n # Sentence shouldn't contain problematic characters\n if self.well_formed and self.r... | [
"0.72757673",
"0.6896224",
"0.66803765",
"0.6666935",
"0.6642678",
"0.65529424",
"0.65316814",
"0.6467364",
"0.64504784",
"0.64176303",
"0.6370217",
"0.63567257",
"0.6353151",
"0.6348308",
"0.6311175",
"0.62783295",
"0.6248707",
"0.6111707",
"0.61105114",
"0.6082513",
"0.6035... | 0.75520724 | 0 |
return a logger that prints to the screen if it's interactive and a file if not | def get_logger(name='some script'):
#timestamp for filename
timestamp = datetime.now().strftime('%Y-%m-%d')
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
#custom formatter
formatter = logging.Formatter(
'%(asctime)s %(name)s %(levelname)s %(filename)s '
'%(f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_main_logger():\n\n # Use verbose debug logging for now.\n console_loglevel = VERBOSITY_LEVELS[2]\n file_loglevel = VERBOSITY_LEVELS[2]\n\n console_fmt = logging.Formatter(\n '%(name)s: %(levelname)s %(message)s')\n file_fmt = logging.Formatter(\n '%(asctime)s - %(name)s: %(leve... | [
"0.60888046",
"0.60173994",
"0.5929699",
"0.58889014",
"0.5855779",
"0.5853313",
"0.5852736",
"0.5819368",
"0.5804063",
"0.5800967",
"0.5776022",
"0.57705855",
"0.57650095",
"0.5753275",
"0.5744197",
"0.5717597",
"0.57117486",
"0.5706986",
"0.5679158",
"0.56692344",
"0.566720... | 0.6818312 | 0 |
Tests the return of `load_cri_image` function | def test_load_cri_image(self, path):
cmd = utils.cmd_output(
stderr='time="2020-07-02T08:02:46Z" '
'level=debug msg="unpacking 1 images"',
stdout="unpacking k8s.gcr.io/my-image:3.1 (sha256:3efe4ff64c93123e"
"1217b0ad6d23b4c87a1fc2109afeff55d2f27d70c55d8f73)...done... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_read_image(self):\n pass",
"def test_CreateROI1(self):\r\n\r\n self.delayDisplay(\"Starting the test\")\r\n #\r\n # first, get some data\r\n #\r\n import urllib\r\n downloads = (\r\n ('http://slicer.kitware.com/midas3/download?items=5767', 'FA.nrrd', slicer.util.loadVolum... | [
"0.69967496",
"0.6590686",
"0.65902233",
"0.6497048",
"0.6327282",
"0.6300939",
"0.62152237",
"0.62148",
"0.62034553",
"0.61346054",
"0.6108102",
"0.6102628",
"0.6064511",
"0.60624236",
"0.60367256",
"0.60231346",
"0.60110754",
"0.59880245",
"0.5982799",
"0.59773093",
"0.5951... | 0.8183807 | 0 |
Get a scorer from string. | def get_scorer(scoring):
if isinstance(scoring, str):
try:
scorer = SCORERS[scoring]
except KeyError:
raise ValueError(
"%r is not a valid scoring value. "
"Use sorted(sklearn.metrics.SCORERS.keys()) "
"to get valid options." % ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_scorer(scoring, compute=True):\n # This is the same as sklearns, only we use our SCORERS dict,\n # and don't have back-compat code\n if isinstance(scoring, six.string_types):\n try:\n scorer = SCORERS[scoring]\n except KeyError:\n raise ValueError('{} is not a v... | [
"0.7410293",
"0.6213774",
"0.6117247",
"0.5969417",
"0.59498906",
"0.5834008",
"0.57948613",
"0.57125705",
"0.5691819",
"0.5677424",
"0.5553856",
"0.5519682",
"0.5454422",
"0.5444198",
"0.53747046",
"0.5372519",
"0.5332151",
"0.53248066",
"0.52808905",
"0.5260689",
"0.5242217... | 0.7338515 | 1 |
Make a scorer from a performance metric or loss function. This factory function wraps scoring functions for use in | def make_scorer(
score_func,
*,
greater_is_better=True,
needs_proba=False,
needs_threshold=False,
**kwargs,
):
sign = 1 if greater_is_better else -1
if needs_proba and needs_threshold:
raise ValueError(
"Set either needs_proba or needs_threshold to True, but not both.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_scorer(scoring, compute=True):\n # This is the same as sklearns, only we use our SCORERS dict,\n # and don't have back-compat code\n if isinstance(scoring, six.string_types):\n try:\n scorer = SCORERS[scoring]\n except KeyError:\n raise ValueError('{} is not a v... | [
"0.68151456",
"0.65854603",
"0.65313846",
"0.6162087",
"0.6153191",
"0.61268836",
"0.6123337",
"0.6015906",
"0.586069",
"0.58467746",
"0.5845448",
"0.5719968",
"0.5628305",
"0.5599996",
"0.5546353",
"0.54967225",
"0.5482464",
"0.54398274",
"0.543661",
"0.5424008",
"0.54104716... | 0.78375727 | 0 |
Event of choose point button Handling to make sure user choose 2 point to find best line After choose 2 points, fine best line and draw it on canvas | def choose_point_command(a):
global canvas, best_line, list_best_label_distance, label_text_result
if choose_point[0] != a and choose_point[1] != a: # if a was not be choose
if choose_point[0] == -1 and choose_point[1] == -1:
choose_point[0] = a
list_point[a].configure(bg=point_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def onClick(self, event):\n if event.inaxes:\n if event.button == 3:\n if len(self.baslin) < 2:\n # Cannot delete if there less than 2 points\n return\n elif event.button != 1:\n return\n else:\n retu... | [
"0.644487",
"0.6414169",
"0.63994014",
"0.6279453",
"0.6074503",
"0.6039465",
"0.5936192",
"0.5895433",
"0.58924294",
"0.5869574",
"0.58490586",
"0.584594",
"0.584594",
"0.58347243",
"0.58235395",
"0.58041525",
"0.5790136",
"0.57632446",
"0.57615465",
"0.5746828",
"0.5745401"... | 0.73080593 | 0 |
Event of off_all_line button Function to show or hide all lines off all points (keep hose best line with 2 point) | def hide_all_line():
global canvas, button_off_all_line, best_line, button_off_best_line
if button_off_all_line['text'] == "Hide all line": # If current status is show and want to hide
canvas.delete("all_line_tag") # Delete all lines from canvas
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hide_all_bestline():\n global canvas, button_off_best_line, best_line\n if best_line is not None:\n if button_off_best_line['text'] == \"Hide best line\": # If current status is show and want to hide\n canvas.delete(\"best_line_tag\") ... | [
"0.7622647",
"0.68477213",
"0.65928304",
"0.658819",
"0.6270692",
"0.62433136",
"0.6175596",
"0.61608386",
"0.5985505",
"0.5888555",
"0.58602905",
"0.58566725",
"0.5833649",
"0.5795332",
"0.5786222",
"0.575878",
"0.57369995",
"0.5720687",
"0.5713423",
"0.57112813",
"0.5651486... | 0.81036454 | 0 |
Event of off_best_line button Function to show or hide best lines of 2 points | def hide_all_bestline():
global canvas, button_off_best_line, best_line
if best_line is not None:
if button_off_best_line['text'] == "Hide best line": # If current status is show and want to hide
canvas.delete("best_line_tag") # Delete best... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hide_best_distance():\n global canvas, list_label_distance, data, list_position, list_best_label_distance\n if len(list_best_label_distance) != 0:\n if button_off_best_label_distance['text'] == \"Hide best distance\": # If current status is show and want to hide\n for i in range(len(li... | [
"0.6818651",
"0.66486394",
"0.60474133",
"0.604604",
"0.59081006",
"0.5839253",
"0.5635505",
"0.56088",
"0.5502675",
"0.54919034",
"0.5474902",
"0.5400621",
"0.5398919",
"0.5303749",
"0.527624",
"0.5274308",
"0.52618957",
"0.52533096",
"0.5252591",
"0.52440584",
"0.5228172",
... | 0.77532905 | 0 |
Event of button_off_all_label_distance button Function to show or hide all distance value | def hide_all_distance():
global canvas, button_off_all_label_distance, list_label_distance, data, list_position, \
list_best_label_distance, button_off_best_label_distance
if button_off_all_label_distance['text'] == "Hide all distance": # If current status is show and want to hide
for i in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hide_best_distance():\n global canvas, list_label_distance, data, list_position, list_best_label_distance\n if len(list_best_label_distance) != 0:\n if button_off_best_label_distance['text'] == \"Hide best distance\": # If current status is show and want to hide\n for i in range(len(li... | [
"0.75043434",
"0.59171087",
"0.5838485",
"0.5706002",
"0.56357735",
"0.5474313",
"0.545505",
"0.5445648",
"0.5394187",
"0.53430897",
"0.5258339",
"0.5220189",
"0.5196048",
"0.51593065",
"0.51419675",
"0.5132579",
"0.5116383",
"0.5098416",
"0.50940084",
"0.50889766",
"0.507515... | 0.8398894 | 0 |
Event of off_best_distance button Function to show or hide best distance of dijkstra | def hide_best_distance():
global canvas, list_label_distance, data, list_position, list_best_label_distance
if len(list_best_label_distance) != 0:
if button_off_best_label_distance['text'] == "Hide best distance": # If current status is show and want to hide
for i in range(len(list_best_lab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hide_all_distance():\n global canvas, button_off_all_label_distance, list_label_distance, data, list_position, \\\n list_best_label_distance, button_off_best_label_distance\n if button_off_all_label_distance['text'] == \"Hide all distance\": # If current status is show and want to hide\n ... | [
"0.6756336",
"0.6017361",
"0.5828534",
"0.5650388",
"0.55981857",
"0.55409235",
"0.5525183",
"0.5472911",
"0.5458907",
"0.524283",
"0.5239041",
"0.5234307",
"0.52263236",
"0.51862323",
"0.5134129",
"0.51089394",
"0.51026577",
"0.50943565",
"0.5082267",
"0.5062372",
"0.5059855... | 0.7727631 | 0 |
Split out the linefree continuum channels from the measurement set and apply channel averaging (for the higher resolution line channels). The flags are backed up, line channels flagged, measurement set split, and the flag state restored. It should be OK to initialize the weight each time, since when found will noop. | def split_linefree(imc):
now = str(datetime.datetime.utcnow())
comment = 'Flags before split for line-free (UTC: {0})'.format(now)
print(':: Saving flag backup : `before_split`')
flagmanager(vis=imc.vis, mode='save', versionname='before_split',
comment=comment)
initweights(vis=imc.vi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lineDetectThread(self):\n \n while True:\n\n tmpList = self.octo.analog_read_all()\n avg = 0\n for x in tmpList:\n avg = avg + x\n\n avg = avg / len(tmpList)\n\n if avg <= self.cutoff:\n if not self.seenLine: # f... | [
"0.48285812",
"0.48112413",
"0.4758139",
"0.47020394",
"0.469053",
"0.46687457",
"0.46044582",
"0.45869437",
"0.45790747",
"0.4564418",
"0.45641688",
"0.45589712",
"0.44781768",
"0.44485095",
"0.44375643",
"0.44301227",
"0.4421234",
"0.44173494",
"0.4417143",
"0.44007793",
"0... | 0.5999584 | 0 |
A utility function that converts an attribute name string into the corresponding attribute tag. | def convert_attribute_name_to_tag(value):
if not isinstance(value, six.string_types):
raise ValueError("The attribute name must be a string.")
for entry in attribute_name_tag_table:
if value == entry[0]:
return entry[1]
raise ValueError("Unrecognized attribute name: '{}'".forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_attribute_tag_to_name(value):\n if not isinstance(value, Tags):\n raise ValueError(\"The attribute tag must be a Tags enumeration.\")\n\n for entry in attribute_name_tag_table:\n if value == entry[1]:\n return entry[0]\n\n raise ValueError(\"Unrecognized attribute tag:... | [
"0.74248964",
"0.71455866",
"0.6820382",
"0.6814265",
"0.6467705",
"0.6433419",
"0.63990474",
"0.6338518",
"0.6189894",
"0.60293674",
"0.6026002",
"0.6026002",
"0.6018459",
"0.5988461",
"0.5980702",
"0.59706277",
"0.5942196",
"0.5880535",
"0.58307683",
"0.58123",
"0.58119905"... | 0.80393004 | 0 |
A utility function that converts an attribute tag into the corresponding attribute name string. | def convert_attribute_tag_to_name(value):
if not isinstance(value, Tags):
raise ValueError("The attribute tag must be a Tags enumeration.")
for entry in attribute_name_tag_table:
if value == entry[1]:
return entry[0]
raise ValueError("Unrecognized attribute tag: {}".format(valu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_attribute_name_to_tag(value):\n if not isinstance(value, six.string_types):\n raise ValueError(\"The attribute name must be a string.\")\n\n for entry in attribute_name_tag_table:\n if value == entry[0]:\n return entry[1]\n\n raise ValueError(\"Unrecognized attribute n... | [
"0.73351747",
"0.72900105",
"0.7044817",
"0.700109",
"0.6944922",
"0.6706183",
"0.66464186",
"0.6546524",
"0.6434635",
"0.6434635",
"0.6406859",
"0.63961947",
"0.63639677",
"0.63639677",
"0.6242204",
"0.6229339",
"0.6229339",
"0.62258285",
"0.6216158",
"0.62033",
"0.62025344"... | 0.7753604 | 0 |
A utility function that computes a bit mask from a collection of enumeration values. | def get_bit_mask_from_enumerations(enumerations):
return functools.reduce(
lambda x, y: x | y, [z.value for z in enumerations]
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_enumerations_from_bit_mask(enumeration, mask):\n return [x for x in enumeration if (x.value & mask) == x.value]",
"def parse_mask(value, mask_enum):\n masks = []\n for mask in mask_enum:\n if value & mask:\n masks.append(mask.name)\n value ^= mask\n if value:\n ... | [
"0.7744489",
"0.66913533",
"0.6403534",
"0.61704373",
"0.61267203",
"0.5990406",
"0.58188605",
"0.5776456",
"0.5742034",
"0.57257146",
"0.5702052",
"0.5667115",
"0.5648651",
"0.54798436",
"0.54597044",
"0.54477435",
"0.5405333",
"0.53865755",
"0.53729063",
"0.53284824",
"0.53... | 0.8022848 | 0 |
A utility function that creates a list of enumeration values from a bit mask for a specific mask enumeration class. | def get_enumerations_from_bit_mask(enumeration, mask):
return [x for x in enumeration if (x.value & mask) == x.value] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_mask(value, mask_enum):\n masks = []\n for mask in mask_enum:\n if value & mask:\n masks.append(mask.name)\n value ^= mask\n if value:\n masks.append(hex(value))\n\n return masks",
"def get_bit_mask_from_enumerations(enumerations):\n return functools.r... | [
"0.69542855",
"0.6844899",
"0.6179964",
"0.6085858",
"0.60515696",
"0.58843184",
"0.5866593",
"0.5610187",
"0.5600955",
"0.5540577",
"0.54730654",
"0.5454916",
"0.5427376",
"0.538644",
"0.5377461",
"0.5375424",
"0.5373737",
"0.5363888",
"0.5209238",
"0.5204924",
"0.51944685",... | 0.81864226 | 0 |
A utility function that checks if the provided value is a composite bit mask of enumeration values in the specified enumeration class. | def is_bit_mask(enumeration, potential_mask):
if not isinstance(potential_mask, six.integer_types):
return False
mask_enumerations = (
CryptographicUsageMask,
ProtectionStorageMask,
StorageStatusMask
)
if enumeration not in mask_enumerations:
return False
ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_enum_value(enumeration, potential_value):\n try:\n enumeration(potential_value)\n except ValueError:\n return False\n\n return True",
"def get_enumerations_from_bit_mask(enumeration, mask):\n return [x for x in enumeration if (x.value & mask) == x.value]",
"def _is_equal_to_enu... | [
"0.5870301",
"0.58618695",
"0.553218",
"0.5408903",
"0.5404764",
"0.53083646",
"0.5269919",
"0.5266223",
"0.521553",
"0.51871705",
"0.5102369",
"0.50527793",
"0.5026475",
"0.49758133",
"0.4956287",
"0.49388525",
"0.4901828",
"0.48965237",
"0.48832533",
"0.48725867",
"0.480630... | 0.6198896 | 0 |
A utility function that checks if the enumeration class contains the provided value. | def is_enum_value(enumeration, potential_value):
try:
enumeration(potential_value)
except ValueError:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains(cls, value):\n return value in cls.values()",
"def contains(cls, value):\n return any(value == item.value for item in cls)",
"def has_value(cls, value):\n return any(value == item.value for item in cls)",
"def has_value(cls, value):\n return any(value == item.value fo... | [
"0.7130909",
"0.6671945",
"0.66446143",
"0.66446143",
"0.6463414",
"0.64291495",
"0.64076877",
"0.63996106",
"0.61606634",
"0.613417",
"0.61334",
"0.6130707",
"0.6110766",
"0.6105736",
"0.6105704",
"0.60750055",
"0.60390246",
"0.6028632",
"0.602763",
"0.60264736",
"0.60111135... | 0.7098082 | 1 |
Convention for saving the elev arrays to file. | def save_lists_to_file(filename, elev_list, dist_list):
import numpy as np
np.save(file=filename,arr=np.array([elev_list, dist_list])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_enu(self, filename):\n x, y, z = self.get_coords_enu()\n coords = np.vstack([x, y, z]).T\n np.savetxt(filename, coords, fmt=b'%.12e')",
"def save_iantconfig(self, filename_root):\n x, y, z = self.get_coords_enu()\n d = np.ones_like(x) # set to 1 to avoid shadowing in ... | [
"0.7392277",
"0.6695063",
"0.6674351",
"0.644882",
"0.63625616",
"0.6278154",
"0.6215802",
"0.62093705",
"0.6171282",
"0.61635345",
"0.610858",
"0.61081475",
"0.601042",
"0.60060334",
"0.6003838",
"0.59577906",
"0.59309465",
"0.59160286",
"0.59078306",
"0.5905936",
"0.5888497... | 0.7149724 | 1 |
Generate a bunch of input JSON files from a template and a bunch of elevation files | def generate_input_files(elevation_folder_path, template_input_file_path):
import pathlib
json_dict = get_inputs_from_file(template_input_file_path)
path_to_match = pathlib.Path(elevation_folder_path)
for heightfile in path_to_match.glob("*.npy"):
dot_index = str(heightfile).rfind('.')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_main():\n for template in templates:\n main([\"-g\", template])\n\n # One at a time\n for xyz_file in example_xyz_files:\n main([template, xyz_file])\n\n # All at once\n main([template] + list(example_xyz_files))\n\n # Allow use of template in the parent... | [
"0.6439445",
"0.6329011",
"0.6317232",
"0.6279043",
"0.62260956",
"0.60334027",
"0.60176724",
"0.60137415",
"0.60113746",
"0.59920955",
"0.59756476",
"0.5974208",
"0.59657097",
"0.5964929",
"0.596335",
"0.59502697",
"0.5911967",
"0.58968824",
"0.5894371",
"0.5880914",
"0.5866... | 0.80537117 | 0 |
Renames .json files for height files that have too steep gradients for driving. Due to tunnels in mountatin roads, sometimes the surface elevation at a road does not correspond to the actual road elevation. Therefore, the heightmap may be that of a road trying to climb an _actual_ mountain. This is undesired behaviour ... | def seed_out_too_steep(config_folder_path, max_gradient):
import pathlib
import os
path_to_match = pathlib.Path(config_folder_path)
for config_file in path_to_match.glob("*.json"):
config_filename = str(config_file)
json_config = get_inputs_from_file(config_filename)
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def renamefile(filename):\n new_data_list = []\n with open(filename, 'r') as f:\n data_list = f.read().split('\\n')\n\n print('Generating new data list..')\n for data in tqdm(data_list):\n if len(data) == 0:\n continue\n data_info = data.split(' ')\n\... | [
"0.55360186",
"0.5124106",
"0.5096552",
"0.5074441",
"0.5036425",
"0.49875963",
"0.49749434",
"0.4938649",
"0.4931775",
"0.49261597",
"0.48441556",
"0.4823751",
"0.47443646",
"0.46914992",
"0.46750745",
"0.46672103",
"0.46231896",
"0.46168032",
"0.45954028",
"0.4571667",
"0.4... | 0.5183655 | 1 |
Create new lists were previously doubled points in dist list removed and averaged in elev_list | def average_double_pts(elev_list, dist_list, minimum_point_distance=0.5):
import numpy as np
dist_array = np.array(dist_list)
diffs = dist_array[1:] - dist_array[:-1]
bad_pts = diffs < minimum_point_distance
bad_indices = [i for i in range(len(bad_pts)) if bad_pts[i]]
new_elev_array = np.arra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def v_dist_space(trial):\n return [np.mean(space) for space in trial]",
"def _euclidian_distances(stop_list):\n e_dists2 = [transitfeed.approximate_distance_between_stops(stop, tail) for\n (stop, tail) in zip(stop_list, stop_list[1:])]\n\n return e_dists2",
"def _transform_d... | [
"0.59104544",
"0.5468914",
"0.5397144",
"0.53817797",
"0.5364048",
"0.535594",
"0.53433156",
"0.5334994",
"0.53302234",
"0.53162",
"0.52459675",
"0.52387244",
"0.52223456",
"0.519468",
"0.5191414",
"0.51864374",
"0.5181687",
"0.51815665",
"0.51673615",
"0.5149777",
"0.5147351... | 0.72335047 | 0 |
Because of slight numerical instabilities, the mostlikelytree method does _not_ in fact always return the same tree when there are multiple trees with the same or very nearly the same likelihood. The best we can ask for is that the method returns _a_ best tree, defined as one with the biggest likelihood, or nearly the ... | def test_that_most_probable_always_returns_a_tree_of_the_same_logprob():
grammar = Grammar(rulebooks)
actual_tree = grammar.sample_tree()
sentence = actual_tree.terminals
inner = grammar.compute_inside_probabilities(sentence)
best_tree = grammar.compute_most_likely_tree(sentence, inner, root=0)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_maximum_value(self):\n if self.root: \n self.max_val = self.root.value\n else:\n return 'No tree found'\n def inner(root):\n if root.left:\n inner(root.left)\n\n if root.right:\n inner(root.right)\n\n if self.max_val < root.value:\n self.max_val = roo... | [
"0.67465556",
"0.6164014",
"0.61626226",
"0.60900533",
"0.6089753",
"0.60731304",
"0.6045642",
"0.60375273",
"0.6031647",
"0.6021071",
"0.5996487",
"0.59402007",
"0.59293586",
"0.58979386",
"0.58588094",
"0.58377635",
"0.58170396",
"0.58130044",
"0.58093256",
"0.5809125",
"0.... | 0.7200898 | 0 |
Load in arguments for applying coefficients for Ensemble Model Output Statistics (EMOS), otherwise known as Nonhomogeneous Gaussian Regression (NGR). The coefficients are applied to the forecast that is supplied, so as to calibrate the forecast. The calibrated forecast is written to a netCDF file. If no coefficients ar... | def main(argv=None):
parser = ArgParser(
description='Apply coefficients for Ensemble Model Output '
'Statistics (EMOS), otherwise known as Non-homogeneous '
'Gaussian Regression (NGR). The supported input formats '
'are realizations, probabilities... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(current_forecast, coeffs, num_realizations=None,\n random_ordering=False, random_seed=None,\n ecc_bounds_warning=False, predictor_of_mean='mean'):\n if coeffs is None:\n msg = (\"There are no coefficients provided for calibration. The \"\n \"uncalibrated fo... | [
"0.5519549",
"0.5417745",
"0.53862226",
"0.52634716",
"0.50273323",
"0.5010265",
"0.49229556",
"0.49013907",
"0.4877792",
"0.48454607",
"0.4783449",
"0.47544655",
"0.47529",
"0.47140917",
"0.47133023",
"0.47060087",
"0.46985283",
"0.4687954",
"0.46867755",
"0.4664076",
"0.465... | 0.7194427 | 0 |
Applying coefficients for Ensemble Model Output Statistics. Load in arguments for applying coefficients for Ensemble Model Output Statistics (EMOS), otherwise known as Nonhomogeneous Gaussian Regression (NGR). The coefficients are applied to the forecast that is supplied, so as to calibrate the forecast. The calibrated... | def process(current_forecast, coeffs, num_realizations=None,
random_ordering=False, random_seed=None,
ecc_bounds_warning=False, predictor_of_mean='mean'):
if coeffs is None:
msg = ("There are no coefficients provided for calibration. The "
"uncalibrated forecast will b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(argv=None):\n parser = ArgParser(\n description='Apply coefficients for Ensemble Model Output '\n 'Statistics (EMOS), otherwise known as Non-homogeneous '\n 'Gaussian Regression (NGR). The supported input formats '\n 'are realizations, pro... | [
"0.6839221",
"0.5753612",
"0.5297529",
"0.50588846",
"0.486943",
"0.48606175",
"0.48570108",
"0.4810559",
"0.4788578",
"0.47579268",
"0.4745183",
"0.47238272",
"0.47165662",
"0.4668261",
"0.46644482",
"0.4629341",
"0.46219748",
"0.46173713",
"0.46099064",
"0.46055603",
"0.460... | 0.6488239 | 1 |
Retrieve a list of all panelist scores from nonBest Of and nonRepeat shows | def retrieve_all_scores(database_connection: mysql.connector.connect
) -> List[int]:
cursor = database_connection.cursor()
query = ("SELECT pm.panelistscore FROM ww_showpnlmap pm "
"JOIN ww_shows s ON s.showid = pm.showid "
"WHERE s.bestof = 0 AND s.repeatshowid ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve_grouped_scores(database_connection: mysql.connector.connect\n ) -> Dict:\n cursor = database_connection.cursor()\n query = (\"SELECT pm.panelistscore, COUNT(pm.panelistscore) \"\n \"FROM ww_showpnlmap pm \"\n \"JOIN ww_shows s ON s.showid = pm.sh... | [
"0.63882565",
"0.6345482",
"0.60516936",
"0.60274804",
"0.5971298",
"0.59415215",
"0.5897459",
"0.58885854",
"0.58742666",
"0.56829435",
"0.567487",
"0.56604165",
"0.56549484",
"0.5630021",
"0.5613433",
"0.56064445",
"0.5598407",
"0.5592181",
"0.55896866",
"0.55654347",
"0.55... | 0.6766444 | 0 |
Retrieve a list of grouped panelist scores from nonBest Of and nonRepeat shows | def retrieve_grouped_scores(database_connection: mysql.connector.connect
) -> Dict:
cursor = database_connection.cursor()
query = ("SELECT pm.panelistscore, COUNT(pm.panelistscore) "
"FROM ww_showpnlmap pm "
"JOIN ww_shows s ON s.showid = pm.showid "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve_all_scores(database_connection: mysql.connector.connect\n ) -> List[int]:\n cursor = database_connection.cursor()\n query = (\"SELECT pm.panelistscore FROM ww_showpnlmap pm \"\n \"JOIN ww_shows s ON s.showid = pm.showid \"\n \"WHERE s.bestof = 0 AND ... | [
"0.61236584",
"0.60025114",
"0.5887449",
"0.58714366",
"0.58647263",
"0.57514274",
"0.57352406",
"0.5672734",
"0.5664091",
"0.5638059",
"0.5633964",
"0.56201035",
"0.5512606",
"0.55024105",
"0.5480762",
"0.5474629",
"0.5465591",
"0.54459333",
"0.5442375",
"0.53806484",
"0.537... | 0.6751662 | 0 |
Print out the scrore spread | def print_score_spread(score_spread: Dict):
print(" Score Spread\n")
print(" Score Count")
for score in score_spread:
print(" {:>7}{:>12}".format(score["score"], score["count"]))
print()
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print(self):\r\n self.print_avec_separateur()",
"def print(self):\n self.print_avec_separateur(\" \")",
"def print_scores(self):\n ### FILL IN ###",
"def print_output(self):\n print(\"Reference score: \" + str(self.PotTax_reference.sum().TFI))\n print(\"Intervention sco... | [
"0.6561322",
"0.643337",
"0.6330498",
"0.6281885",
"0.62810534",
"0.62737805",
"0.62556595",
"0.6224368",
"0.6221346",
"0.6209357",
"0.6202504",
"0.6195883",
"0.6191251",
"0.6188209",
"0.6159958",
"0.6145935",
"0.6139892",
"0.60920966",
"0.6085532",
"0.60845447",
"0.6076933",... | 0.71421385 | 0 |
Return version key to use given a specific version. For example, if a dictionary only has instructions for version 'generic', will return 'generic' given any version string. Raises `ValueError` if no key could be found for requested version. | def get_version_key(self, version):
if self._generic_only:
return GENERIC_VERSION
else:
self.check_version_exists(version)
return version | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetKey(self, version_number):\n return self.dict[str(version_number)]",
"def key_version(self) -> Optional[str]:\n return pulumi.get(self, \"key_version\")",
"def get_version(self, key, version=None):\n if version is None:\n if key not in self._data:\n raise KeyEr... | [
"0.7516901",
"0.6918039",
"0.6749801",
"0.6605578",
"0.6401275",
"0.6225745",
"0.620228",
"0.619842",
"0.6191113",
"0.6155921",
"0.6147764",
"0.60847867",
"0.6057561",
"0.60508114",
"0.5988967",
"0.59874403",
"0.59791094",
"0.59724796",
"0.5945546",
"0.59303916",
"0.58354455"... | 0.8208527 | 0 |
Input layer class that defines the input shape for the network. An input layer is required for the first layer in all models. | def __init__(self, shape):
self.shape = literal_eval(shape)
self.keras_layer = keras.layers.Input(shape=self.shape)
self.type = 'Input'
self.name = ':'.join([self.type, str(self.shape)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, shape, input_var=None):\n\n self.output = layers.InputLayer(shape, input_var=input_var)",
"def build(self, input_layer, trainable=True):\n\n with tf.variable_scope(self.name):\n # Determine the size of the input when flattened\n input_layer_shape = input_layer.get_s... | [
"0.73620754",
"0.68776786",
"0.68701315",
"0.6866467",
"0.6684106",
"0.66439646",
"0.66422045",
"0.65750545",
"0.6553184",
"0.6525942",
"0.63709074",
"0.63709074",
"0.63709074",
"0.6291092",
"0.62881696",
"0.6286421",
"0.6284356",
"0.6267243",
"0.62483495",
"0.62224865",
"0.6... | 0.700692 | 1 |
layer_exist = [conv_act, pool_max_act, pool_ave_act, pool_max_no_act, pool_ave_no_act] | def layers(arr):
layer_exist = [0, 0, 0, 0, 0]
arr = arr.split()
for i, a in enumerate(arr):
if arr[i].lower().startswith("convolution") or arr[i].lower().startswith("innerproduct"):
if i != len(arr) and arr[i+1].lower() == "relu":
layer_exist[0] = 1
if arr[i].lower() == "avepooling":
if (i != (len... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_features(inp_layer, pad=0):\n # Note: tweaked to use average pooling instead of maxpooling\n net = OrderedDict()\n net['conv1_1'] = ConvLayer(inp_layer, 64, 3, pad=pad, flip_filters=False, nonlinearity=rectify)\n net['conv1_2'] = ConvLayer(net['conv1_1'], 64, 3, pad=pad, flip_filters=False, non... | [
"0.6113794",
"0.60285205",
"0.5972099",
"0.59599495",
"0.58484864",
"0.5841038",
"0.5795003",
"0.5780913",
"0.57801276",
"0.5778729",
"0.5769082",
"0.57289445",
"0.5715246",
"0.5696411",
"0.56913024",
"0.5674453",
"0.5619215",
"0.5609114",
"0.558215",
"0.5575851",
"0.5573412"... | 0.6529583 | 0 |
Interfaces that both share a subset of compatible ports can be deemed compatible by setting the `allow_subsets` option of the compatibility test. | def test_is_compatible_subsets(self):
i = Interface('/foo[0:6]')
i['/foo[0:3]'] = [0, 'out', 'gpot']
i['/foo[3:6]'] = [0, 'out', 'spike']
j = Interface('/foo[0:6]')
j['/foo[0:2]'] = [1, 'in', 'gpot']
j['/foo[3:5]'] = [1, 'in', 'spike']
k = Interface('/foo[0:6]')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_is_compatible_subsets_with_null_types(self):\n\n i = Interface('/foo[0:6]')\n i['/foo[0:3]'] = [0, 'out']\n i['/foo[3:6]'] = [0, 'out']\n j = Interface('/foo[0:6]')\n j['/foo[0:2]'] = [1, 'in']\n j['/foo[3:5]'] = [1, 'in']\n k = Interface('/foo[0:6]')\n ... | [
"0.6700613",
"0.5888596",
"0.5888596",
"0.5716942",
"0.5570211",
"0.5458658",
"0.5365004",
"0.5320249",
"0.52785486",
"0.51995903",
"0.5177569",
"0.515498",
"0.51448685",
"0.5117207",
"0.49495307",
"0.49465245",
"0.49463874",
"0.49270806",
"0.4923223",
"0.491944",
"0.4907876"... | 0.78658915 | 0 |
Interfaces that both share a subset of compatible ports can be deemed compatible by setting the `allow_subsets` option of the compatibility test even when the types are null. | def test_is_compatible_subsets_with_null_types(self):
i = Interface('/foo[0:6]')
i['/foo[0:3]'] = [0, 'out']
i['/foo[3:6]'] = [0, 'out']
j = Interface('/foo[0:6]')
j['/foo[0:2]'] = [1, 'in']
j['/foo[3:5]'] = [1, 'in']
k = Interface('/foo[0:6]')
assert i.i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_is_compatible_subsets(self):\n\n i = Interface('/foo[0:6]')\n i['/foo[0:3]'] = [0, 'out', 'gpot']\n i['/foo[3:6]'] = [0, 'out', 'spike']\n j = Interface('/foo[0:6]')\n j['/foo[0:2]'] = [1, 'in', 'gpot']\n j['/foo[3:5]'] = [1, 'in', 'spike']\n k = Interface(... | [
"0.76551175",
"0.6187195",
"0.5959266",
"0.5550304",
"0.5550304",
"0.52693313",
"0.5247899",
"0.5175491",
"0.5172923",
"0.51695246",
"0.51173824",
"0.5093611",
"0.5085437",
"0.50665164",
"0.504104",
"0.5036018",
"0.50319415",
"0.5031793",
"0.49958917",
"0.49873957",
"0.497339... | 0.7800067 | 0 |
Return a strategy that holds if and only if pending >= x or player reaches goal. | def hold_at(x):
def strategy(state):
# your code here
p, me, you, pending = state
return "hold" if (pending >= x or me + pending >= goal) else "roll"
strategy.__name__ = 'hold_at(%d)' % x
return strategy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hold_at(x):\n\n def strategy(state):\n (p, me, you, pending) = state\n return 'hold' if (pending >= x or me + pending >= goal) else 'roll'\n\n strategy.__name__ = 'hold_at(%d)' % x\n return strategy",
"def Pwin(state):\n # Assumes opponent also plays with optimal strategy\n p, me... | [
"0.7355454",
"0.60242695",
"0.6023155",
"0.5951468",
"0.5937637",
"0.572351",
"0.5663513",
"0.56209296",
"0.56154317",
"0.56149787",
"0.5597981",
"0.55769897",
"0.556702",
"0.55660975",
"0.5485379",
"0.54448724",
"0.5435684",
"0.54253024",
"0.5404603",
"0.5403368",
"0.5395781... | 0.7068357 | 1 |
Play a game of pig between two players, represented by their strategies. Each time through the main loop we ask the current player for one decision, which must be 'hold' or 'roll', and we update the state accordingly. When one player's score exceeds the goal, return that player. | def play_pig(A, B):
# your code here
strategies = [A,B]
state = (0,0,0,0)
while True:
p, me, you, pending = state
if me >= goal:
return strategies[p]
elif you >= goal:
return strategies[other_turn[p]]
# elif strategies[p](state) == 'hold':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_pig(A, B):\n # your code here\n strategies = [A, B]\n state = (0, 0, 0, 0)\n while True:\n (p, me, you, pending) = state\n if me >= goal:\n return strategies[p]\n elif you >= goal:\n return strategies[other[p]]\n elif strategies[p](state) == 'h... | [
"0.7907119",
"0.7647033",
"0.7639917",
"0.723368",
"0.7189156",
"0.7187271",
"0.7064494",
"0.7062731",
"0.7054494",
"0.68677187",
"0.674492",
"0.670514",
"0.6567981",
"0.65314806",
"0.6519332",
"0.6519332",
"0.6519332",
"0.65100443",
"0.65067357",
"0.6433185",
"0.632696",
"... | 0.7669755 | 1 |
The utility of a state, here just the probability that an optimal player whose turn it to move can win from the current state | def Pwin(state):
# Assumes opponent also plays with optimal strategy
p, me, you, pending = state
if me + pending >= goal:
return 1
elif you >= goal:
return 0
else:
return max(Q_pig(state, action, Pwin) for action in pig_actions(state)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rough_outcome(self) -> float:\n # HUYNH YOU PRICK WHY THE FUCK DO YOU MAKE US WRITE THIS SHIT EVEN IT'S NOT USED ANYWHERE\n # pick move based on this may not be optimal but better than random\n # return 1 if win immediately\n # return -1 if all states reachable will result the other... | [
"0.77746516",
"0.7501392",
"0.73808473",
"0.7227007",
"0.69487715",
"0.68937486",
"0.68130076",
"0.6812178",
"0.68047494",
"0.6799885",
"0.6795713",
"0.6783112",
"0.67188185",
"0.665067",
"0.65943986",
"0.6592056",
"0.65892106",
"0.6571575",
"0.65390325",
"0.6532277",
"0.6526... | 0.75051713 | 1 |
Search for all typevars and typevarcontaining objects in `args`. Helper function for `_GenericAlias.__init__`. | def _parse_parameters(args: Iterable[Any]) -> Generator[TypeVar, None, None]:
for i in args:
if hasattr(i, "__parameters__"):
yield from i.__parameters__
elif isinstance(i, TypeVar):
yield i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findType(*args, deep: bool=True, exact: bool=True, forward: bool=True, type: AnyStr=\"\",\n **kwargs)->List[AnyStr]:\n pass",
"def find(self, *args):\n return _ida_hexrays.lvars_t_find(self, *args)",
"def used_variables(*terms):\n\n t = terms[0] if len(terms) == 1 else terms\n\n ... | [
"0.6083603",
"0.5493589",
"0.53747714",
"0.53291667",
"0.5164382",
"0.5154936",
"0.50176644",
"0.5015225",
"0.49874654",
"0.49854574",
"0.49834588",
"0.4983403",
"0.49549422",
"0.49442652",
"0.4919461",
"0.48979554",
"0.48860407",
"0.47833136",
"0.4778925",
"0.47677916",
"0.4... | 0.591873 | 1 |
Recursively replace all typevars with those from `parameters`. Helper function for `_GenericAlias.__getitem__`. | def _reconstruct_alias(alias: _T, parameters: Iterator[TypeVar]) -> _T:
args = []
for i in alias.__args__:
if isinstance(i, TypeVar):
value: Any = next(parameters)
elif isinstance(i, _GenericAlias):
value = _reconstruct_alias(i, parameters)
elif hasattr(i, "__para... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_vars(params, contents):\n if isinstance(contents, str):\n contents = [contents]\n replace_contents = []\n\n if params != None and contents != None:\n for content in contents:\n replace_content = content\n for match in regexp_replace_var.findall(content):\n ... | [
"0.5673922",
"0.5523126",
"0.5507102",
"0.54108083",
"0.54027843",
"0.5336006",
"0.5278679",
"0.5244699",
"0.5235492",
"0.5232679",
"0.5227746",
"0.5176148",
"0.5109751",
"0.5095588",
"0.5087228",
"0.505932",
"0.5014933",
"0.5012798",
"0.49798912",
"0.49677464",
"0.49254423",... | 0.6224574 | 0 |
Generates a population of bitarray strings (individuals) to solve the NQueen problem, here N = 'board_size'. 'pop_size' parameter decides the number of bitarray strings (individuals) generated by this function. Creates a list of bitarrray strings (individuals) representing the population for solving the NQueen problem.... | def genPopulation(self):
self.population_list = []
for i in xrange(0, self.pop_size):
individual = bitarray(self.indv_size)
# Loop for randomizing the 'individual' string.
for j in xrange(0, self.board_size):
vert_pos = random.randint(0, self.boa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_population(board_size, population_size):\n return [Nonogram(board_size) for x in range(0, population_size)]",
"def generate_population(population_size, nn_architecture):\n population = []\n for _ in range(population_size):\n population.append(nn.create_nn_from_arch(nn_architecture))\n\... | [
"0.72544706",
"0.67998624",
"0.6587251",
"0.65856385",
"0.64451057",
"0.6369007",
"0.62210387",
"0.6044195",
"0.6014805",
"0.58983636",
"0.58905756",
"0.58675313",
"0.58664834",
"0.5811403",
"0.5697839",
"0.5692206",
"0.56726235",
"0.5658943",
"0.5640834",
"0.5509586",
"0.548... | 0.727817 | 0 |
Populates the fitness list with fitness function values of coresponding entries in the population list. | def computeFitnessList(self,fitnessFunction):
self.fitness_list = []
cmlsum = 0
for individual in self.population_list:
cmlsum = cmlsum + fitnessFunction(individual, self.board_size, self.pos_bits_size)
self.fitness_list.append(cmlsum) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_population(self):\n for idx in xrange(0, self.population_size):\n individual = self.individual_factory.create()\n self.population.append(individual)\n\n self.population_fitness = numpy.asarray(map(lambda individual: individual.get_fitness(), self.population))\n\n ... | [
"0.7050818",
"0.7024004",
"0.6900333",
"0.68683046",
"0.67409855",
"0.6698061",
"0.6585672",
"0.6527284",
"0.65243554",
"0.6502384",
"0.6475374",
"0.6410031",
"0.6401292",
"0.6385652",
"0.6321939",
"0.6284058",
"0.62710774",
"0.6265765",
"0.6243417",
"0.62331927",
"0.6226014"... | 0.7070026 | 0 |
Binary Search for finding appropriate index for key in fitness list. | def findInFitnessList(self, key):
low = 0
high = len(self.fitness_list)
mid = 0
while(low <= high):
mid = (low + high)/2
if key > self.fitness_list[mid]:
low = mid + 1
elif key < self.fitness_list[mid]:
high = m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_search(self, num_lst, key):\r\n # Running time: O(log n) with O(n logn) overhead\r\n # get sorted list\r\n num_lst = sorted(num_lst)\r\n \r\n low, high, idx = 0, len(num_lst), -1\r\n \r\n while low < high:\r\n mid = int(math.floor((low+high) / ... | [
"0.71013904",
"0.70412946",
"0.69745183",
"0.68652153",
"0.6833065",
"0.68021667",
"0.68017167",
"0.6780906",
"0.6739357",
"0.6714616",
"0.6690004",
"0.65812993",
"0.6545252",
"0.6515856",
"0.65082943",
"0.6490799",
"0.6479905",
"0.64732397",
"0.64555985",
"0.6413893",
"0.636... | 0.78341144 | 0 |
Converts a number in int format to a bitarray of length 'size', in binary representation. Returns the bitarray. | def toBitArray(number, size):
temp_bitnum = bitarray(64)
count = 0
number = number & 0xFFFFFFFFFFFFFFFF # enforces the number to be 64 bit.
while count < size:
temp_bitnum[63 - count] = (number % 2)
# print "digit ", count, " : ", (number % 2)
number = number >> 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary(num, size=32):\n ret = np.zeros(size, dtype=np.int)\n n = np.array([int(x) for x in list(bin(num)[2:])])\n ret[ret.size - n.size:] = n\n return ret",
"def binary(num, size=32):\n ret = np.zeros(size, dtype=np.int)\n n = np.array([int(x) for x in list(bin(num)[2:])])\n ret[ret.size... | [
"0.7790668",
"0.7790668",
"0.7245732",
"0.6670738",
"0.64003235",
"0.6200373",
"0.6070387",
"0.60702974",
"0.60172224",
"0.5953754",
"0.5915167",
"0.591251",
"0.58911425",
"0.5887502",
"0.5887502",
"0.5879545",
"0.586908",
"0.5858048",
"0.58292425",
"0.58278644",
"0.5824009",... | 0.7832017 | 0 |
Initialize a symmetry operation object from a string representation of symmetry operation. | def __init__(self, operation_string):
self.operation_string = operation_string.lower()
self.operation_function = None
self.__set_operation_function() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, op, symbolicExpression1, symbolicExpression2):\n\n SymbolicExpression.__init__(self)\n \n self.op = op\n self.symbolicExpression1 = symbolicExpression1\n self.symbolicExpression2 = symbolicExpression2",
"def __init__(self, operand_string):\n\... | [
"0.65855575",
"0.6394667",
"0.60201573",
"0.58792925",
"0.5829858",
"0.5817785",
"0.58118224",
"0.5685034",
"0.5679989",
"0.5663519",
"0.5663512",
"0.5659587",
"0.5653366",
"0.5648754",
"0.5644039",
"0.56371164",
"0.56318647",
"0.56213385",
"0.5609781",
"0.5595345",
"0.555548... | 0.66930246 | 0 |
Given the LATT directive in a res file, return the corresponding centered lattice type. | def construct(cls, latt):
latt = abs(latt)
if latt == 1:
return cls.primitive()
elif latt == 2:
return cls.body_centered()
elif latt == 3:
# default setting from reading in a res file is Rhombohedral
return cls.rhombohedral()
elif l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def specified_lattice_constant(self):\n return load_node(self.get_attribute('specified_lattice_constant'))",
"def print_abs_type(self):\n return 'DLA'",
"def get_ligand_resname_from_topology( topfile ):\n\n file = open( topfile, 'r')\n text = file.readlines()\n file.close()\n indices ... | [
"0.5302461",
"0.51673067",
"0.51398134",
"0.4979288",
"0.48934972",
"0.48730606",
"0.48607278",
"0.48193753",
"0.47571704",
"0.473777",
"0.4727024",
"0.46984535",
"0.46911123",
"0.46570626",
"0.46286234",
"0.46027964",
"0.46002376",
"0.45856792",
"0.45732707",
"0.4515798",
"0... | 0.6210394 | 0 |
Basic plotting feature. Can be used standalone, in which case you can ignore the 'newfig' and 'plotfig' parameters. Otherwise, you may suppress these by passing False and using the returned axes object. | def basicplot(data, plotter='plot', newfig=True, showplot=True, **kwargs):
if plotter not in ('plot', 'step'):
raise ValueError
if newfig:
plt.figure(figsize=kwargs.get('figsize', (8, 6)))
# ............................................................................ Plot per type
if isinstance(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_axes(self):\n plt.switch_backend(\"cairo\")\n fig = plt.figure(figsize=(15,10))\n ax = fig.add_axes([0.05, 0.15, 0.9, 0.80,])\n return (fig, ax)",
"def _newax(ax=None):\n from matplotlib import pyplot as plt\n if ax is not None:\n return ax\n fig = plt.figure(... | [
"0.6635028",
"0.6569405",
"0.64893675",
"0.6439919",
"0.6360829",
"0.6326854",
"0.6290503",
"0.627174",
"0.62165153",
"0.6209581",
"0.6181125",
"0.61717874",
"0.6159054",
"0.6155145",
"0.6095297",
"0.60936546",
"0.60824245",
"0.60354114",
"0.6033826",
"0.6010859",
"0.59907717... | 0.6620118 | 1 |
delegates to base interface run method, then attempts to generate reports | def _run_interface(self, runtime):
try:
runtime = super(
ReportCapableInterface, self)._run_interface(runtime)
except NotImplementedError:
pass # the interface is derived from BaseInterface
# leave early if there's nothing to do
if not self.input... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_report(self):\n raise NotImplementedError",
"def __execute_reporter(self):\n if not self.__args.report:\n return\n reporter.HTMLReporter().generate_report_from_file(\n self.__lst_json_files)",
"def run(self):\n report_file = self.get_report_file_n... | [
"0.7437408",
"0.73895234",
"0.7325222",
"0.7179931",
"0.6891885",
"0.6887828",
"0.6871864",
"0.6871864",
"0.67655283",
"0.67655283",
"0.67655283",
"0.67655283",
"0.67655283",
"0.67655283",
"0.67655283",
"0.67655283",
"0.67655283",
"0.6731759",
"0.67242306",
"0.6709329",
"0.66... | 0.7569578 | 0 |
Generates the visual report | def _generate_report(self):
from niworkflows.viz.utils import plot_registration
NIWORKFLOWS_LOG.info('Generating visual report')
anat = load_img(self._anat_file)
contour_nii = load_img(self._contour) if self._contour is not None else None
if self._mask_file:
anat = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_report(self) -> Report:\n # equity_curve = self._generate_equity_curve()\n # summary_stats = self._generate_summary_stats(equity_curve)\n # return Report(equity_curve, summary_stats)\n pass",
"def _generate_report(self):\n raise NotImplementedError",
"def generat... | [
"0.72419435",
"0.72344077",
"0.7205322",
"0.7167486",
"0.70916015",
"0.70792633",
"0.69737315",
"0.68265104",
"0.67954844",
"0.6770184",
"0.6706242",
"0.6649476",
"0.6630725",
"0.66305715",
"0.66226053",
"0.66017485",
"0.6577003",
"0.6519854",
"0.6497918",
"0.64795333",
"0.64... | 0.7264522 | 0 |
Initialize a new Calibration | def __init__(self, poses=None, selected_point=None):
super(Calibration, self).__init__("calibration")
self.marker_array = MarkerArray()
if selected_point is None:
selected_point = 0
if poses is not None:
self.poses = poses
else:
self.load()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self._read_calibration_data()\n self.configure_sensor(\n TemperatureOversamplings.x08,\n PressureOversamplings.x16,\n HumidityOversamplings.x08,\n IIRFilterCoefficients.FC_003,\n 250,\n 250)",
"def initialise_ca... | [
"0.7170853",
"0.7100124",
"0.7099024",
"0.7032544",
"0.7022527",
"0.6957133",
"0.6374656",
"0.63612366",
"0.6234849",
"0.6194527",
"0.6192426",
"0.61858934",
"0.6176256",
"0.61386317",
"0.6112563",
"0.61066556",
"0.60895455",
"0.6060279",
"0.6034259",
"0.6027615",
"0.59995145... | 0.73918635 | 0 |
Calibration changed event, publish the markers and the calibration data to ROS | def calibration_changed(self):
for marker in self.marker_array.markers:
marker.action = Marker.DELETE
for idx, pose in enumerate(self.poses):
marker = Marker()
marker.id = int(str(int(round(time.time() * 1000)) + idx)[6:])
marker.header.frame_id = Calibr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _doCalibration(self):\n self._cmdCalibration(2)",
"def rDataChanged(self):\n\n self._queues.uResolutionTab.refreshData()\n self._layerManager.updateReviewLayer()",
"def fDataChanged(self):\n\n self._layerManager.getAimsFeatures()",
"def XPLMDataChanged_f(inRefcon):",
"def ge... | [
"0.59780914",
"0.5974194",
"0.57603115",
"0.5716506",
"0.5700313",
"0.56652844",
"0.551917",
"0.550133",
"0.548774",
"0.546406",
"0.54577005",
"0.5453123",
"0.5446209",
"0.54401296",
"0.5424774",
"0.5401204",
"0.53942555",
"0.5393695",
"0.5350199",
"0.5338598",
"0.5327624",
... | 0.7535387 | 0 |
Add new model point to the calibration points | def add(self, p):
self.poses.append(CalibrationPoint(p))
self.selected_point = len(self.poses) - 1
self.calibration_changed() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit(self, p):\n self.poses[self.selected_point].model = p\n self.calibration_changed()",
"def add_point(self, xx, fx):\n dim = len(xx)\n self._realloc(dim)\n self.x[self.nump, :] = xx\n self.fx[self.nump, :] = fx\n self.nump += 1\n # Update the leave-o... | [
"0.69154406",
"0.6766578",
"0.6623721",
"0.6548858",
"0.6522341",
"0.6482697",
"0.6431424",
"0.63752323",
"0.63269496",
"0.6270424",
"0.6258767",
"0.62286866",
"0.6175748",
"0.6123516",
"0.61176217",
"0.61059564",
"0.6047522",
"0.5996935",
"0.59870833",
"0.5979229",
"0.593303... | 0.7142621 | 0 |
Edit the seleted model point | def edit(self, p):
self.poses[self.selected_point].model = p
self.calibration_changed() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _point_edited(self, _var_name, _list_index, _operation):\r\n #update the point only if:\r\n #- the user edited the var (not just a point selection)\r\n #- the input string can be parsed to ints\r\n if (not self.inhibit_callbacks and\r\n is_float(self.editable_x.get())... | [
"0.7051569",
"0.67868155",
"0.6757438",
"0.66552246",
"0.65705884",
"0.6387175",
"0.6364775",
"0.6216918",
"0.62072617",
"0.59917426",
"0.5985266",
"0.59831333",
"0.59759885",
"0.5964893",
"0.58861",
"0.5845197",
"0.58253455",
"0.5799752",
"0.57940185",
"0.5790111",
"0.579011... | 0.7967514 | 0 |
Remove selected calibration point | def remove(self):
if self.selected_point is None:
RosProxy().notify("No calibration point selected", STATE.ERROR)
return
if len(self.poses) == 0:
RosProxy().notify("No calibration point added", STATE.ERROR)
return
self.poses.remove(self.poses[se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_selection(self):\n if self.selected_point_index is not None:\n del self.current_shape[self.selected_point_index]\n self.selected_point_index = None\n self.changed()",
"def rm_calibration(self):\n\n self.bin_edges_kev = None",
"def removePick(self):\n ... | [
"0.7046191",
"0.68148166",
"0.6728017",
"0.6607091",
"0.6529173",
"0.63954777",
"0.6347519",
"0.60552454",
"0.6048657",
"0.6048657",
"0.60466725",
"0.6028333",
"0.601033",
"0.60037434",
"0.60037434",
"0.5995959",
"0.5992583",
"0.59890836",
"0.5910162",
"0.5888631",
"0.5885889... | 0.8378994 | 0 |
Load a default calibration as an example | def load_default(self):
poses = []
cp = CalibrationPoint(Pose(), Pose())
cp.measured.position = Point(0.0, 0.0, 0.12)
cp.measured.orientation.x = -0.025
cp.measured.orientation.y = 1.
cp.measured.orientation.z = 0.011
cp.measured.orientation.w = 0.002
cp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__ (self) :\n self.loadCSPAD2x2CalibParsDefault()",
"def load_cal(self):\n global DEBUG, dtParameterDesc\n if DEBUG:\n print(self.__class__.__name__+'.load_cal(): calibration is loaded')\n if 'refatt' in self.parameters and 'refoutpower' in self.parameters:\n ... | [
"0.64449143",
"0.62831944",
"0.59671456",
"0.5753438",
"0.5722229",
"0.570451",
"0.5687627",
"0.5635133",
"0.558993",
"0.55866563",
"0.55388427",
"0.55273575",
"0.5505142",
"0.5503746",
"0.5497588",
"0.5470468",
"0.5460154",
"0.5457385",
"0.5434277",
"0.5433322",
"0.54281676"... | 0.6843389 | 0 |
Same as cloudvolume.paths.extract, but raise an additional cloudvolume.exceptions.UnsupportedProtocolError if either dataset or layer is not set. | def strict_extract(cloudpath, windows=None, disable_toabs=False):
path = extract(cloudpath, windows, disable_toabs)
if path.dataset == '' or path.layer == '':
raise UnsupportedProtocolError(cloudpath_error(cloudpath))
return path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract(cloudpath, windows=None, disable_toabs=False):\n if len(cloudpath) == 0:\n return ExtractedPath('','','','','','','')\n\n windows_file_re = re.compile(r'((?:\\w:\\\\)[\\d\\w_\\.\\-]+)')\n bucket_re = re.compile(r'^(/?[~\\d\\w_\\.\\-]+(?::\\d+)?)(?:\\b|$)') # posix /what/a/great/path\n \n error ... | [
"0.57432127",
"0.5345072",
"0.5141064",
"0.48350242",
"0.471617",
"0.4686658",
"0.468103",
"0.46336773",
"0.462907",
"0.46199074",
"0.46039414",
"0.45926678",
"0.4592578",
"0.45727795",
"0.45651555",
"0.4543723",
"0.45103985",
"0.4503522",
"0.4497334",
"0.44893438",
"0.448435... | 0.7009644 | 0 |
Given a valid cloudpath of the form | def extract(cloudpath, windows=None, disable_toabs=False):
if len(cloudpath) == 0:
return ExtractedPath('','','','','','','')
windows_file_re = re.compile(r'((?:\w:\\)[\d\w_\.\-]+)')
bucket_re = re.compile(r'^(/?[~\d\w_\.\-]+(?::\d+)?)(?:\b|$)') # posix /what/a/great/path
error = UnsupportedProtocolErro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_validate(path):\n # functionality to be added later\n return path",
"def validate_short_path(short_path):",
"def parse_managed_path(path):\n fields = path.split(':', 1)\n return fields[0], fields[1]",
"def clean_path(self, path):\n if('.flaccuesplit.' in path):\n ... | [
"0.5782255",
"0.5485256",
"0.5111033",
"0.5109678",
"0.5098054",
"0.4996147",
"0.49742427",
"0.4955958",
"0.49552155",
"0.49309495",
"0.49085343",
"0.49030942",
"0.48504016",
"0.48399198",
"0.48375192",
"0.48148483",
"0.47820082",
"0.47807506",
"0.47638345",
"0.47635552",
"0.... | 0.5554715 | 1 |
Extract tags and mentions from a string. Returns a tuple with a set of tags and mentioned users, if they exist. | def extract_tags_and_mentions(s: str) -> typing.Tuple[set, set]:
if not s:
return set(), set()
# Build a set after stripping the # or @ sign before every item found with
# the regular expression.
tags = set(t for t in find_hashtags_re.findall(s))
mentions = set(m[1:] for m in find_mentions_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tagged_user(line, unique_users):\n tagged_user = None\n\n for user in unique_users:\n \n tagged_user = re.search(f\"@{user}\\s*\", line)\n \n if tagged_user != None:\n tagged_user = tagged_user.group(0).replace(\"@\", \"\").strip()\n line = line.replace(f\"@{... | [
"0.5984887",
"0.5866291",
"0.5816416",
"0.57498",
"0.57427794",
"0.56972706",
"0.5674774",
"0.5634183",
"0.5608683",
"0.5608683",
"0.5608683",
"0.5608683",
"0.5608683",
"0.56065565",
"0.56022114",
"0.55869055",
"0.55849683",
"0.5581752",
"0.5581752",
"0.5576589",
"0.5564691",... | 0.8448166 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.