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 |
|---|---|---|---|---|---|---|
Initialize connected_data structure as a dict where each entry is a unique spot and the array rows are data for single frames | def initialize_connected_data(frame_data):
connected_data = {}
for i in range(0, len(frame_data)):
this_spot_data = add_time_nuc(frame_data[i], 0, nucmask)
connected_data[i+1] = np.array([this_spot_data])
return connected_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\r\n self.vertices = col.defaultdict()\r\n self.edges = col.defaultdict(list)",
"def init_table_config_data():\n config_data = {}\n config_data[\"channels\"] = []\n config_data[\"channels_data\"] = {}\n\n return config_data",
"def __init__(self):\n self.data ... | [
"0.5957714",
"0.58687586",
"0.5761916",
"0.56957203",
"0.5670861",
"0.5563269",
"0.5556724",
"0.5397462",
"0.5396216",
"0.53949225",
"0.5343534",
"0.53224397",
"0.53137547",
"0.53076583",
"0.52965915",
"0.52581286",
"0.5185916",
"0.5158004",
"0.51508576",
"0.5140593",
"0.5140... | 0.8117453 | 0 |
Filter connected_data structure for spots lasting a minimum number of frames | def filter_spot_duration(connected_data, min_len):
filtered_data = {}
spot_num = 1
for spot in connected_data:
if (connected_data[spot].shape[0] >= min_len):
filtered_data[spot_num] = connected_data[spot]
spot_num = spot_num + 1
return filtered_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_out_flickers(total_buffer,index_disappeared):\n \n wait_for_disparition = False\n candidate_for_disparition = -1\n to_destroy = [] #List of 3D tuples (value,first_index,last_index) of segmented elements to remove from image\n beginning_index = -1\n premier_i =-1\n list_of_is =[]\n... | [
"0.59837097",
"0.5621668",
"0.56181633",
"0.558799",
"0.5575316",
"0.554562",
"0.5518238",
"0.54400265",
"0.5396022",
"0.5315956",
"0.5298975",
"0.5295641",
"0.5261164",
"0.52356255",
"0.5228062",
"0.5208109",
"0.51851964",
"0.51764244",
"0.5170829",
"0.51634383",
"0.51505387... | 0.6942065 | 0 |
Find mean volume within ellipsoid centered on spots, add to spot_info | def add_volume_mean(spot_data, stack, channel, ij_rad, z_rad, ij_scale=1, z_scale=1):
def ellipsoid_mean(coords, stack, meshgrid, ij_rad=7, z_rad=2):
"""Define ellipsoid around point, return mean of pixel values in ellipsoid."""
# Equation: (x-x0)^2 + (y-y0)^2 + a(z-z0)^2 = r^2
r = ij_rad # ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_spot_center(source_position, light_dir):\n x_spot = source_position[0] + light_dir[0]*source_position[2]/light_dir[2]\n y_spot = source_position[1] + light_dir[1]*source_position[2]/light_dir[2]\n return x_spot, y_spot, 0",
"def calcul_v_sphere(r):\n volume = 4/3 * math.pi * (r ** 3)\n ... | [
"0.57376206",
"0.56841135",
"0.5681834",
"0.56491834",
"0.56102866",
"0.5607667",
"0.5597014",
"0.5596447",
"0.55897605",
"0.5544626",
"0.5533888",
"0.54724944",
"0.5458146",
"0.5439677",
"0.5429221",
"0.54011726",
"0.538757",
"0.53550726",
"0.5353824",
"0.5319338",
"0.531594... | 0.6574097 | 0 |
Define ellipsoid around point, return mean of pixel values in ellipsoid. | def ellipsoid_mean(coords, stack, meshgrid, ij_rad=7, z_rad=2):
# Equation: (x-x0)^2 + (y-y0)^2 + a(z-z0)^2 = r^2
r = ij_rad # r is just more intuitive for me to think about...
a = (r ** 2) / (z_rad ** 2)
z0, i0, j0 = coords
valsgrid = np.sqrt((a * ((meshgrid[0] - z0) ** 2)) + ((... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCenter(self):\n return Point.average(self.points)",
"def get_center(self):\n\n x = np.array(self.x)\n y = np.array(self.y)\n return np.mean(x), np.mean(y)",
"def sphere_l_intensity(img):\n pixels = []\n for j in range(0, img.shape[0]):\n for i in range(1, 40):\n ... | [
"0.62000215",
"0.61073965",
"0.6088595",
"0.59915364",
"0.594273",
"0.5941821",
"0.5941821",
"0.5941821",
"0.5921312",
"0.5896093",
"0.5884862",
"0.586036",
"0.5813924",
"0.5809003",
"0.57892305",
"0.57597697",
"0.57385886",
"0.5735135",
"0.5727635",
"0.5710512",
"0.57038134"... | 0.66231763 | 0 |
Determine mean pixel intensity within a window given parameters of a 3D gaussian function. | def integrate_gaussian(p, wlength_xy, wlength_z):
if ((wlength_xy % 2 == 0) or (wlength_z % 2 == 0)):
raise ValueError('wlength_xy and wlength_z must be odd.')
# Get fit parameters, find coords for center pixel within window.
h, width_z, width_x, width_y = p[5:9]
center_x... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parzen_windowing_gaussian(self, img: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:\n img = torch.clamp(img, 0, 1)\n img = img.reshape(img.shape[0], -1, 1) # (batch, num_sample, 1)\n weight = torch.exp(\n -self.preterm.to(img) * (img - self.bin_centers.to(img)) ** 2\n ... | [
"0.6528081",
"0.6435075",
"0.64093316",
"0.63854927",
"0.63794",
"0.6296535",
"0.62501276",
"0.6223606",
"0.6196191",
"0.61551243",
"0.6140659",
"0.60772455",
"0.60772455",
"0.60772455",
"0.6068441",
"0.60680634",
"0.6010968",
"0.5965149",
"0.5937091",
"0.59290445",
"0.590832... | 0.69954216 | 0 |
Align MS2 traces around selected frames For use in triggered averaging. Takes a dataframe of trace data and a list of spot IDs and frame numbers, makes a panda dataframe of the trace data centered on the indicated frames. | def align_traces(df, locs, window_size=11, include_nan=True):
# Check that window size is appropriate.
max_frame = df.shape[0] - 1
if (window_size % 2 == 0):
raise ValueError("window_size must be odd.")
if ((window_size - 1) >= max_frame):
raise ValueError("window_size larger than number... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _align_frames(frame_pre, frame_now):\n height, width = frame_pre.shape\n horizontal_lines = [np.array([frame_pre[int(height * 1 / 4), :],\n frame_pre[int(height * 2 / 4), :],\n frame_pre[int(height * 3 / 4), :]]),\n\n ... | [
"0.61075115",
"0.5640128",
"0.55968153",
"0.5509019",
"0.54873496",
"0.5447483",
"0.52463675",
"0.52463675",
"0.5174047",
"0.51377374",
"0.5094064",
"0.4921837",
"0.4879902",
"0.48730737",
"0.48683405",
"0.4865354",
"0.48523277",
"0.4839225",
"0.48349258",
"0.47905862",
"0.47... | 0.6673797 | 0 |
Creates a new goal subsystem instance populated with the given option values. | def create_goal_subsystem(
goal_subsystem_type: Type[GS],
default_rank: Rank = Rank.NONE,
**options: Union[RankedValue, Value],
) -> GS:
return goal_subsystem_type(
scope=goal_subsystem_type.name,
scoped_options=_create_scoped_options(default_rank, **options),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_subsystem(\n subsystem_type: Type[SS], default_rank: Rank = Rank.NONE, **options: Union[RankedValue, Value],\n) -> SS:\n options_scope = cast(str, subsystem_type.options_scope)\n return subsystem_type(\n scope=options_scope, scoped_options=_create_scoped_options(default_rank, **options),... | [
"0.55818886",
"0.5381703",
"0.52698374",
"0.52208364",
"0.5148747",
"0.5116267",
"0.51108176",
"0.5106414",
"0.5034482",
"0.5019953",
"0.49740025",
"0.49732503",
"0.49720192",
"0.4969659",
"0.49613714",
"0.49557412",
"0.49364755",
"0.49241704",
"0.49193808",
"0.49071124",
"0.... | 0.6367006 | 0 |
Creates a new subsystem instance populated with the given option values. | def create_subsystem(
subsystem_type: Type[SS], default_rank: Rank = Rank.NONE, **options: Union[RankedValue, Value],
) -> SS:
options_scope = cast(str, subsystem_type.options_scope)
return subsystem_type(
scope=options_scope, scoped_options=_create_scoped_options(default_rank, **options),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, values = None):\n TCInit(self)\n if values is not None:\n self.set_opts(values)",
"def __init__(self, name, dest=None, handler=None,\n title=None, description=None, help=None):\n super(SubCommandOpt, self).__init__(name, type=types.String(),\n ... | [
"0.5848675",
"0.5507858",
"0.55030745",
"0.54839",
"0.54118633",
"0.52644926",
"0.52617824",
"0.51959896",
"0.51930183",
"0.51889545",
"0.5183067",
"0.5179553",
"0.51574206",
"0.5127893",
"0.51209146",
"0.5115612",
"0.51052487",
"0.5104861",
"0.5099387",
"0.5097268",
"0.50900... | 0.64099705 | 0 |
A test helper function that runs an with a set of arguments and mocked Get providers. An named `my_rule` that takes one argument and makes no `Get` requests can be invoked | def run_rule(
rule,
*,
rule_args: Optional[Sequence[Any]] = None,
mock_gets: Optional[Sequence[MockGet]] = None,
union_membership: Optional[UnionMembership] = None,
):
task_rule = getattr(rule, "rule", None)
if task_rule is None:
raise TypeError(f"Expected to receive a decorated `@r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mocked_requests_scrapping_get(*args, **kwargs):\n class MockResponse:\n def __init__(self, json_data, status_code, url):\n self.content = json_data\n self.status_code = status_code\n self.url = url\n self.cookies = {\"JSESSIONID\": \"jkghhjgjhgfjgfgjg\"}\n ... | [
"0.5798914",
"0.576577",
"0.5735906",
"0.56634337",
"0.5587107",
"0.558139",
"0.55682707",
"0.55385035",
"0.55326957",
"0.5389785",
"0.5387248",
"0.5339527",
"0.5299506",
"0.52461684",
"0.51888806",
"0.51670414",
"0.51616627",
"0.51275337",
"0.51183414",
"0.509416",
"0.509337... | 0.7068275 | 0 |
Return the `Native` instance. | def init_native():
return Native() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def native(self):\n return self._native",
"def __type__(self) -> type[Native]:",
"def instance():\n global inst\n try:\n inst\n except:\n inst = BNVMAPI(None)\n return inst",
"def native_value(self):\n return self._handle(\"native_value\")",
"def GetInstance():\n ... | [
"0.71409714",
"0.66721815",
"0.61232656",
"0.5874383",
"0.57764703",
"0.5750495",
"0.5669337",
"0.55879575",
"0.55298465",
"0.55298465",
"0.55298465",
"0.54999673",
"0.5497058",
"0.548195",
"0.54701054",
"0.5459018",
"0.5456261",
"0.5417354",
"0.5417354",
"0.54168373",
"0.541... | 0.7600673 | 0 |
Asserts equality, but also prints the values so they can be compared on failure. | def assert_equal_with_printing(
test_case, expected, actual, uniform_formatter: Optional[Callable[[str], str]] = None
):
str_actual = str(actual)
print("Expected:")
print(expected)
print("Actual:")
print(str_actual)
if uniform_formatter is not None:
expected = uniform_formatter(expe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_verbose(actual, expected):\n assert expected == actual, f\"Expected value: {expected}. But actual value is {actual}\"",
"def assert_equal(self, first, second, msg=\"\"):\r\n assert first == second",
"def assert_equal(left, right):\n msg = \"{} != {}\".format(left, right)\n as... | [
"0.73443013",
"0.68112373",
"0.6732889",
"0.666247",
"0.6656091",
"0.66555184",
"0.6596307",
"0.6498644",
"0.632748",
"0.632748",
"0.62926406",
"0.62742466",
"0.6272744",
"0.6265735",
"0.6239884",
"0.62394404",
"0.6238718",
"0.62241197",
"0.61979616",
"0.6184484",
"0.61723286... | 0.7269182 | 1 |
Generate the str for a Rust Function, which is how Rust refers to ``s. This is useful when comparing strings against engine error messages. See | def fmt_rust_function(func: Callable) -> str:
return f"{func.__module__}:{func.__code__.co_firstlineno}:{func.__name__}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _function_name(func):\n return \"Calling the function: def {}()\".format(func.__name__)",
"def funcstring(funcname):\n s = str(funcname)[10:] #chop off '<function '\n spi = s.index(' ')\n return s[:spi]",
"def function_name_to_string(func):\n if func == statistical_parity_difference:\n ... | [
"0.70569986",
"0.69767207",
"0.69445163",
"0.67333925",
"0.66838056",
"0.6539256",
"0.65197897",
"0.6367706",
"0.63396204",
"0.63294756",
"0.63208455",
"0.6299699",
"0.62855864",
"0.62656",
"0.626383",
"0.6244654",
"0.6192976",
"0.61919385",
"0.61675394",
"0.61492616",
"0.614... | 0.70528305 | 1 |
Probabilities for candidates as replacement for [MASK] in text | def mask_probability(text, candidates, model=BERT, tokenizer=BERT_TOKENIZER):
# Check exactly one mask
masks = sum(np.array(text.split()) == "[MASK]")
if masks != 1:
raise ValueError(
f"Must be exactly one [MASK] in text, {masks} supplied.")
# Get candidate ids
candidate_ids = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mask_probability(text, candidates, model=MODEL, tokenizer=TOKENIZER):\n\n # Check exactly one mask\n masks = sum(np.array(text.split()) == \"[MASK]\")\n if masks != 1:\n raise ValueError(\n f\"Must be exactly one [MASK] in text, {masks} supplied.\")\n\n # Get candidate ids\n ca... | [
"0.71494377",
"0.6225705",
"0.5906032",
"0.5866225",
"0.56947714",
"0.56804025",
"0.5588412",
"0.5573056",
"0.55691713",
"0.5545812",
"0.55397207",
"0.55358493",
"0.55334765",
"0.55199087",
"0.54943836",
"0.54714644",
"0.544585",
"0.54377234",
"0.5433093",
"0.5428688",
"0.542... | 0.7209935 | 0 |
Run BERT on stims. Requires that filename point to a .csv file with a "passage" column, as well as columns for the two words (c1 vs. c2) to be comparing (e.g., start vs. end). | def main(filename, c1, c2):
# Assemble data path
data_path = "data/stims/{FILE}.csv".format(FILE=filename)
# Read in stims
df_passages = pd.read_csv(data_path)
print(len(df_passages))
# For each passage, get log-odds of c1 vs. c2
odds = []
with tqdm(total=df_passages.shape[0]) as ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_bert(filepath):\n print('Loading BERT tokenizer...')\n tokenizer = BertTokenizer.from_pretrained('bert-base-uncased', do_lower_case=True)\n\n print('Loading BERT model...')\n model = BertForSequenceClassification.from_pretrained(filepath)\n\n return model, tokenizer",
"def prepare(inputFi... | [
"0.55813915",
"0.5385646",
"0.5304523",
"0.5275729",
"0.52425414",
"0.5240455",
"0.5208001",
"0.5115082",
"0.50646037",
"0.5060587",
"0.5049103",
"0.5045206",
"0.5010893",
"0.49771702",
"0.49600977",
"0.49559188",
"0.4935264",
"0.49223185",
"0.49160156",
"0.4903173",
"0.48910... | 0.6915262 | 0 |
Concatenate endpoint and final URL. | def concat_url(endpoint, url):
u = "%s/%s" % (endpoint.rstrip("/"), url.strip("/"))
return u.rstrip('/') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _construct_url(self, endpoint):\n return self.base_url + self.api_path + endpoint.strip('/')",
"def build_url(self, endpoint_url: str) -> str:\n return self.base_url + endpoint_url % self.instance_id",
"def _join_url(saas_url, endpoint):\n\n saas_url = f\"{saas_url}/\"\n endpoint = endp... | [
"0.74742275",
"0.7269796",
"0.7175692",
"0.71596",
"0.70213",
"0.69491",
"0.6947381",
"0.6928694",
"0.68832123",
"0.68601626",
"0.6854039",
"0.68420404",
"0.68103427",
"0.67940575",
"0.67940575",
"0.6767998",
"0.6761178",
"0.6674753",
"0.664846",
"0.6641822",
"0.6630077",
"... | 0.81906676 | 0 |
Verify the bugs in the advisories (specified as arguments or in group.yml) for a release. Requires a runtime to ensure that all bugs in the advisories match the runtime version. Also ensures that bugs in the next release which block bugs in these advisories have been verified, as those represent backports we do not wan... | def verify_attached_bugs_cli(runtime, verify_bug_status, advisories):
runtime.initialize()
advisories = advisories or [a for a in runtime.group_config.get('advisories', {}).values()]
if not advisories:
red_print("No advisories specified on command line or in group.yml")
exit(1)
BugValida... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n parser = build_parser()\n args = parser.parse_args()\n\n retval = 0\n try:\n comp = COMPONENTS.get(args.name)\n if comp is None:\n raise MismatchError(\"component name\", \"one of \" + \", \".join(COMPONENTS), args.name)\n\n path = comp['path']\n v... | [
"0.5746845",
"0.5681756",
"0.5652249",
"0.56482136",
"0.5644087",
"0.5618303",
"0.55337614",
"0.5359465",
"0.5237646",
"0.52005523",
"0.51683897",
"0.5160205",
"0.5100718",
"0.5082163",
"0.5078693",
"0.50598735",
"0.50384104",
"0.5026104",
"0.5023134",
"0.49999282",
"0.499218... | 0.69671184 | 0 |
Launch python shell for tmux server, session, window and pane. | def command_shell(
session_name,
window_name,
socket_name,
socket_path,
command,
shell,
use_pythonrc,
use_vi_mode,
):
server = Server(socket_name=socket_name, socket_path=socket_path)
util.raise_if_tmux_not_running(server=server)
current_pane = util.get_current_pane(server=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_session(self):\r\n print('Executing code by running main.run()...')\r\n print('This will open a tmux session...')\r\n print('Detach by pressing CTRL + B and then D')\r\n\r\n # Connect with SSH-PubKey and execute tmux script\r\n subprocess.run(\r\n ['ssh',\r\n... | [
"0.7651912",
"0.6505521",
"0.64358765",
"0.640437",
"0.6341422",
"0.63181067",
"0.63064367",
"0.62475246",
"0.6223957",
"0.6108948",
"0.60860807",
"0.60729367",
"0.5971356",
"0.5894631",
"0.58818585",
"0.58679765",
"0.584855",
"0.5846169",
"0.584471",
"0.5832893",
"0.5782695"... | 0.7390258 | 1 |
Gather policy information from files | def gather_file_data(config):
file_regex = re.compile(config['file_regex'])
category_regex = re.compile(config['category_regex'])
policies = {}
for root, dirs, files in os.walk(config['c7n_policy_directory']):
for file in files:
if file_regex.match(file):
file_path =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_policies():\r\n policy = policies.values()\r\n return policy",
"def GetPolicies(self):\n policy = {}\n if json is None:\n logging.error('No JSON module, cannot parse policy information')\n else :\n try:\n policy = json.loads(open(self.policy_path).read(), strict=False)\n ... | [
"0.5911625",
"0.58434314",
"0.5719689",
"0.5711324",
"0.56559443",
"0.5594694",
"0.5590045",
"0.55445015",
"0.5497",
"0.540195",
"0.5361356",
"0.531168",
"0.5259834",
"0.52506393",
"0.5246839",
"0.52431786",
"0.52330023",
"0.5227213",
"0.52085274",
"0.52017194",
"0.5199296",
... | 0.6739473 | 0 |
Upload html file to S3 | def upload_to_s3(file_path, config):
logging.info("Uploading file to S3 bucket: %s", config['s3_bucket_name'])
s3 = boto3.resource('s3')
s3_filename = config['s3_bucket_path'] + config['rendered_filename']
s3.Bucket(config['s3_bucket_name']).upload_file(
file_path, s3_filename, ExtraArgs={
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload(file_path, aws_path, access_key, secret_key) -> None:\n # bucket = \"dev-com-courtlistener-storage\"\n bucket = \"seals.free.law\"\n client = boto3.client(\n \"s3\",\n aws_access_key_id=access_key,\n aws_secret_access_key=secret_key,\n )\n transfer = S3Transfer(client... | [
"0.7370429",
"0.71789026",
"0.71683186",
"0.7130215",
"0.7094345",
"0.6954891",
"0.68663615",
"0.6810772",
"0.67266816",
"0.6709432",
"0.66733426",
"0.66633886",
"0.66433626",
"0.6633306",
"0.662561",
"0.66119",
"0.6607787",
"0.6580904",
"0.6547099",
"0.652348",
"0.649921",
... | 0.7603138 | 0 |
Compresses older log files into zip file in the same directory. Each directory in the 'logs' directory will be searched for concurrent operating bot support. This method will also delete the old file after archiving. | def archive_logs():
logging.info('Archive start...')
for log_dir in filter(dir_filter, os.listdir('logs')):
path = 'logs/{}'.format(log_dir)
archive_files = filter(lambda x: '.log.' in x, os.listdir(path))
zip_file_name = '{}/{}.zip'.format(
path,
str(datetime.no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def archive_logs(self):\n source = GAConfig[\"log_file_location\"]\n destination = source + \"Archive/\"\n\n if not os.path.exists(source):\n os.makedirs(source)\n if not os.path.exists(destination):\n os.makedirs(destination)\n\n if len(os.listdir(source)) ... | [
"0.75869405",
"0.73306024",
"0.70867497",
"0.68509316",
"0.65570736",
"0.63422644",
"0.6314659",
"0.62978524",
"0.6128477",
"0.60726273",
"0.59432596",
"0.59397364",
"0.58427334",
"0.5823305",
"0.5816636",
"0.57883394",
"0.57785434",
"0.5767404",
"0.5766813",
"0.5763056",
"0.... | 0.79080427 | 0 |
Checks if x is a directory in the 'logs' folder. | def dir_filter(x):
return os.path.isdir('logs/{}'.format(x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_valid_log_dir(log_dir):\n return os.path.isdir(log_dir)",
"def _is_valid_log_dir(log_dir):\n return os.path.isdir(log_dir)",
"def check_path_to_directory(path_to_directory, logger):\n logger.info('Checking the entered path...')\n if os.path.isdir(path_to_directory) is False:\n ... | [
"0.72610724",
"0.72610724",
"0.68007565",
"0.6678344",
"0.65690076",
"0.6473464",
"0.6461999",
"0.6409931",
"0.63623744",
"0.63514376",
"0.6313805",
"0.6309263",
"0.6285337",
"0.62704253",
"0.623613",
"0.6235447",
"0.6208083",
"0.6169552",
"0.61472356",
"0.612465",
"0.6107563... | 0.7915596 | 0 |
Account Created on site is a developer and not a benny | def test_valid_account_create_is_a_developer(self):
ident_choice = UserIdentificationLabel.objects.get(slug="ident1")
form_data = {
'invitation_code': '1234',
'email': 'hank@example.com',
'organization_name': 'transhealth',
'password1': 'BEDrocks@123',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createDeveloper(self):\n self.createUser()\n self.user.is_developer = True\n self.user.put()",
"def is_developer(self):\n return int(self.developer_status) == 2",
"def Build(self,admin):\n \n rv=admin.helper.setAccount(admin.userName,self.currency)\n if rv is None:\n ... | [
"0.60778517",
"0.60674125",
"0.5987252",
"0.5764413",
"0.57497853",
"0.56911457",
"0.5633141",
"0.5611581",
"0.55762774",
"0.5564832",
"0.550934",
"0.5508127",
"0.54820985",
"0.54460865",
"0.5383621",
"0.5382464",
"0.5373304",
"0.53547925",
"0.53533167",
"0.534285",
"0.534226... | 0.659661 | 0 |
Print command to set environment variable, format it correctly for the current platform | def print_set_env_command(name, value):
shell_type = get_shell_type()
if shell_type == Shell.LINUX:
print(f'export {name!s}="{value!s}";')
elif shell_type == Shell.POWER_SHELL:
print(f'$Env:{name!s}="{value!s}";')
else:
print(f"set {name!s}={value!s}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bs_set(self, cmd, arg):\n\t\tif arg:\n\t\t\tfor x in self.split(arg):\n\t\t\t\tif '=' in x:\n\t\t\t\t\tk, v = x.split('=', 1)\n\t\t\t\t\tos.environ[k] = v\n\t\t\t\t\tself.write(\"%s=%s%s\" %(k, v, os.linesep))\n\t\t\t\telif x:\n\t\t\t\t\tself.write(\"%s=%s%s\" %(x, os.environ.get(x, ''), os.linesep))\n\t\telse... | [
"0.61943436",
"0.6016676",
"0.59716016",
"0.5888873",
"0.58723927",
"0.57673454",
"0.56758165",
"0.5655233",
"0.56447625",
"0.5631568",
"0.5627466",
"0.5620255",
"0.56134826",
"0.5536909",
"0.5494274",
"0.54542065",
"0.54527664",
"0.5445931",
"0.543696",
"0.5414417",
"0.53778... | 0.79186285 | 0 |
Print comment command, format it correctly for the current platform | def print_comment(comment):
shell_type = get_shell_type()
if shell_type == Shell.LINUX:
print(f"# {comment!s}")
elif shell_type == Shell.POWER_SHELL:
print(f"# {comment!s}")
else:
print(f"rem {comment!s}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sys_comment(comment, is_error=False):\n COMMENT_STR = \"[*]\"\n if is_error:\n COMMENT_STR = \"[X]\"\n\n print_centered(\"{} {} {}\".format(COMMENT_STR, comment, COMMENT_STR), use_logo=True)\n\n return None",
"def print_comment(text, print_it=verbose):\n prefix = \"OpenCortex >>> \"\n ... | [
"0.73059446",
"0.72229236",
"0.7211783",
"0.72104037",
"0.71124434",
"0.7011514",
"0.66027707",
"0.6540971",
"0.65155685",
"0.6487512",
"0.64764297",
"0.6399721",
"0.6383359",
"0.6343426",
"0.6339768",
"0.6290715",
"0.6249993",
"0.6232092",
"0.6214947",
"0.6173628",
"0.615036... | 0.7978329 | 0 |
Method started when "instance.start()" is called The thread will call "source.target()" at a rate determined by "sample rate" in the caller. | def run(self):
while self.source.SAMPLING:
wx.CallAfter(self.target, self)
sleep(0.75)
self.Terminate() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, samples_number):\n self.sampler.sample(samples_number)",
"def sample_delay(self, *args, **kwargs):\n return _uhd_swig.usrp_source_sptr_sample_delay(self, *args, **kwargs)",
"def run(self, speed_method='average_gap', spike_buffer_count=10):\n\n self.running = True\n ... | [
"0.60447764",
"0.5992645",
"0.5931171",
"0.589222",
"0.5822173",
"0.57965285",
"0.574656",
"0.5734245",
"0.56804925",
"0.564533",
"0.56355685",
"0.56355685",
"0.55986935",
"0.5584269",
"0.55711305",
"0.55538505",
"0.55396765",
"0.5539208",
"0.55151296",
"0.549222",
"0.5471006... | 0.626401 | 0 |
Tests that my choice form requires a choice | def test_choice_form_required(self):
form = VoteForm({})
self.assertFalse(form.is_valid())
self.assertIn('choice', form.errors)
self.assertIn('required', "\n".join(form.errors.get('choice'))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_radioselect_field():",
"def test_check_category_input_3(self):\n choices = [(1, 'choice 1'), (2, 'choice 2')]\n assert validation.check_category_input(2, choices) == True",
"def test_validate_choices_ok(self, choices, value):\n opt = scheme.Option('test-option', choices=choices)\n... | [
"0.74089956",
"0.700157",
"0.698661",
"0.69695634",
"0.69366515",
"0.6825106",
"0.6778479",
"0.674924",
"0.67447466",
"0.6719312",
"0.67129177",
"0.67129177",
"0.6709743",
"0.6696809",
"0.65672",
"0.65545034",
"0.6540261",
"0.65389454",
"0.6504448",
"0.6486532",
"0.6482869",
... | 0.78063613 | 0 |
This is the requested result, when the user hits the index a list of individuals living in or currently within 50 miles of london will be generated. | def index():
return get_in_radius(50) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_locations(self):",
"def test_index_start(self):\n sp_file = os.path.join(\"tests\", \"data\", \"geolife\", \"geolife_staypoints.csv\")\n sp = ti.read_staypoints_csv(sp_file, tz=\"utc\", index_col=\"id\", crs=\"epsg:4326\")\n\n # reproject to WGS_1984_UTM_Zone_49N\n sp = sp... | [
"0.5702726",
"0.56634814",
"0.55557644",
"0.55214024",
"0.55070996",
"0.54865766",
"0.5451361",
"0.53921413",
"0.5359112",
"0.535614",
"0.53479344",
"0.5345904",
"0.5327789",
"0.53064764",
"0.5259722",
"0.5254505",
"0.52207696",
"0.52142113",
"0.5211009",
"0.5209606",
"0.5181... | 0.60760325 | 0 |
Returns the configured GLS Unibox client | def get_unibox_client(self):
if self._gls_unibox_client is None:
client = Client(
self.gls_server,
self.gls_port
)
client.test = self.gls_is_test
self._gls_unibox_client = client
return self._gls_unibox_client | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_client():\n return Client(__address, authkey='strumamor')",
"def uclient():\n return IceCubedSyncClient()",
"def _get_glance_client(self):\n session = self._get_keystone_session()\n return glanceclient.client.Client(2, session=session)",
"def client():\n return Client(**common_... | [
"0.6596754",
"0.65373576",
"0.6365249",
"0.5984165",
"0.5944317",
"0.5854694",
"0.582115",
"0.58013254",
"0.5776709",
"0.5746765",
"0.5741205",
"0.57369256",
"0.57369256",
"0.57062393",
"0.56923044",
"0.56536156",
"0.56215703",
"0.56098574",
"0.5561423",
"0.5546961",
"0.55431... | 0.82784706 | 0 |
Projects a coarse array on a finer array. The shapes of the two must be evenly divisible. Mesh must be uniform (i.e., have equal volumes/weights) | def project_array(fine, coarse):
f = np.array(fine.shape)
c = np.array(coarse.shape)
assert (f // c == f / c).all(), "Meshes do not line up!"
new = np.zeros(c)
xratio, yratio = f // c
for i in range(c[0]):
for j in range(c[1]):
tot = 0
if np.isnan(coarse[i, j]):
new[i, j] = np.nan
else:
for cmi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coarsegrain_cube_y(As, pars):\n verb = pars[\"verbosity\"]\n A1, w1b0, w1b1, w1b2, w1b3 = coarse_grain_pair(As[0], As[1], pars)\n A2 = A1.copy()\n if verb > 0:\n logging.info('-----')\n A8, w8b0, w8b1, w8b2, w8b3 = coarse_grain_pair(As[7], As[6], pars)\n A7 = A8.copy()\n if verb > 0... | [
"0.5828268",
"0.56114316",
"0.5544841",
"0.5477398",
"0.5449794",
"0.5444126",
"0.5399281",
"0.53811014",
"0.53626454",
"0.5357993",
"0.5336566",
"0.5331161",
"0.53108424",
"0.53091383",
"0.5292186",
"0.528533",
"0.5272982",
"0.52662694",
"0.5249113",
"0.5244548",
"0.5238322"... | 0.7529162 | 0 |
Compare two MOC reaction rate distributions to OpenMC Plots will be laid out ________________________________ | | | | | mc | moc1 | moc2 | |__________|__________|__________| |%err moc1 |%err moc1 |%err moc2 | | vs. moc2 | vs. mc | vs. mc | |__________|__________|__________| | def make_six_plots(mc, moc1, moc2, moc1name, moc2name, rxn,
cmin=None, cmax=None, emin=None, emax=None, **kwargs):
# Get reaction rate colorbars
_cmin, _cmax = get_min_and_max((mc, moc1, moc2), positive=True)
if cmin is None:
cmin = max(1 - max(1 - _cmin, _cmax - 1), 0)
if cmax is None:
cmax ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def two_way_comparison(html_writer, thermo1, thermo2, reaction_list, name=None):\n pH, pMg, I, T = (7, 14, 0.1, 298.15)\n \n total_list = []\n \n for reaction in reaction_list:\n try:\n dG0_pred1 = reaction.PredictReactionEnergy(thermo1, pH=pH, pMg=pMg, I=I, T=T)\n dG0_p... | [
"0.63385457",
"0.61217153",
"0.59623927",
"0.57825494",
"0.5775869",
"0.57744086",
"0.5770432",
"0.57002556",
"0.56999236",
"0.5673852",
"0.5669893",
"0.56673414",
"0.5656433",
"0.5651452",
"0.56289107",
"0.5602321",
"0.5595727",
"0.55828524",
"0.5578226",
"0.5567169",
"0.555... | 0.669261 | 0 |
Fetching auditory example into SubjectData Structure | def _spm_auditory_subject_data():
subject_data = fetch_spm_auditory()
subject_data['func'] = None
base_dir = os.path.dirname(subject_data['anat'])
subject_data.output_dir = os.path.join(base_dir, OUTPUT_DIR)
return SubjectData(**subject_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def example_clinical_data(study_name, environment):\n\n odm = ODM(\"test system\")(\n ClinicalData(\"Mediflex\", \"DEV\")(\n SubjectData(\"MDSOL\", \"IJS TEST4\", transaction_type=\"Insert\")(\n StudyEventData(\"SUBJECT\")(\n FormData(\"EN\", transaction_type=\"Update\"... | [
"0.581809",
"0.57771516",
"0.53702515",
"0.53617734",
"0.52999824",
"0.52326226",
"0.51739323",
"0.5141163",
"0.5134739",
"0.5089434",
"0.5087582",
"0.5085697",
"0.5083263",
"0.5079379",
"0.5079035",
"0.5068134",
"0.50584024",
"0.5056629",
"0.50402486",
"0.5038644",
"0.502863... | 0.662094 | 0 |
Wait until a StorageVolume's state is "available". Set "maybe_in_use" to True in order to wait even when the volume is currently in_use. For example, set this option if you're recycling this volume from an old node that you've very recently destroyed. | def _wait_until_volume_available(self, volume, maybe_in_use=False):
ok_states = ["creating"] # it's ok to wait if the volume is in this
tries = 0
if maybe_in_use:
ok_states.append("in_use")
logger.info("Volume: %s is in state: %s", volume.name, volume.state)
while vo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def volume_in_use(self):\n return self._volume_status_check(STATUS_IN_USE, False, 0, 0)",
"def wait_volume(\n self, volume_id, stop=None, delay=1, timeout=100, wait_cb=None):\n return wait(\n self.get_volume_details, (volume_id, ),\n stop or (lambda i: i['status'] !... | [
"0.63608456",
"0.6114131",
"0.5768956",
"0.5719089",
"0.564348",
"0.5637505",
"0.56323284",
"0.5594191",
"0.5559518",
"0.5549304",
"0.55003697",
"0.54798245",
"0.54350185",
"0.54330635",
"0.5403939",
"0.5399671",
"0.53981876",
"0.53912777",
"0.5382214",
"0.5365663",
"0.535362... | 0.8412628 | 0 |
Workaround. self.node.private_ips returns empty list. | def get_private_ip(self):
node_detail = self.driver.ex_get_node_details(self.node)
private_ip = node_detail.private_ips[0].encode("ascii", "ignore")
return private_ip | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private_ip_addresses(self) -> pulumi.Output[Sequence[str]]:\n return pulumi.get(self, \"private_ip_addresses\")",
"def private_ip_addresses(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:\n return pulumi.get(self, \"private_ip_addresses\")",
"def list_public_ips(self, available=... | [
"0.74730664",
"0.74209124",
"0.7064162",
"0.68416506",
"0.6804734",
"0.6636713",
"0.6619918",
"0.66077685",
"0.65843683",
"0.65843683",
"0.65764624",
"0.65556335",
"0.6455513",
"0.6418153",
"0.640006",
"0.6360428",
"0.6339249",
"0.6339249",
"0.6339249",
"0.6339249",
"0.633924... | 0.7533584 | 0 |
Given a type if it's a known typedef (only typedef's that aren't union) are remembered for fixup. typedefs that are union type are mapped to any so those we don't need to alias. typedefs referenced in the file where the typedef was defined are automatically aliased to the real type. This resolves typedef where the decl... | def resolveTypedef(type):
for typedef in _typeDefsFixup:
if typedef.id == type.id:
return typedef.type
return type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_alias(type_):\n type_ref = None\n if isinstance(type_, cpptypes.type_t):\n type_ref = type_\n elif isinstance(type_, typedef.typedef_t):\n type_ref = type_.type\n else:\n pass # not a valid input, just return it\n if not type_ref:\n return type_\n if type_r... | [
"0.70856184",
"0.6920592",
"0.64094436",
"0.59019864",
"0.5894106",
"0.5798306",
"0.5721708",
"0.5686805",
"0.5651905",
"0.5559996",
"0.5555295",
"0.5504577",
"0.54712564",
"0.5438714",
"0.5436048",
"0.54055595",
"0.539853",
"0.5369568",
"0.53488666",
"0.53451025",
"0.5218937... | 0.80433446 | 0 |
Initializes an IDLNode from a PegParser AST output. | def __init__(self, ast, id=None):
if ast:
self.id = self._find_first(ast, 'Id') if ast is not None else None
else:
# Support synthesized IDLNode created w/o an AST (e.g., setlike support).
self.id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, the_ast):\n self._ast = the_ast",
"def __init__(self):\n\n self.prim_parser = parser.Parser()",
"def __init__(self, input_file_name, ast_root_node):\n\n self.input_file_name = input_file_name\n self.ast_root_node = ast_root_node\n self.object_file = ObjectF... | [
"0.64044213",
"0.6266284",
"0.6185185",
"0.5708756",
"0.56727463",
"0.5509706",
"0.5495177",
"0.5473905",
"0.53980553",
"0.5396762",
"0.53796524",
"0.53790003",
"0.53763753",
"0.53754634",
"0.5369841",
"0.53407973",
"0.5340085",
"0.5337613",
"0.53317446",
"0.5327891",
"0.5322... | 0.70922244 | 0 |
Returns string of extra info for __repr__(). | def _extra_repr(self):
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n extras = self._extra_repr()\n if isinstance(extras, list):\n extras = ' '.join([str(e) for e in extras])\n try:\n if self.id:\n return '<%s %s 0x%x>' % (type(self).__name__,\n ('%s %s' % (self.id... | [
"0.78283966",
"0.77375877",
"0.7687218",
"0.76055586",
"0.7555131",
"0.75000334",
"0.74571764",
"0.744892",
"0.74434084",
"0.7438104",
"0.74377024",
"0.74233174",
"0.74117184",
"0.7360773",
"0.7345917",
"0.73441535",
"0.72871655",
"0.72871655",
"0.72871655",
"0.72583014",
"0.... | 0.8242073 | 0 |
Override default equals operation. IDLNodes are equal if all their properties are equal. | def __eq__(self, other):
if other is None or not isinstance(other, IDLNode):
return 1
return self.__dict__.__eq__(other.__dict__) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\r\n if not isinstance(other, BaseElement): return False\r\n return self.as_dict() == other.as_dict() and self.eid == other.eid",
"def __eq__(self, other):\n if not isinstance(other, NodeInterfaceAlias):\n return False\n\n return self.__dict__ == oth... | [
"0.7477901",
"0.74357456",
"0.72444695",
"0.7200534",
"0.7193656",
"0.71801114",
"0.71704066",
"0.71704066",
"0.71704066",
"0.71704066",
"0.71704066",
"0.71675265",
"0.71675265",
"0.71675265",
"0.71511906",
"0.7145813",
"0.7121271",
"0.7114071",
"0.7114071",
"0.7113948",
"0.7... | 0.7792428 | 0 |
Reset the id of the Node. This is typically done during a normalization phase (e.g., "DOMWindow" > "Window"). | def reset_id(self, newId):
self.id = newId | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_uid():\n NNModel._UID_BASE = -1",
"def reset_id(self, new_id):\n if self.id != new_id:\n self.id = new_id\n self.doc_js_name = new_id\n self.javascript_binding_name = new_id\n for member in self.operations:\n member.doc_js_interfa... | [
"0.70308524",
"0.6869483",
"0.6775127",
"0.67088693",
"0.6664753",
"0.6553676",
"0.65210867",
"0.6483599",
"0.6422293",
"0.6365199",
"0.63385797",
"0.62504816",
"0.6188777",
"0.6186573",
"0.61661303",
"0.6149513",
"0.6133739",
"0.6111859",
"0.6092984",
"0.6090128",
"0.6084401... | 0.73122156 | 0 |
Accessor used by all() to find subnodes. | def _all_subnodes(self):
return self.__dict__.values() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_search_subnode_attribute(self):\n\n lista = []\n for (_, value) in self.parser.search(self.xml, 'node@id'):\n lista.append(value)\n self.assertEqual(lista, ['1', '2', '3'])",
"def get_children(self):\n return self.children",
"def getVisitableNodes(self):\n\n r... | [
"0.64605904",
"0.64389324",
"0.6315166",
"0.630854",
"0.6219206",
"0.62068975",
"0.61804354",
"0.6162336",
"0.6150681",
"0.61315566",
"0.6127401",
"0.6120416",
"0.61193985",
"0.6115054",
"0.61043733",
"0.6093995",
"0.60917777",
"0.60601485",
"0.6048049",
"0.6044679",
"0.60380... | 0.6939223 | 0 |
Searches the AST for tuples with a given label. The PegParser output is composed of lists and tuples, where the tuple 1st argument is a label. If ast root is a list, will search recursively inside each member in the list. | def _find_all(self, ast, label, max_results=sys.maxsize):
res = []
if max_results <= 0:
return res
if isinstance(ast, list):
for childAst in ast:
if childAst and \
not(isinstance(childAst, dict)) and \
not(isinstance(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_first(self, ast, label):\n res = self._find_all(ast, label, max_results=1)\n if len(res):\n return res[0]\n return None",
"def findLabel(self, label):\n return self.root._findLabel(label)",
"def _findLabel(self, label):\n if self.label == label:\n ... | [
"0.5548694",
"0.53977364",
"0.5278831",
"0.5259326",
"0.52171534",
"0.520039",
"0.51873386",
"0.51805204",
"0.5123465",
"0.5074415",
"0.5044474",
"0.49878305",
"0.48693886",
"0.4859384",
"0.48249248",
"0.4800178",
"0.4739873",
"0.47191525",
"0.47156197",
"0.4693911",
"0.46827... | 0.627858 | 0 |
Returns true if an element with the given label is in the AST by searching for it. | def _has(self, ast, label):
return len(self._find_all(ast, label, max_results=1)) == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_label(self, label):\n return label in self.get_labels()",
"def has_label(self, label):\n\t\treturn label in self.labels",
"def has_label(self, label):\n\t\t\treturn label in self.labels",
"def has_label(self, label):\n return label in self.labels",
"def tree_contains(T, x):\n if T.labe... | [
"0.6862438",
"0.6747412",
"0.6695561",
"0.6658182",
"0.65795946",
"0.655899",
"0.6502396",
"0.64120346",
"0.6377532",
"0.6353135",
"0.63511646",
"0.63434815",
"0.62181157",
"0.6132546",
"0.61245525",
"0.6116893",
"0.5993297",
"0.5993297",
"0.59343505",
"0.5854531",
"0.5828301... | 0.73816514 | 0 |
Converts AST elements into IDLNode elements. Uses _find_all to find elements with a given label and converts them into IDLNodes with a given constructor. | def _convert_all(self, ast, label, idlnode_ctor):
res = []
found = self._find_all(ast, label)
if not found:
return res
if not isinstance(found, list):
raise RuntimeError("Expected list but %s found" % type(found))
for childAst in found:
convert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_all(self, ast, label, max_results=sys.maxsize):\n res = []\n if max_results <= 0:\n return res\n\n if isinstance(ast, list):\n for childAst in ast:\n if childAst and \\\n not(isinstance(childAst, dict)) and \\\n ... | [
"0.64059407",
"0.54920393",
"0.52157503",
"0.51214254",
"0.50772434",
"0.47918117",
"0.464695",
"0.45771432",
"0.45640677",
"0.45009723",
"0.4462737",
"0.445755",
"0.445154",
"0.4445031",
"0.4433541",
"0.44160184",
"0.44064283",
"0.43987316",
"0.43692365",
"0.436908",
"0.4351... | 0.70154023 | 0 |
Helper method for uniform conversion of extended attributes. | def _convert_ext_attrs(self, ast):
self.ext_attrs = IDLExtAttrs(ast) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extensible_attributes():\n return 'extensibleattributedef?'",
"def inherit_attributes(self, attr_table, base_ext_type):\n base_attrs = base_ext_type.attribute_table.attributedict\n attr_table.inherited.update(base_attrs) # { attr_name }\n attr_table.attributedict.update(base_a... | [
"0.63494587",
"0.61637384",
"0.59014434",
"0.5771259",
"0.5766376",
"0.56892645",
"0.56333554",
"0.56333554",
"0.55991375",
"0.5522741",
"0.5482767",
"0.5453387",
"0.5435932",
"0.5352993",
"0.5328023",
"0.53081566",
"0.5300636",
"0.5294145",
"0.5286404",
"0.5280292",
"0.52784... | 0.6565636 | 0 |
Helper method for uniform conversion of annotations. | def _convert_annotations(self, ast):
self.annotations = IDLAnnotations(ast) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_synapse_annotations(annotations):\n \n if is_synapse_annotations(annotations):\n return annotations\n synapseAnnos = {}\n for key, value in annotations.iteritems():\n if key in ['id', 'etag', 'blobAnnotations', 'creationDate', 'uri']:\n synapseAnnos[key] = value\n ... | [
"0.6555405",
"0.64629054",
"0.6305557",
"0.6264587",
"0.61517036",
"0.6142234",
"0.60739154",
"0.60662335",
"0.60662335",
"0.6036173",
"0.5983792",
"0.5934746",
"0.590155",
"0.5898076",
"0.5892509",
"0.58503664",
"0.5842422",
"0.58409405",
"0.5830955",
"0.5821075",
"0.5800294... | 0.78654003 | 0 |
Overrides the default IDLNode.to_dict behavior. The IDLDictNode members are copied into a new dictionary, and IDLNode members are recursively converted into dicts as well. | def to_dict(self):
res = {}
for (k, v) in self.__map.items():
if isinstance(v, IDLNode):
v = v.to_dict()
res[k] = v
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dict(self):\n res = {}\n for (k, v) in self.__dict__.items():\n if v == None or v == False or v == [] or v == {}:\n # Skip empty/false members.\n continue\n elif isinstance(v, IDLDictNode) and not len(v):\n # Skip empty dict su... | [
"0.80214536",
"0.67948574",
"0.6480687",
"0.6445976",
"0.641951",
"0.63285863",
"0.6243499",
"0.62361443",
"0.62328714",
"0.62328184",
"0.62172663",
"0.6195797",
"0.6149923",
"0.6149923",
"0.6109659",
"0.6088377",
"0.6076207",
"0.60689974",
"0.60689974",
"0.6054331",
"0.60519... | 0.76795065 | 1 |
Synthesize an IDLOperation with no AST used for support of setlike. | def generate_operation(interface_name,
result_type_name,
oper_name,
arguments,
result_nullable=False):
""" Arguments is a list of argument where each argument is:
[IDLType, argument_name, optional_boolean] """
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_operation(self,\n identifier,\n arguments=None,\n return_type=None,\n extended_attributes=None,\n node=None):\n if not return_type:\n return_type = self._create... | [
"0.5600522",
"0.5229043",
"0.5133824",
"0.5080849",
"0.5035134",
"0.4994753",
"0.49918434",
"0.4926797",
"0.49156773",
"0.49007735",
"0.48942155",
"0.48774537",
"0.485861",
"0.48473763",
"0.4844859",
"0.48224536",
"0.48141453",
"0.47965094",
"0.47893456",
"0.4766139",
"0.4759... | 0.6097301 | 0 |
Need to create (in our database) a number of operations. This is a new IDL syntax, the implied operations for a set now use setlike where T is a known | def generate_setLike_operations_properties(interface, set_like):
setlike_ops = []
"""
Need to create a typedef for a function callback e.g.,
a setlike will need a callback that has the proper args in FontFaceSet that is
three arguments, etc.
typedef void FontFaceSetForEachCallback(
FontFace... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set():",
"def new_set(*, ctx: context.ContextLevel, **kwargs) -> irast.Set:\n ir_set = irast.Set(**kwargs)\n ctx.all_sets.append(ir_set)\n return ir_set",
"def Set(self) -> None:",
"def define_set():\n set_1 = set([1, 2, 3])\n print type(set_1)\n print set_1\n\n set_2 = {2, 3, 2}\n ... | [
"0.60883856",
"0.5941632",
"0.59062153",
"0.5841504",
"0.578516",
"0.57658625",
"0.56670064",
"0.56197774",
"0.5541269",
"0.5533224",
"0.5523849",
"0.54196256",
"0.5414708",
"0.53865963",
"0.53650934",
"0.5360222",
"0.53452474",
"0.532943",
"0.5324191",
"0.53078604",
"0.52932... | 0.6911261 | 0 |
Reset the id of the Interface and corresponding the JS names. | def reset_id(self, new_id):
if self.id != new_id:
self.id = new_id
self.doc_js_name = new_id
self.javascript_binding_name = new_id
for member in self.operations:
member.doc_js_interface_name = new_id
for member in self.attributes:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_id(self):\n raise NotImplementedError()",
"def reset(self):\n self.ir_reg_name_generator.reset()",
"def reset_id(self, newId):\n self.id = newId",
"def _reset(self):\n self.characterID = None\n self.myName = u''",
"def clear_ic(self): # -> None:\n ...",
... | [
"0.58981836",
"0.58599675",
"0.5735181",
"0.568398",
"0.55538964",
"0.54658705",
"0.5359874",
"0.5349277",
"0.52972907",
"0.52592605",
"0.52583325",
"0.52020836",
"0.5170203",
"0.5163324",
"0.514814",
"0.51362187",
"0.51089966",
"0.5101676",
"0.51012796",
"0.51012796",
"0.510... | 0.7884957 | 0 |
Check a sparkdataframe to find existence of null values in given columns | def check_sparkdf_not_nulls(sparkdf,columns):
for column in columns:
empties = sparkdf.select(col(column)).where(col(column).isNull())
if len(empties.head(1)) > 0:
print("Checking DataFrame. I found null values in column", column)
return False
else:
print("Checking DataFrame. No null values found in c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_null_columns(spark, df, cols):\n null_cols_list = []\n # this assumes the col list matches the original schema\n # df = df.toDF(*cols)\n try:\n df = df.select(*cols)\n col_null_count = df.select([F.count(F.when(F.isnan(col) | F.col(col).isNull(), col)).alias(col) for col in cols... | [
"0.7968001",
"0.75320756",
"0.70830697",
"0.7068936",
"0.70367",
"0.7027333",
"0.6975715",
"0.6794396",
"0.67697585",
"0.65817136",
"0.6357582",
"0.63538563",
"0.6334456",
"0.6290791",
"0.62617993",
"0.6174786",
"0.6119855",
"0.6113509",
"0.61113983",
"0.609082",
"0.6032035",... | 0.87045765 | 0 |
Check a sparkdataframe to find existence of duplicate values for a set of given columns | def check_sparkdf_find_dupes(sparkdf,columns):
return sparkdf.groupBy(columns).count().where('count>1').sort('count', ascending=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by(df: pd.DataFrame, columns: List[str]) -> Result:\n result = Result(f\"Duplicates\")\n result.items_count = len(df)\n df = df.dropna(subset=columns, how=\"all\")\n duplicates = df[df.duplicated(columns, keep=False)][columns]\n if duplicates.empty:\n return result\n\n errors = {}... | [
"0.70761764",
"0.67027205",
"0.6699218",
"0.660388",
"0.65129834",
"0.6485821",
"0.64064527",
"0.64027154",
"0.63034064",
"0.6282684",
"0.61856705",
"0.61500347",
"0.6127648",
"0.6047853",
"0.5986667",
"0.5979793",
"0.59759897",
"0.59615165",
"0.5949579",
"0.59030557",
"0.590... | 0.8052438 | 0 |
Check a sparkdataframe to find existence of rows with county != one of the valid and remove them | def clean_wrong_counties(sparkdf):
counties=['burgos','ávila','león','segovia','palencia','zamora','soria','salamanca','valladolid']
# First we replace common errors (avila -> ávila, leon -> león)
sparkdf=sparkdf.withColumn('county',lower(col('county'))).withColumn('county', regexp_replace('county', 'avila', 'ávila... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(df):",
"def remove_closed_store(data: pyspark.sql.dataframe.DataFrame) -> pyspark.sql.dataframe.DataFrame:\n closed_store = pd.read_csv('../data/closedStore/Closed stores list.csv')\n closed_store_list = closed_store['Store'].unique()\n \n for store in closed_store_list:\n data = dat... | [
"0.60927004",
"0.5883151",
"0.56114316",
"0.5577637",
"0.55568635",
"0.55402344",
"0.5536535",
"0.54603237",
"0.5458628",
"0.54585034",
"0.5456754",
"0.5443833",
"0.54354286",
"0.54210514",
"0.54181176",
"0.53951836",
"0.53917754",
"0.53639036",
"0.535018",
"0.53207976",
"0.5... | 0.66658825 | 0 |
Get all layers in input dataset | def getLayers(self,ds):
numLayers = ds.GetLayerCount()
layers = []
for i in range(numLayers):
layers.append(ds.GetLayerByIndex(i))
return layers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_layers_output(self, dataset):\n layers_out = []\n\n with self.tf_graph.as_default():\n with tf.Session() as self.tf_session:\n self.tf_saver.restore(self.tf_session, self.model_path)\n for l in self.layer_nodes:\n layers_out.append(l... | [
"0.7323205",
"0.7190773",
"0.7116928",
"0.7041799",
"0.7003817",
"0.69840705",
"0.69775575",
"0.6940857",
"0.6851317",
"0.6762551",
"0.67269593",
"0.6667894",
"0.66465133",
"0.657843",
"0.65484804",
"0.65249443",
"0.65058845",
"0.6440373",
"0.6418502",
"0.6392186",
"0.6373223... | 0.7430822 | 0 |
Get all the features from the provided layer | def getFeatures(self,layer):
numFeatures = layer.GetFeatureCount()
features = []
for i in range(numFeatures):
feature = layer.GetNextFeature()
if feature is not None:
geomRef = feature.GetGeometryRef()
if((geomRef is not None and geomR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAllFeatures(self,layers): \n features = []\n for layer in layers:\n features += self.getFeatures(layer)\n return features",
"def get_all_features(self) :\n raise NotImplementedError",
"def extract_features(self, inputs):\n x = self.conv1(inputs)\n x =... | [
"0.7532495",
"0.698824",
"0.6775168",
"0.6765497",
"0.6589484",
"0.6567784",
"0.6563699",
"0.6525087",
"0.63945794",
"0.6393874",
"0.6370235",
"0.6338528",
"0.6336248",
"0.6287451",
"0.62582076",
"0.6232931",
"0.6226738",
"0.6173324",
"0.61024225",
"0.61024225",
"0.6097073",
... | 0.7991991 | 0 |
Get all features from all input layers | def getAllFeatures(self,layers):
features = []
for layer in layers:
features += self.getFeatures(layer)
return features | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_features(self) :\n raise NotImplementedError",
"def extract_features(self, inputs):\n x = self.conv1(inputs)\n x = self.bn1(x)\n x = self.relu(x)\n x = self.maxpool(x)\n\n x = self.layer1(x)\n x = self.layer2(x)\n x = self.layer3(x)\n x =... | [
"0.7736043",
"0.74079543",
"0.72242516",
"0.69461167",
"0.69096565",
"0.6757849",
"0.66967493",
"0.6691653",
"0.66488785",
"0.65362114",
"0.65101993",
"0.6447215",
"0.64453006",
"0.64038414",
"0.63787663",
"0.63713896",
"0.63454807",
"0.6335672",
"0.63336134",
"0.63222736",
"... | 0.77544725 | 0 |
Get layers from datasource using specific layer names | def getLayersByNames(self,ds, layerNames):
layers = []
for layerName in layerNames:
layer = ds.GetLayer(layerName)
if layer is None:
rospy.loginfo("Layer not found: " + layerName )
else:
layers.append(layer)
return layers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLayers(self,ds):\n numLayers = ds.GetLayerCount()\n layers = []\n for i in range(numLayers):\n layers.append(ds.GetLayerByIndex(i))\n return layers",
"def get_layers(layer_data: Dict[str, Any]) -> List[Layer]:\n try:\n l_data = layer_data['kicad_pcb']\n ... | [
"0.69695085",
"0.682318",
"0.6687111",
"0.6668188",
"0.6543981",
"0.6543981",
"0.6491103",
"0.642833",
"0.6374225",
"0.63272333",
"0.6306053",
"0.63057643",
"0.6299437",
"0.62856114",
"0.62482107",
"0.62280494",
"0.62167877",
"0.62068677",
"0.6160596",
"0.6155484",
"0.6120604... | 0.76040554 | 0 |
load instructions from file and compile task graph | def load_instruction(self, path):
with open(path, "r") as fd:
for line in fd.readlines():
words = line.split(" ")
p, c = (words[1], words[7])
_c = self.pending_tasks.setdefault(c, Task(c))
_p = self.pending_tasks.setdefault(p, Task(p))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_assemble_file(task_file):\n return imp.load_source('assemblefile', task_file)",
"def load(self, file_):\n\n program = []\n\n with open(f'ls8/examples/{file_}') as f:\n for line in f:\n line = line.split(\"#\")\n try:\n v = int(... | [
"0.7161073",
"0.6371488",
"0.6254768",
"0.62106085",
"0.60872686",
"0.59458417",
"0.5904104",
"0.58814",
"0.5799317",
"0.5781601",
"0.5721208",
"0.57137394",
"0.57053137",
"0.5688763",
"0.5652076",
"0.5649462",
"0.5645391",
"0.5645179",
"0.5635451",
"0.5633006",
"0.5631113",
... | 0.7419635 | 0 |
Mark a task complete This will enqueue it's dependents | def complete(self, task):
if self.hold:
[self.queue.push(x) for x in self.hold]
self.hold = []
if task is None:
return
elif task.name in self.pending_tasks:
del self.pending_tasks[task.name]
if task.dependents:
[self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_as_done(self, task):\n raise NotImplementedError('')",
"def task_done(self):\n self._queue.task_done()",
"def task_done(self) -> None:\n pass",
"def done(self):\n self.__queue.task_done()",
"def set_task_finished(self):\n self.busy = False",
"def task_done(self... | [
"0.730148",
"0.7120666",
"0.69866747",
"0.69211143",
"0.6873467",
"0.67596334",
"0.6756576",
"0.66745377",
"0.66745377",
"0.66693366",
"0.6530245",
"0.65264237",
"0.6441161",
"0.6441161",
"0.6441161",
"0.6441161",
"0.6441161",
"0.6441161",
"0.6441161",
"0.6441161",
"0.6441161... | 0.7606407 | 0 |
This function extracts IMEI and Software Version from the login packet. The IMEI and Software Version will be stored into a client dictionary to allow handling of multiple devices at once, in the future. The client socket is passed as an argument because it is in this packet that IMEI is sent and will be stored in the ... | def login(client, q):
# Initialize the dictionary
addresses[client] = {}
# Read data: Bits 2 through 9 are IMEI and 10 is software version
protocol = q[1]
addresses[client]['imei'] = q[2] + q[3] + q[4] + q[5] + q[6] + q[7] + q[8] + q[9]
addresses[client]['software_version'] = q[10]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_version(header, data):\n log = unpack('<I', data)\n game, save = unpack('<7sxf', header)\n if save == -1:\n save = unpack('<I', header)\n if save == 37:\n save = 37.0\n else:\n save /= (1<<16)\n version = get_version(game.decode('ascii'), round(save,... | [
"0.5673131",
"0.55522734",
"0.54552674",
"0.5306779",
"0.52901626",
"0.5241844",
"0.51588374",
"0.515236",
"0.513073",
"0.5110098",
"0.50541234",
"0.50225896",
"0.49775684",
"0.49715415",
"0.4929209",
"0.48918366",
"0.4889113",
"0.48707312",
"0.48686746",
"0.48594397",
"0.484... | 0.61129266 | 0 |
Get a nice string representation of the cubic polynomial `p`. | def nice_cubic_polynomial(p):
tmp = ""
if p["a"] == 1:
tmp += " x^3"
elif p["a"] != 0:
tmp += "%.2fx^3" % p["a"]
if p["b"] == 1:
tmp += "\t+ x^2"
elif p["b"] != 0:
tmp += "\t+ %.2fx^2" % p["b"]
else:
tmp += "\t\t"
if p["c"] == 1:
tmp += "\t+ x"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self) -> str:\n polynomial = \"\"\n for i in range(self.degree, -1, -1):\n if self.coefficients[i] == 0:\n continue\n elif self.coefficients[i] > 0:\n if polynomial:\n polynomial += \" + \"\n else:\n ... | [
"0.6800418",
"0.6732153",
"0.67045623",
"0.6659032",
"0.66174585",
"0.6423057",
"0.6212907",
"0.620363",
"0.6016788",
"0.58934104",
"0.5886453",
"0.5838241",
"0.57581615",
"0.573579",
"0.57154334",
"0.55892724",
"0.5529264",
"0.5507327",
"0.55057025",
"0.55036235",
"0.5495405... | 0.8349409 | 0 |
Remove an enphase_envoy config entry from a device. | async def async_remove_config_entry_device(
hass: HomeAssistant, config_entry: ConfigEntry, device_entry: dr.DeviceEntry
) -> bool:
dev_ids = {dev_id[1] for dev_id in device_entry.identifiers if dev_id[0] == DOMAIN}
data: dict = hass.data[DOMAIN][config_entry.entry_id]
coordinator: DataUpdateCoordinator... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_remove_config_entry_device(\n hass: HomeAssistant, config_entry: ConfigEntry, device_entry: dr.DeviceEntry\n) -> bool:\n dev_ids = {dev_id[1] for dev_id in device_entry.identifiers if dev_id[0] == DOMAIN}\n coordinator: EnphaseUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]\n ... | [
"0.6552235",
"0.6130654",
"0.59584737",
"0.5890043",
"0.57498085",
"0.57023644",
"0.56873775",
"0.55164623",
"0.5500037",
"0.5478333",
"0.5470162",
"0.5441884",
"0.5391111",
"0.53814036",
"0.53691494",
"0.5368767",
"0.53541905",
"0.53413564",
"0.5337643",
"0.5325068",
"0.5295... | 0.64070684 | 1 |
Return a zerovalued matrix of the same shape as `matrix` and with equivalent integer or floating point type Note this differs from `numpy.zero_like` in that it always uses the largest integer type (int_) even if the source matrix uses a smaller type (e.g. uint8). This is so that we have sufficient headroom to sum many ... | def zero_like(matrix):
dtype = numpy.int_ if is_integer(matrix) else numpy.float_
return numpy.zeros(matrix.shape, dtype=dtype) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero_matrix(matrix):\n if not matrix:\n return\n\n n_rows = len(matrix)\n n_cols = len(matrix[0])\n\n # First row and first column of the matrix are used to store row and columns to nullify.\n # At the beginning we determine if the first row and/or first column contain a zero.\n first_... | [
"0.73966384",
"0.71608627",
"0.7073641",
"0.68901014",
"0.68604356",
"0.68059593",
"0.6800942",
"0.67580235",
"0.66957706",
"0.66957706",
"0.6672541",
"0.6668487",
"0.6637845",
"0.66139966",
"0.65811944",
"0.65452635",
"0.6541478",
"0.6527024",
"0.6525011",
"0.65146905",
"0.6... | 0.8943931 | 0 |
Return whether or not the matrix has integer type | def is_integer(matrix):
return numpy.issubdtype(matrix.dtype, numpy.integer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_integer(x):\n return (not isinstance(x, (bool, np.bool))) and \\\n isinstance(x, (numbers.Integral, int, np.int, np.long, long)) # no long type in python 3",
"def isInteger(data):\n\tif type(data) == list or type(data) == np.ndarray:\n\t\tcol = pd.Series(data)\n\telse:\n\t\tcol = data\n\tretur... | [
"0.75369906",
"0.73908705",
"0.72952753",
"0.72952753",
"0.7168371",
"0.7140396",
"0.7100118",
"0.6963798",
"0.69199604",
"0.6912938",
"0.68949765",
"0.68730015",
"0.68598884",
"0.6782187",
"0.67821383",
"0.6633698",
"0.66211396",
"0.6611227",
"0.65699816",
"0.65614873",
"0.6... | 0.89138985 | 0 |
Return the density of a sparse matrix | def get_density(matrix):
return matrix.getnnz() / (matrix.shape[0] * matrix.shape[1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(self):\n return self.nnz/self.dim",
"def density(self):\n return self.nnz / self.size",
"def density_2D(tensor):\n return 1 - sparsity_2D(tensor)",
"def density_ch(tensor):\n return 1 - sparsity_ch(tensor)",
"def matrix_to_density(mat):\n from sympy.physics.quantum.densit... | [
"0.7267739",
"0.7132435",
"0.69846934",
"0.6912411",
"0.67102784",
"0.6371849",
"0.6363305",
"0.63353455",
"0.6332972",
"0.63119537",
"0.62799716",
"0.62675554",
"0.6260785",
"0.62528604",
"0.6146938",
"0.6137834",
"0.6136465",
"0.6115155",
"0.6111693",
"0.6061603",
"0.603574... | 0.8230122 | 0 |
Convert a matrix to use the smallest integer type capable of representing all the values currently stored in it | def convert_to_smallest_int_type(matrix):
target_type = smallest_int_type_for_range(matrix.min(), matrix.max())
if target_type != matrix.dtype:
matrix = matrix.astype(target_type, copy=False)
return matrix | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matrix_to_single_digit(matrix):\n mini = numpy.min(matrix)\n maxi = numpy.max(matrix)\n # Normalize between 0 and 1\n mat_modified = (matrix + abs(mini))/(maxi - mini)\n # Convert similarity scores to distances and change the range to [0; 9]\n mat_modified = 9 * (1 - mat_modified)\n # Conv... | [
"0.68451244",
"0.67703176",
"0.60311395",
"0.5923723",
"0.5922241",
"0.5818655",
"0.5800817",
"0.5764776",
"0.5763138",
"0.57512134",
"0.5731464",
"0.5729652",
"0.5723643",
"0.5717285",
"0.57172185",
"0.5683257",
"0.5644663",
"0.56175995",
"0.5600954",
"0.55806327",
"0.557338... | 0.7348541 | 0 |
Return smallest numpy integer type capable of representing all values in the supplied range | def smallest_int_type_for_range(minimum, maximum):
signed = minimum < 0
abs_max = max(maximum, abs(minimum))
if signed:
if abs_max < 1 << 7:
return numpy.int8
elif abs_max < 1 << 15:
return numpy.int16
elif abs_max < 1 << 31:
return numpy.int32
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_signed_type(x, min_size=8):\n for int_dtype in np.sctypes[\"int\"]:\n if (cudf.dtype(int_dtype).itemsize * 8) >= min_size:\n if np.iinfo(int_dtype).min <= x <= np.iinfo(int_dtype).max:\n return int_dtype\n # resort to using `int64` and let numpy raise appropriate exce... | [
"0.71769917",
"0.6977312",
"0.67614967",
"0.634183",
"0.6268485",
"0.62563896",
"0.62008595",
"0.61327434",
"0.61305994",
"0.61170274",
"0.6067906",
"0.6042717",
"0.5960769",
"0.59440744",
"0.5943825",
"0.5917356",
"0.5911487",
"0.58114755",
"0.58102846",
"0.5800823",
"0.5799... | 0.7716588 | 0 |
Initialize a ParVec instance with values equal to one or the input value. | def initializeParVec(self, length, i, v=1):
ret = ParVec(length, 0)
for ind in range(len(i)):
if type(v) != int and type(v) != float:
ret[i[ind]] = v[ind]
else:
ret[i[ind]] = v
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n\n import numpy as np\n self._linked_array = None \n if isinstance(args[-1], list):\n v = np.ascontiguousarray(args[-1][0])\n col = np.ascontiguousarray(args[-1][1])\n args = list(args[:-1])\n args.append([v, col]... | [
"0.60944414",
"0.5944944",
"0.59079707",
"0.58007574",
"0.57588947",
"0.5757965",
"0.5625341",
"0.55988616",
"0.5569755",
"0.5568984",
"0.5521245",
"0.55086476",
"0.5490662",
"0.548968",
"0.546847",
"0.5460518",
"0.5455003",
"0.5455003",
"0.5455003",
"0.5455003",
"0.5435632",... | 0.6870567 | 0 |
Translate an ``enum DataRefTypes`` value into a string representation. | def data_ref_type_str(dref_enum):
if dref_enum == 0x9000:
return "unknown"
elif dref_enum == 0x9001:
return "integer"
elif dref_enum == 0x9002:
return "fp"
elif dref_enum == 0x9003:
return "integer(store)"
else:
return "INVALID" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_type_str(self):\n return data_ref_type_str(self.data_type)",
"def _get_data_type_name_by_value(data_type, value, field_name='data_type'):\n return data_type.DESCRIPTOR.fields_by_name[field_name].enum_type.values_by_number[value].name",
"def getTypeString(self):\n return '_'.join(s... | [
"0.64488417",
"0.5915168",
"0.5869412",
"0.5845906",
"0.58163184",
"0.57898754",
"0.5700525",
"0.56539005",
"0.5589911",
"0.5450604",
"0.5447355",
"0.54293203",
"0.53662735",
"0.53276265",
"0.5286095",
"0.52517074",
"0.5241835",
"0.5170923",
"0.5157144",
"0.51479024",
"0.5140... | 0.765977 | 0 |
The data ref type as a string, "unknown" "integer" "fp" or "INVALID" | def data_type_str(self):
return data_ref_type_str(self.data_type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_ref_type_str(dref_enum):\n if dref_enum == 0x9000:\n return \"unknown\"\n elif dref_enum == 0x9001:\n return \"integer\"\n elif dref_enum == 0x9002:\n return \"fp\"\n elif dref_enum == 0x9003:\n return \"integer(store)\"\n else:\n return \"INVALID\"",
"d... | [
"0.76956713",
"0.68933004",
"0.6670454",
"0.6580921",
"0.6473783",
"0.6445115",
"0.6438363",
"0.638922",
"0.6378025",
"0.63449824",
"0.634132",
"0.6304323",
"0.6288645",
"0.62766194",
"0.6234214",
"0.62324387",
"0.62109274",
"0.6208498",
"0.6206257",
"0.6203228",
"0.6203228",... | 0.766359 | 1 |
Filter all logs by user. | def get_queryset(self):
qs = Log.objects.filter(user=self.request.user)
return qs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAccessLogForUser(cls, user):\n return cls.objects.filter(user_id=user.pk).order_by('timestamp')",
"def userfilter(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"userfilter\")",
"def get_queryset(self):\n return super().get_queryset().filter(user=self.request.user)",
"def... | [
"0.6822105",
"0.61591154",
"0.6140061",
"0.61382645",
"0.6130061",
"0.60534394",
"0.6047455",
"0.59218",
"0.59192306",
"0.58901983",
"0.58795226",
"0.586993",
"0.58673084",
"0.5864309",
"0.5813333",
"0.57846487",
"0.5769409",
"0.5760135",
"0.57461464",
"0.57321817",
"0.572745... | 0.7318677 | 0 |
Add Form title to context. | def get_context_data(self, **kwargs):
context = super(BaseLogMixin, self).get_context_data(**kwargs)
context['form_title'] = self.form_title
return context | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def context_title(self):\n return self.request.POST.get(\"context_title\", self.context_id)",
"def set_title(self, title = \"FORM\"):\n\n c = self.canvas.setTitle(title)",
"def get_context_data(self, **kwargs):\n context = super(BaseJobMixin, self).get_context_data(**kwargs)\n conte... | [
"0.74071354",
"0.72894204",
"0.7286229",
"0.71726185",
"0.6919468",
"0.6799854",
"0.65779424",
"0.6554997",
"0.6546303",
"0.6539807",
"0.644642",
"0.64215106",
"0.640164",
"0.640164",
"0.640164",
"0.640164",
"0.640164",
"0.640164",
"0.640164",
"0.640164",
"0.640164",
"0.640... | 0.78298235 | 0 |
Filter jobs by current user. | def get_queryset(self):
qs = Job.objects.filter(user=self.request.user)
return qs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n jobs = Job.objects.all()\n if not self.kwargs.get(\"pk\"):\n jobs = jobs.filter(\n status=choices.APPROVED, submission_deadline__gte=datetime.today()\n ).order_by(\"-created_at\")\n if not self.request.user.is_anonymous():\n ... | [
"0.70244026",
"0.67698056",
"0.6759335",
"0.6641301",
"0.6597316",
"0.6581474",
"0.65543056",
"0.65356064",
"0.63639355",
"0.62858814",
"0.627093",
"0.6237571",
"0.61895525",
"0.61800796",
"0.60373586",
"0.6032202",
"0.60200655",
"0.60187614",
"0.59921527",
"0.59821224",
"0.5... | 0.7800031 | 0 |
Currntly active job information. Info includes name of the job and total time spent for this job. If there is no active log, 'Not Working' will be returned. | def current_job(user):
logs = user.log_set.filter(finish__isnull=True)[:1]
if logs:
log = logs[0]
result = LabelResponse(log.job.name,
log.get_duration_display())
else:
log = user.log_set.latest()
result = LabelResponse('Not Working',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def statusJob(self, job):\n with self.thread_lock:\n name = job.name\n job_container = self.shared_dags[job]\n job_dag = job_container.getDAG()\n\n # If there is no timing, then the job is not finished\n if job_container.getTime():\n job_... | [
"0.68009657",
"0.6702752",
"0.6680036",
"0.6408171",
"0.6343074",
"0.6304079",
"0.62953204",
"0.6270759",
"0.6263614",
"0.6222669",
"0.60908127",
"0.5993033",
"0.59769773",
"0.59636134",
"0.59493536",
"0.5913652",
"0.5889485",
"0.58564466",
"0.58541167",
"0.58259565",
"0.5806... | 0.68983704 | 0 |
Whether or not the form is multipart. The form is multipart when there is an enabled avatar service that has a multipart configuration form. | def is_multipart(self):
for service in self.avatar_service_registry.configurable_services:
if service.config_form_class.is_multipart:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_multipart(self):\n for field in self.fields.values():\n if field.widget.needs_multipart_form:\n return True\n return False",
"def is_multipartite(self):\n return True",
"def ismultipart(self):\n if type(self._payload) is ListType:\n return... | [
"0.8177735",
"0.77133185",
"0.7065834",
"0.6311071",
"0.62805766",
"0.6154905",
"0.6030352",
"0.5851574",
"0.5788952",
"0.5550961",
"0.5502673",
"0.5467362",
"0.54063404",
"0.53969055",
"0.53961813",
"0.53961813",
"0.5359346",
"0.5251854",
"0.5248528",
"0.5246166",
"0.5222298... | 0.86132556 | 0 |
Yield the bundle names necessary. Each avatar service can specify a configuration form that may specify JS bundles. Since those forms are not registered through the page, we must add them this way. | def js_bundle_names(self):
yield 'djblets-utils'
yield 'djblets-avatars-config'
for service in self.avatar_service_registry.configurable_services:
for bundle in service.config_form_class.js_bundle_names:
yield bundle | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def css_bundle_names(self):\n yield 'djblets-avatars-config'\n\n for service in self.avatar_service_registry.configurable_services:\n for bundle in service.config_form_class.css_bundle_names:\n yield bundle",
"def fetch_jwt_bundles(self) -> JwtBundleSet:",
"def create_bu... | [
"0.7893009",
"0.5960649",
"0.5488432",
"0.5400663",
"0.53222626",
"0.52193046",
"0.5201623",
"0.5105413",
"0.51030284",
"0.5096213",
"0.5038217",
"0.4973367",
"0.4937148",
"0.4936242",
"0.49121073",
"0.49097875",
"0.4909741",
"0.49005038",
"0.48891622",
"0.48762637",
"0.48695... | 0.852813 | 0 |
Yield the CSS bundle names. Each avatar service can specify a configuration form that may specify CSS bundles. Since those forms are not registered through the page, we must add them this way. | def css_bundle_names(self):
yield 'djblets-avatars-config'
for service in self.avatar_service_registry.configurable_services:
for bundle in service.config_form_class.css_bundle_names:
yield bundle | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def js_bundle_names(self):\n yield 'djblets-utils'\n yield 'djblets-avatars-config'\n\n for service in self.avatar_service_registry.configurable_services:\n for bundle in service.config_form_class.js_bundle_names:\n yield bundle",
"def ext_css_bundle(context, extens... | [
"0.76317704",
"0.57167304",
"0.52687097",
"0.51986027",
"0.5146708",
"0.5104278",
"0.50522244",
"0.5050688",
"0.5010011",
"0.49937245",
"0.49903783",
"0.48922908",
"0.4882869",
"0.4869842",
"0.48655388",
"0.48651272",
"0.48506978",
"0.48471832",
"0.482984",
"0.47975335",
"0.4... | 0.853845 | 0 |
Clean the avatar_service_id field. This ensures that the value corresponds to a valid and enabled avatar service. | def clean_avatar_service_id(self):
avatar_service_id = self.cleaned_data['avatar_service_id']
try:
avatar_service = self.avatar_service_registry.get(
'avatar_service_id', avatar_service_id)
except AvatarServiceNotFoundError:
avatar_service = None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(self):\n super(AvatarSettingsForm, self).clean()\n\n avatar_service_id = self.cleaned_data['avatar_service_id']\n avatar_service = self.avatar_service_registry.get_avatar_service(\n avatar_service_id)\n\n if avatar_service.is_configurable():\n avatar_serv... | [
"0.63320565",
"0.56859416",
"0.5139483",
"0.50330925",
"0.49213085",
"0.4891254",
"0.48138967",
"0.47976613",
"0.4785055",
"0.47521824",
"0.47516873",
"0.47179854",
"0.470563",
"0.4697542",
"0.4647376",
"0.46048954",
"0.46018898",
"0.4596978",
"0.4580802",
"0.45326537",
"0.45... | 0.8431658 | 0 |
Clean the form. This will clean the avatar service configuration form of the selected avatar service (if it is configurable) and raise an exception if it is not valid. This will cache any subform errors so that they can be rendered to the user when rendering the form. | def clean(self):
super(AvatarSettingsForm, self).clean()
avatar_service_id = self.cleaned_data['avatar_service_id']
avatar_service = self.avatar_service_registry.get_avatar_service(
avatar_service_id)
if avatar_service.is_configurable():
avatar_service_form = se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(self, value):\n if not value:\n raise ValidationError(\n 'Error found in Form Field: Nothing to validate')\n\n data = dict((bf.name, value[i]) for i, bf in enumerate(self.form))\n self.form = form = self.form.__class__(data)\n if not form.is_valid():\... | [
"0.5815374",
"0.56451374",
"0.5533979",
"0.5509334",
"0.5477022",
"0.5466455",
"0.54595834",
"0.545065",
"0.5445776",
"0.54311126",
"0.525111",
"0.52499014",
"0.52450776",
"0.52402484",
"0.519771",
"0.51737726",
"0.5126374",
"0.5121722",
"0.50853837",
"0.5059692",
"0.5057127"... | 0.757405 | 0 |
Save the avatar settings. This method attempts to save | def save(self):
try:
old_avatar_service = (
self.avatar_service_registry
.get_avatar_service(
self.settings_manager.avatar_service_id)
)
except ItemLookupError:
old_avatar_service = None
if old_avatar_servic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveSettings(self):\n self.userFiles.applyData()\n self.userPersonal.applyData()",
"def save_profile(self):\n self.save()",
"def save_settings(self):\n settings = {'camera': self.comboCamera.currentIndex(),\n 'rotation': self.comboRotation.currentIndex(),\n ... | [
"0.69342",
"0.6715412",
"0.6217812",
"0.61907786",
"0.6142293",
"0.612289",
"0.6117269",
"0.6114146",
"0.60711354",
"0.606622",
"0.6012281",
"0.5988391",
"0.5979921",
"0.59774315",
"0.5957726",
"0.59455204",
"0.5911861",
"0.5909266",
"0.5909266",
"0.58787477",
"0.58735186",
... | 0.72209036 | 0 |
Get the pieces and movements currently in the cart. | def get_cart_pieces_and_movements(request):
pieces = []
movements = []
cart = request.session.get("cart", {})
for key in cart:
if key.startswith("P"):
try:
tmp = Piece.objects.get(uuid=key[2:])
except ObjectDoesNotExist:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPieces( self ):\n return self.__pieces;",
"def _get_obs(self):\n\n # We get the angle of the pole_angle\n pole_angle = round(self.joints.position[1],3)\n\n # We get the distance from the origin\n y_distance = self.get_y_dir_distance_from_start_point(self.start_point)\n\n... | [
"0.62739784",
"0.6125421",
"0.6089837",
"0.59700817",
"0.5747425",
"0.57423043",
"0.5638352",
"0.5634941",
"0.5535817",
"0.553386",
"0.55208576",
"0.55056393",
"0.54703224",
"0.54334307",
"0.5423335",
"0.53915215",
"0.53879446",
"0.5377681",
"0.53763515",
"0.5376198",
"0.5358... | 0.7975343 | 0 |
Collections have curators, which introduces unique permission considerations. | def determine_perms(self, request, *args, **kwargs):
if hasattr(request, "user") and request.user in Collection.objects.get(id=kwargs['pk']).curators.all():
# The user is a curator, so they can view and edit
return {"can_edit": True, "can_view": True}
else:
# The defa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def principalCollections(self):\n return ()",
"def __base_acl__(self) -> list:\n _acls = [\n (Allow, 'g:professionals', ['list', 'view', 'edit']),\n ]\n return _acls",
"def test_collection_viewset_permissions(logged_in_apiclient):\n client, _ = logged_in_apiclient\n ... | [
"0.5948891",
"0.58946997",
"0.58611304",
"0.5838511",
"0.57985985",
"0.5797393",
"0.5767156",
"0.5731833",
"0.5731833",
"0.5590852",
"0.55760115",
"0.5553819",
"0.55494267",
"0.54567516",
"0.5440651",
"0.538288",
"0.5338052",
"0.5285567",
"0.52697945",
"0.52550316",
"0.521025... | 0.6018753 | 0 |
If the user has permission to edit the collection, add the specified pieces to the specified collection. | def patch(self, request, *args, **kwargs):
if self.determine_perms(request, *args, **kwargs)['can_edit']:
piece_ids = request.data.get("piece_ids")
movement_ids = request.data.get("movement_ids")
# Add the pieces to the collection
self.add_pieces_and_movements_to_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_collection(self, collection: CollectionEntity):\n logging.debug(\"Adding parts for collection %s\", collection.item_id)\n upload_matrix = AddPartsVisitor.get_upload_matrix(collection)\n routing_matrix = AddPartsVisitor.get_routing_matrix(collection)\n self._create_parts(collec... | [
"0.6307805",
"0.61789584",
"0.58508134",
"0.5674337",
"0.5641776",
"0.5626935",
"0.5552108",
"0.5520582",
"0.5502529",
"0.5431552",
"0.53833807",
"0.53406173",
"0.52727985",
"0.5266605",
"0.5261912",
"0.51773775",
"0.5169145",
"0.51677984",
"0.5163913",
"0.51599497",
"0.51311... | 0.7564374 | 0 |
If the user has permission to edit the collection, remove the specified pieces from the collection. | def delete(self, request, *args, **kwargs):
if self.determine_perms(request, *args, **kwargs)["can_edit"]:
piece_ids = request.data.get("piece_ids")
movement_ids = request.data.get("movement_ids")
# Remove the members from the collection
self.remove_pieces_and_mov... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_pieces_and_movements_from_collection(collection_id, piece_ids, movement_ids):\n collection = Collection.objects.get(id=collection_id)\n print(piece_ids)\n print(movement_ids)\n if piece_ids:\n for piece_id in piece_ids:\n piece = Piece.objects.get(id... | [
"0.6597003",
"0.6437928",
"0.6236149",
"0.61067325",
"0.60564095",
"0.590043",
"0.58075595",
"0.5804403",
"0.57704735",
"0.5712868",
"0.559905",
"0.5511886",
"0.550535",
"0.54802024",
"0.54623276",
"0.54227734",
"0.5396801",
"0.5373192",
"0.529023",
"0.5284725",
"0.5276789",
... | 0.75930995 | 0 |
Remove movements and pieces from a collection. | def remove_pieces_and_movements_from_collection(collection_id, piece_ids, movement_ids):
collection = Collection.objects.get(id=collection_id)
print(piece_ids)
print(movement_ids)
if piece_ids:
for piece_id in piece_ids:
piece = Piece.objects.get(id=piece_id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self):\n\n self.last_move = \"\"\n self.collision_boxes = []\n self.removed=True",
"def cleanup():\n for s in [missiles, explosions, bonus]:\n\n set_to_remove = set([])\n for m in s:\n if m.isDead:\n set_to_remove.add(m)\n\n s.diff... | [
"0.6470994",
"0.6425851",
"0.62920344",
"0.6288042",
"0.6258132",
"0.6229627",
"0.6101993",
"0.60076535",
"0.5923661",
"0.5889699",
"0.58717966",
"0.5864233",
"0.5862817",
"0.5850624",
"0.5848518",
"0.5805459",
"0.57971436",
"0.5693003",
"0.5670985",
"0.5643173",
"0.56038904"... | 0.7426205 | 0 |
Add movements and pieces to a collection | def add_pieces_and_movements_to_collection(collection_id, piece_ids, movement_ids):
collection = Collection.objects.get(id=collection_id)
for piece_id in piece_ids:
piece = Piece.objects.get(id=piece_id)
collection.add(piece)
for movement_id in movement_ids:
m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_items(self):\n # -- item list\n item = ['S','H','R','M', 'B', 'C']\n # -- loops through item list and adds them to the maze\n for i in item:\n x_coordinate, y_coordinate = self.find_random_spot()\n self.grid[x_coordinate][y_coordinate] = i",
"def move_bui... | [
"0.59854627",
"0.591115",
"0.58952945",
"0.58847404",
"0.57982355",
"0.57893485",
"0.5754489",
"0.5632621",
"0.5629613",
"0.5607626",
"0.5607626",
"0.5607626",
"0.555832",
"0.5551766",
"0.5509805",
"0.54961246",
"0.5479576",
"0.5450347",
"0.54390186",
"0.54343265",
"0.5422357... | 0.7570805 | 0 |
Given a PATCH request, update a collection. | def collection_update(request, *args, **kwargs):
patch_data = request.data
# Extract form data and validate
form = CollectionForm(patch_data)
if not form.is_valid():
data = json.dumps({"errors": form.errors})
return HttpResponse(content=data, content_type="application/json", status=statu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def updateCollection(self, id=None, body=\"\"):\n payload = {}\n \n if id:\n payload[\"id\"] = id\n \n\n # Parameter validation\n schema = CatalogValidator.updateCollection()\n schema.dump(schema.load(payload))\n \n # Body validation\n... | [
"0.6855529",
"0.6575179",
"0.64411616",
"0.63723576",
"0.6207774",
"0.6190242",
"0.61611605",
"0.6104656",
"0.61033136",
"0.61009985",
"0.6056561",
"0.6041736",
"0.60117584",
"0.5987228",
"0.598022",
"0.5971625",
"0.59222186",
"0.59146017",
"0.5880428",
"0.58603644",
"0.58537... | 0.80087805 | 0 |
Replace ZH nums to digit in String | def zh_num2digit(string):
for match in zh_nums_iter(string):
num_str = match.group(0)
digit_num = parse_zh_num(num_str)
if digit_num is None:
continue
string = string.replace(num_str, str(digit_num), 1)
return string | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(s):\r\n return 'digit ' + str(s)",
"def transform(s):\n return 'digit ' + str(s)",
"def clean_num(quote):\n for char in ROMAN:\n quote = quote.replace(*char)\n return quote",
"def replace_digits(text):\n text = re.sub('[0-9]', '5', text)\n return text",
"def replace_d... | [
"0.66811776",
"0.65797544",
"0.6390311",
"0.63456035",
"0.63191813",
"0.62078977",
"0.6181136",
"0.61374396",
"0.61057967",
"0.60990083",
"0.60009784",
"0.5998775",
"0.59865177",
"0.59686154",
"0.58336943",
"0.5795537",
"0.5794685",
"0.57726485",
"0.5771884",
"0.5755248",
"0.... | 0.77277046 | 0 |
Main function. Read coordinates, fetch addresses and write on file. | def main():
logfile = open(LOGNAME, "r")
datafile = open(DATANAME, "w")
logfile.readline() # first line is always a date
print("fetching addresses...")
line = logfile.readline()
while not line.startswith("***") and line.strip():
cat, lat, lng = line.split(';')
latlng = "%s,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dumpCoordinatesToFile(self, coordinate_ids): \n coordinate_ids_dump_file = open(self.COORDINATES_DUMP_FNAME , 'w')\n pickle.dump(coordinate_ids, coordinate_ids_dump_file)\n coordinate_ids_dump_file.close()",
"def write_to(self, filename):\n with open(filename, 'w') as f:\n ... | [
"0.61419386",
"0.60748714",
"0.6067429",
"0.6007677",
"0.59221876",
"0.5869504",
"0.5842565",
"0.58059776",
"0.57933897",
"0.5789422",
"0.5782631",
"0.55447286",
"0.55437183",
"0.55203307",
"0.5519414",
"0.55171824",
"0.551527",
"0.5498949",
"0.5487832",
"0.54840785",
"0.5470... | 0.6792019 | 0 |
Helper function to clean up details field. | def clean_up_details(self, w_details):
for i, val in enumerate(w_details):
for k in ('when', 'where', 'why'):
clean_text = [x.strip() for x in val[k]]
clean_text = '\n'.join(clean_text)
w_details[i][k] = clean_text.strip()
yield w_details | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alter_details(self, parsed_details_df):\n\n parsed_details_df = parsed_details_df[~pandas.isnull(parsed_details_df.key)]\n parsed_details_df[\"key\"] = parsed_details_df[\"key\"].apply(lambda key: key.replace(\":\", \"\").strip().upper())\n parsed_details_df[\"key\"] = parsed_details_df[\"... | [
"0.61837876",
"0.6182386",
"0.6114121",
"0.6021938",
"0.5857197",
"0.5735668",
"0.57194394",
"0.56944895",
"0.565618",
"0.5617164",
"0.55702287",
"0.5557195",
"0.55525196",
"0.5546854",
"0.5542905",
"0.5520142",
"0.55086",
"0.54694897",
"0.54388785",
"0.5415089",
"0.5408741",... | 0.649685 | 0 |
Compute numerical Jacobian for fhandle, evaluated at x fhandle should accept a lengthN array, and optional kwargs arguments Examples >>> f = sin >>> x = array([pi]) >>> J = numerical_jacobian (f, x) | def numerical_jacobian (fhandle, x, **args):
y = fhandle (x, **args)
numRows, numCols = (len (y), len (x))
J = np.zeros ((numRows, numCols))
for col in range (0, numCols):
xPrime = x.copy ()
deltaX = max (1e-4*x[col], 1e-6)
xPrime[col] += deltaX
yPrime = fhandle (xP... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jacobian_func(f):\n jacobian = jacfwd(f)\n return jacobian",
"def JacobianFunction(p,x,y,z):\n \n n = len(x)\n \n J = np.array([ np.ones((n)),x,x**2,y,y**2,x*y ])\n \n return J",
"def jacobian(f, x, dx):\n x = np.atleast_1d(x)\n dx = np.atleast_1d(dx)\n nx = len(x)\n ny ... | [
"0.70952415",
"0.707327",
"0.70496637",
"0.6982996",
"0.6950513",
"0.68983436",
"0.68001777",
"0.67485833",
"0.6734966",
"0.6734966",
"0.6689383",
"0.6620427",
"0.6614494",
"0.6594359",
"0.65864044",
"0.6581291",
"0.6581123",
"0.65613747",
"0.64126307",
"0.6404477",
"0.639519... | 0.8318865 | 0 |
Handler for responding to health requests. Update the env variable STATUS to failover | def handle_health(event, context):
LOGGER.info("Received event in handle_health:")
response = {"statusCode": os.environ["STATUS"]}
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_health():\n return flask.jsonify(status=\"up\")",
"def health_check():\n app.logger.info(\"Health Check!\")\n return Response(\"All Good!\", status=200)",
"def _healthcheck():\n return '', 200",
"def test_health(self) -> None:\n self._response = self._app.get('/health')\n\n ... | [
"0.70876193",
"0.64707017",
"0.64562917",
"0.6279178",
"0.62484676",
"0.6214639",
"0.6171909",
"0.61317724",
"0.6057038",
"0.6041157",
"0.60240364",
"0.6005561",
"0.6005561",
"0.6003657",
"0.5970314",
"0.59210503",
"0.590608",
"0.58939934",
"0.586789",
"0.58395344",
"0.583727... | 0.7628448 | 0 |
`phrases` should be a list of `Datapoint` instances. Return value is a `float` with the classification accuracy of the input. | def score(self, phrases):
pred = self.predict(phrases)
return accuracy_score(preprocessor.getLabels(phrases), pred) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score(self, phrases):\n pred = self.predict(phrases)\n return accuracy_score(target(phrases), pred)",
"def accuracy(targets: List[List[float]], predict: List[List[float]]):\r\n correct = 0\r\n for i in range(len(targets)):\r\n if predict[i] == targets[i]:\r\n correct += ... | [
"0.76608497",
"0.607119",
"0.5942941",
"0.5911096",
"0.5870916",
"0.5859185",
"0.5855325",
"0.58411443",
"0.58249676",
"0.5817627",
"0.5810849",
"0.57579565",
"0.5740406",
"0.5713754",
"0.5697977",
"0.5694859",
"0.5694859",
"0.5681549",
"0.56579024",
"0.5653497",
"0.56294656"... | 0.76702684 | 0 |
Change the circle radius | def change_circle_handler():
global radius
radius = size | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changeRadius(self):\r\n self.curRadius= self.edit_rad.value()",
"def radius(self, value):\n self._radius = value",
"def setR(self, radius):\n self.radius = radius",
"def set_radius(self, radius):\n self.__begin.set_radius(radius)\n self.__end.set_radius(radius)",
"def... | [
"0.824678",
"0.7787696",
"0.76622397",
"0.76248384",
"0.75572824",
"0.751725",
"0.7312219",
"0.72665197",
"0.7238384",
"0.7238384",
"0.7226871",
"0.72183216",
"0.72051233",
"0.71735",
"0.7170175",
"0.71552086",
"0.7110383",
"0.7080974",
"0.7059398",
"0.70141095",
"0.70112014"... | 0.8152055 | 1 |
Computes the attention and alignments for a given attention_mechanism. | def _compute_attention(attention_mechanism, initial_state, previous_alignments,
attention_layer):
alignments, final_state = attention_mechanism(
initial_state, previous_alignments=previous_alignments)
# Reshape from [batch_size, memory_time] to [batch_size, 1, memory_time]
expanded_a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_attention(attention_mechanism, batch_size, cell_output, previous_alignments,\n attention_layer):\n line_alignments, word_alignments, hier_alignments = attention_mechanism(\n cell_output, batch_size, previous_alignments=previous_alignments)\n\n #... | [
"0.7277527",
"0.62178546",
"0.6159767",
"0.6057265",
"0.6031106",
"0.6030008",
"0.5954123",
"0.55970705",
"0.55942893",
"0.55094904",
"0.54671395",
"0.5413031",
"0.53786933",
"0.53512865",
"0.5349311",
"0.5259757",
"0.5242789",
"0.51720977",
"0.51137",
"0.5112552",
"0.5104999... | 0.71857405 | 1 |
Finds the Body enumeration value, given the name of a body. | def BodyCode(name):
if name not in Body.__members__:
return Body.Invalid
return Body[name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_body_index(self, body_name):\n return self.wrapper.get_body_index(self.instance, body_name.encode('utf-8'))",
"def GetBodyID(self, bodyName):\n return _gmat_py.DeFile_GetBodyID(self, bodyName)",
"def GetBodyID(self, bodyName):\n return _gmat_py.PlanetaryEphem_GetBodyID(self, bodyNa... | [
"0.6757245",
"0.58375",
"0.5817137",
"0.5451699",
"0.5389594",
"0.53451043",
"0.5309708",
"0.5248311",
"0.51827",
"0.5136425",
"0.5063406",
"0.50318384",
"0.5007284",
"0.49910948",
"0.49723566",
"0.49597338",
"0.49528095",
"0.49362987",
"0.49297586",
"0.49115744",
"0.48743743... | 0.6567144 | 1 |
The default Delta T function used by Astronomy Engine. Espenak and Meeus use a series of piecewise polynomials to approximate DeltaT of the Earth in their "Five Millennium Canon of Solar Eclipses". | def DeltaT_EspenakMeeus(ut):
# Fred Espenak writes about Delta-T generically here:
# https://eclipse.gsfc.nasa.gov/SEhelp/deltaT.html
# https://eclipse.gsfc.nasa.gov/SEhelp/deltat2004.html
# He provides polynomial approximations for distant years here:
# https://eclipse.gsfc.nasa.gov/SEhelp/deltatpo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delta_ad_ref(self, T: float):\n return self.kappa_ref * (np.exp(self.eps_ref / T) - 1.0)",
"def Delta(z):\n return (18*np.pi**2 - 82*cosmology.Ode(z) - 39*cosmology.Ode(z)**2) / cosmology.Om(z)",
"def ft(t):\r\n ft = t ** (1.0 / 3.0) if t > 0.008856 else 7.787 * t + 4 / 29\r\n return ft",
... | [
"0.6278171",
"0.615154",
"0.6132715",
"0.6116729",
"0.6101005",
"0.606665",
"0.5878255",
"0.58705986",
"0.58537763",
"0.58337575",
"0.58077294",
"0.5797316",
"0.57878405",
"0.5768267",
"0.5765204",
"0.57402927",
"0.5728629",
"0.5654885",
"0.56152415",
"0.56083447",
"0.5600682... | 0.64060634 | 0 |
Creates a Time object from a Terrestrial Time day value. | def FromTerrestrialTime(tt):
return Time(_UniversalTime(tt), tt) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Make(year, month, day, hour, minute, second):\n micro = round(math.fmod(second, 1.0) * 1000000)\n second = math.floor(second - micro/1000000)\n d = datetime.datetime(year, month, day, hour, minute, second, micro)\n ut = (d - _EPOCH).total_seconds() / 86400\n return Time(ut)",... | [
"0.6474383",
"0.61523044",
"0.6067214",
"0.6027647",
"0.59449834",
"0.5933558",
"0.5910248",
"0.5798117",
"0.5692651",
"0.55954504",
"0.55763704",
"0.54977894",
"0.5451362",
"0.5434837",
"0.541794",
"0.5403912",
"0.54034024",
"0.533974",
"0.5318634",
"0.5294982",
"0.5265611",... | 0.7069213 | 0 |
Calculates the sum or difference of a Time with a specified realvalued number of days. Sometimes we need to adjust a given Time value by a certain amount of time. This function adds the given real number of days in `days` to the date and time in the calling object. More precisely, the result's Universal Time field `ut`... | def AddDays(self, days):
return Time(self.ut + days) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(dt, days=0, seconds=0):\n return dt + datetime.timedelta(days=days, seconds=seconds)",
"def createTime(days=1):\r\n return (int(round(time.time() * 1000))-(days*24*60*60*1000))",
"def get_duration(days=0, hours=0, minutes=0, seconds=0, millis=0):\n\n duration = 0.0\n\n duration += float... | [
"0.63739866",
"0.59929717",
"0.56505406",
"0.5608996",
"0.5458899",
"0.54284775",
"0.5291317",
"0.5282331",
"0.51794803",
"0.5146342",
"0.5144961",
"0.5116093",
"0.5087108",
"0.5067682",
"0.50283223",
"0.50251454",
"0.4981476",
"0.49095318",
"0.4903236",
"0.47857204",
"0.4783... | 0.7383214 | 0 |
Calculates the geocentric position of the Moon at a given time. Given a time of observation, calculates the Moon's position as a vector. The vector gives the location of the Moon's center relative to the Earth's center with x, y, and zcomponents measured in astronomical units. This algorithm is based on Nautical Almana... | def GeoMoon(time):
m = _CalcMoon(time)
# Convert geocentric ecliptic spherical coordinates to Cartesian coordinates.
dist_cos_lat = m.distance_au * math.cos(m.geo_eclip_lat)
gepos = [
dist_cos_lat * math.cos(m.geo_eclip_lon),
dist_cos_lat * math.sin(m.geo_eclip_lon),
m.distance_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _P(time='now'):\n obstime = parse_time(time)\n\n # Define the frame where its Z axis is aligned with geocentric north\n geocentric = PrecessedGeocentric(equinox=obstime, obstime=obstime)\n\n return _sun_north_angle_to_z(geocentric)",
"def moonlongitude(time):\n B0 = 481267.8809\n C0 = 218.3... | [
"0.664575",
"0.6568932",
"0.649876",
"0.64341336",
"0.6145739",
"0.6068177",
"0.6019891",
"0.59832555",
"0.5977066",
"0.59603876",
"0.59515184",
"0.58962613",
"0.58625317",
"0.58507663",
"0.57751584",
"0.57366526",
"0.5723073",
"0.57012475",
"0.5677163",
"0.5665257",
"0.56149... | 0.68728316 | 0 |
Calculates the distance between a body and the Sun at a given time. Given a date and time, this function calculates the distance between the center of `body` and the center of the Sun. For the planets Mercury through Neptune, this function is significantly more efficient than calling HelioVector followed by taking the ... | def HelioDistance(body, time):
if body == Body.Sun:
return 0.0
if 0 <= body.value < len(_vsop):
return _VsopHelioDistance(_vsop[body.value], time)
return HelioVector(body, time).Length() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AngleFromSun(body, time):\n if body == Body.Earth:\n raise EarthNotAllowedError()\n sv = GeoVector(Body.Sun, time, True)\n bv = GeoVector(body, time, True)\n return AngleBetween(sv, bv)",
"def _earth_distance(time='now'):\n return get_earth(time).radius",
"def SearchTransit(body, star... | [
"0.65268666",
"0.6315929",
"0.61403096",
"0.6064754",
"0.5929561",
"0.5763094",
"0.5761787",
"0.56833977",
"0.5626337",
"0.55923057",
"0.54604024",
"0.54516995",
"0.53563565",
"0.53158194",
"0.5305572",
"0.5261689",
"0.52418727",
"0.5213546",
"0.51740557",
"0.50837153",
"0.50... | 0.6960984 | 0 |
Calculates equatorial coordinates of a celestial body as seen by an observer on the Earth's surface. | def Equator(body, time, observer, ofdate, aberration):
gc_observer = _geo_pos(time, observer)
gc = GeoVector(body, time, aberration)
j2000 = [
gc.x - gc_observer[0],
gc.y - gc_observer[1],
gc.z - gc_observer[2]
]
if not ofdate:
return _vector2radec(j2000, time)
te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _position_to_ECEF(self, latitude, longitude, altitude):\n\n # Convert the position to cartesian coordinates in the ECEF frame.\n angular_latitude = radians(latitude)\n angular_longitude = radians(longitude)\n a = 6378137.0 # Earth's semi-major axis (meters)\n f = 1/298.257223563 # Reciprocal fla... | [
"0.6263922",
"0.61497617",
"0.6112122",
"0.60302675",
"0.59933054",
"0.5974637",
"0.59005386",
"0.58623946",
"0.5847565",
"0.58004224",
"0.5771312",
"0.57018155",
"0.56987035",
"0.56945324",
"0.56408775",
"0.5631874",
"0.5605876",
"0.55781645",
"0.5563956",
"0.5541898",
"0.55... | 0.6405329 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.