text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> start_date = now + timedelta(days=-7) term.first_day_quarter = start_date.date() self.assertEquals(term.get_week_of_term(), 2, "7 days in") self.assertEquals(term.get_week_of_term_for_date(now), 2, "7 days in") start_date = now + timedelta...
code_fim
hard
{ "lang": "python", "repo": "uw-it-aca/uw-restclients-sws", "path": "/uw_sws/tests/test_term.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: uw-it-aca/uw-restclients-sws path: /uw_sws/tests/test_term.py Equals(term.get_bod_reg_period1_start(), datetime(2012, 11, 2, 0, 0, 0)) self.assertEquals(term.get_bod_reg_period2_start(), datetime(2012, 11, 26, 0, 0, 0)) self.as...
code_fim
hard
{ "lang": "python", "repo": "uw-it-aca/uw-restclients-sws", "path": "/uw_sws/tests/test_term.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: uw-it-aca/uw-restclients-sws path: /uw_sws/tests/test_term.py rter = "spring" expected_year = 2013 self.assertEquals(term.year, expected_year, "Return {} for the current year".format( expected_year)) self.assertEqua...
code_fim
hard
{ "lang": "python", "repo": "uw-it-aca/uw-restclients-sws", "path": "/uw_sws/tests/test_term.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ### Inputs _button_a = digitalio.DigitalInOut(board.BUTTON_A) _button_a.switch_to_input(pull=digitalio.Pull.UP) _button_b = digitalio.DigitalInOut(board.BUTTON_B) _button_b.switch_to_input(pull=digitalio.Pull.UP) button_left = lambda: not _button_a.value button_right = lambda: ...
code_fim
hard
{ "lang": "python", "repo": "dglaude/circuitpython-examples", "path": "/clue/clue-bar-hammer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>### TOTAL_ROUNDS = 5 TOTAL_ROUNDS = 3 CRYPTO_ALGO = "chacha20" KEY_SIZE = 8 ### in bytes KEY_ENLARGE = 256 // KEY_SIZE // 8 def evaluateRound(mine, yours): """Determine who won the game based on the two strings mine and yours. Returns three booleans (win, draw, void).""" ### Return with...
code_fim
hard
{ "lang": "python", "repo": "dglaude/circuitpython-examples", "path": "/clue/clue-bar-hammer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: dglaude/circuitpython-examples path: /clue/clue-bar-hammer.py ### Trying to recreate MemoryError with broadcastAndReceive ### v2 introduces variable buffer sizes ### Tested with CLUE and Circuit Playground Bluefruit Alpha with TFT Gizmo ### using CircuitPython and 5.3.0 ### copy this file to C...
code_fim
hard
{ "lang": "python", "repo": "dglaude/circuitpython-examples", "path": "/clue/clue-bar-hammer.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: 0x14d/PDPK path: /data_provider/synthetic_data_provider.py """ This module provides the class `SyntheticDataProvider` """ # pylint: disable=too-many-arguments, no-self-use, unused-argument, unused-variable, too-many-locals from __future__ import annotations from collections import defaultdict ...
code_fim
hard
{ "lang": "python", "repo": "0x14d/PDPK", "path": "/data_provider/synthetic_data_provider.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Parses a synthetic dataset to a list of AIPE experiments Parameters: dataset (GeneratedDataset): Synthetic dataset Returns: List of all generated experiments parsed to the AIPE format """ parsed_experiments: List[dei.ExperimentF...
code_fim
hard
{ "lang": "python", "repo": "0x14d/PDPK", "path": "/data_provider/synthetic_data_provider.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def _parse_synthetic_experiment( self, experiment: GeneratedExperiment, experiment_series: GeneratedExperimentSeries, ) -> dei.ExperimentFromDb: """ Parses a synthetic experiment to the AIPE format Parameters: experiment (GeneratedExperi...
code_fim
hard
{ "lang": "python", "repo": "0x14d/PDPK", "path": "/data_provider/synthetic_data_provider.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: angelosalatino/cso-classifier path: /cso_classifier/semanticmodule.py import warnings from kneed import KneeLocator from rapidfuzz.distance import Levenshtein from nltk import everygrams class Semantic: """ A simple abstraction layer for using the Semantic module of the CSO classifier """ ...
code_fim
hard
{ "lang": "python", "repo": "angelosalatino/cso-classifier", "path": "/cso_classifier/semanticmodule.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Args: gram (string): the n-gram found (joined) grams (list): list of tokens to be analysed and founf in the model Returns: list_of_matched_topics (list): containing of all found topics """ identified_topics = list() f...
code_fim
hard
{ "lang": "python", "repo": "angelosalatino/cso-classifier", "path": "/cso_classifier/semanticmodule.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> list_of_merged_topics = {} for gram in grams: if self.model.check_word_in_model(gram): list_of_matched_topics_t = self.model.get_words_from_model(gram) for topic_item in list_of_matched_topics_t: temp_...
code_fim
hard
{ "lang": "python", "repo": "angelosalatino/cso-classifier", "path": "/cso_classifier/semanticmodule.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: wairton/mr-ear path: /music.py SHARP_NOTES = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'] ATTR_SHARP_NOTES = ['C', 'CS', 'D', 'DS', 'E', 'F', 'FS', 'G', 'GS', 'A', 'AS', 'B'] ATTR_FLAT_NOTES = ['C', 'DF', 'D', 'EF', 'E', 'F', 'GF', 'G', 'AF', 'A', 'BF', 'B'] FLAT_NOTES = ['C'...
code_fim
hard
{ "lang": "python", "repo": "wairton/mr-ear", "path": "/music.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return self._base @base.setter def base(self, value): if not self._is_base_valid(value): raise Exception('{} is not a valid note'.format(value)) self._base = value def __lt__(self, other): return Reference.reference_to_code(self) < Reference.refere...
code_fim
hard
{ "lang": "python", "repo": "wairton/mr-ear", "path": "/music.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @property def octave(self): return self._octave @octave.setter def octave(self, value): if 0 > value or 8 < value: raise Exception('{} is not a valid octave'.format(value)) self._octave = value def _is_base_valid(self, base): return base.lo...
code_fim
hard
{ "lang": "python", "repo": "wairton/mr-ear", "path": "/music.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: phildini/django-patronage path: /patronage/migrations/0007_auto_20180926_1723.py # Generated by Django 2.1.1 on 2018-09-26 17:23 from django.conf import settings from django.db import migrations, models <|fim_suffix|> operations = [ migrations.RemoveField( model_name='ti...
code_fim
medium
{ "lang": "python", "repo": "phildini/django-patronage", "path": "/patronage/migrations/0007_auto_20180926_1723.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('patronage', '0006_auto_20180926_1720'), ] operations = [ migrations.RemoveField( model_name='tier', name='creator', ), migrations.AddField( ...
code_fim
medium
{ "lang": "python", "repo": "phildini/django-patronage", "path": "/patronage/migrations/0007_auto_20180926_1723.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Jacob-Lisner/Pneumathorax_Segmentation path: /basicAnalysis.py import os import pandas as pd import json import numpy as np import pydicom as dicom from sklearn.neural_network import MLPClassifier import tensorflow as tf from tensorflow.keras import datasets, layers, models def main(): ...
code_fim
hard
{ "lang": "python", "repo": "Jacob-Lisner/Pneumathorax_Segmentation", "path": "/basicAnalysis.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> yTest = yFull[batch_size:2*batch_size] xTest = np.zeros((batch_size,width,height,1)) for i in range(0,batch_size): img = dicom.read_file("./train_images/"+files[i+batch_size]+".dcm") xTest[i,:,:,:] = np.reshape(img.pixel_array, (width,height,1)).astype(float)/255.0 ...
code_fim
hard
{ "lang": "python", "repo": "Jacob-Lisner/Pneumathorax_Segmentation", "path": "/basicAnalysis.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def _send_all(recipients, **kwargs): for recipient in recipients: _send_single(recipient, **kwargs) def _send_single(recipient, template_path, extra_context, from_email, fail_silently, extra_headers): context = {} context.update(extra_context) context["STATIC_U...
code_fim
hard
{ "lang": "python", "repo": "cuu508/templated-emails", "path": "/templated_emails/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: cuu508/templated-emails path: /templated_emails/utils.py import logging import threading from django.core.mail import EmailMultiAlternatives from django.conf import settings from django.template import TemplateDoesNotExist from django.template.loader import render_to_string from django.contrib.a...
code_fim
hard
{ "lang": "python", "repo": "cuu508/templated-emails", "path": "/templated_emails/utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert f'{fixture_barcode_bingo75} {fixture_barcode_bingo75_2} {app.utiliz.count_range_barcode_in_util_menu()}' \ in app.utiliz.barcode_in_util_menu() app.utiliz.two_delete_barcode(fixture_barcode_bingo75, fixture_barcode_bingo75_2) app.utiliz.comeback_main_page()<|fim_prefix|># repo:...
code_fim
hard
{ "lang": "python", "repo": "FearFactor1/SPA", "path": "/test/Utilizations/bingo-75/test_add_two_barcode_bingo_75_current_draw_keyboard.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: FearFactor1/SPA path: /test/Utilizations/bingo-75/test_add_two_barcode_bingo_75_current_draw_keyboard.py # Добавить два билета на утилизацию по игре бинго 75 с помощью экранной клавиатуры def test_add_two_barcode_bingo_75_current_draw_keyboard_range(app, ...
code_fim
hard
{ "lang": "python", "repo": "FearFactor1/SPA", "path": "/test/Utilizations/bingo-75/test_add_two_barcode_bingo_75_current_draw_keyboard.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pp.utiliz.modal_one_input_ticket_barcode_keyboard(fixture_barcode_bingo75) app.utiliz.click_two_input_in_keyboard() app.utiliz.modal_two_input_ticket_barcode_keyboard(fixture_barcode_bingo75_2) app.utiliz.modal_ticket_barcode_add() app.utiliz.barcode_in_util_menu() assert f'{fixture_ba...
code_fim
hard
{ "lang": "python", "repo": "FearFactor1/SPA", "path": "/test/Utilizations/bingo-75/test_add_two_barcode_bingo_75_current_draw_keyboard.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>model = dict( generator=dict(out_size=256, fp16_enabled=True), discriminator=dict(in_size=256, fp16_enabled=False, num_fp16_scales=4), ) train_cfg = dict(max_iters=800000) optim_wrapper = dict( generator=dict(type='AmpOptimWrapper', loss_scale=512), discriminator=dict(type='AmpOptimWrapper...
code_fim
medium
{ "lang": "python", "repo": "open-mmlab/mmagic", "path": "/configs/styleganv2/stylegan2_c2-PL-R1_8xb4-fp16-globalG-partialD-no-scaler-800kiters_ffhq-256x256.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: open-mmlab/mmagic path: /configs/styleganv2/stylegan2_c2-PL-R1_8xb4-fp16-globalG-partialD-no-scaler-800kiters_ffhq-256x256.py """Config for the `config-f` setting in StyleGAN2.""" <|fim_suffix|>model = dict( generator=dict(out_size=256, fp16_enabled=True), discriminator=dict(in_size=256,...
code_fim
medium
{ "lang": "python", "repo": "open-mmlab/mmagic", "path": "/configs/styleganv2/stylegan2_c2-PL-R1_8xb4-fp16-globalG-partialD-no-scaler-800kiters_ffhq-256x256.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> level_attr = dict(standard_name="level", uints="hPa") lat_attr = dict(standard_name="lat", uints="degrees north") lon_attr = dict(standard_name="lon", uints="degrees east") ds = xr.Dataset({ "temperature":(dims,temps,temp_attr), "precipitation":...
code_fim
hard
{ "lang": "python", "repo": "go1me/python_creat_or_read_netcdf_demo", "path": "/python_netcdf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> temp_attr = dict(standard_name="air_potential_tempeature", uints="f") prcp_attr = dict(standard_name="convective_precipitation_flux", uints="mm") level_attr = dict(standard_name="level", uints="hPa") lat_attr = dict(standard_name="lat", uints="degrees north") lon...
code_fim
hard
{ "lang": "python", "repo": "go1me/python_creat_or_read_netcdf_demo", "path": "/python_netcdf.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: go1me/python_creat_or_read_netcdf_demo path: /python_netcdf.py import time import numpy as np import pandas as pd from netCDF4 import Dataset class pyton_netcdf(object): def __init__(self): pass def creat_netcdf_by_netcdf4(self,file_name_nc): ntimes = 5 nlevels ...
code_fim
hard
{ "lang": "python", "repo": "go1me/python_creat_or_read_netcdf_demo", "path": "/python_netcdf.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: alinamachidon/seq2seq_temporal_attention path: /code/S2S_att.py import chainer from chainer.links import Linear, Bilinear, EmbedID from chainer.functions import array, batch_matmul, reshape from chainer.functions.activation.lstm import lstm from chainer.functions.activation.tanh import tanh from...
code_fim
hard
{ "lang": "python", "repo": "alinamachidon/seq2seq_temporal_attention", "path": "/code/S2S_att.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def encode(self, frame, prev_word, state, dropout_flag=False, dropout_ratio=0.0): state = self.enc(frame, prev_word, state, dropout_flag, dropout_ratio) self.a_list.append(state['h1']) return state def decode(self, frame, prev_word, state, batch_size, xp): if self....
code_fim
hard
{ "lang": "python", "repo": "alinamachidon/seq2seq_temporal_attention", "path": "/code/S2S_att.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def check_ge_wrapper(self, *args): for arg in args: if isinstance(arg, numbers.Real) and arg < value: raise ValueError("Value must be greater than or equal to " + str(value)) return func(self, *args) return check_ge_wrapper re...
code_fim
hard
{ "lang": "python", "repo": "Computational-Fluid-Dynamics/Fluid-Simulation-for-Computer-Graphics", "path": "/src/pyfluid/method_decorators.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Computational-Fluid-Dynamics/Fluid-Simulation-for-Computer-Graphics path: /src/pyfluid/method_decorators.py import numbers from .fluidsimulationsavestate import FluidSimulationSaveState from .vector3 import Vector3 from .gridindex import GridIndex def ijk_or_gridindex(func): def ijk_or_grid...
code_fim
hard
{ "lang": "python", "repo": "Computational-Fluid-Dynamics/Fluid-Simulation-for-Computer-Graphics", "path": "/src/pyfluid/method_decorators.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> from scipy import sparse import matplotlib.pyplot as plt from tick.plot import plot_history import numpy as np from tick.linear_model import SimuLogReg, ModelLogReg from tick.simulation import weights_sparse_gauss from tick.solver import SVRG from tick.prox import ProxElasticNet seed = 1398 np.random.s...
code_fim
medium
{ "lang": "python", "repo": "andro2157/tick", "path": "/examples/plot_asynchronous_stochastic_solver.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: andro2157/tick path: /examples/plot_asynchronous_stochastic_solver.py """ ============================== Asynchronous stochastic solver ============================== This example illustrates the convergence speed of the asynchronous version of SVRG solver. This solver called KroMagnon has been ...
code_fim
hard
{ "lang": "python", "repo": "andro2157/tick", "path": "/examples/plot_asynchronous_stochastic_solver.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def check_subseq_range(subseq_range): """Check that a range of sequences to extract is well defined This function check: - The range is correctly built: 2 integer values separated by a - - The second value is higher than the first one :param download: range for subsequences (limit ...
code_fim
hard
{ "lang": "python", "repo": "nick-youngblut/enasearch", "path": "/enasearch/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> free_text_search, query, result, display, download=None, file=None ): """Search ENA data and get all results (not size limited) This function - Extracts the number of possible results for the query - Extracts the all the results of the query (by potentially running several time...
code_fim
hard
{ "lang": "python", "repo": "nick-youngblut/enasearch", "path": "/enasearch/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nick-youngblut/enasearch path: /enasearch/__init__.py download of data from ENA :param download: download option to specify that records are to be saved in a file (used with file option, accessible with get_download_options) :param file: filepath to save the content of the data (used wit...
code_fim
hard
{ "lang": "python", "repo": "nick-youngblut/enasearch", "path": "/enasearch/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ ('newsletter', '0011_auto_20170127_1807'), ] operations = [ migrations.AlterField( model_name='list', name='provider', field=models.CharField(max_length=32, default='mailerlite', editable=False), ), ]<|fim_prefi...
code_fim
medium
{ "lang": "python", "repo": "rogerhil/flaviabernardes", "path": "/flaviabernardes/flaviabernardes/newsletter/migrations/0012_auto_20170402_1535.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: rogerhil/flaviabernardes path: /flaviabernardes/flaviabernardes/newsletter/migrations/0012_auto_20170402_1535.py # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations <|fim_suffix|> dependencies = [ ('newsletter', '0011_auto_2017012...
code_fim
easy
{ "lang": "python", "repo": "rogerhil/flaviabernardes", "path": "/flaviabernardes/flaviabernardes/newsletter/migrations/0012_auto_20170402_1535.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: MarsPain/BiDAF_test_tf0.12 path: /test.py # test1 # import tensorflow as tf # # # temp = tf.tile([1,2,3],[2]) # # temp2 = tf.tile([[1,2],[3,4],[5,6]],[2,3]) # # # # with tf.Session() as sess: # # print(sess.run(temp)) # # print(sess.run(temp2)) # # t1 = [[[1, 2, 3], [1, 2, 3], [1, 2, 3]],...
code_fim
medium
{ "lang": "python", "repo": "MarsPain/BiDAF_test_tf0.12", "path": "/test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>a = tf.random_normal((100, 100)) b = tf.random_normal((100, 500)) c = tf.matmul(a, b) sess = tf.InteractiveSession() sess.run(c) # test3 # import tensorflow as tf # # with tf.device('gpu'): # a = tf.constant([1.0, 2.0, 3.0], shape=[3], name='a') # b = tf.constant([1.0, 2.0, 3.0], shape=[3], name=...
code_fim
medium
{ "lang": "python", "repo": "MarsPain/BiDAF_test_tf0.12", "path": "/test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: isneverdead/heroku-test path: /duck.py from selenium import webdriver import os chrome_options = webdriver.ChromeOptions() chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN") chrome_options.add_argument("--headless") chrome_options.add_argument("--disable-dev-shm-usage") chrome_...
code_fim
hard
{ "lang": "python", "repo": "isneverdead/heroku-test", "path": "/duck.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#print (search_box) #search_box.send_keys(Keys.RETURN) #submit = driver.get_element_by_id("search_button_homepage") #submit.click()<|fim_prefix|># repo: isneverdead/heroku-test path: /duck.py from selenium import webdriver import os chrome_options = webdriver.ChromeOptions() chrome_options.binary_locati...
code_fim
hard
{ "lang": "python", "repo": "isneverdead/heroku-test", "path": "/duck.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def resize(self, tensor, size): h, w = size h0, w0 = tensor.shape[2:] if h0==h and w0==w: return tensor assert h0%h==0 and w0%w==0 sh, sw = h0//h, w0//w out = nn.functional.avg_pool2d(tensor, kernel_size=(sh,sw), stride=(sh,sw)) retur...
code_fim
hard
{ "lang": "python", "repo": "yilmazdoga/lifting-2d-stylegan-for-3d-aware-face-generation", "path": "/models/perc_loss.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yilmazdoga/lifting-2d-stylegan-for-3d-aware-face-generation path: /models/perc_loss.py import torch import torch.nn as nn import torch.nn.functional as F import torchvision EPS = 1e-7 class PerceptualLoss(nn.Module): def __init__(self, requires_grad=False, loss_type='l2', n_scale=1, slice_in...
code_fim
hard
{ "lang": "python", "repo": "yilmazdoga/lifting-2d-stylegan-for-3d-aware-face-generation", "path": "/models/perc_loss.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: DigitalGlobe/gbdxtools path: /gbdxtools/images/landsat_image.py from gbdxtools.images.base import RDABaseImage from gbdxtools.images.drivers import RDADaskImageDriver from gbdxtools.images.util.image import reproject_params from gbdxtools.rda.error import IncompatibleOptions from gbdxtools.rda.in...
code_fim
hard
{ "lang": "python", "repo": "DigitalGlobe/gbdxtools", "path": "/gbdxtools/images/landsat_image.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return self.options["band_type"] @property def _rgb_bands(self): return [3,2,1] @property def _ndvi_bands(self): return [4,3] @property def _ndwi_bands(self): return[2,4] @classmethod def _build_graph(cls, _id, band_type="MS", proj=None, ...
code_fim
hard
{ "lang": "python", "repo": "DigitalGlobe/gbdxtools", "path": "/gbdxtools/images/landsat_image.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: easyopsapis/easyops-api-python path: /webshell_sdk/api/task/task_client.py # -*- coding: utf-8 -*- import os import sys import webshell_sdk.api.task.create_sync_task_pb2 import webshell_sdk.utils.http_util import google.protobuf.json_format class TaskClient(object): def __init__(self, se...
code_fim
hard
{ "lang": "python", "repo": "easyopsapis/easyops-api-python", "path": "/webshell_sdk/api/task/task_client.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> rsp_obj = webshell_sdk.utils.http_util.do_api_request( method="POST", src_name="logic.webshell_sdk", dst_name=route_name, server_ip=server_ip, server_port=self._server_port, host=self._host, uri=uri, pa...
code_fim
hard
{ "lang": "python", "repo": "easyopsapis/easyops-api-python", "path": "/webshell_sdk/api/task/task_client.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ray-project/ray path: /doc/source/serve/doc_code/fault_tolerance/sleepy_pid.py # flake8: noqa # __start__ # File name: sleepy_pid.py from ray import serve <|fim_suffix|> return os.getpid() app = SleepyPid.bind() # __end__<|fim_middle|> @serve.deployment class SleepyPid: def __init...
code_fim
medium
{ "lang": "python", "repo": "ray-project/ray", "path": "/doc/source/serve/doc_code/fault_tolerance/sleepy_pid.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> import os return os.getpid() app = SleepyPid.bind() # __end__<|fim_prefix|># repo: ray-project/ray path: /doc/source/serve/doc_code/fault_tolerance/sleepy_pid.py # flake8: noqa # __start__ # File name: sleepy_pid.py from ray import serve <|fim_middle|>@serve.deployment class Sleepy...
code_fim
medium
{ "lang": "python", "repo": "ray-project/ray", "path": "/doc/source/serve/doc_code/fault_tolerance/sleepy_pid.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Aidan-Bharath/code_and_stuffs path: /vert_shear.py from __future__ import division import numpy as np import matplotlib import netCDF4 as net from datetime import datetime from datetime import timedelta import matplotlib.pyplot as plt import matplotlib.tri as Tri import matplotlib.ticker as ticke...
code_fim
hard
{ "lang": "python", "repo": "Aidan-Bharath/code_and_stuffs", "path": "/vert_shear.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> matplotlib.rcParams['contour.negative_linestyle'] = 'solid' for i in range(vel.shape[0]): grid = Tri.Triangulation(lon,lat,triangles=nv) fig = plt.figure() plt.rc('font',size='22') ax = fig.add_subplot(111,aspect=(1.0/np.cos(np.mean(lat)*np.pi/180.0))) CS =...
code_fim
hard
{ "lang": "python", "repo": "Aidan-Bharath/code_and_stuffs", "path": "/vert_shear.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: parttimehacker/sensor-testbed path: /testbed.py #!/usr/bin/python3 """ testbed for temperature, humidity, pressure and gas sensors """ # MIT License # # Copyright (c) 2019 Dave Wilson # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associat...
code_fim
hard
{ "lang": "python", "repo": "parttimehacker/sensor-testbed", "path": "/testbed.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>try: HUMIDITY_SI7021_FEED = AIO.feeds("testsi7021humidity") except RequestError: # Doesn't exist, create a new feed FEED = Feed(name="testsi7021humidity") HUMIDITY_SI7021_FEED = AIO.create_feed(FEED) try: TEMPERATURE_DHT22_FEED = AIO.feeds("testdht22temperature") except RequestError: # Do...
code_fim
hard
{ "lang": "python", "repo": "parttimehacker/sensor-testbed", "path": "/testbed.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>""" # config.py import os from pathlib import Path # pathlib is seriously awesome! from inspect import currentframe, getframeinfo fname = getframeinfo(currentframe()).filename # current file name data_dir = Path(fname).resolve().parent.parent.parent / 'data' / 'raw' data_files = os.listdir(data_dir)...
code_fim
medium
{ "lang": "python", "repo": "jmsung/anaphase_promoting_complex", "path": "/apc/apc/.ipynb_checkpoints/config-checkpoint.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jmsung/anaphase_promoting_complex path: /apc/apc/.ipynb_checkpoints/config-checkpoint.py # -*- coding: utf-8 -*- """ Created on Wed Mar 13 11:30:05 2019 <|fim_suffix|>import os from pathlib import Path # pathlib is seriously awesome! from inspect import currentframe, getframeinfo fname = getf...
code_fim
medium
{ "lang": "python", "repo": "jmsung/anaphase_promoting_complex", "path": "/apc/apc/.ipynb_checkpoints/config-checkpoint.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rwchakra/apotoma path: /outlier_exposure_temp_folder/generate_adv.py import numpy as np import tensorflow as tf from tensorflow.keras.models import load_model import foolbox badge_size = 500 model = load_model('./model/model_outexp_cifar.h5') root = '/Users/rwiddhichakraborty/PycharmProjects/The...
code_fim
hard
{ "lang": "python", "repo": "rwchakra/apotoma", "path": "/outlier_exposure_temp_folder/generate_adv.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>advs = np.concatenate(adv).reshape((-1, 32, 32, 3)) # np.save(root+'/cifar10_base_model_adv.npy', advs) # np.save(root+'/cifar10_base_model_adv_labels.npy', adv_labels)<|fim_prefix|># repo: rwchakra/apotoma path: /outlier_exposure_temp_folder/generate_adv.py import numpy as np import tensorflow as tf fro...
code_fim
hard
{ "lang": "python", "repo": "rwchakra/apotoma", "path": "/outlier_exposure_temp_folder/generate_adv.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ssanderson/pstats-view path: /pstatsviewer/viewer.py """ A viewer for Stats objects. """ import os from IPython.display import display from ipywidgets import interactive, IntSlider import matplotlib.pyplot as plt import pandas as pd from pstats import Stats from qgrid.grid import show_grid from ...
code_fim
hard
{ "lang": "python", "repo": "ssanderson/pstats-view", "path": "/pstatsviewer/viewer.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def _interact(count, sort_by): data = self._get_timing_data(count, sort_by, fields) self._show_timing_data( data.ix[::-1, sort_by], sort_by, **mpl_kwargs ) return interactive( _interact, ...
code_fim
hard
{ "lang": "python", "repo": "ssanderson/pstats-view", "path": "/pstatsviewer/viewer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def compare_table(self, other, lsuffix='_l', rsuffix='_r'): left = self.timings[self.default_view_fields] right = other.timings[self.default_view_fields] return self._show_table( left.join( right, lsuffix=lsuffix, rs...
code_fim
hard
{ "lang": "python", "repo": "ssanderson/pstats-view", "path": "/pstatsviewer/viewer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: OpposedOak/mypyladies_sqlite path: /data_sources.py """Links to data sources on chmi pages""" average_temperature_prefix = "https://www.chmi.cz/files/portal/docs/meteo/ok/denni_data/T-AVG/" source_files = { "Jihocesky": [ "C2BYNO01_T_N.csv.zip", ...
code_fim
hard
{ "lang": "python", "repo": "OpposedOak/mypyladies_sqlite", "path": "/data_sources.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ], "Ustecky":[ "U1SNEZ01_T_N.csv.zip", "U2VARN01_T_N.csv.zip", ], }<|fim_prefix|># repo: OpposedOak/mypyladies_sqlite path: /data_sources.py """Links to data sources on chmi pages""...
code_fim
hard
{ "lang": "python", "repo": "OpposedOak/mypyladies_sqlite", "path": "/data_sources.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> elif n not in lista: lista.append(n) print('Adicionado.') r = input('Continuar? [S/N] ') if r.lower() == 'n': print(lista) break<|fim_prefix|># repo: beatrizflorenccio/Studies-Python path: /Exercicios/listas_num.py #MaBe lista = [] while Tru...
code_fim
medium
{ "lang": "python", "repo": "beatrizflorenccio/Studies-Python", "path": "/Exercicios/listas_num.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: beatrizflorenccio/Studies-Python path: /Exercicios/listas_num.py #MaBe lista = [] while True: n = int(input('Digite um valor: ')) <|fim_suffix|> elif n not in lista: lista.append(n) print('Adicionado.') r = input('Continuar? [S/N] ') if r.lower() == 'n'...
code_fim
medium
{ "lang": "python", "repo": "beatrizflorenccio/Studies-Python", "path": "/Exercicios/listas_num.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> nums2[j]]) if j + 1 < n: heapq.heappush(heap, (nums1[i] + nums2[j + 1], i, j + 1)) return res<|fim_prefix|># repo: jxhangithub/leetcode path: /solutions/python3/373.py class Solution: def kSmallestPairs(self, nums1, nums2, k): if not nums1 or not nums2: return [] ...
code_fim
hard
{ "lang": "python", "repo": "jxhangithub/leetcode", "path": "/solutions/python3/373.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jxhangithub/leetcode path: /solutions/python3/373.py class Solution: def kSmallestPairs(self, nums1, nums2, k): if not nums1 or not nums2: return [] n, res, cnt, heap = len(nums2), [], 0, [(nums1[i] + nums2[0], i, 0) for i in range(len(nums1))] while h<|fim_suffix|> nu...
code_fim
hard
{ "lang": "python", "repo": "jxhangithub/leetcode", "path": "/solutions/python3/373.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>while 1: a = 1 break print a if 0: # this is only an error if the code gets hit: print not_defined<|fim_prefix|># repo: jmgc/pyston path: /test/tests/20.py # Programs are well-defined even if they contain potentially-undefined variables # The exceptions are well-defined too, but I don't ...
code_fim
medium
{ "lang": "python", "repo": "jmgc/pyston", "path": "/test/tests/20.py", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: jmgc/pyston path: /test/tests/20.py # Programs are well-defined even if they contain potentially-undefined variables # The exceptions are well-defined too, but I don't support that yet <|fim_suffix|>if 0: # this is only an error if the code gets hit: print not_defined<|fim_middle|>if 1: ...
code_fim
medium
{ "lang": "python", "repo": "jmgc/pyston", "path": "/test/tests/20.py", "mode": "psm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> queryset = Persona.objects.all() serializer_class = PersonaSerializer<|fim_prefix|># repo: jhonnyperalta/trivago-serve path: /core/views/persona_view.py from ..models import Persona from rest_framework import serializers, viewsets from rest_framework import permissions from django.db.models impor...
code_fim
medium
{ "lang": "python", "repo": "jhonnyperalta/trivago-serve", "path": "/core/views/persona_view.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jhonnyperalta/trivago-serve path: /core/views/persona_view.py from ..models import Persona from rest_framework import serializers, viewsets from rest_framework import permissions from django.db.models import Q from operator import __or__ as OR from functools import reduce class PersonaSerializ...
code_fim
medium
{ "lang": "python", "repo": "jhonnyperalta/trivago-serve", "path": "/core/views/persona_view.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if __name__ == '__main__': s = Solution() print s.maxScoreWords(["dog","cat","dad","good"], ["a","a","c","d","d","d","g","o","o"], [1,0,9,5,0,0,3,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0]) print s.maxScoreWords(["xxxz","ax","bx","cx"], ["z","a","b","c","x","x","x"], [4,4,4,0,0,0,0,0,0,0,0,0,0,0,...
code_fim
hard
{ "lang": "python", "repo": "windard/leeeeee", "path": "/maximum-score-words-formed-by-letters.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for key, value in data.items(): if l_data.get(key, 0) < value: return False return True def count_score(self, total, score): count = 0 for w in total: for t in w: count += score[ord(t) - ord('a')] return c...
code_fim
hard
{ "lang": "python", "repo": "windard/leeeeee", "path": "/maximum-score-words-formed-by-letters.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: windard/leeeeee path: /maximum-score-words-formed-by-letters.py # coding=utf-8 class Solution(object): def maxScoreWords(self, words, letters, score): """ :type words: List[str] :type letters: List[str] :type score: List[int] :rtype: int """ ...
code_fim
hard
{ "lang": "python", "repo": "windard/leeeeee", "path": "/maximum-score-words-formed-by-letters.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if(model_manager.is_valid()): num_steps = int(T/sampling_dt) # Get the OD Matrix form Model Manager # OD Matrix can also be initialized from another source, as long as it fits the OD_Matrix class format OD_Matrix = model_manager.get_OD_Matrix(num_st...
code_fim
hard
{ "lang": "python", "repo": "ugirumurera/TA_solver", "path": "/python/Runner_OTM.py", "mode": "spm", "license": "BSD-3-Clause-LBNL", "source": "the-stack-v2" }
<|fim_prefix|># repo: ugirumurera/TA_solver path: /python/Runner_OTM.py from __future__ import division import os import inspect from Model_Manager.OTM_Model_Manager import OTM_Model_Manager_class from Java_Connection import Java_Connection from Solvers.Solver_Class import Solver_class import argparse from Data_Types....
code_fim
hard
{ "lang": "python", "repo": "ugirumurera/TA_solver", "path": "/python/Runner_OTM.py", "mode": "psm", "license": "BSD-3-Clause-LBNL", "source": "the-stack-v2" }
<|fim_prefix|># repo: pezzdoge/BrightID-AntiSybil path: /anti_sybil/tests/24_hours_test.py import xmltodict import requests import os from anti_sybil import algorithms from anti_sybil.utils import * BACKUP_URL = 'http://storage.googleapis.com/brightid-backups/' OUTPUT_FOLDER = './outputs/24_hours_test/' def main():...
code_fim
hard
{ "lang": "python", "repo": "pezzdoge/BrightID-AntiSybil", "path": "/anti_sybil/tests/24_hours_test.py", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> outputs.append(generate_output( ranker.graph, 'SybilRank\n{}'.format(l[1]))) draw_graph(ranker.graph, os.path.join( OUTPUT_FOLDER, 'graph{}.html'.format(i))) write_output_file(outputs, os.path.join( OUTPUT_FOLDER, 'result.csv')) for n in scores_dic:...
code_fim
hard
{ "lang": "python", "repo": "pezzdoge/BrightID-AntiSybil", "path": "/anti_sybil/tests/24_hours_test.py", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> def test_handle_sns_message(): responder = MagicMock() responder.return_value = True message_consumer = handle_sns_message(responder) message_consumer({ "Records": [{ 'Sns': { 'Message': "message" } }] }, {}) responder.ass...
code_fim
hard
{ "lang": "python", "repo": "joelstevenson/xavier", "path": "/tests/test_aws_sns.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: joelstevenson/xavier path: /tests/test_aws_sns.py import pytest from unittest.mock import patch, MagicMock from xavier.aws.sns import publish_sns_message, handle_sns_message def test_publish_sns_event(): TEST_ARN = 'arn:abc' TEST_MESSAGE = "message" with patch('xavier.aws.sns.send...
code_fim
hard
{ "lang": "python", "repo": "joelstevenson/xavier", "path": "/tests/test_aws_sns.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> responder = MagicMock() responder.return_value = True message_consumer = handle_sns_message(responder) message_consumer({ "Records": [{ 'Sns': { 'Message': "message" } }] }, {}) responder.assert_called_once_with("message")<...
code_fim
hard
{ "lang": "python", "repo": "joelstevenson/xavier", "path": "/tests/test_aws_sns.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Abhinavl3v3l/drishtypy_2 path: /data/does_augmentation.py import albumentations as A from torchvision import transforms import numpy as np from drishtypy.data.data_utils import find_stats from albumentations.pytorch import ToTensor import cv2 ''' # A.Resize(input_size,input_size), # A.CoarseDropo...
code_fim
hard
{ "lang": "python", "repo": "Abhinavl3v3l/drishtypy_2", "path": "/data/does_augmentation.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> train_transforms = AlbumCompose(train_albumentation_transform) # Test Phase transformation test_transforms = transforms.Compose([ transforms.ToTensor(), transforms.Normalize(tuple(mean), tuple(stdev)) ]) return train_transforms, test_transforms<|fim_prefix|># repo: Ab...
code_fim
hard
{ "lang": "python", "repo": "Abhinavl3v3l/drishtypy_2", "path": "/data/does_augmentation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def get_data_transform(path): mean, stdev = find_stats(path) input_size = 32 train_albumentation_transform = A.Compose([ # CoarseDropout(max_holes=3, max_height=8, max_width=8, min_holes=None, min_height=None, min_width=None, # fill_value=[i * 255 for i in mea...
code_fim
medium
{ "lang": "python", "repo": "Abhinavl3v3l/drishtypy_2", "path": "/data/does_augmentation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mtshrmn/horrible-downloader path: /test/test_parser.py import os import sys import pytest from httmock import urlmatch, HTTMock # from urllib.parse import parse_qs sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from HorribleDownloader import Parser TEST_DIR_PAT...
code_fim
hard
{ "lang": "python", "repo": "mtshrmn/horrible-downloader", "path": "/test/test_parser.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for batch in batches: assert batch["title"] == title has_magnet = [] for resolution in "480", "720", "1080": assert resolution in batch has_magnet.append("Magnet" in batch[resolution]) assert has_magnet == sorted(has_magnet, reverse=True) ...
code_fim
hard
{ "lang": "python", "repo": "mtshrmn/horrible-downloader", "path": "/test/test_parser.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for code in self.code_blocks: try: yield self.execute_code(code, event=event_dict) except Exception as e: self.log.exception('Code execution error: %s', e) for job in self.jobs: ...
code_fim
hard
{ "lang": "python", "repo": "daniel-covelli/jaffle", "path": "/jaffle/app/watchdog/handler.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: daniel-covelli/jaffle path: /jaffle/app/watchdog/handler.py # -*- coding: utf-8 -*- from pathlib import Path from tornado import gen from watchdog.events import PatternMatchingEventHandler def _event_to_dict(event): """ Converts an Watchdog filesystem event to a dict. Parameters ...
code_fim
hard
{ "lang": "python", "repo": "daniel-covelli/jaffle", "path": "/jaffle/app/watchdog/handler.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self._timeout = None self._in_throttle = False def on_any_event(self, event): """ Event handler for Watchdog filesystem events. Executes the handling in the main ioloop. Parameters ---------- event : watchdog.events.FileSystemEvent ...
code_fim
hard
{ "lang": "python", "repo": "daniel-covelli/jaffle", "path": "/jaffle/app/watchdog/handler.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # Do not save self.replay_buffer since it's a duplicate and seems to # cause joblib recursion issues. return dict( train_replay_buffer=self.train_replay_buffer, validation_replay_buffer=self.validation_replay_buffer, fraction_paths_in_train=self....
code_fim
hard
{ "lang": "python", "repo": "google-research/DBAP-algorithm", "path": "/third_party/rlkit_library/rlkit/data_management/split_buffer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def terminate_episode(self, *args, **kwargs): self.replay_buffer.terminate_episode(*args, **kwargs) self._randomly_set_replay_buffer() def _randomly_set_replay_buffer(self): if random.random() <= self.fraction_paths_in_train: self.replay_buffer = self.train_rep...
code_fim
hard
{ "lang": "python", "repo": "google-research/DBAP-algorithm", "path": "/third_party/rlkit_library/rlkit/data_management/split_buffer.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: google-research/DBAP-algorithm path: /third_party/rlkit_library/rlkit/data_management/split_buffer.py # Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the L...
code_fim
hard
{ "lang": "python", "repo": "google-research/DBAP-algorithm", "path": "/third_party/rlkit_library/rlkit/data_management/split_buffer.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def rotated_array_search_recursive(input_list, number, begin_index, end_index): current_index = (begin_index + end_index) // 2 begin = input_list[begin_index] mid = input_list[current_index] end = input_list[end_index] if mid > begin and mid > end: # left is sorted and right...
code_fim
hard
{ "lang": "python", "repo": "qiyangjie/Udacity-Data-Structures-Algorithm-Projects", "path": "/project3/rotated_array_search.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_function(test_case): input_list = test_case[0] number = test_case[1] if linear_search(input_list, number) == rotated_array_search(input_list, number): print("Pass") else: print("Fail") if __name__ == '__main__': test_function([[6, 7, 8, 9, 10, 1, 2, 3, 4], 6...
code_fim
hard
{ "lang": "python", "repo": "qiyangjie/Udacity-Data-Structures-Algorithm-Projects", "path": "/project3/rotated_array_search.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: qiyangjie/Udacity-Data-Structures-Algorithm-Projects path: /project3/rotated_array_search.py def ordered_array_search_recursive(input_list, number, begin_index, end_index): if input_list[begin_index] == number: return begin_index if end_index - begin_index <= 0: return -...
code_fim
hard
{ "lang": "python", "repo": "qiyangjie/Udacity-Data-Structures-Algorithm-Projects", "path": "/project3/rotated_array_search.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for buffer, transition in zip(self.buffers, transition_list): buffer.extend([transition]) def build_controller(self): return A2CController(self.envs.observation_space.shape[0], self.envs.action_space.n, **self._controller_args, ...
code_fim
hard
{ "lang": "python", "repo": "abilashananthula/torchrl", "path": "/examples/a2c.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: abilashananthula/torchrl path: /examples/a2c.py from kondo import Spec import torch from torchrl.experiments import BaseExperiment from torchrl.utils.storage import TransitionTupleDataset from torchrl.contrib.controllers import A2CController class A2CExperiment(BaseExperiment): def __init__(s...
code_fim
hard
{ "lang": "python", "repo": "abilashananthula/torchrl", "path": "/examples/a2c.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> buffer.truncate() all_transitions = [torch.cat(t, dim=0) for t in all_transitions] all_returns = torch.cat(all_returns, dim=0) return self.controller.learn(*all_transitions, all_returns) @staticmethod def spec_list(): return [ Spec( group='a2c', ...
code_fim
hard
{ "lang": "python", "repo": "abilashananthula/torchrl", "path": "/examples/a2c.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }