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 |
|---|---|---|---|---|---|---|
Make variable `x` arc consistent with variable `y`. To do so, remove values from `self.domains[x]` for which there is no possible corresponding value for `y` in `self.domains[y]`. Return True if a revision was made to the domain of `x`; return False if no revision was made. | def revise(self, x, y):
revision= False
#creates a list of words in the domain of node x to remove since we cannot remove the elements in a set while it is iterating
words_to_remove= []
#function which returns data of where the two nodes intersect/overlap
overlap= self.crossword.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revise(self, x, y):\n # return set a default return value of False\n ret_val = False\n # define a tuple of the two variables without their domains\n var_tup = (x, y)\n # define lists of the variable's domains\n x_values = self.domains[x].copy()\n y_values = self... | [
"0.72537684",
"0.61475664",
"0.56745136",
"0.5599615",
"0.5347956",
"0.5329685",
"0.52662617",
"0.5173786",
"0.5155555",
"0.51406",
"0.51286644",
"0.5128506",
"0.50754297",
"0.49844116",
"0.49676445",
"0.49673513",
"0.49446192",
"0.49185714",
"0.49106404",
"0.4895251",
"0.488... | 0.62897676 | 1 |
Update `self.domains` such that each variable is arc consistent. If `arcs` is None, begin with initial list of all arcs in the problem. Otherwise, use `arcs` as the initial list of arcs to make consistent. Return True if arc consistency is enforced and no domains are empty; return False if one or more domains end up em... | def ac3(self, arcs=None):
if arcs == None:
#creates a queue of arcs to update
arcs= []
for node1 in self.domains:
for node2 in self.domains:
if node1 != node2:
#for each pair of nodes that intersect, add them as a tu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ac3(self, arcs=None):\n if arcs is None:\n arcs = [arc for arc in self.crossword.overlaps if arc is not None]\n while len(arcs) != 0:\n (x, y) = arcs.pop()\n if self.revise(x, y):\n if len(self.domains[x]) == 0:\n return False\n ... | [
"0.697806",
"0.66046983",
"0.6538867",
"0.5821814",
"0.5819417",
"0.55781376",
"0.55291146",
"0.5477376",
"0.5417974",
"0.53960216",
"0.5292191",
"0.51719123",
"0.51084673",
"0.50994927",
"0.50911343",
"0.50407743",
"0.49690744",
"0.4908007",
"0.48773026",
"0.48707816",
"0.48... | 0.7342542 | 0 |
Return an unassigned variable not already part of `assignment`. Choose the variable with the minimum number of remaining values in its domain. If there is a tie, choose the variable with the highest degree. If there is a tie, any of the tied variables are acceptable return values. | def select_unassigned_variable(self, assignment):
var_list= []
#add unassigned variabled to a list along with the number of words left in its domain
for var in self.domains:
if var not in assignment:
var_list.append((var, len(self.domains[var])))
#sort this li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_unassigned_variable(csp:list,assignment:set,method=0) -> variable:\n if(method not in range(3)):\n return \"method out of bounds\"\n \n if(method == 0):\n y = rdint(0,len(csp)-1) #rdint is inclusive, hence the -1\n var = csp[y]\n while(var in assignment):\n ... | [
"0.7858036",
"0.77797157",
"0.768338",
"0.7355039",
"0.7146354",
"0.70380086",
"0.70368797",
"0.6704249",
"0.6679745",
"0.6554601",
"0.6264921",
"0.61608946",
"0.60479784",
"0.60293525",
"0.5977383",
"0.58422977",
"0.56521744",
"0.55985475",
"0.55530345",
"0.55304563",
"0.552... | 0.8013063 | 0 |
Get all dirs for all patients | def get_patient_dirs(base_folder):
patient_dirs = sorted([x for x in base_folder.iterdir() if x.is_dir()])
return patient_dirs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_dirs(self):\n return self.list_groups()",
"def listdirs(self):\n return self.list_groups()",
"def get_directories(self):\n\t\tdirectories = []\n\t\tfor i in range(self.directoryModel.get_row_count()):\n\t\t\tdirectories.append((\n\t\t\t\t\tself.directoryModel.get_value(i, 'directoryTagNa... | [
"0.72177607",
"0.7202697",
"0.70397073",
"0.6985216",
"0.6945787",
"0.68784386",
"0.68418944",
"0.68014354",
"0.67790097",
"0.66683537",
"0.6665189",
"0.6595028",
"0.65714353",
"0.655507",
"0.65258414",
"0.6524022",
"0.6497728",
"0.64369375",
"0.64231855",
"0.6416372",
"0.640... | 0.7753402 | 0 |
Print a success message. The message is colourized with the preset 'success' mode. | def print_success(msg):
colour.cprint(msg, 'success')
sys.stdout.flush() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def success(self, message=''):\n print(colored(message, 'green'))",
"def success(msg):\n click.secho(msg, fg='green')",
"def success(message):\n if DEBUG:\n with print_lock:\n print((Colours.OK_GREEN + 'SUCCESS: ' + Colours.END_COLOUR + message).strip())",
"def print_succes... | [
"0.8902448",
"0.84369403",
"0.83978236",
"0.83409965",
"0.8321712",
"0.8294244",
"0.8240409",
"0.8235121",
"0.7823651",
"0.7756721",
"0.7423129",
"0.73871887",
"0.73582214",
"0.73498464",
"0.7226085",
"0.7042724",
"0.7018427",
"0.6959702",
"0.6881999",
"0.68017226",
"0.677308... | 0.8654305 | 1 |
Verifies that is_url adequately discovers a url | def test_is_url(self):
url = "https://shadowrun.needs.management"
self.assertTrue(run(verification.is_url(url)))
url = "https:// www.google.com"
self.assertFalse(run(verification.is_url(url))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_url(self):\n pass",
"def check_url_invalidity(self) -> bool:\n validate = URLValidator()\n try:\n validate(self.args.url)\n return False\n except ValidationError:\n return True",
"def is_url(self, url):\n return self.is_regex_url(... | [
"0.80692613",
"0.77548784",
"0.7742507",
"0.7677521",
"0.7673419",
"0.76647466",
"0.76245844",
"0.760002",
"0.7591701",
"0.746391",
"0.745363",
"0.7450952",
"0.7417373",
"0.74152166",
"0.7409876",
"0.7392937",
"0.73589176",
"0.732994",
"0.7320073",
"0.72888374",
"0.72865677",... | 0.80367756 | 1 |
Return the best fit line for an array of corners. This function returns an tuple of (m, b), where the best fit line is represented by y = mx + b. | def get_corner_line(corners):
corner_xs = [c[0] for c in corners]
corner_ys = [c[1] for c in corners]
return tuple(np.polyfit(x=corner_xs, y=corner_ys, deg=1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_two_corner_line(corners):\n x1, y1 = corners[0]\n x2, y2 = corners[1]\n\n m = (y1 - y2) / (x1 - x2)\n # Since y - y1 = m(x - x1)\n # y = m(x - x1) + y1\n # y = mx - mx1 + y1\n b = -m * x1 + y1\n return (m, b)",
"def closest_line_point(point:tuple, edge:tuple)->tuple:\n... | [
"0.6537235",
"0.56714416",
"0.55728614",
"0.55728614",
"0.55578935",
"0.54949677",
"0.5462594",
"0.54581445",
"0.5416722",
"0.5385558",
"0.5352758",
"0.5341869",
"0.5306058",
"0.52829087",
"0.5174351",
"0.51693475",
"0.51661116",
"0.51635504",
"0.5129694",
"0.5097066",
"0.508... | 0.72546905 | 0 |
Return the line that contains the two given corners. This function returns an tuple of (m, b), where the best fit line is represented by y = mx + b. | def get_two_corner_line(corners):
x1, y1 = corners[0]
x2, y2 = corners[1]
m = (y1 - y2) / (x1 - x2)
# Since y - y1 = m(x - x1)
# y = m(x - x1) + y1
# y = mx - mx1 + y1
b = -m * x1 + y1
return (m, b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_corner_line(corners):\n corner_xs = [c[0] for c in corners]\n corner_ys = [c[1] for c in corners]\n return tuple(np.polyfit(x=corner_xs, y=corner_ys, deg=1))",
"def closest_line_point(point:tuple, edge:tuple)->tuple:\n d_y, d_x, b = line_equation((edge[0], edge[1]))\n if b == None:\n ... | [
"0.7192746",
"0.66275424",
"0.65080535",
"0.6457784",
"0.6255394",
"0.6246811",
"0.62336004",
"0.61887974",
"0.61093336",
"0.6096381",
"0.60851496",
"0.60836536",
"0.6051689",
"0.6050981",
"0.60425997",
"0.60277164",
"0.60094845",
"0.59796906",
"0.5935358",
"0.59309554",
"0.5... | 0.8239188 | 0 |
Return the top corners for the given rectangles, sorted by their x positions in ascending order. | def get_top_corners(corners):
top_corners = np.concatenate(
[sorted(rect, key=getY)[:2] for rect in corners])
return sorted(top_corners, key=getX) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bottom_corners(corners):\n bottom_corners = np.concatenate(\n [sorted(rect, key=getY)[2:] for rect in corners])\n return sorted(bottom_corners, key=getX)",
"def sort_corners(corners):\n col_sorted = corners[np.argsort(corners[:, 1])] # sort on the value in column\n\n # sort on the valu... | [
"0.72246605",
"0.64537203",
"0.6431297",
"0.6431297",
"0.63572353",
"0.6329216",
"0.6297449",
"0.6252153",
"0.61172265",
"0.60972667",
"0.60818714",
"0.6055741",
"0.5998458",
"0.59686154",
"0.59229404",
"0.58925796",
"0.5891909",
"0.5867505",
"0.58580106",
"0.58476514",
"0.58... | 0.82502043 | 0 |
Return the bottom corners for the given rectangles, sorted by their x positions in ascending order. | def get_bottom_corners(corners):
bottom_corners = np.concatenate(
[sorted(rect, key=getY)[2:] for rect in corners])
return sorted(bottom_corners, key=getX) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top_corners(corners):\n top_corners = np.concatenate(\n [sorted(rect, key=getY)[:2] for rect in corners])\n return sorted(top_corners, key=getX)",
"def _find_bboxes_on_rect_edge(bboxes, left, bottom, right, top):\n bboxes_left = _find_bboxes_in_rect(bboxes, left, bottom, left, top)\n b... | [
"0.6855785",
"0.6544617",
"0.6361645",
"0.63508916",
"0.6320496",
"0.63150394",
"0.6259236",
"0.6109852",
"0.60978025",
"0.6016202",
"0.60144717",
"0.5969408",
"0.5954442",
"0.5940534",
"0.5896087",
"0.5890453",
"0.5881247",
"0.58622795",
"0.58411974",
"0.58325493",
"0.580238... | 0.8297772 | 0 |
Return the four intersection points for the four given lines whose enclosed shape is a quadrilateral. | def get_intersection_points(lines, debug_img=None):
# Convert [a,b,c,d] to [(a,b), (b,c), (c,d), (d,a)]
line_pairs = list(zip(lines, lines[1:]+lines[:1]))
corners = [get_intersection_point(*p) for p in line_pairs]
if debug_img is not None:
int_corners = np.array(corners, np.int32)
dra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _intersection(line_points_0, line_points_1):\n u,v = line_points_0,line_points_1\n (A,B),(C,D) = line_points_0,line_points_1\n h1 = _homogenous_line(A,B)\n h2 = _homogenous_line(C,D)\n P = _intersection_homogenous(h1, h2)\n return P",
"def line_intercept(p1,p2,p3,p4):\n # Note if vertica... | [
"0.66376084",
"0.64503473",
"0.6378339",
"0.62303376",
"0.61068225",
"0.6057025",
"0.604978",
"0.6033074",
"0.60263664",
"0.6014564",
"0.5980057",
"0.5948861",
"0.5915143",
"0.5889566",
"0.5873115",
"0.5860854",
"0.58362013",
"0.5821021",
"0.58049184",
"0.5804329",
"0.5802114... | 0.68249494 | 0 |
Return the locations of the four outside corners of two pieces of tape. The given corners should be a 3D array of shape (2, 4, 2). | def get_outside_corners(tape_corners, debug_img=None):
lines = get_lines(tape_corners, debug_img)
return get_intersection_points(lines, debug_img) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_enclosing_box(corners):\n x_ = corners[:, [0, 2, 4, 6]]\n y_ = corners[:, [1, 3, 5, 7]]\n\n xmin = np.min(x_, 1).reshape(-1, 1)\n ymin = np.min(y_, 1).reshape(-1, 1)\n xmax = np.max(x_, 1).reshape(-1, 1)\n ymax = np.max(y_, 1).reshape(-1, 1)\n\n final = np.hstack((xmin, ymin, xmax, yma... | [
"0.668142",
"0.6418847",
"0.6416916",
"0.6244235",
"0.6214465",
"0.61546284",
"0.60900635",
"0.60504276",
"0.6007057",
"0.60024714",
"0.59885544",
"0.5940592",
"0.5910942",
"0.5910196",
"0.59010154",
"0.5899891",
"0.5890469",
"0.58770394",
"0.58294135",
"0.5825287",
"0.581142... | 0.7617275 | 0 |
Configure logging and start the given root component in the default asyncio event loop. Assuming the root component was started successfully, the event loop will continue running until the process is terminated. | def run_application(
component: Component | dict[str, Any],
*,
event_loop_policy: str | None = None,
max_threads: int | None = None,
logging: dict[str, Any] | int | None = INFO,
start_timeout: int | float | None = 10,
) -> None:
# Configure the logging system
if isinstance(logging, dict)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def startLoop(self):\n if(self.loop is not None):\n raise Exception(\"Event loop is already started!\")\n self.loop = asyncio.new_event_loop()\n self.thread = Thread(target=start_thread_loop, args=(self.loop,))\n self.thread.setDaemon(True)\n self.thread.start()",
"d... | [
"0.6238439",
"0.61393946",
"0.611499",
"0.6053485",
"0.60262555",
"0.60262555",
"0.60262555",
"0.60262555",
"0.59933645",
"0.5989668",
"0.59279275",
"0.59279275",
"0.59089136",
"0.5832428",
"0.58323336",
"0.5828315",
"0.577314",
"0.5772625",
"0.5767474",
"0.5720727",
"0.57056... | 0.64416605 | 0 |
Env wrapper that returns a previous observation with probability `p` and the current observation with a probability `1p`. `last_k` previous observations are stored. | def __init__(self, env: gym.Env, sticky_probability: float, last_k: int):
super().__init__(self, env)
if 1 >= sticky_probability >= 0:
self._sticky_probability = sticky_probability
else:
raise ValueError(
f"sticky_probability = {sticky_probability} is not ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prior_predictive(self):\n cfg = self.config\n n = cfg['batch_size'] * cfg['q/n_samples']\n n_samples = cfg['q/n_samples']\n with util.get_or_create_scope('model', reuse=True):\n h_prior = tf.cast(self.p_h_L.sample(n), cfg['dtype'])\n h_prior = tf.reshape(\n h_prior, [cfg['q/n_sam... | [
"0.58422875",
"0.54212475",
"0.52596",
"0.5250174",
"0.5237888",
"0.52241963",
"0.51826686",
"0.51438004",
"0.5091699",
"0.5071481",
"0.50413746",
"0.5002886",
"0.49614602",
"0.49575868",
"0.49465007",
"0.49387398",
"0.49345186",
"0.4924787",
"0.4917048",
"0.49155378",
"0.490... | 0.54807967 | 1 |
Whether a given date was a national holiday in Russia or not. Note that | def is_russian_2017_holiday(date):
return int(date in russian_2017_holidays) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_holiday(self) -> bool:\n return set(self._get_date_text_ascii()) == set([int(x) for x in self.params['holiday']['holiday_text']])",
"def is_holiday(date):\n \n return date.day in __get_holidays(date.year)[date.month]",
"def is_holdiay_eve(self) -> bool:\n return set(self._get_date_text_a... | [
"0.6789658",
"0.6643774",
"0.6560776",
"0.65457046",
"0.6450233",
"0.6288142",
"0.62529993",
"0.61944073",
"0.6164654",
"0.6029024",
"0.5960723",
"0.59589493",
"0.5914349",
"0.58579916",
"0.5849306",
"0.5829556",
"0.579306",
"0.57718164",
"0.575902",
"0.57510203",
"0.56402165... | 0.79085565 | 0 |
Wrapper function that is identical to the fit method of TPOTClassifier or TPOTRegressor. The purpose is to store the feature and target and use it in other methods of TpotAutoml | def fit(self, features, target, **kwargs):
self.features = features
self.target = target
super(tpot_class, self).fit(features, target, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _tpot_class_wrapper(tpot_class, **kwargs):\n class TpotWrapper(tpot_class):\n\n def __init__(self, **kwargs):\n self.models = None\n self.top_models = OrderedDict()\n self.top_models_scores = OrderedDict()\n self.feature_names = kwargs.pop('feature_names',... | [
"0.6884765",
"0.6830542",
"0.6377049",
"0.62612563",
"0.6105336",
"0.6039189",
"0.6004048",
"0.6004048",
"0.6004048",
"0.6004048",
"0.6004048",
"0.6004048",
"0.6004048",
"0.6004048",
"0.6004048",
"0.6004048",
"0.59704757",
"0.59669846",
"0.59105855",
"0.58675325",
"0.584849",... | 0.7931605 | 0 |
Determines whether scoring_function being greater is more favorable/better. | def is_greater_better(scoring_function):
if scoring_function in [
'accuracy', 'adjusted_rand_score', 'average_precision',
'balanced_accuracy','f1', 'f1_macro', 'f1_micro', 'f1_samples',
'f1_weighted', 'precision', 'precision_macro', 'precision_micro',
'precision_samples','precision_w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def important_features_(self):\n return self.scores_ > self.score_cutoff_",
"def is_better(self, curr, best, **kwargs):\r\n score_threshold = kwargs.pop('score_threshold', 1e-3)\r\n relative_eps = 1.0 + score_threshold\r\n return curr >= best*relative_eps",
"def scoring(estimator, f... | [
"0.69573057",
"0.66306347",
"0.65871125",
"0.65782106",
"0.6549409",
"0.6295534",
"0.6192134",
"0.61666864",
"0.60578316",
"0.5975691",
"0.59255445",
"0.59239906",
"0.5923861",
"0.5922167",
"0.58855665",
"0.5839649",
"0.58306843",
"0.58135617",
"0.5813444",
"0.5792933",
"0.57... | 0.8249342 | 0 |
Create a JSON configuration file | def create_config_file(name):
config = {}
config['name'] = name
to_dir = os.getcwd() + '/' + name
with open(os.path.join(to_dir, 'configuration.json'), 'w') as config_file:
json.dump(config, config_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createConfig():\n\twith open(configPath, 'w', encoding='utf-8') as file:\n\t\tjson.dump(default_config, file, indent=3)",
"def save_config_to_json(config, filename):\n with open(filename, 'w+') as f:\n json.dump(vars(config), f)",
"def write_to_json(config: dict, filename: str):\n\n with open(... | [
"0.79925877",
"0.75612205",
"0.7511189",
"0.75044733",
"0.72702944",
"0.7265625",
"0.7182749",
"0.715349",
"0.7092775",
"0.707714",
"0.70369494",
"0.69433916",
"0.6888235",
"0.68808824",
"0.6878264",
"0.68310314",
"0.68270767",
"0.68089056",
"0.67931706",
"0.6792589",
"0.6791... | 0.79342985 | 1 |
Test that N/A values (None, numpy.nan) are handled consistently when using CSV vs Arrow as a prediction payload format. 1. Make CSV and Arrow prediction payloads from the same dataframe 2. Read both payloads 3. Assert the resulting dataframes are equal | def test_read_structured_input_arrow_csv_na_consistency(tmp_path):
# arrange
df = pd.DataFrame({"col_int": [1, np.nan, None], "col_obj": ["a", np.nan, None]})
csv_filename = os.path.join(tmp_path, "X.csv")
with open(csv_filename, "w") as f:
f.write(df.to_csv(index=False))
arrow_filename =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build_dataframe(self):\n insert_good_data()\n dataframe = get_dataframe()\n # 1 2 3\n self.assertIs(type(dataframe['Total'][0]), numpy.float64)\n self.assertIs(type(dataframe['InvoiceDate'][0]), str)\n self.assertIs(type(dataframe['Count'][0]), numpy.int64)\n ... | [
"0.61763406",
"0.6114238",
"0.6098677",
"0.60721225",
"0.607004",
"0.60079575",
"0.59785664",
"0.59550744",
"0.59273005",
"0.5888702",
"0.58884233",
"0.5882254",
"0.5847906",
"0.58434826",
"0.58389467",
"0.5829927",
"0.5829745",
"0.5829139",
"0.5826037",
"0.58072144",
"0.5796... | 0.8162266 | 0 |
Download poety from all the given sockets. | def get_poetry(sockets):
poems = dict.fromkeys(sockets, '') # socket -> accumulated poem
# socket -> task numbers
sock2task = dict([(s, i + 1) for i, s in enumerate(sockets)])
sockets = list(sockets) # make a copy
# we go around this loop until we've gotten all the poetry
# from all the sock... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download(all):\n print(\"Downloading\")",
"def download_all(self):\r\n # Fetch website list\r\n self.fetch_website_list()\r\n\r\n for website in self.website_list:\r\n self.download(website['id'])",
"def download_all(): #@save\n for name in DATA_HUB:\n download... | [
"0.597947",
"0.5712714",
"0.56852627",
"0.55428046",
"0.5412574",
"0.54029894",
"0.5342332",
"0.52104944",
"0.51643366",
"0.51460445",
"0.51378787",
"0.51278406",
"0.5093799",
"0.50765353",
"0.50118536",
"0.50106645",
"0.5005506",
"0.4997957",
"0.49917343",
"0.49816757",
"0.4... | 0.5779937 | 1 |
Reads in the header of a csv file. | def read_csv_header(input_file_path):
return pd.read_csv(input_file_path, nrows=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_header_csv(csv_file, cols_delimiter):\n\n with open(csv_file, \"r\") as f:\n reader = csv.reader(f, delimiter=cols_delimiter)\n header_csv = next(reader)\n \n return header_csv",
"def read_header(in_file, num_header_rows, sep_type =\"\"):\n\n if sep_type==\"\":\n header=p... | [
"0.73939955",
"0.7053554",
"0.690674",
"0.6880877",
"0.68568385",
"0.6815991",
"0.6812786",
"0.6664034",
"0.66586417",
"0.6636548",
"0.66146225",
"0.65964097",
"0.6591992",
"0.6580241",
"0.65409005",
"0.6530811",
"0.647564",
"0.6435216",
"0.6399741",
"0.63637966",
"0.63596904... | 0.79246676 | 0 |
Reads in a csv file, and attempts to use the date format that is specified in the config file. The date columns it uses are the ones that are specified by the date_cols, first_exp_date_cols, last_exp_date_cols, index_date_col and lookback_date_col params in the general section of the YAML config. Depending on the size ... | def read_csv(config, input_file_path):
header = read_csv_header(input_file_path)
general = config['general']
date_cols_types = ['date_cols',
'first_exp_date_cols',
'last_exp_date_cols',
'index_date_col',
'lookback_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_csv(filename, cols=None, nrows=None):\n\n datecols = ['date_time', 'srch_ci', 'srch_co']\n dateparser = lambda x: pd.to_datetime(x, format='%Y-%m-%d %H:%M:%S',\n errors='coerce')\n dtypes = {\n 'id': np.uint32,\n 'site_name': np.uint8,\n ... | [
"0.6603744",
"0.63429946",
"0.6218511",
"0.6102293",
"0.5955655",
"0.5928705",
"0.5911065",
"0.5899069",
"0.5893626",
"0.5856462",
"0.5846206",
"0.58219165",
"0.5812324",
"0.5803114",
"0.5790189",
"0.5768531",
"0.5740227",
"0.57401526",
"0.5727228",
"0.5662731",
"0.56017125",... | 0.75805265 | 0 |
arr1 and arr2 are well sorted array, | def merge(arr1, arr2):
res = []
i = j = 0
while i< len(arr1) and j < len(arr2):
if arr1[i] < arr2[j]:
res.append(arr1[i])
i+=1
else:
res.append(arr2[j])
j+=1
while i < len(arr1):
res.append(arr1[i])
i +=1
while j < len(arr2):
j +=1
res.append(arr2[j])
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relativeSortArray(self, arr1, arr2):\n\n dict_sort = {}\n list_total = []\n list_diffs = []\n for i in arr2:\n dict_sort[i] = 0\n\n for i in arr1:\n if i in dict_sort:\n dict_sort[i] +=1\n else:\n list_diffs.appen... | [
"0.75161135",
"0.73150843",
"0.71608377",
"0.70064276",
"0.69264805",
"0.6823672",
"0.677047",
"0.67309463",
"0.6730794",
"0.6718469",
"0.66477907",
"0.6646665",
"0.66437846",
"0.6636623",
"0.65979886",
"0.6591886",
"0.65580434",
"0.6506039",
"0.64399946",
"0.64344656",
"0.64... | 0.7351494 | 1 |
Convert version format depsolver is using (depsolver.SemanticVersion) into version format I'm using (string of loose form '1.56.3a'). Currently, for proof of concept and initial tests, we're using versions that fit the SemanticVersion spec instead of PyPI's sometimes elaborate ones. Depsolver can't accept anything othe... | def convert_version_from_depsolver(semantic_version):
return str(semantic_version) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_version_into_depsolver(ver_str):\n\n new_ver_str = ver_str\n pipified_ver = None # paranoid declaration in case of nested try scope issue\n semver = None # paranoid declaration in case of nested try scope issue\n\n # 1: try parsing into a \n try:\n semver = depsolver.version.SemanticVersion.fro... | [
"0.7523081",
"0.6679972",
"0.65238625",
"0.647259",
"0.64516866",
"0.6402522",
"0.62939674",
"0.6271797",
"0.6232487",
"0.6195797",
"0.6168943",
"0.61485195",
"0.6124872",
"0.60784876",
"0.6071909",
"0.5993712",
"0.59458977",
"0.5931294",
"0.5915542",
"0.5906065",
"0.5864157"... | 0.7424289 | 1 |
Convert the distkey to one usable by depsolver. e.g. 'X(1)' to 'X1.0.0' e.g. 'pipaccel(1.0.0) to 'pip_accel1.0.0'. (Shudder) | def convert_distkey_for_depsolver(distkey, as_req=False):
(packname, version) = depdata.get_pack_and_version(distkey)
# depsolver can't handle '-' in package names (ARGH!), so turn all '-' to '_'
# Must turn them back in the conversion back........
try:
my_ds_distkey = convert_packname_for_depsolver(pack... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_dist_to_packageinfo_for_depsolver(distkey, deps):\n\n # Convert the distkey to one usable by depsolver.\n try:\n my_ds_distkey = convert_distkey_for_depsolver(distkey)\n\n except DepsolverConversionError as e:\n logger.exception('In converting dist ' + distkey + ', unable to convert '\n '... | [
"0.66901",
"0.6208333",
"0.6112247",
"0.59464246",
"0.5886873",
"0.58359134",
"0.5804899",
"0.57738584",
"0.56773883",
"0.5669726",
"0.5658778",
"0.56055456",
"0.56003016",
"0.5549638",
"0.553041",
"0.54999673",
"0.5481785",
"0.5457705",
"0.5423742",
"0.5421291",
"0.5404372",... | 0.7886369 | 0 |
Revert from depsolver's package name format to that expected by pip and my code. (Reverses convert_packname_for_depsolver, the package name part of convert_distkey_for_depsolver.) | def convert_packname_from_depsolver(depsolver_packname):
return depsolver_packname.replace('_', '-') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_packname_for_depsolver(packname):\n return packname.replace('-', '_')",
"def convert_dist_to_packageinfo_for_depsolver(distkey, deps):\n\n # Convert the distkey to one usable by depsolver.\n try:\n my_ds_distkey = convert_distkey_for_depsolver(distkey)\n\n except DepsolverConversionError as e:... | [
"0.7958126",
"0.69110525",
"0.67520076",
"0.6417172",
"0.62435454",
"0.61918974",
"0.6146357",
"0.6139465",
"0.6060593",
"0.60385346",
"0.60276145",
"0.5909598",
"0.5794231",
"0.57280093",
"0.56946397",
"0.5673875",
"0.56609714",
"0.5655904",
"0.56495637",
"0.5627103",
"0.557... | 0.8197475 | 0 |
Given deps for a single distkey (e.g. DEPS_SIMPLE[X(1)] above), converts to a depsolver compatible format, depsolver.PackageInfo (e.g. DEPS_SIMPLE_PACKAGEINFOS[0] above) Returned object is type depsolver.PackageInfo. | def convert_dist_to_packageinfo_for_depsolver(distkey, deps):
# Convert the distkey to one usable by depsolver.
try:
my_ds_distkey = convert_distkey_for_depsolver(distkey)
except DepsolverConversionError as e:
logger.exception('In converting dist ' + distkey + ', unable to convert '
'the distkey i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_packs_to_packageinfo_for_depsolver(deps):\n\n packageinfos = []\n packs_unable_to_convert = []\n\n for distkey in deps:\n try:\n packageinfos.append(\n convert_dist_to_packageinfo_for_depsolver(distkey, deps))\n\n except DepsolverConversionError as e:\n logger.exception('In ... | [
"0.75323015",
"0.68106997",
"0.6556982",
"0.56166035",
"0.5575424",
"0.5435932",
"0.5301963",
"0.50579983",
"0.5056386",
"0.5039766",
"0.50050783",
"0.5003971",
"0.49745598",
"0.49658823",
"0.49517682",
"0.4933386",
"0.49276355",
"0.4903854",
"0.48997754",
"0.4833448",
"0.483... | 0.8068134 | 0 |
Given deps (e.g. DEPS_SIMPLE above), converts to a depsolver compatible format, depsolver.PackageInfo (e.g. DEPS_SIMPLE_PACKAGEINFOS above) Uses convert_single_dist_deps_to_packageinfo_for_depsolver | def convert_packs_to_packageinfo_for_depsolver(deps):
packageinfos = []
packs_unable_to_convert = []
for distkey in deps:
try:
packageinfos.append(
convert_dist_to_packageinfo_for_depsolver(distkey, deps))
except DepsolverConversionError as e:
logger.exception('In converting dicti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_dist_to_packageinfo_for_depsolver(distkey, deps):\n\n # Convert the distkey to one usable by depsolver.\n try:\n my_ds_distkey = convert_distkey_for_depsolver(distkey)\n\n except DepsolverConversionError as e:\n logger.exception('In converting dist ' + distkey + ', unable to convert '\n '... | [
"0.7814831",
"0.6645952",
"0.5849598",
"0.5772163",
"0.5651095",
"0.55460703",
"0.5380879",
"0.52095425",
"0.51799494",
"0.51731074",
"0.514024",
"0.50420356",
"0.5032219",
"0.4853209",
"0.48192766",
"0.4802291",
"0.47736835",
"0.47580945",
"0.47571883",
"0.47566876",
"0.4750... | 0.7767393 | 1 |
Given a json containing an array of the repr() values from depsolver.package.PackageInfo objects, reinstantiates those objects. (That is how I am storing the converted objects offline, as the conversion is timeconsuming, and this reinstantiation is faster.) Discards any that do not parse correctly. AFAIK, that currentl... | def reload_already_converted_from_json(fname):
converted = json.load(open(fname, 'r'))
pinfos = []
#unable_to_parse = []
n_unable_to_parse = 0
i = 0
for pinfo_str in converted:
i += 1
try:
pinfos.append(depsolver.package.PackageInfo.from_string(str(pinfo_str))) # cleansing unicode bullshit ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_from_json(self, json_string):\n parsed = json.loads(json_string)\n self.add_packages(parsed.pop('packages', []))\n self.data(parsed)",
"def _reconstruct_object(deserialized_data):\n for key, value in deserialized_data.items():\n key = key.strip('__')\n ... | [
"0.54323393",
"0.5288862",
"0.51934826",
"0.51804334",
"0.5127682",
"0.5049638",
"0.50310385",
"0.50213635",
"0.49853045",
"0.4966573",
"0.49556023",
"0.49215826",
"0.49169537",
"0.4902637",
"0.48895535",
"0.4877743",
"0.4873764",
"0.4831381",
"0.48185492",
"0.4816837",
"0.48... | 0.6904757 | 0 |
Wrapper for the depsolver package so that it can be tested via the same testing I employ for my own resolver package. Solves a dependency structure for a given package's dependencies, using the external depsolver package. Intended to be compatible with resolver.depdata.test_resolver. | def resolve_via_depsolver(distkey, deps, versions_by_package=None,
already_converted=False):
# Convert the dependencies into a format for depsolver, if they are not
# already in a depsolver-friendly format.
converted_dists = []
dists_unable_to_convert = []
if already_converted:
converted_dists = deps... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve_all_via_depsolver(dists_to_solve_for, pinfos, fname_solutions, fname_errors,\n fname_unresolvables):\n\n def _write_data_out(solutions, unable_to_resolve, unresolvables):\n \"\"\"THIS IS AN INNER FUNCTION WITHIN resolve_all_via_depsolver!\"\"\"\n print('')\n print('------------------------... | [
"0.6045728",
"0.59466976",
"0.58936775",
"0.57556385",
"0.56518275",
"0.5650624",
"0.56364626",
"0.5556999",
"0.5540272",
"0.5539575",
"0.55320406",
"0.54185987",
"0.53838867",
"0.5361082",
"0.5345973",
"0.5341506",
"0.5311486",
"0.53074366",
"0.530558",
"0.5240441",
"0.52033... | 0.69128203 | 0 |
Try finding the install solution for every dist in the list given, using dependency information from the given PackageInfo objects. Write this out to a temporary json occasionally so as not to lose data if the process is interrupted, as it is INCREDIBLY SLOW. | def resolve_all_via_depsolver(dists_to_solve_for, pinfos, fname_solutions, fname_errors,
fname_unresolvables):
def _write_data_out(solutions, unable_to_resolve, unresolvables):
"""THIS IS AN INNER FUNCTION WITHIN resolve_all_via_depsolver!"""
print('')
print('------------------------')
print('---... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_deps_temp(self):\n if self.distribution.install_requires:\n self.distribution.fetch_build_eggs(\n self.distribution.install_requires)\n if self.distribution.tests_require:\n self.distribution.fetch_build_eggs(self.distribution.tests_require)",
"def i... | [
"0.5922937",
"0.5768835",
"0.5761671",
"0.5632512",
"0.5614009",
"0.5597793",
"0.5573553",
"0.55656826",
"0.5560957",
"0.55595726",
"0.55272096",
"0.55235165",
"0.5465622",
"0.54655075",
"0.5453411",
"0.5429925",
"0.5423024",
"0.5417975",
"0.54107744",
"0.54062736",
"0.540053... | 0.67788976 | 0 |
Calculates the loss for l2 weight decay and adds it to `cost`. | def decay_weights(cost, weight_decay_rate):
costs = []
for var in tf.trainable_variables():
costs.append(tf.nn.l2_loss(var))
cost += tf.multiply(weight_decay_rate, tf.add_n(costs))
return cost | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def l2_reg_cost(cost):\n\n return cost + tf.losses.get_regularization_losses()",
"def l2_reg_cost(cost):\n return cost + tf.losses.get_regularization_losses()",
"def l2_reg_cost(cost):\n return cost + tf.losses.get_regularization_losses()",
"def l2_reg_cost(cost):\n return cost + tf.losses.get_re... | [
"0.726483",
"0.7252236",
"0.7252236",
"0.7252236",
"0.7178515",
"0.7174578",
"0.71135354",
"0.70613813",
"0.6889519",
"0.6822487",
"0.67483354",
"0.6572109",
"0.64500856",
"0.6406957",
"0.64012545",
"0.63871914",
"0.6377222",
"0.6370404",
"0.6365215",
"0.63465464",
"0.6343835... | 0.7384047 | 0 |
Find reference sequence make a index return mappy alignment result default only keep one best alignment default using 2 threads | def getIndex(reference, thread):
if reference:
reffa = reference
else:
reffa = path.join(path.dirname(path.abspath(path.dirname(__file__))),"reference.fa")
if not path.isfile(reffa):
logging.error("Could not find reference.fa")
sys.exit("ERROR: Could not find reference.fa! Pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_matching_seqs_from_alignment(sequences, ref_sequence):\n\n # if the first sequence (gaps removed) in MSA matches with reference,\n # return this sequence.\n first_seq_in_alignment = sequences[0] \n #first_seq_in_alignment_gaps_removed = first_seq_in_alignment.replace('-','')\n first_seq_in_... | [
"0.66776687",
"0.603756",
"0.5945348",
"0.59341073",
"0.58229715",
"0.58071434",
"0.5803574",
"0.57937586",
"0.57845944",
"0.5776303",
"0.5757716",
"0.5726695",
"0.5724322",
"0.57233447",
"0.57133424",
"0.5708705",
"0.56891",
"0.56794745",
"0.5673394",
"0.56633925",
"0.565285... | 0.68620145 | 0 |
Convert an image containing CARLA semantic segmentation labels to Cityscapes palette. | def labels_to_cityscapes_palette(image):
classes=ZHANG_classes
result =np.zeros((img.shape[0], img.shape[1], 3),dtype=np.uint8)
for key, value in classes.items():
result[np.where(img == key)] = value
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_cityscapes_label_colormap():\r\n colormap = np.zeros((256, 3), dtype=np.uint8)\r\n colormap[0] = [128, 64, 128]\r\n colormap[1] = [244, 35, 232]\r\n colormap[2] = [70, 70, 70]\r\n colormap[3] = [102, 102, 156]\r\n colormap[4] = [190, 153, 153]\r\n colormap[5] = [153, 153, 153]\r\n colormap[6] = ... | [
"0.7037049",
"0.6383233",
"0.6383233",
"0.6371041",
"0.63424903",
"0.63424903",
"0.6281433",
"0.6070441",
"0.6047343",
"0.6018909",
"0.5969842",
"0.59596676",
"0.59451824",
"0.59451824",
"0.5933525",
"0.589702",
"0.589702",
"0.5896587",
"0.57948154",
"0.57948154",
"0.56819206... | 0.78980845 | 0 |
Check result of a Coroutine | def check_result(self, coro_id):
try:
status, response = self.coros_result.get(coro_id)
if status != CoroStatus.Queued:
self.remove_coro(coro_id)
return status, response
except KeyError:
raise CoroMissingException("Coroutine Id {}"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_await_if_coroutine(coroutine, exp_return, args):\n result = asyncio.run(await_if_coroutine(coroutine, *args))\n\n assert result == exp_return",
"async def _do_if_possible(self, coroutine: Awaitable[None]) -> None:\n try:\n await coroutine\n except IncorrectStateException:\... | [
"0.70555294",
"0.67391545",
"0.6546527",
"0.6543024",
"0.6528161",
"0.6526226",
"0.6454859",
"0.6255823",
"0.6249826",
"0.6249826",
"0.6249826",
"0.6240682",
"0.6240682",
"0.6240682",
"0.6205078",
"0.6196182",
"0.61914533",
"0.61541504",
"0.6075995",
"0.60661936",
"0.6053653"... | 0.67717886 | 1 |
Query the published timestamp. | def published(self):
xutimes = self.xutimes()
# If there are 2 xutimes, published is the second. Otherwise, it is the
# first and only xutime.
offset = 0 if len(xutimes) == 1 else 1
return dt.fromtimestamp(int(xutimes[offset])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPublishedTime(self): #$NON-NLS-1$\r",
"def is_published(self):\n now = timezone.now()\n return now >= self.pub_date",
"def was_published_recently(self):\n now = timezone.now()\n return now - datetime.timedelta(days=1) <= self.pub_date <= now",
"def was_published_recently(se... | [
"0.637944",
"0.6223008",
"0.62135386",
"0.5989187",
"0.59752625",
"0.59716725",
"0.5950882",
"0.59144026",
"0.59093064",
"0.58631545",
"0.58490235",
"0.58325297",
"0.58145064",
"0.58035874",
"0.58013976",
"0.5795492",
"0.5785165",
"0.5757043",
"0.574899",
"0.57325506",
"0.571... | 0.6544012 | 0 |
Query the updated timestamp. | def updated(self):
xutimes = self.xutimes()
# If there are 2 xutimes, updated is the first. Otherwise, there is no
# updated date, just published.
return (
dt.fromtimestamp(int(xutimes[0]))
if len(xutimes) == 2 else None
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updated_on(self):\n return self.get_time(\"updated_on\")",
"def time_updated(self):\n return self._time_updated",
"def longpoll(self, last_offset=0):\n\n params = {'timeout': 25}\n\n if last_offset != 0:\n params['offset'] = last_offset + 1\n\n return self.api_... | [
"0.6514072",
"0.64222455",
"0.63847077",
"0.637163",
"0.6343173",
"0.6256463",
"0.62504005",
"0.62043244",
"0.6200104",
"0.6193941",
"0.61809915",
"0.6155149",
"0.6153594",
"0.614756",
"0.614756",
"0.614756",
"0.614756",
"0.614756",
"0.614756",
"0.614756",
"0.614756",
"0.61... | 0.64278007 | 1 |
Map into the Profile model. | def parse(self):
details = self.details()
return Profile(
book_id=self.book_id,
title=self.title(),
user_id=self.user_id(),
username=self.username(),
summary=self.summary(),
published=self.published(),
updated=self.upda... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_full_profile(self) -> Profile:\n return Profile(**{**self.profile, **self.contact})",
"def _profile_to_InstagramUser(profile: Dict[str, Any]) -> _InstagramUser:\n # Navigate to the user JSON that is coincidentally used by the provided API methods\n user = profile['users'][0]['user']\... | [
"0.6386944",
"0.6078071",
"0.5955639",
"0.59452206",
"0.5924131",
"0.5893735",
"0.58359146",
"0.5818783",
"0.58164734",
"0.5816099",
"0.56320775",
"0.56275004",
"0.5618273",
"0.55763835",
"0.5563363",
"0.5558556",
"0.55290043",
"0.5456606",
"0.54563314",
"0.54117835",
"0.5393... | 0.65340567 | 0 |
Get the current position of the goal. | def goal_pos(self) -> Pt:
return self._goal | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goal_position(self):\n return self._read(MX_GOAL_POSITION)",
"def getPos(self):\n return self.__current_pos",
"def get_pos(self):\n return self.pos",
"def get_position(self):\n return self.bot_client.send_command(_Command.GetPosition)",
"def get_pos(self):\r\n return ... | [
"0.81579345",
"0.80057174",
"0.7536035",
"0.7512345",
"0.74855983",
"0.7481217",
"0.7480571",
"0.74779797",
"0.74779797",
"0.74328595",
"0.7381533",
"0.7381533",
"0.7375567",
"0.73221797",
"0.72740036",
"0.72573185",
"0.7254339",
"0.7200677",
"0.71969545",
"0.71378434",
"0.71... | 0.825077 | 0 |
Get the distance between the player and the goal. | def player_goal_distance(self) -> float:
route = self.best_route
return sum(route.values()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distMe_Players(self, player):\n return self.playerPos.distance(player)",
"def get_distance(self):\n print(\"voici la distance à l'obstacle\")",
"def distance_to_current_waypoint(self):\n next_waypoint = self.vehicle.commands.next\n if next_waypoint == 1:\n return None... | [
"0.7473132",
"0.7293953",
"0.7254824",
"0.7148412",
"0.7128136",
"0.71275765",
"0.7054903",
"0.68885946",
"0.6857143",
"0.68300825",
"0.6792063",
"0.6770327",
"0.67508197",
"0.6718603",
"0.67152125",
"0.66675186",
"0.66256315",
"0.66200554",
"0.66099554",
"0.66027814",
"0.655... | 0.82236296 | 0 |
Get the best route from the player to the goal. | def best_route(self, player: Optional[Pt] = None, goal: Optional[Pt] = None):
best = empty_path()
if player is None and goal is None:
diff = self._goal - self._player
else:
diff = goal - player
horz = diff.x // self.PLAYER_DIM
vert = diff.y // self.PLAYE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getBestPath(self):\n if self._bestPathVertex.getNextWaypoint() is None:\n numWaypointsCompleted = len(self._waypoints)\n quality = 2\n if self._vertexQueue.isEmpty():\n quality += 1\n else:\n numWaypointsCompleted = self._bestPathVertex.g... | [
"0.7351605",
"0.7034555",
"0.6983396",
"0.6958331",
"0.68870384",
"0.685827",
"0.6773058",
"0.67406523",
"0.6706887",
"0.65491766",
"0.6518981",
"0.65003234",
"0.6477742",
"0.6474655",
"0.6473335",
"0.6436844",
"0.6435923",
"0.64257306",
"0.6422758",
"0.64042574",
"0.6401543"... | 0.8414008 | 0 |
Get the best route as a numpy array. | def best_routes_matrix(self) -> np.array:
x = np.empty((0, 4))
y = np.empty((0, 4))
for k, v in self.routes.items():
x_row = np.zeros((1, 4))
y_row = np.zeros((1, 4))
# Player start position
player = Pt(k[0][0], k[0][1])
x_row[0, 0] = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_path_best_first(world_nparray, heuristic_type=\"\"):\n world_ndarray = np.copy(world_nparray)\n start = tuple(np.argwhere(world_ndarray == -2)[0])\n goal = tuple(np.argwhere(world_ndarray == -3)[0])\n\n world_ndarray[world_ndarray == -2] = 0\n world_ndarray[world_ndarray == -3] = 0\n\n w... | [
"0.61993045",
"0.6134547",
"0.6061502",
"0.5860874",
"0.56015235",
"0.55797726",
"0.55286056",
"0.5473274",
"0.5465005",
"0.5434912",
"0.54079527",
"0.5407125",
"0.539941",
"0.5397378",
"0.5392903",
"0.5391854",
"0.538973",
"0.536694",
"0.5355134",
"0.5349964",
"0.5339336",
... | 0.673835 | 0 |
Move the player up one cell. | def player_up(self) -> None:
self._routes[self._current_route_key]["UP"] += 1
new_pos = self._player.y - self.MOVE_INC
if new_pos + self.PLAYER_DIM <= self._height and new_pos - self.PLAYER_DIM >= 0:
self._player.y = new_pos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def movePlayerUp(self):\r\n self.player.moveUp()",
"def move_up(self):\n kya = self.board.board[self.player.y-1][self.player.x]\n if self.player.y > 0 and kya != 'X' and kya != 'G':\n self.board.board[self.player.y][self.player.x] = '.'\n self.coin_taken(0, -1)\n ... | [
"0.7994862",
"0.76769966",
"0.7593516",
"0.7587633",
"0.7549472",
"0.747465",
"0.7435515",
"0.73729",
"0.73461956",
"0.7281099",
"0.7164506",
"0.71472996",
"0.7103562",
"0.7095604",
"0.7085147",
"0.70622677",
"0.7051099",
"0.7030037",
"0.7027417",
"0.69769335",
"0.6972158",
... | 0.772859 | 1 |
Move the player down one cell. | def player_down(self) -> None:
self._routes[self._current_route_key]["DOWN"] += 1
new_pos = self._player.y + self.MOVE_INC
if new_pos + self.PLAYER_DIM <= self._height and new_pos - self.PLAYER_DIM >= 0:
self._player.y = new_pos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def movePlayerDown(self):\r\n self.player.moveDown()",
"def move_down(self):\n self.y -= 1",
"def move_down():\n return __maze.move_down()",
"def move_down(self):\n self.move_step(1)",
"def move_down(self):\n kya = self.board.board[self.player.y+1][self.player.x]\n if ... | [
"0.7795926",
"0.7605512",
"0.74790746",
"0.7396365",
"0.7389261",
"0.7355061",
"0.72866434",
"0.719402",
"0.71786267",
"0.7119812",
"0.70716244",
"0.7067565",
"0.70581275",
"0.7022474",
"0.69801766",
"0.69485635",
"0.6926046",
"0.69206846",
"0.69026434",
"0.6869787",
"0.68334... | 0.7607869 | 1 |
Move the player left one cell. | def player_left(self) -> None:
self._routes[self._current_route_key]["LEFT"] += 1
new_pos = self._player.x - self.MOVE_INC
if new_pos + self.PLAYER_DIM <= self._width and new_pos - self.PLAYER_DIM >= 0:
self._player.x = new_pos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_left(self):\n self.rect.x -= 5 # Moves to the left by 5\n\n # If the player reaches the edge of the screen, they can't go further\n if self.rect.x <= -50:\n self.rect.x = -50",
"def move_left(self):\n kya = self.board.board[self.player.y][self.player.x-1]\n ... | [
"0.78693366",
"0.7855117",
"0.779688",
"0.7726264",
"0.76574355",
"0.75703585",
"0.741507",
"0.73590785",
"0.7351474",
"0.7344982",
"0.73071456",
"0.7298308",
"0.72507036",
"0.72507036",
"0.71976733",
"0.7169323",
"0.71631336",
"0.7152363",
"0.7142514",
"0.70967567",
"0.70944... | 0.79673505 | 0 |
Move the player right one cell. | def player_right(self) -> None:
self._routes[self._current_route_key]["RIGHT"] += 1
new_pos = self._player.x + self.MOVE_INC
if new_pos + self.PLAYER_DIM <= self._height and new_pos - self.PLAYER_DIM >= 0:
self._player.x = new_pos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_right(self):\n self.rect.x += 5 # Moves to the right by 5\n\n # If the player reaches the edge of the screen, they can't go further\n if self.rect.x >= 580:\n self.rect.x = 580",
"def move(self, row, col, player):",
"def move_right():\n return __maze.move_right()",
... | [
"0.7641803",
"0.74997973",
"0.73882043",
"0.7373835",
"0.7312114",
"0.7238417",
"0.72026074",
"0.7057817",
"0.70359355",
"0.69748217",
"0.6952666",
"0.6938814",
"0.6937052",
"0.69188285",
"0.6904731",
"0.684828",
"0.68131393",
"0.6777905",
"0.6766982",
"0.6753091",
"0.6748832... | 0.7617395 | 1 |
Initiate a game loop by using the action callback to get player movements. | def callback_game_loop(self) -> None:
self._goal_generate()
self._update()
self.reset()
while self._player != self._goal:
self._update()
action = self._action_callback(
self._player.np,
self._goal.np,
*self._action_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game_loop(self):\n self.interface.game_loop(self)",
"def play_step(self, action):\n self.players[0].moving_left = False\n self.players[0].moving_right = False\n if action == MOVE_LEFT:\n self.players[0].moving_left = True\n for i in range(LOOP_AT_EACH_MOVE_UP... | [
"0.65305406",
"0.6380657",
"0.60681427",
"0.60480475",
"0.60273767",
"0.58478916",
"0.5828401",
"0.5815597",
"0.5756687",
"0.5622581",
"0.5589249",
"0.5572926",
"0.55711186",
"0.55381066",
"0.5522959",
"0.55202115",
"0.55159676",
"0.5504191",
"0.5502004",
"0.54999894",
"0.549... | 0.678102 | 0 |
Test that headers are retrieved from the cache when they exist and not retrieved from Auth0 unecessarily. | def test_headers_from_cache(db, mocker):
get_token = mocker.patch('creator.authentication.get_token')
cache_key = "ACCESS_TOKEN:my_aud"
cache.set(cache_key, "ABC")
headers = client_headers("my_aud")
assert "Authorization" in headers
assert headers["Authorization"] == "Bearer ABC"
assert ge... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_header_cache(db, mocker):\n mock_token = mocker.patch(\"creator.authentication.get_token\")\n mock_token.return_value = \"ABC\"\n\n headers = client_headers(settings.AUTH0_SERVICE_AUD)\n assert \"Authorization\" in headers\n assert headers[\"Authorization\"] == \"Bearer ABC\"\n\n cache_k... | [
"0.7868315",
"0.7144702",
"0.7068851",
"0.687243",
"0.6852933",
"0.6761851",
"0.6565507",
"0.64969903",
"0.6458255",
"0.6385312",
"0.63652015",
"0.6299442",
"0.625249",
"0.6159989",
"0.6140487",
"0.6135812",
"0.61309516",
"0.61077857",
"0.606365",
"0.60534567",
"0.6022729",
... | 0.7761425 | 1 |
Test that Auth0 is called for a new token | def test_new_token(db, mocker):
settings.AUTH0_CLIENT = "123"
settings.AUTH0_SECRET = "abc"
class Resp:
def json(self):
return {"access_token": "ABC"}
def raise_for_status(self):
pass
mock = mocker.patch("creator.authentication.requests.post")
mock.return_v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_new_token_insuficient_config(db, mocker):\n settings.AUTH0_CLIENT = None\n\n mock = mocker.patch(\"creator.authentication.requests.post\")\n\n assert get_token(\"my_aud\") is None\n assert mock.call_count == 0",
"def test_create_o_auth_access_token(self):\n pass",
"def test_patch_o_... | [
"0.71863836",
"0.70839125",
"0.708001",
"0.7072969",
"0.7068836",
"0.7067651",
"0.703223",
"0.70083624",
"0.6975531",
"0.6923069",
"0.6887883",
"0.68862486",
"0.68637717",
"0.6830448",
"0.6812442",
"0.6796147",
"0.6793554",
"0.6769079",
"0.6767983",
"0.67179406",
"0.6688544",... | 0.72491944 | 0 |
Test that no token is fetched when there is not enough config | def test_new_token_insuficient_config(db, mocker):
settings.AUTH0_CLIENT = None
mock = mocker.patch("creator.authentication.requests.post")
assert get_token("my_aud") is None
assert mock.call_count == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_token_get_all(self):\n response = self.app.get('/api/v3/users')\n self.assertEqual(response.status_code, 401)",
"def test_no_token_auth_required(self, client):\n assert_hook_status(client, status=401)",
"def test_missing_token(self):\n ConnectorTelegram({}, opsdroid=OpsD... | [
"0.71030533",
"0.7093617",
"0.6954731",
"0.68749434",
"0.68542343",
"0.68245643",
"0.67864007",
"0.6760013",
"0.6729617",
"0.6728336",
"0.67073685",
"0.66850024",
"0.66672915",
"0.66597193",
"0.6608426",
"0.65870893",
"0.65839183",
"0.6570184",
"0.65669554",
"0.65669554",
"0.... | 0.718768 | 0 |
Run each initial move a number of times to get a better idea of which ones will work best | def run_each_move(root: State, state: GameState) -> State:
for m, base_move in enumerate(root.moves):
for _ in range(50):
base_move = expand(base_move)
outcome, _ = MCTS(base_move, state, False, 0)
if outcome == state.player:
base_move.winner()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n move()\n move()\n pick_beeper()\n move()\n turn_left()\n for i in range(2):\n move()\n put_beeper()\n turn_around()\n move_to_wall()\n turn_right()\n move_to_wall()\n turn_around()",
"def main():\r\n turn_left()\r\n move_three_times()\r\n turn_rig... | [
"0.72601175",
"0.6887708",
"0.6866101",
"0.6832941",
"0.680918",
"0.6680433",
"0.6644872",
"0.6627326",
"0.6594268",
"0.65941274",
"0.6557273",
"0.652432",
"0.6508902",
"0.6505224",
"0.64793086",
"0.6468351",
"0.6467681",
"0.64666164",
"0.6459223",
"0.645269",
"0.6438939",
... | 0.71587455 | 1 |
r""" Computes the noise level sigma to reach a total budget of (target_epsilon, target_delta) at the end of epochs, with a given sample_rate | def get_noise_multiplier(
target_epsilon: float,
target_delta: float,
sample_rate: float,
epochs: int,
alphas: [float],
sigma_min: float = 0.01,
sigma_max: float = 10.0,
) -> float:
from opacus import privacy_analysis
eps = float("inf")
while eps > target_epsilon:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gauss_kernel(sigma, sample_rate, duration):\n l = duration * sample_rate\n x = np.arange(-np.floor(l / 2), np.floor(l / 2)) / sample_rate\n y = (1 / (np.sqrt(2 * np.pi) * sigma)) * np.exp(-(x ** 2 / (2 * sigma ** 2)))\n y /= np.sum(y)\n return y",
"def get_sigma(rate, dt=1 * units.ns):\n re... | [
"0.65214974",
"0.62182915",
"0.6145236",
"0.60547554",
"0.6035485",
"0.5967057",
"0.5942759",
"0.59181756",
"0.58283",
"0.57882774",
"0.5772903",
"0.57728827",
"0.56596065",
"0.5627683",
"0.5620065",
"0.56128526",
"0.5602938",
"0.55988806",
"0.55766183",
"0.55633473",
"0.5540... | 0.7579921 | 0 |
Construct a mock feed entry for testing purposes. | def _generate_mock_feed_entry(
external_id, title, distance_to_home, coordinates, category
):
feed_entry = MagicMock()
feed_entry.external_id = external_id
feed_entry.title = title
feed_entry.distance_to_home = distance_to_home
feed_entry.coordinates = coordinates
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_mock_feed_entry(\n external_id,\n title,\n distance_to_home,\n coordinates,\n category=None,\n attribution=None,\n published=None,\n updated=None,\n status=None,\n):\n feed_entry = MagicMock()\n feed_entry.external_id = external_id\n feed_entry.title = title\n f... | [
"0.801564",
"0.69315803",
"0.6873159",
"0.6795664",
"0.67247635",
"0.6586736",
"0.64809567",
"0.6392763",
"0.62528956",
"0.6224266",
"0.62041086",
"0.6159651",
"0.6155345",
"0.6030917",
"0.5982228",
"0.59491515",
"0.5927826",
"0.58970696",
"0.5871585",
"0.5850287",
"0.5843883... | 0.8318027 | 0 |
Initialization of vanderpol output | def __init__(self):
super(vanderpol_output,self).__init__()
# add figure object for further use
fig = plt.figure()
self.ax = fig.add_subplot(111)
self.ax.set_xlim([-2.5,2.5])
self.ax.set_ylim([-10.5,10.5])
plt.ion()
self.sframe = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_vprinting(**kwargs):\n kwargs['str_printer'] = vsstrrepr\n kwargs['pretty_printer'] = vpprint\n kwargs['latex_printer'] = vlatex\n init_printing(**kwargs)",
"def create_vuln_report():",
"def _populate_output(self):\n pass",
"def __init__(self):\n _snap.TStdOut_swiginit(self... | [
"0.6515523",
"0.6134656",
"0.60123855",
"0.583166",
"0.5558507",
"0.5547795",
"0.5480687",
"0.5468066",
"0.54386157",
"0.5427239",
"0.5388758",
"0.5380829",
"0.53711134",
"0.5337914",
"0.53255886",
"0.53225356",
"0.5319384",
"0.53047055",
"0.52650744",
"0.52605194",
"0.526008... | 0.684879 | 0 |
The key algorithm to use when generating the private key. | def key_algorithm(self) -> str:
return pulumi.get(self, "key_algorithm") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_key(self):\n key = rsa.generate_private_key(\n public_exponent=self.settings['key_public_exponent_size'],\n key_size=self.settings['key_size'],\n backend=default_backend()\n )\n return key",
"def generate_symmetric_key():\n return Fernet.gener... | [
"0.6891513",
"0.66896755",
"0.6685604",
"0.6685604",
"0.6685604",
"0.6685604",
"0.66785383",
"0.6611174",
"0.6518819",
"0.65006274",
"0.63971996",
"0.6396306",
"0.6383091",
"0.6382536",
"0.6376557",
"0.6367731",
"0.6355344",
"0.635209",
"0.6321704",
"0.63141423",
"0.62521714"... | 0.7858189 | 0 |
Gets details of a single CertificateIssuanceConfig. | def get_certificate_issuance_config(certificate_issuance_config_id: Optional[str] = None,
location: Optional[str] = None,
project: Optional[str] = None,
opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_certificate_issuance_config_output(certificate_issuance_config_id: Optional[pulumi.Input[str]] = None,\n location: Optional[pulumi.Input[str]] = None,\n project: Optional[pulumi.Input[Optional[str]]] = None,\n ... | [
"0.6863756",
"0.57507914",
"0.5392511",
"0.53428894",
"0.52555436",
"0.52094597",
"0.519204",
"0.51170826",
"0.51127565",
"0.5026422",
"0.49897617",
"0.49162883",
"0.48484945",
"0.4809881",
"0.47813207",
"0.47646514",
"0.4761052",
"0.47543043",
"0.47497353",
"0.4743443",
"0.4... | 0.71836895 | 0 |
Gets details of a single CertificateIssuanceConfig. | def get_certificate_issuance_config_output(certificate_issuance_config_id: Optional[pulumi.Input[str]] = None,
location: Optional[pulumi.Input[str]] = None,
project: Optional[pulumi.Input[Optional[str]]] = None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_certificate_issuance_config(certificate_issuance_config_id: Optional[str] = None,\n location: Optional[str] = None,\n project: Optional[str] = None,\n opts: Optional[pulumi.InvokeOptions] = None) -> Awa... | [
"0.71836895",
"0.57507914",
"0.5392511",
"0.53428894",
"0.52555436",
"0.52094597",
"0.519204",
"0.51170826",
"0.51127565",
"0.5026422",
"0.49897617",
"0.49162883",
"0.48484945",
"0.4809881",
"0.47813207",
"0.47646514",
"0.4761052",
"0.47543043",
"0.47497353",
"0.4743443",
"0.... | 0.6863756 | 1 |
Set the learning rate of a given `model` generated by `fe.build`. | def set_lr(model: Union[tf.keras.Model, torch.nn.Module], lr: float, weight_decay: Optional[float] = None):
assert hasattr(model, "fe_compiled") and model.fe_compiled, "set_lr only accept models from fe.build"
if isinstance(model, tf.keras.Model):
# when using decoupled weight decay like SGDW or AdamW, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_learning_rate(self, rate):\n self.SGD.set_learning_rate(rate)",
"def assign_learning_rate(session, lr_update, lr_placeholder, new_lr):\n session.run(lr_update, feed_dict={lr_placeholder: new_lr})",
"def adjust_learning_rate(optimizer, epoch, model_type):\n if model_type == 1:\n if epo... | [
"0.71395046",
"0.70618266",
"0.6917554",
"0.68914354",
"0.6872831",
"0.6862473",
"0.68475896",
"0.67931026",
"0.6760157",
"0.6728568",
"0.6724322",
"0.67154443",
"0.6710236",
"0.6707238",
"0.6705722",
"0.6688397",
"0.668348",
"0.6672866",
"0.6672866",
"0.6665554",
"0.6663909"... | 0.71793497 | 0 |
Creates a histogram of smart meter readings to identify their distribution and find outliers. | def hourly_sm_reading_histogram():
cursor = connections["ldc"].cursor()
cursor.execute("select smr.Reading "
"from essex_annotated.SmartMeterReadings smr "
"inner join Meters m on m.MeterID = smr.MeterID "
" and m.`Phase` = 1 "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reading_count_histogram():\r\n cursor = connections[\"ldc\"].cursor()\r\n cursor.execute(\"select count(smr.read_datetime) \"\r\n \"from essex_annotated.SmartMeterReadings smr \" \r\n \"inner join Meters m \"\r\n \" on m.MeterID = smr.MeterID and m.`... | [
"0.67328525",
"0.6239935",
"0.62391126",
"0.59873194",
"0.58854866",
"0.58815724",
"0.5872569",
"0.58556473",
"0.5810704",
"0.5795435",
"0.5760309",
"0.5739301",
"0.5674812",
"0.56742615",
"0.5645246",
"0.56247497",
"0.5608787",
"0.56006426",
"0.5589549",
"0.5570811",
"0.5553... | 0.68666226 | 0 |
Gets the number of readings in a time range grouped by MeterID | def reading_count_histogram():
cursor = connections["ldc"].cursor()
cursor.execute("select count(smr.read_datetime) "
"from essex_annotated.SmartMeterReadings smr "
"inner join Meters m "
" on m.MeterID = smr.MeterID and m.`Phase` = 1 "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMeterReadings(self):\n return self._MeterReadings",
"def get_number_of_measurement(self):\n num_of_meas = 0\n for time in self.mdvtc.keys():\n num_of_meas = num_of_meas + self.mdvtc[time].get_number_of_measurement()\n #\n return num_of_meas",
"def get_readin... | [
"0.59932584",
"0.56850594",
"0.5395487",
"0.5365876",
"0.5278371",
"0.5221799",
"0.512348",
"0.5085135",
"0.5055438",
"0.5047945",
"0.5047142",
"0.5030457",
"0.49874994",
"0.49733794",
"0.49577364",
"0.4953755",
"0.49303856",
"0.49149385",
"0.49143824",
"0.48964334",
"0.48830... | 0.6025856 | 0 |
Counts the number of exceptions per MeterNumber and plots a histogram. | def sm_reading_exception_count_histogram():
cursor = connections["ldc"].cursor()
cursor.execute("select count(smre.reading_datetime_standard) "
"from Meters m "
"left join SmartMeterReadingsExceptions smre "
" on smre.MeterNumber = m.MeterNumber "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_histogram(self, i):\n # styling\n sns.set(style=\"whitegrid\")\n font = {'weight': 'normal'}\n plt.rc('font', **font)\n plt.rc('axes', labelsize=25) # fontsize of the x and y labels\n plt.rc('xtick', labelsize=25) # fontsize of the tick labels\n plt.rc(... | [
"0.6173529",
"0.59257436",
"0.57521635",
"0.5735758",
"0.5726736",
"0.5705087",
"0.5621296",
"0.5619332",
"0.55907875",
"0.55446506",
"0.55407035",
"0.55060387",
"0.5504349",
"0.54718107",
"0.54674673",
"0.5440962",
"0.54346704",
"0.54254365",
"0.53994054",
"0.5381694",
"0.53... | 0.75279325 | 0 |
SELECT "visit_occurrence"."visit_concept_id", COUNT("visit_occurrence"."visit_concept_id") AS "visit_concept_id__count" FROM "visit_occurrence" GROUP BY "visit_occurrence"."visit_concept_id" | def total(request) : # foreign key 가 아니라서 ORM 상에서 JOIN 이 안됨;;
data = VisitOccurrence.objects.values('visit_concept_id').annotate(Count('visit_concept_id'))
for tmp in data : # JOIN 안해서 생긴 불필요한 반복문(N+1 문제)
concept_id = tmp['visit_concept_id']
concept_name = Concept.objects.filter(concept_id=conc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_diagnose_count(visit):\r\n return visit.diagnose.all().count()",
"def count_instances(tbl, col2count, colcounted):\n counted_ser = tbl[col2count].value_counts()\n counted_df = pd.DataFrame(counted_ser, columns=[colcounted]).reset_index()\n counted_df.rename(columns={'index':col2count},inplace... | [
"0.5988635",
"0.5845507",
"0.5831062",
"0.5708651",
"0.56078583",
"0.5583171",
"0.55625606",
"0.5531115",
"0.55106145",
"0.54868984",
"0.5484354",
"0.54476726",
"0.5404469",
"0.54004276",
"0.536023",
"0.5310006",
"0.5281747",
"0.5251521",
"0.5235851",
"0.5223726",
"0.5203971"... | 0.6179557 | 0 |
Wrapper for requests.get with useragent automatically set. And also all requests are reponses are cached. | def _external_request(self, method, url, *args, **kwargs):
self.last_url = url
if url in self.responses.keys() and method == 'get':
return self.responses[url] # return from cache if its there
headers = kwargs.pop('headers', None)
custom = {'User-Agent': useragent}
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requests_get(*args, **kwargs):\n\n logger = kwargs.pop('logger', None)\n s = requests.Session()\n s.headers[\n 'User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36'\n\n try:\n return s.get(*args, **kw... | [
"0.72382575",
"0.6706278",
"0.66522735",
"0.6622188",
"0.63546485",
"0.63333637",
"0.6328832",
"0.63206446",
"0.6274874",
"0.62323165",
"0.62105024",
"0.6169128",
"0.61344707",
"0.61193335",
"0.6117609",
"0.6068327",
"0.6064174",
"0.6063191",
"0.60310495",
"0.60007054",
"0.59... | 0.70372856 | 1 |
Push transaction to the miner network. Returns txid if done successfully. | def push_tx(self, crypto, tx_hex):
raise NotImplementedError(
"This service does not support pushing transactions to the network. "
"Or rather it has no defined 'push_tx' method."
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_push(tx, rpc_user=None, rpc_password=None):\n\n rpc_connection = AuthServiceProxy(\"http://\"+rpc_user+\":\"+rpc_password+\"@127.0.0.1:18332\")\n\n try:\n tx_hash = rpc_connection.sendrawtransaction(tx)\n code = 200\n print \"Transaction broadcast \" + tx_hash\n except JSONR... | [
"0.6160602",
"0.59532255",
"0.5924455",
"0.58844817",
"0.58601177",
"0.573874",
"0.56982905",
"0.5668894",
"0.5585507",
"0.5508735",
"0.5498974",
"0.54317415",
"0.5357308",
"0.5341922",
"0.5329206",
"0.5310497",
"0.5297211",
"0.52924514",
"0.52893835",
"0.52836126",
"0.528170... | 0.6519792 | 0 |
Get block based on either block height, block number or get the latest block. Only one of the previous arguments must be passed on. | def get_block(self, crypto, block_height='', block_number='', latest=False):
raise NotImplementedError(
"This service does not support getting getting block data. "
"Or rather it has no defined 'get_block' method."
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_block_at_height(height, headers):\n if height == 0:\n print('retrieving genesis block...')\n return GENESIS_DICTIONARY\n\n else:\n height_bottom = headers[0]['height'] # TODO can pass in height_bottom as an argument to save recompute\n result = hea... | [
"0.72756964",
"0.7181289",
"0.7142906",
"0.6979643",
"0.6786556",
"0.67289954",
"0.6712528",
"0.66829705",
"0.6668895",
"0.6605809",
"0.65997833",
"0.65225774",
"0.6509247",
"0.6488133",
"0.6473838",
"0.64637846",
"0.6461936",
"0.6452231",
"0.6438939",
"0.64360714",
"0.641553... | 0.76772964 | 0 |
Each service class is instantiated here so the service instances stay in scope for the entire life of this object. This way the service objects can cache responses. | def __init__(self, services=None, verbose=False, responses=None):
if not services:
from moneywagon import ALL_SERVICES
services = ALL_SERVICES
self.services = []
for ServiceClass in services:
self.services.append(
ServiceClass(verbose=verbose,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_services(self):\n service_prefix = rospy.get_name() + \"/\"\n\n self._request_components_serv = rospy.Service(service_prefix +\n 'list_components',\n ListComponents,\n ... | [
"0.71405923",
"0.6957013",
"0.68119806",
"0.67828083",
"0.6754767",
"0.67280805",
"0.65722066",
"0.6539152",
"0.65285087",
"0.651792",
"0.6504264",
"0.6459501",
"0.64424473",
"0.64085054",
"0.64027244",
"0.63932645",
"0.6379879",
"0.6315382",
"0.6307707",
"0.62971926",
"0.626... | 0.7230372 | 0 |
Try each service until one returns a response. This function only catches the bare minimum of exceptions from the service class. We want exceptions to be raised so the service classes can be debugged and fixed quickly. | def _try_services(self, method_name, *args, **kwargs):
for service in self.services:
crypto = ((args and args[0]) or kwargs['crypto']).lower()
address = kwargs.get('address', '').lower()
fiat = kwargs.get('fiat', '').lower()
if service.supported_cryptos and (cryp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_services(self):\n for service in self.services:\n try:\n self.cloud.search_services(service)[0]\n except Exception: # pylint: disable=broad-except\n self.is_skipped = True\n break",
"def wait_for_container():\n for i in xrang... | [
"0.66597927",
"0.6303058",
"0.6231808",
"0.59496015",
"0.58680505",
"0.5662733",
"0.5661657",
"0.5606911",
"0.55774033",
"0.5545486",
"0.5513023",
"0.545945",
"0.5449551",
"0.5402146",
"0.53971815",
"0.5388265",
"0.5384882",
"0.53824943",
"0.5370124",
"0.53136665",
"0.5308921... | 0.6947734 | 0 |
This function is called when all Services have been tried and no value can be returned. It much take the same args and kwargs as in the method spefified in `method_name`. Returned is a string for the error message. It should say something informative. | def no_service_msg(self, *args, **kwargs):
return "All either skipped or failed." | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _try_services(self, method_name, *args, **kwargs):\n for service in self.services:\n crypto = ((args and args[0]) or kwargs['crypto']).lower()\n address = kwargs.get('address', '').lower()\n fiat = kwargs.get('fiat', '').lower()\n\n if service.supported_crypto... | [
"0.7316932",
"0.61711097",
"0.5743864",
"0.5600824",
"0.54378814",
"0.5434237",
"0.5429922",
"0.5426389",
"0.5417822",
"0.5417605",
"0.54125404",
"0.53884834",
"0.5353763",
"0.5330554",
"0.5321938",
"0.5299114",
"0.5282391",
"0.5256569",
"0.5248116",
"0.52478075",
"0.52358246... | 0.65713865 | 1 |
Fetches the value according to the mode of execution desired. `FetcherClass` must be a class that is subclassed from AutoFallback. `services` must be a list of Service classes. `kwargs` is a list of arguments used to make the service call, usually | def enforce_service_mode(services, FetcherClass, kwargs, modes):
average_level = modes.get('average', 1)
paranoid_level = modes.get('paranoid', 1)
verbose = modes.get('verbose', False)
if modes.get('random', False):
random.shuffle(services)
if paranoid_level == 1 and average_level == 1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, mode: str = \"\", src: str = \"\", ds: str = \"\", **fetcher_kwargs):\n\n # Facade options:\n self._mode = OPTIONS[\"mode\"] if mode == \"\" else mode\n self._dataset_id = OPTIONS[\"dataset\"] if ds == \"\" else ds\n self._src = OPTIONS[\"src\"] if src == \"\" else sr... | [
"0.5919799",
"0.56867003",
"0.5336096",
"0.5336096",
"0.53005594",
"0.5059679",
"0.4984045",
"0.49795523",
"0.4886743",
"0.48733893",
"0.48436478",
"0.47754762",
"0.47312748",
"0.472386",
"0.4699327",
"0.46729732",
"0.46497443",
"0.4637465",
"0.4625413",
"0.46218348",
"0.4613... | 0.59569997 | 0 |
Convert a string of 'currency units' to 'protocol units'. For instance converts 19.1 bitcoin to 1910000000 satoshis. Input is a float, output is an integer that is 1e8 times larger. It is hard to do this conversion because multiplying floats causes rounding nubers which will mess up the transactions creation process. | def currency_to_protocol(amount):
if type(amount) == float:
amount = "%.8f" % amount
return int(amount.replace(".", '')) # avoiding float math | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SI_string_to_float(inStr, debug = False):\n func_name = \"SI_string_to_float\"\n \n # Debug print incoming string. \n if debug: print(\"DEBUG: (Func = %s): Input-str: %s\" %( func_name, inStr ))\n \n #Remove all spaces from incoming string. \n inStr = inStr.replace(\" \", \"\"); \n if ... | [
"0.6345295",
"0.623219",
"0.6227067",
"0.61324626",
"0.6060142",
"0.60457605",
"0.59942585",
"0.5937537",
"0.59248286",
"0.5890667",
"0.5804864",
"0.58029294",
"0.5782093",
"0.5778233",
"0.57768774",
"0.57661855",
"0.5747556",
"0.57015926",
"0.56892765",
"0.56356925",
"0.5630... | 0.6538345 | 0 |
Returns the number of minutes it would take to prepare a layer of lasagna assuming that each layer takes two minutes to prepare. | def preparation_time_in_minutes(number_of_layers):
return number_of_layers * 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preparation_time_in_minutes(number_of_layers):\n\n layers_preparation_time = number_of_layers * PREPARATION_TIME\n return layers_preparation_time",
"def preparation_time_in_minutes(number_of_layers: int) -> int:\n return PREPARATION_TIME_PER_LAYER_IN_MINUTES * number_of_layers",
"def elapsed_time_... | [
"0.76357484",
"0.76253945",
"0.7355335",
"0.72474456",
"0.72344285",
"0.7180381",
"0.71662813",
"0.69973075",
"0.6995725",
"0.59058905",
"0.59033453",
"0.5823773",
"0.57848847",
"0.5780186",
"0.5757861",
"0.5701689",
"0.56959116",
"0.56786025",
"0.56524414",
"0.56409097",
"0.... | 0.77988863 | 0 |
GET requrest to fetch categories of one domain_concept | def fetch_categories_from_json(domain_concept):
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"format": "json",
"titles": domain_concept,
"prop": "categories",
"clshow": "!hidden",
"cllimit": "500",
"re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_categories(self):\n _url = urljoin(self.base_url, self.API_CATEGORIES)\n return requests.get(_url)",
"def category():\n kwargs = {k: parse(v) for k, v in request.args.to_dict().items()}\n return jsonify(objects=get_categories(**kwargs))",
"def getcategory(self):\n\n response ... | [
"0.7066114",
"0.6781355",
"0.67293006",
"0.6696701",
"0.65975344",
"0.65901494",
"0.6539132",
"0.6525048",
"0.6497919",
"0.6476198",
"0.6472225",
"0.6450584",
"0.64220375",
"0.63992393",
"0.639708",
"0.6394131",
"0.6389033",
"0.6377105",
"0.633671",
"0.6330015",
"0.6316415",
... | 0.7764639 | 0 |
Allows the user to import a list of tickers from a .csv or .txt file using File>Import. The list should be have no headers and separated only by commas (i.e. aapl,msft,amzn). | def import_csv(self):
path = tk.filedialog.askopenfile(initialdir="/", title="Select File",
filetypes=(("Comma-separated values (.csv)", "*.csv"), ("Text Document (.txt)", "*.txt"),
("All Files", "*.*")))
items = []
if path is not None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_list(ctx, list_path):\n with open(list_path, 'r') as fobj:\n migrator.import_list(ctx.obj[\"sceptre_dir\"], ctx.obj[\"options\"], fobj)",
"def importAll():\n csvFile = openCsv()\n items = [] # chooseKey, count, grade, keyType, mainCategory, mainKey,\n # name, pricePer... | [
"0.6453703",
"0.63323754",
"0.60676646",
"0.5801094",
"0.5700352",
"0.5699906",
"0.5656859",
"0.56058544",
"0.5601727",
"0.5581669",
"0.55716777",
"0.55589217",
"0.5547348",
"0.55232644",
"0.5521119",
"0.5520321",
"0.5495789",
"0.5488231",
"0.5483142",
"0.5464",
"0.5458183",
... | 0.7377189 | 0 |
Allows the user to use File>Export to save the current stock data in the main table (i.e. Treeview). The supported file types are .csv or .txt. | def export_data(self):
stocks = {}
headings = ['Security', 'Price', 'Change', 'Change %', '52 Week', 'Market Cap']
for data in range(6):
for items in self.root.main.treeview.get_children():
values = self.root.main.treeview.item(items, 'values')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_csv(self):\n outputfile = tkinter.filedialog.asksaveasfilename(\n defaultextension=\".csv\",\n filetypes=((\"comma seperated values\", \"*.csv\"),\n (\"All Files\", \"*.*\")))\n if outputfile:\n tabledata = self.tabs.window.aistracker.... | [
"0.7445407",
"0.726318",
"0.72002023",
"0.6993101",
"0.6953994",
"0.6950085",
"0.693632",
"0.69200015",
"0.68654513",
"0.6848675",
"0.683781",
"0.68337893",
"0.6771233",
"0.6770515",
"0.66311675",
"0.65573436",
"0.6543675",
"0.6539647",
"0.6530406",
"0.648566",
"0.64745337",
... | 0.77522004 | 0 |
Controls the type of graph that should be displayed when the user toggles between the different radio buttons (View>Line/Area/or Candlestick). | def get_radio(self):
current_status = self.radio_var.get()
if current_status != self.radio_status:
self.radio_var.set(current_status)
self.radio_status = current_status
self.root.main.generate_graph(self.root.main.ticker)
self.root.main.remove_old_graphs() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_determine(self):\n\n if self.data_type == \"ECG\" or self.data_type == \"ENR\":\n self.curve_channel2 = self.ECGWinHandle.plot(self.display_channel2, pen=self.pen)\n self.curve_channel1 = self.RespirationWinHandle.plot(self.display_channel1, pen=self.pen)\n self.two... | [
"0.65135646",
"0.6226837",
"0.6012273",
"0.5992632",
"0.59125817",
"0.5824621",
"0.57382417",
"0.5715397",
"0.5700875",
"0.5674518",
"0.5663544",
"0.5602436",
"0.5596767",
"0.5595376",
"0.5576069",
"0.55676216",
"0.5537816",
"0.55231786",
"0.55224645",
"0.5493871",
"0.5481482... | 0.6407343 | 1 |
Highlights all of the items in the main table (Treeview) when the user uses View>Select All. This enables the user to use the Remove button to delete multiple line of stocks, rather than one at a time. | def select_all(self):
selected_stocks = self.root.main.treeview.get_children()
self.root.main.treeview.selection_set(selected_stocks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def onSelectAll(self, event):\n\t\tself.ignore = 1\n\t\tself.selectAll(self.tree.GetRootItem())\n\t\tself.ignore = 0",
"def unselectAll(self):\n\t\tself.tree.UnselectAll()",
"def SelectAll(self):\r\n\r\n if not self.HasAGWFlag(TR_MULTIPLE) and not self.HasAGWFlag(TR_EXTENDED):\r\n raise Excep... | [
"0.7141967",
"0.67098427",
"0.66680944",
"0.66445816",
"0.6534179",
"0.6387627",
"0.6363737",
"0.6173146",
"0.6083701",
"0.605215",
"0.5967203",
"0.58961",
"0.58535594",
"0.58238137",
"0.5772508",
"0.5718996",
"0.5689734",
"0.56806684",
"0.5675034",
"0.56437683",
"0.55932295"... | 0.73707426 | 0 |
Retrieves the user's ticker entry and calls get_quote() to add the stock to the main table. | def add_ticker(self):
ticker = self.addEntry.get().upper()
self.get_quote(ticker) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def stock(self, ctx, ticker: str):\n symbols = await self.bot.aiojson(\"https://api.robinhood.com/quotes/\"\\\n f\"?symbols={ticker.upper()}\")\n if not symbols:\n await ctx.send(\"Stock not found. This stock is probably not tradeable on robinho... | [
"0.6663892",
"0.64932716",
"0.6319052",
"0.600088",
"0.5978827",
"0.595742",
"0.5901351",
"0.5878906",
"0.5865346",
"0.57955796",
"0.57895046",
"0.5773195",
"0.5716135",
"0.57135934",
"0.5705392",
"0.56965435",
"0.56572646",
"0.5634664",
"0.56225175",
"0.5598838",
"0.5586135"... | 0.70812464 | 0 |
Function fixes a styling bug in Tkinter see References. Returns the style map for 'option' with any styles starting with ("!disabled", "!selected", ...) filtered out | def fixed_map(self, option):
return [elm for elm in self.style.map("Treeview", query_opt=option) if elm[:2] != ("!disabled", "!selected")] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_tkinter_color_tags(self) -> None:\r\n def fixed_map(option):\r\n # Fix for setting text colour for Tkinter 8.6.9\r\n # From: https://core.tcl.tk/tk/info/509cafafae\r\n #\r\n # Returns the style map for 'option' with any styles starting with\r\n ... | [
"0.74411803",
"0.56792116",
"0.55870986",
"0.52520955",
"0.52229935",
"0.5221422",
"0.5219594",
"0.52169347",
"0.520076",
"0.51779526",
"0.50953865",
"0.5011394",
"0.49788842",
"0.49769038",
"0.4953765",
"0.4946684",
"0.4901559",
"0.48950547",
"0.4883113",
"0.48736447",
"0.48... | 0.66413915 | 1 |
Opens a window that enables the user to save the current graph as a .png or .pdf file. | def save_image(self):
filename = filedialog.asksaveasfilename(title='Save Image As...',
filetypes=(("Portable Network Graphics (.png)", "*.png"), ("Portable Document Format(.pdf)", "*.pdf")))
self.graph.savefig(filename, dpi=self.graph.dpi) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_graph_ui(self):\n filename = input('enter name of the file to save to: ')\n write_graph(self._graph, filename)",
"def on_save(self, event):\n file_choices = \"PNG (*.png)|*.png\"\n \n dlg = wx.FileDialog(\n self, \n message=\"Save plot as...\",\n... | [
"0.7217422",
"0.7016907",
"0.66421396",
"0.6605833",
"0.64459157",
"0.64049566",
"0.6354926",
"0.63502014",
"0.63342744",
"0.63194656",
"0.6317963",
"0.6296376",
"0.6271151",
"0.62541837",
"0.62486297",
"0.62270635",
"0.6159292",
"0.61244416",
"0.60962695",
"0.60937",
"0.6076... | 0.70776874 | 1 |
Dates obtained from the API are in string form, which is converted to Date objects using Date's datestr2num() method. | def bytes_to_dates(self, date_str):
return mpldates.datestr2num(date_str.decode('utf-8')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stringToDate(self, date_strings: list) -> list:\n date_objs = []\n try:\n if isinstance(date_strings, list) == False:\n return date_objs\n\n for date_string in date_strings:\n if isinstance(date_string, str) == False:\n ... | [
"0.61840266",
"0.617582",
"0.6147605",
"0.61337614",
"0.5942185",
"0.58880126",
"0.5846233",
"0.5845299",
"0.5827857",
"0.5782635",
"0.5773858",
"0.5759535",
"0.5754985",
"0.57446635",
"0.5744189",
"0.57410395",
"0.5739683",
"0.5721081",
"0.5720584",
"0.57147133",
"0.56842184... | 0.71613 | 0 |
When the user's mouse leaves a button, the color of the button reverts back to default. | def mouse_out(self, event):
self['background'] = self.defaultBackground | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_unhovered(self):\n if not self.is_selected:\n self.colour = self.normal_colour\n self.is_hovered = False\n self.redraw()",
"def mouse_hover(self):\n self.color1 = self.color # Color changes\n position = pygame.mouse.get_pos() # Get mouse position\n ... | [
"0.72943413",
"0.6943251",
"0.6819052",
"0.677835",
"0.67594427",
"0.66331226",
"0.6542121",
"0.65353227",
"0.6530496",
"0.6511707",
"0.6458569",
"0.64402485",
"0.62088054",
"0.61456305",
"0.6141677",
"0.6097752",
"0.6097556",
"0.6074266",
"0.6046606",
"0.6037004",
"0.5994515... | 0.75050884 | 0 |
get all images related to project | def getImages(self,Project=""):
#images = ["image1.jpg","image2.jpg","image3.jpg"]
os.chdir(self.dataDir)
images = glob.glob("*.png")
return images | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def images(self):\n return self.gameimage_set.all()",
"def list_images(self):\n raise NotImplementedError()",
"def getimgs():",
"def get_images(self):\n \n return self.img_lst",
"def get_images(self):\n return self._get_brains(\"Image\")",
"def images(self):\n re... | [
"0.7327203",
"0.69998074",
"0.69711775",
"0.6830976",
"0.68156797",
"0.67610174",
"0.67610174",
"0.6712448",
"0.6647156",
"0.6633519",
"0.66168433",
"0.66165423",
"0.66083795",
"0.6598045",
"0.65965533",
"0.65742016",
"0.6485215",
"0.6461639",
"0.64360774",
"0.64273465",
"0.6... | 0.7379376 | 0 |
Return a text list with output for this node and its descendents. | def exportNode(self, node, level=0):
title = node.title()
textList = ['<node>', title, repr(level)]
output = node.formatOutput(True)
if output and output[0] == title:
del output[0] # remove first line if same as title
textList.extend(output)
if (output an... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodes(self):\r\n return (node.content for node in self.traverse())",
"def display_content(self):\n list = []\n traverse = self.head\n\n if self.head == None:\n return\n\n while traverse.next != None:\n list.append(traverse.data)\n traverse =... | [
"0.67282903",
"0.66896945",
"0.6634623",
"0.658442",
"0.6583838",
"0.6547543",
"0.65079314",
"0.6504865",
"0.6456624",
"0.64089566",
"0.64089566",
"0.63779",
"0.6341909",
"0.6293093",
"0.6272136",
"0.6246248",
"0.62418544",
"0.62404114",
"0.62278014",
"0.6210254",
"0.61758155... | 0.69072855 | 0 |
Taken from mock_django as importing mock_django created issues with Django 1.9+ Temporarily attaches a receiver to the provided ``signal`` within the scope of the context manager. The mocked receiver is returned as the ``as`` target of the ``with`` statement. To have the mocked receiver wrap a callable, pass the callab... | def mock_signal_receiver(signal, wraps=None, **kwargs):
if wraps is None:
def wraps(*args, **kwrags):
return None
receiver = mock.Mock(wraps=wraps)
signal.connect(receiver, **kwargs)
yield receiver
signal.disconnect(receiver) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receiver(signal, **kwargs):\n def _decorator(func):\n signal.connect(func, **kwargs)\n return func\n return _decorator",
"def wrapped(signal_name, sender=dispatcher.Anonymous, safe=False):\n @wrapt.decorator\n def signal_wrapped(wrapped_func, _, args, kwargs):\n def signal_wr... | [
"0.71629137",
"0.68933326",
"0.6635234",
"0.62061095",
"0.6023584",
"0.59278005",
"0.5376492",
"0.52532405",
"0.519832",
"0.5154296",
"0.51226974",
"0.5118041",
"0.5066991",
"0.5027219",
"0.50008833",
"0.49629828",
"0.49582055",
"0.49504954",
"0.49269605",
"0.48819363",
"0.48... | 0.80449164 | 0 |
function that returns True if a human face is detected in the image, False otherwise | def face_detector(img_path: str):
img = cv2.imread(img_path)
# if no image at that path, return False
if img is None:
return False
# convert to grey
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# detect faces. If no face detected, it's empty and len(faces) will be 0
fac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_face(image):\n cascadePath = \"haarcascade_frontalface_default.xml\"\n faceCascade = cv2.CascadeClassifier(cascadePath)\n faces = faceCascade.detectMultiScale(image)\n if len(faces)>=1:#Should be == , not >=\n return True\n return False",
"def __detect_face(self, img):\n g... | [
"0.7589063",
"0.7457245",
"0.73810637",
"0.73685",
"0.72959054",
"0.7226459",
"0.7161101",
"0.7093389",
"0.704011",
"0.70398116",
"0.69383246",
"0.693281",
"0.6891454",
"0.68514115",
"0.6821416",
"0.6819502",
"0.67627144",
"0.6757088",
"0.67529106",
"0.67441094",
"0.67169964"... | 0.74828804 | 1 |
Extracts `gzip_file` and put into `path`. If members is None, all members on `gzip_file` will be extracted. | def decompress(infile, path, members=None):
with open(infile, 'rb') as inf, open(path, 'w', encoding='utf8') as tof:
decom_str = gzip.decompress(inf.read()).decode('utf-8')
tof.write(decom_str) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extracted_file(fname: str):\n new_fname = extract_gzip(fname)\n gzipped = True\n if new_fname is None:\n new_fname = fname\n gzipped = False\n\n try:\n yield new_fname\n finally:\n if gzipped:\n try:\n bgzip_and_name(new_fname)\n e... | [
"0.6059144",
"0.58870894",
"0.5631394",
"0.55601245",
"0.55015296",
"0.54435426",
"0.53970474",
"0.53848666",
"0.5355207",
"0.51767236",
"0.516184",
"0.51334137",
"0.50963324",
"0.50776106",
"0.50739133",
"0.50640243",
"0.5033139",
"0.50164115",
"0.49896464",
"0.49798658",
"0... | 0.62323934 | 0 |
Train the particle proposer k. | def train_particle_proposer(self):
batch_size = self.trainparam['batch_size']
# epochs = self.trainparam['epochs']
epochs = 500
lr = self.trainparam['learning_rate']
particle_num = self.trainparam['particle_num']
std = 0.2
encoder_checkpoint = "encoder.pth"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self,data,k=None,pca_k=None,frac=0.99,g=g,gp=gp):\n assert self.w is None\n n,d = data.shape\n ys,mean,evals,evecs = pca(data,k=pca_k,frac=frac)\n assert \"ys\",ys.shape==(n,len(evals))\n if verbose: print \"#pca\",len(evals),\"#ica\",k\n if not k: k = len(evals)... | [
"0.64393586",
"0.62180954",
"0.61506796",
"0.6123583",
"0.6122",
"0.6104697",
"0.6045328",
"0.6045328",
"0.6045328",
"0.6045328",
"0.6045328",
"0.60043406",
"0.59965163",
"0.59941137",
"0.5941362",
"0.59407806",
"0.59160984",
"0.59159684",
"0.59156156",
"0.59127027",
"0.58767... | 0.66061413 | 0 |
Eval the particle proposer | def eval_particle_proposer(self, val_loader, epoch):
std = 0.2
mle_loss_total = 0.0
niter = 0
sta_eval = None
particles_eval = None
for i, (sta, obs, act) in enumerate(val_loader):
obs = obs.cuda().reshape(-1, 24, 24, 3).permute(0,3,1,2).float()
st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concurrent_run(self, particle): \r\n # Store the leader values.\r\n leader_vals = self.population[self.leader].values[:]\r\n \r\n # Calculate velocity and move the particle\r\n particle.calculate_velocity(leader_vals)\r\n particle.move()\r\n particle.eval... | [
"0.6455133",
"0.6242884",
"0.61741954",
"0.6163354",
"0.6160182",
"0.61242706",
"0.6119348",
"0.60299283",
"0.5946909",
"0.5920901",
"0.5920901",
"0.58675283",
"0.58139575",
"0.5796437",
"0.57879937",
"0.5752707",
"0.5751892",
"0.5746129",
"0.5746129",
"0.5746129",
"0.5711546... | 0.72165954 | 0 |
Train the observation likelihood estimator l (and h) | def train_likelihood_estimator(self):
batch_size = self.trainparam['batch_size']
epochs = self.trainparam['epochs']
lr = self.trainparam['learning_rate']
self.observation_encoder = self.observation_encoder.double()
self.likelihood_estimator = self.likelihood_estimator.double()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self):\n print('Model training...')\n self.model.train()\n self.likelihood.train()\n optimizer = torch.optim.Adam(\n [{'params': self.model.parameters()}], lr=self.lr)\n mll = gpytorch.mlls.ExactMarginalLogLikelihood(\n self.likelihood, self.model)... | [
"0.6739514",
"0.6686832",
"0.6679614",
"0.6646005",
"0.6523777",
"0.64466846",
"0.6406941",
"0.63663316",
"0.6349435",
"0.6287824",
"0.6273677",
"0.62623334",
"0.6183656",
"0.6168636",
"0.6103057",
"0.60933506",
"0.6079881",
"0.6073172",
"0.6053924",
"0.60450405",
"0.60129815... | 0.69414866 | 0 |
Eval the observation encoder and likelihood estimator | def eval_likelihood_estimator(self, val_loader):
likelihood_list = []
self.observation_encoder.eval()
self.likelihood_estimator.eval()
for i, (sta, obs, act) in enumerate(val_loader):
if self.use_cuda:
sta = sta.cuda()
obs = obs.cuda()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, prediction_fn):\n pass",
"def _evaluate_during_fit(self, test_loader, epoch):",
"def predict_and_eval_in_val(self, sess, tst_reader, metrics):\n raise NotImplementedError(\"\"\"please customize predict_and_eval_in_val\"\"\")",
"def evaluate_model():\n\n print '\\n\\tevaluate r... | [
"0.61521804",
"0.6110636",
"0.609378",
"0.60804623",
"0.60392636",
"0.5955893",
"0.5954635",
"0.5940345",
"0.5918772",
"0.58762807",
"0.58693737",
"0.58433896",
"0.5841193",
"0.5839023",
"0.58384997",
"0.5837645",
"0.58222324",
"0.5814333",
"0.5814333",
"0.58062136",
"0.57782... | 0.63555586 | 0 |
Rename sample names by map and ratify action. | def _rename_samples_by_map(self, map_like: Mapper, **kwargs) -> Optional[Mapper]:
self.__internal_samples.rename(mapper=map_like, axis=0, inplace=True)
return self._ratify_action("_rename_samples_by_map", map_like, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename_samples(self, mapper: Mapper) -> None:\n if isinstance(mapper, dict) or callable(mapper):\n if isinstance(mapper, dict):\n if self.__internal_samples.index.isin(list(mapper.keys())).sum() == len(\n mapper\n ):\n self._... | [
"0.62875706",
"0.6122589",
"0.58786887",
"0.5842476",
"0.57060355",
"0.5681072",
"0.56760776",
"0.56022245",
"0.55651444",
"0.54647946",
"0.5371891",
"0.5359007",
"0.535444",
"0.5341678",
"0.53200805",
"0.5317255",
"0.53028625",
"0.52757776",
"0.5255851",
"0.5231632",
"0.5212... | 0.76349956 | 0 |
Remove samples by sample ids and ratify action. | def _remove_samples_by_id(
self, ids: AnyGenericIdentifier, **kwargs
) -> Optional[AnyGenericIdentifier]:
tmp_ids = np.asarray(ids, dtype=self.__internal_samples.index.dtype)
if len(tmp_ids) > 0:
self.__internal_samples.drop(tmp_ids, inplace=True)
return self._ratify_acti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_sample_by_id(\n self, ids: AnyGenericIdentifier, **kwargs\n ) -> Optional[AnyGenericIdentifier]:\n target_ids = np.asarray(ids)\n if self.xsid.isin(target_ids).sum() == len(target_ids):\n return self._remove_samples_by_id(target_ids, **kwargs)\n else:\n ... | [
"0.639226",
"0.6127415",
"0.59162337",
"0.5895755",
"0.58001274",
"0.57886416",
"0.5755829",
"0.5753229",
"0.57482225",
"0.5744503",
"0.57300043",
"0.5729377",
"0.56691384",
"0.56171346",
"0.56045634",
"0.5599522",
"0.55981165",
"0.5546974",
"0.55387175",
"0.5537321",
"0.5509... | 0.73254853 | 0 |
Rename sample names by `mapper` | def rename_samples(self, mapper: Mapper) -> None:
if isinstance(mapper, dict) or callable(mapper):
if isinstance(mapper, dict):
if self.__internal_samples.index.isin(list(mapper.keys())).sum() == len(
mapper
):
self._rename_samp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rename_samples_by_map(self, map_like: Mapper, **kwargs) -> Optional[Mapper]:\n self.__internal_samples.rename(mapper=map_like, axis=0, inplace=True)\n return self._ratify_action(\"_rename_samples_by_map\", map_like, **kwargs)",
"def rename(self, mapper: Mapping[str, str], inplace=False):\n ... | [
"0.758194",
"0.6715578",
"0.6559243",
"0.6354417",
"0.6306243",
"0.6277657",
"0.62350434",
"0.61070985",
"0.6100785",
"0.60922843",
"0.606802",
"0.60659134",
"0.6048143",
"0.60295737",
"0.59960866",
"0.59960866",
"0.5964489",
"0.5943025",
"0.5927815",
"0.5917615",
"0.58999753... | 0.7247714 | 1 |
Drop samples by sample identifiers. | def drop_sample_by_id(
self, ids: AnyGenericIdentifier, **kwargs
) -> Optional[AnyGenericIdentifier]:
target_ids = np.asarray(ids)
if self.xsid.isin(target_ids).sum() == len(target_ids):
return self._remove_samples_by_id(target_ids, **kwargs)
else:
raise Value... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _remove_samples_by_id(\n self, ids: AnyGenericIdentifier, **kwargs\n ) -> Optional[AnyGenericIdentifier]:\n tmp_ids = np.asarray(ids, dtype=self.__internal_samples.index.dtype)\n if len(tmp_ids) > 0:\n self.__internal_samples.drop(tmp_ids, inplace=True)\n return self._... | [
"0.74150854",
"0.7046915",
"0.6834506",
"0.6785585",
"0.64242166",
"0.62633795",
"0.62346476",
"0.6174152",
"0.6078232",
"0.6041745",
"0.6000368",
"0.5999657",
"0.59908336",
"0.5947375",
"0.59472364",
"0.5927663",
"0.59003496",
"0.5890255",
"0.5872719",
"0.581554",
"0.5750582... | 0.7465148 | 0 |
Merge samples by `variable`. | def merge_samples_by_variable(
self,
variable: Union[str, int],
aggfunc: Union[str, Callable] = "mean",
**kwargs
) -> Optional[Mapper]:
ret = {}
if variable not in self.__internal_samples.columns:
raise TypeError("`variable` is invalid.")
groups = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(self, other):\n from .dataset import Dataset\n\n if other is None:\n return self.to_dataset()\n else:\n other_vars = getattr(other, 'variables', other)\n coords = merge_coords_without_align([self.variables, other_vars])\n return Dataset._fr... | [
"0.52228075",
"0.5189853",
"0.5175908",
"0.51393616",
"0.5125164",
"0.50996494",
"0.5005073",
"0.49820113",
"0.49564427",
"0.49465445",
"0.49429476",
"0.47864658",
"0.47500086",
"0.47321397",
"0.47253013",
"0.4686079",
"0.46686253",
"0.4648857",
"0.4644902",
"0.4642439",
"0.4... | 0.7045637 | 0 |
Reads lines from stdin pipe and yields results onebyone. | def stdin():
while sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
line = sys.stdin.readline()
if not line:
yield from []
break
line = line.strip()
yield line | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(self):\n global ALIVE\n line = sys.stdin.readline()\n if line:\n self.datalines.append(line.rstrip())\n else:\n ALIVE = False",
"def input_pipe():\n x = ''\n while True:\n x = yield x\n yield # to keep the generator i... | [
"0.7002173",
"0.68451184",
"0.6831364",
"0.67381227",
"0.66947484",
"0.6597664",
"0.6512728",
"0.63904774",
"0.6314287",
"0.627424",
"0.62568915",
"0.62506276",
"0.62384653",
"0.6230553",
"0.6169669",
"0.6162527",
"0.6154525",
"0.60982656",
"0.6039983",
"0.6033005",
"0.600947... | 0.7376354 | 0 |
Takes iterator (list or generator) `lines` and spawns `procs` processes, calling `func` with prefined arguments `args` and `kwargs`. Using a queue and multiprocessing to call `func` with the format func(line, args, kwargs) | def parallel(lines, func, args, kwargs, procs=1):
# Start a queue with the size of processes for jobs and a result queue to
# collect results
q_res = mp.Queue()
q_job = mp.Queue(maxsize=procs)
# print lock
iolock = mp.Lock()
# Start the pool and await queue data
pool = mp.Pool(procs,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_multi(lines, func, p=6, suffix=0, write=False, pre_train=True):\n _info('Execute by {}th processes'.format(p))\n pool = Pool(p)\n \n if type(lines) is not zip:\n num_each_b = len(lines) // p\n else:\n # fine tune step, the lines is zip type,\n # this kind of type has n... | [
"0.67201364",
"0.6118932",
"0.6028883",
"0.59322655",
"0.58721066",
"0.5838347",
"0.57472163",
"0.5645924",
"0.560323",
"0.5565889",
"0.5487812",
"0.54873794",
"0.5484812",
"0.5465275",
"0.5445566",
"0.5393869",
"0.5362366",
"0.5309487",
"0.5305509",
"0.52861315",
"0.52560574... | 0.7778335 | 0 |
Create a Run object by reading in a CSV per the pandas read_csv function. | def read_csv(cls, filepath, name=None, description="", **kwargs):
name = filepath if name is None else name
return Run(read_csv(filepath, **kwargs), name=name, description=description) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_csv(cls, name, csv, **kwargs):\r\n data = pd.read_csv(csv, **kwargs)\r\n return Dataset(name, data, **kwargs)",
"def from_csv(file):\n return Replay(Replay.load_csv(file))",
"def from_csv(cls, csv_path, split, window_size,\n spect_key='s', timebins_key='t',\n ... | [
"0.69199145",
"0.6711728",
"0.6519591",
"0.65187865",
"0.6486966",
"0.6481388",
"0.63636446",
"0.63416",
"0.63012636",
"0.6271003",
"0.6253085",
"0.6209066",
"0.6188546",
"0.613258",
"0.61289513",
"0.60237086",
"0.60145247",
"0.601076",
"0.6008511",
"0.5987274",
"0.59781855",... | 0.74075174 | 0 |
=> Verify that can clear all breakpoints. | def test_40_clear_all(self):
break_bar = {"gdb": "break Bar\n", "lldb": "breakpoint set --fullname Bar\n"}
for backend, spec in subtests.items():
with self.subTest(backend=backend):
e.Ty(spec['launch'], delay=1)
e.Ty(break_bar[backend])
e.Ty(sp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_all_breakpoints(self):\r\n #clear all the breakpoints in each engine\r\n console = self.app.toolmgr.get_tool('Console')\r\n engines = console.get_all_engines()\r\n\r\n for eng in engines:\r\n res = self.msg_node.send_msg( eng.engine, \r\n ... | [
"0.7303463",
"0.686518",
"0.67131716",
"0.66601884",
"0.654117",
"0.6340336",
"0.6269009",
"0.6067638",
"0.6050389",
"0.604842",
"0.6022217",
"0.6000273",
"0.59525955",
"0.5908845",
"0.5884856",
"0.5869769",
"0.5840302",
"0.5840302",
"0.5840302",
"0.5840302",
"0.5790643",
"... | 0.75628 | 0 |
Generate a random set of bias model parameters for this feedback modality in this environment. | def init_bias_params(self, rng):
return self.bias_prior.sample(rng) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize_weights(self):\n stddev = 1.0 / math.sqrt(self._hidden_size)\n for layer_id, param_id in itertools.product(\n range(self._num_layers * (self._bidirectional + 1)),\n range(self._num_gates * 2)):\n i = layer_id * 2 + (param_id // self._num_gates)... | [
"0.67339844",
"0.6387431",
"0.63218606",
"0.6161945",
"0.61466396",
"0.6132584",
"0.6097028",
"0.60850155",
"0.6051843",
"0.5974299",
"0.59514433",
"0.59435046",
"0.5919739",
"0.59047526",
"0.5899074",
"0.5845318",
"0.5845318",
"0.5845318",
"0.58354235",
"0.5826014",
"0.58259... | 0.7700251 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.