seed
stringlengths
1
14k
source
stringclasses
2 values
def compile_create_table(qualified_name: str, column_statement: str, primary_key_statement: str) -> str: """Postgresql Create Table statement formatter.""" statement = """ CREATE TABLE {table} ({columns} {primary_keys}); """.format(table=qualified_name, ...
bigcode/self-oss-instruct-sc2-concepts
def insertionsort(list, descending=False): """ Takes in a list as an argument, and sorts it using an "Insertion Sort"-algorithm. --- Args: - list (list): The list to be sorted - descending (bool): Set true if the list be sorted high-to-low. Default=False Raises: - T...
bigcode/self-oss-instruct-sc2-concepts
def GetArgsForMockCall(call_args_list, call_number): """Helper to more sanely get call args from a mocked method. Args: call_args_list: The call_args_list member from the mock in question. call_number: The call number to pull args from, starting at 0 for the first call to the method. Returns: ...
bigcode/self-oss-instruct-sc2-concepts
def filter_transmission_events(selected_events, transmission_events): """Filter transmission_events for node-links of interest. :param selected_events: Specified organism_group-organism_group relationships inside nested dictionary. :type selected_events: dict[str, dict[str, None]] :param transmissi...
bigcode/self-oss-instruct-sc2-concepts
async def raceclass() -> dict: """Create a mock raceclass object.""" return { "id": "290e70d5-0933-4af0-bb53-1d705ba7eb95", "name": "G16", "ageclass_name": "G 16 år", "order": 1, "event_id": "event_id_1", "distance": "5km", }
bigcode/self-oss-instruct-sc2-concepts
import math def mach_angle(M): """Calculate the Mach angle :param <float> M: Mach # :return <float> Mach angle, mu """ return math.asin(1 / M)
bigcode/self-oss-instruct-sc2-concepts
def binarize_score(adata, score_label: str, threshold: float): """ Binarizes a provided key of an AnnData object by labeling values over a threshold as 'positive' or 'negative'. Args: adata: AnnData object to perform the binarization for score_label: Label in adata.obs which will be used fo...
bigcode/self-oss-instruct-sc2-concepts
def _find_calframe(calframes, calpaths, values, calname, verbose=False): """ Find the calibration frame and path from given dicts for dict values. """ if calframes is None: calpath = None calframe = None else: try: calframe = calframes[values] calpath = ca...
bigcode/self-oss-instruct-sc2-concepts
def recv_all(sock): """Receive data until connection is closed.""" data = b'' while True: chunk = sock.recv(1024) if not chunk: break data += chunk return data
bigcode/self-oss-instruct-sc2-concepts
def popis_pozici(pozice): """Popíše pozici pro lidi např: >>> popis_pozici(0, 0) 'a1' """ radek, sloupec = pozice return "abcdefgh"[sloupec] + "12345678"[radek]
bigcode/self-oss-instruct-sc2-concepts
def scale_data(Data,cscale,dscale,scaledown = True): """ Returns scaled data on both columns Parameters ---------- Data: ndarray() Array of data to be scaled scaledown: bool determines if data is scaled down or up cscale: float how much to multiply column 1 by ds...
bigcode/self-oss-instruct-sc2-concepts
def _normalize_input_name(input_name): """Remove :i suffix from input tensor names.""" return input_name.split(":")[0]
bigcode/self-oss-instruct-sc2-concepts
def rectangles_circum(n: int): """Return `n` fixed circumference rectangles, w + h = n""" output = list() for i in range(1, n + 1): output.append((i, n - i + 1)) output.sort(key=lambda x: x[1], reverse=True) return output
bigcode/self-oss-instruct-sc2-concepts
def check_is_user_owner_of_plant(user, target_rich_plant): """Check if user is owner of Rich plant""" if user.id == target_rich_plant.owner: return True else: return False
bigcode/self-oss-instruct-sc2-concepts
def pullColumnAll(cursor, ticker, column_name): """ Retrieves specific column data for the given parameter (column_name) Arguments: cursor: cursor object for the database ticker: ticker for which we are collecting data column_name: specific column we want data from Returns: ...
bigcode/self-oss-instruct-sc2-concepts
import re def regex_search(regex, text): """ Do regular expression search for text. :param regex: Regular expression for search, if none then disabled :param text: Text where to search :return: True if search finds something or regex is None """ if regex: return re.search(regex, t...
bigcode/self-oss-instruct-sc2-concepts
import re def UpdateVerityTable(table, hash_offset): """Update the verity table with correct hash table offset. Args: table: the verity hash table content hash_offset: the hash table offset in sector (each sector has 512 bytes) Returns: updated verity hash table content """ find_offset = re.c...
bigcode/self-oss-instruct-sc2-concepts
def read_lines(txt_name=""): """return the text in a file in lines as a list """ txt_name="./intermediate_file/detect_result/txt/"+txt_name f = open(txt_name,'rU') return f.readlines()
bigcode/self-oss-instruct-sc2-concepts
def list_to_id_dict(base, attribute): """ Return a dict from an attribute in a list of dicts. """ ret = {} for d in base: ret[d[attribute]] = d return ret
bigcode/self-oss-instruct-sc2-concepts
def nth_replace(string, old, new, n=1, option='only nth'): # https://stackoverflow.com/questions/35091557/replace-nth-occurrence-of-substring-in-string """ This function replaces occurrences of string 'old' with string 'new'. There are three types of replacement of string 'old': 1) 'only nth' repla...
bigcode/self-oss-instruct-sc2-concepts
def translate_inequality(param_name): """ Replace GT or LT at the end of a param name by '>' or '<' to achieve Twilio-like inequalities. """ for suffix, replacement in (('GT', '>'), ('LT', '<')): if param_name.endswith(suffix): return param_name[:-len(suffix)] + replacement ...
bigcode/self-oss-instruct-sc2-concepts
def item_order(node): """ Extracts item order value from a project tree node. :param Node node: project tree node. :return: item order value or -1 if not present. :rtype: int """ return node.item.order if node.item.order else -1
bigcode/self-oss-instruct-sc2-concepts
import math def RayleighNumber(g, alpha, deltaT, nu, kappa, H): """ Calculate the Rayleigh number: Ra = g alpha delta T H^3 ------------------- nu kappa """ return (g * alpha * deltaT * math.pow(H, 3.0)) / (nu * kappa)
bigcode/self-oss-instruct-sc2-concepts
import typing import warnings def format_timestamp(ts: typing.Union[int, float]) -> str: """ Function for formatting start/end timestamps. Somewhat more condensed than the standard Pandas formatting. :param ts: The timestamps in microseconds. Rendered as integers, since `idelib` times...
bigcode/self-oss-instruct-sc2-concepts
def hex_to_int(color): """ :hex_to_int: converts a string hexadecimal rgb code to a tuple rgb code consisting or integer values for each channel. :param color: string | hex code for a color (does not include the hashtag) :return: (r, g, b) | a tuple rgb code in integer form ...
bigcode/self-oss-instruct-sc2-concepts
from typing import Any from typing import Union from typing import List from typing import Dict def get_level_lengths( levels: Any, sentinel: Union[bool, object, str] = "" ) -> List[Dict[int, int]]: """For each index in each level the function returns lengths of indexes. Parameters ---------- lev...
bigcode/self-oss-instruct-sc2-concepts
from typing import Dict from typing import Any def _generate_delete_response_with_errors(num_rows=1) -> Dict[str, Any]: """Generates a Content API delete response with errors. Args: num_rows: The number of rows to generate. Returns: A Content API response with errors (item not found). """ response...
bigcode/self-oss-instruct-sc2-concepts
def two_sum(nums, target): """ Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice.""" '''# Brute force O(n^2). for i in range(len(nu...
bigcode/self-oss-instruct-sc2-concepts
import re def osFindValue(obj, searchTerm, searchMethod): """Internal helper method! Generic search method to search a string or int for a searchTerm. Different search methods can be provided for different ways of searching. Args: obj (str|int): The object that is being searched in se...
bigcode/self-oss-instruct-sc2-concepts
def round_to_nearest_increment(x :float, tick_size : float = 0.25) -> float: """ rounds a price value to the nearest increment of `tick_size` Parameters ----------- x : float the price value tick_size: float the size of the tick. E.G. for ES = 0.25, for CL = 0.01 """ val = round(tick_size * r...
bigcode/self-oss-instruct-sc2-concepts
def prob4(A): """Make a copy of 'A' and set all negative entries of the copy to 0. Return the copy. Example: >>> A = np.array([-3,-1,3]) >>> prob4(A) array([0, 0, 3]) """ B = A.copy() B[A < 0] = 0 return B
bigcode/self-oss-instruct-sc2-concepts
def calcSlope(y1, y2, x1, x2): """ Calculate slope between two points """ if x2-x1 == 0: slope = 0 else: slope = (y2 - y1) / (x2 - x1) return slope
bigcode/self-oss-instruct-sc2-concepts
def generate_gcp_project_link(project_id: str) -> str: """Generates a Slack markdown GCP link from the given `project_id`. Args: project_id: The project ID of which to hyperlink. Returns: The generated hyperlink. """ return ('<https://console.cloud.google.com/home/' + ...
bigcode/self-oss-instruct-sc2-concepts
import json def load_json(fpath): """ Load a file from json Args: fpath (string or pathlib.Path object): Path to a json file Returns: python object parsed from json """ with open(fpath, "r") as infile: return json.load(infile)
bigcode/self-oss-instruct-sc2-concepts
def to_string(text, encoding='utf8', errors='strict'): """Convert a string (bytestring in `encoding` or unicode), to unicode.""" if isinstance(text, str): return text return str(text, encoding, errors=errors)
bigcode/self-oss-instruct-sc2-concepts
import struct def parse_task_packet(packet, offset=0): """ Parse a result packet- [2 bytes] - type [2 bytes] - total # of packets [2 bytes] - packet # [2 bytes] - task/result ID [4 bytes] - length [X...] - result data +------+--------------------+--...
bigcode/self-oss-instruct-sc2-concepts
def slope(first_point, second_point): """ Returns the slope between 2 points :param first_point: first point (x,y) :param second_point: second point (x,y) :return: the slope """ return 0. if first_point[0] == second_point[0] else\ ((float(first_point[1]) - float(second_point[1])) / ...
bigcode/self-oss-instruct-sc2-concepts
def stateLabel(s, state_type): """Returns the short-hand label of the state. Parameters: s (State): a State object. state_type (string): either 'e' or 'g' for excited state or ground state. The ground state is primed. Returns: string: "J=...
bigcode/self-oss-instruct-sc2-concepts
def is_void(line): """Test if it is a void line""" for i in line: if i!=' ' and i!='\t' and i!='\n': return False return True
bigcode/self-oss-instruct-sc2-concepts
def nested_lookup(n, idexs): """Function to fetch a nested sublist given its nested indices. Parameters ---------- n: list, the main list in which to look for the sublist idexs: list, the indices of the sublist Returns ------- list: sublist with given indices """...
bigcode/self-oss-instruct-sc2-concepts
from typing import Any from typing import TypeGuard import numbers def is_integer(x: Any) -> TypeGuard[int]: """Return true if x is an integer.""" return isinstance(x, numbers.Integral) and not isinstance(x, bool)
bigcode/self-oss-instruct-sc2-concepts
from typing import List def error_detail(error: Exception) -> List[str]: """Convert an Exception to API representation.""" return [type(error).__name__] + [str(a) for a in error.args]
bigcode/self-oss-instruct-sc2-concepts
def retrieve_pendulum_data(filename = "pendulum.dat"): """ Gets pendulum data from filename and outputs a 2d list of output[0] = L and output[1] = T """ L_list = [] T_list = [] with open(filename, 'r') as infile: for line in infile: data = line.split() try: ...
bigcode/self-oss-instruct-sc2-concepts
def selection_sort(lst: list) -> list: """This is a selection sort algorithm implementation Parameters ---------- lst: list The unsorted list Returns ------- list A sorted list in ascending order References ---------- https://en.wikipedia.org/wiki/Selec...
bigcode/self-oss-instruct-sc2-concepts
def chunks(l, n): """ Yield successive n-sized chunks from l. """ out = [] lens = (len(l) / n) for i in range(0, lens): out.append(l[i * n:i * n + n]) out.append(l[lens * n:]) return out[:-1]
bigcode/self-oss-instruct-sc2-concepts
def find_cols(defline, header_char='='): """ return a sorted list of (start, end) indexes into defline that are the beginning and ending indexes of column definitions based on a reStructuredText table header line. Note that this is a braindead simple version that only understands header_chars an...
bigcode/self-oss-instruct-sc2-concepts
def frompct(x): """ Convert Percent values to Decimal fraction >>> frompct([1.0, 2.3, 80.0, -23.0, 100.0]) [0.01, 0.023, 0.8, -0.23, 1.0] """ return x / 100.0
bigcode/self-oss-instruct-sc2-concepts
def flatten(seq): """ >>> flatten([1 , [2, 2], [2, [3, 3, 3]]]) [1, 2, 2, 2, 3, 3, 3] """ # flatten fonction from C:\Python26\Lib\compiler\ast.py, # compiler is deprecated in py2.6 l = [] for elt in seq: t = type(elt) if t is tuple or t is list or t is set: ...
bigcode/self-oss-instruct-sc2-concepts
def clean(angr_answer): """ angr deals in byte strings, which are not always null-terminated, so clean things up a bit. """ # angr can return non-ascii characters into stdout; we don't want to decode # these, since we're assuming flags are ascii printable. return angr_answer.decode("utf-8", errors="ignore")
bigcode/self-oss-instruct-sc2-concepts
import math def calculate_ratio(numerator_pair, denominator_pair): """ Computes a derived estimate and its MOE for the ratio between the numerator and denominator arguments where the numerator does not represent a subset of the denominator. Args: numerator (list): a two-item sequence with...
bigcode/self-oss-instruct-sc2-concepts
def json(path, _pod): """Retrieves a json file from the pod.""" return _pod.read_json(path)
bigcode/self-oss-instruct-sc2-concepts
from typing import Callable from typing import Tuple from typing import Mapping from typing import Union def _find_one_tree(tree: dict, func: Callable, args: Tuple, kwargs: Mapping, ) -> Union[dict, None]: """ Find one item in the spe...
bigcode/self-oss-instruct-sc2-concepts
from datetime import datetime def str_date_to_date(date_from, date_to): """ Convert two dates in str format to date object Format: YYYYMMDD :param date_from: beginning of the interval :param date_to: end of the interval :return: from_date and to_date equivalent of given in date objects ""...
bigcode/self-oss-instruct-sc2-concepts
def percentage(part, total): """ Calculate percentage. """ return (part / total) * 100
bigcode/self-oss-instruct-sc2-concepts
def listget(lst, ind, default=None): """ Returns `lst[ind]` if it exists, `default` otherwise. >>> listget(['a'], 0) 'a' >>> listget(['a'], 1) >>> listget(['a'], 1, 'b') 'b' """ if len(lst)-1 < ind: return default return lst[ind]
bigcode/self-oss-instruct-sc2-concepts
def unquoteNS(ns): """Un-quotes a namespace from a URL-secure version.""" ns = ns.replace('_sl_', '/') ns = ns.replace('_co_', ':') return ns
bigcode/self-oss-instruct-sc2-concepts
def pre_process_data(linelist): """Empty Fields within ICD data point are changed from Null to 0""" for index in range(len(linelist)): if not linelist[index]: linelist[index] = '0' return linelist
bigcode/self-oss-instruct-sc2-concepts
def json_default(o): """ Defining the default behavior of conversion of a class to a JSON-able object. Essentially makes a dictionary out of the class and returns it. Returns a list of all its elements in case of a set. :param o: The object to convert to JSON. :return: JSON-able version of the c...
bigcode/self-oss-instruct-sc2-concepts
import requests def extra_metadata_helper(project_url, headers): """ Build extra metadata dict to help with other integrations. Parameters ---------- project_url: str The url to the project info headers: dict Figshare Authorization header Returns ------- Extra...
bigcode/self-oss-instruct-sc2-concepts
def get_all_slots(cls): """Iterates through a class' (`cls`) mro to get all slots as a set.""" slots_iterator = (getattr(c, '__slots__', ()) for c in cls.__mro__) # `__slots__` might only be a single string, # so we need to put the strings into a tuple. slots_converted = ((slots,) if isinstance(slot...
bigcode/self-oss-instruct-sc2-concepts
def min_peak(peak): """ Minimum peak criteria Parameters ---------- peak : float The minimum peak pixel value in a leaf """ def result(structure, index=None, value=None): return structure.vmax >= peak return result
bigcode/self-oss-instruct-sc2-concepts
def _exclude(term): """ Returns a query item excluding messages that match the given query term. Args: term (str): The query term to be excluded. Returns: The query string. """ return f"-{term}"
bigcode/self-oss-instruct-sc2-concepts
def make_QC_header(coverage, identity, length): """ Create a header for the read QC file """ cols = "\t".join(["dataset", "read_ID", "passed_QC", "primary_mapped", "read_length", "fraction_aligned", "identity"]) header = "\n".join(["# TALON run filtering settings:", ...
bigcode/self-oss-instruct-sc2-concepts
def is_float32(t): """ Return True if value is an instance of a float32 (single precision) type. """ return t.typecode == "f"
bigcode/self-oss-instruct-sc2-concepts
def join(left, right): """ Join two dag paths together :param str left: A node dagpath or name. :param str right: A node name. :return: A dagpath combining the left and right operant. :rtype:str """ dagpath = "%s|%s" % (left.strip("|"), right.strip("|")) if left.startswith("|"): ...
bigcode/self-oss-instruct-sc2-concepts
def js_time(python_time: float) -> int: """Convert python time to js time, as the mephisto-task package expects""" return int(python_time * 1000)
bigcode/self-oss-instruct-sc2-concepts
def boxBasics(box): """basic statistics of box. Returns (mean,var)""" mean=box.box_data.mean() var=box.box_data.var() return (mean,var)
bigcode/self-oss-instruct-sc2-concepts
def generator_to_list(function): """ Wrap a generator function so that it returns a list when called. For example: # Define a generator >>> def mygen(n): ... i = 0 ... while i < n: ... yield i ... i += 1 # This is ...
bigcode/self-oss-instruct-sc2-concepts
from typing import Mapping def strip_indexes(indexes): """Strip fields from indexes for comparison Remove fields that may change between MongoDB versions and configurations """ # Indexes may be a list or a dict depending on DB driver if isinstance(indexes, Mapping): return { k...
bigcode/self-oss-instruct-sc2-concepts
def get_min_key_for_max_value(d): """ For a dictionary d, get the key for the largest value. If largest value is attained several times, get the smallest respective key. """ sorted_keys = sorted([key for key in d.keys()]) values = [d[key] for key in sorted_keys] max_value = max(val...
bigcode/self-oss-instruct-sc2-concepts
def find_subtree(tree, node_id): """ Recurse through the tree until the node is found Then return the node Args: tree: Node containing full tree node_id: string id directing which nodes to traverse Returns: Node containing full tree """ # We have reached the correct...
bigcode/self-oss-instruct-sc2-concepts
def one_step_integrator(state, ders, I, dt): """RK4 integrates state with derivative and input for one step of dt :param state: state of the variables :param ders: derivative functions :param I: input :param dt: time step :return: state after one integration step""" D = len(state) # 1 k1 = [ders[i](state,I) ...
bigcode/self-oss-instruct-sc2-concepts
def fraction_of_contacts(cm, ref_cm): """ Given two contact matices of equal dimensions, computes the fraction of entries which are equal. This is comonoly refered to as the fraction of contacts and in the case where ref_cm represents the native state this is the fraction of native contacts. ...
bigcode/self-oss-instruct-sc2-concepts
def get_students(selection_db, aws_db, applicants_sql, student_fields_sql): """ Calls the database and gets student information. Input: database connection object, SQL query, dict of fields name/ID Returns: dictionary of student information, key=student ID """ students = {} with selection_d...
bigcode/self-oss-instruct-sc2-concepts
def find_closest_smaller_value(find_value, list_of_values): """ Returns the closest value from a list of values that is smaller than find_value :param find_value: The value we are searching for :param list_of_values: The list of values :return: The index of the closes value in the list. Returns -1 i...
bigcode/self-oss-instruct-sc2-concepts
def test_function_attributes(cache): """ Simple tests for attribute preservation. """ def tfunc(a, b): """test function docstring.""" return a + b cfunc = cache()(tfunc) assert cfunc.__doc__ == tfunc.__doc__ assert hasattr(cfunc, 'cache_info') assert hasattr(cfunc, 'cache_clear'...
bigcode/self-oss-instruct-sc2-concepts
import re def FillParagraph(text,width=70,indentLinesBy=0): """ >>> txt = "123 567 90 123\\n456 89\\n" >>> print FillParagraph(txt,width=10) 123 567 90 123 456 89 >>> print FillParagraph(txt,width=10,indentLinesBy=3) 123 567 90 123 456 89 >>> txt = '123 567 \\n' >>> print FillParagraph...
bigcode/self-oss-instruct-sc2-concepts
def get_fbonds(graph, key): """Get all the possible forming bonds of a certain type Arguments: graph (nx.Graph): graph object of a molecule key (str): string representing the bond type to be examined Returns: list: list of bonds that can be made of this type """ possible_fb...
bigcode/self-oss-instruct-sc2-concepts
def _get_prop(title): """Get property name from plot title. Parameters: title (str): Plot title. Returns: str """ if 'vel' in title: return 'vel' elif 'sigma' in title: return 'sigma' else: return 'default'
bigcode/self-oss-instruct-sc2-concepts
def bind(instance, func, as_name=None): """ Bind the function *func* to *instance*, with either provided name *as_name* or the existing name of *func*. The provided *func* should accept the instance as the first argument, i.e. "self". """ if as_name is None: as_name = func.__name__ ...
bigcode/self-oss-instruct-sc2-concepts
def fill_in_particular_status(response, ids, template_to_fill, object="harvester"): """Replaces `template_to_fill` (e.g. `FULL_IDS`) in templated response to objects with given `ids` """ if len(ids) == 0: response = response.replace(f"{object} {template_to_fill} is", "none is") elif len(ids) == ...
bigcode/self-oss-instruct-sc2-concepts
def n_process(data, L, R): """ Apply panning gains based on chosen pan law. Params ------- data : ndarrary Input audio data. (samples, channels) currently only support max of 2 channels Returns ------- output_buffer : ndarray Panned input audio. (samples, channels) ...
bigcode/self-oss-instruct-sc2-concepts
def CollectionToResourceType(collection): """Converts a collection to a resource type: 'compute.disks' -> 'disks'.""" return collection.split('.', 1)[1]
bigcode/self-oss-instruct-sc2-concepts
def find_last_break(times, last_time, break_time): """Return the last index in times after which there is a gap >= break_time. If the last entry in times is further than signal_separation from last_time, that last index in times is returned. Returns -1 if no break exists anywhere in times. """ i...
bigcode/self-oss-instruct-sc2-concepts
import torch def inner_product(this, that, keepdim=True): """ Calculate the inner product of two tensors along the last dimension Inputs: this, that ...xD torch.tensors containing the vectors Outputs: result ... torch.tensor containing the inner products ...
bigcode/self-oss-instruct-sc2-concepts
def displayhtml (public_key): """Gets the HTML to display for reCAPTCHA public_key -- The public api key""" return """<script src='https://www.google.com/recaptcha/api.js'></script> <div class="g-recaptcha" data-sitekey="%(PublicKey)s"></div>""" % { 'PublicKey' : public_key }
bigcode/self-oss-instruct-sc2-concepts
def prod(xs): """Computes the product along the elements in an iterable. Returns 1 for empty iterable. Args: xs: Iterable containing numbers. Returns: Product along iterable. """ p = 1 for x in xs: p *= x return p
bigcode/self-oss-instruct-sc2-concepts
def root_url() -> str: """Root API route. No functions. Returns ------- str Error and message about API usage. """ return "Folder data microservice.\nWrong request. Use /api/meta/<folder> to get folder list."
bigcode/self-oss-instruct-sc2-concepts
def measureDistance(pointA, pointB): """ Determines the distance pointB - pointA :param pointA: dict Point A :param pointB: dict Point B :return: int Distance """ if (pointA['chromosome'] != pointB['chromosome']): distance = float('inf'); if ('position...
bigcode/self-oss-instruct-sc2-concepts
from typing import Union def maybe_int(string: str) -> Union[int, str]: """Try to cast string to int. Args: string: Input string. Returns: Maybe an int. Pass on input string otherwise. Example: >>> maybe_int('123') 123 >>> maybe_int(' 0x7b') 123 ...
bigcode/self-oss-instruct-sc2-concepts
def args_to_dict(args): """ Convert template tag args to dict Format {% suit_bc 1.5 'x' 1.6 'y' %} to { '1.5': 'x', '1.6': 'y' } """ return dict(zip(args[0::2], args[1::2]))
bigcode/self-oss-instruct-sc2-concepts
def get_image_frames(content_tree, namespaces): """find all draw frames that must be converted to draw:image """ xpath_expr = "//draw:frame[starts-with(@draw:name, 'py3o.image')]" return content_tree.xpath( xpath_expr, namespaces=namespaces )
bigcode/self-oss-instruct-sc2-concepts
def is_structure_line(line): """Returns True if line is a structure line""" return line.startswith('#=GC SS_cons ')
bigcode/self-oss-instruct-sc2-concepts
def _align_interval(interval): """ Flip inverted intervals so the lower number is first. """ (bound_one, bound_two) = interval return (min(bound_one, bound_two), max(bound_one, bound_two))
bigcode/self-oss-instruct-sc2-concepts
def graphql_custom_class_field(field_func): """Decorator that annotates a class exposing a field in GraphQL. The field appears in the GraphQL types for any of the class's subclasses that are annotated with graphql_object or graphql_interface. It is not useful to decorate a function with graphql_cu...
bigcode/self-oss-instruct-sc2-concepts
def select(ds, **selection): """ Returns a new dataset with each array indexed by tick labels along the specified dimension(s) Parameters ---------- ds : xarray Dataset A dataset to select from selection : dict A dict with keys matching dimensions and values given by scalars...
bigcode/self-oss-instruct-sc2-concepts
def vector_dot(vector1, vector2): """ Computes the dot-product of the input vectors. :param vector1: input vector 1 :type vector1: list, tuple :param vector2: input vector 2 :type vector2: list, tuple :return: result of the dot product :rtype: float """ try: if vector1 is No...
bigcode/self-oss-instruct-sc2-concepts
def accuracy_score(data): """ Given a set of (predictions, truth labels), return the accuracy of the predictions. :param data: [List[Tuple]] -- A list of predictions with truth labels :returns: [Float] -- Accuracy metric of the prediction data """ return 100 * sum([1 if p == t else 0 for p, ...
bigcode/self-oss-instruct-sc2-concepts
def prune_graph(adj_lists, relations): """The function is used to prune graph based on the relations that are present in the training Arguments: adj_lists {dict} -- dictionary containing the graph relations {set} -- list of relation ids Returns: dict -- pruned graph """ ...
bigcode/self-oss-instruct-sc2-concepts
def as_time(arg): """Defines the custom argument type TIME. Converts its input into an integer if it lacks a unit suffix, otherwise a float. Args: arg (str): A command line argument. Returns: Value of arg converted to a float (duration) or integer (integrations). Raises: ...
bigcode/self-oss-instruct-sc2-concepts