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 |
|---|---|---|---|---|---|---|
plot image given image_path | def plot_image_path(image_path, log_image_path=False):
img = load_img(image_path)
if log_image_path:
plt.title(image_path)
plt.imshow(img)
plt.axis('off')
plt.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_image(path):\n img = mpimg.imread(path)\n imgplot = plt.imshow(img)\n plt.show()\n plt.close()",
"def plot_image(image):\n plt.imshow(image, cmap=\"gray\", interpolation=\"nearest\")\n plt.axis(\"off\")",
"def plot_image(img, label=\"\"): \n if img.shape[0] == 3:\n img = im... | [
"0.8064528",
"0.6927323",
"0.68491775",
"0.6829865",
"0.68138057",
"0.6799452",
"0.67860734",
"0.6765616",
"0.67493564",
"0.67214227",
"0.6706817",
"0.6699842",
"0.6699842",
"0.6699842",
"0.6646708",
"0.6622579",
"0.6584521",
"0.6538649",
"0.6536479",
"0.65353954",
"0.6519856... | 0.7923502 | 1 |
plot several images given a list of image_path in an harmonious way | def plot_list_image_path(list_image_path, log_image_path=False):
i = 1
nb_img = len(list_image_path)
plt.figure(figsize=(10, 2 * nb_img))
for image_path in list_image_path:
if not os.path.isfile(image_path):
continue
img = load_img(image_path)
plt.subplot(math.ceil(nb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plotImages(image_list, name_list, path, as_grey, toSave=False):\n\n\tfig = plt.figure()\n\timageCoordinate = 100 + 10*len(image_list) + 1\n\ti = 0\n\n\tfor image in image_list:\n\t\tfig.add_subplot(imageCoordinate)\n\t\tplt.title(name_list[i])\n\t\tplt.axis('off')\n\t\tplt.imshow(image)\n\t\tif as_grey:\n\t\t\... | [
"0.7502847",
"0.74570805",
"0.74381226",
"0.73197323",
"0.7233793",
"0.7233793",
"0.7233793",
"0.7216493",
"0.7094925",
"0.70881605",
"0.7048051",
"0.69314724",
"0.6889973",
"0.68867373",
"0.6821303",
"0.68144023",
"0.6755941",
"0.6715435",
"0.6669353",
"0.6636312",
"0.663594... | 0.82239616 | 0 |
plot image from numpy array | def plot_numpy_img(np_img):
plt.imshow(np_img, interpolation='nearest')
plt.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display(array):\n plt.figure()\n plt.imshow(array)\n plt.show()",
"def plot_pixel_array(arr, figsize=(10, 10)):\n arr = arr.squeeze()\n plt.figure(figsize=figsize)\n plt.imshow(arr, cmap=plt.cm.bone)\n plt.show()",
"def plot_img(X: np.ndarray, **kwargs):\n kwargs.setdefa... | [
"0.7948006",
"0.7529159",
"0.7480953",
"0.7217086",
"0.72111607",
"0.70048296",
"0.68409413",
"0.681222",
"0.6800085",
"0.6799093",
"0.67556494",
"0.67556494",
"0.67556494",
"0.6688222",
"0.6679564",
"0.66598195",
"0.6649299",
"0.6636986",
"0.66299415",
"0.66115326",
"0.65907... | 0.7928939 | 1 |
Given two numbers 'num1' and 'num2', returns the maximum number of decimals found in them. | def max_num_decims(num1, num2):
num_max_decs = 0
if ("." in num1) or ("." in num2):
if ("." in num1) and ("." not in num2):
num1A, num1B = num1.split(".")
num_max_decs = len(num1B)
elif ("." in num2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_of_num(first_number: float, second_number: float) -> float:\n return round( second_number / ( first_number / 100 ))",
"def dif_num_of_num(first_number: float, second_number: float) -> float:\n return ( first_number - second_number ) / (( first_number + second_number ) / 2 ) * 100",
"def num_decim... | [
"0.6840515",
"0.67008334",
"0.66440177",
"0.6280915",
"0.6216799",
"0.61641777",
"0.6043872",
"0.6019178",
"0.593011",
"0.59276146",
"0.5833329",
"0.57304245",
"0.57168067",
"0.56887305",
"0.5664995",
"0.56517833",
"0.56353617",
"0.56103504",
"0.557371",
"0.557188",
"0.556313... | 0.7820551 | 0 |
Counts the number of zeros at the beginning of the number 'num'. | def num_zeros_init(num):
iszero = True
num_zeros = 0
i = 0
while iszero == True and (i != len(num)-1):
if num[i] == "0":
num_zeros += 1
elif num[i] != "0":
iszero = False
i += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _count_zero(number):\n zero_count = 0\n while number > 9:\n if number % 10 == 0:\n zero_count += 1\n number /= 10\n else:\n break\n return zero_count",
"def countTrailingZeros(num):\n if num == 0:\n return 32 # Assumes 32 bit integer inputs!\n p = ... | [
"0.7276163",
"0.7096427",
"0.7072348",
"0.6729377",
"0.61873144",
"0.61611557",
"0.6115402",
"0.607611",
"0.6074377",
"0.5987204",
"0.5855923",
"0.57834613",
"0.57722956",
"0.5741183",
"0.57247156",
"0.57234144",
"0.56539124",
"0.5640718",
"0.5607971",
"0.55508775",
"0.553792... | 0.7404852 | 0 |
Counts the number of zeros at the end of the number 'num'. | def num_zeros_end(num):
iszero = True
num_zeros = 0
i = len(num)-1
while (iszero == True) and (i != 0):
if num[i] == "0":
num_zeros += 1
elif num[i] != "0":
iszero = False
i -= 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def countTrailingZeros(num):\n if num == 0:\n return 32 # Assumes 32 bit integer inputs!\n p = 0\n while (num >> p) & 1 == 0:\n p += 1\n return p",
"def _count_zero(number):\n zero_count = 0\n while number > 9:\n if number % 10 == 0:\n zero_count += 1\n number /= 10\n... | [
"0.7950319",
"0.74497575",
"0.72194856",
"0.68119925",
"0.66915673",
"0.66034704",
"0.65522856",
"0.64395845",
"0.6425418",
"0.6229586",
"0.60904527",
"0.60578483",
"0.6010345",
"0.5990095",
"0.5969252",
"0.5916974",
"0.5899573",
"0.58342046",
"0.5814871",
"0.57064193",
"0.56... | 0.7956952 | 0 |
If the number 'num' has decimals, deletes the excess of zeros at the end of it. | def del_decim_zeros(num):
if "." in num:
num_zeros = num_zeros_end(num)
if num_zeros != 0:
num = num[:-num_zeros]
if num[-1] == ".":
num = num[:-1]
return num
else:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_trailing(amount, decimals=2):\n if not amount:\n return amount\n\n s = str(float(amount)).rstrip('0')\n if decimals == 0:\n return s.rstrip('.')\n\n num_decimals = len(s.split('.')[1])\n num_to_add = decimals - num_decimals\n if num_to_add <= 0:\n return s\n\n ret... | [
"0.6825014",
"0.65626127",
"0.6189331",
"0.61214405",
"0.6027722",
"0.6005111",
"0.59891474",
"0.5857598",
"0.5807634",
"0.5779842",
"0.57499546",
"0.57214636",
"0.56866354",
"0.5623665",
"0.5585848",
"0.5579912",
"0.5566864",
"0.55557907",
"0.5552921",
"0.5507861",
"0.550686... | 0.8043163 | 0 |
Takes a string ('txt') and separates it into pairs of characters returning a list with those pairs. | def make_pairs(txt):
lista = []
string = ""
count = 0
if len(txt)%2 != 0 :
count = 1
for i in range(len(txt)):
string += txt[i]
count += 1
if count == 2:
lista.append(string)
string = ""
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pairs(self, word: List[str]) -> List[Tuple[str, str]]:\n pairs: List[Tuple[str, str]] = []\n prev_char = word[0]\n for char in word[1:]:\n pairs.append((prev_char, char))\n prev_char = char\n return pairs",
"def split_strings_to_two_char(*, text: str) -> ... | [
"0.7374797",
"0.6932629",
"0.6583168",
"0.6506529",
"0.6506529",
"0.6500643",
"0.64662534",
"0.6421593",
"0.638958",
"0.6286382",
"0.62012094",
"0.61638594",
"0.61089104",
"0.60459656",
"0.6004015",
"0.5994394",
"0.598661",
"0.59281266",
"0.5900024",
"0.5898023",
"0.58834136"... | 0.7311179 | 1 |
This function uses the long division algorithm to divide two numbers. max_iter = maximum number of iterations; equivalent to the maximum number of decimals plus one (dec = max_iter1). The result is in the format "string". | def divide_str(dividend, divider, decimal_prec=16):
max_iter = decimal_prec + 1
remainder = 1 # != 0
i = 0
# Check for decimals.
dividend, divider = decim_modif_str(dividend, divider)
dividend, divider = int(dividend), int(divider)
while (remainder !... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def long_division(dividend_divisor_tuple, decimal_limit=5):\n\n natural, decimal = [], []\n dividend, divisor = dividend_divisor_tuple[0], dividend_divisor_tuple[1]\n assert isinstance(dividend, int), \"Dividend not int\"\n assert isinstance(divisor, int), \"Divisor not int\"\n floor_div = dividend ... | [
"0.6818187",
"0.65036654",
"0.6257712",
"0.6184741",
"0.6151501",
"0.60843754",
"0.58361936",
"0.5797674",
"0.57211536",
"0.5672084",
"0.5647573",
"0.55608547",
"0.5531552",
"0.5528654",
"0.55112994",
"0.55112994",
"0.5506642",
"0.54791534",
"0.547875",
"0.54733145",
"0.54708... | 0.6573053 | 1 |
Calculation of the square root of a number 'num' in string format. The decimal precision is set by "decimal_prec". The result is given in string format. The result is obtained using a digitbydigit calculation algorithm. | def sqrt_str(num, decimal_prec = 16):
#initialization
if "." in num:
numA, numB = num.split(".")
num_bef_rad = len(numA) # Number of digits before the decimal point in the radicand.
if len(numB)%2 != 0: # If there's not an even number of d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def standard_form(num: Decimal):\n num = Decimal(num)\n\n if num >= 1:\n power = 0\n while num > 1:\n power += 1\n num /= 10\n\n else:\n power = 0\n while num < 1:\n power -= 1\n num *= 10\n if num > 1:\n bre... | [
"0.6061514",
"0.60223246",
"0.5774929",
"0.57738525",
"0.5612643",
"0.56078285",
"0.5549438",
"0.5453259",
"0.53418005",
"0.5282369",
"0.5268672",
"0.52399194",
"0.52296865",
"0.51737946",
"0.51602733",
"0.5138481",
"0.51248676",
"0.51180655",
"0.5111184",
"0.5111184",
"0.507... | 0.7251397 | 0 |
Calculate the power of a number in string format. Returns numpowr. 'powr' must be a positive integer. | def power_str(num, powr):
orig_num = num
for i in range(powr-1):
num = multiply_str(num, orig_num)
return num | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def powerize(n, p):\n return sum(int(d)**p for d in str(n))",
"def _pow_(self, n):\n assert n > 0\n return generic_power(self, n)",
"def power(number, power):\n return math.pow(number, power)",
"def sum_of_digit_powers_in_number(n: int, power: int) -> int:\n return sum(int(digi... | [
"0.6638005",
"0.63242984",
"0.6266292",
"0.62097716",
"0.61159164",
"0.6059749",
"0.6014731",
"0.60064286",
"0.6003567",
"0.59821033",
"0.59268105",
"0.5904753",
"0.5875559",
"0.58696187",
"0.5813878",
"0.57684225",
"0.57546574",
"0.574704",
"0.57453716",
"0.56904",
"0.565644... | 0.8085662 | 0 |
Convert a value to the correct type for this field. Values from the database will already be of the correct type, due to the the caster registered with psycopg2. The field can also be serialized as a string via value_to_string, where it is encoded as a JSON object. | def to_python(self, value):
# Composite types are serialized as JSON blobs. If BaseField.to_python
# is called with a string, assume it was produced by value_to_string
# and decode it
if isinstance(value, str):
try:
value = json.loads(value)
except... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_python(self, value):\n if isinstance(value, models.CharField):\n # If an instance, just return the instance.\n return value\n if value is None:\n # If db has NULL, convert it to UNKNOWN.\n return UNKNOWN\n\n # Otherwise, just return the value.... | [
"0.7580803",
"0.7417569",
"0.74064326",
"0.7228528",
"0.7166787",
"0.7157663",
"0.7136971",
"0.7108574",
"0.70810133",
"0.70160776",
"0.6944583",
"0.6777951",
"0.6755395",
"0.6731473",
"0.6716347",
"0.6699715",
"0.6699715",
"0.66986114",
"0.6697674",
"0.6688111",
"0.6663651",... | 0.76189584 | 0 |
Calculate the percentage of missing minutes in the df data set Consider first and last minute as boundaries | def calculateMissing(odf):
df = odf.copy()
# Calculate last minute of operation for each day in `df`
df.loc[:, 'time'] = np.nan
df.loc[:, 'time'] = df.index.astype(np.int64)//10**9 # (to unix timestamp) from nano seconds 10*9 to seconds
days = df.groupby(df.index.date)['time'].agg(['min', 'max', 'co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delayed_percentage(df, minute):\n frac = df[df['DEP_DELAY'] >= minute].shape[0] / df.shape[0]\n return frac * 100",
"def get_percentage_missing(series):\n num = series.isnull().sum()\n den = len(series)\n return round(num / den, 2)",
"def get_percentage_missing(series):\n num = series.isn... | [
"0.6453151",
"0.6226711",
"0.6226711",
"0.61276513",
"0.6117065",
"0.60801995",
"0.60420936",
"0.56012577",
"0.5563593",
"0.5537609",
"0.5503992",
"0.5468574",
"0.5455167",
"0.5419376",
"0.54076105",
"0.53904414",
"0.5352846",
"0.53400856",
"0.52470315",
"0.52348083",
"0.5227... | 0.7251821 | 0 |
remove days with less than minutes data | def removeDays(minutes=4*60):
global masterdf
masterdf['data'] = masterdf.index.date
days = []
for day, group in masterdf.groupby(masterdf.data):
if len(group) < minutes: # len is number of minutes
continue
days.append(day)
masterdf = masterdf.loc[masterdf.data.isin(days)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune(self, age_hours):\r\n pass",
"def filter_dates(date):\n if not (date.weekday() in [5, 6] or (date.hour > 22 and date.minute > 30)):\n return True\n else:\n return False",
"def keep_daytimes(df, hours=range(0,24)):\n within_hours = lambda x: x.hour in hours\n\n df2 = df[df... | [
"0.5952818",
"0.58333623",
"0.55719686",
"0.55483365",
"0.5520344",
"0.5500797",
"0.54940915",
"0.5473995",
"0.5449962",
"0.5420026",
"0.54093",
"0.53880984",
"0.5368062",
"0.5358361",
"0.5325342",
"0.5293811",
"0.5280786",
"0.5221389",
"0.5192435",
"0.5187749",
"0.5160068",
... | 0.74686795 | 0 |
set data and binary data path before loading or if already loaded | def setDataPath(_path_data_bundle, _path_bin_data, preload=True, verbose=True):
global path_bin_data
global path_data_bundle
path_data_bundle = _path_data_bundle
path_bin_data = _path_bin_data
if preload:
loadExistent(verbose) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(self) -> None:",
"def load_data(self):",
"def __init__(self, data_path=root.joinpath(\"data\")):\n self.data_path = data_path",
"def __init__(self,path):\n self.path = path\n self.data = {}\n self.hasChanged = False\n #--Load\n if os.path.exists(self.pa... | [
"0.7145079",
"0.69138706",
"0.68069154",
"0.6632644",
"0.6603452",
"0.6589054",
"0.6586386",
"0.65464",
"0.6444249",
"0.6401591",
"0.63503474",
"0.63095284",
"0.62265867",
"0.6225615",
"0.6225615",
"0.622511",
"0.62239164",
"0.6211915",
"0.6192761",
"0.61471605",
"0.6131283",... | 0.8033364 | 0 |
get the corresponding collumns for that symbol consider the following collumns for each symbol [OPENHIGHLOWCLOSETICKVOLVOLSPREAD] | def getSymbol(symbol):
global masterdf
if len(symbols) > 1:
ifirst_collumn = symbols[symbols==symbol].index[0]*7
else:
ifirst_collumn = 0
return masterdf.iloc[:, ifirst_collumn:ifirst_collumn+7] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cols(self):\n collist = []\n if self.direction == \"vertical\":\n if len(self.position[0]) == 4:\n print('TODO')\n elif len(self.position[0]) == 5:\n print('TODO')\n else:\n collist.append(int(self.position[0][2]))\... | [
"0.5327763",
"0.5273726",
"0.5240342",
"0.51666963",
"0.50883925",
"0.501095",
"0.49680743",
"0.49491686",
"0.49135408",
"0.4891802",
"0.4855911",
"0.48446053",
"0.48119864",
"0.47812012",
"0.47694564",
"0.47543198",
"0.47337794",
"0.4729126",
"0.472299",
"0.47067514",
"0.469... | 0.59147316 | 0 |
Stop the timer, and report the elapsed time | def stop(self):
if self._start_time is None:
raise TimerError("Timer is not running. Use start() to start it")
elapsed_time = time.perf_counter() - self._start_time
self._start_time = None
return (f"Elapsed time: {elapsed_time:0.4f} seconds") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self):\n\t\tif self.__start_time is None:\n\t\t\traise TimerError(f\"Timer is not running, so it can't be stopped. Use .start to start the timer.\")\n\n\t\telapsed_time = time.perf_counter() - self.__start_time\n\n\t\tself.__start_time = None",
"def stop_timer(self):\n self.end_time = datetime.no... | [
"0.7900779",
"0.7862506",
"0.78334314",
"0.77531374",
"0.7743302",
"0.7575595",
"0.74835706",
"0.73453045",
"0.7323793",
"0.72810274",
"0.7199797",
"0.6928195",
"0.6851975",
"0.6840021",
"0.68090636",
"0.6737569",
"0.6704678",
"0.66392744",
"0.66353256",
"0.66353256",
"0.6635... | 0.80945516 | 0 |
Question list generic view. Allows the user to select from a number of ways of viewing questions, rendered with the given template. | def question_list(request, question_views, template, questions_per_page=None,
page_number=None, extra_context=None):
view_id = request.GET.get('sort', None)
view = dict([(q.id, q) for q in question_views]).get(view_id,
question_views[0])... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_index():\n story_name = request.args.get(\"template_picker\")\n return render_template(\"questions.html\",\n story=story_templates[story_name],\n story_name=story_name)",
"def question(num):\n if request.method == 'GET':\n questionGroup... | [
"0.71978104",
"0.69084626",
"0.6690975",
"0.65760136",
"0.65109444",
"0.6482572",
"0.6470924",
"0.64321196",
"0.62327635",
"0.6138639",
"0.60831404",
"0.59622526",
"0.58151567",
"0.5811288",
"0.5800559",
"0.5800559",
"0.5772922",
"0.575402",
"0.570867",
"0.5644744",
"0.564184... | 0.7559092 | 0 |
Displays a Question and any Comments on it. This is primarily intended as a fallback for users who can't dynamically load Comments. | def question_comments(request, question, form=None):
populate_foreign_key_caches(User, (
((question,), ('author', 'last_edited_by', 'closed_by')),
),
fields=('username', 'gravatar', 'reputation', 'gold', 'silver',
'bronze'))
content_type = ContentType.objects.get_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def question_page(question_id):\n return render_template('question.html', question_id=question_id)",
"def faqitem_show(request,item_container):\n app_name = 'faqitem'\n parent = item_container.get_parent()\n if parent.item.has_comments:\n comments = item_comment(request, item_container=item_container)\n... | [
"0.66193175",
"0.6497225",
"0.64916533",
"0.6347121",
"0.62772447",
"0.6236035",
"0.6096824",
"0.6087213",
"0.60636973",
"0.6006572",
"0.59829944",
"0.5935103",
"0.580005",
"0.5762421",
"0.5750788",
"0.5745637",
"0.5690303",
"0.5643972",
"0.5631671",
"0.5600234",
"0.5598512",... | 0.70452404 | 0 |
Entry point for editing a question. Fields which can be edited depend on the loggedin user's roles or reputation, so this view delegates to the apporopriate view based on those criteria. | def edit_question(request, question_id):
question = get_object_or_404(Question, id=question_id)
if auth.can_edit_post(request.user, question):
return _edit_question(request, question)
elif auth.can_retag_questions(request.user):
return _retag_question(request, question)
else:
rai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _edit_question(request, question):\n latest_revision = question.get_latest_revision()\n preview = None\n revision_form = None\n if request.method == 'POST':\n if 'select_revision' in request.POST:\n # The user submitted to change the revision to start editing from\n rev... | [
"0.6963285",
"0.67990196",
"0.66909206",
"0.6301942",
"0.6265073",
"0.6177936",
"0.5943086",
"0.5884923",
"0.58754605",
"0.58508307",
"0.58033717",
"0.57628006",
"0.5718933",
"0.5704791",
"0.5699009",
"0.5694323",
"0.56457436",
"0.5642854",
"0.5640206",
"0.56344837",
"0.56192... | 0.7464574 | 0 |
Allows the user to edit a Question's title, text and tags. If the Question is not already in wiki mode, the user can put it in wiki mode, or it will automatically be put in wiki mode if the question has been edited five times by the person who asked it, or has been edited by four different users. | def _edit_question(request, question):
latest_revision = question.get_latest_revision()
preview = None
revision_form = None
if request.method == 'POST':
if 'select_revision' in request.POST:
# The user submitted to change the revision to start editing from
revision_form =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_question(request, question_id):\n question = get_object_or_404(Question, id=question_id)\n if auth.can_edit_post(request.user, question):\n return _edit_question(request, question)\n elif auth.can_retag_questions(request.user):\n return _retag_question(request, question)\n else:\... | [
"0.660097",
"0.6577975",
"0.6183553",
"0.6157668",
"0.61305684",
"0.6120735",
"0.58406883",
"0.576193",
"0.56488806",
"0.5616788",
"0.55953723",
"0.5571593",
"0.5551248",
"0.554505",
"0.55383503",
"0.5506687",
"0.5494428",
"0.54742086",
"0.54729503",
"0.5471076",
"0.5436176",... | 0.7363707 | 0 |
Closes or reopens a Question based on its current closed status. | def close_question(request, question_id):
question = get_object_or_404(Question, id=question_id)
if not auth.can_close_question(request.user, question):
raise Http404
if not question.closed:
return _close_question(request, question)
else:
return _reopen_question(request, question... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n self.is_open = False",
"def close(self):\n\n if self._state == states['open']:\n self._do_close()",
"def close(self):\n self.closed = True",
"def close(self):\n self.__CheckOpen('close')\n self.__closed = True",
"def is_closed(self):\n rai... | [
"0.62413925",
"0.6010099",
"0.5995683",
"0.5901342",
"0.5858219",
"0.5857345",
"0.5839649",
"0.58071893",
"0.58002657",
"0.5786295",
"0.57686913",
"0.5763162",
"0.57280344",
"0.5680727",
"0.5679006",
"0.56459576",
"0.5630385",
"0.56074476",
"0.5599112",
"0.55921495",
"0.55804... | 0.7503205 | 0 |
Deletes or undeletes a Question. | def delete_question(request, question_id):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self):\n key = self.request.get('key')\n\n if not self.assert_xsrf_token_or_fail(\n self.request, self.XSRF_TOKEN, {'key': key}):\n return\n\n if not CourseOutlineRights.can_delete(self):\n transforms.send_json_response(\n self, 40... | [
"0.7444122",
"0.72047997",
"0.69089574",
"0.6871518",
"0.68535244",
"0.6812029",
"0.6809156",
"0.67394114",
"0.67273694",
"0.66970485",
"0.6673856",
"0.6607518",
"0.65219593",
"0.6497674",
"0.6402097",
"0.63994443",
"0.6251442",
"0.62493646",
"0.61630726",
"0.61136013",
"0.60... | 0.75934464 | 0 |
Adds or removes a FavouriteQuestion. Favouriting will not use a confirmation page, as it's an action which is nondestructive and easily reversible. | def favourite_question(request, question_id):
if request.method != 'POST':
raise Http404
question = get_object_or_404(Question, id=question_id, deleted=False)
favourite, created = FavouriteQuestion.objects.get_or_create(
user=request.user, question=question)
if not created:
favo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_fav(request, q_id):\n if request.method == 'POST':\n Quotes.objects.add_to_user_fav(request.session['id'], q_id)\n return redirect('/quotes')",
"def remove_from_fav(request, q_id):\n if request.method == 'POST':\n Quotes.objects.remove_from_user_fav(request.session['id'], q_id)\... | [
"0.66295946",
"0.65394634",
"0.60124284",
"0.5998105",
"0.5985239",
"0.5904005",
"0.58821785",
"0.5852993",
"0.58180875",
"0.581328",
"0.5662974",
"0.5655863",
"0.55941904",
"0.5505502",
"0.54789233",
"0.546905",
"0.53972465",
"0.5355801",
"0.52718896",
"0.52621657",
"0.52438... | 0.71072334 | 0 |
Adds an Answer to a Question. Once a certain number of Answers have been added, a Question and all its Answers will enter wiki mode and all subsequent Answers will be in wiki mode. | def add_answer(request, question_id):
question = get_object_or_404(Question, id=question_id)
preview = None
if request.method == 'POST':
form = AddAnswerForm(request.POST)
if form.is_valid():
html = sanitize_html(markdowner.convert(form.cleaned_data['text']))
if 'prev... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_answer():\n\n ans = request.form['answer']\n responses.append(ans)\n\n responses = session['responses']\n responses.append(ans)\n session['responses'] = responses\n \n # redirect...\n q_num = len(responses)\n \n if q_num >= len(satisfaction_survey.questions):\n return r... | [
"0.7049604",
"0.6722432",
"0.6582631",
"0.65265065",
"0.64372987",
"0.6259222",
"0.6195688",
"0.6138146",
"0.61364526",
"0.6118234",
"0.61158556",
"0.6026567",
"0.60160404",
"0.58654934",
"0.5848301",
"0.5810702",
"0.5809741",
"0.5795985",
"0.57219505",
"0.57120955",
"0.57054... | 0.6856323 | 1 |
Displays a single Answer and any Comments on it. This is primarily intended as a fallback for users who can't dynamically load Comments. | def answer_comments(request, answer_id, answer=None, form=None):
if answer is None:
answer = get_object_or_404(Answer, id=answer_id)
populate_foreign_key_caches(User, (
((answer,), ('author', 'last_edited_by')),
),
fields=('username', 'gravatar', 'reputation', 'gold', 'sil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_question(q_id):\n responses = session[ANSWERS_KEY]\n if len(responses) < len(survey.questions):\n current_question = survey.questions[len(responses)]\n return render_template(\"question.html\", \n question = current_question)\n else:\n return re... | [
"0.6250322",
"0.6212243",
"0.6199123",
"0.61311096",
"0.6031663",
"0.58639663",
"0.58520186",
"0.5840569",
"0.58269155",
"0.5797709",
"0.5766596",
"0.5718988",
"0.56935954",
"0.56597334",
"0.5628641",
"0.5620105",
"0.5616766",
"0.5599222",
"0.551805",
"0.5486032",
"0.54841936... | 0.73833334 | 0 |
Revision history for an Answer. | def answer_revisions(request, answer_id):
answer = get_object_or_404(Answer, id=answer_id)
revisions = list(answer.revisions.all())
populate_foreign_key_caches(User, ((revisions, ('author',)),),
fields=('username', 'gravatar', 'reputation', 'gold', 'silver',
'bronze'))
for i, r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revision_history(self, uuid):\n return self.write.revision_history(rid=uuid)",
"def history():",
"def history(name):\n from pybel.resources.arty import get_knowledge_history\n from pybel.resources.document import get_bel_knowledge_hash\n\n for path in get_knowledge_history(name):\n h... | [
"0.723237",
"0.7015047",
"0.6446162",
"0.64305264",
"0.6362762",
"0.6327976",
"0.63235044",
"0.63235044",
"0.63235044",
"0.61985636",
"0.61895114",
"0.6172785",
"0.6119343",
"0.6107345",
"0.60783255",
"0.6063162",
"0.6049912",
"0.6031435",
"0.60040706",
"0.59988356",
"0.59988... | 0.7029768 | 1 |
Marks an Answer as accepted. | def accept_answer(request, answer_id):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accept(self):\n self.accepted = True\n self.acceptedItem = self.currentItem",
"def accept(self):\n self.accepted = True\n self.acceptedItem = self.currentItem",
"def handle_accepted(self, m: Message) -> None:\n self.sim.accepted = m.value\n self.sim.accepted_n = m.... | [
"0.6303912",
"0.6303912",
"0.6247611",
"0.6243819",
"0.6242058",
"0.61657894",
"0.61366415",
"0.61357534",
"0.6112169",
"0.6088814",
"0.60866195",
"0.60866195",
"0.60391957",
"0.5948447",
"0.5912427",
"0.58902717",
"0.58753985",
"0.585076",
"0.57786554",
"0.5761055",
"0.57610... | 0.73193705 | 0 |
Deletes or undeletes an Answer. | def delete_answer(request, answer_id):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_question(request, question_id):\n raise NotImplementedError",
"def remove_answer(self, answer):\n index = self.find(answer)\n if index is not None:\n del self.answers[index]",
"def delete():",
"def delete(self):\n key = self.request.get('key')\n\n if not s... | [
"0.6614487",
"0.6585176",
"0.63598573",
"0.62970304",
"0.61252254",
"0.61252254",
"0.61252254",
"0.61252254",
"0.60880053",
"0.6079088",
"0.6052136",
"0.601121",
"0.59931797",
"0.59931797",
"0.5949665",
"0.59421235",
"0.5930423",
"0.59285575",
"0.5914332",
"0.59101915",
"0.59... | 0.7634153 | 0 |
Deletes a Comment permenantly. | def delete_comment(request, comment_id):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def delete_comment(comment: models.Comment = Depends(resolve_comment_for_comment_owner_or_resub_owner),\n db: Session = Depends(get_db)):\n crud.delete_comment(db, comment.id)",
"def delete_comment(self, id, **args): \n args.update(id=id)\n return self.fetch(\"/comm... | [
"0.7846597",
"0.78029704",
"0.772044",
"0.7705053",
"0.7662541",
"0.7531776",
"0.72647095",
"0.7225802",
"0.71778035",
"0.7171956",
"0.7123719",
"0.71113276",
"0.70782435",
"0.70561737",
"0.70526505",
"0.7006858",
"0.7003302",
"0.7003302",
"0.69442314",
"0.6928011",
"0.688192... | 0.8158874 | 0 |
Displays a Badge and any Users who have recently been awarded it. | def badge(request, badge_id):
badge = get_object_or_404(Badge, id=badge_id)
awarded_to = badge.awarded_to.all().order_by('-award__awarded_at').values(
'id', 'username', 'reputation', 'gold', 'silver', 'bronze')[:500]
return render_to_response('badge.html', {
'title': '%s Badge' % badge.name,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getBadgeAwardedTime(userId, badgeId):\n url = f\"https://badges.roblox.com/v1/users/{userId}/badges/awarded-dates?badgeIds={badgeId}\"\n r = requests.get(url)\n j = json.loads(r.text)\n return j['data']",
"def manage_user_standing(request):\r\n if not request.user.is_staff:\r\n... | [
"0.576127",
"0.5720313",
"0.54879713",
"0.5459598",
"0.5453989",
"0.53855133",
"0.5357557",
"0.5288912",
"0.5286651",
"0.5283919",
"0.5264545",
"0.52517176",
"0.52266204",
"0.5207032",
"0.520393",
"0.51995116",
"0.51977664",
"0.5162896",
"0.5159411",
"0.5148356",
"0.51466113"... | 0.7135236 | 0 |
This method tests whether an admin cannot post sale from admin account. | def test_admin_cannot_post_sale(self):
response = self.client.post(
'/self.base_url/sales',
headers=dict(Authorization="Bearer " + self.owner_token),
content_type = 'application/json'
)
response_data = json.loads(response.data)
self.assertEqual(response_data['mes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_admin_cannot_add_item(self):\n response = self.client.get(\n '/self.base_url/sales/3/2',\n headers=dict(Authorization=\"Bearer \" + self.owner_token),\n content_type = 'application/json'\n )\n\n response_data = json.loads(response.data)\n self.assertEqual(r... | [
"0.73994184",
"0.7013472",
"0.692038",
"0.68910986",
"0.6625998",
"0.66196585",
"0.65783584",
"0.6575577",
"0.6526274",
"0.65188617",
"0.64771503",
"0.64765954",
"0.6432482",
"0.642842",
"0.6401828",
"0.63980126",
"0.63924634",
"0.6384356",
"0.63694507",
"0.6347521",
"0.63475... | 0.7973246 | 0 |
This method tests whether attendant cannot view all sales. | def test_attendant_cannot_view_all_sales(self):
response = self.client.get(
'/self.base_url/sales',
headers=dict(Authorization="Bearer " + self.attendant_token),
content_type = 'application/json'
)
response_data = json.loads(response.data)
self.assertEqual(respons... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cannot_get_other_attendant_sales(self):\n response = self.client.get(\n '/self.base_url/sales/1',\n headers=dict(Authorization=\"Bearer \" + self.attendant_token),\n content_type = 'application/json'\n )\n response_data = json.loads(response.data)\n self.as... | [
"0.6643602",
"0.65054494",
"0.6440905",
"0.6426616",
"0.6017078",
"0.59870034",
"0.5910895",
"0.5844408",
"0.580026",
"0.5795543",
"0.5783102",
"0.5765318",
"0.57620674",
"0.5752455",
"0.574848",
"0.57375306",
"0.5722448",
"0.5716002",
"0.56846875",
"0.56653523",
"0.55955434"... | 0.6979228 | 0 |
Runs a GraphQL query. | def run_graphql(query: str, token: str):
response = requests.post(
'https://api.github.com/graphql',
json={'query': query},
headers={'Authorization': 'Bearer ' + token})
response.raise_for_status()
return response.json() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query(self, query, authorization_required=True):\n url = 'https://{}/api/v1/graphql'.format(self.host)\n headers = {\n 'Content-Type': 'application/json',\n }\n json = {\n 'query': query,\n }\n # Login if not yet done\n if authorization_req... | [
"0.7070459",
"0.6968903",
"0.691833",
"0.68828565",
"0.687693",
"0.67832917",
"0.67325777",
"0.6695119",
"0.668657",
"0.65787524",
"0.65209275",
"0.6514786",
"0.6511142",
"0.6494312",
"0.64831984",
"0.6468217",
"0.6418266",
"0.6363951",
"0.6348219",
"0.6252259",
"0.62517166",... | 0.72155255 | 0 |
Crawl tankeogteknikk web site and fetch current ads | def fetch_ads(url='http://tankeogteknikk.no/qmedia/oslo.php'):
try:
r = HTMLSession().get(url)
except RequestError:
logger.exception('failed to fetch ads')
return []
r.raise_for_status() # raise exception if 404 or other non ok http status
subs = r.html.find('table.sub')
ad... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_ad_page(self, response):\n ad_base_xpath = '/html/body/section[@id=\"container\"]/main/section[@class=\"content-center\"]/section[@id=\"adview\"]'\n ad_base = response.xpath(ad_base_xpath)\n ad_base2 = ad_base.xpath(\n 'section/section/section[@class=\"properties lineNegat... | [
"0.6549859",
"0.64689934",
"0.6191523",
"0.6030565",
"0.6020952",
"0.59866107",
"0.59795856",
"0.59707654",
"0.59554183",
"0.5949683",
"0.5937807",
"0.59302175",
"0.5886366",
"0.58750105",
"0.58384025",
"0.5790844",
"0.5769996",
"0.5768703",
"0.57486117",
"0.5716268",
"0.5685... | 0.6975925 | 0 |
Create a client authenticator object for given SASL mechanism. | def client_authenticator_factory(mechanism):
authenticator = CLIENT_MECHANISMS_D[mechanism]
return authenticator() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server_authenticator_factory(mechanism, password_database):\n authenticator = SERVER_MECHANISMS_D[mechanism]\n return authenticator(password_database)",
"def __init__(self, mechanism, security_protocol=None):\n\n self.mechanism = mechanism\n self.handshake_version = None\n self.aut... | [
"0.68722814",
"0.57934594",
"0.54707",
"0.5468402",
"0.546486",
"0.5417156",
"0.53780663",
"0.5287046",
"0.5180441",
"0.51572526",
"0.50952095",
"0.50952095",
"0.5010907",
"0.49893668",
"0.49572313",
"0.4934121",
"0.4916445",
"0.4907898",
"0.4891602",
"0.48217008",
"0.4797167... | 0.7940818 | 0 |
Create a server authenticator object for given SASL mechanism and password databaser. | def server_authenticator_factory(mechanism, password_database):
authenticator = SERVER_MECHANISMS_D[mechanism]
return authenticator(password_database) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client_authenticator_factory(mechanism):\n authenticator = CLIENT_MECHANISMS_D[mechanism]\n return authenticator()",
"def _create_auth(self, auth_uri, username, password): # pylint: disable=no-self-use\n return authentication.SASTokenAuth.from_shared_access_key(auth_uri, username, password)",
... | [
"0.6703229",
"0.5701145",
"0.5604202",
"0.5592586",
"0.5375703",
"0.53165096",
"0.527724",
"0.5222822",
"0.52077866",
"0.5202746",
"0.5182145",
"0.51366407",
"0.51163125",
"0.5093356",
"0.5057539",
"0.5041315",
"0.50326926",
"0.5027122",
"0.50180745",
"0.5001154",
"0.49880448... | 0.79636574 | 0 |
Filter a mechanisms list only to include those mechanisms that cans succeed with the provided properties and are secure enough. | def filter_mechanism_list(mechanisms, properties, allow_insecure = False,
server_side = False):
# pylint: disable=W0212
result = []
for mechanism in mechanisms:
try:
if server_side:
klass = SERVER_MECHANISMS_D[mechanism]
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_by_property(self, properties=None, **kwargs):\r\n\t\tif properties is None:\r\n\t\t\tproperties = {}\r\n\t\tproperties.update(kwargs)\r\n\t\tresult_list = ElementList()\r\n\t\tfor element in self:\r\n\t\t\tif all(k in element.properties and element.properties[k] == v\r\n\t\t\t\t\tfor k, v in properties.... | [
"0.5699851",
"0.52899766",
"0.518739",
"0.51146436",
"0.508265",
"0.50175214",
"0.5009587",
"0.50028116",
"0.49396864",
"0.48976088",
"0.48460746",
"0.4810315",
"0.47753012",
"0.47662416",
"0.47486055",
"0.47273138",
"0.47254753",
"0.4706724",
"0.46828786",
"0.46733832",
"0.4... | 0.71829396 | 0 |
This function encodes the length of a variable into bytes conforming to the | def encode_length(value):
if value == Length.INDEFINITE:
return bytes([0b10000000])
if value < 127:
return bytes([value])
output = []
while value > 0:
value, remainder = value // 256, value % 256
output.insert(0, remainder)
# prefix length information
output = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_length(value: int) -> bytes:\n elems, rem_len = [], value\n while True:\n elem = rem_len & 0x7F\n rem_len >>= 7\n if not rem_len:\n elems.append(elem)\n break\n elem |= 0x80\n elems.append(elem)\n return bytes(elems)",
"def encode_bytes... | [
"0.77181756",
"0.743362",
"0.7397387",
"0.70339084",
"0.6911628",
"0.6882828",
"0.68740034",
"0.6857361",
"0.68414146",
"0.6770081",
"0.67331237",
"0.6694589",
"0.667934",
"0.6676288",
"0.6550097",
"0.6548717",
"0.6531878",
"0.64749664",
"0.6432828",
"0.640844",
"0.6392812",
... | 0.7681858 | 1 |
Given a bytes object, which starts with the length information of a TLV value, returns a namedtuple with the length and the remaining bytes. So, given a TLV value, this function takes the "LV" part as input, parses the length information and returns the length plus the remaining "V" part (including any subsequent bytes... | def decode_length(data: bytes) -> LengthValue:
if data[0] == 0b11111111:
# reserved
raise NotImplementedError('This is a reserved case in X690')
elif data[0] & 0b10000000 == 0:
# definite short form
output = int.from_bytes([data[0]], 'big')
data = data[1:]
elif data[0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length_wrapper(buf, pos):\n length, pos = self.decode_varint(buf, pos)\n end = pos+length\n output = []\n while pos < end:\n value, pos = wrapped_decoder(buf, pos)\n output.append(value)\n if pos > end:\n raise ... | [
"0.64150894",
"0.63973886",
"0.61851543",
"0.6085057",
"0.5999484",
"0.57561797",
"0.57561797",
"0.57553464",
"0.57496357",
"0.5731136",
"0.57247484",
"0.56196153",
"0.5597361",
"0.55578035",
"0.5524402",
"0.5499094",
"0.54437697",
"0.54426795",
"0.54287183",
"0.53769445",
"0... | 0.65070444 | 0 |
Converts a list of varbinds into a tablelike structure. num_base_nodes can be used for table which rowids consist of multiple OID tree nodes. By default, the last node is considered the row ID, and the secondlast is the | def tablify(varbinds: List[Tuple[Any, Any]], num_base_nodes: int=0) -> list:
rows = {}
for oid, value in varbinds:
if num_base_nodes:
tail = oid.identifiers[num_base_nodes:]
col_id, row_id = tail[0], tail[1:]
row_id = '.'.join([str(node) for node in row_id])
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expr2truthtable(expr):\n inputs = [ttvar(v.names, v.indices) for v in expr.inputs]\n return truthtable(inputs, expr.iter_image())",
"def statements_to_txns(statement_list):\n new_list = [[stmt] for stmt in statement_list]\n return new_list",
"def makeTableNamesList(n, ):",
"def create_numbers... | [
"0.48981458",
"0.48046044",
"0.4791325",
"0.46490142",
"0.45247823",
"0.45140782",
"0.45098865",
"0.44711795",
"0.44403082",
"0.44383937",
"0.44296795",
"0.44192946",
"0.4394352",
"0.43775594",
"0.43737778",
"0.43499905",
"0.43416765",
"0.43036002",
"0.42966565",
"0.42906594",
... | 0.8294487 | 0 |
Test method add(a, b) | def test_add(self):
self.assertEqual(3, add(1, 2))
self.assertNotEqual(3, add(2, 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_add():\n\n assert add(1, 1) == 2\n assert add(1, 2) == add(2, 1) == 3",
"def test_add(self):\n self.assertEqual(add(1, 1), 2, \"Wrong answer\")\n self.assertEqual(add(10, 1), 11, \"Wrong answer\")\n self.assertEqual(add(15, 15), 30, \"Wrong answer\")",
"def test_add(self):\... | [
"0.8403832",
"0.83135176",
"0.83120936",
"0.8274514",
"0.8154746",
"0.8017622",
"0.7980359",
"0.7975503",
"0.7958587",
"0.7947391",
"0.7920278",
"0.7920278",
"0.7920278",
"0.79120195",
"0.7785436",
"0.77111113",
"0.7677445",
"0.7671747",
"0.7666651",
"0.7650121",
"0.76438",
... | 0.83345205 | 1 |
Test method multi(a, b) | def test_multi(self):
self.assertEqual(6, multi(2, 3)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_multi(self):\n self.assertEqual(6, foo.multi(2, 3))",
"def test_observable_mult(obs_a, obs_b, result):\n o = _observable_mult(obs_a, obs_b)\n assert o.compare(result)",
"def test_merge_two_two():\n run_merge([1, 3], [2, 4], [1, 2, 3, 4])",
"def test_merge_two_two_same():\n run_mer... | [
"0.80462456",
"0.6543535",
"0.6491823",
"0.64458776",
"0.64359564",
"0.6347622",
"0.63467115",
"0.6302334",
"0.6294341",
"0.61660635",
"0.61619616",
"0.6143756",
"0.6128932",
"0.6107751",
"0.6105836",
"0.6073012",
"0.6070781",
"0.60532993",
"0.60442275",
"0.60402524",
"0.6008... | 0.83514917 | 0 |
Test method divide(a, b) | def test_divide(self):
self.assertEqual(2, divide(6, 3))
self.assertEqual(2.5, divide(5, 2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def divide(a, b):\n return a / b",
"def divide(self, a, b):\n return a / b",
"def test_divide(self):\n self.assertEqual(2, foo.divide(6, 3))\n self.assertEqual(2.5, foo.divide(5, 2))",
"def div(a,b):\r\n return a/b",
"def test_divide(self):\n print \"divide\"\n self.ass... | [
"0.8718313",
"0.8709082",
"0.85563856",
"0.8337081",
"0.8319287",
"0.81204",
"0.81059384",
"0.8055957",
"0.8045913",
"0.8045913",
"0.8045913",
"0.79783475",
"0.7958541",
"0.7946043",
"0.79361945",
"0.78919554",
"0.7884527",
"0.7825891",
"0.78224224",
"0.7812931",
"0.7761326",... | 0.87368065 | 0 |
A ``property`` member to get feature. Returns | def feature(self):
return self._feature | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, feature_name):\n return getattr(self, feature_name)",
"def get_feature_of(self, name, field_):\n return self.get_person(name)[field_]",
"def get(self, name):\n try:\n return(self._d_features[name])\n except:\n log.error(\"Can't get feature '%s'\" ... | [
"0.7429972",
"0.69470334",
"0.6913287",
"0.66577333",
"0.65954673",
"0.6574765",
"0.65732443",
"0.6493396",
"0.6349535",
"0.63281256",
"0.63104475",
"0.63013023",
"0.62895536",
"0.62598675",
"0.6258869",
"0.62548155",
"0.622489",
"0.6219373",
"0.6216852",
"0.6212862",
"0.6195... | 0.80473495 | 1 |
A ``property`` member to get loss. Returns | def loss(self):
return self._loss | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss(self):\n return self._get(\"loss\")",
"def loss_op(self):\n return self.loss",
"def get_loss(self):\n raise NotImplementedError",
"def _get_loss(self):\n raise NotImplementedError",
"def get_loss(self):\n return self.loss / self.cnt",
"def loss(self) -> KernelL... | [
"0.8276235",
"0.7937903",
"0.7853789",
"0.7604106",
"0.73672855",
"0.7281491",
"0.6939322",
"0.68877",
"0.6721873",
"0.667054",
"0.66663224",
"0.66014874",
"0.65989643",
"0.6588192",
"0.65814584",
"0.65421057",
"0.6456126",
"0.6398717",
"0.63835084",
"0.6280813",
"0.6279331",... | 0.8047107 | 1 |
Outputs the recommendation graph in gexf format | def gexfFormat(profile, recom, filename):
# ! ids are raw -> strings
clickedItems = set(map(lambda x: str(x[0]), profile)) # set of clicked items
recomItems = set() # set of recommended items
with open(filename, 'w') as f:
# write header
f.write("""<?xml version="1.0" encoding="UTF-8"?>\n""")
f.w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gexf_graph():\n # you must replace these lines and supply your own graph\n \n \n \n my_gexf = Gexf(\"JiajiaXie\", \"My awesome graph\")\n graph=my_gexf.addGraph(\"undirected\", \"static\", \"My awesome networks\")\n \n atr1=graph.addNodeAttribute('Type',type='string')\n\n\n for set i... | [
"0.6518206",
"0.6492693",
"0.62182534",
"0.60855573",
"0.6026033",
"0.6022717",
"0.6011771",
"0.597186",
"0.5966696",
"0.59158415",
"0.5866235",
"0.5795243",
"0.5794244",
"0.57844627",
"0.5769349",
"0.5742664",
"0.57403666",
"0.571646",
"0.57115054",
"0.5705533",
"0.57034814"... | 0.6643684 | 0 |
Outputs the recommendation graph as a Graph() object Graph has two rings (2hop) | def graph_2hop(profile, recom, filename):
g = Graph()
# ! ids are raw -> strings
clickedItems = set(map(lambda x: str(x[0]), profile)) # set of clicked items
recomItems = set() # set of recommended items
# get recommended items
for click in range(0, len(profile)): # for all the clicks
for rec in recom... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_graph(self):",
"def buildRomaniagraph(Graph):\n \n g=Graph()\n for name in ('Oradea','Zerind','Arad','Timisoara', 'Lugoj','Mehadia', \n 'Dobreta','Sibiu','Fagaras','Rimnicu Vilcea','Pitesti','Craiova',\n 'Bucharest','Giurgiu','Urziceni','Hirsova','Eforie','Vaslui'... | [
"0.6265043",
"0.60261345",
"0.5926568",
"0.5733324",
"0.5690727",
"0.5673141",
"0.5631745",
"0.562904",
"0.56239283",
"0.5620823",
"0.55869305",
"0.5577203",
"0.5553991",
"0.55262804",
"0.5521139",
"0.5518216",
"0.5515867",
"0.5515479",
"0.5503169",
"0.54850835",
"0.54811126"... | 0.7407797 | 0 |
Updates the recommendation graph as a Graph() object | def itemGraphUpdate(clicked_iid, recom, graph=None):
if graph is None:
g = Graph()
else:
g = graph
# ! ids are raw -> strings
clicked_iid = str(clicked_iid)
# add vertices
rec_ids = set(map(lambda x: str(x[0]), recom))
for iid in rec_ids.union(set([clicked_iid])):
# append if vertex does not... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\r\n self.g = self.create_graph()",
"def force_update_graph(self):\n self.updated_data = 1\n self.update_graph()",
"def populate_graph(self):",
"def update_graph(graph):\n\n if not isinstance(graph, WeightedGraph):\n raise TypeError('update_graph(graph): graph ... | [
"0.6545904",
"0.61194843",
"0.59791607",
"0.5885248",
"0.5845937",
"0.5802323",
"0.5785915",
"0.5756701",
"0.5721302",
"0.56963307",
"0.5601753",
"0.55493534",
"0.5534333",
"0.5527087",
"0.55035305",
"0.5489941",
"0.5476881",
"0.54395366",
"0.53804374",
"0.53669584",
"0.53420... | 0.61907077 | 1 |
Look for serializer class in self.serializer_action_classes, which should be a dict mapping action name (key) to serializer class (value), | def get_serializer_class(self):
try:
return self.serializer_action_classes[self.action]
except (KeyError, AttributeError):
return super(
MultiSerializerViewSetMixin, self).get_serializer_class() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_serializer_class(self):\n return self.serializer_classes.get(self.action,\n self.default_serializer_class)",
"def get_serializer_class(self, *args, **kwargs):\n if self.action == 'list':\n return self.serializer_list_class\n else:\... | [
"0.7793277",
"0.77470917",
"0.77249867",
"0.75814193",
"0.7549364",
"0.74470603",
"0.72321916",
"0.72214085",
"0.71423715",
"0.7075341",
"0.6952846",
"0.6899209",
"0.68710005",
"0.68418986",
"0.6814228",
"0.67282605",
"0.66363025",
"0.66278434",
"0.66154486",
"0.64702797",
"0... | 0.84128475 | 0 |
Set zeropadding at beginning of frame. | def zero_pad_front(self, zf):
self.zf = zf
self.nfft = self.N+self.zb+self.zf
if self.analysis_window is not None:
self.analysis_window = np.concatenate((np.zeros(zf), self.analysis_window))
if self.synthesis_window is not None:
self.synthesis_window = np.concaten... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zero_pad_back(self, zb):\n self.zb = zb\n self.nfft = self.N+self.zb+self.zf\n if self.analysis_window is not None:\n self.analysis_window = np.concatenate((self.analysis_window, np.zeros(zb)))\n if self.synthesis_window is not None:\n self.synthesis_window = n... | [
"0.5761993",
"0.5609871",
"0.55634654",
"0.5504001",
"0.5464581",
"0.5449529",
"0.54428387",
"0.5384842",
"0.53071064",
"0.52637416",
"0.52493453",
"0.52068114",
"0.5151429",
"0.51371413",
"0.50682837",
"0.50500166",
"0.50412107",
"0.50278777",
"0.5022913",
"0.5021852",
"0.50... | 0.64935875 | 0 |
Set timedomain filter with appropriate zeropadding. Frequency spectrum of the filter is computed and set for the object. There is also a check for sufficient zeropadding. | def set_filter(self, coeff, zb=None, zf=None, freq=False):
# apply zero-padding
if zb is not None:
self.zero_pad_back(zb)
if zf is not None:
self.zero_pad_front(zf)
self.reset()
if not freq:
# compute filter magnitude and phase spectrum... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n # Create a new instance of a high pass filter, using the default constructor\n hpf = GRT.HighPassFilter()\n\n # Set the cutoff frequency of the filter to 2.0Hz\n hpf.setCutoffFrequency(2, 1.0 / 1000.0)\n\n # Create some variables to help generate the signal data\n num_seconds = 6 #... | [
"0.5977531",
"0.5787666",
"0.5669019",
"0.55807704",
"0.5452509",
"0.54226756",
"0.5370911",
"0.5358593",
"0.53426456",
"0.5296308",
"0.52961355",
"0.5288189",
"0.5259538",
"0.52438253",
"0.52346075",
"0.52238655",
"0.522103",
"0.52134895",
"0.51669514",
"0.51487315",
"0.5112... | 0.6203471 | 0 |
Get reconstructed previous samples. | def get_prev_samples(self):
return self.y_p | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPreviousDataPoints(self):\n return self.dataPoints",
"def copy_previous_sample(self):\n self.context[self.iter] = self.context[self.iter-1]\n self.beta[self.iter] = self.beta[self.iter-1]",
"def get_prev(self):\n return self.fathers",
"def previous(self):\n return _o... | [
"0.70523727",
"0.6881008",
"0.6615702",
"0.64174384",
"0.64159167",
"0.6167121",
"0.6160991",
"0.6144606",
"0.61311173",
"0.6119277",
"0.6107851",
"0.60681945",
"0.6053761",
"0.60440516",
"0.60411966",
"0.60098934",
"0.60004914",
"0.5974811",
"0.59624743",
"0.59318995",
"0.59... | 0.7585624 | 0 |
This route get new updates from Telegram server next this updates sends to handlers defined in handlers.py | def telegram_web_hook():
update = Update.de_json(request.stream.read().decode('utf-8'))
bot.process_new_updates([update])
return Response('ok', 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle(bot):\n global update_id\n # Request updates after the last update_id\n for update in bot.get_updates(offset=update_id, timeout=10):\n update_id = update.update_id + 1\n\n if update.message: # your bot can receive updates without messages\n if update.message.text == '/... | [
"0.676299",
"0.6495885",
"0.63592947",
"0.63008076",
"0.6228417",
"0.6198653",
"0.60686064",
"0.6051617",
"0.6035832",
"0.60319716",
"0.6006856",
"0.5997417",
"0.5928093",
"0.5917178",
"0.5848683",
"0.5758191",
"0.57514024",
"0.5710718",
"0.5707119",
"0.56754243",
"0.56704855... | 0.69992054 | 0 |
Number of bins to store values in. | def bins(self, value):
self.num_bins = int(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bins(self):\n min_val = 0\n max_val = 1\n buckets = 10\n values_per_bucket = 10\n\n import numpy\n\n data = list(numpy.linspace(min_val, max_val, buckets * values_per_bucket))\n bins = numpy.linspace(min_val, max_val + sys.float_info.epsilon, buckets + 1)\n... | [
"0.72512835",
"0.7245077",
"0.7222917",
"0.7202123",
"0.71756864",
"0.71332246",
"0.71169543",
"0.711236",
"0.7110419",
"0.7110419",
"0.70395905",
"0.703958",
"0.702982",
"0.7029697",
"0.70171195",
"0.6965415",
"0.69487476",
"0.69446665",
"0.6934302",
"0.69153357",
"0.687651"... | 0.77153325 | 0 |
Scans the ship based on the precision value. | def scan_this_ship(
self, precision: int=1, *, scan_for_crew:bool=True, scan_for_systems:bool=True, use_effective_values=False
)->Dict[str,Union[int,Tuple,ShipStatus,ShipClass]]:
if isinstance(precision, float):
raise TypeError("The value 'precision' MUST be an intiger between 1 amd 100... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_precision(self, precision) :\n self.__precision = self.parent().action().filter(precision)",
"def scan_ap(self, cut_off = 3480, r_ap = 12, r_an = 3):\r\n for trial in range(self.dimension):\r\n max_count, max_rank = self.pick_largest(cut_off = cut_off)\r\n if max_coun... | [
"0.5208343",
"0.5091704",
"0.50516194",
"0.49526346",
"0.4922299",
"0.4911728",
"0.4871121",
"0.48637703",
"0.48381466",
"0.48370963",
"0.4809724",
"0.48076838",
"0.47961012",
"0.47918564",
"0.47794414",
"0.47585192",
"0.4749212",
"0.47110945",
"0.46995407",
"0.46683583",
"0.... | 0.5695845 | 0 |
Run a number of simulations of energy weapon hits against the target ship and returns the avaraged result. | def simulate_energy_hit(
self, target:Starship, number_of_simulations:int, energy:float, cannon:bool=False,
*,
simulate_systems:bool=False,
simulate_crew:bool=False,
use_effective_values:bool=False,
target_scan:Optional[Dict[str,Union[Tuple,int,ShipStatus,ShipClass]]]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def takeHit(self, amount, type, enemyShip):\n if type == 'energy':\n # go through shields in quadrant first\n if self.currentSP > 0:\n if self.currentSP >= amount:\n self.currentSP -= amount\n amount = 0\n else:\n ... | [
"0.60075307",
"0.59146893",
"0.59134305",
"0.5822662",
"0.5814551",
"0.5743074",
"0.5720371",
"0.57181424",
"0.57099694",
"0.5681851",
"0.56700224",
"0.5660041",
"0.5643833",
"0.56365556",
"0.5632416",
"0.5627991",
"0.56276286",
"0.5621812",
"0.56217706",
"0.5615002",
"0.5593... | 0.68050003 | 0 |
returns random samples from multiple distributions | def random_samples(bins, dist):
N = dist.shape[0]
samples = np.empty([N,1], dtype=np.float32)
for i in range(N):
smpl = np.random.choice(bins, p=dist[i,:]/np.sum(dist[i,:]))
samples[i,0] = smpl.astype(np.float32)
return samples | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_distribution(p1=[1.0,0.1,10000],p2=[-1.0,0.6,30000]):\n mu1,sig1,num1 = p1\n mu2,sig2,num2 = p2\n g1 = scipy.stats.norm(mu1,sig1).rvs(num1)\n g2 = scipy.stats.norm(mu2,sig2).rvs(num2)\n\n samples = np.concatenate([g1,g2])\n return samples",
"def generate_samples(mu1,cov,number_of_s... | [
"0.70574653",
"0.6946669",
"0.6861014",
"0.6822244",
"0.65405303",
"0.64461255",
"0.6415942",
"0.6403516",
"0.638835",
"0.636612",
"0.6360244",
"0.63509405",
"0.63402885",
"0.6321304",
"0.6321304",
"0.6321301",
"0.63066596",
"0.62933457",
"0.62816435",
"0.62736475",
"0.627095... | 0.705815 | 0 |
returns random bins from multiple distributions | def random_bins(num_classes, dist):
N = dist.shape[0]
bins = np.empty([N,1], dtype=np.int32)
for i in range(N):
smpl = np.random.choice(num_classes, p=dist[i,:]/np.sum(dist[i,:]))
bins[i,0] = smpl
return bins | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_samples(bins, dist):\n N = dist.shape[0]\n samples = np.empty([N,1], dtype=np.float32)\n \n for i in range(N):\n smpl = np.random.choice(bins, p=dist[i,:]/np.sum(dist[i,:]))\n samples[i,0] = smpl.astype(np.float32)\n \n return samples",
"def create_random_sample(idx... | [
"0.7508363",
"0.69380885",
"0.6771232",
"0.65738857",
"0.6425043",
"0.63512796",
"0.61846936",
"0.6110717",
"0.60829866",
"0.60624784",
"0.60505307",
"0.6032603",
"0.6031573",
"0.60144526",
"0.6007902",
"0.59849346",
"0.5971969",
"0.5965493",
"0.5964238",
"0.59641916",
"0.592... | 0.7647302 | 0 |
Returns a function for a getBatch function | def getBatchFunction(mdlParams):
if mdlParams['batch_func_type'] not in getBatch_map:
raise ValueError('Name of getBatch function unknown %s' % mdlParams['batch_func_type'])
func = getBatch_map[mdlParams['batch_func_type']]
@functools.wraps(func)
def getBatch(mdlParams, indices, batchID):
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_batch_fn(dataset):\n def get_batch(idx):\n x_bat = dataset['input'][idx]\n y_bat = dataset['label'][idx]\n x_bat, y_bat = preprocess(x_bat, y_bat)\n\n return x_bat, y_bat\n\n return get_batch",
"def get_batch(self, batch_kwargs, batch_parameters=None) -> None:\n ... | [
"0.76445514",
"0.7105275",
"0.6593782",
"0.64836043",
"0.6394233",
"0.63645023",
"0.6317198",
"0.62854385",
"0.62081707",
"0.61908257",
"0.6100359",
"0.6064591",
"0.6058815",
"0.6041532",
"0.60362273",
"0.6001232",
"0.5941997",
"0.5895424",
"0.5894011",
"0.58808607",
"0.58745... | 0.76802933 | 0 |
Seek the file at the given position. | def seek(self, position: int, whence: int = 0) -> None:
raise NotImplementedError(
'Seek operation is not supported by this object: %r' % self
) # pragma: no cover | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seek(self, offset, relativeTo):\n self.oFile.seek(offset, relativeTo)",
"def advance_in_file(self, file_pos):\n if self.is_open:\n try:\n self.fd.seek(file_pos)\n except (AttributeError, ValueError): # pragma: debug\n if self.is_open:\n ... | [
"0.76993483",
"0.76891154",
"0.7548075",
"0.7513573",
"0.7472935",
"0.7280132",
"0.7213151",
"0.72075",
"0.7173454",
"0.7047044",
"0.7045246",
"0.7045246",
"0.7035013",
"0.6981876",
"0.68223673",
"0.6808338",
"0.6760128",
"0.66283756",
"0.6599173",
"0.6499626",
"0.6450718",
... | 0.7804235 | 0 |
Create time factor smoothing model X target tensor tmode temporal factor obtained by decomposing a target tensor nmode1 first nontemporal factor nmode2 second nontemporal factor window width of Gaussian kernel and spike/dip reduce kernel rank rank of tensor decomposition tlength length of time dimension (K) seasonp sea... | def create_model(X, tmode, nmode1, nmode2, nmode, window, rank, tlength, seasonp, horizon, f_window):
model = smooth_tfactor(X, tmode, nmode1, nmode2, nmode, window, rank, tlength, seasonp, horizon, f_window)
opt = torch.optim.SGD(model.parameters(),lr=0.001)
return model, opt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predictions(loader, model, win_len_per_ser, criterion, device, window_out = 1 ):\n \n model.eval()\n num_win_per_ser = win_len_per_ser #num windows\n #print(num_win_per_ser)\n y_pred = []\n y_true = []\n with torch.no_grad():\n for idx, (x, y) in enumerate(loader): #for i in range... | [
"0.5978756",
"0.57869995",
"0.5527813",
"0.5495574",
"0.54578036",
"0.5456743",
"0.5406472",
"0.53990376",
"0.5391752",
"0.53367877",
"0.5334804",
"0.53345275",
"0.53314143",
"0.53254807",
"0.52804357",
"0.52803254",
"0.5263955",
"0.5262726",
"0.5258535",
"0.5254844",
"0.5243... | 0.69456 | 0 |
Train the model epochs number of epochs to train model tensor forecasting model opt optimization method nmode number of total modes n | def train_model(train, val, epochs, model, opt, nmode, n, val_nmode1, val_nmode2):
for epoch in range(epochs):
opt.zero_grad()
loss = get_loss(model, train)
loss.requires_grad = True
loss.backward()
opt.step()
if epoch%10 == 0:
model.eval()
lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self):\n self.epoch = 0\n self.step = 0\n self.start_time = time.time()\n for self.epoch in range(self.num_epochs):\n print(\"EPOHA\")\n self.run_epoch()\n print(\"SAVE MODEL\")\n self.save_model()",
"def train(self, num_batches: i... | [
"0.7032251",
"0.6953194",
"0.6840906",
"0.6832272",
"0.68262655",
"0.6822291",
"0.6766732",
"0.6766732",
"0.6763773",
"0.67544067",
"0.67520034",
"0.6734389",
"0.6638364",
"0.66345334",
"0.6618578",
"0.6602076",
"0.6578685",
"0.65695775",
"0.65622234",
"0.6551037",
"0.6550912... | 0.7263793 | 0 |
A bagofwords model using a learned word embedding. Note it disregards the word order in the text. Returns a tf.estimator.EstimatorSpec. | def bag_of_words_model(features, labels, mode):
bow_column = tf.feature_column.categorical_column_with_identity(
WORDS_FEATURE, num_buckets=n_words)
# The embedding values are initialized randomly, and are trained along with
# all other model parameters to minimize the training loss.
bow_embedding_colum... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bag_of_words_model(features, labels, mode):\n bow_column = tf.feature_column.categorical_column_with_identity(\n WORDS_FEATURE, num_buckets=n_words)\n bow_embedding_column = tf.feature_column.embedding_column(\n bow_column, dimension=EMBEDDING_SIZE)\n bow = tf.feature_column.input_layer(... | [
"0.7760733",
"0.74265504",
"0.71465653",
"0.616672",
"0.6046265",
"0.6012774",
"0.59553236",
"0.5931751",
"0.59279746",
"0.5919495",
"0.5818954",
"0.58072764",
"0.57818687",
"0.5733954",
"0.5723362",
"0.57022715",
"0.5687482",
"0.5671911",
"0.5660198",
"0.5651615",
"0.564389"... | 0.7850809 | 0 |
a bitstring is a string where 'o' represents an item to be scored and '.' represents an item to be ignored while scoring the sequence. the sequence string and bitstring must be of the same length and the sequence cannot contain punctuation or spaces | def score_bitstring(self, sequence, bitstring):
spans = self.get_bitstring_spans(bitstring)
# we use the tab character \t to represent the positions
# to skip when scoring the sequence
seq_by_bits = [ sequence[i] if i in spans else '\t' for i in range(len(sequence)) ]
self.mayb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode(string,bits=7,multipleblocks=1):\n B=1<<bits\n i = 0\n ans = \"\"\n for c in list(string):\n ## read a single character\n if( c == \"1\" ) :\n if (multipleblocks) : ans = ans + \"1\" ; pass ## to say 'there is another 1 in this block'\n\t ans = ans + dec_to_bin(i,bit... | [
"0.5770506",
"0.5724998",
"0.5701106",
"0.56768364",
"0.56196374",
"0.55462277",
"0.55286086",
"0.55279315",
"0.5505439",
"0.548913",
"0.5479736",
"0.54769963",
"0.54749554",
"0.5466628",
"0.54245585",
"0.5417284",
"0.5356189",
"0.5346046",
"0.5329817",
"0.5325525",
"0.531973... | 0.6646117 | 0 |
Monta a imagem novamente e imprime | def imprime_imagem(tipo, imagem):
cv.imshow(tipo, imagem)
cv.waitKey(0)
cv.destroyAllWindows() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recarregar_imagem(self):\n self.salvar_imagem(caminho_imagem=self.caminho_temp)\n self.carregar_imagem(caminho_imagem=self.caminho_temp)",
"def unprocess(image):\n return image + MEAN_PIXEL",
"def saveimage(self):\n if self.saveimageButton.isChecked():\n self.save = True\... | [
"0.7076457",
"0.62817305",
"0.6155066",
"0.6134367",
"0.60774577",
"0.6059456",
"0.6020727",
"0.6002184",
"0.59293276",
"0.5893911",
"0.58814615",
"0.58747613",
"0.5824862",
"0.5824862",
"0.5785226",
"0.57777363",
"0.57769746",
"0.57746506",
"0.5768607",
"0.57604593",
"0.5736... | 0.7318156 | 0 |
Notifies all subscribers about a key press. | def notify(self, sender, key, key2=b'\x00'):
EventListener.notify(self, sender, KeyPressEventArgs(key, key2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_key_event(self, key):\n pass",
"def key_press_event(self, event):\n pass",
"def key_event(self, key: Any, action: Any):\n pass",
"def _on_key_press(self, event):",
"def on_key_press(self, event):\n\n #print(\"you pressed {}\".format(event.key))\n key_press_handler(... | [
"0.6874464",
"0.6603063",
"0.6512852",
"0.6431999",
"0.6267865",
"0.6241978",
"0.62351334",
"0.61685526",
"0.6119373",
"0.60976124",
"0.60345465",
"0.60266465",
"0.6012053",
"0.60117406",
"0.5997674",
"0.59828794",
"0.5931227",
"0.5880054",
"0.5864692",
"0.58326644",
"0.58318... | 0.6709994 | 1 |
Print the elapsed time from a specific starting point. | def print_time(start):
if (time.time()-start)/60 > 1:
elapsed_time = divmod(time.time()-start, 60)
if elapsed_time[0] > 1:
print("\nElapsed time: %.0f minutes, %.2f seconds" % (elapsed_time[0], elapsed_time[1]))
else:
print("\nElapsed time: %.0f minute, %.2f seconds" ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_time_elapsed(self):\r\n stop_time = time.time()\r\n elapsed_time = stop_time - self.start_time\r\n print(f\"-- time elapsed: {elapsed_time:.5f} s\", flush=True)",
"def print_time(s, start_time):\n print(\"%s, time %ds, %s.\" % (s, (time.time() - start_time), time.ctime()))\n ... | [
"0.77482617",
"0.7203376",
"0.71094936",
"0.69760436",
"0.6899156",
"0.6862542",
"0.68258214",
"0.67351747",
"0.6734833",
"0.672111",
"0.6703022",
"0.66845113",
"0.666063",
"0.6640431",
"0.64536387",
"0.6334673",
"0.63327825",
"0.6307953",
"0.6303008",
"0.6295093",
"0.6278732... | 0.7358734 | 1 |
Load the dbapi driver module and register the base exception class | def _load_driver_module(self):
driver = get_dbapi_module(self.driver_module)
exceptions.register(driver.DatabaseError)
return driver | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_exceptions_module():\n return exceptions",
"def connect(self, dbapi_connection, connection_record):",
"def load_ceODBC(finder, module):\n finder.IncludeModule(\"datetime\")\n finder.IncludeModule(\"decimal\")",
"def mapDBErrors(excType, excValue, excTb):\n# This is a helper to all DB-based c... | [
"0.54538536",
"0.53903604",
"0.52853954",
"0.52616227",
"0.5236667",
"0.5190577",
"0.5171703",
"0.51479286",
"0.5121154",
"0.5120621",
"0.5119738",
"0.5063392",
"0.5044426",
"0.50394756",
"0.50245506",
"0.5015598",
"0.50098103",
"0.49851283",
"0.49819702",
"0.4966365",
"0.495... | 0.7629617 | 0 |
Return True if the database supports committing/rolling back DDL statements within a transaction | def _check_transactional_ddl(self):
table_name = "yoyo_tmp_{}".format(utils.get_random_string(10))
table_name_quoted = self.quote_identifier(table_name)
sql = self.create_test_table_sql.format(table_name_quoted=table_name_quoted)
with self.transaction() as t:
self.execute(sql... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autocommit(self):\n if self.isolation_level is None:\n return True\n return False",
"def custom_statement(statement):\n try:\n conn = _access()\n cur = conn.cursor()\n conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)\n cur.execute(\"{}\".format(stat... | [
"0.67133236",
"0.6440264",
"0.6417211",
"0.634534",
"0.61735946",
"0.61575025",
"0.6139712",
"0.59383726",
"0.59187573",
"0.59026885",
"0.5895076",
"0.588609",
"0.58708024",
"0.5799137",
"0.57894987",
"0.577671",
"0.5771531",
"0.57455456",
"0.5736144",
"0.5719612",
"0.5683285... | 0.72476774 | 0 |
Create a new savepoint with the given id | def savepoint(self, id):
self.execute("SAVEPOINT {}".format(id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def savepoint_release(self, id):\n self.execute(\"RELEASE SAVEPOINT {}\".format(id))",
"def post(self, saving_plan_id):\n return CreateSavingDeposit(current_user.id, saving_plan_id, request)",
"def set_savepoint(self, name=None):\n if name is None:\n name = f\"{uuid.uuid1()}\"\n... | [
"0.69292134",
"0.61841214",
"0.5871252",
"0.5851897",
"0.5721253",
"0.56541157",
"0.56006706",
"0.5522963",
"0.5503352",
"0.54951596",
"0.54449797",
"0.538813",
"0.5360623",
"0.5346576",
"0.53310823",
"0.5330043",
"0.5328561",
"0.5318926",
"0.530357",
"0.53023463",
"0.5299375... | 0.7847571 | 0 |
Release (commit) the savepoint with the given id | def savepoint_release(self, id):
self.execute("RELEASE SAVEPOINT {}".format(id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def savepoint(self, id):\n self.execute(\"SAVEPOINT {}\".format(id))",
"def savepoint_rollback(self, id):\n self.execute(\"ROLLBACK TO SAVEPOINT {}\".format(id))",
"def release_savepoint(self, name):\n if not isinstance(name, str) or len(name.strip()) == 0:\n raise ProgrammingEr... | [
"0.7221298",
"0.66681224",
"0.64296126",
"0.58430684",
"0.5837331",
"0.57998353",
"0.5680208",
"0.564503",
"0.55930936",
"0.5582591",
"0.54700184",
"0.54700184",
"0.54700184",
"0.54700184",
"0.54700184",
"0.5452811",
"0.543841",
"0.53886515",
"0.53472596",
"0.53304905",
"0.53... | 0.88392895 | 0 |
Rollback the savepoint with the given id | def savepoint_rollback(self, id):
self.execute("ROLLBACK TO SAVEPOINT {}".format(id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rollback_to(self, name):\n if not isinstance(name, str) or len(name.strip()) == 0:\n raise ProgrammingError(\"Invalid SAVEPOINT name\")\n self._connection.execute_nonquery(\n \"sql\",\n f\"ROLLBACK TO SAVEPOINT {quote_identifier(name)}\",\n True,\n ... | [
"0.7168183",
"0.6872426",
"0.6833481",
"0.67801434",
"0.6742444",
"0.669766",
"0.66901237",
"0.6679372",
"0.6601219",
"0.6487994",
"0.64684784",
"0.6451165",
"0.6442229",
"0.64306086",
"0.6400453",
"0.62901735",
"0.6258998",
"0.61950433",
"0.60964864",
"0.60820466",
"0.601566... | 0.92670494 | 0 |
Disable the connection's transaction support, for example by setting the isolation mode to 'autocommit' | def disable_transactions(self):
self.rollback()
yield | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_autocommit_off(self):\n res = self.dbh.run_autocommit(False)\n self.assertIsNone(res)",
"def start_transaction(self):\n self._db.autocommit = False",
"def set_tx_isolation(self):\n # https://dev.mysql.com/worklog/task/?id=9636\n # MYSQL_5_TO_8_MIGRATION\n if s... | [
"0.6684296",
"0.65854245",
"0.63642794",
"0.61816436",
"0.6149668",
"0.61228764",
"0.6114969",
"0.60978216",
"0.5916519",
"0.59022367",
"0.5873229",
"0.5825638",
"0.58005404",
"0.5782175",
"0.5744321",
"0.5735494",
"0.57067984",
"0.556692",
"0.55637825",
"0.5550606",
"0.55307... | 0.67661643 | 0 |
Create the lock table if it does not already exist. | def create_lock_table(self):
try:
with self.transaction():
self.execute(self.create_lock_table_sql.format(self))
except self.DatabaseError:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __createTableIfNotExists(self):\n query = \"SELECT name FROM sqlite_master WHERE type='table'\"\n results = self._cursor.execute(query)\n name_list = [name for r in results for name in r]\n\n if self.table_name not in name_list:\n # Timestamp is for the time from pythons ... | [
"0.6715152",
"0.6582216",
"0.6542635",
"0.648909",
"0.64771235",
"0.6382866",
"0.63716376",
"0.632266",
"0.6290517",
"0.6286476",
"0.62847483",
"0.62701046",
"0.6263319",
"0.62404543",
"0.6219418",
"0.6195649",
"0.61955684",
"0.61487883",
"0.6134242",
"0.6123798",
"0.61145246... | 0.86439276 | 0 |
Check and upgrade yoyo's internal schema. | def ensure_internal_schema_updated(self):
if self._internal_schema_updated:
return
if internalmigrations.needs_upgrading(self):
assert not self._in_transaction
with self.lock():
internalmigrations.upgrade(self)
self.connection.commit()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def upgradeSchema(self) -> None:",
"def upgrade_schema():\n\n db_version = get_db_version()\n try:\n while db_version < CURRENT_DATABASE_VERSION:\n db_version += 1\n upgrade_script = 'upgrade_to_'+str(db_version)\n globals()[upgrade_script]()\n except KeyErr... | [
"0.76689655",
"0.6483057",
"0.64351314",
"0.6320934",
"0.61950755",
"0.61950755",
"0.6017873",
"0.58912766",
"0.5770561",
"0.57435405",
"0.5736878",
"0.5730118",
"0.5729991",
"0.5683597",
"0.56561327",
"0.5648598",
"0.5648271",
"0.5627395",
"0.56119394",
"0.56026196",
"0.5597... | 0.75230944 | 1 |
Return the list of migration hashes in the order in which they were applied | def get_applied_migration_hashes(self):
self.ensure_internal_schema_updated()
sql = self.applied_migrations_sql.format(self)
return [row[0] for row in self.execute(sql).fetchall()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_applied_migrations(self):\n with self.internal_db.begin() as conn:\n sql = \"SELECT name from migration;\"\n migrations = conn.execute(sql).fetchall()\n return [m[0] for m in migrations]",
"def to_apply(self, migrations):\n applied = self.get_applied_migration_h... | [
"0.6956376",
"0.68037903",
"0.63020134",
"0.6074639",
"0.6040121",
"0.60337085",
"0.60239613",
"0.5929028",
"0.5898079",
"0.57800215",
"0.57381326",
"0.57321006",
"0.5724899",
"0.5688587",
"0.56755334",
"0.56513876",
"0.5572648",
"0.5567353",
"0.5539155",
"0.548781",
"0.54786... | 0.7844744 | 0 |
Return the subset of migrations already applied and which may be rolled back. The order of migrations will be reversed. | def to_rollback(self, migrations):
applied = self.get_applied_migration_hashes()
ms = (m for m in migrations if m.hash in applied)
return migrations.__class__(
reversed(topological_sort(ms)), migrations.post_apply
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_applied_migrations(self):\n with self.internal_db.begin() as conn:\n sql = \"SELECT name from migration;\"\n migrations = conn.execute(sql).fetchall()\n return [m[0] for m in migrations]",
"def get_available_migrations(self):\n migrations = set()\n for f ... | [
"0.69642067",
"0.68544054",
"0.68086565",
"0.6761815",
"0.67466116",
"0.6605805",
"0.65244645",
"0.62952274",
"0.61215043",
"0.609772",
"0.6051195",
"0.59758854",
"0.5804454",
"0.5716386",
"0.55545163",
"0.55143344",
"0.5507644",
"0.54986966",
"0.5463343",
"0.54569095",
"0.54... | 0.70861655 | 0 |
Run any postapply migrations present in ``migrations`` | def run_post_apply(self, migrations, force=False):
for m in migrations.post_apply:
self.apply_one(m, mark=False, force=force) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_migrations(self):",
"def model_post_migrate(*args, **kwargs):\n global IN_MIGRATIONS\n IN_MIGRATIONS = False",
"def run_migrations(self, migrations):\n for migration in migrations:\n name = migration[\"name\"]\n migration[\"script\"] = self.get_sql_script(name)\n\n ... | [
"0.7919552",
"0.72818",
"0.7218555",
"0.7071908",
"0.70119965",
"0.6584717",
"0.6558056",
"0.6474744",
"0.6377573",
"0.6348761",
"0.6336851",
"0.6278092",
"0.6247853",
"0.6245194",
"0.62331754",
"0.62325",
"0.62247837",
"0.62239474",
"0.6211887",
"0.61842954",
"0.6164936",
... | 0.8433546 | 0 |
Rollback a single migration | def rollback_one(self, migration, force=False):
logger.info("Rolling back %s", migration.id)
self.ensure_internal_schema_updated()
migration.process_steps(self, "rollback", force=force)
self.log_migration(migration, "rollback")
with self.transaction():
self.unmark_one... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rollback(migrator, database, fake=False, **kwargs):\n pass",
"def rollback(self):\r\n self.db.rollback()",
"def rollback(self):\n self.db.rollback()",
"def rollback(self):\n pass",
"def rollback(self):\n self.conn.rollback()",
"def rollback(self):\n raise NotImpl... | [
"0.7597766",
"0.74895024",
"0.7434431",
"0.7209166",
"0.7109169",
"0.70990753",
"0.70444125",
"0.70286727",
"0.6983482",
"0.6979073",
"0.6941488",
"0.6845109",
"0.68448836",
"0.68221384",
"0.67402834",
"0.6728949",
"0.65991324",
"0.6587818",
"0.6539391",
"0.6508419",
"0.64973... | 0.7761049 | 0 |
Import and return the named DBAPI driver module | def get_dbapi_module(name):
return import_module(name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_driver_module(self):\n driver = get_dbapi_module(self.driver_module)\n exceptions.register(driver.DatabaseError)\n return driver",
"def _import_dbo_driver(self, dbo_driver):\n\n return importlib.import_module(dbo_driver)",
"def getDBSApi():\n if 'testbed' in dbs3_url:\n... | [
"0.78080094",
"0.6933537",
"0.6928564",
"0.6539357",
"0.63883835",
"0.62572336",
"0.6166937",
"0.5869059",
"0.58421063",
"0.57864547",
"0.5779158",
"0.5737559",
"0.57229096",
"0.57229096",
"0.57229096",
"0.5722717",
"0.5722717",
"0.57017565",
"0.57009023",
"0.57009023",
"0.56... | 0.8363904 | 0 |
Validates the bucket list data | def validate_bucket_list_data(func):
@wraps(func)
def validate_bucket_list(*args, **kwargs):
bucket_list_data = request.get_json()
if not bucket_list_data:
return {"message": "You have to provide the required data"}, 400
elif "bucket_list_id" not in bucket_list_data or "bucke... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_get_bucket_list_data(func):\n @wraps(func)\n def validate_data(*args, **kwargs):\n limit_of_items = request.args.get('limit')\n page_no = request.args.get('page')\n query = request.args.get('q')\n if not isinstance(limit_of_items, int):\n return {\"message\... | [
"0.6716562",
"0.6261523",
"0.6235112",
"0.59970206",
"0.59509945",
"0.5947807",
"0.59445846",
"0.594176",
"0.58961564",
"0.58957505",
"0.5880116",
"0.58611774",
"0.5849924",
"0.58360267",
"0.58294684",
"0.58293635",
"0.5817248",
"0.5816991",
"0.58105755",
"0.5768447",
"0.5745... | 0.74141 | 0 |
Fetch data of the current period. | async def fetch_current_period(self):
await self.fetch_all_periods_raw()
self._logger.info("Fetching current period data")
json_res = self._all_periods_raw[0]
self._current_period = {}
for key, data in CURRENT_MAP.items():
self._current_period[key] = json_r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def fetch_all_periods_raw(self):\n self._logger.info(\"Fetching current period data\")\n await self._client.select_customer(self.account_id, self.customer_id)\n\n params = {'idContrat': '0' + self.contract_id}\n res = await self._client.http_request(CONTRACT_CURRENT_URL_3, \"get\"... | [
"0.7365732",
"0.68140924",
"0.6608338",
"0.651072",
"0.6363908",
"0.6260412",
"0.61981994",
"0.61610883",
"0.612922",
"0.6111493",
"0.6097787",
"0.60829765",
"0.59900206",
"0.59758735",
"0.5972339",
"0.59691715",
"0.59367496",
"0.5919092",
"0.59156233",
"0.5889079",
"0.586403... | 0.79306346 | 0 |
Fetch data of all the periods and stored it in raw states | async def fetch_all_periods_raw(self):
self._logger.info("Fetching current period data")
await self._client.select_customer(self.account_id, self.customer_id)
params = {'idContrat': '0' + self.contract_id}
res = await self._client.http_request(CONTRACT_CURRENT_URL_3, "get", params=param... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def fetch_current_period(self):\n\n await self.fetch_all_periods_raw()\n\n self._logger.info(\"Fetching current period data\")\n \n json_res = self._all_periods_raw[0]\n\n self._current_period = {}\n for key, data in CURRENT_MAP.items():\n self._current_per... | [
"0.7113313",
"0.61913276",
"0.59504074",
"0.58694655",
"0.5862734",
"0.58406967",
"0.5810176",
"0.57895696",
"0.5775264",
"0.57086813",
"0.5688354",
"0.5669046",
"0.5650255",
"0.56254244",
"0.5625138",
"0.5608699",
"0.5586064",
"0.55529875",
"0.55447406",
"0.5541005",
"0.5534... | 0.74418646 | 0 |
Return collected monthly data of the current year. | def current_monthly_data(self):
return self._current_monthly_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def fetch_monthly_data(self):\n self._logger.info(\"Fetching monthly data\")\n await self._client.select_customer(self.account_id, self.customer_id)\n headers = {\"Content-Type\": \"application/json\"}\n res = await self._client.http_request(MONTHLY_DATA_URL, \"get\", headers=head... | [
"0.6959322",
"0.6864002",
"0.6775935",
"0.6734739",
"0.66153824",
"0.63786316",
"0.6339446",
"0.6234003",
"0.62111247",
"0.6198287",
"0.61954886",
"0.61515737",
"0.6144586",
"0.611688",
"0.60399127",
"0.6024035",
"0.6000673",
"0.5995335",
"0.59884",
"0.59790665",
"0.59761906"... | 0.730444 | 0 |
Return collected daily data of the current year. | def current_daily_data(self):
return self._current_daily_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def daily(self):\n url = f\"?function=TIME_SERIES_DAILY&{self.url_append}\"\n data = self.client.get(url=url).json()\n return self.__process__(data[f\"Time Series (Daily)\"], metadata=data[\"Meta Data\"], format=\"%Y-%m-%d\")",
"def daily(self):\n return c.Daily(self)",
"def year_da... | [
"0.69483185",
"0.66666967",
"0.65841186",
"0.650167",
"0.64621854",
"0.6440734",
"0.63282704",
"0.6238483",
"0.6213337",
"0.6193845",
"0.61800516",
"0.61739266",
"0.61631864",
"0.60694844",
"0.6011108",
"0.5974877",
"0.5966672",
"0.5928624",
"0.5920005",
"0.5877967",
"0.58636... | 0.6867238 | 1 |
Return collected hourly data. | def hourly_data(self):
return self._hourly_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hourly_data():\n return generate_df_for_tests(freq=\"H\", periods=24 * 500)",
"def get_hourly(self):\n pass",
"async def fetch_hourly_data(self, day=None):\n self._logger.info(\"Fetching hourly data for %s\", day)\n await self._client.select_customer(self.account_id, self.customer_i... | [
"0.76183605",
"0.74695057",
"0.73557806",
"0.68906623",
"0.68146986",
"0.67716026",
"0.6657837",
"0.6532368",
"0.6456294",
"0.64482284",
"0.6372681",
"0.63097465",
"0.62673557",
"0.61356765",
"0.6119386",
"0.6113111",
"0.61089766",
"0.6041314",
"0.6011854",
"0.599214",
"0.598... | 0.8046037 | 0 |
Returns the OAuth access token string. | def access_token(self):
return self.access_token_str | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_access_token():\n\n account = get_account()\n\n account.EnsureCredentials(dbus_interface=GOA_ACCOUNT)\n access_token, _ = account.GetAccessToken(dbus_interface=GOA_ACCOUNT_OAUTH2)\n return str(access_token)",
"def return_authorization_string(self):\n\n return \"{0} {1}\".format(self.to... | [
"0.76856524",
"0.7420995",
"0.7396376",
"0.7383793",
"0.72701585",
"0.72463155",
"0.7242154",
"0.71939355",
"0.717772",
"0.717772",
"0.7120599",
"0.7098091",
"0.7097638",
"0.70772445",
"0.70346785",
"0.6991295",
"0.6950604",
"0.6881695",
"0.676658",
"0.67661756",
"0.6747697",... | 0.75482535 | 1 |
Register a Mastodon API app on a specific instance. | def _register_app(self, instance, app_name, app_url):
logging.info("first time we've seen Mastodon instance %s with app %s %s! "
"registering an API app.", instance, app_name, app_url)
redirect_uris = set(urljoin(self.request.host_url, path)
for path in set(self.REDIREC... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_app_instance(script_info):\n return create_app()",
"def init_app(app):\n api.add_namespace(ns)\n app.register_blueprint(bp, url_prefix='/api/v1')",
"def register(self):\n if self.registered:\n return\n\n config = current_app.config.get('TERMINAL_CONFIGS', {})\n ... | [
"0.6017061",
"0.6014171",
"0.5984297",
"0.5937011",
"0.5924655",
"0.5904233",
"0.5879818",
"0.5878323",
"0.5856865",
"0.58478624",
"0.5840547",
"0.58206224",
"0.5798079",
"0.5774702",
"0.5749019",
"0.5706185",
"0.5705004",
"0.5704147",
"0.56701416",
"0.56276834",
"0.5625791",... | 0.8092017 | 0 |
Rescale a super_video according to its new width, height an fps | def rescale_video(video_fn, w, h, fps, dir, new_dir, common_suffix, dict_video_length, ffmpeg, crf=17):
# Output video_name
video_id = video_fn.replace(dir, '').replace(common_suffix, '')
video_fn_rescaled = video_fn.replace(dir, new_dir)
video_fn_rescaled = video_fn_rescaled.replace(common_suffix, com... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changeRes(width, height):\n\n\tlive_capture.set(3, width)\n\tlive_capture.set(4, height)",
"def run(input_video_file, output_video_file):\n print(\"Debut de la transformation du format de la video\")\n #récupération de la vidéo\n video = cv2.VideoCapture(input_video_file)\n #fps de la vidéo\n ... | [
"0.6355776",
"0.61875075",
"0.6132847",
"0.6068619",
"0.5990971",
"0.59293383",
"0.5892419",
"0.58009297",
"0.5786489",
"0.567829",
"0.56765693",
"0.5675275",
"0.5652734",
"0.5638916",
"0.5577313",
"0.5576904",
"0.5563446",
"0.5551674",
"0.5538098",
"0.55366886",
"0.5498801",... | 0.6649745 | 0 |
Scrapes the specified Shopify site and adds items to array | def scrape_site(url, headers, proxy):
items = []
# Makes request to site
s = rq.Session()
page = 1
while True:
html = s.get(url + f'?page={page}&limit=250', headers=headers, proxies=proxy, verify=False, timeout=20)
output = json.loads(html.text)['products']
if output == []:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrape(site=''):\n scraper.scrape(get_site_config(site))",
"def parse(self, response):\n for sel in response.xpath('//*[@id=\"J_goodsList\"]/ul/li[@class=\"gl-item\"]'):\n \"\"\"iterate all items in this page\"\"\"\n sku = sel.xpath('.//@data-sku').extract_first()\n ... | [
"0.64423054",
"0.6175078",
"0.6085178",
"0.60668594",
"0.59142834",
"0.5875458",
"0.58454096",
"0.58255935",
"0.5776304",
"0.5691475",
"0.5663107",
"0.5657626",
"0.5636857",
"0.562094",
"0.5594744",
"0.55909693",
"0.5581335",
"0.5541942",
"0.5541779",
"0.55263656",
"0.5523055... | 0.7233906 | 0 |
Get convex hull property values from resource files produced by numerical simulations. Notes Original data can be found at | def _get_resource(
resource_directory: str, resource: str
) -> ConvexHullExpectationValues:
try:
resource_ = importlib_resources.files(resource_directory).joinpath(resource)
resource_values = np.load(str(resource_))
except (AttributeError, TypeError): # required for python < 3.9
w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hull(self):\n capacity = self._getAttribute(Attribute.hullCapacity)\n em = self._getAttribute(Attribute.hullEM)\n explosive = self._getAttribute(Attribute.hullExplosive)\n kinetic = self._getAttribute(Attribute.hullKinetic)\n thermal = self._getAttribute(Attribute.hullThermal)\n\n em = 1.0 - ... | [
"0.6126978",
"0.5919253",
"0.5813936",
"0.5810784",
"0.57919985",
"0.55380297",
"0.5495465",
"0.54732853",
"0.54562294",
"0.535494",
"0.5352206",
"0.532841",
"0.52941144",
"0.5280437",
"0.5260272",
"0.5234388",
"0.5232042",
"0.52203715",
"0.51945525",
"0.5159477",
"0.5150251"... | 0.5959517 | 1 |
Compute the expected convex hull area for `n_points` data points that are normal distributed in 2dimensional space with standard deviation `sigma`. | def compute_convex_hull_region_measure_2d(n_points, sigma=1) -> float:
def pdf(x):
return 1 / (np.sqrt(2 * np.pi)) * np.exp((-1 / 2) * (x**2))
def cdf(x):
return 1 / 2 * (1 + special.erf(x / np.sqrt(2)))
area = (
3
* np.pi
* special.binom(n_points, 3)
* int... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ns_sigma_clip(self, n_norm_sigma):\n nres = self.data.norm_results[:,self.result_index]\n npred = self.predict(self.data.norm_params)[:,0]\n err = npred - nres\n m = np.nanmean(err)\n s = np.nanstd(err)\n bad = (np.abs((err - m) / s) > n_norm_sigma)\n self.data.... | [
"0.5858475",
"0.5774635",
"0.57685256",
"0.56553096",
"0.55031556",
"0.54939026",
"0.54421043",
"0.53947896",
"0.5381842",
"0.53763247",
"0.53630286",
"0.5358807",
"0.5358578",
"0.53430283",
"0.5337358",
"0.53338265",
"0.53302515",
"0.53286016",
"0.5291966",
"0.5289076",
"0.5... | 0.72793144 | 0 |
Get the expected convex hull property for `n_points` data points that are normal distributed in 2 or 3dimensional space with standard deviation `sigma`. | def _get_convex_hull_property_expectation(
convex_hull_property, n_points, sigma=1
) -> ConvexHullExpectationValues:
try:
convex_hull_property = convex_hull_property.name.upper()
except AttributeError:
convex_hull_property = convex_hull_property.upper()
convex_hull_expectation_values = _... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_convex_hull_region_measure_2d(n_points, sigma=1) -> float:\n\n def pdf(x):\n return 1 / (np.sqrt(2 * np.pi)) * np.exp((-1 / 2) * (x**2))\n\n def cdf(x):\n return 1 / 2 * (1 + special.erf(x / np.sqrt(2)))\n\n area = (\n 3\n * np.pi\n * special.binom(n_points, ... | [
"0.6603479",
"0.59581935",
"0.5903127",
"0.58651793",
"0.57674575",
"0.57210475",
"0.5712172",
"0.5508661",
"0.5475195",
"0.5473231",
"0.54275763",
"0.54015243",
"0.5391555",
"0.5387514",
"0.538605",
"0.5376728",
"0.53753835",
"0.5368965",
"0.5358368",
"0.53517467",
"0.534619... | 0.67292875 | 0 |
Return the prefix assigned to 'namespace', or None | def getNamespacePrefix(self, namespace):
return self.namespaceTable.get(namespace, None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefixForNamespace (self, namespace):\n pfxs = self.__inScopePrefixes.get(namespace)\n if pfxs:\n return next(iter(pfxs))\n return None",
"def prefix_to_ns(self, prefix):\n defin = self.module.i_ctx.get_module(\n self.module.i_prefixes[prefix][0])\n re... | [
"0.827114",
"0.79014564",
"0.78330964",
"0.77960485",
"0.77960485",
"0.77960485",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",
"0.7595303",... | 0.838441 | 0 |
sm.set_current_screen( GameScreen ) > None Store the given screen to the one that should be shown. | def set_current_screen(self, screen):
self.current_screen = screen
screen.screen_manager = self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_change_screen(self):\n self.sm.add_widget(Screen(name='screen1'))\n self.sm.current = 'screen1'\n self.assertEqual(self.sm.current, 'login')\n self.assertTrue(isinstance(self.sm.current_screen, LoginScreen))",
"def change_to(name):\n global screen_manager\n screen_manag... | [
"0.7270156",
"0.71507627",
"0.68489456",
"0.6746601",
"0.6649845",
"0.6617163",
"0.6565083",
"0.64988285",
"0.63238007",
"0.6288834",
"0.62576365",
"0.6245604",
"0.61572176",
"0.6115946",
"0.60883117",
"0.60883117",
"0.60374165",
"0.6036424",
"0.6035109",
"0.60126704",
"0.598... | 0.82100713 | 0 |
sm.set_controls( Controls ) > None Set a control scheme while leaving the current screen the same. | def set_controls(self, controls):
self.current_screen.control_manager.switch_controls(controls) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def switch_to_controls_screen(self, player):\n\t\tcontrols = SelectControls(player) #it's possible these should be ControlsControls but I'm not sure\n\t\tcontrol_manager = ControlManager(controls)\n\t\tcontrols_screen = ControlsScreen(control_manager, player)\n\t\tself.set_current_screen(controls_screen)",
"def ... | [
"0.6972065",
"0.65079385",
"0.64458215",
"0.63720655",
"0.63699996",
"0.6328795",
"0.6309921",
"0.62696147",
"0.62689507",
"0.62678826",
"0.62462693",
"0.62401974",
"0.623622",
"0.6229467",
"0.62196404",
"0.62115294",
"0.6206061",
"0.62000954",
"0.62000954",
"0.62000954",
"0.... | 0.83586055 | 0 |
sm.process_event( Event ) > None Process a pygame event based on the current control scheme. | def process_event(self, event):
self.current_screen.control_manager.process_event(event) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_event(self, event):\r\n pass",
"def process_event(self, event):\n if event.type == pygame.QUIT:\n self.quit = True\n\n if event.type == pygame.USEREVENT:\n if event.user_type == pygame_gui.UI_BUTTON_PRESSED:\n if event.ui_element == self.singl... | [
"0.71941525",
"0.7068599",
"0.6623851",
"0.64792836",
"0.6467519",
"0.64671814",
"0.6467147",
"0.6459091",
"0.6391475",
"0.6390151",
"0.6384425",
"0.6347497",
"0.63339925",
"0.6285484",
"0.6232094",
"0.62160754",
"0.6203715",
"0.61761636",
"0.6165278",
"0.61482537",
"0.611202... | 0.7981769 | 0 |
sm.update_current_screen( ) > None Tell the current screen to update its visual elements. | def update_current_screen(self):
self.current_screen.update() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_screen(self):",
"def refresh(self) -> None:\n self.screen.refresh()",
"def _refresh_screen(self):\n self.myscreen.refresh()\n self.box1.refresh()\n self.box2.refresh()",
"def _update_screen(self):\n\t\tself.screen.fill(self.settings.bg_color)\n\t\tself.pigeon.blitme()\... | [
"0.7810991",
"0.73679274",
"0.7259116",
"0.7194947",
"0.71816343",
"0.7161952",
"0.71343434",
"0.7116386",
"0.7085809",
"0.7063459",
"0.70556456",
"0.7044937",
"0.70166755",
"0.69851005",
"0.6974298",
"0.69600856",
"0.6908582",
"0.6886732",
"0.68431026",
"0.68343574",
"0.6812... | 0.8883656 | 0 |
sm.draw_screen( ) > None The screen manager draws its screen image onto the screen that the player would see. | def draw_screen(self):
self.current_screen.draw_screen(self.master_screen) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_screen(self, master_screen):\n master_screen.blit(self.screen_image, (0, 0))",
"def drawScreen(screen):\n screen.fill(BLACK) # Fill the screen with black.\n \n\n # Flip the display so that the things we drew actually show up.\n pygame.display.flip()",
"def draw(self, screen):",
"... | [
"0.8466092",
"0.7693201",
"0.76692",
"0.76136816",
"0.7519344",
"0.7475776",
"0.74651366",
"0.7394929",
"0.7377869",
"0.7306094",
"0.7291524",
"0.7284858",
"0.7274371",
"0.7269743",
"0.72615314",
"0.7259366",
"0.72213274",
"0.72195256",
"0.7204483",
"0.71971095",
"0.7189081",... | 0.82568353 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.