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 |
|---|---|---|---|---|---|---|
Returns the quantization config for transformerbased models. | def _get_transformer_quantization_config(subset_size: int) -> Dict[str, Any]:
return {
"algorithm": "quantization",
"preset": "mixed",
"initializer": {
"range": {"num_init_samples": subset_size, "type": DEFAULT_RANGE_TYPE},
"batchnorm_adaptation": {"num_bn_adaptation_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_default_quantization_config(preset: QuantizationPreset, subset_size: int) -> Dict[str, Any]:\n return {\n \"algorithm\": \"quantization\",\n \"preset\": preset.value,\n \"initializer\": {\n \"range\": {\"num_init_samples\": subset_size, \"type\": DEFAULT_RANGE_TYPE},\n ... | [
"0.66286147",
"0.5942934",
"0.5907931",
"0.5872018",
"0.5804783",
"0.57093644",
"0.56935316",
"0.5644522",
"0.56273764",
"0.5596549",
"0.5582015",
"0.55781955",
"0.5568165",
"0.5547753",
"0.5484123",
"0.54839206",
"0.54510504",
"0.5421256",
"0.54176253",
"0.5367854",
"0.53125... | 0.780377 | 0 |
Returns the default quantization config | def _get_default_quantization_config(preset: QuantizationPreset, subset_size: int) -> Dict[str, Any]:
return {
"algorithm": "quantization",
"preset": preset.value,
"initializer": {
"range": {"num_init_samples": subset_size, "type": DEFAULT_RANGE_TYPE},
"batchnorm_adap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_transformer_quantization_config(subset_size: int) -> Dict[str, Any]:\n return {\n \"algorithm\": \"quantization\",\n \"preset\": \"mixed\",\n \"initializer\": {\n \"range\": {\"num_init_samples\": subset_size, \"type\": DEFAULT_RANGE_TYPE},\n \"batchnorm_adapt... | [
"0.7033103",
"0.6777367",
"0.6720709",
"0.65748835",
"0.6455274",
"0.642663",
"0.63270366",
"0.63183445",
"0.63130504",
"0.6306793",
"0.62361944",
"0.6232875",
"0.621485",
"0.6185362",
"0.6169694",
"0.6101184",
"0.6091094",
"0.6084804",
"0.60460657",
"0.59970856",
"0.5981526"... | 0.8306506 | 0 |
Creates the NNCFConfig for the quantization algorithm. | def _create_nncf_config(
preset: QuantizationPreset,
target_device: TargetDevice,
subset_size: int,
model_type: Optional[ModelType],
ignored_scope: Optional[IgnoredScope],
advanced_parameters: Optional[AdvancedQuantizationParameters],
) -> NNCFConfig:
if model_type is None:
compressi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, quantized_edges_in_cfg: int, total_edges_in_cfg: int):\n self.quantized_edges_in_cfg = quantized_edges_in_cfg\n self.total_edges_in_cfg = total_edges_in_cfg",
"def _add_fp_configs(CONFIG):\n CONFIG.declare(\n 'fp_cutoffdecr',\n ConfigValue(\n default=1... | [
"0.6211365",
"0.5947636",
"0.5926075",
"0.5917099",
"0.58897614",
"0.584447",
"0.584447",
"0.56702006",
"0.5627676",
"0.55820346",
"0.5560999",
"0.55283594",
"0.54756486",
"0.54677653",
"0.5465148",
"0.54618865",
"0.5459208",
"0.54586923",
"0.54444957",
"0.54440576",
"0.54371... | 0.7439748 | 0 |
Implementation of the `compress_weights()` method for the PyTorch backend. | def compress_weights(model: torch.nn.Module, use_fake_quantize: bool = False) -> torch.nn.Module:
compressed_model, _ = replace_modules_by_nncf_modules(model)
insert_pre_compression_operations(model, use_fake_quantize)
return compressed_model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compress(self, tensor):",
"def compress(self, tensor, *args, **kwargs):\n pass",
"def weight_compression(weights, bits, axis=0, quantizer=None):\n assert bits <= 8\n n = 2**bits\n index_table = []\n codebook_table = np.zeros((weights.shape[axis], n))\n km_models = [None] * weights.shape[axis]\n... | [
"0.67688566",
"0.6305428",
"0.62857914",
"0.59490013",
"0.59490013",
"0.57656217",
"0.5713356",
"0.57009125",
"0.56955546",
"0.56836677",
"0.55329573",
"0.5532722",
"0.5511265",
"0.5505167",
"0.5443281",
"0.54317117",
"0.5425128",
"0.54003054",
"0.53999305",
"0.5396085",
"0.5... | 0.67650056 | 1 |
Create an embedded document instance from MongoDB data | def build_from_mongo(cls, data, use_cls=True):
# If a _cls is specified, we have to use this document class
if use_cls and '_cls' in data:
cls = cls.opts.instance.retrieve_embedded_document(data['_cls'])
doc = cls()
doc.from_mongo(data)
return doc | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_mongo(data):\n if not data:\n return None\n\n data['id'] = str(data['_id'])\n return data",
"def from_mongo(cls, data: dict) -> Union[\"MongoModel\", Dict]:\n if not data:\n return data\n id = data.pop('_id', None)\n return cls(**dict(data, id=id))",
"def create... | [
"0.7066903",
"0.6612481",
"0.63551545",
"0.6348332",
"0.6091033",
"0.6033079",
"0.5778242",
"0.5773537",
"0.5751162",
"0.5727225",
"0.5722528",
"0.5691701",
"0.56832474",
"0.56717724",
"0.55828565",
"0.55790466",
"0.5539406",
"0.5517863",
"0.5484895",
"0.54323846",
"0.5430872... | 0.73655903 | 0 |
Multidimensional Gaussian fourier filter. The array is multiplied with the fourier transform of a Gaussian kernel. | def fourier_gaussian(input, sigma, n=-1, axis=-1, output=None):
input = numpy.asarray(input)
output = _get_output_fourier(output, input)
axis = normalize_axis_index(axis, input.ndim)
sigmas = _ni_support._normalize_sequence(sigma, input.ndim)
sigmas = numpy.asarray(sigmas, dtype=numpy.float64)
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fmgf(array, sigma):\n x, y = np.arange(len(array)), array.copy()\n yg = ndimage.filters.gaussian_filter(y, sigma)\n y -= yg\n\n # digitizing\n m = 101\n dy = 6.0 * mad(y) / m\n ybin = np.arange(np.min(y) - 5 * dy, np.max(y) + 5 * dy + dy, dy)\n z = np.zeros([len(ybin), len(x)])\n z[n... | [
"0.6724297",
"0.6515853",
"0.64436597",
"0.64298147",
"0.6300525",
"0.62142223",
"0.6133565",
"0.61210185",
"0.60772467",
"0.6005786",
"0.59797704",
"0.58723",
"0.58492655",
"0.5830647",
"0.575321",
"0.56844056",
"0.5630864",
"0.56108207",
"0.55966944",
"0.5580227",
"0.557872... | 0.66539884 | 1 |
Multidimensional uniform fourier filter. The array is multiplied with the Fourier transform of a box of given size. | def fourier_uniform(input, size, n=-1, axis=-1, output=None):
input = numpy.asarray(input)
output = _get_output_fourier(output, input)
axis = normalize_axis_index(axis, input.ndim)
sizes = _ni_support._normalize_sequence(size, input.ndim)
sizes = numpy.asarray(sizes, dtype=numpy.float64)
if not ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_fourier_filter(self):\n size = max(64, int(2 ** np.ceil(np.log2(2 * self.m[-1].item()))))\n\n pi = torch.acos(torch.zeros(1)).item() * 2.0\n n = torch.cat(\n [\n torch.arange(1, size // 2 + 1, 2, device=self.n.device),\n torch.arange(size // 2 ... | [
"0.6378481",
"0.6309765",
"0.62861556",
"0.62434644",
"0.61714876",
"0.60929567",
"0.6092913",
"0.6006388",
"0.59960955",
"0.59704673",
"0.57724774",
"0.57447904",
"0.5739366",
"0.5689734",
"0.5677718",
"0.5673864",
"0.56690097",
"0.5644021",
"0.56193554",
"0.56177664",
"0.56... | 0.672973 | 0 |
Multidimensional ellipsoid Fourier filter. The array is multiplied with the fourier transform of a ellipsoid of given sizes. | def fourier_ellipsoid(input, size, n=-1, axis=-1, output=None):
input = numpy.asarray(input)
if input.ndim > 3:
raise NotImplementedError("Only 1d, 2d and 3d inputs are supported")
output = _get_output_fourier(output, input)
axis = normalize_axis_index(axis, input.ndim)
sizes = _ni_support._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _irfft2d(f_x) :",
"def process( fids, ndim=2 ):\n\timg = np.empty_like( fids )\n\tax = -1*(np.array( range(ndim) )+1)\n\t\n\timg = np.fft.fftshift( np.fft.fftn( fids, axes=ax, ).astype( np.complex64), axes=ax )\n\t\n\treturn np.squeeze(img)",
"def _get_fourier_filter(self):\n size = max(64, int(2 ... | [
"0.5919297",
"0.5817323",
"0.5366147",
"0.5307928",
"0.52779627",
"0.5270385",
"0.5188855",
"0.5180645",
"0.51758784",
"0.5060478",
"0.5059644",
"0.5033383",
"0.50284445",
"0.5026053",
"0.5017994",
"0.50149393",
"0.5008967",
"0.4998893",
"0.4998793",
"0.49833018",
"0.49821383... | 0.6894624 | 0 |
Safe conversion of page to utf | def __init__(self, page):
try:
self.page = page.encode("utf8")
except UnicodeDecodeError:
self.page = page.decode('iso-8859-1').encode('utf8') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convertFromUnicode(content):\n return content",
"def process_page(page):\n content = utils.any2unicode(page, 'utf8').strip()\n content = re.sub(r\"[^a-zA-Z]\", \" \", content)\n \n return content",
"def fix_unicode_encode_error(cls, safe=False):\n from .path9 import Path\n from... | [
"0.65442806",
"0.6308765",
"0.62095857",
"0.6024676",
"0.59617436",
"0.5852157",
"0.58336884",
"0.5832144",
"0.5830336",
"0.5777034",
"0.5749223",
"0.5742238",
"0.5740002",
"0.57341146",
"0.57124454",
"0.56925076",
"0.5677184",
"0.5604121",
"0.5572304",
"0.5555498",
"0.555383... | 0.64852524 | 1 |
Convert page to str | def __str__(self):
return str(self.page) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_to_string(page, alph):\n s = ''\n links = Measurements.get_all_links(page)\n for l in links:\n s += alph[l]\n return s",
"def process_page(page):\n content = utils.any2unicode(page, 'utf8').strip()\n content = re.sub(r\"[^a-zA-Z]\", \" \", content)\n \n ... | [
"0.72416747",
"0.6311964",
"0.61297363",
"0.61254025",
"0.6117378",
"0.6117378",
"0.5759532",
"0.5716281",
"0.5664423",
"0.5635445",
"0.5631912",
"0.5611601",
"0.55995196",
"0.5591691",
"0.5526723",
"0.551222",
"0.5453172",
"0.5440903",
"0.5410642",
"0.54025006",
"0.5399925",... | 0.68699765 | 1 |
Returns the type of applying the binary operator with the current type and the type of the right operand, or returns None if the operation is not valid | def binop_type(cls, op, right_type):
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_operation(\n statement: ast.BinOp,\n) -> Optional[Union[int, float, str, bytes]]:\n if isinstance(statement.left, ast.BinOp):\n left = evaluate_operation(statement.left)\n else:\n left = evaluate_node(statement.left)\n\n if isinstance(statement.right, ast.BinOp):\n rig... | [
"0.6980014",
"0.6376216",
"0.63047373",
"0.6289566",
"0.6168144",
"0.5986405",
"0.594299",
"0.5919433",
"0.59048015",
"0.58846456",
"0.58320713",
"0.5771884",
"0.5764865",
"0.5709627",
"0.57065237",
"0.56597155",
"0.5610864",
"0.5607209",
"0.55886",
"0.5584397",
"0.5579483",
... | 0.7616685 | 0 |
Returns the type of applying the unary operator to the current type | def unaryop_type(cls, op):
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unary_operator(op):\n # Only negate is currently supported for all our possible input types.\n valid_ops = {'-'}\n if op not in valid_ops:\n raise ValueError(\"Invalid unary operator %s.\" % op)\n\n def unary_operator(self):\n # This can't be hoisted up a scope because the types retur... | [
"0.7026326",
"0.62878203",
"0.62745595",
"0.6230687",
"0.61832154",
"0.6153777",
"0.6153615",
"0.6035553",
"0.60099876",
"0.5954016",
"0.59390163",
"0.5836451",
"0.58051866",
"0.5675768",
"0.56312513",
"0.55480313",
"0.55199814",
"0.5483337",
"0.54803765",
"0.5456091",
"0.539... | 0.73739296 | 0 |
Ensure that settings are restored after test_settings_before. | def test_settings_restored(self) -> None:
from django.conf import settings
assert TestLiveServer._test_settings_before_run is True # type: ignore[attr-defined]
assert (
f"{settings.__class__.__module__}.{settings.__class__.__name__}"
== "django.conf.Settings"
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teardown_function():\n\n # Force module reload as the default test settings have been restored\n importlib.reload(defaults)",
"def teardown_method(self, method):\n restore_settings()",
"def teardown(self):\n # dump persistent storage to file\n dump_persistent_settings(self.settin... | [
"0.73878825",
"0.6784818",
"0.6733559",
"0.6715742",
"0.6488583",
"0.6481755",
"0.6481755",
"0.64424235",
"0.64274263",
"0.6407588",
"0.6295553",
"0.6175864",
"0.61559063",
"0.61030084",
"0.609804",
"0.6097769",
"0.60595536",
"0.60365754",
"0.6018529",
"0.60083866",
"0.598593... | 0.775121 | 0 |
LiveServer always serves statics with ``django.contrib.staticfiles`` handler. | def test_serve_static_with_staticfiles_app(self, django_testdir, settings) -> None:
django_testdir.create_test_module(
"""
from urllib.request import urlopen
from django.utils.encoding import force_str
class TestLiveServer:
def test_a(self, live_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serve_static_files(request, path, insecure=False, **kwargs):\n\n if not settings.DEBUG and not insecure:\n raise Http404\n normalized_path = posixpath.normpath(unquote(path)).lstrip('/')\n absolute_path = finders.find(normalized_path)\n if not absolute_path:\n if path.endswith('/') or... | [
"0.692166",
"0.6793395",
"0.672456",
"0.66780925",
"0.6508464",
"0.6489936",
"0.646022",
"0.6422593",
"0.6398329",
"0.6394773",
"0.6379119",
"0.6352794",
"0.63344926",
"0.6232494",
"0.6215064",
"0.6189717",
"0.61667037",
"0.6146262",
"0.61179745",
"0.6043764",
"0.60087985",
... | 0.70656496 | 0 |
Because ``django.contrib.staticfiles`` is not installed LiveServer can not serve statics with django >= 1.7 . | def test_serve_static_dj17_without_staticfiles_app(self, live_server, settings) -> None:
with pytest.raises(HTTPError):
urlopen(live_server + "/static/a_file.txt").read() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_serve_static_with_staticfiles_app(self, django_testdir, settings) -> None:\n django_testdir.create_test_module(\n \"\"\"\n from urllib.request import urlopen\n\n from django.utils.encoding import force_str\n\n class TestLiveServer:\n def te... | [
"0.6716268",
"0.6231927",
"0.6190265",
"0.61497104",
"0.592605",
"0.59110135",
"0.58870727",
"0.5886149",
"0.5850551",
"0.5821276",
"0.5779303",
"0.5771501",
"0.57279146",
"0.57038695",
"0.56011933",
"0.5590249",
"0.55280924",
"0.5513304",
"0.5501698",
"0.5489761",
"0.5481401... | 0.6403566 | 1 |
TextResponse will be not applied by RuleExtractor. Need convert to HtmlResponse | def process_response(request, response, spider):
headers = ['text/html; charset=UTF-8', 'text/html; charset=utf-8', 'text/html;charset=UTF-8',
'text/html;charset=utf-8', 'text/html;charset=ISO-8859-1',
'application/xhtml+xml; charset=utf-8']
# log.msg("In Midd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_html_output(self):\n pass",
"def get_html(self):\r\n pass",
"def _format_response(self, response):\n texts = []\n for result in response.results: \n texts.append(result.alternatives[0].transcript)\n return texts",
"def process_response(self, request, res... | [
"0.61386234",
"0.59616053",
"0.5953273",
"0.5924247",
"0.5882797",
"0.5802751",
"0.57943356",
"0.5772422",
"0.5726808",
"0.5726808",
"0.5669942",
"0.56435025",
"0.5613142",
"0.55854046",
"0.5585026",
"0.5578091",
"0.55673695",
"0.55666703",
"0.5552076",
"0.553761",
"0.5524938... | 0.65883505 | 0 |
Tests a given component dataframe for convergence, returning True for converged components | def test_component(self, component_dataframe, ignore_weight=False):
# define our acceptable bounds
skew_range = [-0.6, 0.6]
kurt_range = [-1.5, 0.75] # accept shorter tails for bang-on data
weight_low = 0.008
# perform weight test first if not ignored
if not ignore_wei... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def converged(self) -> bool:",
"def converged(self) -> bool:",
"def converged(self) -> bool:",
"def has_convergence_delta(self) -> bool:\n return False",
"def converged(self) -> bool:\n if self._species is not None and self._species.n_atoms == 1:\n return True # Optimisation 0 DOF... | [
"0.6538666",
"0.6538666",
"0.6538666",
"0.6366643",
"0.6296365",
"0.605637",
"0.58805627",
"0.58160526",
"0.57632166",
"0.5750119",
"0.5745037",
"0.57065284",
"0.5695569",
"0.5663899",
"0.56550163",
"0.5587026",
"0.55850583",
"0.5548356",
"0.553449",
"0.5469594",
"0.5452946",... | 0.6763347 | 0 |
Take location (code2,code3,country name) return countryName and coords | def locate(location):
coord = None
country_name = None
if location:
location = location.lower()
for ind, row in country_map.iterrows():
if (
(re.match(r'(.*\W|\W*){}\b'.format(row['code2']), location))
or(re.match(r'(.*\W|\W*){}\b'.format(row['code3']), location... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loc_to_coord(codes):\n def adfilter(codes):\n return re.findall(\"\"\"[a-zA-Z]+, [A-Z]{2}\"\"\", \";\".join(codes))\n\n api_key = \"AIzaSyCxQCjOrHFAf7T-W3vtUYqWkgSFkvMjxN4\"\n\n g = geocoders.GoogleV3(api_key = api_key)\n coords = {\"lat\":[], \"long\":[]}\n for code in adfilter(codes):\n... | [
"0.6872996",
"0.6658761",
"0.6427587",
"0.64248663",
"0.6413235",
"0.6389267",
"0.6352416",
"0.6344214",
"0.6342886",
"0.6201723",
"0.61685705",
"0.61586225",
"0.614145",
"0.61208564",
"0.6072315",
"0.606234",
"0.6036042",
"0.6028122",
"0.6024029",
"0.60227036",
"0.6012603",
... | 0.7792582 | 0 |
Read the steering file to gather user inputs from the GUI of pyRiverBed. Parameters are declared as global variables. | def read_steering():
print('+> Trying to read steering file...', end='')
try:
d = np.loadtxt('steering.txt', delimiter=',', skiprows=1)
print(' [done]')
except IOError:
print('\nNo steering file found')
print('Please provide steering file first\n')
job_done()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_input(self):\n try:\n path = tkFileDialog.askdirectory()\n if not path: # User the cancelled dialog box so bug out\n return False\n # Search the user-provided path for all the input files.\n foundall, missing = self.files.locate_input(path)... | [
"0.6534614",
"0.6480986",
"0.6264293",
"0.61416334",
"0.6109954",
"0.5936167",
"0.5849614",
"0.5842282",
"0.5826436",
"0.578414",
"0.57564574",
"0.57386065",
"0.5683754",
"0.567388",
"0.5645699",
"0.5645465",
"0.5632296",
"0.56240624",
"0.56231207",
"0.55820847",
"0.5581234",... | 0.68253434 | 0 |
Print a table displaying parameters read from the steering file. Require 'tabulate' library. | def print_para_table(s):
if MODE == 1:
t = [['Parameter', 'Value', 'Unit'],
['Number of bends', NBENDS, '/'],
['Width', WIDTH, 'm'],
['Depth', DEPTH, 'm'],
['Length', LAMBDA*(NBENDS+1), 'm'],
['Arc wavelength', LAMBDA, 'm'],
['Sl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tab_printer(args):\n args = vars(args)\n keys = sorted(args.keys())\n tab = Texttable()\n tab.add_rows([[\"Parameter\", \"Value\"]])\n tab.add_rows([[k.replace(\"_\", \" \").capitalize(), args[k]] for k in keys])\n print(tab.draw())",
"def tab_printer(args):\n args = vars(args)\n keys... | [
"0.6731898",
"0.6727638",
"0.6693523",
"0.66596514",
"0.66596514",
"0.64847577",
"0.6466909",
"0.63867766",
"0.6372735",
"0.63454986",
"0.6304587",
"0.629846",
"0.62803787",
"0.62803787",
"0.62415814",
"0.6233019",
"0.621662",
"0.6205308",
"0.61270964",
"0.6085865",
"0.608106... | 0.7408522 | 0 |
Print a table displaying mean, median and mode of centerline grid size before and after resampling. Require 'tabulate' library. | def print_resamp_table(mean1, median1, mode1, mean2, median2, mode2):
t = [['Streamwise\nresolution', 'Before '
+'After\nresampling --> resampling', '\nUnit'],
['Mean', str(mean1) + ' --> ' + str(mean2), 'm'],
['Median', str(median1) + ' --> ' + str(median2), 'm'],
['Mode', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summarize_as_table(self):\n h = human_readable_size\n h_throughput = human_readable_throughput\n table = [\n ['Total Time (seconds)', '%.3f' % self.total_time,\n self.std_dev_total_time],\n ['Maximum Memory', h(self.max_memory), h(self.std_dev_max_memory)]... | [
"0.6565323",
"0.6138334",
"0.6114011",
"0.6073732",
"0.60654634",
"0.605878",
"0.60337764",
"0.60322475",
"0.60169584",
"0.6001512",
"0.59973735",
"0.5922056",
"0.58799005",
"0.58584213",
"0.58325213",
"0.58321124",
"0.5765773",
"0.5743075",
"0.572621",
"0.5705246",
"0.567230... | 0.7362937 | 0 |
Print Kinoshita Curve equation. Only work for Mode 1. | def print_eqn():
if sys.stdout.encoding.lower().startswith('utf'):
if JS != 0 and JF != 0:
print('Eqn: \u03B8=' + str(np.around(THETA0, decimals=6)) +
'*sin(2\u03C0s/' + str(np.around(LAMBDA, decimals=6)) +
')\n +' + str(np.around(THETA0**3, decimals=6)) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_kinoshita():\n if MODE != 1:\n return [], [], [], [], []\n print('MODE 1: GENERATE KINOSHITA CURVE FROM EQUATION is selected')\n print('Kinoshita Curve parameters are read from steering file:')\n print_eqn()\n s = np.linspace(0, NBENDS*LAMBDA, int(NBENDS*LAMBDA/DS) + 1)\n print_p... | [
"0.6009057",
"0.59244484",
"0.57258797",
"0.5719299",
"0.5606414",
"0.5596424",
"0.5556299",
"0.55449724",
"0.5524112",
"0.5523874",
"0.55117285",
"0.5498666",
"0.5461777",
"0.5460435",
"0.5453134",
"0.5452214",
"0.53886247",
"0.5387569",
"0.53753626",
"0.53699505",
"0.536399... | 0.6549474 | 0 |
Build Kinoshita Curve (noncomputational part). Only work for Mode 1. | def build_kinoshita():
if MODE != 1:
return [], [], [], [], []
print('MODE 1: GENERATE KINOSHITA CURVE FROM EQUATION is selected')
print('Kinoshita Curve parameters are read from steering file:')
print_eqn()
s = np.linspace(0, NBENDS*LAMBDA, int(NBENDS*LAMBDA/DS) + 1)
print_para_table(s)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_k(self):\n\t\n\tself.k = -np.array([self.sth*self.cphi, self.sth*self.sphi, self.cth])\n\n\treturn",
"def createAnisotropicK(powerSpectrum,center,aniso):\n\n if aniso > 1.:\n anisoNew = 1. / aniso\n padDim = int( np.round( powerSpectrum.shape[0] / ( anisoNew ) ) )\n else:\n ... | [
"0.61084265",
"0.58661884",
"0.5722478",
"0.56312686",
"0.562919",
"0.55858815",
"0.558461",
"0.5543797",
"0.55313665",
"0.5458351",
"0.5447106",
"0.5440787",
"0.5429062",
"0.5335893",
"0.5293114",
"0.52813584",
"0.5255335",
"0.5196818",
"0.51894844",
"0.5181761",
"0.5176679"... | 0.73484176 | 0 |
Read river centerline coordinates from userprepared centerline file. Centerline is then resampled to prevent ununiform spacing. Only work for Mode 2. | def read_centerline(s, x, y, cur, theta):
if MODE == 2:
print('MODE 2: READ YOUR OWN RIVER CENTERLINE FROM FILE is selected')
try:
centerlinexy = np.loadtxt(FNAME)
except IOError:
print('\'' + FNAME + '\' not found')
print('Please place \'' + FNAME + '\' i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ds9_line(self, center_coordinates, width=20 ):\n for fn in self.images:\n print(fn)\n ff = pyfits.open(fn)\n w = wcs.WCS(ff[0].header)\n co = center_coordinates\n print(co.ra.deg, co.dec.deg )\n #pix = w.wcs_world2pix([co.ra], [co.dec], 0... | [
"0.5484611",
"0.54598975",
"0.541714",
"0.5410985",
"0.53711194",
"0.5348809",
"0.53283346",
"0.5277495",
"0.5272035",
"0.52507305",
"0.52339166",
"0.5203206",
"0.5176077",
"0.5174357",
"0.5174031",
"0.51609975",
"0.51548326",
"0.5138431",
"0.5123837",
"0.50979066",
"0.508635... | 0.74167114 | 0 |
Extend centerline to have straight channels at both ends. | def extend_centerline(s, x, y, cur, theta):
print('+> Extending centerline to have straight channels at both ends...', end='')
if MODE == 1:
extlength = LAMBDA/10
d = DS
elif MODE == 2:
extlength = WIDTH
d = INTERVAL
num = int(extlength/d)
coshead = (x[1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def centerAxis():\n dislin.center()",
"def linecenter(l):\n return scale3(add(l[0],l[1]),0.5)",
"def centerline_to_polygon(\n centerline: np.ndarray, width_scaling_factor: float = 1.0, visualize: bool = False\n) -> np.ndarray:\n # eliminate duplicates\n _, inds = np.unique(centerline, axis=0, re... | [
"0.6367526",
"0.6277636",
"0.60933346",
"0.58676577",
"0.58125347",
"0.57696474",
"0.5726331",
"0.5680378",
"0.56134474",
"0.5567007",
"0.55354726",
"0.5523416",
"0.5488831",
"0.5460297",
"0.5416137",
"0.5398362",
"0.53754103",
"0.5371892",
"0.5368449",
"0.5356547",
"0.534115... | 0.7979626 | 0 |
Impose a phase lag to the curvature signal by replacing the local curvature with the upstreamwise moving averaged curvature. | def lag(s, cur, t):
if LAG == 0:
return cur
else:
if MODE == 1:
num = int(WIDTH*LAGSTR/DS)
elif MODE == 2:
num = int(WIDTH*LAGSTR/np.mean(np.diff(s)))
if np.mod(t, LPRINT) == 0:
print('+> Adding phase lag to local curvature...', end='')
cur = compu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_baseline(self):\n\n print(\" \\t Apply Savitzky-Golay filter \\t %d\" %self.nwin)\n base_savgol = signal.savgol_filter(self.input, self.nwin, 1)\n self.input_nobase = self.input - base_savgol",
"def adjust_u(self):\r\n # compute the volume integrals of the x,y, and z compon... | [
"0.5069656",
"0.49511254",
"0.4938894",
"0.49136677",
"0.48906946",
"0.48032054",
"0.46865338",
"0.46588433",
"0.4652921",
"0.4643875",
"0.4641906",
"0.46012482",
"0.4595003",
"0.45939776",
"0.45844513",
"0.45730233",
"0.45540237",
"0.45404497",
"0.4538936",
"0.45381907",
"0.... | 0.49604023 | 1 |
Compute left and right offset polylines of centerline with an offset distance of L. Thank Y. Luo for improving the offsetting method. | def offset(x, y, L):
length = x.size
offsetx = np.zeros((length, 2))
offsety = np.zeros((length, 2))
dx = np.zeros(length-1)
dy = np.zeros(length-1)
dxL = np.zeros(length-1)
dyL = np.zeros(length-1)
xl = np.zeros(length) # counterclockwise
xr = np.zeros(length) # clockwise
yl = n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_laneOffset(self):\n center_line = np.poly1d(np.mean([self.line_l.get_LinePoly().coeffs, self.line_r.get_LinePoly().coeffs], axis=0))\n # store the center line polynomial\n self.center_poly = center_line\n center_point = IMAGE_WIDTH/2 - center_line(709)\n offset_from_c... | [
"0.74781597",
"0.6577585",
"0.6375418",
"0.6173955",
"0.6073473",
"0.6069938",
"0.597449",
"0.59539807",
"0.59206563",
"0.5882129",
"0.58703756",
"0.5837737",
"0.58107406",
"0.5750666",
"0.57391214",
"0.570022",
"0.56990975",
"0.5670591",
"0.5662863",
"0.56608677",
"0.5651498... | 0.7511953 | 0 |
Build and write the finite element mesh (noncompuational). | def write_mesh_file(allxyz, beck_bed):
if SAVEMESH:
print('+> Saving finite element mesh files...', end='')
fname = FNAME.rsplit('.', 1)[0]
ncol = beck_bed[0,:].size
nrow = beck_bed[:,0].size
nele = (nrow-1)*(ncol-1)*2
d = compute_mesh(nrow, ncol, nele)
h = ':... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateDummyUpperDimensionalMesh(self):\n\n\n sys.stdout = open(os.devnull, \"w\")\n p = self.InferPolynomialDegree()\n mesh = Mesh()\n if self.element_type == \"tri\":\n mesh.Parallelepiped(nx=1,ny=1,nz=1, element_type=\"tet\")\n mesh.GetHighOrderMesh(p=p)\n ... | [
"0.67319965",
"0.6486597",
"0.641751",
"0.6250623",
"0.611316",
"0.6060483",
"0.6028214",
"0.5988006",
"0.59420913",
"0.59015757",
"0.5859401",
"0.5840814",
"0.5839659",
"0.5817488",
"0.581355",
"0.57974845",
"0.5776498",
"0.57728815",
"0.5749524",
"0.57306874",
"0.57267076",... | 0.72402173 | 0 |
Generate a rustanalyzer compatible rustproject.json file. | def generate_rust_project_json(self) -> None:
if not self.rust_crates:
return
with open(os.path.join(self.environment.get_build_dir(), 'rust-project.json'),
'w', encoding='utf-8') as f:
json.dump(
{
"sysroot_src": os.path.join... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createproject(destinationdir):\n print(f\"Writing json data files to {destinationdir}\")\n return",
"def projectToJSONFile(projectPath):\n jsonProjectFileName = projectPath.split('.')[0] + '_summary.json'\n jsonProject = projectToJSON(projectPath)\n with open (jsonProjectFileName, 'w') as outF... | [
"0.5765005",
"0.5750292",
"0.56758595",
"0.5569898",
"0.55584913",
"0.547835",
"0.547835",
"0.547835",
"0.5442536",
"0.5390132",
"0.5291652",
"0.52869755",
"0.5279458",
"0.52660453",
"0.525721",
"0.52367043",
"0.5209489",
"0.52066916",
"0.5184295",
"0.51825064",
"0.5129931",
... | 0.69861084 | 0 |
Splits the target's sources into .vala, .gs, .vapi, and other sources. Handles both preexisting and generated sources. Returns a tuple (vala, vapi, others) each of which is a dictionary with the keys being the path to the file (relative to the build directory) and the value being the object that generated or represents... | def split_vala_sources(self, t: build.BuildTarget) -> \
T.Tuple[T.MutableMapping[str, File], T.MutableMapping[str, File],
T.Tuple[T.MutableMapping[str, File], T.MutableMapping]]:
vala: T.MutableMapping[str, File] = OrderedDict()
vapi: T.MutableMapping[str, File] = Ordered... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_vala_compile(self, target: build.BuildTarget) -> \\\n T.Tuple[T.MutableMapping[str, File], T.MutableMapping[str, File], T.List[str]]:\n (vala_src, vapi_src, other_src) = self.split_vala_sources(target)\n extra_dep_files = []\n if not vala_src:\n raise Invalid... | [
"0.6056835",
"0.58320844",
"0.56975776",
"0.5695355",
"0.56941354",
"0.56379557",
"0.55843604",
"0.5572055",
"0.5410893",
"0.535213",
"0.5313574",
"0.53130484",
"0.530888",
"0.52893823",
"0.5281984",
"0.5279749",
"0.5272755",
"0.5268782",
"0.5266625",
"0.52504265",
"0.5248615... | 0.785854 | 0 |
Vala is compiled into C. Set up all necessary build steps here. | def generate_vala_compile(self, target: build.BuildTarget) -> \
T.Tuple[T.MutableMapping[str, File], T.MutableMapping[str, File], T.List[str]]:
(vala_src, vapi_src, other_src) = self.split_vala_sources(target)
extra_dep_files = []
if not vala_src:
raise InvalidArguments(f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_glibc():\n if not os.path.exists(glibc_build_dir):\n docmd(\"mkdir %s\" % glibc_build_dir)\n glibc_subdir = \"glibc-%s\" % glibc_version\n if not os.path.exists(glibc_subdir):\n docmd(\"wget http://ftpmirror.gnu.org/glibc/\"\n \"%s.tar.bz2\" % glibc_subdir)\n docmd(\"tar jxf %s.tar.b... | [
"0.5602567",
"0.543335",
"0.53301674",
"0.5304108",
"0.5286191",
"0.52635735",
"0.5227829",
"0.51943076",
"0.5164394",
"0.51239663",
"0.5060787",
"0.50462466",
"0.5021612",
"0.4998351",
"0.4991233",
"0.4991233",
"0.49836853",
"0.4957573",
"0.494618",
"0.49404785",
"0.49330255... | 0.64493704 | 0 |
Generate rules for transpiling Cython files to C or C++ | def generate_cython_transpile(self, target: build.BuildTarget) -> \
T.Tuple[T.MutableMapping[str, File], T.MutableMapping[str, File], T.List[str]]:
static_sources: T.MutableMapping[str, File] = OrderedDict()
generated_sources: T.MutableMapping[str, File] = OrderedDict()
cython_source... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pyo():\n local('python -O -m compileall .')",
"def pyo():\n local('python -O -m compileall .')",
"def compile_cutils():\r\n\r\n types = ['npy_' + t for t in ['int8', 'int16', 'int32', 'int64', 'int128',\r\n 'int256', 'uint8', 'uint16', 'uint32', 'uint64', 'uint128', 'uint256',\r\n 'f... | [
"0.644899",
"0.644899",
"0.63634294",
"0.63512045",
"0.6192792",
"0.6134807",
"0.5765677",
"0.5760449",
"0.5747454",
"0.5743692",
"0.56498545",
"0.5609859",
"0.55956745",
"0.5582601",
"0.5581401",
"0.5578906",
"0.5548663",
"0.5526328",
"0.55054164",
"0.5475244",
"0.54675543",... | 0.65219265 | 0 |
Helper method to get rsp options. rsp_file_syntax() is only guaranteed to be implemented if can_linker_accept_rsp() returns True. | def _rsp_options(self, tool: T.Union['Compiler', 'StaticLinker', 'DynamicLinker']) -> T.Dict[str, T.Union[bool, RSPFileSyntax]]:
options = {'rspable': tool.can_linker_accept_rsp()}
if options['rspable']:
options['rspfile_quote_style'] = tool.rsp_file_syntax()
return options | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_options(ret):\n attrs = {\"host\": \"host\", \"port\": \"port\", \"skip\": \"skip_on_error\", \"mode\": \"mode\"}\n\n _options = salt.returners.get_returner_options(\n __virtualname__, ret, attrs, __salt__=__salt__, __opts__=__opts__\n )\n return _options",
"def compilation_options(se... | [
"0.50831187",
"0.4936194",
"0.4710779",
"0.4703603",
"0.47000256",
"0.46416172",
"0.46384525",
"0.46382034",
"0.46292686",
"0.45956933",
"0.45816252",
"0.4573522",
"0.45415303",
"0.45326465",
"0.45186582",
"0.44897",
"0.44642767",
"0.44639853",
"0.4455904",
"0.44428545",
"0.4... | 0.7745526 | 0 |
scan a Fortran file for dependencies. Needs to be distinct from target to allow for recursion induced by `include` statements.er It makes a number of assumptions, including `use`, `module`, `submodule` name is not on a continuation line Regex `incre` works for `include "foo.f90"` and `include "foo.f90"` `usere` works f... | def _scan_fortran_file_deps(src: Path, srcdir: Path, dirname: Path, tdeps, compiler) -> T.List[str]:
incre = re.compile(FORTRAN_INCLUDE_PAT, re.IGNORECASE)
usere = re.compile(FORTRAN_USE_PAT, re.IGNORECASE)
submodre = re.compile(FORTRAN_SUBMOD_PAT, re.IGNORECASE)
mod_files = []
src = Path(src)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan_fortran_module_outputs(self, target):\n if self.use_dyndeps_for_fortran():\n return\n compiler = None\n # TODO other compilers\n for lang, c in self.environment.coredata.compilers.host.items():\n if lang == 'fortran':\n compiler = c\n ... | [
"0.66169536",
"0.61312497",
"0.58868647",
"0.5637438",
"0.55885524",
"0.5586976",
"0.5523092",
"0.5467778",
"0.5432288",
"0.5417047",
"0.5335516",
"0.519833",
"0.51949865",
"0.51465106",
"0.5142541",
"0.5124167",
"0.5095581",
"0.50270045",
"0.5003758",
"0.49810615",
"0.494451... | 0.7567411 | 0 |
Returns a histogram over all relationships in a graph | def count_relations(graph):
return Counter(
data[RELATION]
for _, _, data in graph.edges_iter(data=True)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_unique_relations(graph):\n return Counter(itt.chain.from_iterable(get_edge_relations(graph).values()))",
"def multiple_connections_histogram(synapses):\n count_of_synapses = synapses.groupby(['pre', 'post']).size()\n return count_of_synapses",
"def count_pathologies(graph):\n return Count... | [
"0.69387263",
"0.6183445",
"0.6046419",
"0.6034515",
"0.59751195",
"0.57758623",
"0.57072544",
"0.5633479",
"0.5611335",
"0.56087476",
"0.55993664",
"0.5599142",
"0.55365855",
"0.5526105",
"0.54780513",
"0.547426",
"0.54703754",
"0.5457386",
"0.54382086",
"0.5435362",
"0.5413... | 0.7300097 | 0 |
Makes a dict that accumulates the values for each key in an iterator of doubles | def group_dict_set(iterator):
d = defaultdict(set)
for key, value in iterator:
d[key].add(value)
return dict(d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_densities(densities):\n\n return {spin: sum(np.array(dens[spin]) for dens in densities) \n for spin in densities[0].keys()}",
"def build_histogram(iterator, key):\n buckets = defaultdict(int)\n values = {}\n\n num_objects = 0\n for obj in iterator:\n num_objects += 1\n\n ... | [
"0.6195448",
"0.5842633",
"0.5762505",
"0.5756769",
"0.5659886",
"0.5645777",
"0.5627008",
"0.5534746",
"0.5509884",
"0.55032265",
"0.54376537",
"0.54350764",
"0.54216063",
"0.5409323",
"0.540671",
"0.5402735",
"0.53859186",
"0.53531986",
"0.53487366",
"0.5334113",
"0.5327092... | 0.61645067 | 1 |
Returns a histogram of the different types of relations present in a graph. | def count_unique_relations(graph):
return Counter(itt.chain.from_iterable(get_edge_relations(graph).values())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_relations(graph):\n return Counter(\n data[RELATION]\n for _, _, data in graph.edges_iter(data=True)\n )",
"def relationship_types(self):\n return frozenset(self._relationships_by_type.keys())",
"def get_all_relations(graph, u, v):\n return {\n data[RELATION]\n ... | [
"0.7243773",
"0.5846342",
"0.5788476",
"0.5771844",
"0.5683003",
"0.55974525",
"0.5592673",
"0.55913526",
"0.55775154",
"0.5538538",
"0.55222",
"0.55188054",
"0.53761876",
"0.53658545",
"0.5363041",
"0.5343787",
"0.529524",
"0.52806026",
"0.5279505",
"0.5273678",
"0.5265037",... | 0.6904264 | 1 |
Counts how many times each annotation is used in the graph | def count_annotations(graph):
return Counter(_annotation_iter_helper(graph)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_annotation_values(graph, annotation):\n return Counter(iter_annotation_values(graph, annotation))",
"def get_annotation_count(self):\n return self._num_annos",
"def get_no_of_annotations(database, label, train_vids_all):\n count = 0\n for vid in train_vids_all:\n for ann in dat... | [
"0.8343825",
"0.75170594",
"0.68242604",
"0.6573023",
"0.64739114",
"0.6471781",
"0.6350306",
"0.6324876",
"0.6313155",
"0.62601817",
"0.6247608",
"0.6229666",
"0.6193566",
"0.6186364",
"0.61589694",
"0.6157267",
"0.6121791",
"0.6050442",
"0.6028076",
"0.60266453",
"0.6026645... | 0.8530131 | 0 |
Gets the set of annotations used in the graph | def get_annotations(graph):
return set(_annotation_iter_helper(graph)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def annotations(self):\n return self._annotations",
"def annotations(self):\n\n return self._annotations",
"def annotations(self) -> Mapping[str, str]:\n return pulumi.get(self, \"annotations\")",
"def annotations(self) -> Mapping[str, str]:\n return pulumi.get(self, \"annotations... | [
"0.8111795",
"0.8045864",
"0.7362889",
"0.7362889",
"0.7331711",
"0.70147973",
"0.69533426",
"0.69257975",
"0.69232273",
"0.69228804",
"0.68237376",
"0.6820551",
"0.6820551",
"0.67251045",
"0.6618748",
"0.6587142",
"0.65761614",
"0.652672",
"0.6499983",
"0.6469789",
"0.633797... | 0.8332945 | 0 |
Gets the set of all annotations that are defined in a graph, but are never used. | def get_unused_annotations(graph):
return graph.defined_annotation_keywords - get_annotations(graph) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_annotations(graph):\n return set(_annotation_iter_helper(graph))",
"def get_annotation_values(graph, annotation):\n return set(iter_annotation_values(graph, annotation))",
"def get_unused_list_annotation_values(graph):\n result = {}\n for annotation, values in graph.annotation_list.items():... | [
"0.8046899",
"0.6747276",
"0.6727379",
"0.6385317",
"0.6370691",
"0.6229582",
"0.6198001",
"0.59983647",
"0.5742247",
"0.57196945",
"0.5694495",
"0.5674026",
"0.56460255",
"0.56373686",
"0.56286234",
"0.55884176",
"0.55659765",
"0.55608773",
"0.5503239",
"0.5494925",
"0.54823... | 0.79468316 | 1 |
Gets all of the unused values for list annotations | def get_unused_list_annotation_values(graph):
result = {}
for annotation, values in graph.annotation_list.items():
used_values = get_annotation_values(graph, annotation)
if len(used_values) == len(values): # all values have been used
continue
result[annotation] = set(values)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_unused_annotations(graph):\n return graph.defined_annotation_keywords - get_annotations(graph)",
"def get_annotation_values(graph, annotation):\n return set(iter_annotation_values(graph, annotation))",
"def metric_annotations_allow_list(self) -> Optional[pulumi.Input[str]]:\n return pulumi... | [
"0.68537354",
"0.62805945",
"0.59040225",
"0.589097",
"0.58017445",
"0.575836",
"0.5727465",
"0.57149005",
"0.56691",
"0.56430316",
"0.56349885",
"0.5633079",
"0.55975",
"0.55915046",
"0.55841595",
"0.5538164",
"0.5534096",
"0.5508441",
"0.5505978",
"0.55038834",
"0.54778254"... | 0.7874108 | 0 |
Gets annotation/value pairs for values for whom the search string is a substring | def get_annotations_containing_keyword(graph, keyword):
return [
{
'annotation': annotation,
'value': value
}
for annotation, value in iter_annotation_value_pairs(graph)
if keyword.lower() in value.lower()
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _substring_occurrences(\n cls, in_str: str, substrings: Iterable[str]\n ) -> Dict[str, List[int]]:\n occurrences = {}\n for substring in substrings:\n occurrences[substring] = list(findall(substring, in_str))\n return occurrences",
"def search_in_tree(self, tree, sub... | [
"0.5903146",
"0.5488121",
"0.5460287",
"0.5396356",
"0.53472704",
"0.5338512",
"0.53332084",
"0.5275697",
"0.5245533",
"0.5171115",
"0.51687026",
"0.5167059",
"0.5165257",
"0.51592106",
"0.5158753",
"0.5154511",
"0.5152063",
"0.5150403",
"0.5129545",
"0.51103365",
"0.51068866... | 0.576712 | 1 |
Counts in how many edges each annotation appears in a graph | def count_annotation_values(graph, annotation):
return Counter(iter_annotation_values(graph, annotation)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_annotations(graph):\n return Counter(_annotation_iter_helper(graph))",
"def edgecount(self):\n\n raise NotImplementedError",
"def num_edges(g):\n total_edges_with_duplicates = sum(len(v) for v in g.values())\n return total_edges_with_duplicates // 2",
"def edge_count(self) -> int:\n... | [
"0.8137551",
"0.73022085",
"0.6926789",
"0.69061303",
"0.68878543",
"0.6854445",
"0.67950374",
"0.6794573",
"0.67014533",
"0.6696235",
"0.6683472",
"0.66686267",
"0.6668122",
"0.6655918",
"0.6652132",
"0.6610412",
"0.65590703",
"0.65477306",
"0.6536954",
"0.6498154",
"0.64939... | 0.7824741 | 1 |
Get all values for the given annotation | def get_annotation_values(graph, annotation):
return set(iter_annotation_values(graph, annotation)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_annotations(self):\n entity = self.get_object()\n serializer = AnnotationValueSerializer(entity.annotations.all(), many=True)\n return Response(serializer.data)",
"def handle_enum(enum_annotations: Any) -> list:\n result = []\n for attribute in list(enum_annotations):\n... | [
"0.67769945",
"0.6325543",
"0.6274638",
"0.6220138",
"0.6180968",
"0.6171129",
"0.61034197",
"0.60787046",
"0.60713106",
"0.6068879",
"0.5992964",
"0.59564936",
"0.59216946",
"0.59216946",
"0.59015006",
"0.5887698",
"0.5887698",
"0.5886613",
"0.5818207",
"0.5798842",
"0.57982... | 0.75477934 | 0 |
Counts in how many edges each annotation appears in a graph, but filter out source nodes and target nodes | def count_annotation_values_filtered(graph, annotation, source_filter=None, target_filter=None):
source_filter = keep_node_permissive if source_filter is None else source_filter
target_filter = keep_node_permissive if target_filter is None else target_filter
return Counter(
data[ANNOTATIONS][annota... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_annotations(graph):\n return Counter(_annotation_iter_helper(graph))",
"def compute_num_edges(graph):\n # return the number of edges\n return sum([len(graph[source_node].keys()) for source_node in graph.keys()]) / 2",
"def count_annotation_values(graph, annotation):\n return Count... | [
"0.64924645",
"0.61406404",
"0.60482",
"0.5913293",
"0.5882233",
"0.5866123",
"0.5851271",
"0.58161896",
"0.57976633",
"0.57823884",
"0.57695407",
"0.57527435",
"0.56889486",
"0.5676223",
"0.5665394",
"0.5659691",
"0.5659477",
"0.56017035",
"0.556301",
"0.5519132",
"0.5494026... | 0.7213139 | 0 |
Iterates over unique nodenode pairs in the graph | def _iter_pairs(graph):
for u, v in set(graph.edges_iter()):
yield u, v | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iteredges(self):\n for source, targets in self.successors.items():\n for target in targets:\n yield source, target",
"def iter_nodes(self):",
"def all_pairs(self):\n return chain(self.nx_graph.edges(), nx.non_edges(self.nx_graph))",
"def nodes(self):\n for n... | [
"0.68542266",
"0.6712754",
"0.6575832",
"0.6528945",
"0.64538825",
"0.6438056",
"0.6314288",
"0.62993896",
"0.6280058",
"0.6257878",
"0.62574124",
"0.625634",
"0.6213354",
"0.62093157",
"0.6184859",
"0.61808145",
"0.61796695",
"0.6145432",
"0.60995543",
"0.60977054",
"0.60902... | 0.78772706 | 0 |
Returns if the set of relations contains a contradiction | def relation_set_has_contradictions(relations):
has_increases = any(relation in CAUSAL_INCREASE_RELATIONS for relation in relations)
has_decreases = any(relation in CAUSAL_DECREASE_RELATIONS for relation in relations)
has_cnc = any(relation == CAUSES_NO_CHANGE for relation in relations)
return 1 < sum([... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_relations(self, relations):\n if self.debug:\n print(\"Checking relations\")\n result = False\n work_relations = []\n\n # Eliminate unnecessary(duplicated) clauses\n if relations[\"is_derived_from\"]:\n relations[\"has_derived_form\"] = True\n ... | [
"0.7122376",
"0.67345405",
"0.6449695",
"0.6206758",
"0.6205824",
"0.6188202",
"0.61652434",
"0.61545885",
"0.6087285",
"0.60733366",
"0.6025005",
"0.6013213",
"0.60035706",
"0.5984546",
"0.59587294",
"0.5939061",
"0.5924129",
"0.5839123",
"0.5822666",
"0.5814324",
"0.5813227... | 0.7635147 | 0 |
Checks if a pair of nodes has any contradictions in their causal relationships. | def pair_has_contradiction(graph, u, v):
relations = get_all_relations(graph, u, v)
return relation_set_has_contradictions(relations) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relation_set_has_contradictions(relations):\n has_increases = any(relation in CAUSAL_INCREASE_RELATIONS for relation in relations)\n has_decreases = any(relation in CAUSAL_DECREASE_RELATIONS for relation in relations)\n has_cnc = any(relation == CAUSES_NO_CHANGE for relation in relations)\n return ... | [
"0.68102324",
"0.6214052",
"0.6207057",
"0.60906833",
"0.6065176",
"0.60568976",
"0.6026552",
"0.6008109",
"0.59604144",
"0.59581804",
"0.59490097",
"0.5934767",
"0.5910104",
"0.59072256",
"0.5901164",
"0.5900084",
"0.58665067",
"0.58433616",
"0.5840681",
"0.5824252",
"0.5824... | 0.62543714 | 1 |
Iterates over contradictory node pairs in the graph based on their causal relationships | def get_contradictory_pairs(graph):
for u, v in _iter_pairs(graph):
if pair_has_contradiction(graph, u, v):
yield u, v | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_successors(self, node):\n succs = []\n parent_state = self.node_to_state(node)\n for it in self.children:\n child_node = (node[0] + it[0], node[1] + it[1])\n child_state = self.node_to_state(child_node)\n edge = self.interpolate(parent_state, child_state, self.distance_bw_states(pa... | [
"0.6238017",
"0.5909709",
"0.5907469",
"0.58362544",
"0.57939804",
"0.5792186",
"0.5703263",
"0.5681727",
"0.56771266",
"0.5671722",
"0.56632626",
"0.5611376",
"0.5602615",
"0.559068",
"0.5563447",
"0.5538029",
"0.55253816",
"0.55157125",
"0.5515107",
"0.5483767",
"0.5442139"... | 0.69560146 | 0 |
Returns a counter of all of the mentions of pathologies in a network | def count_pathologies(graph):
return Counter(_pathology_iterator(graph)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_relations(graph):\n return Counter(\n data[RELATION]\n for _, _, data in graph.edges_iter(data=True)\n )",
"def num_links(self):\n count=0.0\n for cluster in self.clusters:\n if self.clusters[cluster] == self.clusters[cluster].antecessor:\n numberofmembers=se... | [
"0.6493108",
"0.6265583",
"0.61763126",
"0.58439344",
"0.58234376",
"0.5724303",
"0.5712313",
"0.56395566",
"0.5600497",
"0.5599743",
"0.5586163",
"0.55701447",
"0.5519347",
"0.55081844",
"0.54878646",
"0.54671645",
"0.54594654",
"0.54498696",
"0.5437356",
"0.543203",
"0.5405... | 0.7180617 | 0 |
builds the url to get the static map. puts a marker on the start and end locations. assumes start and end are in a format / have enough info to give a proper location. does clean white spaces tho | def find_map(start, end, *otherlocs):
small = "200x200"
large = "512x512"
start = start.replace(" ","+")
end = end.replace(" ","+")
small_url = g_api_base_url + static_url + small + map_type_url + small_marker_url + start + map_concat + end
big_url = g_api_base_url + static_url + large + map_type_url + mark... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_url(self):\n if self.has_marker:\n marker_param = f'mlat={self.mlat}&mlng={self.mlng}&'\n else:\n marker_param = ''\n if self.start:\n start_param = 'start=true&'\n else:\n start_param = ''\n url = f'{MapController.MAP_URL}... | [
"0.7412921",
"0.7408514",
"0.6695499",
"0.6539618",
"0.65338993",
"0.64012855",
"0.6347697",
"0.62790763",
"0.625587",
"0.61357576",
"0.60827684",
"0.60016644",
"0.5909071",
"0.5871183",
"0.5864181",
"0.58204234",
"0.57807314",
"0.5719914",
"0.57073295",
"0.5690754",
"0.56851... | 0.74909633 | 0 |
builds urls for the directions and distance matrix apis | def build_url(start, end, transit_mode):
transit = ""
traffic = "best_guess"
depart = "now"
if transit_mode:
transit = transit_mode
direc_url = g_api_base_url + dir_url + "origin=" + start + "&destination=" + end + trans_url \
+ transit + goog_dir_key
dist_url = g_api_base_url + ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_url(_origin_details, travel_start_date, travel_start_time, destination_list):\n prefix = 'https://timetable.search.ch/api/route.json?one_to_many=1'\n\n origin_body = f'&from={_origin_details}&date={travel_start_date}&time={travel_start_time}'\n\n # Build iteratively with necessary syntax betwee... | [
"0.662632",
"0.6459529",
"0.64105844",
"0.63785255",
"0.61424583",
"0.6120072",
"0.61160785",
"0.5975166",
"0.5922255",
"0.5866318",
"0.58486396",
"0.58353645",
"0.5809004",
"0.5791701",
"0.5777878",
"0.57720447",
"0.5690597",
"0.5641834",
"0.56298447",
"0.5613718",
"0.560166... | 0.7186997 | 0 |
Defines the way to parse the magic command ``%%maml``. | def maml_parser():
parser = MagicCommandParser(prog="maml",
description='Runs a maml script.')
parser.add_argument('-q', '--quiet', action='store_true', default=False,
help='hide output')
return parser | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maml(self, line, cell):\n parser = self.get_parser(CsMLMagics.maml_parser, \"maml\")\n args = self.get_args(line, parser)\n\n if args is not None:\n quiet = args.quiet\n out, err = maml(cell, not quiet)\n if out:\n print(out)\n if ... | [
"0.670974",
"0.5512939",
"0.51862484",
"0.5175543",
"0.50888264",
"0.49876153",
"0.49551958",
"0.49524027",
"0.49337393",
"0.4880694",
"0.48664626",
"0.48470613",
"0.4794826",
"0.47836807",
"0.4777479",
"0.47459564",
"0.47455326",
"0.4718852",
"0.46997732",
"0.46576157",
"0.4... | 0.740539 | 0 |
Defines magic command ``%%maml``. | def maml(self, line, cell):
parser = self.get_parser(CsMLMagics.maml_parser, "maml")
args = self.get_args(line, parser)
if args is not None:
quiet = args.quiet
out, err = maml(cell, not quiet)
if out:
print(out)
if err:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maml_parser():\n parser = MagicCommandParser(prog=\"maml\",\n description='Runs a maml script.')\n parser.add_argument('-q', '--quiet', action='store_true', default=False,\n help='hide output')\n return parser",
"def command(s... | [
"0.6546807",
"0.5515294",
"0.52751005",
"0.52579564",
"0.5237155",
"0.51861405",
"0.512959",
"0.5102926",
"0.49472788",
"0.49453253",
"0.49353927",
"0.49225372",
"0.4891675",
"0.48703486",
"0.47610494",
"0.470173",
"0.46908697",
"0.4684091",
"0.46759415",
"0.4654112",
"0.4648... | 0.6613872 | 0 |
Defines the way to parse the magic command ``%%mlnet``. | def mlnet_parser():
parser = MagicCommandParser(prog="mlnet",
description='Compiles and wrap a C# function into a Python function.\n'
'Automatically adds ML.net dependencies.')
parser.add_argument('name', type=str, help=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mlnet(self, line, cell):\n line, cell = CsMagics._preprocess_line_cell_maml( # pylint: disable=W0212\n line, cell)\n\n parser = self.get_parser(CsMagics.CS_parser, \"CS\")\n args = self.get_args(line, parser)\n\n if args is not None:\n name = args.name\n ... | [
"0.57447124",
"0.53171813",
"0.5278795",
"0.52074957",
"0.5104776",
"0.5055335",
"0.50357693",
"0.5034653",
"0.49979833",
"0.49518523",
"0.4937366",
"0.49060217",
"0.49001834",
"0.4745951",
"0.47331885",
"0.4656194",
"0.46342298",
"0.46050298",
"0.46031177",
"0.4588288",
"0.4... | 0.7271368 | 0 |
Defines magic command ``%%mlnet``. | def mlnet(self, line, cell):
line, cell = CsMagics._preprocess_line_cell_maml( # pylint: disable=W0212
line, cell)
parser = self.get_parser(CsMagics.CS_parser, "CS")
args = self.get_args(line, parser)
if args is not None:
name = args.name
dep = CsMa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mlnet_parser():\n parser = MagicCommandParser(prog=\"mlnet\",\n description='Compiles and wrap a C# function into a Python function.\\n'\n 'Automatically adds ML.net dependencies.')\n parser.add_argument('name', typ... | [
"0.6607906",
"0.5527357",
"0.54824287",
"0.5431624",
"0.54184914",
"0.54072374",
"0.53655416",
"0.52886176",
"0.5091649",
"0.49965236",
"0.4974869",
"0.49429768",
"0.49062353",
"0.48281196",
"0.48139057",
"0.4807876",
"0.47813764",
"0.47685274",
"0.47484493",
"0.47436157",
"0... | 0.5684712 | 1 |
Deletes the local configuration for a container. | async def delete_local_configuration_routine(self, name: str):
plat = get_local_platform_routines()
user = LocalUserRoutines(plat)
manager = LocalContainerConfigurationManager(user)
cont = self.GetItemByName(name)
manager.DeleteByID(cont.GetID()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_local_config(self):\n with ignored(OSError):\n os.remove(os.path.join(self.rundir, const.LOCAL_CONFIG_FILE))",
"def delete_container(self, container: Container):",
"def delete_container(self, account, container):\n \n pass",
"def delete_container(ContainerName=None)... | [
"0.68364567",
"0.65952647",
"0.65655595",
"0.63887167",
"0.6293753",
"0.6252849",
"0.6222041",
"0.6218625",
"0.6210771",
"0.61385065",
"0.6115384",
"0.6097698",
"0.60793775",
"0.60496986",
"0.6009285",
"0.6003192",
"0.59821314",
"0.59776366",
"0.5943736",
"0.5928523",
"0.5888... | 0.7014883 | 0 |
Returns a drop table or database SQL statement. | def drop_statement(self, object_type, object_name):
drop_statement = "DROP %s %s" % (object_type, object_name)
return drop_statement | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop(name):\n\t\treturn \"DROP DATABASE {0};\".format(name)",
"def _get_sql_drop_table(table_attr):\n template = 'DROP TABLE IF EXISTS \"%s\" CASCADE;' % (table_attr['name'])\n return template",
"def drop_statement(self, objecttype, objectname):\n statement = Engine.drop_statement(self... | [
"0.7439682",
"0.7192483",
"0.7143962",
"0.7049561",
"0.67682046",
"0.6763672",
"0.6577111",
"0.64398366",
"0.6311948",
"0.63029295",
"0.6295627",
"0.62305164",
"0.62251985",
"0.6221728",
"0.6211469",
"0.6206424",
"0.6188908",
"0.61786735",
"0.6153751",
"0.61287767",
"0.612725... | 0.7213489 | 1 |
This function connects to the device provided when called (dev) in the instantiated testbed (testbed_obj) and executes the provided show command (if none was provided, 'show version' is executed by default. If the Save option = True (s in the command line) was provided then the output will be saved to a JSON file in th... | def device_info(dev, testbed_obj, showcmd='show version', save_to_json=False, logstdout=True):
device = testbed_obj.devices[dev]
device.connect(log_stdout=logstdout)
response = device.parse(showcmd)
print(f"Response from {dev} is of type {type(response)} and length {len(response)}")
print(f"RAW res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def executeShow(self,\n rsrcType,\n showAdditionalParams=[],\n rsrcAdditionalParams=[]):\n\n args = [\"show\",\n \"--wavefrontHost\", util.wavefrontHostName,\n \"--apiToken\", util.wavefrontApiToken] \\\n + sho... | [
"0.6001754",
"0.56841195",
"0.566696",
"0.54662395",
"0.54120153",
"0.5365674",
"0.5250371",
"0.523401",
"0.52098423",
"0.5194957",
"0.51602536",
"0.51479226",
"0.5107748",
"0.5103756",
"0.50766176",
"0.5072563",
"0.50322425",
"0.5027172",
"0.50200206",
"0.5005128",
"0.500112... | 0.72180516 | 0 |
Account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error. | def expected_bucket_owner(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "expected_bucket_owner") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected_bucket_owner(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"expected_bucket_owner\")",
"def owner_account_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"owner_account_id\")",
"def owner_account_id(self) -> Optional[pulumi.Input[str]]:\n return ... | [
"0.7146499",
"0.6446139",
"0.6384591",
"0.6065642",
"0.5860553",
"0.5854814",
"0.58411705",
"0.581899",
"0.57273",
"0.57180434",
"0.5700793",
"0.5700793",
"0.5690769",
"0.5674292",
"0.5650694",
"0.56504285",
"0.5646915",
"0.5642213",
"0.5625961",
"0.5623262",
"0.56102705",
... | 0.70394754 | 1 |
Get an existing BucketLifecycleConfigurationV2 resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None,
bucket: Optional[pulumi.Input[str]] = None,
expected_bucket_owner: Optional[pulumi.Input[str]] = None,
rules: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.I... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(resource_name: str,\n id: pulumi.Input[str],\n opts: Optional[pulumi.ResourceOptions] = None,\n minimal_action: Optional[pulumi.Input[str]] = None,\n most_disruptive_allowed_action: Optional[pulumi.Input[str]] = None,\n name: Optional[pulumi.Input[str]... | [
"0.58018064",
"0.5353829",
"0.5117951",
"0.51060236",
"0.50312877",
"0.49301392",
"0.48632613",
"0.4778881",
"0.47655228",
"0.47473097",
"0.4707761",
"0.4704642",
"0.46908763",
"0.46863323",
"0.4678712",
"0.46439952",
"0.46264488",
"0.46231508",
"0.46105427",
"0.455522",
"0.4... | 0.7716009 | 0 |
Account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error. | def expected_bucket_owner(self) -> pulumi.Output[Optional[str]]:
return pulumi.get(self, "expected_bucket_owner") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected_bucket_owner(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"expected_bucket_owner\")",
"def expected_bucket_owner(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"expected_bucket_owner\")",
"def owner_account_id(self) -> pulumi.Output[str]:\n ... | [
"0.7040738",
"0.7040738",
"0.6445131",
"0.63837475",
"0.6061159",
"0.5858455",
"0.5852843",
"0.583966",
"0.5817529",
"0.5723972",
"0.5716804",
"0.5698139",
"0.5698139",
"0.5686788",
"0.5675481",
"0.5651604",
"0.565157",
"0.564837",
"0.5641776",
"0.562609",
"0.5620628",
"0.5... | 0.7147683 | 0 |
Get original model if the input model is a model wrapper. | def get_ori_model(model: nn.Module) -> nn.Module:
if is_model_wrapper(model):
return model.module
else:
return model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_non_wrapped_model(model: nn.Module) -> nn.Module:\n from torch.nn import DataParallel\n from torch.nn.parallel import DistributedDataParallel\n\n if not isinstance(model, nn.Module):\n raise RuntimeError(\"Input model must be a subclass of nn.Module.\")\n\n if isinstance(model, (DataPara... | [
"0.6501197",
"0.6491106",
"0.6491106",
"0.6491106",
"0.6491106",
"0.6491106",
"0.6491106",
"0.6491106",
"0.6491106",
"0.6491106",
"0.6491106",
"0.64641833",
"0.64641833",
"0.6462358",
"0.64084584",
"0.63638914",
"0.6319201",
"0.6311763",
"0.6279905",
"0.6277195",
"0.6266046",... | 0.7013369 | 0 |
Load annotation from annotations.json file | def _load_annotations(self):
annotation_file = self._filepath(self.ANNOTATION_FILE)
with open(annotation_file) as f:
json_data = json.load(f)
return json_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_annotation(json_path):\n # Open the file containing the annotation\n with open(json_path) as annotation_file:\n\n # Parse the AI2D annotation from the JSON file into a dictionary\n annotation = json.load(annotation_file)\n\n # Return the annotation\n retu... | [
"0.7888858",
"0.7325585",
"0.7084303",
"0.6923192",
"0.687097",
"0.68155825",
"0.66877896",
"0.6673177",
"0.65827876",
"0.6560132",
"0.6559868",
"0.6558796",
"0.65527225",
"0.64227253",
"0.63591856",
"0.6338805",
"0.6284784",
"0.6264161",
"0.62268883",
"0.62000585",
"0.618474... | 0.8038193 | 0 |
Load the data indices txt file. | def _load_split_indices(self):
split_file = self.SPLITS.get(self.split)
indices_file = self._filepath(split_file)
with open(indices_file) as txt_file:
idx_data = [int(i) for i in txt_file.readline().split()]
return idx_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_index_data(data_path):\n index_keywords = []\n with open(data_path) as data:\n for line in data:\n index_keywords.append(line.rstrip())\n return index_keywords",
"def load_info():\n data = np.loadtxt(\"u_sol_meta.txt\", dtype=int)\n return data",
"def load_labels_index... | [
"0.67228645",
"0.64503235",
"0.6270136",
"0.62359387",
"0.62125915",
"0.6206149",
"0.61973083",
"0.6185728",
"0.61774135",
"0.61695915",
"0.61617666",
"0.61599284",
"0.61492556",
"0.61449534",
"0.61161757",
"0.6100025",
"0.60692877",
"0.602712",
"0.6014525",
"0.60091174",
"0.... | 0.68765545 | 0 |
Convert the bbox record to BBox2D objects. | def _convert_to_bbox2d(single_bbox):
label = single_bbox["label_id"]
bbox = single_bbox["bbox"]
canonical_bbox = BBox2D(
x=bbox[0], y=bbox[1], w=bbox[2], h=bbox[3], label=label
)
return canonical_bbox | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bbox2fields():\n bbox2label = {\n 'gt_bboxes': 'gt_labels',\n 'gt_bboxes_ignore': 'gt_labels_ignore'\n }\n bbox2mask = {\n 'gt_bboxes': 'gt_masks',\n 'gt_bboxes_ignore': 'gt_masks_ignore'\n }\n bbox2seg = {\n 'gt_bboxes': 'gt_semantic_seg',\n }\n return b... | [
"0.6832664",
"0.6783777",
"0.6691991",
"0.63218105",
"0.6319875",
"0.6284736",
"0.6246083",
"0.6223461",
"0.61668444",
"0.6120401",
"0.6079261",
"0.6019865",
"0.6007134",
"0.59077746",
"0.5902924",
"0.5898657",
"0.58965296",
"0.5879593",
"0.5847342",
"0.58367205",
"0.58200914... | 0.75232357 | 0 |
Download dataset from GCS | def download(self):
cloud_path = f"gs://{const.GCS_BUCKET}/{self.GCS_PATH}"
# download label file
label_zip = download_file_from_gcs(
cloud_path, self.root, self.LABEL_ZIP
)
with zipfile.ZipFile(label_zip, "r") as zip_dir:
zip_dir.extractall(self.root)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_dataset(self):\n raise NotImplementedError",
"def download_dataset(url=DATASET_URL):\n # disable insecure https warning\n urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)\n\n c = urllib3.PoolManager()\n with c.request(\"GET\", url, preload_content=False) as res,... | [
"0.7185856",
"0.68503934",
"0.6714282",
"0.67088765",
"0.66851914",
"0.6538648",
"0.6525635",
"0.6497461",
"0.64432293",
"0.6433408",
"0.6422011",
"0.639159",
"0.63663715",
"0.6344865",
"0.6338407",
"0.62408376",
"0.6234367",
"0.62312293",
"0.6227992",
"0.6183774",
"0.6181906... | 0.75893414 | 0 |
Finds number of documents in the Tweet collection matching a given search_term (and location, if provided). | def count_tweets(search_term, location=None):
if location:
return len(Tweet.objects(Q(keyword_search_term=search_term) & Q(location_address=location)))
else:
return len(Tweet.objects(keyword_search_term=search_term)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _count(self):\n if self._count_valid:\n return self._total_results\n\n url = self._build_url(\"/_search\")\n request = self._build_request(0, -1)\n resp = self._cb.post_object(url, body=request)\n result = resp.json()\n\n self._total_results = result[\"num_f... | [
"0.67774284",
"0.67774284",
"0.64773935",
"0.6338761",
"0.63320786",
"0.6253776",
"0.61553955",
"0.6143456",
"0.6119857",
"0.605183",
"0.60442805",
"0.6041794",
"0.6023299",
"0.60119075",
"0.59792614",
"0.59583217",
"0.5956584",
"0.59333336",
"0.59300566",
"0.5897961",
"0.585... | 0.81229687 | 0 |
Calculates a keyword's historical sentiment (restricted within a location, if provided). | def get_historical_sentiment(search_term, location=None):
if location:
positive = len(Tweet.objects(Q(keyword_search_term=search_term) & Q(location_address=location) & Q(sentiment_type="positive")))
negative = len(Tweet.objects(Q(keyword_search_term=search_term) & Q(location_address=location) &... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_historical_sentiment_avg(search_term, location=None):\r\n\r\n total = 0\r\n\r\n if location:\r\n tweets = Tweet.objects(Q(keyword_search_term=search_term) & Q(location_address=location))\r\n count = len(tweets)\r\n else:\r\n tweets = Tweet.objects(Q(keyword_search_term=search_... | [
"0.67188215",
"0.67036396",
"0.6334149",
"0.6167096",
"0.59021384",
"0.5850361",
"0.5808837",
"0.57456166",
"0.55691725",
"0.55315197",
"0.55021304",
"0.5500344",
"0.5474109",
"0.54653317",
"0.5465105",
"0.5422208",
"0.5408632",
"0.5408632",
"0.54046506",
"0.5381399",
"0.5356... | 0.704126 | 0 |
Calculates the average sentiment score for a given keyword (restricted within a location, if provided). | def get_historical_sentiment_avg(search_term, location=None):
total = 0
if location:
tweets = Tweet.objects(Q(keyword_search_term=search_term) & Q(location_address=location))
count = len(tweets)
else:
tweets = Tweet.objects(Q(keyword_search_term=search_term))
count... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sentiment_overtime(keyword, location=None):\r\n\r\n # Get date 10 days ago\r\n ten_days_ago = datetime.now() - timedelta(days=10)\r\n\r\n # Get raw PyMongo collection\r\n collection = Tweet._get_collection()\r\n\r\n if location:\r\n match = {\r\n \"$match\":\r\n ... | [
"0.70859677",
"0.63445497",
"0.615348",
"0.6074",
"0.607026",
"0.6054127",
"0.60071707",
"0.59709895",
"0.58449465",
"0.58252454",
"0.5823854",
"0.58144957",
"0.57648957",
"0.57458204",
"0.5664769",
"0.5651309",
"0.56352067",
"0.56242144",
"0.56193566",
"0.5584524",
"0.558051... | 0.74165547 | 0 |
Calculates the average sentiment score in a given query set of Tweets. | def get_query_sentiment_avg(tweets):
total = 0
count = len(tweets)
for tweet in tweets:
total += tweet.sentiment_score
# Calculate average
avg = total / count
avg = float("{0:.2f}".format((float(avg))))
return avg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_query_statistics(tweets, sentiment_aggregate_list):\r\n\r\n total = len(tweets)\r\n positive_percentage = float(\"{0:.2f}\".format((float(sentiment_aggregate_list[0][1]/total*100))))\r\n neutral_percentage = float(\"{0:.2f}\".format((float(sentiment_aggregate_list[1][1]/total*100))))\r\n negati... | [
"0.67024827",
"0.66712636",
"0.66350305",
"0.66138715",
"0.65283984",
"0.6518941",
"0.6491312",
"0.6487166",
"0.64857775",
"0.6405299",
"0.62509996",
"0.6194273",
"0.6162189",
"0.6128368",
"0.61244524",
"0.6088544",
"0.6022574",
"0.6017512",
"0.60000277",
"0.59923315",
"0.597... | 0.854272 | 0 |
Generates basic statistics for a given query set of Tweets. | def get_query_statistics(tweets, sentiment_aggregate_list):
total = len(tweets)
positive_percentage = float("{0:.2f}".format((float(sentiment_aggregate_list[0][1]/total*100))))
neutral_percentage = float("{0:.2f}".format((float(sentiment_aggregate_list[1][1]/total*100))))
negative_percentage = flo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def statistics(all_new_tweets, all_retweets, all_quote_tweets):\n length_all_quote_tweets = len(all_quote_tweets)\n length_all_retweets = len(all_retweets)\n length_all_tweets = len(all_new_tweets)\n\n # print(db_twitter.collections.stats())\n total_tweets = length_all_quote_tweets + length_all_retw... | [
"0.69248664",
"0.620815",
"0.59848654",
"0.59815437",
"0.5954515",
"0.5952684",
"0.5883914",
"0.5861081",
"0.57721597",
"0.57669294",
"0.5752889",
"0.5752543",
"0.564709",
"0.564132",
"0.5640209",
"0.5572535",
"0.55670476",
"0.55010945",
"0.5492158",
"0.5483679",
"0.54743016"... | 0.7054746 | 0 |
Aggregates sentiment types for a given tweet collection. | def aggregate_sentiment(tweets):
positive = 0
negative = 0
neutral = 0
for tweet in tweets:
if tweet.sentiment_type == "positive":
positive += 1
elif tweet.sentiment_type == "negative":
negative += 1
else:
neutral += 1
resu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect(self, collect_types: List[str]) -> None:\n valid_types = [x for x in collect_types if x in self._valid_types.keys()]\n for ctype in valid_types:\n self._collect_tweets(ctype)",
"def do_sentiment_analysis(self):\n\n tweets_sentiment = []\n\n for tweet in self.twe... | [
"0.59929293",
"0.59618926",
"0.58570933",
"0.5779308",
"0.57485133",
"0.573751",
"0.56903654",
"0.56657684",
"0.55670786",
"0.5521338",
"0.54893357",
"0.542505",
"0.53890103",
"0.53886825",
"0.53880984",
"0.533604",
"0.52402407",
"0.52377105",
"0.5190812",
"0.51520646",
"0.51... | 0.72262305 | 0 |
Gets the predominant sentiment type from a list of sentiments. (Eg [[positive, 3],[neutral, 10],[negative,15]]) | def predominant_sentiment(sentiment_aggregate_list):
positive = int(sentiment_aggregate_list[0][1])
neutral = int(sentiment_aggregate_list[1][1])
negative = int(sentiment_aggregate_list[2][1])
if positive > neutral and positive > negative:
return "positive"
elif neutral > positive ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify_sentiment(sent_index):\n\n\tif sent_index < -0.5:\n\t\treturn 'negative'\n\tif sent_index <= 0.5 and sent_index >= -0.5:\n\t\treturn 'neutral'\n\tif sent_index >= 0.5:\n\t\treturn 'positive'",
"def classify(tweets, positives, negatives):\n sentiment_list = makelist(tweets, positives, negatives)\n... | [
"0.6732237",
"0.63710135",
"0.6355821",
"0.6258131",
"0.61799365",
"0.611913",
"0.6108495",
"0.60978174",
"0.6085284",
"0.5958469",
"0.59254676",
"0.5863128",
"0.5860238",
"0.5843611",
"0.5822473",
"0.58167547",
"0.5785102",
"0.5766148",
"0.5755716",
"0.5731452",
"0.5707599",... | 0.7360832 | 0 |
Gets sentiment statistics for average sentiment for a given keyword (and location, if specified) over the past 10 days. | def get_sentiment_overtime(keyword, location=None):
# Get date 10 days ago
ten_days_ago = datetime.now() - timedelta(days=10)
# Get raw PyMongo collection
collection = Tweet._get_collection()
if location:
match = {
"$match":
{
"k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_historical_sentiment_avg(search_term, location=None):\r\n\r\n total = 0\r\n\r\n if location:\r\n tweets = Tweet.objects(Q(keyword_search_term=search_term) & Q(location_address=location))\r\n count = len(tweets)\r\n else:\r\n tweets = Tweet.objects(Q(keyword_search_term=search_... | [
"0.7494988",
"0.6593404",
"0.64326733",
"0.62750417",
"0.5912352",
"0.54747236",
"0.5449991",
"0.5329276",
"0.5303148",
"0.52833545",
"0.52704436",
"0.50593525",
"0.5013312",
"0.49506775",
"0.49489254",
"0.4912962",
"0.4879828",
"0.48639044",
"0.4842615",
"0.48359329",
"0.481... | 0.8139415 | 0 |
Gets the top 10 most positive / negative sentiment triggers from the past 7 days. | def get_sentiment_trends(order):
# Get date seven days ago
seven_days_ago = datetime.now() - timedelta(days=7)
# Get raw PyMongo collection
collection = Tweet._get_collection()
# Perform aggregate query
result = collection.aggregate([
{
"$match":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_extreme_tweets(self, sentiment, count=1, num_score=False):\n def return_polarity(tweet):\n return tweet['polarity']\n\n print(\"The top {} most {} tweets:\".format(count, sentiment))\n\n if sentiment == 'positive':\n sorted_tweet = sorted(self.positive_tweets, k... | [
"0.5406669",
"0.54055756",
"0.5391852",
"0.536155",
"0.5360676",
"0.5214797",
"0.5178173",
"0.51120335",
"0.50702655",
"0.5060932",
"0.5052575",
"0.501701",
"0.5007129",
"0.50032103",
"0.49881318",
"0.49561754",
"0.49547327",
"0.49525204",
"0.4947948",
"0.49175078",
"0.490440... | 0.54947144 | 0 |
Load the feed url into self.entries using the feedparser module. | def __init__(self, url=URL):
self.entries = feedparser.parse(url).entries | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_feed(self):\n parsed_feed = feedparser.parse(self.rss_url)\n # Check for malformed feed\n if parsed_feed['bozo']:\n raise Exception('malformed rss feed!')\n self.parsed_feed = parsed_feed",
"def feed(self):\n feed_dict = feedparser.parse(self.URL)\n ... | [
"0.7183806",
"0.68700135",
"0.66769147",
"0.6660742",
"0.6519246",
"0.6506825",
"0.6443622",
"0.6431346",
"0.64295334",
"0.6419183",
"0.6348568",
"0.6227926",
"0.61853313",
"0.6180963",
"0.610789",
"0.6107114",
"0.607002",
"0.6055648",
"0.60153824",
"0.5997344",
"0.5982748",
... | 0.8170361 | 0 |
Return a list of episode IDs (itunes_episode attribute) of the episodes the pass in domain was mentioned in. | def get_episode_numbers_for_mentioned_domain(self, domain: str) -> list:
return [ep.itunes_episode
for ep in self.entries
if domain.lower() in ep.summary.lower()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def episodes(self):\n episodes = []\n for series in self.series:\n episodes.extend(series.episodes)\n return episodes",
"def episodes(self):\n episodes = []\n for season in self.seasons:\n episodes.extend(season.episodes)\n return episodes",
"def ... | [
"0.68623555",
"0.6790614",
"0.64584225",
"0.62703633",
"0.6171073",
"0.616064",
"0.5982251",
"0.58765996",
"0.5858648",
"0.5848835",
"0.57939684",
"0.5776999",
"0.57678777",
"0.57606727",
"0.57389754",
"0.56692666",
"0.5666441",
"0.56479317",
"0.5601704",
"0.55696493",
"0.552... | 0.8150568 | 0 |
Return the number of episodes that had one of more special guests featured (use SPECIAL_GUEST). | def number_episodes_with_special_guest(self) -> int:
return len([ep for ep in self.entries if SPECIAL_GUEST in ep.summary]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_episodes(self) -> int:\n return len(self.episodes)",
"def n_episodes(self):\n raise NotImplementedError",
"def get_tv_episodes(self) -> int:\n return len(glob.glob(os.path.join(\n os.path.dirname(self.file),\n f\"*{os.path.splitext(self.file)[-1]}\"\n ... | [
"0.649917",
"0.62428266",
"0.5887413",
"0.5634373",
"0.552352",
"0.54988056",
"0.54770404",
"0.53177136",
"0.5314232",
"0.52770793",
"0.52533907",
"0.5198246",
"0.5186868",
"0.5182951",
"0.51779616",
"0.5158745",
"0.5125548",
"0.51043326",
"0.5093988",
"0.50591505",
"0.505139... | 0.8896974 | 0 |
Return the average duration in seconds of a Python Bytes episode, as | def get_average_duration_episode_in_seconds(self) -> NamedTuple:
times = [ep.itunes_duration for ep in self.entries]
format_times = []
for time in times:
if not time.startswith('00'):
time = '0' + time
format_times.append(time)
dts = [datetime.st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_wav_duration(wav_bytes: bytes) -> float:\n with io.BytesIO(wav_bytes) as wav_buffer:\n wav_file: wave.Wave_read = wave.open(wav_buffer, \"rb\")\n with wav_file:\n frames = wav_file.getnframes()\n rate = wav_file.getframerate()\n return frames / float(rate)"... | [
"0.67595243",
"0.65047795",
"0.64271915",
"0.64189667",
"0.6367844",
"0.6341444",
"0.6284898",
"0.6283205",
"0.6277745",
"0.62206906",
"0.62178415",
"0.6192925",
"0.6191467",
"0.6185916",
"0.61730164",
"0.6169899",
"0.61567783",
"0.6137445",
"0.6130938",
"0.6128692",
"0.61263... | 0.71605974 | 0 |
Build an index from word to set of document indexes This does the exact same thing as create_index() except that it uses your htable. As a number of htable buckets, use 4011. Returns a listofbuckets hashtable representation. | def myhtable_create_index(files):
res_buckets = htable(4011)
for id, file in enumerate(files):
if file[-4:] == '.txt':
word_list = words(get_text(file))
for word in word_list:
value = htable_get(res_buckets, word)
if value == None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createIndex(pages): \n index = defaultdict(list)\n for url, content, links in pages:\n counts = getNumberTerms(content)\n for term, count in counts.items():\n index[term].append((url, count))\n return index",
"def perform_indexing(self, words_list):\n\n indexer_tab... | [
"0.66589546",
"0.6544771",
"0.64670044",
"0.64168614",
"0.63033056",
"0.6180472",
"0.6178157",
"0.6154601",
"0.61489826",
"0.6104722",
"0.60848147",
"0.6009543",
"0.60010827",
"0.5981455",
"0.5976573",
"0.5911548",
"0.59066755",
"0.590064",
"0.5855223",
"0.58235234",
"0.58033... | 0.7427538 | 0 |
This does the exact same thing as index_search() except that it uses your htable. I.e., use htable_get(index, w) not index[w]. | def myhtable_index_search(files, index, terms):
res_file = []
count = 0
if len(terms) == 0:
print('empty terms')
return
for term in terms:
term = term.lower()
count += 1
if count == 1:
s = htable_get(index, term)
if s == None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup(index,keyword):\n\tif keyword in index:\n\t\treturn index[keyword]\n\treturn None",
"def __getitem__(self,idx):\n try:\n return self._cache[idx]\n except:\n pass\n\n try:\n # return full data entry as list\n out = self._data[idx]\n ... | [
"0.6155713",
"0.59609514",
"0.59491926",
"0.59410375",
"0.5900303",
"0.5845122",
"0.5789598",
"0.577333",
"0.57275766",
"0.5688099",
"0.5681756",
"0.56468856",
"0.5621905",
"0.5621905",
"0.5621905",
"0.5621905",
"0.5621905",
"0.5621905",
"0.5621905",
"0.5621905",
"0.5621905",... | 0.6331249 | 0 |
Tests if builsing an dirichlet ensemble is running without problems | def test_dirichletensemble():
np.random.seed(seed=2)
X, y = make_blobs(n_samples=200, centers=2, n_features=2, cluster_std=4,
random_state=2)
n_train = 100
trainX, testX = X[:n_train, :], X[n_train:, :]
trainy, testy = y[:n_train], y[n_train:]
n_members = 5
stack = Dir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_machine_learning():",
"def test_valid_ensemble(ensemble: bool) -> None:\n mapie = MapieRegressor(ensemble=ensemble)\n mapie.fit(X_toy, y_toy)",
"def test_training(self):\n\t\tpass",
"def run_experiment() -> List[bool]:\n return [random.random() < 0.5 for _ in range(1000)]",
"def main():\n... | [
"0.65376455",
"0.65050536",
"0.6211623",
"0.6093889",
"0.60780334",
"0.6073346",
"0.6068026",
"0.60495067",
"0.60197634",
"0.60121745",
"0.59868246",
"0.5984857",
"0.5951661",
"0.594414",
"0.5943446",
"0.5942952",
"0.5937696",
"0.59257823",
"0.5918587",
"0.59163463",
"0.59018... | 0.670472 | 0 |
Map s_new to t_new based on known mapping of s (source) to t (target), with s original/intrinsic coordinates and t intrinsic/original coordinates | def mapping(s, t, s_new, k,c):
n, s_dim = s.shape
t_dim = t.shape[1]
n_new = s_new.shape[0]
# 1. determine nearest neighbors
dist = np.sum((s[np.newaxis] - s_new[:,np.newaxis])**2,-1)
nn_ids = np.argsort(dist)[:,:k] # change to [:,:k]
nns = np.row_stack([s[nn_ids[:,ki]] for ki in range(k)])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_model(self, original, t1, t2, resolution_scaling_factor=1):\n img = Image()\n img.time_stamp = t2\n\n if t1 == t2:\n img.initialize_with_image(original)\n return img\n\n calc_shift_fnc = self.calculate_shift\n orig_get_fnc = original.get\n i... | [
"0.55668783",
"0.5532111",
"0.5460896",
"0.5447538",
"0.53842735",
"0.5356351",
"0.53368974",
"0.53297365",
"0.53066075",
"0.5294714",
"0.52837485",
"0.5263581",
"0.52585614",
"0.52573544",
"0.52403593",
"0.5213048",
"0.51814204",
"0.5172513",
"0.51586723",
"0.51488996",
"0.5... | 0.66779846 | 0 |
Read source and creates a new brace token | def create_token(self):
token = Token(PAREN.get(self.current_char), "brace")
self.current_char = self.source.read(1)
return token | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_till_closing_brace(stream):\n rv = \"\"\n in_braces = 1\n while True:\n if EscapeCharToken.starts_here(stream, '{}'):\n rv += stream.next() + stream.next()\n else:\n c = stream.next()\n if c == '{': in_braces += 1\n elif c == '}': in_bra... | [
"0.59238863",
"0.58185357",
"0.5810777",
"0.5810427",
"0.5761932",
"0.5747912",
"0.542546",
"0.5393044",
"0.5324538",
"0.530029",
"0.5290811",
"0.5258126",
"0.5244535",
"0.52285373",
"0.5211549",
"0.517982",
"0.51321423",
"0.51276994",
"0.51232326",
"0.51212436",
"0.5091131",... | 0.71761155 | 0 |
Receives a char and returning if its a left or right brace | def should_lex(cls, char):
return char == '{' or char == '}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bracketed (phrase,bracketing='()'):\r\n\r\n level = 0\r\n left_point = None\r\n right_point = None\r\n \r\n\r\n for count,char in enumerate(phrase):\r\n\r\n if char == bracketing[0]:\r\n if level ==... | [
"0.6396085",
"0.6267263",
"0.6178741",
"0.61347187",
"0.6007452",
"0.6006558",
"0.59606045",
"0.5951733",
"0.59003645",
"0.58945894",
"0.58871955",
"0.58813554",
"0.58139944",
"0.58129483",
"0.58129483",
"0.5799351",
"0.57966834",
"0.5772036",
"0.57385767",
"0.57300985",
"0.5... | 0.72300553 | 0 |
Crop graph image Crops the desired image by it's type. | def crop_image(self):
image_data = Image.open(self.img_path)
return image_data.crop(self.data_type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop_image(self, img):\n img.crop_image(self._center, 1.1 * self._radius)",
"def crop(image, dimX, dimY):\n # TODO\n return image",
"def crop(self, *args, **kwargs):\n return _image.image_crop(self, *args, **kwargs)",
"def __call__(self, img):\n image_width, image_height = img.... | [
"0.66398174",
"0.6505323",
"0.6446542",
"0.63750404",
"0.63750404",
"0.63555723",
"0.6341775",
"0.633309",
"0.62684494",
"0.626365",
"0.623445",
"0.6195632",
"0.61726093",
"0.61628",
"0.6140623",
"0.6068601",
"0.60564905",
"0.6035729",
"0.60079396",
"0.6002261",
"0.5993988",
... | 0.6803471 | 0 |
Transform Image into array Transform cropped image into an numpy multidimensional array. | def np_image_matrix(self):
return np.array(self.crop_image()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_to_array(self, img):\n x = np.asarray(img, dtype=self.dtype)\n if len(x.shape) == 3:\n if self.channels_first:\n x = x.transpose(2, 0, 1)\n elif len(x.shape) == 2:\n if self.channels_first:\n x = x.reshape((1, x.shape[0], x.shape[1]... | [
"0.722699",
"0.6876687",
"0.68659633",
"0.68560636",
"0.6853701",
"0.65742826",
"0.64895433",
"0.64520043",
"0.64459306",
"0.63613623",
"0.6347112",
"0.6313576",
"0.6297982",
"0.6266448",
"0.6222398",
"0.6181755",
"0.6175415",
"0.6161334",
"0.6153839",
"0.6122482",
"0.6093073... | 0.6892566 | 1 |
Find Blue pixels Finds all blue pixels inside the graph area, which represents the desired points of the graph. The method generates a numpy 2d array with these pixels relative positions. | def blue_matrix(self):
return np.vstack(np.where(self.np_image_matrix() == 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_blue(x, y, slot = 0):\r\n return __g[slot].pixels_rgb[__g[slot].width * 3 * y + x * 3 + 2]",
"def get_blue(self, x, y):\n self.__check_dimensions(x, y)\n return self.pixels[(x, y)].get_blue()",
"def blue_channel(img):\n\n blue = np.zeros(img.shape,dtype=float)\n\n blue[:,:,0] = n... | [
"0.6495526",
"0.64614147",
"0.62514365",
"0.60262513",
"0.5827481",
"0.57433754",
"0.5736232",
"0.5696482",
"0.56894076",
"0.5617795",
"0.5553846",
"0.55003446",
"0.54996854",
"0.54855716",
"0.5472395",
"0.54648805",
"0.5462373",
"0.5456809",
"0.5430799",
"0.5417668",
"0.5415... | 0.6844396 | 0 |
clean repeated j pixels Find the first item of each row and gets the pixels with the lowest j value, which represents the biggest real value of the y axis of the graph, crossed with x axis. | def clean_double_values(self):
trans_blue = self.blue_matrix().transpose()
b_array = []
for i in trans_blue:
min_col = [i[0], i[1]]
for j in trans_blue[0:]:
if j[1] == min_col[1]:
if j[0] < min_col[0]:
min_col[0]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_smaller_neighbour(plots, i, j):\n n = len(plots)\n neighbours = []\n if i > 0:\n neighbours.append((i-1, j))\n if i < n-1:\n neighbours.append((i+1, j))\n if j > 0:\n neighbours.append((i, j-1))\n if j < n-1:\n neighbours.append((i, j+1))\n\n min_elevation =... | [
"0.56734896",
"0.56369495",
"0.56135774",
"0.5611539",
"0.5562747",
"0.5554404",
"0.55534256",
"0.55487216",
"0.55104053",
"0.5484114",
"0.5463305",
"0.5457158",
"0.54555976",
"0.5414113",
"0.5403876",
"0.5402138",
"0.5381725",
"0.53808093",
"0.53107697",
"0.53102785",
"0.530... | 0.57108814 | 0 |
Saves csv file into image folder saves generated data by class into a csv file with the name, plus the type of data. This method keeps track if the file was generate, and replace it with a new one | def save_values(self):
f_name = self.img_path.split('.')[0] + '_{}_'.\
format(self.data_type_name) + '.csv'
dir_name = os.path.join(self.base_dir, f_name)
if not os.path.exists(dir_name):
for data_list in self.converted_values():
with open(f_name, 'a') as ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_csv(self):\n if not self.__is_csv():\n # creates the csv file if it did not exist.\n self.__create_csv()\n try:\n with open(self.__csv_file_name, 'a', newline='', encoding='utf-8') as csv_file:\n writer = csv.DictWriter(csv_file, fieldnames=sel... | [
"0.6624201",
"0.6549683",
"0.6435749",
"0.64239025",
"0.6376977",
"0.62230694",
"0.61884254",
"0.6154384",
"0.6124744",
"0.6118921",
"0.6071223",
"0.60594875",
"0.59954077",
"0.5983704",
"0.5972146",
"0.5940008",
"0.59392995",
"0.59351414",
"0.5909594",
"0.5909318",
"0.590845... | 0.7220325 | 0 |
Run an acrosssubject classification Decode responses on each hand separately from CPRO data Limit to ROIs within SMN network | def conditionDecodings(data, rois, ncvs=100, effects=False, motorOutput=False,confusion=False, decoder='similarity', nproc=5):
ncond = data.shape[1] # two motor outputs
nSubjs = data.shape[2]
nsamples = nSubjs * ncond
stats = np.zeros((len(rois),nsamples))
rmatches = np.zeros((len(rois),))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute(self, requests):\n responses = []\n for request in requests:\n infer_outputs = pb_utils.get_input_tensor_by_name(\n request, self.input_names[0])\n im_infos = pb_utils.get_input_tensor_by_name(request,\n ... | [
"0.56707114",
"0.56553566",
"0.5601765",
"0.55017805",
"0.5460834",
"0.5439918",
"0.54097337",
"0.537334",
"0.53697425",
"0.5360478",
"0.53484106",
"0.5340918",
"0.52992934",
"0.5270834",
"0.5248631",
"0.52458835",
"0.5234071",
"0.5232353",
"0.52291584",
"0.52209944",
"0.5219... | 0.6313217 | 0 |
Returns a dictionary containing all diagnostic light curves. The dictionary will provide a light curve for each matrix in the design matrix collection. | def _create_diagnostic_lightcurves(self):
if self.coefficients is None:
raise ValueError("you need to call `correct()` first")
lcs = {}
for idx, submatrix in enumerate(self.dmc.matrices):
# What is the index of the first column for the submatrix?
firstcol_idx... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_materials_dict(self):\n c = 299792458.0\n w_mat = 2 * np.pi * c / self.l_mat - self.w0\n l2_mat = (self.l_mat * 1e6) ** 2\n\n n_air = 1 + 0.05792105 * l2_mat / (238.0185 * l2_mat - 1) + 0.00167917 * l2_mat / (57.362 * l2_mat - 1)\n air_ip = interp1d(w_mat, n_air, bou... | [
"0.60194796",
"0.59146357",
"0.5619035",
"0.55798995",
"0.55360436",
"0.54979974",
"0.54268354",
"0.5380969",
"0.53533584",
"0.53345037",
"0.5332291",
"0.52693045",
"0.52423155",
"0.5225769",
"0.52155113",
"0.5174672",
"0.51708114",
"0.51582485",
"0.51488817",
"0.51368886",
"... | 0.75933963 | 0 |
Produce diagnostic plots to assess the effectiveness of the correction. | def _diagnostic_plot(self):
if not hasattr(self, "corrected_lc"):
raise ValueError(
"Please call the `correct()` method before trying to diagnose."
)
with plt.style.context(MPLSTYLE):
_, axs = plt.subplots(2, figsize=(10, 6), sharex=True)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Diagnostic_plot2(self):\n\n probs = pd.read_csv(self.probfile)\n\n fig, ax = generalPlot(xaxis=r'$\\nu / \\mu$Hz', yaxis=r'$P_{\\rm det}$')\n plt.scatter(probs['f0'], probs['Pdet_Kepler'], label='Kepler - 4yrs')\n plt.scatter(probs['f0'], probs['Pdet_TESS365'], label='TESS - 1 yr')\... | [
"0.6873683",
"0.6821231",
"0.6672336",
"0.66437536",
"0.66437536",
"0.66437536",
"0.6629172",
"0.6596364",
"0.6589779",
"0.6557499",
"0.6521361",
"0.6518009",
"0.65085554",
"0.64940095",
"0.64903545",
"0.64805514",
"0.6445851",
"0.6403377",
"0.6347727",
"0.63423556",
"0.63348... | 0.7091261 | 0 |
takes a discrete point in time, and puts the position, velocity, and acceleration into a ROS JointTrajectoryPoint() to be put into a RobotTrajectory. | def trajectory_point(self, t, jointspace):
point = JointTrajectoryPoint()
delta_t = .01
if jointspace:
x_t, x_t_1, x_t_2 = None, None, None
ik_attempts = 0
theta_t_2 = self.get_ik(self.target_position(t-2*delta_t))
theta_t_1 = self.get_ik(self.targ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trajectory_point(self, t, jointspace):\n point = JointTrajectoryPoint()\n delta_t = .01\n if jointspace:\n x_t, x_t_1, x_t_2 = None, None, None\n ik_attempts = 0\n theta_t = theta_t_1 = theta_t_2 = None\n while theta_t_2 is None:\n ... | [
"0.7366635",
"0.6119101",
"0.6077254",
"0.59451604",
"0.5930126",
"0.5914397",
"0.5907721",
"0.58628654",
"0.58250636",
"0.58205104",
"0.57535905",
"0.5750186",
"0.5665363",
"0.566258",
"0.56621027",
"0.5604078",
"0.560013",
"0.5575069",
"0.5521112",
"0.55184346",
"0.5504239"... | 0.7287572 | 1 |
Remember to call the constructor of MotionPath | def __init__(self, total_time, kin, limb, ar_tag_pos):
# raise NotImplementedError
self.r = .1
MotionPath.__init__(self, limb, kin, total_time)
self.ar_tag_pos = np.array([ar_tag_pos[0],ar_tag_pos[1],ar_tag_pos[2]])
self.ar_tag_pos[2] = 0.282
self.start_pos = [ar_tag_po... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, limb, kin, total_time, goal_pos, num_way, start_pos=None):\n MotionPath.__init__(self, limb, kin, total_time)\n self.start_pos = start_pos\n self.goal_pos = goal_pos\n self.num_way = num_way\n self.base_frame = 'base'\n self.tool_frame = 'left_hand_camer... | [
"0.7820282",
"0.7787644",
"0.77386826",
"0.6963891",
"0.6757834",
"0.65536493",
"0.65116596",
"0.64888525",
"0.6445253",
"0.63971484",
"0.6376502",
"0.636337",
"0.63444155",
"0.6312085",
"0.6276762",
"0.6248574",
"0.62414914",
"0.6194726",
"0.6188483",
"0.6171967",
"0.6170589... | 0.78976136 | 0 |
Returns the arm's desired velocity in workspace coordinates at time t. You should NOT simply take a finite difference of self.target_position() | def target_velocity(self, time):
x_v = self.w*self.r*cos(self.w*time)
y_v = -self.w*self.r*sin(self.w*time)
z_v = 0
# raise NotImplementedError
return np.array([x_v,y_v,z_v]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target_velocity(self, time):\n return self.target(time, self.velocities, self.dt, self.num_way)",
"def target_velocity(self, time):\n return self.target(time, self.velocities, self.dt, self.num_way)",
"def target_velocity(self, time):\n path, path_time = self.get_current_path(time)\n ... | [
"0.7068331",
"0.7068331",
"0.70444334",
"0.7034289",
"0.6955907",
"0.68580544",
"0.6856776",
"0.6856776",
"0.67172503",
"0.6685114",
"0.66773754",
"0.6674364",
"0.66353154",
"0.66283923",
"0.6606402",
"0.65924555",
"0.65924555",
"0.6582541",
"0.6543292",
"0.6520295",
"0.65179... | 0.72390187 | 0 |
Returns the arm's desired x,y,z acceleration in workspace coordinates at time t. You should NOT simply take a finite difference of self.target_velocity() | def target_acceleration(self, time):
x_a = -self.w**2*self.r*sin(self.w*time)
y_a = -self.w**2*self.r*cos(self.w*time)
z_a = 0
# raise NotImplementedError
return np.array([x_a,y_a,z_a]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target_velocity(self, time):\n\n x_v = self.w*self.r*cos(self.w*time)\n y_v = -self.w*self.r*sin(self.w*time)\n z_v = 0\n # raise NotImplementedError\n return np.array([x_v,y_v,z_v])",
"def acceleration(v,u,t):\n return ((v-u)/t)",
"def acceleration(self):\n ux,... | [
"0.6654176",
"0.65230024",
"0.64852095",
"0.64031357",
"0.64031357",
"0.63639945",
"0.6288034",
"0.62409705",
"0.61979336",
"0.6173782",
"0.61587775",
"0.6153133",
"0.6142052",
"0.6091978",
"0.6033012",
"0.60062426",
"0.599504",
"0.5980418",
"0.58893937",
"0.58403546",
"0.580... | 0.70134026 | 0 |
Reduce this Dataset's data by applying ``count`` along some dimension(s). | def count(
self,
dim: Dims = None,
*,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Dataset:
return self.reduce(
duck_array_ops.count,
dim=dim,
numeric_only=False,
keep_attrs=keep_attrs,
**kwargs,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(\n self,\n dim: Dims = None,\n *,\n keep_attrs: bool | None = None,\n **kwargs: Any,\n ) -> DataArray:\n return self.reduce(\n duck_array_ops.count,\n dim=dim,\n keep_attrs=keep_attrs,\n **kwargs,\n )",
"def... | [
"0.730545",
"0.69733924",
"0.69733924",
"0.69529074",
"0.69529074",
"0.6121086",
"0.60577554",
"0.5984994",
"0.5982864",
"0.59388554",
"0.5934392",
"0.5903536",
"0.5890546",
"0.5856696",
"0.5820845",
"0.5794014",
"0.5787277",
"0.5708209",
"0.56682146",
"0.5646369",
"0.5555573... | 0.7285971 | 1 |
Reduce this Dataset's data by applying ``prod`` along some dimension(s). | def prod(
self,
dim: Dims = None,
*,
skipna: bool | None = None,
min_count: int | None = None,
keep_attrs: bool | None = None,
**kwargs: Any,
) -> Dataset:
return self.reduce(
duck_array_ops.prod,
dim=dim,
skipna=ski... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prod(self, axis=None, keepdims=False, dtype=None, out=None):\n return np.multiply.reduce(\n self, out=out, axis=axis, keepdims=keepdims, dtype=dtype\n )",
"def prod(\n self,\n dim: Dims = None,\n *,\n skipna: bool | None = None,\n min_count: int | N... | [
"0.7481061",
"0.735098",
"0.714532",
"0.714532",
"0.700226",
"0.700226",
"0.6688766",
"0.65455145",
"0.65137213",
"0.64294696",
"0.6274849",
"0.6176995",
"0.6066634",
"0.59346235",
"0.5929033",
"0.591033",
"0.591033",
"0.591033",
"0.58753616",
"0.5752229",
"0.5747925",
"0.5... | 0.74074686 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.