query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Initializing the matrix with empty spaces and 4 disks in the middle
def __init__(self, rows=8, cols=8): self.rows = rows self.cols = cols self.matrix = [[Disk.NONE for x in range(rows)] for y in range(cols)] init_array = (('d','4',Disk.LIGHT), ('e','5',Disk.LIGHT), ('d','5',Disk.DARK), ('e','4',Disk.DARK)) # init_array = (('a', '2', Disk.LIGHT), (...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_grid(grid):\r\n for i in range (4):\r\n grid.append ([])\r\n for j in range (4):\r\n grid[i].append (0)", "def setup(self, length):\n self.matrix = [None] * length\n for x in range(0,length):\n self.matrix[x] = [None] * length\n self.i = self...
[ "0.64748305", "0.6358961", "0.63243663", "0.63230354", "0.630076", "0.62858284", "0.6266029", "0.62325704", "0.6192642", "0.6134938", "0.61248815", "0.60938185", "0.60859346", "0.6036646", "0.60248256", "0.59950703", "0.59868973", "0.59673345", "0.5966538", "0.59619606", "0.5...
0.6944642
0
utitlity function which converts datetime object to string by using given format
def timestamp2str(datetime_obj, datetime_format): return datetime_obj.strftime(datetime_format)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def datetime_to_str(date, date_format=FORMAT_DATE):\n return date.strftime(date_format)", "def datetime_to_str(obj):\n return obj.strftime(\"%Y-%m-%d %H:%M:%S\")", "def datetime_to_str(obj):\n if not obj:\n return False\n return obj.strftime(DEFAULT_SERVER_DATETIME_FORMAT)", "def date2str(...
[ "0.774227", "0.75884473", "0.74928164", "0.7473095", "0.739007", "0.7299268", "0.7299268", "0.7295642", "0.7279088", "0.72779906", "0.7252911", "0.72221386", "0.72100514", "0.7144959", "0.7118181", "0.7088526", "0.7084137", "0.70834726", "0.70770425", "0.7042669", "0.70410705...
0.7968772
0
function to find out if the iterator values are strictly increasing
def is_increasing(values): return all([i <= j for i, j in zip(values, values[1:])])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def increasing(data):\n return (np.diff(data) > 0).all() == True", "def verify_increasing(seq):\n\n # https://stackoverflow.com/questions/24577688/compare-current-item-to-next-item-in-a-python-list\n\n for i, j in enumerate(seq[:-1]):\n if j >= seq[i + 1]:\n return False\n return Tr...
[ "0.7550674", "0.742065", "0.7380579", "0.7330071", "0.7295085", "0.69785655", "0.6967177", "0.69096357", "0.6828117", "0.6765246", "0.66230834", "0.65786606", "0.6456287", "0.64211696", "0.6420313", "0.63956785", "0.6387355", "0.63474953", "0.63260007", "0.630477", "0.6302267...
0.74788445
1
function to find out if the iterator values are strictly decreasing
def is_decreasing(values): return all([i >= j for i, j in zip(values, values[1:])])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_strictly_increasing(a):\n return np.all(np.diff(a) > 0)", "def is_increasing(values):\n\n return all([i <= j for i, j in zip(values, values[1:])])", "def is_monotonic_decreasing(self) -> bool:\n # monotonic decreasing if and only if reverse is monotonic increasing\n return self[::-1]...
[ "0.75458854", "0.72780436", "0.7247122", "0.72342974", "0.71599364", "0.7133871", "0.70926654", "0.7085752", "0.70222306", "0.6850934", "0.6847655", "0.68165034", "0.6760362", "0.67144686", "0.6692387", "0.6684923", "0.6496994", "0.64900136", "0.648634", "0.6305804", "0.61978...
0.78962004
0
Returns the z for which P(Z >= z) = probability
def normal_lower_bound(probability: float, mu: float = 0, sigma: float = 1) -> float: return inverse_normal_cdf(1 - probability, mu, sigma)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zprob(z):\r\n Z_MAX = 6.0 # maximum meaningful z-value\r\n if z == 0.0:\r\n x = 0.0\r\n else:\r\n y = 0.5 * math.fabs(z)\r\n if y >= (Z_MAX*0.5):\r\n x = 1.0\r\n elif (y < 1.0):\r\n w = y*y\r\n x = ((((((((0.000124818987 * w\r\n ...
[ "0.7842882", "0.75300777", "0.7506635", "0.73198897", "0.678861", "0.6602982", "0.64032084", "0.6326456", "0.6299229", "0.62925357", "0.6259421", "0.6219085", "0.6216597", "0.6143424", "0.6125308", "0.60966885", "0.6074466", "0.6065904", "0.6032191", "0.59980464", "0.5996478"...
0.0
-1
Test successful and failed container spawns
def test_spawn(self): # We can pass bogus parameters since they are only actually used by # MachineWrapper, which is mocked. job_args = { 'job_dir': "/jobs/2020", 'job_type': "", 'job_parameters': "", 'timeout': 0} # I/O errors during dire...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test001_create_containers(self):\n self.log('%s STARTED' % self._testID)\n\n self.log('Create a two container on that node, should succeed.')\n self.cont1_name = self.random_string()\n self.containers = {self.cont1_name: {'hostname': self.cont1_name,\n ...
[ "0.7310803", "0.7193672", "0.7153792", "0.6946781", "0.68586415", "0.67054707", "0.66968685", "0.6683956", "0.65811104", "0.6398159", "0.63944906", "0.63114107", "0.6302709", "0.62845296", "0.62816197", "0.62734425", "0.62709486", "0.6251736", "0.62441754", "0.6203492", "0.62...
0.6690945
7
Return True if N is prime number. >>> is_prime(7) True >>> is_prime(10) False >>> is_prime(1) False
def is_prime(n): def prime_helper(index): if index == n: return True elif n % index == 0 or n == 1: return False else: return prime_helper(index + 1) return prime_helper(2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isprime(n):\r\n\treturn is_prime(n)", "def isprime(n):\n\treturn is_prime(n)", "def is_prime(n):\n return mr_prime(n)", "def if_prime(cls, n):\n\n if (n <= 1):\n return False\n if (n <= 3):\n return True\n\n if (n % 2 == 0 or n % 3 == 0):\n return ...
[ "0.85019106", "0.8492053", "0.82565874", "0.8243938", "0.8200872", "0.81477684", "0.81238955", "0.810259", "0.8102104", "0.809813", "0.80880064", "0.8062325", "0.80484855", "0.8036164", "0.8013056", "0.79856193", "0.79842776", "0.79748416", "0.7970765", "0.7969587", "0.796861...
0.7573713
66
A hole number is a number in which every other digit dips below the digits immediately adjacent to it. >>> check_hole_number(123) False >>> check_hole_number(3241968) True >>> check_hole_number(3245968) False
def check_hole_number(n): if n // 10 == 0: return True # The \ symbol just allows me to continue this line of code on a new line. # It's only included to make sure all the code stays on the page return ((n // 10) % 10) < (n % 10) and ((n // 10) % 10) < ((n // 100) % 10) \ and check_h...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_number(self):\n digits = self.number\n _sum = 0\n alt = False\n ix = []\n for x in str(digits):\n ix.append(int(x))\n for d in reversed(ix):\n assert 0 <= d <= 9\n if alt:\n d *= 2\n if d > 9:\n ...
[ "0.66089475", "0.6524737", "0.6501561", "0.6289364", "0.6287634", "0.62772197", "0.6240159", "0.61689353", "0.61232096", "0.60461533", "0.6029135", "0.5990273", "0.59401137", "0.57957417", "0.57953656", "0.57865435", "0.5781659", "0.5775289", "0.5756116", "0.57402855", "0.570...
0.81741446
0
Generates sample Data frame with IDs, Timestamps and Values. For example see doctest file.
def generate_sample_triplet_df(self, data_type: str, max_int: int = 100, id_list: Optional[List[int]] = None) -> DataFrame: if id_list is None: self._set_seed() id_list = [random.randint(1, 5) for i in range(100)] df_triplet = pd.DataFram...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_test(self):\n count = 500\n dates = []\n value = []\n now = datetime.datetime.now()\n # print(now)\n for i in range(count):\n some_date = now - datetime.timedelta(\n days=randrange(30),\n hour...
[ "0.7315561", "0.687136", "0.65831095", "0.63964635", "0.6392277", "0.6379468", "0.63008595", "0.6298811", "0.62672", "0.61975276", "0.61879694", "0.61879694", "0.61844665", "0.61438197", "0.6103917", "0.60850954", "0.6079151", "0.60590446", "0.60191536", "0.60087585", "0.6002...
0.63883775
5
Construct Note from dct.
def from_dict(cls, dct): if dct.pop('type') != cls.__name__: fmt = 'Can not construct Note from dict %s' raise ValueError(fmt % dct) return cls(**dct)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_dict(cls, dct):\n pass", "def from_dict(cls, note_dict):\n\n missing_properties = set(cls.SERIALIZED_ATTRIBUTE_TYPES.keys()) - set(note_dict.keys())\n if len(missing_properties) > 0:\n raise MissingProperties(\"Some required properties are missing: {}\".format(missing_pro...
[ "0.62324816", "0.5825756", "0.5774063", "0.5663643", "0.5614052", "0.55089915", "0.5474682", "0.5443261", "0.5397188", "0.5305946", "0.52507657", "0.5241753", "0.52146935", "0.5207193", "0.51884204", "0.5182707", "0.5166838", "0.5165633", "0.5133356", "0.51174647", "0.5113889...
0.7634096
0
Construct Note from JSON string.
def from_json(cls, string): dct = json.loads(string) return cls.from_dict(dct)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_json_str(cls, json_str):\n return cls.from_json(simplejson.loads(json_str))", "def from_json_string(my_str):\n rep = json.loads(my_str)\n return rep", "def _build_data_from_text(self, text):\n try:\n record = json.loads(text)\n except Exception as e:\n logg...
[ "0.6801496", "0.6657323", "0.6346291", "0.63246197", "0.63137436", "0.6251102", "0.62326396", "0.62253714", "0.6223952", "0.62132555", "0.6209065", "0.6195011", "0.6195011", "0.6191375", "0.6179499", "0.6179499", "0.6179499", "0.61794966", "0.6161784", "0.6157292", "0.6157292...
0.683505
0
Serialize as JSON string.
def to_json(self): return json.dumps(self.to_dict())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def asJsonString(self):\n return json.dumps(self.asDict(), sort_keys=True)", "def toJSONString(self):\n JSONObject = self.toDict()\n\n return json.dumps(JSONObject, ensure_ascii=False)", "def to_json(self) -> str:\n return json.dumps(self.to_dict())", "def to_json(self) -> str:\n ...
[ "0.82893336", "0.8268846", "0.8192226", "0.8192226", "0.8192226", "0.8192226", "0.8192226", "0.8192226", "0.8192226", "0.8192226", "0.8192226", "0.8183975", "0.8171755", "0.8154721", "0.8148741", "0.8131409", "0.8111274", "0.80836797", "0.80651903", "0.8052366", "0.8039835", ...
0.7798914
62
Return a project's localconfig contents (or default if missing).
def getlocalconfig(projroot: Path) -> Dict[str, Any]: localconfig: Dict[str, Any] try: with open(Path(projroot, 'config/localconfig.json')) as infile: localconfig = json.loads(infile.read()) except FileNotFoundError: localconfig = {} return localconfig
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_project_config():\n if get_project_config.CONFIG is None:\n import json\n with open('project.json') as fp:\n get_project_config.CONFIG = json.load(fp)\n return get_project_config.CONFIG", "def get_project_config(project_path, use_cache=True):\n\n return get_local_config(...
[ "0.70170414", "0.6907102", "0.69056165", "0.68427473", "0.65916365", "0.6476708", "0.6332859", "0.6320358", "0.63101274", "0.6295776", "0.6251484", "0.62400305", "0.62280333", "0.6227188", "0.6201059", "0.61987144", "0.60728556", "0.6068038", "0.6026095", "0.5989678", "0.5964...
0.7654283
0
Utility to recursively delete keys with no value.
def del_none(d): for key, value in list(d.items()): if value is None or value == "": del d[key] elif isinstance(value, dict): del_none(value) return d
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_empty(d):\n for key in d.keys():\n if d[key] is None:\n del d[key]\n return d", "def delete_none(dict_):\n if isinstance(dict_, dict):\n for key, value in list(dict_.items()):\n if isinstance(value, dict):\n delete_none(value)\n el...
[ "0.74256355", "0.7168771", "0.7042284", "0.70100415", "0.68680394", "0.68507105", "0.6827919", "0.6616483", "0.655199", "0.64822036", "0.6479535", "0.64350367", "0.6399073", "0.63745147", "0.63300365", "0.6262614", "0.62390226", "0.6160876", "0.6158151", "0.6118191", "0.60781...
0.6968649
4
r"""Creates a fullyconnected (ReLU by default) layer with
def fc_layer(in_tensor, in_dim, out_dim, sigmoid=tf.nn.relu, name=None): with tf.name_scope(name): initial_weights = tf.truncated_normal((in_dim, out_dim), stddev=0.1) weights = tf.Variable(initial_weights, name='weights') initial_biases = tf.constant(0.0, shape=[out_dim], dtype=tf.float32)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fully_connected_relu(input, size):\n return tf.nn.relu(fully_connected(input, size))", "def make_fully_connected_layer(input_layer,\n layer_size,\n activation=tf.nn.relu,\n layer_name='',\n ...
[ "0.72926354", "0.67506754", "0.67497474", "0.66754407", "0.66752756", "0.65914243", "0.6540724", "0.6511563", "0.6476631", "0.64698637", "0.6435268", "0.63652444", "0.6349807", "0.63429374", "0.6271413", "0.62618846", "0.62441677", "0.62283623", "0.6225963", "0.6219159", "0.6...
0.57921433
80
Takes in a list of images and returns softmax probabilities.
def get_output(self, images, auto_resize=True): if auto_resize: images_ = [imresize(im, (224, 224)) for im in images] else: images_ = images feed_dict = {self.input_images: images_} return sess.run(vgg.output, feed_dict)[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def softmax(inputs):\n probs = np.exp(inputs)\n # print(probs.shape)\n # t = np.sum(probs, axis=0)\n # print(t.shape)\n\n probs /= np.sum(probs, axis=0)[np.newaxis,:]\n return probs", "def softmax(inputs):\n return np.exp(inputs) / float(sum(np.exp(inputs)))", "def softmax(inputs):\n re...
[ "0.72290164", "0.69299406", "0.69299406", "0.685859", "0.6712751", "0.67075914", "0.66937083", "0.6678799", "0.6661235", "0.66478896", "0.6638762", "0.6592364", "0.6569064", "0.65556556", "0.65505946", "0.6539283", "0.6539103", "0.65384495", "0.6513558", "0.64980525", "0.6497...
0.0
-1
Generate a random string of fixed length
def random_string(stringLength=10): letters = string.ascii_lowercase return ''.join(choice(letters) for i in range(stringLength))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))", "def generate_random_string(length=6):\n n = int(length / 2 + 1)\n x = binascii.hexlify(os.urandom(n))\n s = x[:length]\n return s.decode(\"utf-8\")",...
[ "0.8680464", "0.8573714", "0.85486245", "0.85297275", "0.85209286", "0.84331024", "0.8432044", "0.84157014", "0.84120053", "0.8389201", "0.8345882", "0.8343962", "0.83406156", "0.83348686", "0.83240855", "0.82986933", "0.82911193", "0.8281826", "0.82818025", "0.82811046", "0....
0.79591393
53
Overlay the individual fibers within an IFU on a plot.
def overlay_fibers(self, ax, diameter=None, skies=None, return_figure=True, **kwargs): if self.wcs is None: raise MarvinError('No WCS found. Cannot overlay fibers.') # check the diameter if diameter: assert isinstance(diameter, (float, int)), 'diameter must be a number...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fiPlot(rf):\n\tfi = rf.feature_importances_\n\tprint(len(fi))\n\tfi = 100* (fi/fi.max())\n\tsorted_idx = np.argsort(fi)\n\tpos = np.arange(len(fi))\n\tprint(pos)\n\tplt.figure()\n\tplt.barh(pos,fi[sorted_idx],align='center')\n\tplt.savefig('featureImporances.png')", "def fdplot(self, imx):\n fig = plt...
[ "0.6331801", "0.5841936", "0.58298343", "0.5817217", "0.58132106", "0.5781872", "0.5672604", "0.56334144", "0.56060505", "0.55776566", "0.5554674", "0.55494976", "0.55289525", "0.55170166", "0.55066127", "0.5495125", "0.54643756", "0.5442674", "0.5439164", "0.54361653", "0.54...
0.54800206
16
Overlay the sky fibers on a plot
def overlay_skies(self, ax, diameter=None, return_figure=True, **kwargs): if self.wcs is None: raise MarvinError('No WCS found. Cannot overlay sky fibers.') # check for sky coordinates if self.bundle.skies is None: self.bundle.get_sky_coordinates() # check the...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot(self):\n\t\tself.plotOfHeatingCurrent().plot()", "def plotCombinedIncludingOceanFloors(self):\n self.CombinedPlotHelper(minc=70,maxc=170,num=50)", "def plot(self):\n self.fig = plt.figure('black hole')\n self.fig.clf() #clear the graph to avoir superposing data from the same set (...
[ "0.65283877", "0.64167815", "0.64050853", "0.63602334", "0.6350044", "0.62508094", "0.6211702", "0.6174098", "0.6173661", "0.6167938", "0.6144616", "0.61092955", "0.6090199", "0.60846317", "0.60665613", "0.6061195", "0.60602343", "0.60559255", "0.6053103", "0.6047373", "0.604...
0.6217057
6
Instantiate NOV class with test values. The additional parameters can be passed to test NOV under different carbon conditions.
def instantiate_nov(cls, target_year, carbon_tax, fuel_co2_content, carbon_capture_rate, consider_leap_year): return NetOperationalValue(discount_rate=cls.DISCOUNT_RATE, lifetime=cls.LIFETIME, unit_size=cls.UNIT_SIZE, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_test_instance(cls, **kwargs):\n # create a instance with random parameters\n obj = super(LibraryBinaryNumeric, cls).create_test_instance(**kwargs)\n # choose an optimal interaction matrix\n obj.choose_sensitivity_matrix('auto')\n return obj", "def test_init_custom_pa...
[ "0.63493186", "0.6026954", "0.59564155", "0.588115", "0.5875367", "0.58316797", "0.5806599", "0.578889", "0.5755929", "0.57557577", "0.57468635", "0.57283837", "0.5688957", "0.56883466", "0.56550163", "0.5638191", "0.5634541", "0.56184834", "0.5611818", "0.5609465", "0.560147...
0.6004321
2
Text representation of the RateLimitedIP object.
def display_name(self, obj): return six.text_type(obj)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self) :\n if not self.parsed :\n return \"\"\n mybuffer = []\n mybuffer.append(\"IPP version : %s.%s\" % self.version)\n mybuffer.append(\"IPP operation Id : 0x%04x\" % self.operation_id)\n mybuffer.append(\"IPP request Id : 0x%08x\" % self.request_id)\n ...
[ "0.6826606", "0.6542127", "0.6510034", "0.63695925", "0.625228", "0.6201073", "0.619602", "0.6191498", "0.61246216", "0.6117054", "0.6117054", "0.6117054", "0.6117054", "0.6117054", "0.6117054", "0.6117054", "0.6117054", "0.6117054", "0.6117054", "0.6117054", "0.6117054", "...
0.0
-1
Loads the MPEG7 Shape dataset, containing 1400 images of 70 classes (20 images per class). Returns
def load_mpeg7(): # List of image file names dataset_directory = os.path.join(root_directory,'MPEG7') filenames = os.listdir(dataset_directory) filenames.sort() # List of numpy array; each row is a Image of the dataset data = [] # Numpy array of labels associated to each class of image ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_shapes(self,count,img_folder,mask_folder,imglist,dataset_root_path):\n self.add_class(\"shapes\",1,\"red_s\")\n self.add_class(\"shapes\",2,\"red_m\")\n self.add_class(\"shapes\",3,\"red_l\")\n self.add_class(\"shapes\",4,\"yellow_s\")\n self.add_class(\"shapes\",5,\"yel...
[ "0.6238543", "0.60697573", "0.60312223", "0.60145223", "0.594461", "0.59373033", "0.5933787", "0.58944863", "0.5872117", "0.5820331", "0.577066", "0.5760281", "0.57535404", "0.575338", "0.57426155", "0.5738027", "0.5737724", "0.57094383", "0.5707139", "0.5698266", "0.56765753...
0.7233063
0
Parse attribute list and return a list of attribute tuples.
def get_attrs(str): return _scanner.scan(str)[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_attributes(root):\n output_list = []\n for _, value in enumerate(root[0][2]):\n attr = Attribute(value)\n output_list.append(attr)\n return output_list", "def parse_attrs(buf):\r\n attrs = []\r\n while buf:\r\n t = ord(buf[0])\r\n l = ord(b...
[ "0.67604405", "0.66291606", "0.6610874", "0.652041", "0.6257682", "0.62263906", "0.61935157", "0.61172664", "0.6112285", "0.61068577", "0.6081897", "0.6030436", "0.60205835", "0.60033137", "0.5950777", "0.5943913", "0.593525", "0.59156185", "0.5847191", "0.58143216", "0.58031...
0.5172441
64
Six months before September should be March
def test_september_minus_six(self): month, year = get_month_from_offset(9, 2000, -6) self.assertEqual(month,3) self.assertEqual(year,2000)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_march_minus_six(self):\n month, year = get_month_from_offset(3, 2000, -6)\n self.assertEqual(month, 9)\n self.assertEqual(year, 1999)", "def test_march_plus_six(self):\n month, year = get_month_from_offset(3, 2000, 6)\n self.assertEqual(month, 9)\n self.assertEq...
[ "0.7512543", "0.7421695", "0.73840296", "0.66225696", "0.66225696", "0.6583417", "0.64840406", "0.6358635", "0.63089365", "0.63039184", "0.6261856", "0.6220307", "0.6168135", "0.6108113", "0.61015356", "0.60928607", "0.6042373", "0.59938365", "0.59928393", "0.5985336", "0.598...
0.74320894
1
Return the value that the user entered. After a valid value has been entered, and OK button pushed (or enter pressed), this method may be used to retrieve the value. Returns ``None`` in all other situations.
def GetValue(self): if self.__cancelled: return None else: return self.__value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_value(self):\r\n return input(\"Enter your choice :\")", "def value(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"value\")", "def value(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"value\")", "def value(self) -> Optional[pulumi.Input[str]]...
[ "0.75344014", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.70560366", "0.6802181",...
0.63783395
53
Called when the Ok button is pushed. The entered value is stored and the dialog is closed. The value may be retrieved via the
def __onOk(self, ev): self.__value = self.__spinCtrl.GetValue() if self.IsModal(): self.EndModal(wx.ID_OK) else: self.SetReturnCode(wx.ID_OK) self.Close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def okButton(self):\n \n s = self.number_entry.get().strip()\n \n try:\n self.answer=int(s)\n except:\n self.answer=-1 # Cancel the operation.\n \n self.top.destroy()", "def cb_ok(self):\n debug(\"in ok\")\n self.values = {}\n for en...
[ "0.74385154", "0.7001327", "0.67999", "0.67887443", "0.6726846", "0.67087746", "0.6690613", "0.6593956", "0.65083736", "0.64723635", "0.64355904", "0.64278936", "0.63801193", "0.61930543", "0.61930543", "0.6182514", "0.61489725", "0.61373425", "0.61329293", "0.6093706", "0.60...
0.71695644
1
Tests generic entity update service.
async def test_camera_generic_update( hass: HomeAssistant, mock_entry: MockEntityFixture, camera: tuple[ProtectCamera, str], ): assert await async_setup_component(hass, "homeassistant", {}) state = hass.states.get(camera[1]) assert state and state.state == "idle" mock_entry.api.update = A...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_otoroshi_controllers_adminapi_tcp_service_api_controller_update_entity_action(self):\n pass", "def test_update(self):\n pass", "def test_update(self):\n pass", "def test_update(self):\n pass", "def test_update_case(self):\n pass", "def test_otoroshi_controllers...
[ "0.78955746", "0.74771196", "0.74771196", "0.74771196", "0.73415947", "0.7259309", "0.7237386", "0.72158635", "0.70355064", "0.6952744", "0.690349", "0.6883567", "0.68404555", "0.6800107", "0.67964864", "0.67232513", "0.66835916", "0.6668856", "0.66458815", "0.660955", "0.659...
0.0
-1
View for getting all products
def get_all_products(request, *args, query_str=''): active_filters = [] products = Product.objects.all() product_fields = ( ("size", "options"), ("price", "range"), ("colours", "options"), ("year", "range"), ("collection", "equals") ) field_ranges = [] fo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_products(request):\n products = Product.objects.all()\n return render(request, \"products.html\", {\"products\": products})", "def all_products(request):\n\n products = Product.objects.all()\n return render(request, 'products.html', {'products': products})", "def products(request):\n\n r...
[ "0.85889775", "0.8584514", "0.80839807", "0.8077228", "0.787021", "0.77327776", "0.768992", "0.7624601", "0.76196074", "0.76125556", "0.7586354", "0.7580423", "0.7580109", "0.7515487", "0.75078064", "0.73868835", "0.7373729", "0.73090434", "0.72592443", "0.72338676", "0.72303...
0.0
-1
View for getting specific product
def get_product(request, product_pk): product = get_object_or_404(Product, pk=product_pk) context = { 'product': product, 'MEDIA_URL': settings.MEDIA_URL } return render(request, 'products/single_product.html', context)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def product_view(request, product):\n product = Products.objects.get(product=product)\n\n context = {\n \"product\": product,\n }\n\n return render(request, \"products/product_detail.html\", context)", "def product_detail(request, product_id):\n # Search for product in Product Model using p...
[ "0.8373205", "0.7817594", "0.76996857", "0.76296955", "0.7609186", "0.74996454", "0.73481274", "0.73322934", "0.72361946", "0.7232319", "0.72304326", "0.7212379", "0.71471024", "0.7089532", "0.70353025", "0.70193565", "0.70091385", "0.70040834", "0.6959846", "0.69372743", "0....
0.78225577
1
API keys can't be forgotten. This could deauthorize the API key, but there probably isn't any utility in giving API keys a way to deauthorize themselves. Anyway, returns no headers.
def forget(self, request): return []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deauthorize():\n\tPAYLOAD_HEADERS.pop('Authorization', None)", "def test_authorization_header_not_present(self, get_key_secret):\r\n request = Request(self.environ)\r\n request.body = self.get_request_body()\r\n response = self.xmodule.grade_handler(request, '')\r\n real_response ...
[ "0.6803548", "0.65408015", "0.6535182", "0.6461532", "0.6452847", "0.6445998", "0.640515", "0.6388619", "0.6388471", "0.63728386", "0.6372567", "0.6298591", "0.6297153", "0.6248177", "0.6215019", "0.6143284", "0.612622", "0.6100605", "0.60865784", "0.6069149", "0.60669965", ...
0.0
-1
API keys can't be forgotten. This could deauthorize the bearer token, but there probably isn't any utility in giving bearer tokens a way to deauthorize themselves. Anyway, returns no headers.
def forget(self, request): return []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deauthorize():\n\tPAYLOAD_HEADERS.pop('Authorization', None)", "def forget(self, request):\n return [('WWW-Authenticate', 'Bearer realm=\"%s\"' % self.realm)]", "def test_authorization_header_not_present(self, get_key_secret):\r\n request = Request(self.environ)\r\n request.body = self...
[ "0.6942778", "0.6841196", "0.6626936", "0.6558509", "0.6550465", "0.6452305", "0.64482224", "0.6423576", "0.6401126", "0.6384306", "0.6382608", "0.6358418", "0.6335653", "0.632815", "0.6316709", "0.624477", "0.62446594", "0.6240657", "0.62227833", "0.6205216", "0.6193267", ...
0.0
-1
Test create_app without passing test config.
def test_fail_token(client, request): res = client.get('/token?uid=1') assert res.status_code == 400 assert 'User does not exist' in res.data.decode('utf-8')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_app():\n assert not create_app().testing\n assert create_app({'TESTING': True}).testing", "def test_config():\n assert not sample.create_app().testing\n assert sample.create_app({\"TESTING\": True}).testing", "def test_config():\n assert not create_app().testing\n assert creat...
[ "0.8850087", "0.813269", "0.8125104", "0.8035616", "0.80110157", "0.7688096", "0.7623751", "0.7605146", "0.7599213", "0.7562456", "0.7501943", "0.735687", "0.73023415", "0.7252003", "0.72149676", "0.71856964", "0.7180324", "0.7176667", "0.7162609", "0.7160988", "0.7152597", ...
0.0
-1
Test create_app without passing test config.
def test_get_token(client, request): res = client.get('/token?uid={}'.format(settings.FIREBASE_UID)) assert res.status_code == 200 assert len(res.data) > 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_app():\n assert not create_app().testing\n assert create_app({'TESTING': True}).testing", "def test_config():\n assert not sample.create_app().testing\n assert sample.create_app({\"TESTING\": True}).testing", "def test_config():\n assert not create_app().testing\n assert creat...
[ "0.8850087", "0.813269", "0.8125104", "0.8035616", "0.80110157", "0.7688096", "0.7623751", "0.7605146", "0.7599213", "0.7562456", "0.7501943", "0.735687", "0.73023415", "0.7252003", "0.72149676", "0.71856964", "0.7180324", "0.7176667", "0.7162609", "0.7160988", "0.7152597", ...
0.0
-1
Return slice of df containing all rows with df[date_col].dt.year >= first_year. Returns df if first_year is None.
def year_slice(df, first_year=None, date_col='start_date'): if first_year is None: return df if first_year <= df[date_col].min().year: # No need to slice return df return df[df[date_col] >= f"{first_year}-01-01"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def year_slice(df, first_year = None, date_col = 'start_date'):\n if first_year is None:\n return df\n years = df[date_col].dt.year\n if first_year <= years.min():\n # No need to slice\n return df\n return df[years >= first_year]", "def date_filter(frame, date_column, year):\n ...
[ "0.8692967", "0.6916101", "0.6475987", "0.6318579", "0.6097049", "0.59132314", "0.5876796", "0.5793554", "0.5776828", "0.56945443", "0.5652291", "0.5467824", "0.54667866", "0.54383206", "0.540031", "0.539278", "0.5352745", "0.53379816", "0.5273453", "0.5232996", "0.5201749", ...
0.870499
0
Load forecast data from file and returns as a dataframe.
def load_forecast_from_file(file_name, mask_df=None): # Load forecast dataframe forecast = pd.read_hdf(file_name) # PY37 if 'start_date' in forecast.columns: forecast.start_date = pd.to_datetime(forecast.start_date) if 'target_date' in forecast.columns: forecast.target_date ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_data(fpath: str, station: Dict[str, Any]) -> pd.DataFrame:\n df = pd.read_csv(\n fpath,\n skiprows=station['header_line_num']-1,\n usecols=['date', 'rain'],\n )\n\n # format the date from a string to a proper datetime object\n df['date'] = pd.to_datetime(df['date'])\n\n ...
[ "0.72931594", "0.71401757", "0.7119044", "0.6954168", "0.68516535", "0.68484163", "0.6710672", "0.6687381", "0.6608117", "0.6607454", "0.6607454", "0.6607454", "0.6549507", "0.65311193", "0.651707", "0.6504314", "0.65013427", "0.6475853", "0.6474795", "0.64581454", "0.6438564...
0.69432443
4
Return the config. Use this method to get the bot config
def get_config(self) -> Dict[str, Any]: if self.config is None: self.config = self.load_config() return self.config
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def config(self):\n if self.__config is None:\n self.__config = self._get_config(self.bot)\n return self.__config", "def get_config(self):\n return self.config", "def getConfig(self):\n \n return self.config", "def get_config():\n return CONFIG", "def config...
[ "0.8794691", "0.8260136", "0.80892885", "0.7926577", "0.79057753", "0.78236943", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", "0.7821813", ...
0.79455966
3
Importing letter of alphabet 'abcdefghijklmnopqrstuvwxyz'
def get_available_letters(): available = string.ascii_lowercase return available
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_alphabet(number):\n return chr(number + 96)", "def get_alphabet(number):\n return chr(number + 96)", "def letter_code(letter):\n value = ord(letter.lower()) - ord('a') + 10\n return value + value // 11", "def next_letter(letter):\r\n\tcoded_text = ''\r\n\tstep = 1\r\n\tif letter in ascii_...
[ "0.6978001", "0.6978001", "0.6896066", "0.67410505", "0.66355014", "0.6502094", "0.64975846", "0.64975846", "0.648248", "0.64425176", "0.6426691", "0.6404602", "0.63999647", "0.6371025", "0.6351236", "0.6351236", "0.6351236", "0.6312614", "0.6283822", "0.6275287", "0.62707174...
0.62079656
24
Given a date, return the nearest business day that could be a potential payday.
def get_nearest_business_day(date: date_class, holidays: list) -> date_class: while date in holidays: num_of_days_after_holiday = 1 week_day_placeholder = (date + timedelta(days=num_of_days_after_holiday)).weekday() while week_day_placeholder in {5,6}: num_of_days_after_holi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_nearest_payday(\n date: date_class,\n frequency: timedelta,\n holidays: list,\n given_payday: date_class,\n default_payday: WeekNamePlaceholder) -> date_class:\n _payday = given_payday\n \n if date < given_payday: # Go Backward\n # change frequency to...
[ "0.72994125", "0.66964525", "0.6624541", "0.62566423", "0.6221044", "0.61572963", "0.59895384", "0.5964122", "0.5822103", "0.57903045", "0.5770065", "0.5733709", "0.55682606", "0.55450153", "0.5544446", "0.5538581", "0.5505692", "0.5485728", "0.54665524", "0.5438866", "0.5437...
0.7196114
1
Read a text file and parse it, return a list of lines.
def readfile(input_file): lines = [] with open(input_file, 'r') as file: for line in file: lines.append(line.rstrip()) return lines
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(filename):\n with open(filename) as file:\n lines = [line.strip() for line in file]\n return lines", "def _get_lines_from_file(path: str) -> List[str]:\n if os.path.isfile(path):\n with open(path, 'r') as f:\n lines = f.readlines()\n else:\n raise InputError(...
[ "0.7932721", "0.79067385", "0.7891527", "0.7867271", "0.7822065", "0.77384955", "0.773432", "0.77172756", "0.76860225", "0.766936", "0.7649198", "0.76408565", "0.76102936", "0.75584584", "0.75584584", "0.75020856", "0.74872154", "0.74838406", "0.7434301", "0.743358", "0.74242...
0.74622184
18
Read and preprocess an image with data augmentation (random transform).
def read_for_training(p): return read_cropped_image_npy(p, True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_for_training(p, augmentation=False):\n img = imread(TRAIN + p, mode='RGB')\n msk = img\n\n if mode == 'background':\n data = {'image': img}\n elif mode == 'instance' or mode == 'code':\n msk = imread(TRAIN_MASK + p.replace('.jpg', '.png'))\n data = {'image': img, 'mask': m...
[ "0.70983887", "0.6943158", "0.688551", "0.68004996", "0.674634", "0.67293", "0.669832", "0.66739017", "0.6640704", "0.66043407", "0.65809053", "0.657818", "0.65741193", "0.65732604", "0.6542803", "0.6535964", "0.65216327", "0.64716566", "0.6438178", "0.64301634", "0.64249456"...
0.5977028
84
Read and preprocess an image without data augmentation (use for testing).
def read_for_validation(p): return read_cropped_image_npy(p, False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess(self, img):\n img_ = image.load_img(img, target_size=(299, 299))\n img_ = image.img_to_array(img_)\n img_ = np.expand_dims(img_, axis=0)\n img_ = preprocess_input(img_)\n return img_", "def _preprocess_image(self, image_raw):\n\n image = tf.io.decode_raw(i...
[ "0.7602969", "0.7248016", "0.722284", "0.71843404", "0.7184335", "0.71565145", "0.71435726", "0.7083108", "0.707574", "0.7067366", "0.7060635", "0.6975651", "0.6953753", "0.6905524", "0.69026303", "0.6898259", "0.68915087", "0.68718076", "0.68572867", "0.6855969", "0.68412083...
0.6213208
99
First scale the data using StandardScaler if scaled == False
def neural_network(xtrain, ytrain, xtest, ytest,labels_mapping, scaled = False): if not scaled : scaler = StandardScaler() xtrain = scaler.fit_transform(xtrain) xtest = scaler.transform(xtest) nn = MLPClassifier() #hidden_layer_sizes=30, alpha=0.0001, early_stopping=True nn = __trai...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def standardiser(self):\n # Select only numeric features first\n\n #self.X = self.data.loc[:, self.data.columns != self.target].values\n numeric_columns = []\n for col in self.X.columns:\n if self.X[col].dtype!='object':\n numeric_columns.append(col)\n s...
[ "0.7218791", "0.7191713", "0.70394105", "0.6975558", "0.6961362", "0.6930918", "0.69271106", "0.68575054", "0.6831504", "0.68284446", "0.6819331", "0.6818507", "0.67920756", "0.6757513", "0.67507", "0.6730819", "0.67110133", "0.67094827", "0.6705719", "0.66934055", "0.6671914...
0.0
-1
First scale the data using StandardScaler if not scaled and maybe resample
def svm(xtrain, ytrain, xtest, ytest,labels_mapping, scaled = False): if not scaled : scaler = StandardScaler() xtrain = scaler.fit_transform(xtrain) xtest = scaler.transform(xtest) svm = SVC(C=10, cache_size=1500, class_weight='balanced') svm = __train_and_test(svm, xtrain, ytrain,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rescale(self):\n # forecast on real data, don't need this anymore\n pass", "def resample(self):\n pass", "def standardize(X):\n\n scaler = StandardScaler()\n X_scaled = scaler.fit_transform(X)\n return X_scaled", "def test_scaler():\n raw = io.read_raw_fif(raw_fname)\n ...
[ "0.7301517", "0.6632437", "0.6613051", "0.6595125", "0.6588132", "0.6546846", "0.65277237", "0.6515841", "0.651", "0.6504241", "0.6502828", "0.64754426", "0.6463376", "0.6435751", "0.6428781", "0.64133346", "0.6412797", "0.63972056", "0.6386845", "0.63795465", "0.6376913", ...
0.0
-1
Clip all gradients at this point in time. The norm is computed over all gradients together, as if they were concatenated into a single vector. Gradients are modified inplace.
def clip_grad_norm_( self, max_norm: Union[float, int], norm_type: Union[float, int] = 2.0, groups: Optional[List[List[int]]] = None, ) -> torch.Tensor: assert self._is_root, "clip_grad_norm should only be called on the root (parent) instance" self.assert_state(TrainingState.IDLE) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clip_grads(self): # Clipping gradients for stability\n parameters = list(filter(lambda p: p.grad is not None, self.machine.parameters()))\n for p in parameters:\n p.grad.data.clamp_(-10, 10)", "def clip_gradient(model, clip_norm):\n totalnorm = 0\n for p in model.paramete...
[ "0.7234078", "0.70931065", "0.7087318", "0.7041712", "0.6994368", "0.69793355", "0.6918789", "0.689754", "0.68667644", "0.6675523", "0.6618761", "0.66097236", "0.6588387", "0.65814036", "0.6564941", "0.6551267", "0.6439358", "0.63258845", "0.63132817", "0.62862694", "0.627521...
0.63820463
17
Return the local shard of a full tensor.
def _get_shard(self, tensor: torch.Tensor) -> Tuple[torch.Tensor, int]: tensor = self._flatten_and_pad_to_world_size( tensor, self.world_size * self._shard_size_multiple) local_size = tensor.size(0) // self.world_size begin, end = self.rank * local_size, (self.rank + 1) * local_size tensor = ten...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shard(self):\n return self._shard", "def shard_tensor(x, process_mesh=None, shard_spec=None):\n\n if process_mesh is not None:\n assert isinstance(\n process_mesh, ProcessMesh\n ), \"Argument process_mesh {} is not an instance of ProcessMesh\".format(\n process_m...
[ "0.6099813", "0.5874232", "0.58428824", "0.58428824", "0.56802654", "0.5587651", "0.55354303", "0.53458536", "0.53412724", "0.53174275", "0.52987903", "0.52757055", "0.52561295", "0.5252544", "0.52365756", "0.52323824", "0.5217135", "0.5161181", "0.515733", "0.51558495", "0.5...
0.77070284
0
A context manager to disable gradient synchronizations across FSDP processes. Within this context, gradients will be accumulated on module variables, which will later be synchronized in the first forwardbackward pass after exiting the context.
def no_sync(self) -> Generator: self._lazy_init() assert self._is_root, "no_sync on inner FSDP is not supported" self.assert_state(TrainingState.IDLE) # This instance may wrap other FSDP instances and we # need to set all of them to accumulate gradients. old_flags = [] for m in self.modules(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _finalize_params(fsdp_module: FullyShardedDataParallel) -> None:\n for handle in fsdp_module._handles:\n p = handle.flat_param\n if p.requires_grad:\n if hasattr(p, \"_post_backward_hook_state\"):\n p_assert(\n ...
[ "0.6891195", "0.6799861", "0.63945884", "0.6231746", "0.6104134", "0.60445285", "0.60245174", "0.59870183", "0.59758", "0.594575", "0.58647954", "0.5838866", "0.5829284", "0.58135855", "0.5702212", "0.56986016", "0.5696088", "0.5667963", "0.56588745", "0.5657598", "0.56567985...
0.70270365
0
Set up a list to avoid registering prebackward hooks incorrectly. And a list to apply optimization barrier on backward pass tensors.
def _setup_output_hook_and_backward_opt_barrier_lists(self) -> None: assert self._is_root, "This should only be called on the root" self._output_pre_backward_hook_registered = set() self._backward_opt_barrier_tensors = [] self._backward_opt_barrier_tensor_ids = set() for n, m in self.named_modules()...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _fp32_register_post_backward_hooks(self):\n\n # Helper function to avoid issues with late binding closures\n def make_post_backward_hook(param):\n def post_backward_hook(*unused):\n self._fp32_optim_grad_sync_needed = True\n if hasattr(param, 'main_grad'):...
[ "0.6892539", "0.6817105", "0.67764384", "0.6743315", "0.6634035", "0.6633885", "0.658463", "0.6562383", "0.6494526", "0.62982607", "0.60378724", "0.6013717", "0.60000384", "0.5945345", "0.5854405", "0.5826044", "0.57632494", "0.5634424", "0.54802567", "0.547969", "0.5438676",...
0.7160828
0
Add tensor to backward pass optimization barrier list if it is not there.
def _try_adding_to_backward_opt_barrier_lists(self, tensor: torch.Tensor) -> None: if id(tensor) not in self._backward_opt_barrier_tensor_ids: self._backward_opt_barrier_tensor_ids.add(id(tensor)) self._backward_opt_barrier_tensors.append(tensor)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _poputil_block_recompute_backward(op, grads):\n return grads", "def _apply_opt_barrier_to_params_and_tensors(\n self, p_list: List[torch.Tensor], p_shard_list: List[torch.Tensor],\n dependency_tensors: List[torch.Tensor]):\n if len(p_list) + len(p_shard_list) + len(dependency_tensors) == 0:\n ...
[ "0.6255564", "0.6100858", "0.60640955", "0.5995273", "0.5924337", "0.59193915", "0.590711", "0.58544457", "0.5831913", "0.58308136", "0.5783415", "0.57667774", "0.5748316", "0.57216793", "0.56783605", "0.56430024", "0.56299055", "0.56154805", "0.55834407", "0.5558023", "0.555...
0.78098917
0
Register hook to `dependency_tensors` to put their gradient tensors into self._backward_opt_barrier_tensors for backward pass optimization barrer.
def _register_grad_opt_barrier_hooks( self, dependency_tensors: List[torch.Tensor]) -> None: if not torch.is_grad_enabled(): return # don't register hooks if grad isn't enabled def _grad_opt_barrier_hook(t_grad: torch.Tensor): self._try_adding_to_backward_opt_barrier_lists(t_grad) self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _register_post_backward_hooks(self) -> None:\n if not torch.is_grad_enabled():\n return # don't register grad hooks if grad isn't enabled\n for p in self.full_params:\n if p.requires_grad:\n if hasattr(p, \"_shard_bwd_hook\"):\n continue\n # Register a hook on the first ...
[ "0.68092126", "0.6792964", "0.6702238", "0.62400526", "0.6212433", "0.61180437", "0.6086423", "0.6000124", "0.5954072", "0.588943", "0.58467245", "0.5840487", "0.56945574", "0.5615899", "0.54912275", "0.54761446", "0.54718", "0.5419614", "0.54047835", "0.54047835", "0.5376192...
0.8301252
0
Register backward hooks to reshard params and reducescatter grads. This is called during forward pass. The goal is to attach a hook on each of the parameter's gradient generating function (``grad_acc`` below) so that the hook is called after all gradients for that param are computed.
def _register_post_backward_hooks(self) -> None: if not torch.is_grad_enabled(): return # don't register grad hooks if grad isn't enabled for p in self.full_params: if p.requires_grad: if hasattr(p, "_shard_bwd_hook"): continue # Register a hook on the first call, empirica...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _fp32_register_post_backward_hooks(self):\n\n # Helper function to avoid issues with late binding closures\n def make_post_backward_hook(param):\n def post_backward_hook(*unused):\n self._fp32_optim_grad_sync_needed = True\n if hasattr(param, 'main_grad'):...
[ "0.7462905", "0.69060594", "0.688766", "0.6856517", "0.6834197", "0.6677355", "0.6671704", "0.65846634", "0.65497565", "0.6516998", "0.64897394", "0.6291849", "0.62878025", "0.6284139", "0.62600726", "0.600069", "0.5904114", "0.5796979", "0.57926524", "0.57776725", "0.5722192...
0.7972718
0
Flatten and pad a tensor to a given world size (for reducescatter).
def _flatten_and_pad_to_world_size(self, tensor: torch.Tensor, world_size: int) -> torch.Tensor: if self._shard_param_on_dim_0: # shard only on dim 0 of the parameter, without flattening if tensor.size(0) % world_size != 0: pad_size = world_size - tensor.size...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wrap_pad(input, size):\n M1 = tf.concat([input[:, :, -size[1]:, :], input, input[:, :, 0:size[1], :]], 2)\n M1 = tf.concat([M1[:, -size[0]:, :, :], M1, M1[:, 0:size[0], :, :]], 1)\n return M1", "def pad(input, pad_size):\n if not pad_size:\n return input\n return tf.pad(input, [[0,0],[p...
[ "0.7144496", "0.6669238", "0.6487876", "0.64263964", "0.63391405", "0.6281128", "0.626849", "0.62397903", "0.620776", "0.6170778", "0.6129287", "0.6126736", "0.6097369", "0.60817534", "0.6074656", "0.60084975", "0.6001042", "0.5991514", "0.5981589", "0.59411633", "0.58645254"...
0.8523019
0
Does a GET request to /v2/payments/{payment_id}. Retrieves details for a specific payment.
def get_payment(self, payment_id): return super().new_api_call_builder.request( RequestBuilder().server('default') .path('/v2/payments/{payment_id}') .http_method(HttpMethodEnum.GET) .template_param(Parameter() .key...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retrieve(payment_id):\n http_client = HttpClient()\n response, __ = http_client.get(routes.url(routes.PAYMENT_RESOURCE, resource_id=payment_id))\n return resources.Payment(**response)", "def get(self, payment_id=None):\n if payment_id:\n payemnt = Payment.query.filter_b...
[ "0.8498946", "0.83088595", "0.82039946", "0.78867936", "0.7605686", "0.7395516", "0.7149845", "0.6852734", "0.66524243", "0.64836586", "0.63389045", "0.63348454", "0.6306717", "0.6261567", "0.61714005", "0.613381", "0.6007443", "0.5942717", "0.5718822", "0.57019156", "0.56429...
0.8058351
3
r""" Return a LaTeX representation of ``self``.
def _latex_(self): return r"\mathbb{P}_{%s}" % latex(self.Delta())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __repr__(self): # pragma: no cover\r\n if self.latex == self.sans_parens:\r\n latex_repr = u'\"{}\"'.format(self.latex)\r\n else:\r\n latex_repr = u'\"{}\" or \"{}\"'.format(self.latex, self.sans_parens)\r\n\r\n if self.tall:\r\n wrap = u'<[{}]>'\r\n ...
[ "0.78418356", "0.7727769", "0.7695589", "0.7374604", "0.73041743", "0.72596556", "0.7253343", "0.7157525", "0.7135335", "0.71022457", "0.70961916", "0.70766973", "0.70650357", "0.70599365", "0.70599365", "0.68704855", "0.68538725", "0.6848989", "0.68271786", "0.68046254", "0....
0.7157886
7
r""" Return the reflexive polytope associated to ``self``.
def Delta(self): return self._Delta_polar.polar()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def defining_polynomial(self):\n return self.defining_polynomials()[0]", "def defining_polynomial(self):\n return self.defining_polynomials()[0]", "def embed_in_reflexive_polytope(self, output='hom'):\n if self.affine_dimension() > 2:\n raise NotImplementedError('can only embed ...
[ "0.6094851", "0.6094851", "0.6053461", "0.6000702", "0.5915638", "0.58915544", "0.58879536", "0.5867651", "0.5833705", "0.5827252", "0.58218575", "0.5821365", "0.57832044", "0.5697129", "0.5687417", "0.5648143", "0.56409824", "0.56409824", "0.56391615", "0.5584487", "0.554051...
0.0
-1
Compute the average precision, given the recall and precision curves.
def _compute_ap(recall, precision): # correct AP calculation # first append sentinel values at the end mrec = np.concatenate(([0.], recall, [1.])) mpre = np.concatenate(([0.], precision, [0.])) print("><<<<<<<<>>>>>>>>>>>>>") print(mrec) print(mpre) print("><<<<<<<<>>>>>>>>>>>>>") #...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_average_precision(precision, recall):\n # identical but faster version of new_precision[i] = old_precision[i:].max()\n precision = np.concatenate([[0.0], precision, [0.0]])\n for i in range(len(precision) - 1, 0, -1):\n precision[i - 1] = np.maximum(precision[i - 1], precision[i])\n\n ...
[ "0.83714455", "0.8136858", "0.77525085", "0.77255106", "0.7718583", "0.76943123", "0.7692928", "0.7650776", "0.7650776", "0.7627588", "0.75597596", "0.7537287", "0.727422", "0.7251301", "0.7228867", "0.7209946", "0.72006965", "0.7182446", "0.7162544", "0.7130612", "0.70859635...
0.74771714
12
>>> _isnumber_with_thousands_separator(".") False >>> _isnumber_with_thousands_separator("1") True >>> _isnumber_with_thousands_separator("1.") True >>> _isnumber_with_thousands_separator(".1") True >>> _isnumber_with_thousands_separator("1000") False >>> _isnumber_with_thousands_separator("1,000") True >>> _isnumber_w...
def _isnumber_with_thousands_separator(string): try: string = string.decode() except (UnicodeDecodeError, AttributeError): pass return bool(re.match(_float_with_thousands_separators, string))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_number(value):\n try:\n float(value.replace(',', ''))\n except ValueError:\n return False\n return True", "def _is_number(s) -> bool:\n try:\n float(s)\n except ValueError:\n return False\n else:\n return True", "def _is_number(value):\n try:\n...
[ "0.6542095", "0.6294855", "0.61424583", "0.6099551", "0.6082271", "0.6065819", "0.6065819", "0.6065819", "0.605616", "0.60495883", "0.60338634", "0.6010475", "0.59945637", "0.5984697", "0.59356755", "0.58544415", "0.5844431", "0.5810023", "0.5809045", "0.57973355", "0.5790351...
0.8396988
0
>>> _isnumber("123.45") True >>> _isnumber("123") True >>> _isnumber("spam") False >>> _isnumber("123e45678") False >>> _isnumber("inf") True
def _isnumber(string): if not _isconvertible(float, string): return False elif isinstance(string, (str, bytes)) and ( math.isinf(float(string)) or math.isnan(float(string)) ): return string.lower() in ["inf", "-inf", "nan"] return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_number(s):\n try:\n float(s)\n return True\n except ValueError:\n return False", "def is_number(string):\n try:\n float(string)\n return True\n except ValueError:\n return False", "def is_number(s):\n try:\n float(s)\n return True\n except ValueE...
[ "0.87432945", "0.87063056", "0.87037754", "0.87037754", "0.87037754", "0.86839", "0.86623156", "0.8658077", "0.8587047", "0.8549031", "0.8478405", "0.8423849", "0.84080803", "0.83790374", "0.8373497", "0.8343268", "0.8341039", "0.83257306", "0.83168423", "0.8314271", "0.82663...
0.85281724
10
Symbols after a decimal point, 1 if the string lacks the decimal point. >>> _afterpoint("123.45") 2 >>> _afterpoint("1001") 1 >>> _afterpoint("eggs") 1 >>> _afterpoint("123e45") 2 >>> _afterpoint("123,456.78") 2
def _afterpoint(string): if _isnumber(string) or _isnumber_with_thousands_separator(string): if _isint(string): return -1 else: pos = string.rfind(".") pos = string.lower().rfind("e") if pos < 0 else pos if pos >= 0: return len(string) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def two_digits_after_point(value):\n if isinstance(value, str):\n result = format(float(value), '.2f')\n return result\n elif isinstance(value, float):\n result = format(value, '.2f')\n return float(result)\n elif isinstance(value, int):\n value = float(value)\n p...
[ "0.5807374", "0.54738426", "0.5101628", "0.50197816", "0.5018497", "0.4993644", "0.49502248", "0.49051082", "0.4896271", "0.48899698", "0.4850698", "0.48095798", "0.4798857", "0.47888988", "0.47621077", "0.4738099", "0.4732712", "0.47234747", "0.47089487", "0.47002798", "0.46...
0.78380966
0
Center string. >>> _padboth(6, '\u044f\u0439\u0446\u0430') == ' \u044f\u0439\u0446\u0430 ' True
def _padboth(width, s): fmt = "{0:^%ds}" % width return fmt.format(s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def center(text, width=72, pad_character=\" \"):\n\n length = len(text)\n prefix = (width - length) // 2\n suffix = width - prefix - length\n return (prefix * \" \") + text + (suffix * \" \")", "def _pad_shorter(sequence: str) -> str:\n return sequence.ljust(3, \"X\")", "def get_pad2(s1, s2)...
[ "0.7140216", "0.63684124", "0.63169694", "0.6292559", "0.62823284", "0.62645966", "0.6213063", "0.61896425", "0.6170726", "0.6164957", "0.61557645", "0.61284983", "0.6115836", "0.6107988", "0.61054456", "0.61", "0.6041634", "0.6007407", "0.5999633", "0.59379756", "0.5920162",...
0.65963936
1
A type safe wrapper for converting a bytestring to str. This is essentially just a wrapper around .decode() intended for use with things like map(), but with some
def _to_str(s, encoding="utf8", errors="ignore"): if isinstance(s, bytes): return s.decode(encoding=encoding, errors=errors) return str(s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bytes_to_str(s, encoding='utf-8'):\n if isinstance(s, bytes):\n return s.decode(encoding)\n return s", "def bytes_to_str(s, encoding='utf-8'):\n if six.PY3 and isinstance(s, bytes):\n return s.decode(encoding)\n return s", "def bytes_to_str(s, encoding='utf-8'):\n if six.PY3 an...
[ "0.8154812", "0.81371343", "0.81371343", "0.8084186", "0.79103696", "0.78460264", "0.7819046", "0.7566766", "0.7456021", "0.74405515", "0.7419448", "0.73675716", "0.73517245", "0.73455", "0.73379016", "0.73228925", "0.731033", "0.72620136", "0.7245369", "0.72316766", "0.71974...
0.78993315
5
Returns the attributes for this machine.
def get_attributes(): bot_id = socket.gethostname().lower().split('.', 1)[0] return os_utilities.get_attributes(bot_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAttributes(self):\n return self.attributes", "def getAttributes(self):\n return self.attributes", "def GetAttributes(self):\r\n\r\n return self._attr", "def get_attributes(self):\n return self.attributes", "def getAttributes(self):\n pass", "def get_attributes(se...
[ "0.77701336", "0.77701336", "0.77157146", "0.76253116", "0.76118535", "0.7567369", "0.74726593", "0.7454361", "0.74511325", "0.74102587", "0.74102587", "0.74102587", "0.7380915", "0.73561007", "0.7328756", "0.72709304", "0.71834505", "0.71631664", "0.7157943", "0.71349585", "...
0.7069597
25
Returns the reference config.
def config(self, device: Device, precision: Precision, world_size: int, rank_zero_seed: int): train_dataset = RandomClassificationDataset(size=16) eval_dataset = RandomClassificationDataset(size=16) return { 'model': SimpleModel(), 'train_dataloader': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_config(self):\n return self.config", "def _get_config(self):\n return self.__config", "def _get_config(self):\n return self.__config", "def _get_config(self):\n return self.__config", "def _get_config(self):\n return self.__config", "def _get_config(self):\n return self.__co...
[ "0.7303697", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "...
0.0
-1
Returns the reference config.
def config(self): train_dataset = RandomClassificationDataset() eval_dataset = RandomClassificationDataset() return { 'model': SimpleModel(), 'train_dataloader': DataLoader( dataset=train_dataset, b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_config(self):\n return self.config", "def _get_config(self):\n return self.__config", "def _get_config(self):\n return self.__config", "def _get_config(self):\n return self.__config", "def _get_config(self):\n return self.__config", "def _get_config(self):\n return self.__co...
[ "0.7303697", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "0.7259904", "...
0.0
-1
Get current date in YEARMONTHDAY format.
def get_date(): dt = datetime.now() return dt.strftime("%Y-%m-%d")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_date_today() -> str:\n return datetime.now().strftime(\"%Y-%m-%d\")", "def get_today(self):\n # using now() to get current time\n current_time = datetime.datetime.now()\n day = str(current_time.day)\n month = str(current_time.month)\n\n day = self.check_and_repai...
[ "0.7229084", "0.7136875", "0.700063", "0.69979775", "0.6876184", "0.6743486", "0.6676277", "0.66296995", "0.6571405", "0.65098035", "0.6506451", "0.64529675", "0.6418477", "0.637093", "0.63606524", "0.63559055", "0.6345028", "0.632469", "0.62799686", "0.6268996", "0.6266585",...
0.63688594
14
Get the value of the Literal.
def getValue(self): raise NotImplementedError("Define in derived class")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getValue(self):\n return _libsbml.ASTNode_getValue(self)", "def value(self):\n s = str(self.input.text())\n if self._is_string_:\n return s\n else:\n return eval(s)", "def getValue(self):\n return self.text()", "def value(self) -> str:\n if ...
[ "0.69176006", "0.67216945", "0.6705249", "0.6699813", "0.6699813", "0.6666605", "0.66269714", "0.6625353", "0.6616099", "0.660955", "0.6537174", "0.6530694", "0.6529157", "0.6523697", "0.6523697", "0.6511547", "0.6511547", "0.6511547", "0.6502566", "0.6499618", "0.6499618", ...
0.0
-1
This implementation is slightly faster than tensor2img. It now only supports torch tensor with shape (1, c, h, w).
def tensor2img_fast(tensor, rgb2bgr=True, min_max=(0, 1)): output = tensor.squeeze(0).detach().clamp_(*min_max).permute(1, 2, 0) output = (output - min_max[0]) / (min_max[1] - min_max[0]) * 255 output = output.type(torch.uint8).cpu().numpy() if rgb2bgr: output = cv2.cvtColor(output, cv2.COLOR_RG...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def im_convert(tensor):\n \n image = tensor.to(\"cpu\").clone().detach()\n image = image.numpy().squeeze()\n image = image.transpose(1,2,0)\n image = image * np.array((0.229, 0.224, 0.225)) + np.array((0.485, 0.456, 0.406))\n image = image.clip(0, 1)\n\n return image", "def tensor_to_image(i...
[ "0.6861531", "0.6811791", "0.6708912", "0.66678745", "0.6659391", "0.65594685", "0.65594685", "0.65582573", "0.65407014", "0.65360963", "0.6518375", "0.64753115", "0.6453792", "0.6434146", "0.64291716", "0.6420121", "0.6359532", "0.6333421", "0.63196564", "0.63155043", "0.631...
0.68518776
1
Read an image from bytes.
def imfrombytes(content, flag='color', float32=False): img_np = np.frombuffer(content, np.uint8) imread_flags = {'color': cv2.IMREAD_COLOR, 'grayscale': cv2.IMREAD_GRAYSCALE, 'unchanged': cv2.IMREAD_UNCHANGED} img = cv2.imdecode(img_np, imread_flags[flag]) if float32: img = img.astype(np.float32...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image_decoder(rawbytes):\n img = Image.open(BytesIO(rawbytes))\n array = np.asarray(img, dtype=np.uint8)\n return array", "def read_image(img_path):\n img = imageio.imread(uri=img_path)\n return img", "def read_image(self, item):\n assert item['image_dtype'] == 'uint16'\n\n filename ...
[ "0.7084831", "0.6854387", "0.6825468", "0.68083876", "0.6657157", "0.6639139", "0.66016585", "0.65861046", "0.65771484", "0.6494287", "0.64901775", "0.6479835", "0.6388642", "0.63756", "0.63729894", "0.63712287", "0.63273114", "0.63086474", "0.6303887", "0.6285786", "0.627715...
0.7081325
1
Any arguments that are ultimately represented as bytes can be specified either as bytes or as strings. However we enforce that any string arguments must only contain characters in the plain ASCII range. chr(0)...chr(127). If you need to use characters outside that range then be precise, and use a bytewise argument.
def enforce_bytes(value: Union[bytes, str], *, name: str) -> bytes: if isinstance(value, str): try: return value.encode("ascii") except UnicodeEncodeError: raise TypeError(f"{name} strings may not include unicode characters.") elif isinstance(value, bytes): return...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_bytes_encoding_arg_non_kwarg(self):\n u = u'Unicode string: \\u5b54\\u5b50'\n b = py23_bytes(u, 'utf-8')\n self.assertEqual(b, u.encode('utf-8'))", "def bytes(*args, **kwargs): # real signature unknown\n pass", "def bytes_check(*args, func=None):\n func = func or inspect.sta...
[ "0.68610555", "0.66094005", "0.65707976", "0.65583795", "0.6472137", "0.64531964", "0.6402997", "0.63600063", "0.6323508", "0.62645555", "0.6244428", "0.6208456", "0.61847144", "0.61819243", "0.60637915", "0.6059526", "0.6049556", "0.60121655", "0.6010169", "0.59964514", "0.5...
0.6883881
0
Convienence function that ensure all items in request or response headers are either bytes or strings in the plain ASCII range.
def enforce_headers( value: Union[HeadersAsMapping, HeadersAsSequence, None] = None, *, name: str ) -> List[Tuple[bytes, bytes]]: if value is None: return [] elif isinstance(value, Mapping): return [ ( enforce_bytes(k, name="header name"), enforce_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_response_non_text_encoding():\n headers = {\"Content-Type\": \"image/png\"}\n response = httpcore.Response(200, content=b\"xyz\", headers=headers)\n assert response.text == \"xyz\"\n assert response.encoding == \"ascii\"", "def test_response_no_charset_with_ascii_content():\n content = b\...
[ "0.61406654", "0.6128241", "0.60466325", "0.5971178", "0.5905622", "0.5893737", "0.58359456", "0.5821749", "0.58020806", "0.5740074", "0.5693007", "0.5682882", "0.5676924", "0.56732374", "0.56628203", "0.55564576", "0.5556294", "0.5547389", "0.553744", "0.5423602", "0.5386306...
0.5176623
38
Getter for the missing value character in the data.
def missing(self): return self.MISSING
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_value(self, character):\n return -self.item.get_value(character)", "def missing_values(self):\n missing_values = self.data.isna().sum()\n if missing_values:\n fracture = missing_values / self.data.count()\n return f\"N={missing_values},{round(fracture, 2)}%\"\n ...
[ "0.6499473", "0.6200618", "0.5944398", "0.57941484", "0.5711948", "0.5632841", "0.5621153", "0.5607849", "0.55804276", "0.5569528", "0.55688655", "0.5538723", "0.5531943", "0.5518225", "0.5484424", "0.5484208", "0.5478072", "0.54432297", "0.5432", "0.54280126", "0.542577", ...
0.5534694
12
Initialises model parameters prior to fitting. Extends the base classes method. See _BaseHMM.py for more information.
def _init_model_params(self): super()._init_model_params() if 'e' in self.init_params: if self.init_type == 'uniform': if self.nr_no_train_de == 0: self.B = [ np.full( (self.n_states, self.n_features[i])...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def params_init(self) -> None:\n # Initialize weights and biases with uniform distribution.\n nn.init.uniform_(self.emb.weight, self.init_lower, self.init_upper)\n nn.init.uniform_(self.fc_e2h[1].weight, self.init_lower, self.init_upper)\n nn.init.uniform_(self.fc_e2h[1].bias, self.init_lower, self.ini...
[ "0.72519994", "0.7052896", "0.7048691", "0.6986132", "0.6973283", "0.68647254", "0.6856685", "0.682334", "0.68105865", "0.676604", "0.6740836", "0.6720289", "0.67196655", "0.67066276", "0.67060673", "0.6703218", "0.6699637", "0.6697226", "0.66911834", "0.66875273", "0.6671801...
0.72751135
0
Returns the minimax action using self.depth and self.evaluationFunction
def getAction(self, gameState): return self.alphaBetaState(gameState, 0, 0, -float('inf'), float('inf'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = minimax(self.evaluationFunction, 1, 0,\n gameState.generateSuccessor(0, move), self.depth)\n if util > _max o...
[ "0.7482665", "0.7383559", "0.71806973", "0.7110041", "0.70884514", "0.70694935", "0.70683014", "0.7048308", "0.70055133", "0.69651455", "0.69642085", "0.69604385", "0.6945924", "0.68998593", "0.6895832", "0.688605", "0.6826282", "0.6767276", "0.6758028", "0.6751636", "0.67054...
0.0
-1
Get word embedding op from embedding op
def _get_word_tensor(embedding_op: tf.Operation) -> tf.Tensor: assert embedding_op.type == 'AddV2' add = embedding_op.inputs[0].op assert add.type == 'AddV2' identity = add.inputs[0].op assert identity.type == 'Identity' gather = identity.inputs[0].op assert gathe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_embedding_layer(self, input_data, doc_input_data):\n opts = self._options\n word_embedding = tf.Variable(tf.random_uniform((self.vocab_size, opts.embed_dim), -1.0, 1.0))\n embed = []\n\n temp = tf.zeros([opts.batch_size, opts.embed_dim])\n embed_d = []\n for n in ...
[ "0.73252714", "0.70400095", "0.70283526", "0.6983", "0.6885749", "0.66525847", "0.6644698", "0.6599045", "0.65726596", "0.6536544", "0.64794534", "0.64469", "0.6425379", "0.6407107", "0.6404322", "0.6374274", "0.6371897", "0.636494", "0.6342331", "0.63066983", "0.62021065", ...
0.78313375
0
Get token embedding op from embedding op
def _get_token_tensor(embedding_op: tf.Operation) -> tf.Tensor: assert embedding_op.type == 'AddV2' identity_2 = embedding_op.inputs[1].op assert identity_2.type == 'Identity' gather_2 = identity_2.inputs[0].op assert gather_2.type == 'ResourceGather' return gather_2.out...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_word_tensor(embedding_op: tf.Operation) -> tf.Tensor:\n assert embedding_op.type == 'AddV2'\n add = embedding_op.inputs[0].op\n assert add.type == 'AddV2'\n identity = add.inputs[0].op\n assert identity.type == 'Identity'\n gather = identity.inputs[0].op\n ...
[ "0.7492029", "0.6493747", "0.6358026", "0.631711", "0.6278309", "0.62704146", "0.62359965", "0.6210149", "0.6179377", "0.61283904", "0.5958456", "0.5938996", "0.59338063", "0.5889382", "0.5872871", "0.5870001", "0.58656967", "0.5820393", "0.57991546", "0.5778024", "0.57558745...
0.789456
0
This function takes the text from a tweet and preproceses it. It cleans it according to GloVe's twitter word embeddings
def clean_string(tweet): # Remove new lines tweet = re.sub("\n", " ", tweet) # Replace urls with token tweet = re.sub("https?:\/\/\S+|www\.(\w+\.)+\S*", "<url>", tweet) # Split words with slashes tweet = re.sub("/", " / ", tweet) # Remove apostrophes and commas tweet = re.sub("['\"’,]", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess(text):\n text = remove_space(text)\n text = clean_special_punctuations(text)\n text = handle_emojis(text)\n text = clean_number(text)\n text = spacing_punctuation(text)\n text = clean_repeat_words(text)\n text = remove_space(text)\n #text = stop(text)# if changing this, then ...
[ "0.7898617", "0.7452399", "0.74481386", "0.73230374", "0.73230374", "0.73198974", "0.7201898", "0.7147456", "0.70362544", "0.7003467", "0.70001364", "0.6980996", "0.6792771", "0.67732376", "0.67599154", "0.67211235", "0.6709763", "0.6595905", "0.6584331", "0.6566347", "0.6550...
0.6568438
19
Return string representation suitable for object reconstruction.
def __repr__(self): s = self.name if self.param != "None": s += ' with parameter '+self.param s += '; '+self.applyTo if self.applyTo != "global": s += ': '+self.conditions return s
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n class_name_str = str(self.__class__.__name__) + \": (\"\n head_str = str(self.head_vertex) + \", \"\n tail_str = str(self.tail_vertex) + \", \"\n weight_str = str(self.weight) + \")\"\n attributes_str = head_str + tail_str + weight_str\n str_rep = clas...
[ "0.7550448", "0.7550448", "0.75484604", "0.7421932", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", "0.74141777", ...
0.0
-1
Calculates the binary cross entropy on the aggregated outputs of each batch. Use the max when y_true == 1 but the mean when y_true== 0
def obj_mix(Y_true,Y_pred): y_true = K.mean(Y_true,axis=0) if y_true == 1: y_pred = K.max(Y_pred,axis=0) return(K.mean(K.binary_crossentropy(y_pred, y_true))) elif y_true == 0: return(K.mean(K.binary_crossentropy(Y_pred,Y_true))) else: print('unexpected value of y_true',y...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binary_cross_entropy(y_true, y_preds):\n return np.sum(y_true * np.log(y_preds) + (1 - y_true) * np.log(1 - y_preds))", "def binary_cross_entropy(y_true, y_pred, eps=1e-15):\n assert y_true.shape == y_pred.shape\n y_pred = np.clip(y_pred, eps, 1 - eps) # Avoid log(0)\n return - np.mean(\n ...
[ "0.751932", "0.72573495", "0.7256394", "0.7213564", "0.7079301", "0.7046794", "0.704372", "0.7015776", "0.70154345", "0.6973653", "0.6913271", "0.68767905", "0.68608356", "0.6846285", "0.68144524", "0.6803912", "0.67933303", "0.67887545", "0.6745289", "0.6744104", "0.67302287...
0.7119242
4
Initialize. Motion events will be sent to the specified address.
def __init__(self, socket, address): self.socket = socket self.address = address self.num_events = 0 # RPi.GPIO invokes the callback method from different threads for each # registered GPIO pin, which means we must handle concurrent calls... self.lock = RLock() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init(self, address, port):\n \n pygame.init()\n pygame.joystick.init()\n self.controller = pygame.joystick.Joystick(0)\n self.controller.init()\n self.event_dict = {}\n\n # Create a TCP/IP socket\n self.sock = socket.socket(socket.AF_INET, socket.SOCK_STR...
[ "0.677801", "0.5957114", "0.5936195", "0.59334797", "0.5925841", "0.5915736", "0.58898205", "0.58710676", "0.5822217", "0.5795484", "0.5687509", "0.5686153", "0.56733733", "0.56579643", "0.5615253", "0.5614057", "0.55953777", "0.55924404", "0.55872995", "0.5583893", "0.557670...
0.62987953
1
Generate all unique strict subsequences of the specified length, optionally treating "sequence" as an infinite circular array.
def subsequences(sequence, length, circular=False): if circular: for i in xrange(len(sequence)): subsequence = sequence[i:i + length] yield subsequence + sequence[0:length - len(subsequence)] else: for i in xrange(len(sequence) - length + 1): yield sequence[i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fast_forward_to_length(sequences, length):\n return itertools.dropwhile(lambda seq: len(seq) != length, sequences)", "def combinations(sequence, length, NULL=object()):\r\n if length <= 0:\r\n combos = [NULL]\r\n else:\r\n combos = []\r\n for i, item in enumerate(sequence, 1):\r...
[ "0.6368506", "0.6311978", "0.6050164", "0.6010195", "0.59332037", "0.59234065", "0.59106314", "0.58832335", "0.5871862", "0.58509177", "0.58509177", "0.58460057", "0.58445215", "0.58355874", "0.58320427", "0.5810086", "0.57959014", "0.57931554", "0.5789068", "0.5789068", "0.5...
0.7536472
0
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, ShowAutoCreatePolicyResponse): return False return self.__dict__ == other.__dict__
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def __eq__(self, other):\n if i...
[ "0.8088132", "0.8088132", "0.8054589", "0.7982687", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", ...
0.0
-1
Returns true if both objects are not equal
def __ne__(self, other): return not self == other
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True", "def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)", "def __ne__(self, other) -> bool:\n return not self.__eq__(other)", "def __eq__(self, other):\n ...
[ "0.845611", "0.8391477", "0.8144138", "0.81410587", "0.8132492", "0.8093973", "0.80920255", "0.80920255", "0.80920255", "0.8085325", "0.8085325", "0.8076365", "0.8076365", "0.8065748" ]
0.0
-1
Produce a limited stream of values from an iterator. If `n` is 0 or None, don't limit the iterator at all.
def limit(iterator, n=None): # Producing at most `n` values from the given iterator. # Tried using try-except blocks to cover the stop iteration # exception for iter. if not n: return iterator output = [] iter = (i for i in iterator) for x in range(0, n): try: o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def limit(iterator, n=None):\n for i, v in enumerate(iterator):\n yield v\n if i + 1 == n:\n break", "def limit(iterable, n):\n for count, element in enumerate(iterable):\n if count >= n: break\n else: yield element", "def iterate(iterator, n):\n # throw away n-1...
[ "0.81798553", "0.74154925", "0.7374941", "0.7370469", "0.7360399", "0.73495483", "0.73299736", "0.7025565", "0.70048577", "0.70048577", "0.69829243", "0.69468176", "0.69468176", "0.68507653", "0.6839687", "0.6787767", "0.6747792", "0.6710701", "0.6693136", "0.6641916", "0.662...
0.8477086
0
Implement this method to return the value of the resolvable_property.
def get_resolved_value( self, stack: "stack.Stack", stack_class: Type["stack.Stack"] ) -> Any: pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def property(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"property\")", "def resolve(self):\n return resolve(self.val())", "def __call__(self, arg):\n return self.get_property(arg)", "def get_value(self, reference_path):\n\n if (reference_path.start_protocol is no...
[ "0.6821072", "0.6674497", "0.65914404", "0.6552484", "0.6529322", "0.6522357", "0.6455077", "0.6387297", "0.6386354", "0.6372815", "0.6333942", "0.6287543", "0.6242844", "0.62190586", "0.61920977", "0.6168353", "0.6135813", "0.6102774", "0.60980004", "0.6090925", "0.6087045",...
0.0
-1
Obtains the resolved value for this property. Any resolvers that resolve to None will have their key/index removed from their dict/list where they are. Other resolvers will have their key/index's value replace with the resolved value to avoid redundant resolutions.
def get_resolved_value( self, stack: "stack.Stack", stack_class: Type["stack.Stack"] ) -> T_Container: keys_to_delete = [] def resolve(attr: Union[dict, list], key: Union[int, str], value: Resolver): # Update the container key's value with the resolved value, if possible... ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resolve(self):\n return resolve(self.val())", "def resolve_resolver_value(self, resolver: \"Resolver\") -> Any:\n try:\n return resolver.resolve()\n except RecursiveResolve:\n # Recursive resolve issues shouldn't be masked by a placeholder.\n raise\n e...
[ "0.7109319", "0.69254684", "0.681345", "0.6485417", "0.6276801", "0.62258667", "0.62212586", "0.62188625", "0.6188876", "0.6116443", "0.60962147", "0.60665053", "0.58822995", "0.5876782", "0.5803398", "0.5701613", "0.5642112", "0.5637307", "0.5591054", "0.5574686", "0.5560353...
0.5994172
12
Gets the fullyresolved value from the property. Resolvers will be replaced on the stack instance with their resolved value to avoid redundant resolutions.
def get_resolved_value( self, stack: "stack.Stack", stack_class: Type["stack.Stack"] ) -> Any: raw_value = getattr(stack, self.name) if isinstance(raw_value, Resolver): value = self.resolve_resolver_value(raw_value) # Overwrite the stored resolver value with the resol...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resolve(self):\n return resolve(self.val())", "def get_resolved_value(\n self, stack: \"stack.Stack\", stack_class: Type[\"stack.Stack\"]\n ) -> Any:\n pass", "def _get_resolved(self):\n return self.__resolved", "def resolve_resolver_value(self, resolver: \"Resolver\") -> Any:\n ...
[ "0.7285139", "0.66580427", "0.6612513", "0.6549235", "0.62745225", "0.6198444", "0.61238134", "0.587929", "0.5878775", "0.57903653", "0.5783566", "0.5770237", "0.57174873", "0.565451", "0.5651387", "0.5585604", "0.5579232", "0.5528005", "0.55224043", "0.5508488", "0.5504958",...
0.7360377
0
Function to change the gain of the ALS sensors that are connected to the multiplexer. The variable i2c_sensor_gain can take the values 0 (gain = 1), 1 (gain = 8), 2 (gain = 16), and 3 (gain = 130).
def i2c_set_gain_all_sensors(pi, i2c_multiplexer_handle, i2c_sensor_handle, channel_numbers, i2c_sensor_gain): for channel_number in channel_numbers: i2c_multiplexer_select_channel(pi, i2c_multiplexer_handle, channel_number) i2c_sensor_handle.ambient_light_gain...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def i2c_change_gain_all_sensors(pi, i2c_multiplexer_handle, i2c_sensor_handle, channel_numbers, gain):\n for channel_number in channel_numbers:\n i2c_multiplexer_select_channel(\n i2c_multiplexer_select_channel, channel_number)\n i2c_sensor_handle.ambient_light_gain = gain", "def set_...
[ "0.7838934", "0.64619696", "0.62360793", "0.60507804", "0.60504", "0.59876555", "0.58884364", "0.5822884", "0.58117855", "0.5805836", "0.5804934", "0.5782361", "0.5706696", "0.5682449", "0.5656912", "0.5602207", "0.5523741", "0.5509937", "0.5496614", "0.5455737", "0.5440469",...
0.7360746
1
Function to change the gain of the ALS sensors that are connected to the multiplexer. variable i2c_sensor_gain can take the values 0 (gain = 1), 1 (gain = 8), 2 (gain = 16), and 3 (gain = 130).
def i2c_change_gain_all_sensors(pi, i2c_multiplexer_handle, i2c_sensor_handle, channel_numbers, gain): for channel_number in channel_numbers: i2c_multiplexer_select_channel( i2c_multiplexer_select_channel, channel_number) i2c_sensor_handle.ambient_light_gain = gain
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def i2c_set_gain_all_sensors(pi, i2c_multiplexer_handle, i2c_sensor_handle, channel_numbers, i2c_sensor_gain):\n for channel_number in channel_numbers:\n i2c_multiplexer_select_channel(pi,\n i2c_multiplexer_handle, channel_number)\n i2c_sensor_handle.ambient_l...
[ "0.7423357", "0.647509", "0.62754184", "0.61743975", "0.60917413", "0.5993012", "0.5929322", "0.582763", "0.58223754", "0.5807776", "0.57847136", "0.57804906", "0.5722536", "0.57046103", "0.56889284", "0.56758404", "0.5574301", "0.5529423", "0.5527807", "0.55193484", "0.54938...
0.7888089
0
Function to calculate the output of a Proportional Integral Derivative Controller (PIDcontroller).
def pid_controller_calculator(pid_parameters, error, duration=0.17): k_p = pid_parameters[0] k_i = pid_parameters[1] k_d = pid_parameters[2] error = np.array(error) proportional_term = k_p * error[-1] integrational_term = k_i * duration * np.sum(error) differential_term = k_d * (error[-1] - ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _PIDController__calculate(self): \n \n\t\tenabled = self.m_enabled\n\t\tpidInput = self.m_pidInput\n\n\t\tif enabled:\n\n\t\t input = pidInput.PIDGet()\n\n\t\t self.m_error = self.m_setpoint - input\n\t\t if self.m_continuous:\n\t\t \n\t\t if math.fabs(self.m_error) > (self.m_m...
[ "0.75438035", "0.7284141", "0.63271904", "0.60335207", "0.59820825", "0.58844215", "0.58684385", "0.58636576", "0.5832575", "0.58089423", "0.5777085", "0.57294345", "0.57272094", "0.5721611", "0.5721611", "0.5721611", "0.56734157", "0.56707466", "0.56363714", "0.5604463", "0....
0.7203142
2
Function to check if the test box is stably heated to the desired temperature.
def check_heated_up(error): error = np.array(error) error = np.abs(error) if len(error) < 30 or sum(error[-30:-1]) > 15: return False else: return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check(self, temp=None):\n if temp == None:\n temp = self._temp.get_tempC()\n # Get target temperature from file\n target_temp = env['thermostat']['targetTemp']\n msg = \"{} {} {} {}\".format(\"Temp:\", temp, \" Target Temp:\", target_temp)\n self._logger.debug(msg)...
[ "0.67318016", "0.67288387", "0.654851", "0.650819", "0.6489996", "0.6416259", "0.63839024", "0.6372449", "0.6358308", "0.62952006", "0.6276", "0.6274441", "0.6263037", "0.6260504", "0.62506723", "0.61792487", "0.61712414", "0.6156235", "0.6138915", "0.6138915", "0.6138915", ...
0.0
-1
Asks user to specify a city, month, and day to analyze.
def get_filters(): #initialize month and day (if time_filter = 'none' month and day are kept equal to zero) month = 0 day = 0 print('Hello! Let\'s explore some US bikeshare data!') #GET CITY city = input("\n Would you like to see data from Chicago, New York or Washington? \n").lower() whil...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)", "def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f...
[ "0.66714007", "0.65354675", "0.64593667", "0.6374057", "0.6348314", "0.63097656", "0.62868035", "0.6259136", "0.62316", "0.62130964", "0.62050414", "0.6181105", "0.6171822", "0.61686903", "0.6158568", "0.61582303", "0.61532456", "0.61444426", "0.6131269", "0.610484", "0.61025...
0.5775211
66
Loads data for the specified city and filters by month and day if applicable.
def load_data(city, time_filter, month, day): print("\nLoading data and preprocessing...") start_time = time.time() df = pd.read_csv(CITY_DATA[city]) #Create columns for the dataframe for convinience in calculations df['start_year'] = [int(value[0:4]) for value in df["Start Time"]] df['start...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ...
[ "0.81320685", "0.8108889", "0.8045821", "0.8042514", "0.80090284", "0.80071104", "0.79991937", "0.7998333", "0.7988789", "0.797905", "0.79737365", "0.79610896", "0.7956163", "0.7947432", "0.79463065", "0.7908287", "0.7908229", "0.7904569", "0.7900715", "0.78930074", "0.788921...
0.0
-1
Displays statistics on the most frequent times of travel.
def time_stats(df): print('\nCalculating The Most Frequent Times of Travel...\n') start_time = time.time() # Display the most common month month_mode = NUM_TO_MONTH[df['start_month'].mode()[0]] print("The most common month has been " + month_mode + ".") # Display the most common day of week ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\...
[ "0.80247396", "0.80233026", "0.7915788", "0.78266186", "0.7822246", "0.78143597", "0.77659196", "0.7740343", "0.773628", "0.77344066", "0.76867086", "0.7668633", "0.7651731", "0.7644636", "0.76399267", "0.76367253", "0.7625196", "0.7623158", "0.7612803", "0.76002145", "0.7583...
0.0
-1
Displays statistics on the most popular stations and trip.
def station_stats(df): print('\nCalculating The Most Popular Stations and Trip...\n') start_time = time.time() # Display most commonly used start station cstart_station = df['Start Station'].mode()[0] print("The most common start station has been " + cstart_station + ".") # Display most commo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m...
[ "0.7815675", "0.7662213", "0.7553417", "0.74914914", "0.74748665", "0.7446617", "0.7428588", "0.74237514", "0.74177027", "0.7400495", "0.7387161", "0.7385634", "0.73647535", "0.735934", "0.73566747", "0.73548365", "0.7351854", "0.7351274", "0.735057", "0.73421645", "0.7340198...
0.6806197
96
Displays statistics on the total and average trip duration.
def trip_duration_stats(df): print('\nCalculating Trip Duration...\n') start_time = time.time() # compute a column on the data frame having the travel time of each bike rent df['travel_time'] = df['end_sec'] - df['start_sec'] + 60*(df['end_min']-df['start_min']) + 3600*(df['end_hour']-df['start_hour']...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri...
[ "0.814274", "0.8025143", "0.80041367", "0.79496753", "0.7937415", "0.79312176", "0.7926815", "0.7915187", "0.79142886", "0.7908032", "0.79055744", "0.7900715", "0.7891682", "0.78894734", "0.7886722", "0.78851086", "0.7884266", "0.7882474", "0.78738385", "0.78686154", "0.78664...
0.0
-1
Adapted from load_file of sklearn, this loads files from directories and subdirectories
def load_files_sub(container_path, description=None, categories=None, load_content=True, shuffle=True, encoding=None, charset=None, charset_error=None, decode_error='strict', random_state=0): from os.path import isdir from os import listdir from os.path import jo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_for_sklearn(self):\n\n labels = [] # string labels\n examples = [] # examples as strings\n\n # document number -> label mapping\n doc2label = n2b2.map_patients_to_labels(\n self.xml_dir,\n self.category)\n\n for f in os.listdir(self.cui_dir):\n doc_id = f.split('.')[0]\n ...
[ "0.69829124", "0.68089914", "0.6581123", "0.639368", "0.63810444", "0.63791573", "0.6326334", "0.63139087", "0.63093185", "0.6302252", "0.6216079", "0.62111765", "0.61799574", "0.6154709", "0.61505216", "0.6145987", "0.6115458", "0.61113006", "0.6105166", "0.61003083", "0.609...
0.0
-1
Return a string representation of this hub.
def __repr__(self) -> str: return f"<Hub host={self.host} app_id={self.app_id}>"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_string(self):\n return self.__repr__()", "def serialize(self):\n\n return str(self)", "def serialize(self):\n\n\t\treturn str(self)", "def to_string(self):\r\n return self.__str__()", "def toString(self) -> str:\n raise NotImplementedError", "def __str__(self):\n ...
[ "0.76874536", "0.75883555", "0.7518112", "0.74743575", "0.74606997", "0.7375215", "0.7335236", "0.7328006", "0.7328006", "0.72803766", "0.72379076", "0.722928", "0.722928", "0.722928", "0.722928", "0.722928", "0.722928", "0.722928", "0.722928", "0.722928", "0.722928", "0.72...
0.8189225
0
Return the current hub mode.
def mode(self) -> Optional[str]: for mode in self._modes: if mode.active: return mode.name return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_mode(self):\r\n return self._api.get_mode()", "def get_mode(self) -> str:\n\n return self.send(self.cmd.GET_MODE)", "def get_mode(self):\r\n return self.mode", "def getmode(self):\n return self.mode", "def mode(self) -> str:\n return pulumi.get(self, \"mode\")", ...
[ "0.7597531", "0.7474025", "0.74090165", "0.7387282", "0.73510855", "0.73510855", "0.7252343", "0.72167367", "0.71695316", "0.71257424", "0.71257424", "0.71257424", "0.7121371", "0.7121371", "0.7106695", "0.7106695", "0.7106695", "0.7063384", "0.70419866", "0.70129037", "0.700...
0.6946213
23
Extracts ngrams from the current string if n <= len(string)
def extract_n_grams(string, n, overlap=0, unique=True): if n > len(string): return [] n_grams = [] step = n - overlap n_grams = [string[i:i+n] for i in range(0, len(string)-step+1, step)] if unique: n_grams = list(set(n_grams)) n_grams = [g+"\n" for g in n_grams] retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ngramas(n, string):\n\n ngrams = []\n i = 0\n while i + n < len(string):\n ngrams.append(string[i:i + n])\n i += 1\n\n return ngrams", "def ngrams(text, n):\n return chain(*[ngrams_(text, i) for i in range(n + 1)])", "def get_ngrams(seq, n):\n return", "def _ngrams(self, s...
[ "0.84467524", "0.7935012", "0.78996223", "0.7893587", "0.7778176", "0.76662934", "0.7563878", "0.74601954", "0.7435136", "0.74344337", "0.73883104", "0.73075396", "0.727432", "0.72036266", "0.71773434", "0.71773434", "0.7166321", "0.71659625", "0.71629286", "0.71037745", "0.7...
0.79329044
2
Test bad request to route /auth/signup
def test_register(self): # Test no username data = {'password': 'pwd', 'email': 'Josh'} data = json.dumps(data) response = self.client.post( 'api/v2/auth/signup', content_type="application/json", data=data) data = json.loads(response.data) self.assertEqual(dat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testsignup(self):\n rv = self.app.get('/signup')\n self.assertEqual(rv.status_code, 200, \"signup page did not load as expected\")", "def test_signup_when_no_data_provied(self):\n response = self.client.post('/api/v1/register')\n data = response.get_json()\n\n self.assertEq...
[ "0.7829825", "0.743015", "0.7381255", "0.7249407", "0.72054344", "0.7204305", "0.7167168", "0.7158418", "0.7111919", "0.7109361", "0.7106784", "0.70954984", "0.7045709", "0.7015991", "0.7006945", "0.6996461", "0.69855917", "0.6965271", "0.6910544", "0.68998796", "0.6895965", ...
0.64562297
79
Tests POST requests to api/v2/parcels with no token, invalid token or unauthorized user
def test_create_parcel_authentication(self): # Test no token in headers response = self.client.post( 'api/v2/parcels', data=json.dumps(mock_data['order'])) data = json.loads(response.data) self.assertEqual(data, {message: 'Token missing'}) self.assertEqual(response.st...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_create_parcel_authentication(self):\n # Test no token in headers\n response = self.client.post(\n 'api/v1/parcels', data=json.dumps(mock_data['order']))\n data = json.loads(response.data)\n self.assertEqual(data, {message: 'Token missing'})\n self.assertEqual(...
[ "0.72694004", "0.690783", "0.679436", "0.67260045", "0.64535475", "0.64454746", "0.63695604", "0.63090456", "0.6298224", "0.62966996", "0.62864226", "0.62805974", "0.6280423", "0.6260072", "0.62193733", "0.6206236", "0.6177117", "0.6173735", "0.6169496", "0.6159602", "0.61513...
0.73168087
0