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 |
|---|---|---|---|---|---|---|
Uploads an MLLog JSON metrics file to BigQuery. | def upload_file(metrics_file, project, dataset, table, model_name=None):
with open(metrics_file) as fp:
metrics = json.load(fp)
metrics = convert_format_in_metrics_list(metrics)
benchmark_run = [{
'metrics': metrics,
'upload_ts': _current_epoch_secs(),
'model_name': model_name,
}]
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_metrics(metrics_dict, project, dataset, table):\n # Credentials will be loaded from envvar $GOOGLE_APPLICATION_CREDENTIALS.\n bq_client = bigquery.Client(project=project)\n table_ref = bq_client.dataset(dataset).table(table)\n errors = bq_client.insert_rows_json(table_ref, metrics_dict)\n return er... | [
"0.6523446",
"0.5977217",
"0.58539873",
"0.57336205",
"0.553127",
"0.5528499",
"0.54631466",
"0.53195614",
"0.5305177",
"0.5258516",
"0.52165115",
"0.51927817",
"0.5180879",
"0.5147956",
"0.51438236",
"0.5134168",
"0.5129649",
"0.511234",
"0.5095287",
"0.5092074",
"0.5082945"... | 0.66691846 | 0 |
Uploads a list of BigQuerycompliant metrics. Uses credentials loaded from envvars. | def upload_metrics(metrics_dict, project, dataset, table):
# Credentials will be loaded from envvar $GOOGLE_APPLICATION_CREDENTIALS.
bq_client = bigquery.Client(project=project)
table_ref = bq_client.dataset(dataset).table(table)
errors = bq_client.insert_rows_json(table_ref, metrics_dict)
return errors | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_file(metrics_file, project, dataset, table, model_name=None):\n with open(metrics_file) as fp:\n metrics = json.load(fp)\n\n metrics = convert_format_in_metrics_list(metrics)\n\n benchmark_run = [{\n 'metrics': metrics,\n 'upload_ts': _current_epoch_secs(),\n 'model_name': model_nam... | [
"0.66197985",
"0.5868843",
"0.57163423",
"0.5687214",
"0.5663961",
"0.5571626",
"0.55640894",
"0.5533103",
"0.55106306",
"0.54016525",
"0.53770477",
"0.53562987",
"0.5323036",
"0.53031945",
"0.5276902",
"0.5260836",
"0.52581626",
"0.5251817",
"0.5218062",
"0.51744646",
"0.516... | 0.7244196 | 0 |
adjust shape of the data to the shape of the placeholder if possible. If shape is incompatible, AssertionError is thrown | def adjust_shape(placeholder, data):
if not isinstance(data, np.ndarray) and not isinstance(data, list):
return data
if isinstance(data, list):
data = np.array(data)
placeholder_shape = [x or -1 for x in placeholder.shape.as_list()]
assert _check_shape(placeholder_shape, data.shape), \... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_shape(placeholder_shape, data_shape):\n\n return True",
"def unchanged_shape(input_shape):\n return input_shape",
"def _keras_update_shape(self, prep):\n\n # Run preprocessing on the training data\n X_transform = prep.fit_transform(self.X_train)\n\n # If the input shape ha... | [
"0.7264371",
"0.6425713",
"0.62848926",
"0.6173703",
"0.61707115",
"0.61548173",
"0.61498374",
"0.6106558",
"0.6080679",
"0.60698617",
"0.604165",
"0.6010312",
"0.59979993",
"0.5996327",
"0.59849435",
"0.596573",
"0.5940336",
"0.5940336",
"0.5931667",
"0.59261507",
"0.5912691... | 0.7831077 | 0 |
Get default session or create one with a given config | def get_session(config=None):
sess = tf.get_default_session()
if sess is None:
sess = make_session(config=config, make_default=True)
return sess | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_session(self, db_config=\"Database\"):\n # If the DB is not in the sessionmaker_dict, make it\n if db_config not in self.sessionmaker_dict:\n self.make_sessionmaker(db_config)\n\n # Get the sessionmaker object from the sessionmaker dict\n sessionmaker_obj = self.sessi... | [
"0.703297",
"0.69959134",
"0.6906809",
"0.6772363",
"0.6763062",
"0.6684641",
"0.66016096",
"0.6570028",
"0.6557356",
"0.6539421",
"0.65383965",
"0.65320086",
"0.64519566",
"0.6451444",
"0.6413892",
"0.6412225",
"0.6408763",
"0.64006054",
"0.63860995",
"0.63715434",
"0.635402... | 0.75204444 | 0 |
Create placeholder to feed observations into of the size appropriate to the observation space | def observation_placeholder(ob_space, batch_size=None, name='Ob'):
assert isinstance(ob_space, (Discrete, Box, MultiDiscrete)), \
'Can only deal with Discrete and Box observation spaces for now'
dtype = ob_space.dtype
if dtype == np.int8:
dtype = np.uint8
return tf.placeholder(shape=(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_placeholders(self):\n # \"None\" means the batches may have a variable batch size and length.\n self.x = tf.placeholder(tf.int64, shape=[None, None])",
"def dummy_data(size):\n add_dummy_data(size)",
"def __create_placeholders(self):\n with tf.name_scope(\"data\"):\n self... | [
"0.6633393",
"0.6370947",
"0.6204943",
"0.6117182",
"0.6056088",
"0.59087914",
"0.59023803",
"0.5752217",
"0.5752217",
"0.57422525",
"0.57301575",
"0.57257634",
"0.5703276",
"0.57009584",
"0.5652739",
"0.5641767",
"0.5617518",
"0.55950457",
"0.55878353",
"0.5542547",
"0.55369... | 0.669906 | 0 |
Computes fraction of variance that ypred explains about y. Returns 1 Var[yypred] / Var[y] | def explained_variance(ypred, y):
assert y.ndim == 1 and ypred.ndim == 1
vary = np.var(y)
return np.nan if vary == 0 else 1 - np.var(y-ypred)/vary | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def explained_variance(ypred,y):\n assert y.ndim == 1 and ypred.ndim == 1\n vary = np.var(y)\n return np.nan if vary==0 else 1 - np.var(y-ypred)/vary",
"def explained_variance(ypred: th.Tensor, y: th.Tensor, comm: MPI.Comm = None) -> float:\n assert ypred.shape == y.shape\n err = y - ypred\n if... | [
"0.81318265",
"0.74437964",
"0.7169984",
"0.713317",
"0.70109063",
"0.68943655",
"0.6867458",
"0.6800784",
"0.67746234",
"0.67746234",
"0.67746234",
"0.67668754",
"0.6749416",
"0.6728679",
"0.6671476",
"0.66572624",
"0.6569937",
"0.65656984",
"0.6551609",
"0.6539363",
"0.6519... | 0.8116399 | 1 |
Caches all checksumtobuffer entries in zipfile All "file names" in the zipfile must be checksum hexes Note that caching is temporary and entries will be removed after some time if no element (cell, expression, or highlevel library) holds their checksum This can be overridden with "incref=True" (not recommended for long... | def add_zip(manager, zipfile, incref=False):
from .core.cache.buffer_cache import empty_dict_checksum, empty_list_checksum
result = []
for checksum in zipfile.namelist():
if checksum in (empty_dict_checksum, empty_list_checksum):
continue
checksum2 = bytes.fromhex(checksum)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_hash(cls, filelike, digest):\r\n block_size = digest.block_size * 1024\r\n for chunk in iter(lambda: filelike.read(block_size), b''):\r\n digest.update(chunk)",
"def hash_file_in_zip(zip_handler, file_path_in_zip, algorithm=\"sha1\"):\n block_size = 64 * 1024\n hasher = getattr(hashli... | [
"0.58678126",
"0.58579415",
"0.5782853",
"0.54929125",
"0.5450387",
"0.5393173",
"0.5379317",
"0.5343442",
"0.53043896",
"0.5301792",
"0.52878374",
"0.5282642",
"0.5252761",
"0.5217392",
"0.52024865",
"0.52001184",
"0.5122253",
"0.50365645",
"0.5028685",
"0.5016187",
"0.49699... | 0.6674768 | 0 |
Fills checksums in the nodes from TEMP values, if untranslated | def fill_checksums(mgr, nodes, *, path=None):
from .core.structured_cell import StructuredCell
first_exc = None
for p in nodes:
node, old_checksum = None, None
try:
pp = path + p if path is not None else p
node = nodes[p]
if node["type"] in ("link", "conte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_totals(self):\n # Reset counts to 0\n self.total_f = self.total_s = self.total_intra = self.total_mac_regular = self.total_mac_infected = \\\n self.total_mac_activated = self.total_regular_fast = self.total_regular_slow = self.total_infected_fast = \\\n self.total_inf... | [
"0.5373244",
"0.5351049",
"0.52009624",
"0.5196692",
"0.5084761",
"0.5032294",
"0.5026871",
"0.50247073",
"0.50177515",
"0.4969107",
"0.49379054",
"0.4932278",
"0.49272853",
"0.49116668",
"0.4883707",
"0.48715746",
"0.48671964",
"0.48646513",
"0.48619476",
"0.48481774",
"0.48... | 0.6553185 | 0 |
Return the weighted average and standard deviation. values, weights Numpy ndarrays with the same shape. | def weighted_avg_and_std(values, weights):
average = np.average(values, weights=weights)
variance = np.average((values-average)**2, weights=weights) # Fast and numerically precise
return (average, np.sqrt(variance)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weighted_avg_and_std(values, weights):\n average = np.average(values, weights=weights)\n variance = np.average((values-average)**2, weights=weights)\n return average, np.sqrt(variance)",
"def weighted_avg_and_std(values, weights):\n values = np.array(values)\n values = values[np.isfinite(value... | [
"0.8005689",
"0.7901033",
"0.7886321",
"0.78607464",
"0.78606933",
"0.76652753",
"0.76652753",
"0.7482152",
"0.7358072",
"0.7352045",
"0.73219514",
"0.71806735",
"0.70576894",
"0.7007703",
"0.6995239",
"0.6995239",
"0.69312394",
"0.6750909",
"0.6639378",
"0.6638508",
"0.66308... | 0.79902005 | 1 |
Compute weighted percentiles. If the weights are equal, this is the same as normal percentiles. Elements of the C{data} and C{wt} arrays correspond to each other and must have equal length (unless C{wt} is C{None}). | def weighted_percentiles(data, wt, percentiles):
assert np.greater_equal(percentiles, 0.0).all(), "Percentiles less than zero"
assert np.less_equal(percentiles, 1.0).all(), "Percentiles greater than one"
data = np.asarray(data)
assert len(data.shape) == 1
if w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percentile(data, percentiles, weights=None):\n # check if actually weighted percentiles is needed\n if weights is None:\n return np.percentile(data, list(percentiles))\n if np.equal(weights, 1.).all():\n return np.percentile(data, list(percentiles))\n\n # make sure percentiles are fra... | [
"0.76435167",
"0.65649253",
"0.65649253",
"0.6541879",
"0.6504269",
"0.6326886",
"0.6307562",
"0.6179892",
"0.6047864",
"0.6012886",
"0.59321684",
"0.57003355",
"0.56894684",
"0.5683082",
"0.5592804",
"0.55798393",
"0.5522773",
"0.54804194",
"0.5478309",
"0.54608065",
"0.5386... | 0.84741753 | 0 |
Returns median ignoring NAN | def nanmedian(arr, **kwargs):
return ma.median( ma.masked_where(arr!=arr, arr), **kwargs ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _nanmedian(arr1d): # This only works on 1d arrays\n cond = 1-np.isnan(arr1d)\n x = np.sort(np.compress(cond,arr1d,axis=-1))\n if x.size == 0:\n return np.nan\n return np.median(x)",
"def nanmedian(x, axis=0, preop=None):\n x = np.asarray(x)\n if axis is None:\n x = x.ravel()\... | [
"0.7612167",
"0.760392",
"0.75946695",
"0.75930095",
"0.7547139",
"0.7506518",
"0.74757653",
"0.7468638",
"0.7417313",
"0.73726755",
"0.7257516",
"0.72557527",
"0.7226571",
"0.7222345",
"0.72191626",
"0.7219064",
"0.718095",
"0.7178429",
"0.7170332",
"0.71539026",
"0.7150443"... | 0.7958463 | 0 |
extracts the stem from a plural noun, or returns empty string | def noun_stem (s):
"""codes from statements.py (PART A)"""
def match (p):
return re.match(p + '$', s, re.IGNORECASE)
if (s in unchanging_plurals_list):
return s
elif (s[-3:] == 'men'):
return s[0:-3] + 'man'
elif match('.*(?<!.[aeiousxyz]|sh|ch)s'):
return s[:-1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stem(self) -> str:",
"def stem(s):\r\n if len(s) < 5 :\r\n return s\r\n \r\n if s[-3:] == 'ing':\r\n if s[-4] == s[-5]:\r\n if s[-4] == 'l' :\r\n s = s[:-3]\r\n s = s[:-4]\r\n else: \r\n s = s[:-3]\r\n elif s[-2:] == 'er':\r\n ... | [
"0.7141811",
"0.7095378",
"0.7048611",
"0.7027068",
"0.69304997",
"0.67633414",
"0.6726911",
"0.6687432",
"0.6676323",
"0.6651816",
"0.66005397",
"0.6599164",
"0.6525595",
"0.65212137",
"0.65207666",
"0.64794654",
"0.64794654",
"0.6475581",
"0.64637524",
"0.64192605",
"0.6394... | 0.7957819 | 0 |
returns a list of all possible tags for wd relative to lx | def tag_word (lx,wd):
resultSet = {tag for (word, tag) in function_words_tags if (word == wd)}
nS = noun_stem(wd)
vS = verb_stem(wd)
for x in lx.getAll('A'):
if (x == wd):
resultSet.add('A')
for x in lx.getAll('P'):
if (x == wd):
resultSet.add('P')
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_words (lx, wds):\n if (wds == []):\n return [[]]\n else:\n tag_first = tag_word (lx, wds[0])\n tag_rest = tag_words (lx, wds[1:])\n return [[fst] + rst for fst in tag_first for rst in tag_rest]",
"def tags():",
"def list_all_tags(self,obs):",
"def get_target_tags(sel... | [
"0.68528354",
"0.6328143",
"0.6211847",
"0.597972",
"0.5962043",
"0.5927393",
"0.5911419",
"0.58973616",
"0.5871693",
"0.5852154",
"0.5825749",
"0.58123523",
"0.5728548",
"0.57055503",
"0.568728",
"0.5677005",
"0.56436646",
"0.56359637",
"0.5633816",
"0.56156874",
"0.5606692"... | 0.69890743 | 0 |
returns a list of all possible taggings for a list of words | def tag_words (lx, wds):
if (wds == []):
return [[]]
else:
tag_first = tag_word (lx, wds[0])
tag_rest = tag_words (lx, wds[1:])
return [[fst] + rst for fst in tag_first for rst in tag_rest] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findTags(user_input, tagged_text):\n result = []\n for item in tagged_text:\n for w in user_input:\n if w[WORD] == item[WORD]:\n tup = (w[WORD], item[TAG])\n result.append(tup)\n continue\n\n return result",
"def build_taglist(tags):\n taglis... | [
"0.6754341",
"0.6627011",
"0.6556509",
"0.64722145",
"0.64334977",
"0.6429258",
"0.6421842",
"0.6399951",
"0.6383925",
"0.63640195",
"0.6356996",
"0.6321087",
"0.63097256",
"0.63097256",
"0.6238624",
"0.62298197",
"0.6217182",
"0.62165517",
"0.6199632",
"0.6197919",
"0.614274... | 0.6719142 | 1 |
Tests that the serializer renders an existing instance correctly. | def test_renders_instance_correctly(self):
# Make a service to render
service = self.project.services.create(name = 'service1', category = self.category)
# In order to render the links correctly, there must be a request in the context
request = APIRequestFactory().post('/services/{}/'.fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_object_creation(self):\n serializer = ProductSerializer(data=self.data)\n self.assertTrue(serializer.is_valid())\n product = serializer.save()\n\n self.assertEqual(product.title, self.title)\n self.assertEqual(product.description, self.description)\n self.assertEq... | [
"0.6839425",
"0.6759501",
"0.67334944",
"0.6726043",
"0.6640404",
"0.659872",
"0.6523596",
"0.6521611",
"0.6485039",
"0.64780027",
"0.64752555",
"0.6442146",
"0.63352555",
"0.63208264",
"0.6242018",
"0.622369",
"0.6210658",
"0.62052596",
"0.6187093",
"0.61081153",
"0.60960174... | 0.72793794 | 0 |
Tests that required fields are enforced on create. | def test_create_enforces_required_fields(self):
serializer = ServiceSerializer(data = {}, context = dict(project = self.project))
self.assertFalse(serializer.is_valid())
required_fields = {'name', 'category'}
self.assertCountEqual(serializer.errors.keys(), required_fields)
for na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_required_fields(self):\n assert self.title\n assert self.format",
"def test_required_field_values_are_present():\n\n model_definition = {'language': {'type': 'fixed',\n 'required': True,\n 'persisted': True},\n ... | [
"0.7458286",
"0.7444483",
"0.7124201",
"0.7121246",
"0.6951668",
"0.6918757",
"0.688382",
"0.6875096",
"0.6875058",
"0.6815032",
"0.67094404",
"0.67026573",
"0.6675406",
"0.6669527",
"0.66245985",
"0.66205037",
"0.6608198",
"0.659373",
"0.6577857",
"0.6564985",
"0.6543988",
... | 0.80200785 | 0 |
Tests that the serializer enforces the unique together constraint on category and name. | def test_cannot_create_with_same_category_and_name(self):
# Create an initial service
self.project.services.create(name = "service1", category = self.category)
# Then try to create the same service using the serializer
serializer = ServiceSerializer(
data = dict(name = "servi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_add_same_category(self):\n response = self.client.post('/api/v1/categories',\n data=json.dumps(category[0]),\n content_type='application/json',\n headers=self.admin_headers)\n self.assert... | [
"0.7251836",
"0.7112222",
"0.7026761",
"0.68964195",
"0.67048824",
"0.66926086",
"0.66434354",
"0.66207445",
"0.66040266",
"0.656431",
"0.65539294",
"0.6550937",
"0.6546715",
"0.63720655",
"0.6355607",
"0.6302978",
"0.6273455",
"0.62039167",
"0.6142832",
"0.61005276",
"0.6081... | 0.749425 | 0 |
Tests that the list serializer renders an existing instance correctly. | def test_list_renders_instance_correctly(self):
# Make a service to render
service = self.project.services.create(name = 'service1', category = self.category)
# In order to render the links correctly there must be a request in the context
request = APIRequestFactory().post('/')
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_one(self):\n obj = self.factory.create()\n response = self._get()\n self.assertEquals(response.status_code, 200)\n self.assertTemplateUsed(response, self.template_name)\n self.assertEquals(response.context['object_list'].count(), 1)\n self.assertEquals(respon... | [
"0.69210505",
"0.68472755",
"0.67852294",
"0.6758423",
"0.66353214",
"0.65901667",
"0.64684844",
"0.64684844",
"0.6466252",
"0.6437805",
"0.64357406",
"0.64165527",
"0.6410081",
"0.6376611",
"0.6368804",
"0.6325705",
"0.6287968",
"0.626912",
"0.62682563",
"0.62665397",
"0.624... | 0.76969224 | 0 |
Tests that invalid requirements correctly fails for the list of services. | def test_list_cannot_create_with_invalid_requirement(self):
# Test with a string for the requirements
serializer = ServiceListSerializer(
data = dict(name = "service2", category = self.category.pk, requirements = "requirements1"),
context = dict(project = self.project)
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _checkServices(self, expectedServices):\n it = iter(self._getServices())\n for (type_uri, service_uri) in expectedServices:\n for element in it:\n if type_uri in xrds.getTypeURIs(element):\n self.assertEqual(xrds.getURI(element), service_uri)\n ... | [
"0.6652535",
"0.63944703",
"0.63525254",
"0.6248919",
"0.6213733",
"0.6155486",
"0.61272925",
"0.6118433",
"0.60867417",
"0.60663563",
"0.6037591",
"0.59633803",
"0.59532416",
"0.59380984",
"0.59379965",
"0.5933373",
"0.59262633",
"0.5893517",
"0.58908415",
"0.58897734",
"0.5... | 0.7205704 | 0 |
For now this just returns chi(z) | def chibar(z):
return chi(z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chi(self):\n return self._chi",
"def chi(Mu, Y):\n return Y*(1-hg2f3(Mu,Y))",
"def test_chi_1(self):\n NN = 0\n w = 0.01\n kz = 1.0e-7\n kp = 1.0e-7\n wp = 2.0e3\n tz = 1.0e-18\n tp = 1.0e-18\n vthz = 1e5\n vthp = 1e5\n omega =... | [
"0.7055452",
"0.69941884",
"0.66041845",
"0.6554016",
"0.6461637",
"0.6452683",
"0.6255398",
"0.62539893",
"0.62385875",
"0.61541283",
"0.61210215",
"0.6045498",
"0.5996258",
"0.59601825",
"0.595365",
"0.5936639",
"0.5900496",
"0.5900496",
"0.5897062",
"0.5893195",
"0.5870829... | 0.879052 | 0 |
Returns the alpha_M parameter (unitless) | def alpha_M(z, c_M = 0):
I = CLASS(z_i)
return I.alpha_M(z, c_M) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alpha(self) -> float:\n return self.intrinsic_matrix[0, 1]",
"def _get_alpha(self, m_t, v_t):\n return max(0, ((-m_t * self._psi \n + math.sqrt((m_t ** 2 * self._phi ** 4) \n / 4 + v_t * self._phi ** 2 * self._xi)) \n ... | [
"0.7024431",
"0.68071014",
"0.6656122",
"0.6620876",
"0.66078854",
"0.66078854",
"0.66078854",
"0.64557284",
"0.6452207",
"0.6432217",
"0.6417361",
"0.64103806",
"0.6396868",
"0.6385246",
"0.63572574",
"0.63183844",
"0.6268445",
"0.6252516",
"0.6239953",
"0.62385505",
"0.6219... | 0.73521745 | 0 |
For 1Darrays z, zp and k the returned Wk should be of shape (k, z, zp) Unitless | def Wk(z, zp, k, c_M=0, c_B=0):
c = 299792458/1000 # km/s
A = np.zeros((len(k), len(z), len(zp)))
chiz = np.copy(A); np.transpose(chiz, (0,2,1))[:] = chi(z)
chifraction = (chiz - chi(zp))*chi(zp)/chiz
A[:] = omega_matter(zp)*H(zp)/(1 + zp)**2*G_light(zp, c_M, c_B)
W2 = 3/2*A*chifraction
Wtra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Wv(z, k, c_M=0):\n k *= 0.6763 # 1/Mpc\n c = 299792458/1000 # km/s\n A = np.zeros((len(k), len(z)))\n A[:] = -(1 - c/(Hcal(z)*chi(z)) + alpha_M(z, c_M)/2)*f(z)*H(z)/(1+z)\n Wtransp = np.transpose(A)*1/k**2*1/c\n W = np.transpose(Wtransp)\n return W",
"def Wk2(z, zp, k, c_M=0, c_B=0):\n ... | [
"0.6884488",
"0.6755884",
"0.6065031",
"0.5893971",
"0.57345504",
"0.5673375",
"0.5663741",
"0.5663695",
"0.56613433",
"0.5626072",
"0.5563906",
"0.5558154",
"0.5553848",
"0.5537722",
"0.5469138",
"0.54536694",
"0.5436422",
"0.5432859",
"0.5432065",
"0.5397731",
"0.5397574",
... | 0.71552336 | 0 |
For 1Darrays z and k the returned Wk should be of shape (k, z) k must be of units [h/Mpc] Units Mpc | def Wv(z, k, c_M=0):
k *= 0.6763 # 1/Mpc
c = 299792458/1000 # km/s
A = np.zeros((len(k), len(z)))
A[:] = -(1 - c/(Hcal(z)*chi(z)) + alpha_M(z, c_M)/2)*f(z)*H(z)/(1+z)
Wtransp = np.transpose(A)*1/k**2*1/c
W = np.transpose(Wtransp)
return W | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Wk(z, zp, k, c_M=0, c_B=0):\n c = 299792458/1000 # km/s\n A = np.zeros((len(k), len(z), len(zp)))\n chiz = np.copy(A); np.transpose(chiz, (0,2,1))[:] = chi(z)\n chifraction = (chiz - chi(zp))*chi(zp)/chiz\n A[:] = omega_matter(zp)*H(zp)/(1 + zp)**2*G_light(zp, c_M, c_B)\n W2 = 3/2*A*chifracti... | [
"0.7870504",
"0.7474883",
"0.7132625",
"0.616303",
"0.59628433",
"0.58472097",
"0.57110393",
"0.5689242",
"0.5661133",
"0.56517184",
"0.5599754",
"0.55689734",
"0.55267835",
"0.5524058",
"0.5520632",
"0.5519467",
"0.5500151",
"0.5499817",
"0.54330796",
"0.542372",
"0.54214627... | 0.77516663 | 1 |
From a base directory, go through all subdirectories, find all files with the given extension, apply the given function 'func' to all of them. If no 'func' is passed, we do nothing except counting. INPUT basedir base directory of the dataset func function to apply to all filenames ext extension, .h5 by default RETURN n... | def apply_to_all_files(basedir,func=lambda x: x,ext='.h5'):
cnt = 0
# iterate over all files in all subdirectories
for root, dirs, files in os.walk(basedir):
files = glob.glob(os.path.join(root,'*'+ext))
# count files
cnt += len(files)
# apply function to all files
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_data(*args, **kwargs):\n\n filepath = kwargs[\"filepath\"]\n func = kwargs[\"func\"]\n \n # get all files matching extension from directory\n all_files = []\n for root, dirs, files in os.walk(filepath):\n files = glob.glob(os.path.join(root,'*.json'))\n for f in files :\... | [
"0.5982175",
"0.5941424",
"0.5753361",
"0.5748104",
"0.57224715",
"0.5706049",
"0.5706049",
"0.57050556",
"0.5698501",
"0.56690365",
"0.5656603",
"0.5653413",
"0.564903",
"0.5595214",
"0.5573508",
"0.5569163",
"0.5567944",
"0.552704",
"0.55074143",
"0.5507264",
"0.5444663",
... | 0.85140646 | 0 |
Apply this L{Response} to the given L{IRequest}, setting its response code and headers. | def _applyToRequest(self, request: IRequest) -> Any:
request.setResponseCode(self.code)
for headerName, headerValueOrValues in self.headers.items():
if not isinstance(headerValueOrValues, (str, bytes)):
headerValues = headerValueOrValues
else:
head... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, request):\n self._logger.debug(f'__call__, {request.url} adding Authorization header')\n request.headers[\"Authorization\"] = self._get_auth_value()\n request.register_hook(\"response\", self._handle_401)\n return request",
"def process_response(self, response):\n ... | [
"0.569689",
"0.55160934",
"0.5499549",
"0.5497122",
"0.5462403",
"0.5456694",
"0.5426024",
"0.5416732",
"0.540777",
"0.5398471",
"0.53628373",
"0.5362411",
"0.5333309",
"0.533221",
"0.5288713",
"0.52814555",
"0.52500486",
"0.5240639",
"0.5166942",
"0.51573116",
"0.5150605",
... | 0.7856492 | 0 |
Function to return appliance as a dictionary | def return_as_dictionary(self):
item = Inventory.return_as_dictionary(self)
item['Brand'] = self.brand
item['Voltage'] = self.voltage
return item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_as_dictionary(self):\n output_dict = Inventory.return_as_dictionary(self)\n output_dict['brand'] = self.brand\n output_dict['voltage'] = self.voltage\n\n return output_dict",
"def fusion_api_get_appliance_state(self, appliance):\n return self.appstate.get(applian... | [
"0.6490274",
"0.61623645",
"0.6160245",
"0.6064466",
"0.6014985",
"0.5973834",
"0.59084517",
"0.58709776",
"0.58163977",
"0.5797105",
"0.5795567",
"0.57445794",
"0.57236224",
"0.5689995",
"0.56870043",
"0.5623612",
"0.55827254",
"0.55518955",
"0.55299723",
"0.5495793",
"0.548... | 0.62603354 | 1 |
Execute 'free m' command, grab the memory capacity and used size then return; Memory size 'total_mem', Used_mem, and percentage of used memory. | def memory(self):
# Run 'free -m' command and make a list from output.
mem_data = self.execCMD('free', '-m').split()
total_mem = int(mem_data[7]) / 1024.
used_mem = int(mem_data[15]) / 1024.
# Caculate percentage
used_mem_percent = int(used_mem / (total_mem / 100))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_memory_usage():\n\n memory_usage = {'total' : 0, 'used' : 0}\n meminfo = subprocess.Popen(['free', '-m'], shell=False, stdout=subprocess.PIPE)\n meminfo.stdout.readline()\n total_used = meminfo.stdout.readline()\n memory_usage['total'] = total_used.split()[1]\n memory_usage['used'] = tota... | [
"0.7866056",
"0.72543114",
"0.7155577",
"0.7122068",
"0.6907069",
"0.67725396",
"0.6755199",
"0.67313683",
"0.6701412",
"0.6684663",
"0.66814786",
"0.6665287",
"0.6626875",
"0.6607064",
"0.6602899",
"0.6591926",
"0.65918064",
"0.65682495",
"0.65626854",
"0.65488124",
"0.65280... | 0.8185023 | 0 |
Getter method for discard_packet, mapped from YANG variable /system_monitor/tm/discard_packet (container) | def _get_discard_packet(self):
return self.__discard_packet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_discard_packet(self, v, load=False):\n if hasattr(v, \"_utype\"):\n v = v._utype(v)\n try:\n t = YANGDynClass(v,base=discard_packet.discard_packet, is_container='container', presence=False, yang_name=\"discard-packet\", rest_name=\"discard-packet\", parent=self, path_helper=self._path_help... | [
"0.790528",
"0.6182131",
"0.61668676",
"0.531125",
"0.52867895",
"0.52236766",
"0.52000684",
"0.51729614",
"0.50056964",
"0.4896797",
"0.48735863",
"0.47513863",
"0.4749091",
"0.47213098",
"0.47207725",
"0.47124574",
"0.47078794",
"0.46982715",
"0.46891648",
"0.4664234",
"0.4... | 0.7179013 | 1 |
Setter method for discard_packet, mapped from YANG variable /system_monitor/tm/discard_packet (container) | def _set_discard_packet(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=discard_packet.discard_packet, is_container='container', presence=False, yang_name="discard-packet", rest_name="discard-packet", parent=self, path_helper=self._path_helper, extmethods=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_discard_voq_packet(self, v, load=False):\n if hasattr(v, \"_utype\"):\n v = v._utype(v)\n try:\n t = YANGDynClass(v,base=discard_voq_packet.discard_voq_packet, is_container='container', presence=False, yang_name=\"discard-voq-packet\", rest_name=\"discard-voq-packet\", parent=self, path_he... | [
"0.65819514",
"0.6504372",
"0.5777475",
"0.55611277",
"0.5306879",
"0.52309644",
"0.5206775",
"0.5164954",
"0.51418597",
"0.51133955",
"0.50640184",
"0.49788272",
"0.49216458",
"0.49026236",
"0.48520446",
"0.48438975",
"0.48363075",
"0.4788903",
"0.47200122",
"0.46406695",
"0... | 0.83464676 | 0 |
Getter method for discard_voq_packet, mapped from YANG variable /system_monitor/tm/discard_voq_packet (container) | def _get_discard_voq_packet(self):
return self.__discard_voq_packet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_discard_voq_packet(self, v, load=False):\n if hasattr(v, \"_utype\"):\n v = v._utype(v)\n try:\n t = YANGDynClass(v,base=discard_voq_packet.discard_voq_packet, is_container='container', presence=False, yang_name=\"discard-voq-packet\", rest_name=\"discard-voq-packet\", parent=self, path_he... | [
"0.8085972",
"0.6796295",
"0.62222385",
"0.48254594",
"0.46912187",
"0.46262443",
"0.45535722",
"0.4536514",
"0.4534638",
"0.44781283",
"0.44188026",
"0.43867618",
"0.43729118",
"0.43653727",
"0.43570754",
"0.43370515",
"0.4330832",
"0.4325667",
"0.43130645",
"0.42760116",
"0... | 0.7631716 | 1 |
Setter method for discard_voq_packet, mapped from YANG variable /system_monitor/tm/discard_voq_packet (container) | def _set_discard_voq_packet(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=discard_voq_packet.discard_voq_packet, is_container='container', presence=False, yang_name="discard-voq-packet", rest_name="discard-voq-packet", parent=self, path_helper=self._path... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_discard_packet(self, v, load=False):\n if hasattr(v, \"_utype\"):\n v = v._utype(v)\n try:\n t = YANGDynClass(v,base=discard_packet.discard_packet, is_container='container', presence=False, yang_name=\"discard-packet\", rest_name=\"discard-packet\", parent=self, path_helper=self._path_help... | [
"0.7216919",
"0.69087565",
"0.5475429",
"0.51441365",
"0.4851496",
"0.47530356",
"0.47489414",
"0.47393924",
"0.47100192",
"0.45429173",
"0.4522722",
"0.4488606",
"0.4438179",
"0.4395799",
"0.43296006",
"0.4305724",
"0.42723322",
"0.42414337",
"0.42339814",
"0.42012924",
"0.4... | 0.8485469 | 0 |
Getter method for delete_packet, mapped from YANG variable /system_monitor/tm/delete_packet (container) | def _get_delete_packet(self):
return self.__delete_packet | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_delete_packet(self, v, load=False):\n if hasattr(v, \"_utype\"):\n v = v._utype(v)\n try:\n t = YANGDynClass(v,base=delete_packet.delete_packet, is_container='container', presence=False, yang_name=\"delete-packet\", rest_name=\"delete-packet\", parent=self, path_helper=self._path_helper, e... | [
"0.769457",
"0.51749223",
"0.5043252",
"0.48553017",
"0.4825453",
"0.47454274",
"0.4690791",
"0.4689474",
"0.4682232",
"0.46789247",
"0.4594007",
"0.45689905",
"0.4556813",
"0.44933376",
"0.44364294",
"0.4396366",
"0.43701908",
"0.43589088",
"0.43460083",
"0.43415383",
"0.432... | 0.6530532 | 1 |
Setter method for delete_packet, mapped from YANG variable /system_monitor/tm/delete_packet (container) | def _set_delete_packet(self, v, load=False):
if hasattr(v, "_utype"):
v = v._utype(v)
try:
t = YANGDynClass(v,base=delete_packet.delete_packet, is_container='container', presence=False, yang_name="delete-packet", rest_name="delete-packet", parent=self, path_helper=self._path_helper, extmethods=self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_delete_packet(self):\n return self.__delete_packet",
"def _set_discard_packet(self, v, load=False):\n if hasattr(v, \"_utype\"):\n v = v._utype(v)\n try:\n t = YANGDynClass(v,base=discard_packet.discard_packet, is_container='container', presence=False, yang_name=\"discard-packet\", re... | [
"0.5846014",
"0.55212694",
"0.4750918",
"0.4739482",
"0.46651882",
"0.46579283",
"0.46348274",
"0.4628366",
"0.46215436",
"0.46131364",
"0.45513767",
"0.45244956",
"0.4488758",
"0.44818833",
"0.44707245",
"0.44570056",
"0.44329908",
"0.44034705",
"0.43741593",
"0.43647036",
"... | 0.8180967 | 0 |
Upload command table into the device. The command table can either be specified through the dedicated ``CommandTable`` class or in a raw format, meaning a json string or json dict. In the case of a json string or dict the command table is validated by default against the schema provided by the device. | def upload_to_device(
self,
ct: t.Union[CommandTable, str, dict],
*,
validate: bool = False,
check_upload: bool = True,
) -> None:
try:
self.data(json.dumps(ct.as_dict())) # type: ignore
except AttributeError:
if validate:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_cmd_table(self, cmd_table_str, index=None):\n\n if index is None:\n index = self.index\n\n # Validate if string is a valid JSON\n try:\n json.loads(cmd_table_str)\n except ValueError:\n self.hd.log.error(\"Command table string is invalid JSON ... | [
"0.767257",
"0.5756202",
"0.5746842",
"0.5648261",
"0.5155404",
"0.5083287",
"0.50155735",
"0.4931106",
"0.4912772",
"0.49107316",
"0.49047408",
"0.49035355",
"0.48703343",
"0.48496118",
"0.48195195",
"0.4811149",
"0.48045552",
"0.47865066",
"0.47859934",
"0.47811607",
"0.475... | 0.7371073 | 1 |
Load command table from the device. | def load_from_device(self) -> CommandTable:
ct = CommandTable(self.load_validation_schema(), active_validation=True)
ct.update(self.data())
return ct | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_device():",
"def load_devices():",
"def load_status_table():",
"def loadPlayerCommands(self, player):\n player.addCommand('get', self.commands['get']())\n player.addCommand('drop', self.commands['drop']())\n player.addCommand('go', self.commands['go']())\n player.addComma... | [
"0.6488594",
"0.6189319",
"0.6081568",
"0.60474384",
"0.5816879",
"0.5731737",
"0.56587625",
"0.5533811",
"0.55280423",
"0.5501672",
"0.5501672",
"0.5483072",
"0.54802936",
"0.54446083",
"0.5434541",
"0.5406182",
"0.538996",
"0.5318249",
"0.53113896",
"0.52938235",
"0.5263023... | 0.73740697 | 0 |
Leva os pedidos para o balcao, o garcom tiver algum pedido | def registra_ped(self):
if len(self.anotados) > 0:
# randomiza um tempo que ele leva para ir ate a copa
tempo = random.randint(1, 3)
time.sleep(tempo)
logging.info(" ".join(["garcom",
str(self.nome),
"registrou os ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entrega_ped(self):\n for i in self.anotados:\n # acorda a thread do cliente para ele poder receber e beber\n i.continuar() # e_esperar.set()\n logging.info(\" \".join([\"garcom\",\n str(self.nome),\n \"entregou para o Clie... | [
"0.67858803",
"0.6036683",
"0.5945399",
"0.59296864",
"0.58801556",
"0.57825935",
"0.5776992",
"0.5693268",
"0.5630691",
"0.5626066",
"0.5583205",
"0.551264",
"0.5470678",
"0.5467803",
"0.5462122",
"0.5455559",
"0.5435498",
"0.54268414",
"0.54112256",
"0.53799343",
"0.5364381... | 0.61557084 | 1 |
Vai de cliente em cliente da lista e entrega o pedido do garcom | def entrega_ped(self):
for i in self.anotados:
# acorda a thread do cliente para ele poder receber e beber
i.continuar() # e_esperar.set()
logging.info(" ".join(["garcom",
str(self.nome),
"entregou para o Cliente",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nao_quer_beber(self, cliente):\n self.vazio.acquire()\n with self.lock:\n self.buff_n_quer.append(cliente)\n # libera lara um garcom retira-lo\n self.cheio.release()",
"def carregar_contatos(self):\r\n self.clientes = []\r\n fornecedor = SistemaFornecedor(... | [
"0.71192676",
"0.7080675",
"0.698998",
"0.68995124",
"0.6704582",
"0.67017424",
"0.6601441",
"0.6443575",
"0.62911665",
"0.6271121",
"0.6077145",
"0.604305",
"0.6030782",
"0.6016036",
"0.60023236",
"0.60023236",
"0.59945315",
"0.59109855",
"0.5893534",
"0.58643913",
"0.585586... | 0.7456515 | 0 |
Starts up AutoQuakePycker and setsup processes | def AutoQuakePycker_run():
import glob
from itertools import product
import multiprocessing
import logging
import more_itertools as mit
from munch import munchify
import os
import yaml
from obspy import read_events, Catalog
logger = multiprocessing.log_to_stderr(logging.DEBUG)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_workers():\n party_queue = Queue()\n p = Producer(party_queue)\n p.daemon = True\n c = Consumer(party_queue)\n c.deamon= True\n m = MasterUpdater(db,application_name)\n m.deamon = True\n p.start()\n c.start()\n m.start()",
"def work(self):\n self.config_file = self.a... | [
"0.6752843",
"0.6308155",
"0.62900054",
"0.62779295",
"0.6174796",
"0.6135414",
"0.6087149",
"0.5975377",
"0.5917627",
"0.5861175",
"0.5768359",
"0.5755857",
"0.573232",
"0.5722852",
"0.5693792",
"0.56868386",
"0.5660398",
"0.56511384",
"0.564545",
"0.56340885",
"0.56284803",... | 0.6628572 | 1 |
Process picking on each trace parsed by process_station. | def process_trace(n_tr, tr, sta, orig_time, cmps, cfg):
cmp = tr.stats.channel[2:3]
sta[cmp] = {}
sta[cmp]["times"] = tr.times(reftime=orig_time)
sta[cmp]["tr_results"] = np.zeros(
(len(cfg.picking.FILT_WINS["P"]), sta["lenD"])
)
sta[cmp]["f1_results"] = np.zeros(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_station(sta, st_sta, dist, ev_dict, evt, orig_time, phase, cmps,\n cfg):\n sta[\"ncha\"] = len(st_sta)\n sta[\"lenD\"] = int(st_sta[0].stats.npts)\n sta[\"samplerate\"] = st_sta[0].stats.sampling_rate\n sta[\"nwinsamp\"] = int(np.ceil(cfg.picking.KURT_WINS[0]*sta[\"sample... | [
"0.561336",
"0.5340198",
"0.51733655",
"0.5101451",
"0.50483245",
"0.5014227",
"0.49925804",
"0.49856606",
"0.49655566",
"0.49292234",
"0.49136835",
"0.49119592",
"0.4900823",
"0.4884412",
"0.48709524",
"0.48641142",
"0.4859937",
"0.48597705",
"0.48596904",
"0.48254803",
"0.4... | 0.54188657 | 1 |
Get credentials from credential_code table | def get_credentials():
sql = """
SELECT credential_name, description full_name
FROM credential_code
WHERE can_use = 1
"""
# [('CRNA', 'Certified Registered Nurse Anesthetist'), ... ]
record_set = get_record(sql)
result = dict(record_set)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_account(cls,account):\n for credentials in cls.credential_list:\n if credentials.account == account:\n return credentials",
"def query_device_credential(self, device_code):\n raise NotImplementedError()",
"def find_credentials(cls, account):\n for cred... | [
"0.6380027",
"0.63772357",
"0.62800604",
"0.62043893",
"0.61673486",
"0.6059827",
"0.60042894",
"0.59732854",
"0.59247184",
"0.5885401",
"0.5814344",
"0.5804914",
"0.5797491",
"0.5784889",
"0.5780887",
"0.576941",
"0.57640386",
"0.5682038",
"0.5647576",
"0.5617215",
"0.561149... | 0.7522114 | 0 |
Get license type from license_type table | def get_license_type():
sql = """
SELECT license_type license, description
FROM license_types_codes
WHERE can_use = 'Y'
"""
# [('P', 'Permanent'), ... ]
record_set = get_record(sql)
result = dict(record_set)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lic_type():\n return VocabularyType.create(id='licenses', pid_type='lic')",
"def license_counting_type(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"license_counting_type\")",
"def license_counting_type(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"license_cou... | [
"0.71083283",
"0.65060353",
"0.6409396",
"0.6395097",
"0.6350483",
"0.6280159",
"0.626313",
"0.594117",
"0.59148496",
"0.58682024",
"0.5804771",
"0.57613003",
"0.5729305",
"0.566395",
"0.5644454",
"0.56440747",
"0.56373185",
"0.5595259",
"0.5529593",
"0.55287284",
"0.5500365"... | 0.82150394 | 0 |
Computes the reverse complementary sequence of DNA for the specfied DNA sequence | def get_reverse_complement(dna):
rev_comp = ''
for i in range(0, len(dna)):
nucleo = dna[i]
comp = get_complement(nucleo)
rev_comp = comp + rev_comp
return rev_comp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_complement_strand(dna):\n reverse_complement = \"\"\n\n for character in dna[::-1]:\n if character == \"A\":\n reverse_complement += \"T\"\n elif character == \"T\":\n reverse_complement += \"A\"\n elif character == \"C\":\n reverse_complement... | [
"0.75488645",
"0.75032",
"0.74943614",
"0.7489699",
"0.74795413",
"0.7419932",
"0.73843974",
"0.73704416",
"0.73488766",
"0.7339861",
"0.7338994",
"0.7278367",
"0.7258061",
"0.7248897",
"0.72437245",
"0.7231113",
"0.72207266",
"0.7216731",
"0.72124445",
"0.7201928",
"0.717467... | 0.7621168 | 0 |
Takes a DNA sequence (a string) and splits it into a list of codons as a list of strings. | def split_into_codons(dna):
dna_split = []
length = math.ceil(len(dna)/3)
for i in range(0, length):
j = 3*i
codon = dna[j:j+3]
dna_split += [codon]
return dna_split | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def codonify(strand: str) -> list:\n\n # Loops through the whole string and slices every set of three characters into\n # the list codons\n codons = [strand[index : index + len_codon] for index in range(0,len(strand),len_codon)]\n return codons",
"def split_sequence(self, sequence):\n\t\treturn [char... | [
"0.76325625",
"0.7126395",
"0.664527",
"0.6518877",
"0.64912313",
"0.6343734",
"0.6172283",
"0.5927538",
"0.57787275",
"0.5762863",
"0.57578117",
"0.5722345",
"0.56479174",
"0.5628706",
"0.5622963",
"0.56195796",
"0.5608178",
"0.5603107",
"0.55903715",
"0.5554325",
"0.5506480... | 0.7554874 | 1 |
Computes the maximum length of the longest ORF over num_trials shuffles of the specfied DNA sequence | def longest_ORF_noncoding(dna, num_trials):
i = 0
longest_each_trial = []
while i < num_trials:
shuffled_dna = shuffle_string(dna)
longest_each_trial.append(longest_ORF(shuffled_dna))
i += 1
longest_longest = max(longest_each_trial, key=len)
return len(longest_longest) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_ORF_noncoding(dna, num_trials):\n longest=[]\n for i in range(0,num_trials):\n \tshuffled_str=shuffle_string(dna)\n \tlongest.append(longest_ORF(shuffled_str))\n long_ORF=max(longest,key=len)\n return len(long_ORF)",
"def longest_ORF_noncoding(dna, num_trials):\n longest = ''\n ... | [
"0.87454444",
"0.85417074",
"0.8508988",
"0.8500134",
"0.84909016",
"0.8478915",
"0.8408802",
"0.8328015",
"0.8279816",
"0.8135475",
"0.806552",
"0.80442095",
"0.74661",
"0.7383516",
"0.7355161",
"0.7231103",
"0.7160716",
"0.7150049",
"0.7064139",
"0.70563704",
"0.7049209",
... | 0.87796474 | 0 |
r""" Check if a node is within a given tree | def isInTree(tree, node_id):
if tree.id == node_id:
return True
for child in tree.children:
if isInTree(child, node_id):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree_contains(T, x):",
"def _contains(self, data, node):\n # Base Cases.\n if node is None:\n return False\n \n if data == node.data:\n # print('true')\n return True\n\n # Recursion.\n elif data < node.data:\n return self._... | [
"0.7212649",
"0.69590783",
"0.6943295",
"0.6933358",
"0.68935555",
"0.68585426",
"0.6801516",
"0.6795224",
"0.67887914",
"0.67847973",
"0.67236304",
"0.6670391",
"0.65809155",
"0.6579306",
"0.6579306",
"0.6560116",
"0.65460753",
"0.6535671",
"0.6531757",
"0.6519901",
"0.65154... | 0.7590022 | 0 |
r""" Retrieve trees from the database | def retrieveTrees(c):
all_nodes = dict()
root_nodes = list()
c.execute('''SELECT id, parent_id, title FROM node''')
data_db = c.fetchall()
# Initialize nodes list
for data_line in data_db:
db_child_id = data_line[0]
db_parent_id = data_line[1]
child_title = data_lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree(requets):\n q_all_root = Node.objects.filter(root=None)\n # print(q_all_root)\n tree_data = {'tree': list()}\n if q_all_root.exists():\n for root_node in q_all_root.iterator():\n tree_data['tree'].append(serializers.to_json(root_node))\n return JsonResponse(tree_data)",
... | [
"0.66766506",
"0.64393234",
"0.62105787",
"0.6195408",
"0.61873317",
"0.6116675",
"0.59998167",
"0.5990259",
"0.59872144",
"0.5973071",
"0.5863447",
"0.58589774",
"0.58480716",
"0.58461946",
"0.5788798",
"0.57644904",
"0.5748305",
"0.5695824",
"0.5693353",
"0.56928176",
"0.56... | 0.76741445 | 0 |
test is url from local instance returns false if url is not from local instance | def test_is_url_from_local_instance_returns_false_if_url_is_not_from_local_instance(
self,
):
# Arrange / Act
return_value = BlobDownloader(
"http://google.com"
).is_url_from_local_instance()
# Assert
self.assertEqual(return_value, False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_is_url_from_local_instance_returns_true_if_url_is_from_local_instance(\n self,\n ):\n # Arrange / Act\n return_value = BlobDownloader(\n f\"{settings.SERVER_URI}/987653456789\"\n ).is_url_from_local_instance()\n # Assert\n self.assertEqual(return_val... | [
"0.8326189",
"0.7563898",
"0.7391311",
"0.7306345",
"0.7198602",
"0.70632184",
"0.70412534",
"0.6971546",
"0.69464165",
"0.69348705",
"0.6917425",
"0.6911348",
"0.6845896",
"0.6830405",
"0.67078394",
"0.6673642",
"0.6622697",
"0.6606159",
"0.65751404",
"0.65704507",
"0.656026... | 0.8048743 | 1 |
test is url from local instance returns true if url is from local instance | def test_is_url_from_local_instance_returns_true_if_url_is_from_local_instance(
self,
):
# Arrange / Act
return_value = BlobDownloader(
f"{settings.SERVER_URI}/987653456789"
).is_url_from_local_instance()
# Assert
self.assertEqual(return_value, True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_is_url_from_local_instance_returns_false_if_url_is_not_from_local_instance(\n self,\n ):\n # Arrange / Act\n return_value = BlobDownloader(\n \"http://google.com\"\n ).is_url_from_local_instance()\n # Assert\n self.assertEqual(return_value, False)",
... | [
"0.8006396",
"0.76584333",
"0.7328554",
"0.72059613",
"0.71551526",
"0.69793546",
"0.69580793",
"0.69361204",
"0.68586457",
"0.68421954",
"0.6803643",
"0.6797329",
"0.6763512",
"0.6673644",
"0.66666275",
"0.6630955",
"0.658322",
"0.6570475",
"0.65235066",
"0.65200907",
"0.650... | 0.8382086 | 0 |
test get url base returns url base | def test_get_url_base_returns_url_base(self):
# Arrange / Act
return_value = BlobDownloader(
f"{settings.SERVER_URI}/987653456789"
).get_url_base()
# Assert
self.assertEqual(return_value, SERVER_URI) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_base_url():\n eq_(get_base_url(\"http://foo.com/bar/baz\"), \"http://foo.com\")\n eq_(get_base_url(\"https://foo.com:443/foo/bar\"), \"https://foo.com:443\")",
"def test_base_url(self):\n r = self.base_check_request(\"get\", \"/\")\n\n base_urls = {\n 'apartments': sel... | [
"0.8288913",
"0.7973403",
"0.73123354",
"0.7095292",
"0.70330036",
"0.7027149",
"0.70020926",
"0.6822621",
"0.67986476",
"0.67960024",
"0.67893785",
"0.6759985",
"0.6748989",
"0.6730808",
"0.672302",
"0.67135113",
"0.66677517",
"0.662433",
"0.6597434",
"0.6587899",
"0.6583607... | 0.8093016 | 1 |
test get url base raise exception if url cannot be parsed | def test_get_url_base_raise_exception_if_url_cannot_be_parsed(self):
# Assert
with self.assertRaises(BlobDownloaderUrlParseError):
# Arrange / Act
BlobDownloader("random_string").get_url_base() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_base_url(self):\n\n # Each of these URLs should be invalid\n for url in [\n \"test.com/123\",\n \"http://:80/123\",\n \"//xyz.co.uk\",\n ]:\n with self.assertRaises(Exception):\n a = api.InvenTreeAPI(url, connect=False)\n\n ... | [
"0.72232926",
"0.71809757",
"0.7084807",
"0.6980054",
"0.6879571",
"0.6876905",
"0.6858107",
"0.68257797",
"0.6821073",
"0.6818993",
"0.67914814",
"0.67595667",
"0.6745185",
"0.6726518",
"0.6704314",
"0.66425157",
"0.6617049",
"0.65837646",
"0.65771997",
"0.6562182",
"0.64907... | 0.81099594 | 0 |
test get blob response raise exception if url is unidentified | def test_get_blob_response_raise_exception_if_url_is_unidentified(self):
# Assert
with self.assertRaises(BlobDownloaderUrlParseError):
# Arrange / Act
BlobDownloader("random_string").get_blob_response() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_blob_response_return_blob_from_local_if_url_is_local(\n self, mock_send_get_request\n ):\n # Arrange / Act\n mock_send_get_request.return_value = \"local\"\n return_value = BlobDownloader(\n f\"{settings.SERVER_URI}/987653456789\"\n ).get_blob_response(... | [
"0.6937022",
"0.6710404",
"0.66658187",
"0.6626974",
"0.65516716",
"0.6506383",
"0.64904374",
"0.6396566",
"0.6393654",
"0.6389945",
"0.6378755",
"0.63720566",
"0.6337001",
"0.63044894",
"0.6301144",
"0.62981606",
"0.6297102",
"0.6296079",
"0.62017787",
"0.61530447",
"0.61230... | 0.79559755 | 0 |
test get blob response return blob from local if url is local | def test_get_blob_response_return_blob_from_local_if_url_is_local(
self, mock_send_get_request
):
# Arrange / Act
mock_send_get_request.return_value = "local"
return_value = BlobDownloader(
f"{settings.SERVER_URI}/987653456789"
).get_blob_response()
# Asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def web_get_file(self, url):\n try:\n print(url)\n response = requests.get(url, verify=False)\n file_buffer = BytesIO(response.content)\n file_buffer.seek(0)\n return file_buffer\n except:\n print(traceback.print_exc())\n re... | [
"0.67848",
"0.67195266",
"0.6595828",
"0.645836",
"0.6157754",
"0.61474097",
"0.61350363",
"0.61051184",
"0.61017853",
"0.60973495",
"0.6055147",
"0.6039269",
"0.60149926",
"0.5991898",
"0.5988457",
"0.5936077",
"0.59275734",
"0.5913829",
"0.5908348",
"0.5903778",
"0.58813745... | 0.814828 | 0 |
test get blob response return blob from remote if url is identified as remote federated | def test_get_blob_response_return_blob_from_remote_if_url_is_identified_as_remote_federated(
self, mock_send_get_request
):
# Arrange / Act
mock_send_get_request.return_value = "remote"
with patch.object(
settings, "INSTALLED_APPS", ["core_federated_search_app"]
)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_blob_response_return_blob_from_local_if_url_is_local(\n self, mock_send_get_request\n ):\n # Arrange / Act\n mock_send_get_request.return_value = \"local\"\n return_value = BlobDownloader(\n f\"{settings.SERVER_URI}/987653456789\"\n ).get_blob_response(... | [
"0.72958964",
"0.62410825",
"0.6139537",
"0.59126943",
"0.5825398",
"0.58215654",
"0.58107543",
"0.5787567",
"0.5731848",
"0.5727866",
"0.56994575",
"0.5673289",
"0.5632613",
"0.5621256",
"0.55838436",
"0.5507877",
"0.5431264",
"0.53780866",
"0.5363014",
"0.5361692",
"0.53486... | 0.73940045 | 0 |
Makes ten users and tests that the index view gets 10 users | def test_more_profiles(self):
for x in range(0, 10):
User.objects.create_user(
username="".join(("koalabear", str(x))),
email="".join(("koalabear@example.com", str(x))),
password="".join(("secret", str(x)))
)
c = Client()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_users_ten_filter_id(app, add_ten_users):\n with app.app_context():\n add_ten_users()\n filters = [dict(column='id', type='geq', value=5)]\n users = get_entities(User, 2, 3, filters,\n dict(column='id', dir='desc'))\n assert len(users.items) ==... | [
"0.6496502",
"0.636242",
"0.6303693",
"0.6302952",
"0.6216447",
"0.62095904",
"0.6200508",
"0.6179496",
"0.6123137",
"0.6085692",
"0.60838324",
"0.6055862",
"0.60469353",
"0.60071236",
"0.6001675",
"0.6000833",
"0.5955942",
"0.5950305",
"0.5935058",
"0.5926907",
"0.59260064",... | 0.7008765 | 0 |
Process the request before routing it. | def process_request(self, req, resp):
pass
"""TODO: to be defined1.
:Process the request before routing it.
Args:: TODO
"""
# self._Process the request before routing it.
# Args: = Process the request before routing it.
# Args: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_request(self, request):\n raise NotImplementedError('process_request not implemented in BaseService')",
"def process_request(self, req):\n req.context = self.make_context(req)",
"def process_request(self, req):\n return None",
"def process_request(self, request):\n ret... | [
"0.7500698",
"0.7473704",
"0.7465404",
"0.73907685",
"0.7353511",
"0.7344368",
"0.72647524",
"0.70198137",
"0.70074207",
"0.7004615",
"0.68845177",
"0.68835014",
"0.6878531",
"0.6768162",
"0.6703887",
"0.6692186",
"0.668999",
"0.6637183",
"0.6628284",
"0.6599545",
"0.6593324"... | 0.8367448 | 0 |
Copy the schemapi utility and its test file into altair/utils/ | def copy_schemapi_util():
# copy the schemapi utility file
source_path = abspath(join(dirname(__file__), 'schemapi', 'schemapi.py'))
destination_path = abspath(join(dirname(__file__), '..', 'altair',
'utils', 'schemapi.py'))
print("Copying\n {0}\n -> {1}".format(sou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_testutils():\n build()\n sh(\"%s psutil\\\\tests\\\\test_testutils.py\" % PYTHON)",
"def setup(self):\n self.cwd = os.getcwd()\n self.t = tempfile.mkdtemp()\n dir_path = Path(\"packages\")\n tmp_dir = self.t / dir_path\n src_dir = self.cwd / Path(ROOT_DIR, dir_pa... | [
"0.6534019",
"0.6056576",
"0.5858216",
"0.5858216",
"0.56233567",
"0.54831636",
"0.54797065",
"0.54797065",
"0.53626454",
"0.53533256",
"0.5327549",
"0.52980834",
"0.52762675",
"0.5235947",
"0.5229167",
"0.52216065",
"0.521719",
"0.52099717",
"0.51815474",
"0.51676357",
"0.51... | 0.761749 | 0 |
Generate a schema wrapper at the given path. | def generate_vegalite_schema_wrapper(schema_file):
# TODO: generate simple tests for each wrapper
with open(schema_file) as f:
rootschema = json.load(f)
contents = [HEADER,
"from altair.utils.schemapi import SchemaBase, Undefined",
LOAD_SCHEMA.format(schemafile='vega-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_schema(self, schema: str):\n return",
"def generate_schema(class_name, schema):\n superclass = schema[\"superclass\"]\n if superclass == \"Schema\": superclass = \"Object\"\n\n has_map = False\n is_model_builder = False\n has_inherited = False\n for field in schema[\"fields\"]... | [
"0.6081418",
"0.59163386",
"0.5892883",
"0.57816476",
"0.5690508",
"0.5688011",
"0.5680319",
"0.56798965",
"0.5556615",
"0.5545649",
"0.55216885",
"0.54928905",
"0.5492306",
"0.54886657",
"0.54161835",
"0.5391675",
"0.53060555",
"0.5304895",
"0.52118486",
"0.5199787",
"0.5176... | 0.6059992 | 1 |
Sets the params of a hmm for sim experiment 1 | def set_params_hmm_exp1(hmm) :
hmm.length = 12
hmm.dims = [(2,3)]*hmm.length # (latent,emit) dimspace
hmm.emit = [
[[0.6,0.2,0.2],[0.2,0.6,0.2]]
]*hmm.length
hmm.trans = [
[[0.7,0.3],[0.3,0.7]]
]*hmm.length
hmm.seqmap = [{'a':0,'b':1}]*hmm.length
hmm.seqmap2 = [{0:'a',1:'b'}]*hmm.length
hmm.featmap = [{'H'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_hparams(experiment):\n hparams = {}\n\n # General parameters.\n hparams['batch_size'] = 64\n hparams['eval_batch_size'] = 64\n hparams['learning_rate_warmup_steps'] = 2000\n hparams['learning_rate_constant'] = 1\n hparams['learning_rate'] = 0.001\n hparams['train_epoches'] = 200\n hparams['step... | [
"0.6423308",
"0.64182746",
"0.62911874",
"0.62509716",
"0.620881",
"0.61902076",
"0.6180237",
"0.61744344",
"0.614165",
"0.6122826",
"0.6083221",
"0.60797495",
"0.6070772",
"0.60647374",
"0.604287",
"0.60281956",
"0.6023605",
"0.6014657",
"0.5991374",
"0.5972809",
"0.59608895... | 0.75140095 | 0 |
Generate a column with given values | def generate_column(values, previous_table):
# result = []
for i in range(0, len(previous_table)):
# current_item = previous_table[i] + values[i]
# result.append(current_item)
values[i][0:0] = previous_table[i]
# return result
print "Column(s) attached to result"
return va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_column(values, df=pandas.DataFrame()):\n df['col_{}'.format(len(df.columns))] = values\n return df",
"def column(v):\n\n return eval(v, config_functions)",
"def add_column(values, df=None):\n if df is None:\n df=pandas.DataFrame()\n df['col_{}'.format(len(df.columns))] = values\n ... | [
"0.68062496",
"0.65673304",
"0.6560795",
"0.6542762",
"0.647227",
"0.6431108",
"0.61469585",
"0.61083233",
"0.60831773",
"0.60509396",
"0.60097736",
"0.59917843",
"0.5794303",
"0.57419103",
"0.5715137",
"0.5713725",
"0.5702195",
"0.56762266",
"0.56541175",
"0.56046337",
"0.56... | 0.6656984 | 1 |
returns word with 10% possiblity of returning null | def get_random_word_10per_null():
word_dic = wordlist
word_dic_length = len(word_dic) - 1
random_word_location = get_random_num_given_per_null(word_dic_length, 0.1)
if random_word_location:
return word_dic[random_word_location]
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_single_word_with_junk(self):\n score = location.match_weight('clevedon UK', ['clevedon'])\n\n self.assertEqual(score, 1000)",
"def non_std_words(work):\n dictionary = enchant.Dict(\"en_US\")\n non_std_word = []\n\n for elem in work:\n lyrics = [item for sublist in elem[1] f... | [
"0.66960514",
"0.6181667",
"0.6141516",
"0.60442233",
"0.60102886",
"0.60022",
"0.59698385",
"0.5920282",
"0.5916053",
"0.59126693",
"0.588819",
"0.5860365",
"0.5860261",
"0.58487487",
"0.5842525",
"0.58342135",
"0.5831628",
"0.58316064",
"0.58164245",
"0.5804187",
"0.5787933... | 0.69392467 | 0 |
append given data for the fows and columns given | def append_data(start_col, end_col, rows, func_for_content):
result = [generate_header(start_col, end_col, "")]
while len(result) < rows + 1:
item = []
while len(item) < end_col - start_col + 1:
to_append = func_for_content()
item.append(to_append)
result.append... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_data(self, rowdata):\n if not rowdata.keys():\n # No columns were specified\n return\n for colnam in rowdata.keys():\n # Check the the column is actually defined in\n # in the table\n try:\n self.list_columns().index(colnam... | [
"0.6389315",
"0.6106118",
"0.60005295",
"0.599688",
"0.59859526",
"0.59375894",
"0.59375894",
"0.59375894",
"0.59375894",
"0.59375894",
"0.59375894",
"0.59375894",
"0.59375894",
"0.59375894",
"0.5937176",
"0.5881445",
"0.58082163",
"0.57780695",
"0.5747824",
"0.5670428",
"0.5... | 0.6139843 | 1 |
generate csv table with given array | def generate_csv_table(table_values):
with open('ayasdi_assignment.csv', 'wb') as csvfile:
filewriter = csv.writer(csvfile, delimiter=',')
filewriter.writerows(table_values) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_csv(table, header):\n with open(\"%s.csv\" % header, \"w\") as csvfile:\n for i in range(len(table)):\n for j in range(len(table[i])):\n if j != len(table[i])-1:\n tmp = table[i][j] + \",\"\n else:\n tmp = table[i... | [
"0.7346989",
"0.6924507",
"0.6680908",
"0.6641846",
"0.6564316",
"0.6537733",
"0.61447304",
"0.6143278",
"0.61339015",
"0.60982794",
"0.6076228",
"0.60623395",
"0.6058749",
"0.6049604",
"0.6035948",
"0.6032145",
"0.599436",
"0.59845364",
"0.597547",
"0.5969221",
"0.5951832",
... | 0.7020019 | 1 |
add all lines to the SQLite database. | def add_all_lines(conn, table_values):
column_list = table_values[0]
column_row = ",".join(column_list)
qmark = "?"
col_count = len(column_list)
for cols in range(1, col_count):
qmark += ", ?"
cols = cols
cur = conn.cursor()
cur.execute("DROP TABLE IF EXISTS ayasdi_table;")... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_db(self, loglines):\n self.database = self.database.append(loglines, ignore_index=True)",
"def save_db():\n # establish connection to db\n conn = sqlite3.connect('journal_entries.db')\n\n # create cursor to execute commands\n c = conn.cursor()\n\n # create table if specified tabl... | [
"0.7315239",
"0.6402058",
"0.6328022",
"0.62780845",
"0.62010753",
"0.6066139",
"0.59396553",
"0.58879584",
"0.5877146",
"0.58757937",
"0.5848079",
"0.58376193",
"0.5829202",
"0.5797994",
"0.5796137",
"0.5771828",
"0.5763948",
"0.573806",
"0.57142043",
"0.5711746",
"0.5697731... | 0.66328627 | 1 |
The list of metadata keys and values for the image are returned | def test_list_image_metadata(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _getAllMeta(self):\n try:\n metadata = pyexiv2.ImageMetadata(self.imagePath)\n metadata.read()\n return metadata\n except:\n print 'error reading meta data'\n return None",
"def GetMetadata(IMAGE):\n SPACING = IMAGE.GetSpacing()\n O... | [
"0.78094023",
"0.7380972",
"0.705795",
"0.70533746",
"0.70188904",
"0.69729894",
"0.69729894",
"0.6896384",
"0.6806562",
"0.6796114",
"0.6784264",
"0.6694479",
"0.6682299",
"0.66375786",
"0.6636082",
"0.6634411",
"0.66013986",
"0.65849024",
"0.65849024",
"0.65676636",
"0.6553... | 0.78286606 | 0 |
Create metadata file for list of CHF patients with study ID and subject ID hf_patients_file CSV file with list of dicoms associated with heart failure patients expects column names 'dicom_id', 'study_id', and 'subject_id' metadata_file CSV file with dicom IDs as rows and a number of metadata fields as columns expects c... | def get_metadata(hf_patients_file, metadata_file, output_file):
# Use 'dicom_id' as names for row indices
hf_patients = pd.read_csv(hf_patients_file, sep=',', index_col="dicom_id")
# Use 'dicom' as name
metadata = pd.read_csv(metadata_file, index_col="dicom", dtype={"StudyDate": str, "StudyTime": str}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_csv_file(data_root, output_file, fields):\n filenames = []\n patient_names = os.listdir(data_root + '/' + fields[0])\n print(len(patient_names))\n for patient_name in patient_names:\n patient_image_names = []\n for field in fields:\n image_name = data_root + '/' + fi... | [
"0.60668874",
"0.5944595",
"0.59333044",
"0.58555573",
"0.5807391",
"0.57814443",
"0.5758959",
"0.56571156",
"0.5639829",
"0.5587535",
"0.55863255",
"0.5567972",
"0.5562293",
"0.55381227",
"0.55377805",
"0.55328715",
"0.55207646",
"0.55164474",
"0.5515072",
"0.54153335",
"0.5... | 0.8242767 | 0 |
Test the help file | def test_help(self):
help_file = os.path.join(cwd, indir, "rdfc_help")
help_text = StringIO()
with redirect_stdout(help_text):
with self.assertRaises(HelpPrinted):
main(["--help"])
if os.path.exists(help_file):
with open(help_file) as f:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_help(self):\n help_file = os.path.join(cwd, indir, \"r5json_help\")\n help_text = StringIO()\n with redirect_stdout(help_text):\n with self.assertRaises(HelpPrinted):\n main([\"--help\"])\n if os.path.exists(help_file):\n with open(help_file... | [
"0.8042502",
"0.8038368",
"0.8033258",
"0.78555655",
"0.78202975",
"0.78139514",
"0.7774096",
"0.7725733",
"0.7725733",
"0.7713123",
"0.770867",
"0.7704543",
"0.763082",
"0.7591885",
"0.75887424",
"0.75694066",
"0.7549705",
"0.75341034",
"0.75311893",
"0.75053424",
"0.7505342... | 0.8088576 | 0 |
returns css styles from pygments for syntax highlighting | def get_syntax_css(cls):
from pygments.formatters import HtmlFormatter
return HtmlFormatter().get_style_defs('.highlight') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highlight_code(code, lexer=None):\n# See this page for help with colouring: http://pygments.org/docs/tokens/\n#\n#from pygments.styles.default import DefaultStyle\n#from pygments.style import Style\n#from pygments.styles import get_style_by_name\n#from pygments.token import Comment, Keyword, Name, String, Oper... | [
"0.73377943",
"0.71244407",
"0.69365674",
"0.6894865",
"0.67768574",
"0.66296226",
"0.65562516",
"0.64005",
"0.6387637",
"0.6268078",
"0.6254456",
"0.6223599",
"0.61921525",
"0.6189117",
"0.61254483",
"0.6116371",
"0.6115638",
"0.60905224",
"0.60905075",
"0.60767215",
"0.6065... | 0.84907407 | 0 |
Generating a random tensor, passing through the model and saving the picture | async def get_image(self):
# generating
fixed_latent = torch.randn(1, 512, 1, 1, device=self.device)
with torch.no_grad():
# passing through
fake_images = self.model(fixed_latent)
# saving
save_image(fake_images, f'models/FaceGAN_dir/faces/fake.j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_model(model):\n model(tf.random.uniform((1, 512, 512, 3)))",
"def generate_and_save_images(model, seed, output_path, title):\n\n predictions = model(tf.Variable(seed, trainable=False))\n\n fig = plt.figure(figsize=(4,4))\n\n for i in range(predictions.shape[0]):\n plt.subplot(4, 4, i+1)... | [
"0.63793933",
"0.63191825",
"0.62726223",
"0.6266079",
"0.62476015",
"0.6233061",
"0.620632",
"0.6203282",
"0.611562",
"0.6092084",
"0.6081869",
"0.6068366",
"0.60439837",
"0.6043676",
"0.60012376",
"0.5979085",
"0.5966345",
"0.59204125",
"0.5920266",
"0.59171826",
"0.5905021... | 0.66911685 | 0 |
split the data by filenames into train, val and test sets | def data_split(folder=CONFIG.data_folder, val_proportion=CONFIG.val_proportion):
files = os.listdir(folder)
train_files, val_files, test_files = list(), list(), list()
period = int(np.round(1 / val_proportion))
corruption = list()
max_H, max_W = 0, 0
for (i, file) in enumerate(files)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_train_val_test_split(root: str, val_file: str, test_file: str):\n \n ####################\n # Labels\n ####################\n\n label_list = [label for label in sorted(os.listdir(root)) if os.path.isdir(os.path.join(root, label)) and label[0] != \"_\"]\n label_map = {idx: label for idx, l... | [
"0.74674946",
"0.7285035",
"0.72539085",
"0.71486753",
"0.7148425",
"0.7123635",
"0.7109452",
"0.7011198",
"0.6927029",
"0.6920675",
"0.6920064",
"0.6917964",
"0.69065714",
"0.68984383",
"0.6868742",
"0.6809516",
"0.6805288",
"0.6761615",
"0.67467535",
"0.67467415",
"0.673097... | 0.7556877 | 0 |
augmentation on a single image. !! currently type = [0..5] | def augmentation_simple(filename, aug_type, max_H, max_W, folder=CONFIG.data_folder):
image = rgb2grey(mpimg.imread(os.path.join(folder, filename)))
image_augmented = np.ones(shape=(max_H, max_W))
(h, w) = np.shape(image)
stride_0, stride_1 = max_H - h, (max_W - w) // 2
offset = ((aug_type % ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def augment(self, image):\n pass",
"def _augment(img):\r\n return flip(img, axis=2)",
"def _augment(img):\n return flip(img, axis=2)",
"def augmentation_nine(filename, aug_type, max_H, max_W, folder=CONFIG.data_folder):\r\n\r\n # image = rgb2grey(mpimg.imread(os.path.join(folder, file... | [
"0.7852038",
"0.7255157",
"0.7244718",
"0.72229093",
"0.7202417",
"0.70517504",
"0.6965538",
"0.69253707",
"0.6887688",
"0.6848763",
"0.66882473",
"0.66793793",
"0.6634361",
"0.662635",
"0.6607445",
"0.6600997",
"0.65715784",
"0.65489054",
"0.65093356",
"0.6487716",
"0.646406... | 0.7304175 | 1 |
Transform a Swagger parameter definition to a valid JSONSchema Remove known Swagger fields as well as any custom definitions (starting with "x"). | def clean_schema(schema):
# type: (Dict) -> Dict
return {k: v for k, v in schema.items()
if k not in _SWAGGER_FIELDS and not k.lower().startswith("x-")} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schema(self, schema, in_='formData'):\n parameters = core.parameters_from_object_schema(schema, in_=in_)\n return compose(*map(self.parameter, parameters))",
"def swagger_validate(f):\n @wraps(f)\n def swagger_validated_function(*args, **kwargs):\n converted_uri = request.path\n ... | [
"0.5634488",
"0.54268676",
"0.5291475",
"0.5284733",
"0.52830863",
"0.5275915",
"0.52673525",
"0.52542907",
"0.52526486",
"0.52353656",
"0.5219161",
"0.5153639",
"0.51495343",
"0.5132784",
"0.5130623",
"0.51149714",
"0.51133686",
"0.51019096",
"0.5072219",
"0.5069785",
"0.505... | 0.6300005 | 0 |
We map paths (typically only the relative part) to a canonical class name. In the event that the path is "/", ROOT_CLASS_NAME will be returned. | def path_to_class_name(path):
# type: (unicode) -> unicode
character_map = {
ord("{"): None,
ord("}"): None,
ord("_"): u"/"
}
sanitised = path.translate(character_map)
class_name = u"".join(
# Uppercase the first letter of each non-empty word, while
# preservi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_full_path_to_class(cls: Type) -> str:\n mod = cls.__module__\n name = cls.__name__\n\n return f\"{mod}.{name}\"",
"def getClassName(self, uris):\n\t\t#Iterate over the class mapping. As the uris are stored in the value they have to be checked against the given uris parameter\n\t\t#Class mapping ... | [
"0.6339648",
"0.6236675",
"0.61127424",
"0.61037046",
"0.6011135",
"0.5856981",
"0.5853071",
"0.58370733",
"0.57991314",
"0.57933414",
"0.57880706",
"0.5731319",
"0.57217526",
"0.56777734",
"0.5672132",
"0.56446004",
"0.5644488",
"0.5620071",
"0.5614535",
"0.56039876",
"0.559... | 0.7644174 | 0 |
We map paths (typically only the relative part) to a canonical operation name. The operation name is used as the name of the function that must provide the serverside logic. Typically the operation name is provided in the Swagger space via the `operationId` field. This function is used as a fallback mechanism when it i... | def path_to_operation(path, verb):
# type: (unicode, unicode) -> unicode
character_map = {
ord("{"): None,
ord("}"): None,
ord("_"): u"/"
}
if path == u"/":
operation = ROOT_OPERATION
else:
sanitised = path.translate(character_map)
operation = u"_".joi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_operation_name_func(request):\n if getattr(request, 'matched_route', None) is None:\n return request.method\n\n return request.matched_route.name",
"def _normalize_operation(operation):\n try:\n operation = operation.upper()\n except AttributeError:\n pass\n\n try:... | [
"0.6826489",
"0.63041455",
"0.6230122",
"0.60720176",
"0.6010415",
"0.5984602",
"0.5814402",
"0.57815593",
"0.5647395",
"0.5600232",
"0.55825686",
"0.55529",
"0.553222",
"0.55182445",
"0.5505394",
"0.54893184",
"0.54767674",
"0.54703027",
"0.5450176",
"0.5418301",
"0.5407876"... | 0.6336917 | 1 |
JSONSchema definitions may contain references. This function replaces all references with their full definitions. Inplace mods are made. | def resolve_schema_references(self, definition):
# type: (Generator, Dict) -> None
if "$ref" in definition:
schema_reference = definition.pop("$ref")
section, name = schema_reference.split("/")[-2:]
referenced_definition = self.parser.specification[section][name]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_ref(schema: T, schema_prefix: str) -> T:\n if isinstance(schema, List):\n return [replace_ref(item, schema_prefix) for item in schema]\n\n if isinstance(schema, Dict):\n if \"$ref\" in schema:\n schema[\"$ref\"] = schema_prefix + schema[\"$ref\"].split(\"/\")[-1]\n ... | [
"0.6295187",
"0.6187042",
"0.6131107",
"0.61137927",
"0.5949536",
"0.5908075",
"0.58352274",
"0.58206695",
"0.5819343",
"0.5551711",
"0.5521385",
"0.5502297",
"0.55003107",
"0.5472781",
"0.54675686",
"0.5458783",
"0.54558086",
"0.5446794",
"0.54416686",
"0.54301834",
"0.54000... | 0.75482386 | 0 |
Generate a `urls.py` file from the given specification. | def generate_urls(self):
# type: (Generator) -> str
relative_urls = [path.replace(self.parser.base_path + "/", "")
for path in self.parser.paths]
entries = {
fixup_parameters(relative_url, self.backend): path_to_class_name(relative_url)
for relati... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uri_template(app, **kwargs):\n assert len(kwargs) == 1\n\n endpoint = kwargs.keys()[0]\n parameters = kwargs.values()[0]\n\n for url in app.url_map.iter_rules():\n if url.endpoint == endpoint:\n break\n else:\n return ''\n\n ut = url.rule\n\n for param, replacement... | [
"0.62118447",
"0.5955845",
"0.5846046",
"0.58062273",
"0.57732004",
"0.56964135",
"0.5661389",
"0.56549877",
"0.5635723",
"0.5591032",
"0.5576201",
"0.5549466",
"0.54992837",
"0.54779065",
"0.54511166",
"0.543676",
"0.54254884",
"0.5413376",
"0.5404953",
"0.53950757",
"0.5388... | 0.6598577 | 0 |
Generate a `schemas.py` file from the given specification. | def generate_schemas(self):
# type: (Generator) -> str
schemas = {}
for name, definition in self.parser.specification.get("definitions",
{}).items():
schema = copy.deepcopy(definition)
self.resolve_schema_refer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createSchema(schema):\n return \"CREATE SCHEMA \\\"{name}\\\";\\n\".format(name = schema.name)",
"def write_schema_files():\n print(\"\\nStarting to generate Provider JSON Schemas...\\n\")\n\n for name, generator in schema_generators().items():\n schema = generator()\n with open(f\"../... | [
"0.6278286",
"0.6120532",
"0.5914922",
"0.590964",
"0.58451927",
"0.5811448",
"0.5810112",
"0.5793022",
"0.57539463",
"0.57230437",
"0.56757647",
"0.5655373",
"0.5630526",
"0.5547899",
"0.5527448",
"0.5439858",
"0.54181385",
"0.5379845",
"0.5372401",
"0.5365813",
"0.53636587"... | 0.6828343 | 0 |
Generate a `views.py` file from the given specification. | def generate_views(self):
# type: (Generator) -> str
return render_to_string(
self.backend, "views.py", {
"classes": self._classes,
'host': self.parser.specification.get('host'),
'basePath': self.parser.specification.get('basePath'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_view(name, fields=''):\n if '/' in name:\n blueprint_name, model_name = name.split('/')\n output_file = 'blueprints/%s/views.py' % blueprint_name\n else:\n model_name = name\n output_file = 'views.py'\n file_exists = os.path.exists(output_file)\n form_data = []\n ... | [
"0.6551651",
"0.595738",
"0.58046216",
"0.5711838",
"0.5601871",
"0.54447436",
"0.54244304",
"0.5400428",
"0.53443485",
"0.5311343",
"0.5310942",
"0.5279183",
"0.52688825",
"0.5245032",
"0.51810306",
"0.5162419",
"0.51130146",
"0.5102034",
"0.51017463",
"0.50766385",
"0.50703... | 0.74028915 | 0 |
Generate a `stubs.py` file from the given specification. | def generate_stubs(self):
# type: (Generator) -> str
return render_to_string(
self.backend, "stubs.py", {
"classes": self._classes,
"module": self.module_name
}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GenPy(mod,fname):\n f = open(fname, 'w')\n title = \"\"\"#\n# This file is generated automatically\n# Author:IAN\n# http://www.iknot.org\n\"\"\"\n f.write(title)\n for i in mod.__dict__.keys():\n s = \"def \" + i + \"():\" + \"\\n\"\n f.write(s)\n s = \" return\"\n f.... | [
"0.61551994",
"0.6086302",
"0.58718497",
"0.57005364",
"0.5645396",
"0.5604032",
"0.5584951",
"0.55506635",
"0.55281496",
"0.55198425",
"0.5432277",
"0.5398684",
"0.5394113",
"0.5358465",
"0.535375",
"0.534014",
"0.53318554",
"0.5228245",
"0.52165556",
"0.51921624",
"0.517973... | 0.671416 | 0 |
Generate a `utils.py` file from the given specification. | def generate_utils(self):
# type: (Generator) -> str
return render_to_string(
self.backend,
"utils.py",
{
"security_defs": self.security_defs
},
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_cpp():\n cpp_file = AUTOGEN_WARNING\n cpp_file += \"// Implements basic nuclear data functions.\\n\"\n cpp_file += \"#ifndef PYNE_IS_AMALGAMATED\\n\"\n cpp_file += '#include \"atomic_data.h\"\\n'\n cpp_file += '#include \"nucname.h\"\\n'\n cpp_file += \"#endif\\n\"\n cpp_file += \... | [
"0.5886601",
"0.58114994",
"0.5791762",
"0.566734",
"0.55754083",
"0.5565954",
"0.5440808",
"0.5430989",
"0.5419702",
"0.5411999",
"0.53402895",
"0.53386",
"0.53274995",
"0.5317688",
"0.52698743",
"0.5227267",
"0.52257186",
"0.5211393",
"0.5204965",
"0.5199996",
"0.51931614",... | 0.6554294 | 0 |
Given a state, return a sequence of (action, state) pairs reachable from this state. If there are many successors, consider an iterator that yields the successors one at a time, rather than building them all at once. Iterators will work fine within the framework. | def successor(self, state):
successors = []
for move in self.getMoves(state):
a = self.tryMove(move, state)
successors.append([move, a])
return successors | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def successor(self, state):\n for action in self.actions:\n nexts = state.move(action)\n if nexts is not None:\n yield (action,nexts)",
"def successorStates(self, state):\r\n\r\n successors = []\r\n\r\n for action in Directions.CARDINAL:\r\n x,... | [
"0.80621916",
"0.72835743",
"0.722379",
"0.71282077",
"0.70814997",
"0.70672643",
"0.7063342",
"0.6862942",
"0.67577654",
"0.6720068",
"0.6697063",
"0.661315",
"0.6576345",
"0.65481335",
"0.6505044",
"0.6487742",
"0.64783996",
"0.6444707",
"0.6427616",
"0.6382935",
"0.6356721... | 0.74979883 | 1 |
Cancels in progress deletion of VMWare Private Cloud. | def cancel_private_cloud_deletion(
project_id: str, zone: str, cloud_name: str
) -> operation.Operation:
return cancel_private_cloud_deletion_by_full_name(
f"projects/{project_id}/locations/{zone}/privateClouds/{cloud_name}"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel(self):\n # terminate background thread\n self.stop.set()\n CoordinationAdaptor.delete_cds(self.url)",
"def terminate_instances(self, props):\n return self._vm_async_apply(props, 'delete')",
"def vm_delete(vm_hostname, retire=False):\n\n with _get_vm(vm_hostname, unlock... | [
"0.6210842",
"0.61159253",
"0.6113491",
"0.61061263",
"0.6087419",
"0.60825014",
"0.60483444",
"0.60249645",
"0.5915582",
"0.5877888",
"0.58686525",
"0.5862239",
"0.58388627",
"0.58360887",
"0.5822662",
"0.5808141",
"0.5798858",
"0.5798622",
"0.57963693",
"0.5765568",
"0.5722... | 0.6275939 | 0 |
Execute command on vm and return dict with results | def run_on_vm(env, os_conn, vm, vm_keypair=None, command='uname',
vm_login="cirros", timeout=3 * 60, vm_password='cubswin:)',
vm_ip=None):
results = []
def execute(expected_exceptions=None):
if not os_conn.server_status_is(vm, 'ACTIVE'):
return False
expe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _run_json(key, process, cmd):\n logging.info('Running %s', ' '.join(cmd))\n raw = subprocess.check_output(cmd)\n logging.info('- returned %d bytes', len(raw))\n return key, process(json.loads(raw))",
"def run_dict(cmd, cwd=None):\n if \"convertto-json\" not in cmd.lower():\n cmd = f\"{cmd} | Co... | [
"0.646654",
"0.62317586",
"0.619809",
"0.61723423",
"0.6164972",
"0.61125106",
"0.6071638",
"0.60580677",
"0.6053685",
"0.5981986",
"0.598153",
"0.59808517",
"0.5976741",
"0.5951696",
"0.5910579",
"0.5857431",
"0.5851837",
"0.5849398",
"0.5843684",
"0.58372986",
"0.58070374",... | 0.6738235 | 0 |
Check that all vms can ping each other and public ip | def check_vm_connectivity(env, os_conn, vm_keypair=None, timeout=4 * 60):
servers = os_conn.get_servers()
for server1 in servers:
ips_to_ping = [settings.PUBLIC_TEST_IP]
for server2 in servers:
if server1 == server2:
continue
ips_to_ping += os_conn.get_nov... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def online_check():\n try_first_ips = [\n \"216.58.213.238\", # google\n \"8.8.8.8\", # google\n \"8.8.4.4\", # google\n \"46.228.47.115\", # yahoo\n ]\n last_resort_ips = [ # dns root servers\n \"198.41.0.4\",\n \"192.228.79.201\",\n \"192.33.4.12\",\... | [
"0.7020805",
"0.7007775",
"0.7002641",
"0.6654022",
"0.6555028",
"0.6555028",
"0.6451388",
"0.6426847",
"0.64174914",
"0.6412209",
"0.64020956",
"0.6370579",
"0.63160264",
"0.63150287",
"0.6310998",
"0.6310998",
"0.6260132",
"0.62036276",
"0.61729664",
"0.61667365",
"0.614962... | 0.7387345 | 0 |
Function to parse affiliation strings Parameter | def parse_affiliation(affiliation):
aff_split = affiliation.split(', ')
if len(aff_split) > 1:
return(aff_split[0], ", ".join(aff_split[1:]))
else:
return(None, aff_split[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_author_affiliation(medline):\n authors = []\n article = medline.find(\"Article\")\n if article is not None:\n author_list = article.find(\"AuthorList\")\n if author_list is not None:\n authors_list = author_list.findall(\"Author\")\n for author in authors_list... | [
"0.67092717",
"0.60142004",
"0.5644304",
"0.5624837",
"0.5512916",
"0.5508131",
"0.53981274",
"0.5296138",
"0.5228943",
"0.51897866",
"0.5170896",
"0.5134638",
"0.51305115",
"0.51190424",
"0.51120347",
"0.50983244",
"0.5096334",
"0.5081843",
"0.50308645",
"0.4981987",
"0.4945... | 0.7435547 | 0 |
Function to parse existing affiliations data from file Parameter | def parse_affiliations(path='affiliations.json'):
geo_dict, affils = atj.get_affiliation_json(path)
return geo_dict, affils | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_author_affiliation(medline):\n authors = []\n article = medline.find(\"Article\")\n if article is not None:\n author_list = article.find(\"AuthorList\")\n if author_list is not None:\n authors_list = author_list.findall(\"Author\")\n for author in authors_list... | [
"0.64196956",
"0.5912233",
"0.5832929",
"0.56556225",
"0.5532335",
"0.55259013",
"0.54877734",
"0.54613775",
"0.54355925",
"0.5421329",
"0.5405842",
"0.539367",
"0.53914005",
"0.5389385",
"0.53783065",
"0.5376795",
"0.5353379",
"0.5342108",
"0.53350073",
"0.5312624",
"0.52966... | 0.6655886 | 0 |
The constructor for the RosIotBridgeActionServer class. This function will initialize this node as an action server. We will also load various paramter values from the ROS parameter server, and start a seprate thread to read the data coming from MQTT client | def __init__(self):
# Initialize the action server
self._as = actionlib.ActionServer('/action_ros_iot',
msgRosIotAction,
self.on_goal,
auto_start = False)
# * self.on_goal - Pointer of the function to be called
# when a goal is received
# * self.on_cancel - Pointer of the f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n\t# Initialize the node\n\trospy.init_node(\"node_action_server_ros_iot_bridge\")\n\n\t# Create a object for RosIotBridgeActionServer class\n\taction_server = RosIotBridgeActionServer()\n\n\t# Not letting this node die\n\trospy.spin()",
"def __init__(self):\n self.action_server = actionlib.... | [
"0.73460126",
"0.67316574",
"0.6127553",
"0.6112876",
"0.6079766",
"0.60330147",
"0.60315645",
"0.60058445",
"0.5988712",
"0.5986981",
"0.5985204",
"0.59545624",
"0.59378284",
"0.5912471",
"0.59075725",
"0.59029007",
"0.5896427",
"0.5879108",
"0.587333",
"0.5844836",
"0.58369... | 0.71007687 | 1 |
The callback function for when a message is received from MQTT This function publishes the message from MQTT to a ROS topic, and uploads it to google sheet. | def mqtt_sub_callback(self, client, userdata, message):
#def mqtt_sub_callback(self, message):
# Decode the message using UTF-8 and convert it
# to 'string' datatype
payload = str(message.payload.decode("utf-8"))
rospy.loginfo("[BRIDGE] Message Received from MQTT")
# Give the appropiate values to the cont... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mqtt_on_message(client, userdata, msg):\n logging.debug('mqtt message received for topic %s', msg.topic)\n image_queue.put(msg.payload)",
"def on_mqtt_message(client, userdata, message):\n global recorders, mqtt_topic_pub\n try:\n if len(message.payload)>0:\n payload = json.loads(st... | [
"0.70635974",
"0.6865122",
"0.67584234",
"0.67152506",
"0.6694387",
"0.668327",
"0.6622484",
"0.6594329",
"0.65824336",
"0.6562991",
"0.6471413",
"0.6446854",
"0.64454794",
"0.64226544",
"0.6401174",
"0.63772756",
"0.6370019",
"0.6364606",
"0.6344656",
"0.630961",
"0.629004",... | 0.7709318 | 0 |
Returns the top authors of all time | def topAuthors():
c = db.cursor()
c.execute("select name, sum(hits) as hits\
from authorhits group by name\
order by hits desc;")
results = c.fetchall()
c.close()
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_authors():\n\n cur.execute(\"\"\"\n SELECT author, count(*) AS article_author\n FROM article_summary\n GROUP BY author\n ORDER BY article_author DESC;\n \"\"\")\n result = cur.fetchall()\n return result",
"def printTopAuthors():\n query = \"\"\"\n SELECT ... | [
"0.8221705",
"0.81402403",
"0.81337076",
"0.80476844",
"0.78352237",
"0.77738464",
"0.7622924",
"0.7612146",
"0.74960506",
"0.7411446",
"0.73828864",
"0.73441505",
"0.73402417",
"0.7219034",
"0.7176552",
"0.71194685",
"0.7110655",
"0.7087625",
"0.70455694",
"0.68131906",
"0.6... | 0.8315578 | 0 |
Convert the given filter's type to SupportedFilterType. This method is necessary because click can only accept a single type for its tuple (which is string in this case). | def _convert_filters_type(
filter: List[Tuple[str, PredicateType, SupportedFilterType]],
schema: StateSchema,
) -> List[Tuple[str, SupportedFilterType]]:
new_filter = []
if dataclasses.is_dataclass(schema):
schema = {field.name: field.type for field in fields(schema)}
else:
schema = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_filter_type(filter):\n if filter == 'nat':\n return '-N'\n if filter == 'options':\n return '-O'\n if filter == 'filter':\n return '-R'",
"def select_filter(self, filter_type: str) -> None:\n _groomed_tab: str = filter_type.lower().replace(' ', '-')\n\n if fil... | [
"0.6374015",
"0.606037",
"0.6043694",
"0.5947252",
"0.5937136",
"0.58425623",
"0.58183426",
"0.56938934",
"0.5573471",
"0.5504654",
"0.547705",
"0.54721314",
"0.5467399",
"0.54188025",
"0.523528",
"0.5191037",
"0.5189393",
"0.5178763",
"0.51485044",
"0.5139776",
"0.5134359",
... | 0.6437874 | 0 |
List all placement group information from the cluster. | async def list_placement_groups(self, *, option: ListApiOptions) -> ListApiResponse:
try:
reply = await self._client.get_all_placement_group_info(
timeout=option.timeout
)
except DataSourceUnavailable:
raise DataSourceUnavailable(GCS_QUERY_FAILURE_WARN... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_groups(self):\n self.cursor.execute(\"select * from groups\")\n self.connection.commit()\n return self.cursor.fetchall()",
"def list_groups(self):\n return self.get_admin(\"groups\")",
"def list_groups(self, **params):\n url = 'groups'\n if params:\n ... | [
"0.6410386",
"0.6383272",
"0.6338985",
"0.6293622",
"0.62360305",
"0.62317884",
"0.616342",
"0.61477834",
"0.6092305",
"0.6092153",
"0.60720086",
"0.6044878",
"0.6041827",
"0.60390687",
"0.60359895",
"0.5999155",
"0.59588313",
"0.5947516",
"0.59461147",
"0.59351856",
"0.59332... | 0.7460139 | 0 |
List all runtime env information from the cluster. | async def list_runtime_envs(self, *, option: ListApiOptions) -> ListApiResponse:
agent_ids = self._client.get_all_registered_runtime_env_agent_ids()
replies = await asyncio.gather(
*[
self._client.get_runtime_envs_info(node_id, timeout=option.timeout)
for node... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def envs():\n\n # update and grab the envs from the metadata keys\n metadata = _init()\n return list(metadata.keys())",
"def all_envs():\n return all_tasks.keys()",
"def get_all_environments():\n return ENVIRONMENTS",
"def list_envs(self):\n if self.hdfs:\n files = self.hdfs.... | [
"0.70993704",
"0.6772352",
"0.670903",
"0.66694355",
"0.6546429",
"0.6438007",
"0.62355334",
"0.62250715",
"0.6204362",
"0.61995274",
"0.61844176",
"0.6090929",
"0.60385424",
"0.60130614",
"0.59921336",
"0.5969281",
"0.59633166",
"0.5946404",
"0.5928985",
"0.5925936",
"0.5914... | 0.69075584 | 1 |
List all cluster events from the cluster. | async def list_cluster_events(self, *, option: ListApiOptions) -> ListApiResponse:
result = []
all_events = await self._client.get_all_cluster_events()
for _, events in all_events.items():
for _, event in events.items():
event["time"] = str(datetime.fromtimestamp(int(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster_list():\n request_debug(r, logger)\n json_body = r.get_json(force=True, silent=True) or {}\n result = cluster_handler.list(filter_data=json_body)\n response_ok[\"data\"] = result\n return jsonify(response_ok), CODE_OK",
"async def getAll():\n return [cluster.export() for cluster in ... | [
"0.696297",
"0.6443055",
"0.6413927",
"0.6367069",
"0.63632715",
"0.63184714",
"0.63090795",
"0.6256486",
"0.62558013",
"0.61660993",
"0.6039116",
"0.6017532",
"0.60073125",
"0.597525",
"0.5955499",
"0.59487087",
"0.5942659",
"0.5936057",
"0.5923418",
"0.59196156",
"0.5909087... | 0.75570846 | 0 |
Remove & Set iptable rules for exposing public IP for enobeb instead of private IP.. | def set_enodebd_iptables_rule():
# Remove & Set iptable rules for exposing public ip
# for enobeb instead of private
cfg = load_service_config('enodebd')
port, interface = cfg['tr069']['port'], cfg['tr069']['interface']
enodebd_public_ip = cfg['tr069']['public_ip']
# IPv4 only as iptables only w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iptables_apply():\n\n with settings(warn_only=True):\n run(\"sudo iptables-restore < /etc/iptables.rules\")",
"def set_ip_adresses(self):\n # unfold a config tree for the current suffix, if any\n for interface, details in self.interfaces.items():\n for k, v in details.items... | [
"0.6663209",
"0.6357194",
"0.62394255",
"0.6021902",
"0.6016427",
"0.58369994",
"0.5809754",
"0.57799",
"0.57165486",
"0.5703059",
"0.56724066",
"0.5669777",
"0.5645836",
"0.5606715",
"0.56015825",
"0.55929905",
"0.558684",
"0.55724764",
"0.55694616",
"0.55657405",
"0.5557915... | 0.68455297 | 0 |
Convert a dict into a namedtuple. | def to_namedtuple(d, classname='struct'):
if not isinstance(d, dict):
raise ValueError("Can only convert dicts into namedtuple")
for k,v in d.iteritems():
if isinstance(v, dict):
d[k] = to_namedtuple(v)
return namedtuple(classname, d.keys())(**d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_tuple(in_dict,tupname='values'):\n the_tup = namedtuple(tupname, in_dict.keys())\n the_tup = the_tup(**in_dict)\n return the_tup",
"def ntuple_from_dict(d):\n return namedtuple('TupleFromDict', d.keys())(**d)",
"def namedtuple_from_dict(obj):\n if isinstance(obj, dict):\n ... | [
"0.7626957",
"0.7620599",
"0.7102021",
"0.67740077",
"0.6631872",
"0.64189035",
"0.6333203",
"0.6311087",
"0.6285666",
"0.62456316",
"0.6243369",
"0.62207985",
"0.59952044",
"0.58233434",
"0.5730133",
"0.56388736",
"0.56069636",
"0.56064814",
"0.56009185",
"0.5566233",
"0.556... | 0.806114 | 0 |
Return index of first clay tile found below current/origin tile and if none are found, return 1. Downward flow is possible (not blocked by clay), if 1 is returned, or an index > (y0 + 1) is returned, otherwise downward flow is blocked. Set wet tiles to '|' along path to clay or if no clay all should be set to '|'. If f... | def flow_down(tiles, x0=0, y0=0, dim=14):
global _flowcnt
yclay = -1
for y in range(1+y0, dim-1):
if(tiles[y][x0] == '#'):
yclay = y
if( yclay < 0 ):
# set all tiles below to '|' and return index of deepest '|'
deepest = dim-1
for y in range(y0, dim-y0-1):
tiles[y][x0] = '|'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flow_left(tiles, x0=0, y0=0, dim=14):\n global _flowcnt\n for xl in range(x0-1, 0, -1):\n if(tiles[y0][xl] == '#'):\n return [xl, y0]\n else:\n tiles[y0][xl] = '|' ; _flowcnt += 1 # flowing left\n if( tiles[y0+1][xl] == '.' ): # stop flowing left and head down\n tiles[y0][xl] = '|... | [
"0.5939262",
"0.5909081",
"0.5863656",
"0.56711936",
"0.56474495",
"0.55265504",
"0.53901654",
"0.5277698",
"0.5269822",
"0.5215685",
"0.5194767",
"0.51930237",
"0.5168052",
"0.51599646",
"0.5151128",
"0.5120858",
"0.5080478",
"0.5069069",
"0.50546664",
"0.5038852",
"0.502224... | 0.64086735 | 0 |
Return index of first clay tile found right of current/origin tile and if none are found, return 1. Rightward flow is possible (not blocked by clay), if 1 is returned, or an index > x+1 is returned, otherwise rightward flow is blocked. Set wet tiles to either '|' along path to clay or if no clay all should be set to '|... | def flow_right(tiles, x0=0, y0=0, dim=14):
global _flowcnt
for xr in range(x0+1, dim-1):
if(tiles[y0][xr] == '#'):
return [xr, y0]
else:
tiles[y0][xr] = '|' ; _flowcnt += 1 # flowing right
if( tiles[y0+1][xr] == '.' ): # flow down -- stop flowing right and flow down
deepest = flow_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flow_left(tiles, x0=0, y0=0, dim=14):\n global _flowcnt\n for xl in range(x0-1, 0, -1):\n if(tiles[y0][xl] == '#'):\n return [xl, y0]\n else:\n tiles[y0][xl] = '|' ; _flowcnt += 1 # flowing left\n if( tiles[y0+1][xl] == '.' ): # stop flowing left and head down\n tiles[y0][xl] = '|... | [
"0.6133292",
"0.5647454",
"0.56351894",
"0.5339487",
"0.53264093",
"0.5215546",
"0.5146599",
"0.51240015",
"0.5120151",
"0.5112491",
"0.50917816",
"0.50912",
"0.50531",
"0.50514895",
"0.50184715",
"0.501208",
"0.49867427",
"0.49845314",
"0.49823982",
"0.49786595",
"0.49774146... | 0.62173504 | 0 |
Return index of first clay tile found left of current/origin tile and if none are found, return 1. Leftward flow is possible (not blocked by clay), if 1 is returned, or an index < x1 is returned, otherwise leftwardward flow is blocked. Set wet tiles to either '|' or '+' along path to clay or if no clay all should be se... | def flow_left(tiles, x0=0, y0=0, dim=14):
global _flowcnt
for xl in range(x0-1, 0, -1):
if(tiles[y0][xl] == '#'):
return [xl, y0]
else:
tiles[y0][xl] = '|' ; _flowcnt += 1 # flowing left
if( tiles[y0+1][xl] == '.' ): # stop flowing left and head down
tiles[y0][xl] = '|'
de... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flow_right(tiles, x0=0, y0=0, dim=14):\n global _flowcnt\n for xr in range(x0+1, dim-1):\n if(tiles[y0][xr] == '#'):\n return [xr, y0]\n else:\n tiles[y0][xr] = '|' ; _flowcnt += 1 # flowing right\n if( tiles[y0+1][xr] == '.' ): # flow down -- stop flowing right and flow down\n de... | [
"0.58539164",
"0.57448274",
"0.5557695",
"0.55487823",
"0.5518897",
"0.5496849",
"0.54825425",
"0.5471294",
"0.54475725",
"0.54471606",
"0.5414942",
"0.53673595",
"0.5365683",
"0.53414446",
"0.5341128",
"0.5280579",
"0.5262887",
"0.5260946",
"0.5257132",
"0.52158743",
"0.5184... | 0.70672554 | 0 |
Once all the leftrightdownward flow has been established, evaluate the overflow tiles that hold steadystate H2O and reset their respective '|' values to '~'. For eash row of tiles, find areas bounded by clay leftrightbelow, anf if tile(s) are marked as '|', set to '~'. Perhapes simplest to navigate is bottomup, assumim... | def overflow(tiles, xsrc, dim=14):
global _flowcnt
global _wetcnt
blocked = [False for idx in range(0, dim-1)]
for y in range(dim-2, 0, -1):
for x in range(0, dim-1):
if( tiles[y][x] == '|' ):
if( tiles[y+1][x] == '#' or tiles[y+1][x] == '~' ):
tiles[y][x] = '~'
_flowcnt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flow_down(tiles, x0=0, y0=0, dim=14):\n global _flowcnt\n yclay = -1\n for y in range(1+y0, dim-1):\n if(tiles[y][x0] == '#'):\n yclay = y\n \n if( yclay < 0 ):\n # set all tiles below to '|' and return index of deepest '|'\n deepest = dim-1\n for y in range(y0, dim-y0-1):\n tiles[y]... | [
"0.64365155",
"0.5886586",
"0.58177894",
"0.5730414",
"0.56128454",
"0.54995936",
"0.5499391",
"0.5447144",
"0.5398074",
"0.5395922",
"0.5385071",
"0.53718567",
"0.53352207",
"0.5310737",
"0.52873784",
"0.52873784",
"0.52873784",
"0.52452433",
"0.52401423",
"0.5236727",
"0.52... | 0.6216894 | 1 |
Push message into prequeue. Will be added to queue when flushMsgs() is called. This is done to prevent miners that execute later in a step from acting on msgs from miners that executed earlier that step. | def pushMsg(self, msg, delay=0):
self.pre_queue.append([msg, delay]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flushMsgs(self):\n\n self.queue = self.pre_queue[:]\n self.pre_queue = []",
"def enqueue(self, message):\n self.pending_messages += [message]",
"def enqueue_message(self, item: MessageQueueItem):\n heapq.heappush(self._message_queue, item)",
"def add_to_queue(self, msg):\n ... | [
"0.6449725",
"0.64490336",
"0.6320997",
"0.6156579",
"0.5998645",
"0.58202463",
"0.58202463",
"0.58202463",
"0.5748217",
"0.5656365",
"0.564649",
"0.5635319",
"0.56329495",
"0.5593771",
"0.5588221",
"0.55239743",
"0.54906934",
"0.5461113",
"0.5453775",
"0.543034",
"0.54136133... | 0.7383343 | 0 |
Adds all messages from prequeue to queue. | def flushMsgs(self):
self.queue = self.pre_queue[:]
self.pre_queue = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enqueue(self, message):\n self.pending_messages += [message]",
"def runQueueEnqueue(self):\n raise NotImplementedError",
"def flush_msg_queue(self):\n if self.msg_queue is None:\n return\n while not self.msg_queue.empty():\n self.msg_queue.get()",
"def pu... | [
"0.65916914",
"0.6586419",
"0.6532083",
"0.6463212",
"0.6447692",
"0.63544184",
"0.62794936",
"0.6202364",
"0.61335087",
"0.6107296",
"0.60093033",
"0.59931624",
"0.5888605",
"0.58861136",
"0.5874488",
"0.5861219",
"0.58143365",
"0.5795629",
"0.5795601",
"0.5788988",
"0.57425... | 0.7283502 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.