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 |
|---|---|---|---|---|---|---|
Merge an existing AbideRegistry into this one, keeping properties already present in this one and only merging properties that don't yet exist. | def merge(self, registry):
for property_name, property_item in registry.items():
if property_name not in self:
self.set_property(property_item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n return self.update({})",
"def _merge(self, other: dict):\n self._storage = dict_merge(self._storage, other)",
"def merge(self, other):\n merged = copy.deepcopy(self.__dict__())\n for k, v in other.__dict__():\n if k in merged and getattr(self, k):\n ... | [
"0.55507815",
"0.55414605",
"0.532423",
"0.53020734",
"0.5290227",
"0.5225598",
"0.5142893",
"0.51419336",
"0.51071876",
"0.5073005",
"0.50702655",
"0.50646394",
"0.50576466",
"0.49336034",
"0.49330747",
"0.49016225",
"0.48852488",
"0.48832685",
"0.488003",
"0.4870947",
"0.48... | 0.6592531 | 0 |
change nubmber of missing, whle fixing k, qi and size of dataset | def get_result_missing(att_trees, data, k=DEFAULT_K, n=DEFAULT_K):
data_back = copy.deepcopy(data)
length = len(data_back)
qi_len = len(data[0]) - 1
raw_missing = raw_missing_record = 0
print "K=%d" % k
for record in data:
flag = False
for value in record:
if value ==... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pivot_num(data: PandasDF, var: str, performance: str = 'bad_ind',\n n: int = 10, ks: float = True, max_ks_only: float = False) -> PandasDF:\n temp = data.loc[:, [var, performance]].copy()\n temp_missing = temp.loc[temp[var].isnull(), :]\n temp_noMissing = temp.loc[~temp[var].isnull(), :]\... | [
"0.5625626",
"0.5465201",
"0.54609203",
"0.53622466",
"0.52481824",
"0.5229756",
"0.5151207",
"0.51455116",
"0.5095228",
"0.509389",
"0.5092229",
"0.5091221",
"0.50859225",
"0.50685453",
"0.5050776",
"0.50357234",
"0.50298697",
"0.4998754",
"0.49985066",
"0.49860984",
"0.4981... | 0.6014288 | 0 |
Transforms the given source dict to a target dict based on the implemented ruleset. | def transform(self, source: dict) -> dict:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subst_dict(target, source):\n dict = {}\n\n if target:\n def get_tgt_subst_proxy(thing):\n try:\n subst_proxy = thing.get_subst_proxy()\n except AttributeError:\n subst_proxy = thing # probably a string, just return it\n return subst_p... | [
"0.6293355",
"0.6013593",
"0.5974697",
"0.58764845",
"0.5870711",
"0.5825023",
"0.58013415",
"0.5561623",
"0.55460215",
"0.5544287",
"0.55300653",
"0.5520241",
"0.55021775",
"0.54956675",
"0.5470732",
"0.5413718",
"0.5398131",
"0.5393067",
"0.5354263",
"0.5331905",
"0.5330366... | 0.7035352 | 0 |
Searches for the specified node in the target dict object for further processing. | def _node_search(self, mapping: WizardDataMappingBaseEnum, root_node: str, target_dict: dict) -> tuple:
keys = mapping.get_registration_field_reference(root_node).split(".")
max_depth: int = len(keys) - 1
return self._recursive_search(target_dict, keys, max_depth) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findNode(self, target: hash.hash.Hash):\n for bucket in self.buckets:\n if bucket.inRange(nodeID):\n for node in bucket:\n if node.hash == target:\n return node\n \n return None\n return None... | [
"0.6458002",
"0.636581",
"0.6159206",
"0.60092944",
"0.57412994",
"0.57050276",
"0.5686447",
"0.56060046",
"0.5532294",
"0.55157566",
"0.54548234",
"0.5422413",
"0.53641313",
"0.53610045",
"0.5332658",
"0.5328531",
"0.53281033",
"0.53203183",
"0.530248",
"0.5295509",
"0.52568... | 0.6678959 | 0 |
Returns summary for the clustering in form of which objects were assigned to which cluster and how many samples of each object were assigned to which cluster. | def summarize(k, samples):
cluster_assignments = dict()
sample_assignments = dict()
unique, counts = np.unique(samples[:, 0], return_counts=True)
sample_objects = dict(zip(unique, counts))
for oid in sample_objects:
# count the number of samples that belonged to each cluster for this object
sample_assignments... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_overview(self) -> None:\n print(f\"\\n\\nCluster overview:\")\n all_clusters = self.get_all_clusters()\n print(f\" - Total of {len(all_clusters)} clusters\")\n if all_clusters:\n cluster_lengths = [len(v) for v in all_clusters.values()]\n print(f\" - Avera... | [
"0.7024156",
"0.67413795",
"0.65553635",
"0.6400142",
"0.6399458",
"0.63829273",
"0.63645506",
"0.63288116",
"0.6261311",
"0.62351966",
"0.62264615",
"0.62164265",
"0.61641264",
"0.6156463",
"0.6149437",
"0.6143532",
"0.6119567",
"0.6118515",
"0.61017936",
"0.6093622",
"0.607... | 0.7156205 | 0 |
Temporary function that configures logging to go straight to console. | def setup_logging():
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
console = logging.StreamHandler(sys.stdout)
console.setLevel(logging.DEBUG)
console.setFormatter(formatter)
root = logging.getLogger()
root.addHandler(console)
root.setLevel(logging.DEB... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_console_logger ():\n\t\tconsole = logging.StreamHandler()\n\t\tconsole.setLevel(logging.INFO) # Change level for console logger in development mode\n\t\tformatter = logging.Formatter('%(levelname)-8s %(message)s')\n\t\tconsole.setFormatter(formatter)\n\t\tlogging.getLogger('').addHandler(console)",
... | [
"0.7744444",
"0.7212908",
"0.71922755",
"0.6954237",
"0.6946993",
"0.6937946",
"0.6893693",
"0.68809277",
"0.68545187",
"0.684831",
"0.6822329",
"0.67961013",
"0.67405695",
"0.67387825",
"0.6733418",
"0.6722712",
"0.6687495",
"0.6649076",
"0.6637922",
"0.6631609",
"0.6619285"... | 0.7359638 | 1 |
Sets default configuration values for pokered. These should eventually be moved into the configuration module. | def configure_for_pokered(config=config):
attrs = {
"version": "red",
"map_dir": os.path.join(config.path, 'maps/'),
"gfx_dir": os.path.join(config.path, 'gfx/tilesets/'),
"to_gfx_name": red_gfx_name,
"block_dir": os.path.join(config.path, 'gfx/blocksets/'), # not used
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config_init(self):\n\n game_opts = [\n\n # Execution Options\n ('debug',False), # Toggle Debug Messaging\n ('log_path',False), # Turn on logging (w/path)\n ('log_lvl',logging.DEBUG), # Set log level\n\n # World Generation Opti... | [
"0.68206334",
"0.66279453",
"0.64431655",
"0.64198345",
"0.64198345",
"0.64198345",
"0.6298531",
"0.62911874",
"0.62797886",
"0.6273936",
"0.6201167",
"0.61984444",
"0.6187273",
"0.61839336",
"0.6172492",
"0.61234754",
"0.60714173",
"0.60698897",
"0.6066412",
"0.6030387",
"0.... | 0.6774129 | 1 |
Sets default configuration values for pokecrystal. These should eventually be moved into the configuration module. | def configure_for_pokecrystal(config=config):
attrs = {
"version": "crystal",
"map_dir": os.path.join(config.path, 'maps/'),
"gfx_dir": os.path.join(config.path, 'gfx/tilesets/'),
"to_gfx_name": lambda x : '%.2d' % x,
"block_dir": os.path.join(config.path, 'tilesets/'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initConfiguration():\n UTIL.SYS.s_configuration.setDefaults([\n [\"SYS_COLOR_LOG\", \"1\"],\n [\"HOST\", \"127.0.0.1\"],\n [\"NCTRS_TM_SERVER_PORT\", \"2502\"],\n [\"NCTRS_TM_DU_VERSION\", \"V0\"],\n [\"SPACECRAFT_ID\", \"758\"]])",
"def setdefaults(self):\n self.config = {\n ... | [
"0.6538164",
"0.65269065",
"0.6479381",
"0.638243",
"0.63516474",
"0.63516474",
"0.63516474",
"0.62303483",
"0.61623925",
"0.6151685",
"0.61513054",
"0.59917414",
"0.5970082",
"0.59475154",
"0.59347796",
"0.5927527",
"0.5883482",
"0.5882603",
"0.5876634",
"0.58725595",
"0.585... | 0.6968128 | 0 |
Route for the processing of an essay submitted by POST request | def essay_post_new():
text0 = request.form['text']
essay = {}
status = 200
if (app.debug is True):
essay = Flask_process_text(text0)
else:
try:
essay = Flask_process_text(text0)
except Exception as e:
## Any unsupported exceptions coming fr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self):",
"def post():\n pass",
"def post(self, request):\n pass",
"def do_POST(self):\r\n self._send_handler_response('POST')",
"def post(self):\n pass",
"def post(self):\n pass",
"def post(self):\n pass",
"def post(self):\n pass",
"def post... | [
"0.6570866",
"0.65123093",
"0.6362852",
"0.6359819",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63241047",
"0.63001585",
"0.6274297",
... | 0.6817374 | 0 |
Class decorator. Takes a dictionary of mapping from keybind > signal. If one of the keybinds is detected, the specified signal is sent with the calling object as the only argument. | def signal_map(mapping):
def decorator(cls):
if not hasattr(cls, 'signals'):
return cls
cls.__keymap = mapping
def keypress(self, size, key):
if key in self.__keymap:
signal = self.__keymap[key]
logger.debug("Keypress '{}' sent signa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_forwards_args(self):\n seen_kwargs = {}\n\n def callback(**kwargs):\n seen_kwargs.update(kwargs)\n\n SignalHook(self.test_extension, self.signal, callback)\n self.signal.send(sender=self, foo=1, bar=2)\n\n self.assertTrue('foo', seen_kwargs)\n self.asse... | [
"0.56830674",
"0.56747514",
"0.56612265",
"0.5526517",
"0.5519064",
"0.55119467",
"0.5493346",
"0.54629815",
"0.53654486",
"0.5305662",
"0.5279558",
"0.52793956",
"0.5256346",
"0.52491015",
"0.5239506",
"0.5238507",
"0.5208698",
"0.52058035",
"0.5129249",
"0.51212853",
"0.510... | 0.75173485 | 0 |
Downloads a discovery document for the given api_name and version. This utility assumes that the API for which a discovery document is being retrieved is publicly accessible. However, you may access whitelisted resources for a public API if you are added to its whitelist and specify the associated label. | def DownloadDiscoveryDocument(api_name, version, path=_DEFAULT_DISCOVERY_PATH,
label=None):
credentials = _GetCredentials()
auth_session = AuthorizedSession(credentials)
discovery_service = build('discovery', 'v1')
discovery_rest_url = None
discovery_response = discovery_service... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def document_api(\n name, version, uri, doc_destination_dir, artifact_destination_dir=DISCOVERY_DOC_DIR\n):\n http = build_http()\n resp, content = http.request(\n uri\n or uritemplate.expand(\n FLAGS.discovery_uri_template, {\"api\": name, \"apiVersion\": version}\n )\n ... | [
"0.72981805",
"0.6734526",
"0.64512706",
"0.6035877",
"0.5581646",
"0.54990536",
"0.5306303",
"0.52876794",
"0.52130306",
"0.5148488",
"0.5062018",
"0.5056105",
"0.50496435",
"0.5046927",
"0.5018025",
"0.50053316",
"0.4952479",
"0.48979062",
"0.4880371",
"0.4877402",
"0.48739... | 0.85871446 | 0 |
Builds the Google Cloud Pub/Sub service for the specified version. | def GetCloudPubSubService(version):
credentials = _GetCredentials()
service = build('pubsub', version, credentials=credentials)
return service | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_subresource(servicePath,\n version,\n **kargs):\n splits = servicePath.split('.')\n serviceName = splits[0]\n subresources = splits[1:]\n\n client = discovery.build(serviceName, version, **kargs)\n\n for subresource in subresources:\n subres... | [
"0.57153666",
"0.5608188",
"0.52320915",
"0.5231218",
"0.5215677",
"0.5124253",
"0.49410287",
"0.4928817",
"0.4889315",
"0.47986013",
"0.47937685",
"0.47748703",
"0.47745627",
"0.4770796",
"0.47336197",
"0.47038734",
"0.47037455",
"0.46962577",
"0.46865353",
"0.46845642",
"0.... | 0.75297475 | 0 |
Builds the realtimebidding service for the specified version. | def GetService(version=_DEFAULT_VERSION, developer_key=None):
credentials = _GetCredentials()
if version in _REALTIME_BIDDING_VERSIONS:
# Initialize client for the Real-Time Bidding API.
service = build(_REALTIME_BIDDING_API_NAME, version, credentials=credentials,
developerKey=developer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_instance(cls,\n version: date,\n service_name: str = DEFAULT_SERVICE_NAME,\n ) -> 'DirectLinkApisV1':\n if version is None:\n raise ValueError('version must be provided')\n\n authenticator = get_authenticator_from_environme... | [
"0.5569035",
"0.552676",
"0.5366935",
"0.51349723",
"0.5069962",
"0.50330245",
"0.49777514",
"0.49529108",
"0.49461666",
"0.49356827",
"0.49331987",
"0.4930468",
"0.4911512",
"0.4851224",
"0.48050913",
"0.47942278",
"0.47915474",
"0.4762772",
"0.47495747",
"0.47264645",
"0.47... | 0.6628569 | 0 |
Builds a service using the specified discovery document. | def GetServiceFromFile(discovery_file):
credentials = _GetCredentials()
with open(discovery_file, 'r') as handler:
discovery_doc = handler.read()
service = build_from_document(service=discovery_doc, credentials=credentials)
return service | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def document_api_from_discovery_document(\n discovery_url, doc_destination_dir, artifact_destination_dir=DISCOVERY_DOC_DIR\n):\n http = build_http()\n response, content = http.request(discovery_url)\n discovery = json.loads(content)\n\n service = build_from_document(discovery)\n\n name = discover... | [
"0.64967304",
"0.6030143",
"0.589598",
"0.5847395",
"0.5738073",
"0.56972104",
"0.56820416",
"0.5582655",
"0.5537132",
"0.55302894",
"0.5434771",
"0.54292744",
"0.5420864",
"0.5398877",
"0.53854674",
"0.5381908",
"0.5316397",
"0.53089416",
"0.5304767",
"0.5292204",
"0.5289053... | 0.6653792 | 0 |
Return an inspyred crossover function based on the given function. This function generator takes a function that operates on only two parent candidates to produce an iterable sequence of offspring (typically two). The generator handles the pairing of selected parents and collecting of all offspring. The generated funct... | def crossover(cross):
@functools.wraps(cross)
def inspyred_crossover(random, candidates, args):
if len(candidates) % 2 == 1:
candidates = candidates[:-1]
moms = candidates[::2]
dads = candidates[1::2]
children = []
for i, (mom, dad) in enumerate(zip(moms, dads... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crossover(cross):\r\n @functools.wraps(cross)\r\n def ecspy_crossover(random, candidates, args):\r\n if len(candidates) % 2 == 1:\r\n candidates = candidates[:-1]\r\n moms = candidates[::2]\r\n dads = candidates[1::2]\r\n children = []\r\n for i, (mom, dad) i... | [
"0.75560653",
"0.59480983",
"0.5935825",
"0.5895034",
"0.5812965",
"0.5759852",
"0.5736582",
"0.5733353",
"0.5718653",
"0.57111734",
"0.57025594",
"0.56801486",
"0.5678542",
"0.5672112",
"0.56708926",
"0.5608201",
"0.552107",
"0.5520685",
"0.5502717",
"0.5495076",
"0.5481087"... | 0.7708781 | 0 |
Return the offspring of uniform crossover on the candidates. This function performs uniform crossover (UX). For each element of the parents, a biased coin is flipped to determine whether the first offspring gets the 'mom' or the 'dad' element. An optional keyword argument in args, ``ux_bias``, determines the bias. | def uniform_crossover(random, mom, dad, args):
ux_bias = args.setdefault('ux_bias', 0.5)
crossover_rate = args.setdefault('crossover_rate', 1.0)
children = []
if random.random() < crossover_rate:
bro = copy.copy(dad)
sis = copy.copy(mom)
for i, (m, d) in enumerate(zip(mom, dad)):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uniform_crossover(random, mom, dad, args):\r\n ux_bias = args.setdefault('ux_bias', 0.5)\r\n crossover_rate = args.setdefault('crossover_rate', 1.0)\r\n children = []\r\n if random.random() < crossover_rate:\r\n bro = copy.copy(dad)\r\n sis = copy.copy(mom)\r\n for i, (m, d) in... | [
"0.61603284",
"0.57518995",
"0.51962733",
"0.51483315",
"0.512234",
"0.4940673",
"0.4929111",
"0.49239802",
"0.48817232",
"0.48575172",
"0.48472595",
"0.4789144",
"0.47818902",
"0.47776258",
"0.47735626",
"0.47145042",
"0.46981046",
"0.46507037",
"0.46464217",
"0.46441185",
"... | 0.62081856 | 0 |
Return the offspring of arithmetic crossover on the candidates. This function performs arithmetic crossover (AX), which is similar to a generalized weighted averaging of the candidate elements. The allele of each parent is weighted by the ax_alpha keyword argument, and the allele of the complement parent is weighted by... | def arithmetic_crossover(random, mom, dad, args):
ax_alpha = args.setdefault('ax_alpha', 0.5)
ax_points = args.setdefault('ax_points', None)
crossover_rate = args.setdefault('crossover_rate', 1.0)
bounder = args['_ec'].bounder
children = []
if random.random() < crossover_rate:
bro = copy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _crossover(self, sel):\n offspring = []\n for p1, p2 in sel:\n p1 = copy.deepcopy(p1)\n p2 = copy.deepcopy(p2)\n\n tmp = self.op.crossover(\n copy.deepcopy(p1['individual']),\n copy.deepcopy(p2['individual']))\n if not tmp[... | [
"0.53981245",
"0.5329241",
"0.51723456",
"0.5150698",
"0.5106049",
"0.49826026",
"0.49341378",
"0.47726318",
"0.47720823",
"0.4746147",
"0.47242197",
"0.46623877",
"0.46561575",
"0.4653956",
"0.46342048",
"0.46092457",
"0.45876846",
"0.4583629",
"0.45682684",
"0.4557402",
"0.... | 0.5358517 | 1 |
Return the offspring of blend crossover on the candidates. This function performs blend crossover (BLX), which is similar to arithmetic crossover with a bit of mutation. It creates offspring whose values are chosen randomly from a range bounded by the parent alleles but that is also extended by some amount proportional... | def blend_crossover(random, mom, dad, args):
blx_alpha = args.setdefault('blx_alpha', 0.1)
blx_points = args.setdefault('blx_points', None)
crossover_rate = args.setdefault('crossover_rate', 1.0)
bounder = args['_ec'].bounder
children = []
if random.random() < crossover_rate:
bro = copy.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blend_crossover(random, mom, dad, args):\r\n blx_alpha = args.setdefault('blx_alpha', 0.1)\r\n blx_points = args.setdefault('blx_points', None)\r\n crossover_rate = args.setdefault('crossover_rate', 1.0)\r\n bounder = args['_ec'].bounder\r\n children = []\r\n if random.random() < crossover_ra... | [
"0.60011",
"0.563031",
"0.55039793",
"0.5291128",
"0.52086353",
"0.517744",
"0.5123646",
"0.51229113",
"0.51227796",
"0.51224315",
"0.51028264",
"0.5100048",
"0.5081637",
"0.50476974",
"0.50207806",
"0.5018427",
"0.5007083",
"0.49650475",
"0.4952013",
"0.49350655",
"0.4870944... | 0.6025638 | 0 |
Return the offspring of simulated binary crossover on the candidates. This function performs simulated binary crossover (SBX), following the implementation in NSGAII | def simulated_binary_crossover(random, mom, dad, args):
crossover_rate = args.setdefault('crossover_rate', 1.0)
if random.random() < crossover_rate:
di = args.setdefault('sbx_distribution_index', 10)
bounder = args['_ec'].bounder
bro = copy.copy(dad)
sis = copy.copy(mom)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simulated_binary_crossover(random, mom, dad, args):\r\n crossover_rate = args.setdefault('crossover_rate', 1.0)\r\n if random.random() < crossover_rate:\r\n di = args.setdefault('sbx_distribution_index', 10)\r\n bounder = args['_ec'].bounder\r\n bro = copy.copy(dad)\r\n sis = ... | [
"0.6887202",
"0.66483",
"0.61619645",
"0.60364294",
"0.57141507",
"0.5652131",
"0.5621282",
"0.54595256",
"0.54372764",
"0.5420452",
"0.537418",
"0.5370365",
"0.5336791",
"0.5334947",
"0.53227204",
"0.53013736",
"0.5299903",
"0.52882814",
"0.52813506",
"0.5236538",
"0.5230506... | 0.6978185 | 0 |
Return the offspring of Laplace crossover on the candidates. This function performs Laplace crosssover (LX), following the implementation specified in (Deep and Thakur, "A new crossover operator for real coded genetic algorithms," Applied Mathematics and Computation, Volume 188, Issue 1, May 2007, pp. 895911). This fun... | def laplace_crossover(random, mom, dad, args):
crossover_rate = args.setdefault('crossover_rate', 1.0)
if random.random() < crossover_rate:
bounder = args['_ec'].bounder
a = args.setdefault('lx_location', 0)
b = args.setdefault('lx_scale', 0.5)
bro = copy.copy(dad)
sis = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _crossover(self, sel):\n offspring = []\n for p1, p2 in sel:\n p1 = copy.deepcopy(p1)\n p2 = copy.deepcopy(p2)\n\n tmp = self.op.crossover(\n copy.deepcopy(p1['individual']),\n copy.deepcopy(p2['individual']))\n if not tmp[... | [
"0.58404624",
"0.57481474",
"0.57417303",
"0.57125723",
"0.56641746",
"0.5645168",
"0.5642679",
"0.5457934",
"0.5456284",
"0.54418725",
"0.53179973",
"0.5301446",
"0.52797896",
"0.52770644",
"0.5192121",
"0.5158112",
"0.51519334",
"0.5137148",
"0.51297754",
"0.51172304",
"0.5... | 0.57764274 | 1 |
Parse a key=value=type command line arg that comes in a list. Returns Dictionary of options with the correct types. | def parse_options(option_list: List[str]) -> Dict[str, Union[int, float, str]]:
d = dict()
for o in option_list:
o = o.split('=')
if len(o) != 3:
raise OptionParsingError("Not enough elements in the parsed options. Need 3 elements.")
key = o[0]
val = o[1]
if o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_arg_list(self):\n\t\targ_list = {}\n\t\tfor arg in getopt.getopt(sys.argv[1:], 'c:r:j:d')[0]:\n\t\t\targ_list[arg[0][1:]] = arg[1]\n\t\n\t\treturn arg_list",
"def parse_kwargs(kwargs_list: List[str]) -> Dict[str, Any]:\n\n kwargs_dict = {}\n\n for kwarg in kwargs_list:\n key = kwarg[2:].s... | [
"0.69291884",
"0.6713729",
"0.66098994",
"0.654922",
"0.6441218",
"0.6433154",
"0.64158493",
"0.6372566",
"0.6308097",
"0.62898046",
"0.6267641",
"0.62230957",
"0.6189013",
"0.6167051",
"0.6166115",
"0.616541",
"0.61501485",
"0.6109313",
"0.6103926",
"0.6084132",
"0.6078017",... | 0.7624646 | 0 |
Encode an option dict into a command line string that cascade_at can understand. Returns List of strings that can be passed to the command line.. | def encode_options(options: Dict[str, Union[str, float, int]]) -> List[str]:
d = list()
rev_dict = {v: k for k, v in type_mappings.items()}
for k, v in options.items():
t = type(v)
if t not in rev_dict:
raise OptionParsingError(f"Unknown option type {t}.")
arg = f'{k}={v}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_options(options, return_list=True):\n\n cmd_options = []\n\n for key, value in options.items():\n\n if value is not None:\n txt = f\"--{key} {value}\"\n else:\n txt = f\"--{key}\"\n\n cmd_options.append(txt)\n\n if return_list:\n return cmd_optio... | [
"0.6672936",
"0.6576634",
"0.64632386",
"0.6266173",
"0.61365074",
"0.61365074",
"0.612159",
"0.60841817",
"0.6073305",
"0.6043996",
"0.59815985",
"0.59466445",
"0.59257406",
"0.58806074",
"0.586232",
"0.5844024",
"0.58317894",
"0.5820227",
"0.5800517",
"0.5799547",
"0.579950... | 0.7084254 | 0 |
Parse the dismod commands that come from command line arguments in a list. Returns list of commands that dismod can understand | def parse_commands(command_list: List[str]) -> List[str]:
return [' '.join(x.split('-')) for x in command_list] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_commands(self, commands: List[str]):",
"def cmd_list(args):",
"def parse_commands(args):\n\n # command flags, mapped to their function.\n commands = {\n '-l': {\n 'aliases': ['--list'],\n 'func': do_list,\n 'kwargs': None,\n },\n '-h': {\n... | [
"0.68276083",
"0.6675786",
"0.66491014",
"0.6639968",
"0.66223323",
"0.651876",
"0.65133154",
"0.64849234",
"0.64712006",
"0.6466917",
"0.63955957",
"0.63948977",
"0.6363335",
"0.6358228",
"0.6328111",
"0.63193023",
"0.6306998",
"0.62842536",
"0.6258902",
"0.6255466",
"0.6252... | 0.7127569 | 0 |
Converts an argument to a flag, like model_version_id to modelversionid. | def _arg_to_flag(name: str) -> str:
arg = '-'.join(name.split('_'))
return f'--{arg}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _flag_to_arg(flag: str) -> str:\n arg = flag.split('--')[1].split('-')\n arg = '_'.join(arg)\n return arg",
"def _arg_to_command(k: str, v: Optional[Union[str, int, float]] = None):\n command = _arg_to_flag(k)\n if v is not None:\n command += f' {v}'\n return command",
"def flag_ke... | [
"0.6590305",
"0.5745334",
"0.55384004",
"0.54860014",
"0.52809024",
"0.52305204",
"0.5170556",
"0.5114146",
"0.50949305",
"0.5084797",
"0.5046727",
"0.5032376",
"0.49962172",
"0.49942017",
"0.49607122",
"0.49438405",
"0.491969",
"0.4874299",
"0.48694623",
"0.48176888",
"0.480... | 0.70808184 | 0 |
Splits a flag that looks like modelversionid into an argument that looks like model_version_id. | def _flag_to_arg(flag: str) -> str:
arg = flag.split('--')[1].split('-')
arg = '_'.join(arg)
return arg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _arg_to_flag(name: str) -> str:\n arg = '-'.join(name.split('_'))\n return f'--{arg}'",
"def _parse_flags(self, flags):\n s = ''\n for flag in flags:\n if len(s):\n s += ' | '\n s += 'gf.sim.VariableFlag.%s' % (flag)\n if len(s):\n return s\n else:\n return '0'",
... | [
"0.5780041",
"0.5571187",
"0.5545629",
"0.5502681",
"0.54060006",
"0.5399714",
"0.52989393",
"0.5282142",
"0.5276059",
"0.52680475",
"0.5203346",
"0.51975304",
"0.51257795",
"0.50831616",
"0.5066755",
"0.50496227",
"0.5044899",
"0.50396246",
"0.49897784",
"0.4975387",
"0.4965... | 0.64214563 | 0 |
Convert an argument name to an "empty" placeholder for an argument to later be filled in. Used by the jobmon TaskTemplate. E.g. takes something that looks like "model_version_id" and converts it to "{model_version_id}" | def _arg_to_empty(name: str) -> str:
arg = "{" + name + "}"
return arg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_arg_name(self, arg, variable_name):",
"def arg_name(name):\n return \"--\" + name.replace('_', '-')",
"def argument(arg, default):\n return \"{0}={1}\".format(arg, default) if default else arg",
"def variable_argument(self):\n if self.is_variadic():\n if self.args... | [
"0.6888572",
"0.66297895",
"0.6515924",
"0.62020886",
"0.61162794",
"0.60101515",
"0.59318465",
"0.59016836",
"0.5827356",
"0.57620907",
"0.5743553",
"0.57284564",
"0.5666781",
"0.56305546",
"0.56073815",
"0.55728793",
"0.5566801",
"0.55580854",
"0.55580854",
"0.5548567",
"0.... | 0.7613815 | 0 |
Takes a key (k) and a value (v) and turns it into a commandline argument like k=model_version v=1 and returns modelversion 1. If empty, returns an a template command rather than the command itself | def _arg_to_command(k: str, v: Optional[Union[str, int, float]] = None):
command = _arg_to_flag(k)
if v is not None:
command += f' {v}'
return command | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def command_friendly_kv_pair(dict):\n # subprocess.run expects parameters to be in the foo=bar format. We build this format here and return a list\n output = []\n for key, value in dict.items():\n output.append('%s=%s' % (key, value))\n return output",
"def get_key_command(client: KeyVaultClie... | [
"0.6279236",
"0.6083482",
"0.57848155",
"0.5633048",
"0.5611898",
"0.55644727",
"0.55293155",
"0.5340225",
"0.53104573",
"0.5288793",
"0.5262455",
"0.5247463",
"0.51920956",
"0.51567817",
"0.5098501",
"0.50756335",
"0.5070354",
"0.5051675",
"0.503861",
"0.50332874",
"0.503328... | 0.68132955 | 0 |
A class that does operations on a list of arguments. | def __init__(self, arg_list: List[_Argument]):
self.arg_list: List[_Argument] = arg_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_args(args):\n run_list_args(args)",
"def create_argument_list(self):\n raise NotImplementedError",
"def parse_list_args(args):\n\n args.image_transformers = parse_transformers(args.image_transformers)\n args.tensor_transformers = parse_transformers(args.tensor_transformers)\n args.t... | [
"0.6630469",
"0.63799804",
"0.6223992",
"0.61640614",
"0.61035067",
"0.6083365",
"0.60742",
"0.6046261",
"0.60256857",
"0.600408",
"0.59836245",
"0.5931386",
"0.5906878",
"0.5883545",
"0.5882717",
"0.58796144",
"0.587377",
"0.58663076",
"0.5862648",
"0.58600634",
"0.58468693"... | 0.6529208 | 1 |
Converts list of arguments to an ArgumentParser. | def _to_parser(self) -> ArgumentParser:
parser = ArgumentParser()
for arg in self.arg_list:
parser.add_argument(arg._flag, **arg._parser_kwargs)
return parser | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arg_parse():\n p = ap.ArgumentParser()\n p.add_argument()\n return p.parse_args()",
"def build_argument_parser():\n description=\"A simple tool to batch rename given files.\"\n parser = ArgumentParser(description=description)\n parser.add_argument(\"-i\", \"--input-list\", required=False,\n... | [
"0.6689526",
"0.66418236",
"0.65175176",
"0.6508834",
"0.6451397",
"0.6451397",
"0.64353776",
"0.642825",
"0.64202136",
"0.6392615",
"0.6363931",
"0.63528883",
"0.6325844",
"0.6324088",
"0.6311919",
"0.6261066",
"0.6239911",
"0.62153864",
"0.61830664",
"0.6181541",
"0.6175291... | 0.7810521 | 0 |
Parses arguments from a list of arguments into an argument namespace using ArgumentParser.parse_args(). Also decodes potential dismod commands and options. | def parse_args(self, args: List[str]) -> Namespace:
parser = self._to_parser()
args = parser.parse_args(args)
if hasattr(args, 'dm_commands'):
if args.dm_commands is not None:
args.dm_commands = parse_commands(args.dm_commands)
else:
args.d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_arguments(args):",
"def _parse_args(self, cmd_line_list):\n parser = ArgumentParser()\n parser.add_argument('--yaml', help='yaml file specifying config to run')\n args = parser.parse_args(cmd_line_list)\n return vars(args)",
"def _parse_args(self):\n parser = argpar... | [
"0.7105361",
"0.67964506",
"0.6789828",
"0.67334574",
"0.6713294",
"0.67111045",
"0.6589387",
"0.6570861",
"0.65562314",
"0.6522016",
"0.65109265",
"0.6507887",
"0.6491577",
"0.6470998",
"0.6409037",
"0.63932204",
"0.63873875",
"0.6382316",
"0.6366575",
"0.6359192",
"0.635619... | 0.74812925 | 0 |
Creates a template of arguments from an argument list. Will return something that looks like "{argument1} {argument2}" | def template(self) -> str:
arguments = []
for arg in self.arg_list:
flag = arg._flag
arg = _flag_to_arg(flag)
placeholder = _arg_to_empty(arg)
arguments.append(placeholder)
return ' '.join(arguments) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def args_template():\n def required_arg_template_pat():\n return ( \n (c.paren(var_or_atomics() + opt_colon_sort_meta())) |\n var_or_atomic()\n )\n return (brace_noassign().possibly() + required_arg_template_pat().many())",
"def _create_arguments(self, args):\n ... | [
"0.65616566",
"0.6183756",
"0.6144895",
"0.60093826",
"0.5927253",
"0.58037114",
"0.5793754",
"0.57438946",
"0.5647408",
"0.56372666",
"0.56073415",
"0.5587228",
"0.5582654",
"0.5552702",
"0.55442554",
"0.54972726",
"0.5460326",
"0.5448793",
"0.5448093",
"0.5413476",
"0.54070... | 0.6726828 | 0 |
Returns the current range of valid values | def getRange(self) -> Tuple[int, int]:
return self.validator().bottom(), self.validator().top() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _full_value_range(self):\n min_value, max_value = self._raw_data.data_range\n return max_value - min_value",
"def get_range(cls, data: tuple or list) -> float:\n cls._data_validation(data)\n max_ = cls.get_max(data)\n min_ = cls.get_min(data)\n return float(max_ - min_)",
... | [
"0.7685519",
"0.70607877",
"0.70454717",
"0.6991528",
"0.6965289",
"0.6962066",
"0.6859699",
"0.68507016",
"0.68431336",
"0.6823089",
"0.68209",
"0.6793608",
"0.66680664",
"0.6633512",
"0.66233736",
"0.6601982",
"0.65988374",
"0.6583819",
"0.6581041",
"0.65713406",
"0.6556152... | 0.73728305 | 1 |
Handle change of histogram range from the range slider | def __rangeChanged(self, first, second):
tooltip = "Histogram range:\n[%g, %g]" % (first, second)
self.__rangeSlider.setToolTip(tooltip)
self.__rangeLabel.setToolTip(tooltip) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autoHistogramRange(self):\n self.vb.enableAutoRange(self.vb.XAxis, True)\n self.vb.enableAutoRange(self.vb.YAxis, True)\n # self.range = None\n # self.updateRange()\n # self.vb.setMouseEnabled(False, False)\n\n # def updateRange(self):\n # self.vb.autoRange()\n ... | [
"0.7538808",
"0.73559135",
"0.73497653",
"0.73497653",
"0.73337156",
"0.73337156",
"0.72392315",
"0.6810438",
"0.66320217",
"0.66224724",
"0.658371",
"0.65811986",
"0.65531963",
"0.6504793",
"0.64732856",
"0.6411091",
"0.6354699",
"0.6342652",
"0.62566984",
"0.62514645",
"0.6... | 0.7936009 | 0 |
Update histogram and stats from the item | def _updateFromItem(self):
item = self.getItem()
if item is None:
self.reset()
return
if not isinstance(item, self._SUPPORTED_ITEM_CLASS):
_logger.error("Unsupported item", item)
self.reset()
return
# Compute histogram and st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_values(self):\n # have to reset params to 0 when recalculating\n self.total_weight = self.total_price = self.total_value = self.total_fitness = 0\n for index, value in enumerate(self.item_stats):\n if value == 1:\n self.total_weight += self.items[index].wei... | [
"0.6690862",
"0.6283491",
"0.597615",
"0.59533566",
"0.5937633",
"0.5907779",
"0.5881812",
"0.58777666",
"0.5872015",
"0.5857613",
"0.5854136",
"0.58169454",
"0.5816622",
"0.58079773",
"0.5781084",
"0.57798415",
"0.5769755",
"0.57676035",
"0.57232594",
"0.570378",
"0.5695487"... | 0.7574821 | 0 |
Synchronises selected item with plot widget. | def _updateSelectedItem(self):
plot = self.plot
if plot is not None:
selected = plot.selection().getSelectedItems()
# Give priority to image over scatter
for klass in (items.ImageBase, items.Scatter):
for item in selected:
if isinst... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_selection(self):\n raise NotImplementedError",
"def plot_changed(self):\n self.plotType = self.ui.selectPlotType.currentText()\n self.value_changed()",
"def slotSelectFromPlot(self, selectDict):\n logger.info(' -->> emit signalSelectFromPlot ScatterPlotMainWindow !!!!!!!... | [
"0.64624995",
"0.6395857",
"0.6296318",
"0.6237512",
"0.62184864",
"0.6191139",
"0.61861914",
"0.61574066",
"0.6152853",
"0.6127451",
"0.61113685",
"0.6080558",
"0.60571474",
"0.60452074",
"0.60305876",
"0.60287696",
"0.60277885",
"0.6020022",
"0.60172886",
"0.5983049",
"0.59... | 0.7954543 | 0 |
Returns the widget displaying the histogram | def getHistogramWidget(self):
return self._getToolWindow() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def histogram(self):\r\n channel = self.ui.channel_selection.itemData(self.ui.channel_selection.currentIndex())\r\n\r\n #create a window, the reference must be stored, because the window\r\n #gets destroyed when its reference is garbage collected\r\n #make plotWindow a list and append t... | [
"0.7061277",
"0.69501203",
"0.68699145",
"0.6706122",
"0.6534066",
"0.65103215",
"0.6489858",
"0.6466796",
"0.639807",
"0.63101625",
"0.62911344",
"0.6211254",
"0.61960334",
"0.61696315",
"0.61635846",
"0.61367637",
"0.6123929",
"0.6083236",
"0.6079656",
"0.6065166",
"0.60495... | 0.82228994 | 0 |
A dualincome ruleset which uses simple rules where possible, intended mainly for testing. | def alice(
partner1_salary_compound_rate: float,
partner1_salary_plateau: float,
partner2_salary_compound_rate: float,
partner2_salary_plateau: float,
base_spending: float,
spending_luxury_compound_rate: float,
rrsp_interest_rate: float,
tfsa_interest_rate: float,
):
ruleset_func = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rules():",
"def __init__(self, left_rule, right_rule):\n Rule.__init__(self)\n self.__subrules = [left_rule, right_rule]",
"def __init__(self, left_rule, right_rule):\n Rule.__init__(self)\n self.__autorule = None\n self.__subrules = [left_rule, right_rule]",
"def... | [
"0.5862188",
"0.5724831",
"0.5615715",
"0.5579088",
"0.54993427",
"0.54069495",
"0.5384174",
"0.532144",
"0.53145355",
"0.53075856",
"0.5280832",
"0.5273101",
"0.5262033",
"0.52355766",
"0.5225133",
"0.52012074",
"0.5176728",
"0.51510364",
"0.51488656",
"0.51320904",
"0.51302... | 0.60019565 | 0 |
Save trainable variables in the model to npz file with current value of each variable in tf.trainable_variables(). | def save_trainable_variables (self , sess , savefn):
state = getattr (self , 'state' , {})
utils.train.save_trainable_variables(
sess, savefn, self._scope, **state ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, model_out_file):\n\t\tvariables_dict = {v.name: v for v in tf.global_variables()}\n\t\tvalues_dict = self.sess.run(variables_dict)\n\t\tnp.savez(open(model_out_file, 'wb'), **values_dict)",
"def savable_variables(self):\n return tf.global_variables()",
"def save(filename, vars):\n p = {}\n... | [
"0.77411115",
"0.7342082",
"0.7287824",
"0.7103885",
"0.688335",
"0.6768757",
"0.66715765",
"0.66602504",
"0.65303904",
"0.64213234",
"0.6400361",
"0.6381975",
"0.6329674",
"0.6326982",
"0.62663496",
"0.6257402",
"0.62162197",
"0.6214965",
"0.62076235",
"0.61964625",
"0.61960... | 0.774512 | 0 |
Load trainable variables from saved file. | def load_trainable_variables (self, sess, savefn):
self.state = utils.train.load_trainable_variables(sess, savefn) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_training_data(self):\n self._save_training_data()",
"def load_params_from_pickle_file(session: tf.Session,\n params_filename: Text) -> None:\n with open(params_filename, 'rb') as f:\n params = pickle.load(f)\n for var in tf.trainable_variables():\... | [
"0.71960396",
"0.70627034",
"0.6982785",
"0.69725084",
"0.6921597",
"0.6917487",
"0.6774719",
"0.6695076",
"0.6676079",
"0.6676079",
"0.66635466",
"0.6660492",
"0.6598899",
"0.6594415",
"0.6560092",
"0.6553832",
"0.6492643",
"0.64879227",
"0.6473616",
"0.64683986",
"0.6459515... | 0.82551587 | 0 |
Call func by selecting appropriate arguments from a argdict as well as kwargs | def callFuncBasedOnDict(func, argdict, **kwargs):
if argdict is None:
argdict = {}
seldict = selectArgsFromDict(func, argdict)
if kwargs is not None:
seldict.update(kwargs)
return func(**seldict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def selectArgsFromDict(func, argdict):\n return dict([(i, argdict[i]) for i in getArgs(func) if i in argdict])",
"def kwargs(kwargs):\n run_kwargs(kwargs)",
"def exec_params(call, *args, **kwargs):\n arg_spec = getattr(call, '_argspec', None)\n if arg_spec and not arg_spec.keywords:\n kwargs... | [
"0.7247215",
"0.7148424",
"0.6686485",
"0.6509613",
"0.6478772",
"0.6449938",
"0.6368157",
"0.6364912",
"0.624615",
"0.62181324",
"0.620267",
"0.61353123",
"0.6101103",
"0.6094938",
"0.6090208",
"0.59868765",
"0.59685",
"0.59656274",
"0.59288245",
"0.59287405",
"0.5921486",
... | 0.8205471 | 0 |
full test to determine whether a function is callable given arguments | def isCallableWithArgs(func, argdict):
return not missingArgs(func, argdict) and not invalidArgs(func, argdict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_callable(func: Any) -> bool:\n # noinspection PyTypeChecker\n return isinstance(func, (types.FunctionType, types.BuiltinFunctionType,\n types.MethodType, functools.partial))",
"def is_callable(o):\n return callable(o)",
"def is_callable(o):\n return isinst... | [
"0.8043053",
"0.769143",
"0.76113504",
"0.7497088",
"0.7310708",
"0.7201597",
"0.7183681",
"0.6882035",
"0.68759084",
"0.6750539",
"0.6558839",
"0.65530676",
"0.65278536",
"0.6495978",
"0.64895743",
"0.6446316",
"0.6437389",
"0.6419986",
"0.641831",
"0.6383968",
"0.6358628",
... | 0.80176526 | 1 |
function to tell what you are missing from argdict | def missingArgs(func, argdict):
return set(getRequiredArgs(func)).difference(argdict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_required_arg(*args):\n for a in args:\n if a not in arg_dict:\n return a",
"def GetMissingArguments(self):\n return []",
"def test_missing_arg_repr():\n argspec = inspect.getfullargspec(exceptional.wrap)\n assert repr(argspec.kwonlydefaults[\"message\"]) == \"<MISSING>\"... | [
"0.73363334",
"0.7244634",
"0.70374715",
"0.6803898",
"0.67266184",
"0.67114115",
"0.6554523",
"0.6470076",
"0.6388287",
"0.6375971",
"0.63278836",
"0.63259083",
"0.63241726",
"0.63233143",
"0.6309832",
"0.63031167",
"0.62901896",
"0.62558925",
"0.6230833",
"0.6225469",
"0.61... | 0.7362744 | 0 |
this function classifies objects from video dict with cvlib python package. | def classify_objects(video_dict, params, paths, vid_time_length=10, make_videos=True):
yolo_dict = {}
for video_num, (name, video) in enumerate(video_dict.items()):
print('Classifying video {}/{}.'.format(video_num, len(video_dict)))
yolo_dict[name] = {}
# loop over frames of video an... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vis_detections_video(im, class_name, dets, csv_file, csv, frame_id, thresh=0.5):\n nms_max_overlap = 0.6\n metric = nn_matching.NearestNeighborDistanceMetric(\"cosine\", 0.2, 100)\n tracker = Tracker(metric)\n detections = []\n scores = []\n h, w, _ = im.shape\n thick = int((h + w) // 300)... | [
"0.6015281",
"0.601183",
"0.5993276",
"0.5792634",
"0.5756552",
"0.5669971",
"0.56536233",
"0.5638236",
"0.56043786",
"0.5590023",
"0.5587217",
"0.55868554",
"0.55619556",
"0.5552709",
"0.5552561",
"0.5544587",
"0.55440867",
"0.549236",
"0.5492263",
"0.54880214",
"0.54424584"... | 0.730892 | 0 |
Moves the tooltip in the world frame by the given x,y,z / roll,pitch,yaw. True on success | def move_tip(x=0., y=0., z=0., roll=0., pitch=0., yaw=0.):
transform = PyKDL.Frame(PyKDL.Rotation.RPY(pitch, roll, yaw),
PyKDL.Vector(-x, -y, -z))
tip_pose = get_tip_pose()
tip_pose_kdl = posemath.fromMsg(tip_pose)
final_pose = toMsg(tip_pose_kdl * transform)
arm_comman... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move( self, event ):\n self.lastMotion = time()\n if self.follow == False: # If the follow flag is not set, motion within the widget will make the ToolTip dissapear\n self.withdraw()\n self.visible = 1\n self.geometry( '+... | [
"0.6089259",
"0.6000828",
"0.5988017",
"0.5988017",
"0.5411746",
"0.5384831",
"0.53588617",
"0.5325385",
"0.5292513",
"0.5253395",
"0.51829153",
"0.5145922",
"0.51455396",
"0.5140263",
"0.5134566",
"0.51338595",
"0.5131408",
"0.5099384",
"0.50469345",
"0.50339395",
"0.5030658... | 0.70308006 | 0 |
Throws ValueError if data is not list, tuple, or None | def _data_validation(data):
if isinstance(data, (list, tuple, type(None))) is not True:
raise ValueError(f"data must be tuple, list, or None, "
f"data type is '{type(data).__name__}'. "
f"Iterable data cannot be empty.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkTrainData(cls, data):\n\n if data == None or len(data) == 0:\n raise Exception(\"No data\")\n\n if type(data[0]) != tuple:\n raise Exception(\"Not a list of tuples\")\n\n if len(data[0]) != 2 and type(data[0][0]) != str and type(data[0][1]) != list:\n ... | [
"0.7660926",
"0.64638644",
"0.6422923",
"0.6404551",
"0.63229305",
"0.62484825",
"0.6218231",
"0.616253",
"0.6160331",
"0.6153625",
"0.61400735",
"0.6136175",
"0.61123484",
"0.61044014",
"0.6084617",
"0.5957655",
"0.5912516",
"0.58761597",
"0.58723783",
"0.5868495",
"0.585389... | 0.85903543 | 0 |
Return a tuple of data's quartile information (Q1, Q2, Q3, IQR) If you arrange all valued in the dataset from smallest to largest, Q2 is the middlemost value (the median). If you divide the dataset in half from this median and find the middlemost value in these halves, Q1 is the middlemost value of the first half and Q... | def get_quartile_data(cls, data: tuple or list) -> tuple:
cls._data_validation(data)
# Sort the data
sorted_data = sorted(list(data))
# Get q2, which is the median
q2 = cls.get_median(data)
first_half_data = list()
second_half_data = list()
# add to first ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_quartile_data(cls, data: tuple or list) -> tuple:\n cls._data_validation(data)\n from math import floor\n # Sort the data\n n = cls.get_n(data)\n if n == 0:\n # Empty dataset, returns zeroes\n return 0, 0, 0, 0\n sorted_data = sorted(list(data... | [
"0.86814016",
"0.7956387",
"0.73629045",
"0.7266403",
"0.72327554",
"0.6956993",
"0.6757972",
"0.668319",
"0.6638791",
"0.66310585",
"0.6606817",
"0.659038",
"0.6587118",
"0.6565645",
"0.65437573",
"0.6538354",
"0.6502364",
"0.64743066",
"0.64359903",
"0.63698876",
"0.636948"... | 0.8612872 | 1 |
Return a tuple of all outliers in dataset. Outliers are defined as data points which are not within 1.5 IQRs of Q1 or Q3. If remove_outliers=True, instead returns the data with outliers removed. Lower Outlier Limit = Q1 (1.5IQR) Upper Outlier Limit = Q3 +(1.5IQR) | def get_outlier_data(cls, data: tuple or list, remove_outliers=False) -> tuple:
cls._data_validation(data)
q1, q2, q3, iqr = cls.get_quartile_data(data)
data_without_outliers = list()
outliers_list = list()
lower_out_bound, upper_out_bound = q1 - 1.5*iqr, q3 + 1.5*iqr
pri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_outliers(data): \n \n idx_out = find_outliers_IQR(data)\n \n cleaned = data[~idx_out].copy()\n\n # print(f'There were {idx_out.sum()} outliers.')\n \n return cleaned",
"def get_outlier_data(\n cls, data: tuple or list, remove_outliers=False\n ) -> tuple:\n ... | [
"0.8190102",
"0.81744343",
"0.75078195",
"0.7411929",
"0.73364514",
"0.72968316",
"0.7266782",
"0.71986395",
"0.71556485",
"0.7138233",
"0.7055311",
"0.7044442",
"0.69663453",
"0.69504064",
"0.6867932",
"0.68141323",
"0.68134224",
"0.6811384",
"0.67942876",
"0.6792364",
"0.67... | 0.8220814 | 0 |
Return a tuple of data's quartile information (Q1, Q2, Q3, IQR) If you arrange all valued in the dataset from smallest to largest, Q2 is the middlemost value (the median). If you divide the dataset in half from this median and find the middlemost value in these halves, Q1 is the middlemost value of the first half and Q... | def get_quartile_data(cls, data: tuple or list) -> tuple:
cls._data_validation(data)
from math import floor
# Sort the data
n = cls.get_n(data)
if n == 0:
# Empty dataset, returns zeroes
return 0, 0, 0, 0
sorted_data = sorted(list(data))
n_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_quartile_data(cls, data: tuple or list) -> tuple:\n cls._data_validation(data)\n # Sort the data\n sorted_data = sorted(list(data))\n # Get q2, which is the median\n q2 = cls.get_median(data)\n first_half_data = list()\n second_half_data = list()\n # ... | [
"0.86127615",
"0.79561895",
"0.7363667",
"0.7266413",
"0.7234658",
"0.6957703",
"0.67579246",
"0.6683327",
"0.6639408",
"0.6631373",
"0.6607943",
"0.65904045",
"0.65866876",
"0.65661675",
"0.6544473",
"0.6537689",
"0.65024775",
"0.64734846",
"0.6436739",
"0.6370607",
"0.63698... | 0.8681264 | 0 |
Return the sample variance (s\u00b2) of each data set as a tuple. If is_population=True, returns the population variance (\u03c3\u00b2) instead. | def get_var(cls, data: tuple or list, is_population=False) -> float:
cls._data_validation(data)
mean = cls.get_mean(data)
variance = float()
n = cls.get_n(data)
for each_item in data:
variance += (each_item - mean) ** 2
# Checks whether is a population or samp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_population_variance(self):\n\t\treturn self.variables.get('population_variance')",
"def variance(self):\n return self.properties.get('variance')",
"def variance(self):\r\n\t\t_mean = sum(self.sample)/len(self.sample)\r\n\t\treturn sum(map(lambda x: (x - _mean)**2, self.sample))/(len(self.sample)... | [
"0.71327597",
"0.67674506",
"0.6685351",
"0.65718824",
"0.6553213",
"0.65447384",
"0.6540613",
"0.6483999",
"0.6459404",
"0.6353432",
"0.6345209",
"0.63438183",
"0.63338304",
"0.6325998",
"0.6280821",
"0.6251935",
"0.62394226",
"0.6235735",
"0.62145925",
"0.6191499",
"0.61914... | 0.73430026 | 0 |
Return tuple of difference of two dependent data sets Note that this method assumes that the two data sets are dependent and of equal sample sizes, i.e. this method is meaningless when applied to two independent data sets. | def get_data_diff(cls, data1: tuple, data2: tuple) -> tuple:
cls._data_validation(data1)
cls._data_validation(data2)
data1_n = StatMe.get_n(data1)
data2_n = StatMe.get_n(data2)
if data1_n != data2_n:
raise ValueError(f"Samples are not of equal length.\n"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff(A,B):\n #A-B\n x = list(set(A) - set(B))\n #B-A\n y = list(set(B) - set(A))\n return x, y",
"def set_difference(set_a, set_b):\n \n diff = set_b - set_a\n \n return diff",
"def diff(self, x0, x1):\n nq, nv, nx = self.model.nq, self.model.nv, self.nx\n assert (x0.s... | [
"0.69509035",
"0.68752706",
"0.6504726",
"0.65008557",
"0.642601",
"0.63917977",
"0.63459766",
"0.62474805",
"0.6239011",
"0.62191683",
"0.6194459",
"0.61915225",
"0.61788774",
"0.6174397",
"0.61711997",
"0.6162345",
"0.6144045",
"0.60510117",
"0.6031635",
"0.59960496",
"0.59... | 0.77125275 | 0 |
Return the pooled variance between the first and second data sets | def get_var_pool(cls, data1: tuple, data2: tuple) -> float:
cls._data_validation(data1)
cls._data_validation(data2)
n1 = cls.get_n(data1)
var1 = cls.get_var(data1)
n2 = cls.get_n(data2)
var2 = cls.get_var(data2)
return ((n1 - 1) * var1 + (n2 - 1) * var2) / (n1 + n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pooled_sample_variance(sample1, sample2):\n deg_freedom = len(sample1) + len(sample2) - 2\n mean1 = statistics.mean(sample1)\n squares1 = ((x - mean1) ** 2 for x in sample1)\n mean2 = statistics.mean(sample2)\n squares2 = ((x - mean2) ** 2 for x in sample2)\n\n return (math.fsum(squares1) + m... | [
"0.7066996",
"0.64504707",
"0.64277244",
"0.640207",
"0.6249601",
"0.6203304",
"0.59842765",
"0.5964988",
"0.5925388",
"0.5816522",
"0.5807429",
"0.5756509",
"0.56738883",
"0.5667132",
"0.56528944",
"0.562759",
"0.56016576",
"0.55566925",
"0.554267",
"0.5518305",
"0.55033016"... | 0.6641171 | 1 |
Convert actual df into t_table lookup df. For n > 150, returns 999 (zscore lookup value for ttable). | def _get_lookup_df(cls, df_data: tuple or list, df_is_population=False) -> int:
cls._data_validation(df_data)
n = cls.get_n(df_data)
df = n-1
if df >= 150 or df_is_population:
return 999
elif df <= 30:
return df
else:
# stores the previ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_titanic_data(df):\n\n df.embark_town.fillna('Other', inplace=True)\n\n # Drop deck and embarked_town\n df.drop(columns=['deck', 'embark_town'], inplace=True)\n\n # Encoding: Objects (Categorical Variables) to Numeric\n # Use sklearn's LabelEncoder\n encoder = LabelEncoder()\n\n # S... | [
"0.54173565",
"0.53379613",
"0.52356905",
"0.52255005",
"0.51306707",
"0.51279414",
"0.511602",
"0.51081264",
"0.5105641",
"0.5036905",
"0.50213903",
"0.50027704",
"0.49914676",
"0.4990226",
"0.49587485",
"0.4940191",
"0.4919737",
"0.49194276",
"0.49128762",
"0.4908752",
"0.4... | 0.5578196 | 0 |
Return alpha(\u03b1), determined by CL and tailedness. \u03b1 = 1 CL \u03b1 = (1 CL) / 2 for twotailed tests, to account for both possible extreme tails in the distribution. | def _get_alpha(cls, cl: float, tail: str):
alpha = (1 - cl) / 2 if tail == "two" else (1 - cl)
return round(alpha, 3) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alpha(self,k1,k2,c):\n if k1 == 0.:\n return 0.\n else:\n return 1. + k2*c/k1",
"def _tstat_alpha(self):\n return _handle_ab(self._tstat_all, self.use_const)[0]",
"def clAlphaT(self):\n A = 2 * pi * self.aspectRatioT\n B = (self.aspectRatioT * self.b... | [
"0.60391426",
"0.5964379",
"0.59364223",
"0.5921598",
"0.5899678",
"0.5892448",
"0.5811773",
"0.57884306",
"0.57884306",
"0.57884306",
"0.5761492",
"0.57613426",
"0.57104206",
"0.5643682",
"0.56156635",
"0.5586468",
"0.5562589",
"0.5561338",
"0.5516102",
"0.5499588",
"0.54036... | 0.70785445 | 0 |
Provides metadata for the UserInterfaceType plugin. This gives humanreadable information on the plugin, dependency resolution information, and tells the plugin system what this plugin can do. | def metadata():
return {
"name": "User Interface Type",
"description": "Defines a type of plug-in that communicates with the user by showing information to the user and allowing the user to control the application.",
"version": 2,
"dependencies": {},
"type": { #This is a "plug-in type" plug-in.
"type_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_interface_info(self): # real signature unknown; restored from __doc__\n pass",
"def get_plugin_interface(self):",
"def metadata(self) -> interface.Metadata:\n return cast(interface.Metadata, self._interfaces[interface.Metadata])",
"def plugin_data(self) -> global___SummaryMetadata.Plugi... | [
"0.61903876",
"0.5972374",
"0.57847023",
"0.5763439",
"0.57444113",
"0.5743814",
"0.57142943",
"0.5705293",
"0.5666131",
"0.5616112",
"0.5563328",
"0.542009",
"0.5387956",
"0.53818756",
"0.53818756",
"0.53782296",
"0.53117156",
"0.5289842",
"0.5267869",
"0.52673215",
"0.52365... | 0.7924266 | 0 |
Validates whether the specified metadata is valid for user interface plugins. User interface metadata must have a ``userinterface`` entry, which must | def validate_metadata(user_interface_metadata):
if "userinterface" not in user_interface_metadata:
raise luna.plugins.MetadataValidationError("This is not a user interface plug-in.")
required_functions = {"join", "start", "stop"}
try:
if not required_functions <= user_interface_metadata["userinterface"].keys():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metadata():\n\treturn {\n\t\t\"name\": \"User Interface Type\",\n\t\t\"description\": \"Defines a type of plug-in that communicates with the user by showing information to the user and allowing the user to control the application.\",\n\t\t\"version\": 2,\n\t\t\"dependencies\": {},\n\n\t\t\"type\": { #This is a... | [
"0.5880484",
"0.57338774",
"0.5612077",
"0.54693663",
"0.5427157",
"0.5378694",
"0.5303779",
"0.52518684",
"0.522419",
"0.5138454",
"0.5125952",
"0.5111557",
"0.50984967",
"0.5088108",
"0.5084488",
"0.5055832",
"0.5045968",
"0.50456053",
"0.50423694",
"0.49870116",
"0.4978431... | 0.84427905 | 0 |
Add pipe failure to the leaks dict. | def pipe_failure(self, tube, fluid=None, N_welds=1, max_flow=None):
# If fluid not defined use fluid of the Source
fluid = fluid or self.fluid
# Failure rate coefficients; Piping failure rate is per unit of length,
# weld is dependent on number of welds, pipe OD and wall thickness
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failure_mode(self, name, failure_rate, q_std, N=1):\n self.leaks.append(\n self._make_leak(name, failure_rate, q_std, N))",
"def auditmemallocfail(self) :\n\t\ttry :\n\t\t\treturn self._auditmemallocfail\n\t\texcept Exception as e:\n\t\t\traise e",
"def auditportallocfail(self) :\n\t\ttry... | [
"0.5732793",
"0.53959626",
"0.534181",
"0.53402734",
"0.5289784",
"0.5119834",
"0.5101168",
"0.507846",
"0.50469095",
"0.5033066",
"0.5027118",
"0.5009161",
"0.50034285",
"0.49901775",
"0.49738032",
"0.49625376",
"0.49494156",
"0.4929026",
"0.4914285",
"0.4890131",
"0.4882169... | 0.5879053 | 0 |
Add dewar insulation failure to leaks dict. Store failure rate, flow rate and expected time duration of the failure event for the dewar insulation failure. Based on FESHM4240. Failure modes are analyzed by `Volume.odh` method. | def dewar_insulation_failure(self, q_std):
failure_rate = TABLE_1['Dewar']['Loss of vacuum']
self.leaks.append(
self._make_leak('Dewar insulation failure', failure_rate, q_std, 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failure_mode(self, name, failure_rate, q_std, N=1):\n self.leaks.append(\n self._make_leak(name, failure_rate, q_std, N))",
"def _make_leak(self, name, failure_rate, q_std, N):\n N_events = N * self.N\n tau = self.volume/q_std\n total_failure_rate = N_events*failure_rat... | [
"0.6150373",
"0.5749372",
"0.5595032",
"0.5496742",
"0.5341827",
"0.53159404",
"0.51895225",
"0.51661247",
"0.5164078",
"0.5149587",
"0.5141537",
"0.50924855",
"0.505334",
"0.5052884",
"0.5009815",
"0.5003419",
"0.49941376",
"0.49664646",
"0.49133098",
"0.49062636",
"0.488159... | 0.69461983 | 0 |
Add UTube failure to leaks dict. Store failure rate, flow rate and expected time duration of the failure event for the dewar insulation failure. Based on FESHM4240. Failure modes are analyzed by `Volume.odh` method. | def u_tube_failure(self, outer_tube, inner_tube, L, use_rate,
fluid=None, N=1):
# TODO Make areas adjustable, add info to docstring
flow_path_cases = {'Small event': ht.piping.Annulus(outer_tube.ID,
inner_tube.OD,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failure_mode(self, name, failure_rate, q_std, N=1):\n self.leaks.append(\n self._make_leak(name, failure_rate, q_std, N))",
"def dewar_insulation_failure(self, q_std):\n failure_rate = TABLE_1['Dewar']['Loss of vacuum']\n self.leaks.append(\n self._make_leak('Dewar ... | [
"0.62996244",
"0.6081853",
"0.5967863",
"0.59589446",
"0.57245386",
"0.5637934",
"0.56091994",
"0.5550118",
"0.55276215",
"0.5523503",
"0.5457722",
"0.54345715",
"0.54227185",
"0.540919",
"0.5392647",
"0.53509164",
"0.5341924",
"0.53290635",
"0.528553",
"0.5253357",
"0.520192... | 0.7077728 | 0 |
Add pressure vessel failure to leaks dict. Store failure rate, flow rate and expected time duration of the event for transfer line failure. Based on FESHM 4240. Failure modes are analyzed by `Volume.odh` method. | def pressure_vessel_failure(self, q_std_rupture, fluid=None):
# If fluid not defined use fluid of the Source
fluid = fluid or self.fluid
for case, parameters in TABLE_2['Vessel, pressure'].items():
name = 'Pressure vessel ' + case
if isinstance(parameters, dict):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def u_tube_failure(self, outer_tube, inner_tube, L, use_rate,\n fluid=None, N=1):\n # TODO Make areas adjustable, add info to docstring\n flow_path_cases = {'Small event': ht.piping.Annulus(outer_tube.ID,\n inner_tube.OD... | [
"0.5895279",
"0.58741015",
"0.58721024",
"0.57350564",
"0.5734858",
"0.5273407",
"0.5273209",
"0.5161501",
"0.5152299",
"0.50805694",
"0.50692445",
"0.50475574",
"0.50008637",
"0.50005174",
"0.49996737",
"0.49666536",
"0.49650532",
"0.49615368",
"0.49581695",
"0.49567917",
"0... | 0.666339 | 0 |
Add general failure mode to leaks dict. Store failure rate, flow rate and expected time duration of the failure event for general failure mode. Failure modes are analyzed by `Volume.odh` method. | def failure_mode(self, name, failure_rate, q_std, N=1):
self.leaks.append(
self._make_leak(name, failure_rate, q_std, N)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_leak(self, name, failure_rate, q_std, N):\n N_events = N * self.N\n tau = self.volume/q_std\n total_failure_rate = N_events*failure_rate\n total_failure_rate.ito(1/ureg.hr)\n return (name, total_failure_rate, q_std, tau.to(ureg.min), N_events)",
"def test_loss_hook(se... | [
"0.55107766",
"0.5364057",
"0.5345816",
"0.5153793",
"0.50932765",
"0.50351113",
"0.502037",
"0.49866393",
"0.49547714",
"0.4933598",
"0.4926014",
"0.4904773",
"0.48874328",
"0.48584226",
"0.4838802",
"0.48380056",
"0.47908464",
"0.47816858",
"0.47497073",
"0.4739524",
"0.472... | 0.68871087 | 0 |
Calculate leak flow/release for a given piping element. For this calculation the gas is assumed to have no pressure loss on entry due to the different possible options. This makes analysis simple and conservative. For the full pipe rupture case it is usually assumed that the release area is equal to tube cross section ... | def _leak_flow(cls, tube, area, fluid):
d = (4*area/math.pi)**0.5 # diameter for the leak opening
exit_ = ht.piping.Exit(d)
TempPiping = ht.piping.Piping(fluid)
TempPiping.add(
tube,
exit_,
)
if area != tube.area:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pipe_failure(self, tube, fluid=None, N_welds=1, max_flow=None):\n # If fluid not defined use fluid of the Source\n fluid = fluid or self.fluid\n # Failure rate coefficients; Piping failure rate is per unit of length,\n # weld is dependent on number of welds, pipe OD and wall thickne... | [
"0.6381292",
"0.5661798",
"0.5626378",
"0.54133904",
"0.5259986",
"0.5236037",
"0.52057636",
"0.5197794",
"0.5169742",
"0.51044613",
"0.5099405",
"0.5072147",
"0.50551397",
"0.5022336",
"0.50140405",
"0.49782217",
"0.49536902",
"0.4939579",
"0.49342322",
"0.489776",
"0.487424... | 0.7203139 | 0 |
Format failure rate, flow rate and expected time duration of the failure event for a leak. | def _make_leak(self, name, failure_rate, q_std, N):
N_events = N * self.N
tau = self.volume/q_std
total_failure_rate = N_events*failure_rate
total_failure_rate.ito(1/ureg.hr)
return (name, total_failure_rate, q_std, tau.to(ureg.min), N_events) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatFailure(self, test, err):\n return self.formatError(test, err)",
"def test_manager_reports_duration_including_failure():\n\n httpretty.register_uri(\n httpretty.GET,\n \"http://test.com/long_failed\",\n body=httpretty_body_that_waits_and_returns(0.5, None),\n )\n\n ... | [
"0.6140188",
"0.5897113",
"0.585269",
"0.5849131",
"0.5757911",
"0.5635867",
"0.55230266",
"0.55227655",
"0.55061984",
"0.5505019",
"0.54786354",
"0.54182583",
"0.5416461",
"0.5405261",
"0.5389772",
"0.53731793",
"0.5275777",
"0.52040815",
"0.519116",
"0.51494825",
"0.5131447... | 0.6359496 | 0 |
Combine several ODH sources sharing volume. Can be used for failure modes affecting several sources in parallel. | def combine(name, sources):
fluid = ht.ThermState(sources[0].fluid.name, T=ht.T_NTP, P=ht.P_NTP)
if all([source.fluid.name == fluid.name for source in sources]):
total_volume = sum([source.volume for source in sources])
return Source(name, fluid, total_volume)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_combination(sonar_model, input_paths, output_path, engine):\n # TODO: there should be compression option for the combined file too...\n\n def coerce_type(ds, group):\n if group == 'Beam':\n if sonar_model == 'EK80':\n ds['transceiver_software_version'] = ds['trans... | [
"0.5694566",
"0.56148976",
"0.54036075",
"0.53820014",
"0.5315765",
"0.52329516",
"0.5208108",
"0.5146966",
"0.513335",
"0.5095876",
"0.5057739",
"0.5045067",
"0.5022017",
"0.500303",
"0.49761328",
"0.49656466",
"0.49650297",
"0.4956805",
"0.4940756",
"0.49406424",
"0.4896856... | 0.6918295 | 0 |
Calculate ODH fatality rate for given `Source`s. For each leak of each source ODH conditions are analyzed and fatality rates are calculated. The results are collected in fail_modes list. | def odh(self, sources, power_outage=False):
self.fail_modes = []
# Probability of power failure in the building:
# PFD_power if no outage, 1 if there is outage
PFD_power_build = (power_outage or
TABLE_1['Electrical Power Failure']['Demand rate'])
# Calc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fatality_fan_powered(self, source, leak, sol_PFD, PFD_power_build):\n (failure_mode_name, leak_failure_rate, q_leak, tau, N) = leak\n for (P_fan, Q_fan, N_fan) in self.Fan_flowrates:\n # Probability of power on, ODH system working, and m number of fans\n # with flow rate Q_... | [
"0.639882",
"0.61853623",
"0.5198145",
"0.48865837",
"0.4809793",
"0.4745529",
"0.47022194",
"0.4641142",
"0.4628895",
"0.45942694",
"0.4469745",
"0.4404132",
"0.43621033",
"0.43478933",
"0.43275335",
"0.43183514",
"0.431352",
"0.4298347",
"0.4293593",
"0.42874545",
"0.427791... | 0.7015947 | 0 |
Calculate fatality rate in the volume for ODH protection failure. Calculate failure rate of leak occuring and no safety response occuring due to power failure and isolation solenoid failure, or power on and ODH system failure. O2 concentration is limited only by amount of inert gas the source has. Fans are not operatio... | def _fatality_no_response(self, source, leak, sol_PFD,
PFD_power_build):
(failure_mode_name, leak_failure_rate, q_leak, tau, N) = leak
P_no_response = float(PFD_power_build) * sol_PFD + \
(1-PFD_power_build)*self.PFD_ODH
P_i = leak_failure_rate * P_no_re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fatality_fan_powered(self, source, leak, sol_PFD, PFD_power_build):\n (failure_mode_name, leak_failure_rate, q_leak, tau, N) = leak\n for (P_fan, Q_fan, N_fan) in self.Fan_flowrates:\n # Probability of power on, ODH system working, and m number of fans\n # with flow rate Q_... | [
"0.60235065",
"0.5961136",
"0.58948976",
"0.5526284",
"0.55170983",
"0.53160745",
"0.5297183",
"0.5253064",
"0.51723504",
"0.51687574",
"0.5096973",
"0.5010972",
"0.49728975",
"0.49670574",
"0.4959852",
"0.49482557",
"0.48530757",
"0.48435175",
"0.4823226",
"0.4820656",
"0.48... | 0.6028143 | 0 |
Calculate fatality rates for fan failure on demand. Calculate fatality rates for the case of ODH system responding and fans powered but some of the fans failing on demand. See wiki for further explanation. Adds calculation results to the fail_modes list. | def _fatality_fan_powered(self, source, leak, sol_PFD, PFD_power_build):
(failure_mode_name, leak_failure_rate, q_leak, tau, N) = leak
for (P_fan, Q_fan, N_fan) in self.Fan_flowrates:
# Probability of power on, ODH system working, and m number of fans
# with flow rate Q_fan on.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fan_fail(self):\n # TODO add fans with different volumetric rates (see report as well)\n Fail_rate = self.lambda_fan\n Fan_flowrates = []\n for m in range(self.N_fans+1):\n # Probability of exactly m units starting\n P_m_fan_work = prob_m_of_n(m, self.N_fans, ... | [
"0.5976335",
"0.5800688",
"0.5793206",
"0.5278259",
"0.51749235",
"0.51479864",
"0.50197566",
"0.4980716",
"0.4886527",
"0.48797902",
"0.48643532",
"0.48379484",
"0.48011443",
"0.47967914",
"0.47813833",
"0.47725174",
"0.47659168",
"0.47551543",
"0.4754042",
"0.47385153",
"0.... | 0.677475 | 0 |
Calculate fatality probability for given oxygen concentration. The equation is fitted from the FESHM 4240 plot. | def _fatality_prob(self, O2_conc):
if O2_conc >= 0.18: # Lowest oxygen concentration above 18%
Fi = 0
elif O2_conc <= 0.088: # 8.8% of oxygen is assumed to be 100% fatal
Fi = 1
else:
# Fi formula, reverse engineered using 8.8% and 18% thresholds
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pr_dominant_offpring(offspring_zygosity):\n\n homozygous_dominant, heterozygous, homozygous_recessive = offspring_zygosity\n\n total = homozygous_dominant + heterozygous + homozygous_recessive\n dominant = homozygous_dominant + heterozygous\n\n pr_dominant = dominant / total\n\n return pr_domina... | [
"0.58419925",
"0.58070016",
"0.56442904",
"0.5618727",
"0.56060743",
"0.55602694",
"0.5558371",
"0.55557066",
"0.5547927",
"0.5523127",
"0.5514237",
"0.5470292",
"0.54664814",
"0.546445",
"0.54536456",
"0.54408586",
"0.5437179",
"0.54363346",
"0.5434748",
"0.54204845",
"0.541... | 0.7696928 | 0 |
Calculate ODH class as defined in FESHM 4240. Returns int ODH class. | def odh_class(self):
if self.phi < 1e-7/ureg.hr:
return 0
elif self.phi < 1e-5/ureg.hr:
return 1
elif self.phi < 1e-3/ureg.hr:
return 2
else:
# TODO add a custom exception for ODH > 2
print('ODH fatality rate is too high. Please... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DAM_class_level(self, class_entity: und.Ent):\n if \"Interface\" in class_entity.kindname():\n return 2.0\n\n private_variables = len(class_entity.ents(\"Define\", \"Java Variable Private Member\"))\n protected_variables = len(class_entity.ents(\"Define\", \"Java Variable Protec... | [
"0.61941946",
"0.6073732",
"0.6039141",
"0.59284633",
"0.5847515",
"0.5661549",
"0.56504405",
"0.5536489",
"0.5534853",
"0.55204695",
"0.5511418",
"0.55110085",
"0.54881746",
"0.54308605",
"0.53876334",
"0.53790814",
"0.53224164",
"0.525254",
"0.5241441",
"0.5236536",
"0.5216... | 0.76211125 | 0 |
Print a report for failure modes and effects. The report is sorted by fatality rate descending. | def report(self, brief=True, sens=None):
self.fail_modes.sort(key=lambda x: x.phi, reverse=True)
sens = sens or SHOW_SENS
title = f'ODH report for {self}'
padding = len(title) + 10
print('#'*padding)
print(title)
print('-'*padding)
if brief:
pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_fails(self,result,cause=False,detail=False):\n fails = result.get_fails()\n if fails:\n print ('=== FAILS '+('='*60))\n for fail in fails:\n print (fail.id)\n if cause:\n print (' ',fail.get_cause())\n if detail:\n ... | [
"0.6206705",
"0.59326273",
"0.58146775",
"0.5759397",
"0.57398576",
"0.5687681",
"0.56708777",
"0.56109154",
"0.55646807",
"0.5552639",
"0.5552112",
"0.55355096",
"0.5464556",
"0.5440957",
"0.5431149",
"0.54164475",
"0.54160124",
"0.540715",
"0.5400654",
"0.54003173",
"0.5395... | 0.6278852 | 0 |
Prepare a short table for failure modes and effects. The report is sorted by fatality rate descending. | def report_short_table(self, sens=None):
self.fail_modes.sort(key=lambda x: x.phi, reverse=True)
sens = sens or SHOW_SENS
table = [["Failure mode", "Fans on", "O_2", "Duration, min", "\\phi_i"]]
table.append(None)
for f_mode in self.fail_modes:
if f_mode.phi >= sens:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_table(type_, test_type, device_name, thresholds):\n x = PrettyTable() \n x.field_names = [device_name] + thresholds\n \n \"Chrome,\" + test_type + \",\" + str(notAfter_date) + \",\" + thresholds[index], \",fail\"\n \n ##read all Chromep entries\n ##get all test_type rows\n ##lo... | [
"0.64098376",
"0.5957766",
"0.58932674",
"0.54565907",
"0.539092",
"0.53548634",
"0.53548634",
"0.5280158",
"0.52681416",
"0.52667576",
"0.5242095",
"0.520481",
"0.5186109",
"0.51242334",
"0.5049847",
"0.5039647",
"0.5037103",
"0.503655",
"0.50297123",
"0.5002275",
"0.4996405... | 0.73222107 | 0 |
Calculate the probability of m out of n units working. Calculation is done using binomial distribution. | def prob_m_of_n(m, n, T, l):
PFD_one_unit = l*T
m_of_n = binom(n, m) * (PFD_one_unit)**(n-m) * (1-PFD_one_unit)**m
return m_of_n | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_probability(k: int, m: int, n: int) -> float:\n population = [\"AA\" for _ in range(k)] + [\"Aa\" for _ in range(m)] + [\"aa\" for _ in range(n)]\n pairings = it.combinations(population, 2)\n probabilities = [PROBABILITIES[pairing] for pairing in pairings]\n output = sum(probabilities) / ... | [
"0.79381037",
"0.7571825",
"0.75367785",
"0.74892473",
"0.718715",
"0.7186842",
"0.71784484",
"0.7104355",
"0.70734644",
"0.695075",
"0.69473517",
"0.691506",
"0.6875324",
"0.6825012",
"0.6772642",
"0.67398417",
"0.673924",
"0.6729206",
"0.6699638",
"0.6692936",
"0.66819865",... | 0.7670718 | 1 |
Calculate the final oxygen concentration for continuous flow. Equivalent to conc_vent(V, R, Q, float('inf')). | def conc_final(V, R, Q):
if Q > 0:
C = 0.21/(Q+R)*Q
elif abs(Q) <= abs(R):
C = 0
elif abs(Q) > abs(R):
C = 0.21*(1-R/abs(Q))
return C | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conc_vent(V, R, Q, t):\n if Q > 0:\n C = 0.21/(Q+R) * (Q+R*math.e**-((Q+R)/V*t))\n elif abs(Q) <= R:\n C = 0.21*math.e**-(R/V*t)\n elif abs(Q) > R:\n C = 0.21*(1-R/abs(Q)*(1-math.e**-(abs(Q)*t/V)))\n return C",
"def conc_after(V, C_e, Q, t, t_e):\n C = 0.21-(0.21-C_e)*math... | [
"0.7371679",
"0.68841326",
"0.62628317",
"0.6067613",
"0.600988",
"0.5925458",
"0.58317536",
"0.57587767",
"0.57530713",
"0.57408696",
"0.55814916",
"0.55788034",
"0.5552848",
"0.5534186",
"0.5490134",
"0.5466125",
"0.5437804",
"0.5426694",
"0.542646",
"0.5424657",
"0.5414025... | 0.6911598 | 1 |
Print the results of the ODH analysis for a volume. If several volumes given (in case of interlapping volumes) the worst case will be printed. | def print_result(*Volumes):
max_phi = -1/ureg.hr
for volume in Volumes:
if volume.phi > max_phi:
max_volume = volume
line_1 = '# Fatality rate for {} is {:.1e} # '.format(max_volume, volume.phi)
pad = len(line_1)
line_2 = '# Recommended ODH class {}'.format(max_volume.odh_class(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_results(inside_ellipsoid_per_step, inside_ellipsoid_all, conf):\n if conf.verbosity > 0:\n per_step_percentage = np.sum(inside_ellipsoid_per_step, axis=0) / float(\n conf.n_rollouts)\n print(\"\"\"\\n=====Uncertainty propagation===== \"\"\")\n print(\"\"\"Per step perce... | [
"0.6076633",
"0.58335817",
"0.578717",
"0.5764819",
"0.5708327",
"0.57060343",
"0.5651979",
"0.5650857",
"0.5488244",
"0.5408044",
"0.5405682",
"0.5396798",
"0.53912807",
"0.53626204",
"0.5359393",
"0.52684",
"0.5258393",
"0.52547324",
"0.5238997",
"0.5229664",
"0.5223999",
... | 0.65382415 | 0 |
Initialize the Abstract base class of a Variational State defined on an hilbert space. | def __init__(self, hilbert: AbstractHilbert):
self._hilbert = hilbert # type: AbstractHilbert
self._model_state = {} # type: PyTree
self._parameters = {} # type: PyTree | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_state(self):\n # Initialize everything to zero\n self.stateC = self.initializer((self.nSym, 1))\n self.stateC_prev = self.initializer((self.nSym, 1))\n self.state = self.toNeural(self.stateC)\n self.state_prev = self.toNeural(matrix=self.stateC_prev)\n self.... | [
"0.66713417",
"0.64572304",
"0.6398625",
"0.6388972",
"0.63356894",
"0.6299398",
"0.6227243",
"0.6222026",
"0.62105525",
"0.62102795",
"0.6195474",
"0.6141361",
"0.6126284",
"0.6114694",
"0.6112479",
"0.61019963",
"0.6083083",
"0.60628355",
"0.6019901",
"0.5988344",
"0.598000... | 0.67266685 | 0 |
r"""The pytree of the parameters of the model. | def parameters(self) -> PyTree:
return self._parameters | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variables(self) -> PyTree:\n return flax.core.freeze({\"params\": self.parameters, **self.model_state})",
"def parameterNode(self):\r\n # framework\r\n profbox()\r\n return self.parameterNode",
"def parameterNode(self):\n #framework\n profbox()\n return self.parameterNode",
"def ... | [
"0.7385442",
"0.6606818",
"0.62927306",
"0.6261241",
"0.62531644",
"0.62116337",
"0.6189143",
"0.5985493",
"0.59852135",
"0.5982368",
"0.59517086",
"0.59439075",
"0.5943505",
"0.5928683",
"0.5913491",
"0.58814526",
"0.5872295",
"0.5865241",
"0.5845439",
"0.5845439",
"0.584543... | 0.8160057 | 0 |
r"""The optional pytree with the mutable state of the model. | def model_state(self) -> Optional[PyTree]:
return self._model_state | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree(self):\r\n return self._tree",
"def __copy__(self) -> 'Tree':\n return non_recursive_tree_copy(self)",
"def tree(self):\n # type: () -> Optional[Module]\n return self._tree",
"def get_tree(self):\n return self.tree or None",
"def test_parent_read_only():\n t = Tree(None)\... | [
"0.6223878",
"0.6183596",
"0.61077166",
"0.6103018",
"0.5914585",
"0.5802627",
"0.575805",
"0.57547",
"0.57230943",
"0.5715844",
"0.5713787",
"0.56472003",
"0.56472003",
"0.56472003",
"0.56472003",
"0.55974734",
"0.5592061",
"0.5558143",
"0.555776",
"0.55290544",
"0.5511357",... | 0.70185894 | 0 |
r"""The PyTree containing the parameters and state of the model, used when evaluating it. | def variables(self) -> PyTree:
return flax.core.freeze({"params": self.parameters, **self.model_state}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parameters(self) -> PyTree:\n return self._parameters",
"def __call__(self, params: Mapping[str, Any],\n batch: Mapping[str, jnp.ndarray]) -> PyTreeDef:\n ...",
"def model_state(self) -> Optional[PyTree]:\n return self._model_state",
"def parameterNode(self):\r\n # frame... | [
"0.72823274",
"0.62419695",
"0.61395806",
"0.6070549",
"0.5913993",
"0.5892661",
"0.588385",
"0.584981",
"0.5712577",
"0.5679467",
"0.5679467",
"0.5679467",
"0.5679467",
"0.5656677",
"0.5551771",
"0.5551533",
"0.55390733",
"0.5533959",
"0.5529545",
"0.5401554",
"0.53472054",
... | 0.7401724 | 0 |
r"""Convert this mixed state to a qutip density matrix Qobj. | def to_qobj(self): # -> "qutip.Qobj"
from qutip import Qobj
q_dims = [list(self.hilbert_physical.shape), list(self.hilbert_physical.shape)]
return Qobj(np.asarray(self.to_matrix()), dims=q_dims) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_qobj(self): # -> \"qutip.Qobj\"\n from qutip import Qobj\n\n q_dims = [list(self.hilbert.shape), [1 for i in range(self.hilbert.size)]]\n return Qobj(np.asarray(self.to_array()), dims=q_dims)",
"def serialize_Q(Q: np.ndarray):\n ret = QMatrix()\n ret.q_matrix = [QMatrixRow() fo... | [
"0.6459236",
"0.64518213",
"0.62433493",
"0.59719163",
"0.5919937",
"0.5865261",
"0.58466554",
"0.56326973",
"0.5629153",
"0.55800503",
"0.55686086",
"0.5567256",
"0.55051607",
"0.5466473",
"0.54598826",
"0.5440446",
"0.5437382",
"0.5437118",
"0.5430142",
"0.5422909",
"0.5419... | 0.6822012 | 0 |
Computes the expectation value of the given operator over the variational state. | def expect(vstate: VariationalState, operator: AbstractOperator): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expectation(operator, state):\n\n if isinstance(state, scipy.sparse.spmatrix):\n # Handle density matrix.\n if isinstance(operator, scipy.sparse.linalg.LinearOperator):\n raise ValueError('Taking the expectation of a LinearOperator with '\n 'a density mat... | [
"0.73366123",
"0.7222232",
"0.7041802",
"0.631812",
"0.604789",
"0.5915146",
"0.589428",
"0.5876983",
"0.5830442",
"0.58052284",
"0.5766971",
"0.57608795",
"0.5747666",
"0.56931096",
"0.56688267",
"0.5637735",
"0.5619489",
"0.5608534",
"0.55620414",
"0.5543287",
"0.5540375",
... | 0.7237491 | 1 |
Establish a connection with the server. Set `self.stream` to the `pyxmpp.jabberd.ComponentStream` when initial connection succeeds. | def connect(self):
if not self.jid or self.jid.node or self.jid.resource:
raise ValueError,"Cannot connect: no or bad JID given"
if not self.secret:
raise ValueError,"Cannot connect: no secret given"
if not self.server:
raise ValueError,"Cannot connect: no ser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect(self):\n if self.server is not None:\n # TODO might want to give client debug flag option\n self.client = xmpp.Client(server=self.server, port=self.port, debug=[])\n con = self.client.connect(server=(self.server, self.port))\n\n # making helper classes... | [
"0.69157887",
"0.6877156",
"0.66275495",
"0.66263306",
"0.66263306",
"0.6622735",
"0.6613999",
"0.66042864",
"0.6585165",
"0.6509693",
"0.6508548",
"0.6492015",
"0.64870465",
"0.6427897",
"0.6406653",
"0.64025706",
"0.6399208",
"0.6368029",
"0.6316508",
"0.6271877",
"0.625225... | 0.7528595 | 0 |
Get the stream of the component in a safe way. | def get_stream(self):
self.lock.acquire()
stream=self.stream
self.lock.release()
return stream | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_stream(self):\n result = self.stream\n self.stream = \"\"\n return result",
"def stream(self):\r\n return streams.Stream(self)",
"def stream(self):\r\n return streams.Stream(self)",
"def stream(self):\n return streams.Stream(self)",
"def stream(self):\n\t\t... | [
"0.7813552",
"0.73093575",
"0.73093575",
"0.72392064",
"0.71380043",
"0.68041235",
"0.6763978",
"0.6759576",
"0.6547358",
"0.65138996",
"0.64420074",
"0.63967717",
"0.63899106",
"0.6356386",
"0.6313429",
"0.62822145",
"0.6140741",
"0.6103475",
"0.6076918",
"0.60742474",
"0.60... | 0.7730196 | 1 |
Register a feature to be announced by Service Discovery. | def register_feature(self, feature_name):
self.disco_info.add_feature(feature_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register(cls, feature_name, feature):\n if feature_name in cls.feature_registry:\n raise FeatureAlreadyRegistered(feature_name)\n cls.feature_registry[feature_name] = feature",
"def register_service(self) -> None:\n strategy = cast(Strategy, self.context.strategy)\n des... | [
"0.6767601",
"0.62767833",
"0.6213465",
"0.6098763",
"0.6075585",
"0.58385265",
"0.57447296",
"0.57391727",
"0.5735931",
"0.5735931",
"0.570295",
"0.5646223",
"0.56006825",
"0.56006825",
"0.5569809",
"0.55604154",
"0.5557282",
"0.55560994",
"0.5542508",
"0.5523626",
"0.551883... | 0.7496854 | 0 |
Unregister a feature to be announced by Service Discovery. | def unregister_feature(self, feature_name):
self.disco_info.remove_feature(feature_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_feature(self, feature):\r\n try:\r\n self._features.remove(feature)\r\n except Exception:\r\n return\r\n detach = getattr(feature, 'on_detach', None)\r\n if detach is not None:\r\n detach(self)",
"def __delattr__(self, feature):\n set... | [
"0.7234667",
"0.6661622",
"0.6654812",
"0.65258306",
"0.64295805",
"0.63569415",
"0.62806374",
"0.6280209",
"0.62158936",
"0.6206144",
"0.6193515",
"0.6166244",
"0.6110538",
"0.6105044",
"0.6105044",
"0.605418",
"0.6034885",
"0.6032989",
"0.6032759",
"0.6029561",
"0.6011828",... | 0.8387436 | 0 |
Handle various stream state changes and call right methods of `self`. | def __stream_state_change(self,state,arg):
self.stream_state_changed(state,arg)
if state=="fully connected":
self.connected()
elif state=="authenticated":
self.authenticated()
elif state=="authorized":
self.authorized()
elif state=="disconnecte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stream_state_changed(self,state,arg):\n pass",
"def stream_state_changed(self,state,arg):\n if opts.verbose:\n print \"*** State changed: %s %r ***\" % (state,arg)\n else:\n pass",
"def stream_changed(self, uri):\n pass",
"def stream_call(self):\n ... | [
"0.78895384",
"0.68260914",
"0.6409811",
"0.6369162",
"0.6344077",
"0.62601334",
"0.603433",
"0.59010655",
"0.5873999",
"0.5868889",
"0.5808116",
"0.57923627",
"0.57655436",
"0.5761755",
"0.5749359",
"0.573211",
"0.5684717",
"0.56735766",
"0.56671077",
"0.56656724",
"0.564488... | 0.7470412 | 1 |
Handle a discoinfo query. | def __disco_info(self,iq):
q=iq.get_query()
if q.hasProp("node"):
node=from_utf8(q.prop("node"))
else:
node=None
info=self.disco_get_info(node,iq)
if isinstance(info,DiscoInfo):
resp=iq.make_result_response()
self.__logger.debug("Di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli(ctx, query):\n query = query.split('/')\n get_info(query)",
"def get_info(self, info):\r\n pass",
"def process_info(self, info):\n return info",
"def info_handler(userdata, *args):\n\t\tinfo = database.devinfo(userdata[\"cursor\"], args[0])\n\t\t\n\t\tif info is None:\n\t\t\tprint... | [
"0.59908015",
"0.5874965",
"0.56763387",
"0.56491685",
"0.5562806",
"0.551351",
"0.5379382",
"0.5369016",
"0.5272622",
"0.52676773",
"0.52373207",
"0.5186972",
"0.5169449",
"0.51482904",
"0.5144639",
"0.5129233",
"0.51241094",
"0.5123439",
"0.509425",
"0.50923896",
"0.508306"... | 0.70154274 | 0 |
Handle a discoitems query. | def __disco_items(self,iq):
q=iq.get_query()
if q.hasProp("node"):
node=from_utf8(q.prop("node"))
else:
node=None
items=self.disco_get_items(node,iq)
if isinstance(items,DiscoItems):
resp=iq.make_result_response()
self.__logger.debu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_items_handler(query):\n items = getItemsByName(query)\n return jsonify(items=[i.serialize for i in items])",
"def query_items(self, request, params, payload):\n return util.ndb_query_from_values(self.model, params).fetch()",
"def get_items_for_query(self, query_str):\n raise NotIm... | [
"0.57164264",
"0.5608247",
"0.5520259",
"0.5432534",
"0.53975445",
"0.53627044",
"0.5322989",
"0.5303249",
"0.5280937",
"0.52668864",
"0.5260443",
"0.5259907",
"0.5255112",
"0.5254149",
"0.5249836",
"0.51780385",
"0.514595",
"0.5127345",
"0.5107591",
"0.5099575",
"0.5099575",... | 0.66721976 | 0 |
Handle stream creation event. [may be overriden in derived classes] | def stream_created(self,stream):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_stream(self):\n pass",
"def start_stream(self):\n pass",
"def add_stream_to_event(self,stream):\n assert isinstance(stream,Stream)",
"def process_IN_CREATE(self, event):\n self.ProcessFile(event.name)",
"def __init__(self, stream):\n self.stream = stream",
"def _... | [
"0.7602492",
"0.7028708",
"0.6454284",
"0.64243484",
"0.63340473",
"0.63340473",
"0.63292897",
"0.62247956",
"0.61535805",
"0.6152194",
"0.61246437",
"0.60779375",
"0.60511464",
"0.6039878",
"0.60376835",
"0.6023824",
"0.6018856",
"0.60125256",
"0.6009551",
"0.59860206",
"0.5... | 0.83577925 | 0 |
Handle stream closure event. [may be overriden in derived classes] | def stream_closed(self,stream):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stream_status_event(self, event):\r\n pass",
"def request_received(self, event):\n log.debug(\"request received, stream %s\", event.stream_id)",
"def stream_state_changed(self,state,arg):\n pass",
"def stream_call(self):\n pass",
"def process_IN_CLOSE_WRITE(self, event):",
"de... | [
"0.68242705",
"0.6463266",
"0.6414683",
"0.6398063",
"0.6271539",
"0.62169015",
"0.60852075",
"0.6076142",
"0.6034561",
"0.59915805",
"0.59613615",
"0.5934897",
"0.5905793",
"0.5898639",
"0.58615917",
"0.58546025",
"0.58373463",
"0.58128047",
"0.5790825",
"0.5786417",
"0.5744... | 0.6526973 | 1 |
Handle a stream error received. [may be overriden in derived classes] | def stream_error(self,err):
self.__logger.debug("Stream error: condition: %s %r"
% (err.get_condition().name,err.serialize())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_request_error(self, status_code):\n log.error(\"Stream encountered HTTP error: %d\", status_code)",
"def on_connection_error(self):\n log.error(\"Stream connection has errored or timed out\")",
"def _handle_error(self, soc):\n err_string = \"socket error\"\n if soc in self._reading:\... | [
"0.7221695",
"0.69530296",
"0.68626505",
"0.6637434",
"0.6482486",
"0.6361655",
"0.63598186",
"0.6275657",
"0.62751657",
"0.6272131",
"0.62548524",
"0.62074804",
"0.6178833",
"0.6163628",
"0.6155807",
"0.61543494",
"0.61513495",
"0.6131373",
"0.6104614",
"0.60864156",
"0.6047... | 0.70682997 | 1 |
Handle a stream state change. [may be overriden in derived classes] | def stream_state_changed(self,state,arg):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __stream_state_change(self,state,arg):\n self.stream_state_changed(state,arg)\n if state==\"fully connected\":\n self.connected()\n elif state==\"authenticated\":\n self.authenticated()\n elif state==\"authorized\":\n self.authorized()\n elif ... | [
"0.8110733",
"0.79275924",
"0.70709205",
"0.6905514",
"0.6596064",
"0.6596064",
"0.6517958",
"0.62820935",
"0.6261136",
"0.6224113",
"0.6183899",
"0.616299",
"0.6083104",
"0.6066408",
"0.60274255",
"0.6026631",
"0.60072976",
"0.6000606",
"0.59990644",
"0.59986216",
"0.5992868... | 0.87195003 | 0 |
Handle successful authentication event. A good place to register stanza handlers and disco features. [should be overriden in derived classes] | def authenticated(self):
self.__logger.debug("Setting up Disco handlers...")
self.stream.set_iq_get_handler("query","http://jabber.org/protocol/disco#items",
self.__disco_items)
self.stream.set_iq_get_handler("query","http://jabber.org/protocol/disco#info",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authentication_hook(self):\n pass",
"def auth_complete(self, *args, **kwargs):\n request_data = self.strategy.request_data()\n\n sso_params = request_data.get(\"sso\")\n sso_signature = request_data.get(\"sig\")\n\n param_signature = hmac.new(\n self.setting(\"SE... | [
"0.68363607",
"0.6044735",
"0.60170233",
"0.60143876",
"0.60114545",
"0.60049105",
"0.59941304",
"0.5974587",
"0.5890883",
"0.5889594",
"0.5859647",
"0.5840435",
"0.58397806",
"0.58061874",
"0.58061874",
"0.5791992",
"0.57758445",
"0.5771166",
"0.57590616",
"0.5739374",
"0.57... | 0.62774074 | 1 |
Get discoinfo data for a node. [may be overriden in derived classes] | def disco_get_info(self,node,iq):
to=iq.get_to()
if to and to!=self.jid:
return iq.make_error_response("recipient-unavailable")
if not node and self.disco_info:
return self.disco_info
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __disco_info(self,iq):\n q=iq.get_query()\n if q.hasProp(\"node\"):\n node=from_utf8(q.prop(\"node\"))\n else:\n node=None\n info=self.disco_get_info(node,iq)\n if isinstance(info,DiscoInfo):\n resp=iq.make_result_response()\n self.... | [
"0.6871241",
"0.62665915",
"0.61718",
"0.60817903",
"0.5979027",
"0.5979027",
"0.597608",
"0.5964263",
"0.59326667",
"0.59011",
"0.5897912",
"0.58444035",
"0.5842514",
"0.58325905",
"0.5814806",
"0.581295",
"0.5807344",
"0.57974905",
"0.5793282",
"0.57798433",
"0.57316035",
... | 0.6782496 | 1 |
Get discoitems data for a node. [may be overriden in derived classes] | def disco_get_items(self,node,iq):
to=iq.get_to()
if to and to!=self.jid:
return iq.make_error_response("recipient-unavailable")
if not node and self.disco_items:
return self.disco_items
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data(node):\n return node['data']",
"def getItemData(itemId):\n return Gw2Spidy._request('item', str(itemId))['result']",
"def __disco_items(self,iq):\n q=iq.get_query()\n if q.hasProp(\"node\"):\n node=from_utf8(q.prop(\"node\"))\n else:\n node=None... | [
"0.633038",
"0.6200804",
"0.6013455",
"0.59789824",
"0.59707445",
"0.5966929",
"0.59421146",
"0.59097546",
"0.56797266",
"0.5665139",
"0.56622565",
"0.56536365",
"0.56274885",
"0.55336416",
"0.55131185",
"0.5499119",
"0.54829735",
"0.54567564",
"0.5450693",
"0.5430541",
"0.54... | 0.62508786 | 1 |
Interpolation of a staircase function using averaging. This function returns nan outside of the input abscissa range. | def interp1d_stair_aver(x, y): #TODO: deal with the case x not sorted
def f(xp):
yp=np.empty(np.size(xp)-1)
xmod=x[~(np.isnan(x)+np.isnan(y))]
ymod=y[~(np.isnan(x)+np.isnan(y))]
yint=np.cumsum(np.concatenate((np.array([0]),ymod[:-1]*(xmod[1:]-xmod[:-1]))))
g=interp1d(xmod,y... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interp1d_stair_aver_withnan(x, y): #TODO: deal with the case x not sorted\n def f(xp):\n xmod=x[~(np.isnan(x)+np.isnan(y))]\n ymod=y[~(np.isnan(x)+np.isnan(y))]\n yp=np.empty(np.size(xp)-1)\n yint=np.cumsum(np.concatenate((np.array([0]),ymod[:-1]*(xmod[1:]-xmod[:-1]))))\n ... | [
"0.6612869",
"0.6197294",
"0.6021409",
"0.59408367",
"0.58685285",
"0.5757912",
"0.5747442",
"0.5746117",
"0.5628356",
"0.56112516",
"0.5594228",
"0.5554872",
"0.5553829",
"0.5519848",
"0.5465822",
"0.54347026",
"0.5407415",
"0.5396332",
"0.53776",
"0.5349899",
"0.5349717",
... | 0.6691568 | 0 |
Interpolation of a staircase function using averaging. This function returns nan when there are all nans in one interpolation interval. | def interp1d_stair_aver_withnan(x, y): #TODO: deal with the case x not sorted
def f(xp):
xmod=x[~(np.isnan(x)+np.isnan(y))]
ymod=y[~(np.isnan(x)+np.isnan(y))]
yp=np.empty(np.size(xp)-1)
yint=np.cumsum(np.concatenate((np.array([0]),ymod[:-1]*(xmod[1:]-xmod[:-1]))))
g=interp1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interp1d_stair_aver(x, y): #TODO: deal with the case x not sorted\n def f(xp):\n yp=np.empty(np.size(xp)-1)\n xmod=x[~(np.isnan(x)+np.isnan(y))]\n ymod=y[~(np.isnan(x)+np.isnan(y))]\n yint=np.cumsum(np.concatenate((np.array([0]),ymod[:-1]*(xmod[1:]-xmod[:-1]))))\n g=inte... | [
"0.6942735",
"0.64421344",
"0.6326304",
"0.6222424",
"0.6200586",
"0.6040275",
"0.5972592",
"0.59142005",
"0.58430594",
"0.5767788",
"0.5762497",
"0.5755958",
"0.5682408",
"0.56756353",
"0.5646744",
"0.564491",
"0.5589128",
"0.55759656",
"0.55423373",
"0.55390733",
"0.552185"... | 0.71166354 | 0 |
Initialize the site record attributes. | def __init__(self, site_record_string) -> None:
super().__init__()
self.quadrat = None
self.waypoint = None
self.grid_reference = None
self.photo_up = None
self.photo_down = None
self.wetness = None
self.canopy = None
self.species = []
stri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_attributes(self):\n self.attr = {\n 'name': None,\n 'tags': [],\n 'openHours': None,\n 'type': None,\n 'parent': None,\n 'locationId': None,\n 'bannerAbbreviation': None,\n 'arcGisAbbreviation': None,\n ... | [
"0.6735955",
"0.65529585",
"0.6512695",
"0.63683957",
"0.63453543",
"0.6218702",
"0.61691666",
"0.6167701",
"0.61475956",
"0.608511",
"0.603915",
"0.6023864",
"0.59777045",
"0.595316",
"0.5944511",
"0.5943978",
"0.5942444",
"0.5922102",
"0.5920835",
"0.5882726",
"0.586566",
... | 0.7114244 | 0 |
Return all subtiles contained within a tile | def all_descendant_tiles(x, y, zoom, max_zoom):
if zoom < max_zoom:
for child_tile in mercantile.children(x, y, zoom):
yield child_tile
for desc_tile in all_descendant_tiles(child_tile.x, child_tile.y,
child_tile.z, max_zoom):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_tiles(self):\n lat1, lat2 = self.bbox.south, self.bbox.north\n lon1, lon2 = self.bbox.west, self.bbox.east\n # convert to geographic bounding box\n minlat, minlon = min(lat1, lat2), min(lon1, lon2)\n maxlat, maxlon = max(lat1, lat2), max(lon1, lon2)\n\n # convert ... | [
"0.676234",
"0.6596666",
"0.64846224",
"0.63919574",
"0.63342875",
"0.63312995",
"0.6318957",
"0.6259967",
"0.6224775",
"0.62130743",
"0.6210267",
"0.61658144",
"0.61581886",
"0.6139943",
"0.6124439",
"0.6120807",
"0.6054848",
"0.601967",
"0.6005847",
"0.5993344",
"0.5978138"... | 0.6925616 | 0 |
All tiles that should not be in MBTiles | def redundant_tiles(mbtiles, required_tiles):
xyz_dict= lambda: defaultdict(xyz_dict)
# Mark all tiles that are required
marked_tiles = xyz_dict()
for tile in required_tiles:
marked_tiles[tile.z][tile.x][tile.y] = True
for tile in mbtiles.all_tiles():
required = marked_tiles[tile.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def missing_tiles(mbtiles, required_tiles):\n for tile in required_tiles:\n if not mbtiles.tile_exists(tile.x, tile.y, tile.z):\n yield tile",
"def open_tiles(self):\n return list(filter(None, self.empty))",
"def discard_tile(self):\n raise NotImplemented()",
"def find_tiles(se... | [
"0.71309334",
"0.66754884",
"0.65807",
"0.6471359",
"0.6469424",
"0.64363986",
"0.64131284",
"0.63628995",
"0.63628465",
"0.63358223",
"0.63254714",
"0.63083833",
"0.6305903",
"0.6300953",
"0.6284223",
"0.6275323",
"0.62566996",
"0.6220742",
"0.6201428",
"0.6201267",
"0.61915... | 0.69980603 | 1 |
All tiles that should be in MBTiles but are missing | def missing_tiles(mbtiles, required_tiles):
for tile in required_tiles:
if not mbtiles.tile_exists(tile.x, tile.y, tile.z):
yield tile | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redundant_tiles(mbtiles, required_tiles):\n xyz_dict= lambda: defaultdict(xyz_dict)\n\n # Mark all tiles that are required\n marked_tiles = xyz_dict()\n for tile in required_tiles:\n marked_tiles[tile.z][tile.x][tile.y] = True\n\n\n for tile in mbtiles.all_tiles():\n required = mar... | [
"0.7078869",
"0.6778325",
"0.6713871",
"0.6635691",
"0.659477",
"0.65015763",
"0.6449895",
"0.64383185",
"0.6418814",
"0.63844216",
"0.6355032",
"0.6353515",
"0.6344302",
"0.63361865",
"0.6327802",
"0.62926275",
"0.62705094",
"0.626863",
"0.6231602",
"0.6198358",
"0.6195752",... | 0.77272135 | 0 |
Calculate min, max, mean and stddev for values applying a factor. | def _calculate_stats(values, factor=1):
result = {'min': min(values) * factor,
'max': max(values) * factor,
'sum': sum(values) * factor,
'mean': 0,
'stddev': 0}
if values:
mean = sum(values) / float(len(values))
result['mean'] = factor * m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_statistical_measures(errors, step_error, max_error, min_error=0.):\n if isinstance(errors[0], Iterable):\n mean_val = []\n std_val = []\n median_val = []\n mad_val = []\n max_val = []\n auc_val = []\n fail_val = []\n for e in errors:\n ... | [
"0.64670855",
"0.62839454",
"0.6065232",
"0.60381913",
"0.6000552",
"0.59957784",
"0.59866536",
"0.5935536",
"0.5907073",
"0.5857234",
"0.58116394",
"0.580348",
"0.5799028",
"0.5774109",
"0.577322",
"0.5765237",
"0.57508856",
"0.5731915",
"0.57177246",
"0.56852514",
"0.565329... | 0.7550818 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.