Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given snippet: <|code_start|> :return: True if two list are equal False if two lists are different """ if len(message.words) != template.get_length(): return False for index in range(0, template.get_length()): if template.token[index] == "*" or template.token[index] == ...
def remove_sub_templates(chromosome: Chromosome, cluster_id: int):
Based on the snippet: <|code_start|> """ This utility contains methods used to control the templates """ def compute_matched_lines(messages: dict, template: Template): # if the templates has not be changed # we don't need to recompute the list of matched lines if not template.is_changed()...
def match(message: Message, template: Template):
Using the snippet: <|code_start|> random.seed(0) def check_variable_parts(chromosome: Chromosome, messages: dict): """ checks each variable element in a template agiants the values of the matched lines :param chromosome: the chromosome with the templates :param messages: the original log messages...
def is_all_star_template(template: Template):
Given snippet: <|code_start|> def match_event(self, event_list): match_list = [] paras = [] if self.n_workers == 1: results = match_fn(event_list, self.template_match_dict, self.optimized) else: pool = mp.Pool(processes=self.n_workers) chunk_...
loader = logloader.LogLoader(self.logformat, self.n_workers)
Next line prediction: <|code_start|>firestore_client = firestore.Client() def add_product(product): """ Helper function for adding a product. Parameters: product (Product): A Product object. Output: The ID of the product. """ product_id = uuid.uuid4().hex firestore_client....
return Product.deserialize(product)
Continue the code snippet: <|code_start|> Parameters: product_ids (List[str]): A list of product IDs. Output: The total price. """ total = 0 for product_id in product_ids: product = get_product(product_id) total += product.price return total def get_promos(): ...
entry = PromoEntry.deserialize(result)
Next line prediction: <|code_start|># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ A collection of helper functions for cart related operations. """ firestore_client = firestore....
item = CartItem.deserialize(result)
Continue the code snippet: <|code_start|>firestore = firestore.Client() def add_order(order): """ Helper function for adding an order. Parameters: order (Order): An Order object. Output: The ID of the order. """ order_id = uuid.uuid4().hex firestore.collection('orders').doc...
return Order.deserialize(order_data)
Next line prediction: <|code_start|> if self.pi_0 is None: self.pi_0 = market.JLT_pi if self.recovery_rate is None: self.recovery_rate = market.recovery_rate spread_list, col_index, row_index = self.market_spread def f(pi_0): return function_o...
dw = generator_correlated_variables(corr_matrix = self.corr_matrix, time_horizon = self.time_horizon, fixed_seed = self.fixed_seed)
Predict the next line for this snippet: <|code_start|> zcb_curves = pickle.load(input) self.spot_rate = zcb_curves[self.beta] if self.gamma is not None: with open(r'data\pickle\adjusted_gamma_zcb_curves.pkl', 'rb') as input: zcb_curves = pickle.load(in...
dw = generator_correlated_variables(corr_matrix = self.corr_matrix, time_horizon = self.time_horizon, fixed_seed = self.fixed_seed)
Predict the next line after this snippet: <|code_start|> if self.sigma is None: self.sigma = market.vol_IR_rate self.spot_rate = market.spot_rates # ===================================== if self.alpha is not None: with open(r'data\pickle\adjusted_alpha...
derivf = diff(self.forward_rate, range(len(self.forward_rate)))
Continue the code snippet: <|code_start|> 1. traj_i: Type: int Function: the i-th economic scenario 2. time_step: Type: int Function: valuation date """ # ======================================...
self.balance_sheets.append(Balance_Sheets())
Continue the code snippet: <|code_start|> Attributes: =========== 1. model_points: Type: array Function: collection of the model points characterized by its id. Methods: ======== 1. update: """ def __init__(self): self.model_point...
mdp = Model_Point()
Given the following code snippet before the placeholder: <|code_start|> if self.pi_0 is None: self.pi_0 = market.JLT_pi if self.recovery_rate is None: self.recovery_rate = market.recovery_rate spread_list, col_index, row_index = self.market_spread def f(p...
dw = generator_correlated_variables(corr_matrix = self.corr_matrix, time_horizon = self.time_horizon, fixed_seed = self.fixed_seed)
Continue the code snippet: <|code_start|> def get_EQ_prices(self, initial_value, market_equity_shock = 0.): """ Method: get_EQ_prices Function: return 1. EQ_prices: (Type: array) normalised equity prices 2. EQ_book_value (Type: array) normali...
dw = generator_correlated_variables(corr_matrix = self.corr_matrix, time_horizon = self.time_horizon, fixed_seed = self.fixed_seed)
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- """ Created on Mon Jul 25 22:57:32 2016 @author: Quang Dien DUONG """ ### Progam packages ### Python packages Working_URL = r'Feuille_de_calcul_ALM(Working).xlsm' @xw.func def PCA_swap(): # ============================================================...
eigenvalues, eigenvectors, VL1, VL2, VL3, alpha_min, alpha_max, beta_min, beta_max, gamma_min, gamma_max, maturities = pca_swap_rate(Working_URL)
Given the code snippet: <|code_start|> def test_generator_correlated_variables(): corr_matrix = np.array([ [ 1., 0.2, 0.9], [ 0.2, 1., 0.5], [ 0.9, 0.5, 1.] ]) time_horizon = 1000 fixed_seed = 1000 <|code_end|> , generate the next line using the imports in this file: import ...
dw = generator_correlated_variables(corr_matrix = corr_matrix, time_horizon = time_horizon, fixed_seed = fixed_seed)
Given the code snippet: <|code_start|> sheet = wb.sheet_by_name(sheet_name) number_of_rows = sheet.nrows number_of_cols = sheet.ncols for col in range(1, number_of_cols): morta_list = [] sexe = str(sheet.cell(0,col).value) for row in range(1, number_of_...
mp = Model_Point()
Next line prediction: <|code_start|> def __init__(self, db_base_url): self.tx_base_url = db_base_url + '/db/data/transaction' def begin_tx(self, op): tx_open_url = self.tx_base_url try: # # [!] neo4j seems picky about receiving an additional empty statement list...
raise Neo4JException(op.error_set)
Here is a snippet: <|code_start|> """ Main application load function. [!] Do not use as a flask endpoint as multiple functions redirect here """ # fetch rz_username for welcome message email_address = session.get('username') rz_username = "Anonymous Stranger" role_set = [] if None !...
return common_resp_handle__client_error(status=404)
Based on the snippet: <|code_start|> req, req_data = self._json_post(c, '/api/rzdoc/search', {'search_query': self.rzdoc_name}) self.assertEqual(req.status_code, 200) self.assertIn(self.rzdoc_name, req_data["data"]) self.assertEqual(req_data["error"], None) def test_...
op = DBO_raw_query_set(q)
Continue the code snippet: <|code_start|> note = req_dict['note'] img = decode_base64_uri(req_dict['img']) html = req_dict['html'] user_agent = req_dict['browser']['userAgent'] return RZ_User_Feedback(url=url, note=note, ...
send_email__flask_ctx(recipients=[current_app.rz_config.feedback_recipient],
Given the following code snippet before the placeholder: <|code_start|> self.html = html self.user_agent = user_agent def decode_base64_uri(base64_encoded_data_uri): start = base64_encoded_data_uri.find(',') + 1 encoded = base64_encoded_data_uri[start:] return base64.decodestring(encoded) d...
return make_response__json(status=400) # bad Request
Predict the next line for this snippet: <|code_start|> try: u_feedback = sanitize_input(request) except: log.warn('failed to sanitize inputs. request: %s' % request) return make_response__json(status=400) # bad Request # FIXME: should be async via celery (or another method) sess...
return make_response__json(status=HTTP_STATUS__500_INTERNAL_SERVER_ERROR)
Continue the code snippet: <|code_start|> Missing: this loses all the history. no user recorded for newly created doc """ global kernel destination = kernel.rzdoc__create(rzdoc_name) ctx = namedtuple('Context', ['user_name', 'rzdoc'])(None, destination) kernel.diff_commit__topo(c...
result = Topo_Diff()
Predict the next line after this snippet: <|code_start|> ret_data = __response_wrap(data, error_str) resp_payload = json.dumps(ret_data) resp = Response(resp_payload, mimetype='application/json', status=status) resp.headers['Access-Control-Allow-Origin'] = '*' # more response processing return r...
except RZDoc_Exception__not_found as e:
Continue the code snippet: <|code_start|> def dst_id(self): return self['__dst_id'] @staticmethod def link_ptr(src_id=None, dst_id=None): """ init from src_id or dst_id attributes - at least one must be provided """ return Link.Link_Ptr(src_id, dst_id) class ...
return str_to_unicode('rzdoc: name: %s') % (self.name)
Predict the next line after this snippet: <|code_start|> class RZCommit(): """ Rhizi Commit object Currently this object is substituted by either a diff object, this currently acts as a model stub. """ @staticmethod def diff_obj_from_blob(blob): """ @return json.loads(g...
if not python2:
Continue the code snippet: <|code_start|> user_db = current_app.user_db existing_account = None try: _, existing_account = user_db.lookup_user__by_email_address(us_req['email_address']) except Exception as _: pass # thrown if user was not found, expected if None != existing_account...
pw_hash = hash_pw(str(plaintxt_pw), salt)
Given the code snippet: <|code_start|> log.warning('user sign-up: request not found or bad token: remote-address: %s' % (request.remote_addr)) return render_template('user_signup.html', state='activation_failure') else: # no validation token: new user return render_template(...
send_email__flask_ctx(recipients=[us_req['email_address']],
Here is a snippet: <|code_start|> if su_req.has_expired(): log.info('user sign-up request expired: %s' % (su_req)) del us_req_map[su_req_email] def filter_expired__pw_rst_requests(pw_rst_req_map): for pw_rst_tok, pw_rst_req in pw_rst_req_map.items(): if pw_rst_req.has_expire...
return make_response__json(status=HTTP_STATUS__401_UNAUTORIZED) # return empty response
Given snippet: <|code_start|> if None == pw_rst_req: # request expired & already removed OR bad token log.warning('pw reset: request not found or bad token: remote-address: %s' % (request.remote_addr)) return render_template('pw_reset.html', pw_rst_step='gener...
return make_response__json__html(status=HTTP_STATUS__500_INTERNAL_SERVER_ERROR, html_str=html_err__tech_difficulty)
Predict the next line for this snippet: <|code_start|> def get_or_init_usreq_map(): """ lazy user signup request map getter """ if not hasattr(current_app, 'usreq_email_to_req_map'): setattr(current_app, 'usreq_email_to_req_map', {}) us_req_map = current_app.usre...
return make_response__json__html(status=HTTP_STATUS__400_BAD_REQUEST, html_str='<p>%s</p>' % (e.caller_err_msg))
Given the code snippet: <|code_start|> if None == pw_rst_req: # request expired & already removed OR bad token log.warning('pw reset: request not found or bad token: remote-address: %s' % (request.remote_addr)) return render_template('pw_reset.html', pw_rst_st...
return make_response__json__html(status=HTTP_STATUS__500_INTERNAL_SERVER_ERROR, html_str=html_err__tech_difficulty)
Based on the snippet: <|code_start|> email_address = req_json['email_address'] p = req_json['password'] return email_address, p if request.method == 'POST': try: email_address, p = sanitize_input(request) except: log.warn('failed to sanitize inputs. re...
return make_response__json(status=HTTP_STATUS__200_OK) # return empty response
Next line prediction: <|code_start|> if su_req.has_expired(): log.info('user sign-up request expired: %s' % (su_req)) del us_req_map[su_req_email] def filter_expired__pw_rst_requests(pw_rst_req_map): for pw_rst_tok, pw_rst_req in pw_rst_req_map.items(): if pw_rst_req.has_exp...
return make_response__json(status=HTTP_STATUS__401_UNAUTORIZED) # return empty response
Given the following code snippet before the placeholder: <|code_start|> points = count(start=1) names = ('challenge {}'.format(i) for i in(count(start=1))) keys = ('challenge {}'.format(i) for i in(count(start=1))) class ChallengeAutoFixture(AutoFixture): field_values = { 'points': generators.Callable...
register(Challenge, ChallengeAutoFixture)
Continue the code snippet: <|code_start|> class RegistrationTestCase(TestCase, SimpleTestCase): def setUp(self): self.client = Client() self.user = get_user_model().objects.create_user( 'username', 'username@username.it', 'u1u2u3u4' ) self.tmp_us...
UserProfile.objects.create(
Given the following code snippet before the placeholder: <|code_start|> ) start = instance.created_at solved.datetime = start + (now() - start) * random.random() solved.save() # random image """ gender = 'men' if instance.gender == 'M' else 'women...
register(UserProfile, UserProfileAutoFixture)
Here is a snippet: <|code_start|> class UserAutoFixture(AutoFixture): field_values = { 'username': generators.ChoicesGenerator(choices=user_usernames), 'password': generators.StaticGenerator(make_password('demo')), 'first_name': generators.ChoicesGenerator(choices=user_first_names), ...
teams = cycle(iter(Team.objects.exclude(name='admin')))
Predict the next line for this snippet: <|code_start|> class UserAutoFixture(AutoFixture): field_values = { 'username': generators.ChoicesGenerator(choices=user_usernames), 'password': generators.StaticGenerator(make_password('demo')), 'first_name': generators.ChoicesGenerator(choices=us...
return SKILLS_SEPARATOR.join([user_profiles_skills[i] for i in randIndex])
Predict the next line for this snippet: <|code_start|> class UserAutoFixture(AutoFixture): field_values = { 'username': generators.ChoicesGenerator(choices=user_usernames), 'password': generators.StaticGenerator(make_password('demo')), <|code_end|> with the help of current file imports: import...
'first_name': generators.ChoicesGenerator(choices=user_first_names),
Next line prediction: <|code_start|> class UserAutoFixture(AutoFixture): field_values = { 'username': generators.ChoicesGenerator(choices=user_usernames), 'password': generators.StaticGenerator(make_password('demo')), 'first_name': generators.ChoicesGenerator(choices=user_first_names), <...
'last_name': generators.ChoicesGenerator(choices=user_last_names),
Using the snippet: <|code_start|> class UserAutoFixture(AutoFixture): field_values = { 'username': generators.ChoicesGenerator(choices=user_usernames), 'password': generators.StaticGenerator(make_password('demo')), 'first_name': generators.ChoicesGenerator(choices=user_first_names), ...
'name': generators.ChoicesGenerator(choices=team_names),
Here is a snippet: <|code_start|> class UserAutoFixture(AutoFixture): field_values = { 'username': generators.ChoicesGenerator(choices=user_usernames), 'password': generators.StaticGenerator(make_password('demo')), 'first_name': generators.ChoicesGenerator(choices=user_first_names), ...
randIndex = random.sample(range(len(user_profiles_skills)), random.randint(2,5))
Here is a snippet: <|code_start|> } class TeamAutoFixture(AutoFixture): field_values = { 'name': generators.ChoicesGenerator(choices=team_names), 'created_by_id': 1 } teams = cycle(iter(Team.objects.exclude(name='admin'))) def set_skill(*args, **kwargs): randIndex = random.sample(ra...
for challenge in Challenge.objects.filter(pk__gt=instance.pk):
Using the snippet: <|code_start|> class TeamAutoFixture(AutoFixture): field_values = { 'name': generators.ChoicesGenerator(choices=team_names), 'created_by_id': 1 } teams = cycle(iter(Team.objects.exclude(name='admin'))) def set_skill(*args, **kwargs): randIndex = random.sample(range(le...
solved = ChallengeSolved.objects.create(
Predict the next line for this snippet: <|code_start|> class ChallengeAdminForm(forms.ModelForm): class Meta: model = Challenge widgets = { 'description': TinyMCE(mce_attrs={'width': 800}) } fields = '__all__' class CategoryAdminForm(forms.ModelForm): class Meta: ...
model = Hint
Next line prediction: <|code_start|> class ChallengeAdminForm(forms.ModelForm): class Meta: model = Challenge widgets = { 'description': TinyMCE(mce_attrs={'width': 800}) } fields = '__all__' class CategoryAdminForm(forms.ModelForm): class Meta: model = Cate...
model = Attachment
Given snippet: <|code_start|> model = Category widgets = { 'description': TinyMCE(mce_attrs={'width': 800}) } fields = '__all__' class HintAdmin(admin.TabularInline): model = Hint fieldsets = (None, {'fields': ('text',)}), can_delete = True class AttachmentAdmin...
@admin.register(ChallengeSolved)
Next line prediction: <|code_start|> class ChallengeAdminForm(forms.ModelForm): class Meta: model = Challenge widgets = { 'description': TinyMCE(mce_attrs={'width': 800}) } fields = '__all__' class CategoryAdminForm(forms.ModelForm): class Meta: <|code_end|> . Use c...
model = Category
Given the code snippet: <|code_start|> class UserScoreTest(TestCase): def setUp(self): test_category = Category.objects.create(name='test') country = Country.objects.create(name='Italy') # create 9 users: u0, u1, ... u8 self.users = [get_user_model().objects.create_user( ...
self.teams = [Team.objects.create(
Given the following code snippet before the placeholder: <|code_start|> class UserScoreTest(TestCase): def setUp(self): test_category = Category.objects.create(name='test') country = Country.objects.create(name='Italy') # create 9 users: u0, u1, ... u8 self.users = [get_user_mode...
UserProfile.objects.create(user=u, job='job', gender='M', country=country, team=next(teams_users))
Given snippet: <|code_start|> class UserScoreTest(TestCase): def setUp(self): test_category = Category.objects.create(name='test') country = Country.objects.create(name='Italy') # create 9 users: u0, u1, ... u8 self.users = [get_user_model().objects.create_user( 'u{}'...
Challenge.objects.create(name='c{}'.format(i), points=i, category=test_category)
Given snippet: <|code_start|> country = Country.objects.create(name='Italy') # create 9 users: u0, u1, ... u8 self.users = [get_user_model().objects.create_user( 'u{}'.format(i), 'u{}@test.com'.format(i), 'u1u2u3u4' ) for i in range(9)] # crea...
ChallengeSolved.objects.create(user=u.profile, challenge=c)
Based on the snippet: <|code_start|> def index(request): countries = Country.objects\ .annotate(num_user=Count('userprofile'))\ .filter(num_user__gt=0) parameters = { 'users_count': get_user_model().objects.count(), <|code_end|> , predict the immediate next line with the help of imports:...
'teams_count': Team.objects.count(),
Using the snippet: <|code_start|> class ChallengeSolverSerializer(serializers.Serializer): challenge = serializers.IntegerField() key = serializers.CharField() def create(self, validated_data): pass class ChallengeSolvedSerializer(serializers.ModelSerializer): key = serializers.CharField() ...
model = Team
Given the code snippet: <|code_start|> class ChallengeSolverSerializer(serializers.Serializer): challenge = serializers.IntegerField() key = serializers.CharField() def create(self, validated_data): pass class ChallengeSolvedSerializer(serializers.ModelSerializer): key = serializers.CharFie...
model = UserTeamRequest
Given snippet: <|code_start|> class ChallengeSolverSerializer(serializers.Serializer): challenge = serializers.IntegerField() key = serializers.CharField() def create(self, validated_data): pass class ChallengeSolvedSerializer(serializers.ModelSerializer): key = serializers.CharField() ...
model = ChallengeSolved
Based on the snippet: <|code_start|> class LoggedInUserWithoutProfileMiddleware(FilterRequestMiddlewareMixin): allowed_paths = [ reverse_lazy('logout') ] def custom_filter(self, request): return not hasattr(request.user, 'profile') def response(self, request): return curry(ser...
return user_without_team(request.user)
Using the snippet: <|code_start|>#from rest_framework import routers app_name = 'api_users' ''' router = routers.SimpleRouter() router.register(r'user-team-request', UserTeamRequestViewSet, 'user-team-request') urlpatterns = router.urls + [ ] ''' urlpatterns = [ <|code_end|> , determine the next line of code....
url(r'^user-team-request/$', UserRequestHTMLTable.as_view(), name='user-team-request')
Using the snippet: <|code_start|> def challenges_categories(request): categories = Category.objects.all() user = request.user team = user.profile.team categories_num_done_user = [ c.challenges.filter(solved_by=user.profile).distinct().count() for c in categories ] categ...
'challenges_count': Challenge.objects.count(),
Next line prediction: <|code_start|> def challenges_categories(request): categories = Category.objects.all() user = request.user team = user.profile.team categories_num_done_user = [ c.challenges.filter(solved_by=user.profile).distinct().count() for c in categories ] ca...
last_team_solutions = ChallengeSolved.objects\
Continue the code snippet: <|code_start|> class TabularUserAdmin(admin.TabularInline): model = get_user_model() @admin.register(Team) class TeamAdmin(admin.ModelAdmin): #filter_horizontal = ('TabularUserAdmin',) pass <|code_end|> . Use current file imports: from django.contrib import admin from djang...
@admin.register(UserProfile)
Continue the code snippet: <|code_start|> class TabularUserAdmin(admin.TabularInline): model = get_user_model() @admin.register(Team) class TeamAdmin(admin.ModelAdmin): #filter_horizontal = ('TabularUserAdmin',) pass @admin.register(UserProfile) class UserProfileAdmin(admin.ModelAdmin): pass <|c...
@admin.register(UserTeamRequest)
Using the snippet: <|code_start|># from registration.forms import RegistrationForm class CustomRegistrationForm(RegistrationForm): first_name = forms.CharField(required=True) last_name = forms.CharField(required=True) class Meta: model = RegistrationForm.Meta.model fields = RegistrationFo...
model = UserProfile
Based on the snippet: <|code_start|># from registration.forms import RegistrationForm class CustomRegistrationForm(RegistrationForm): first_name = forms.CharField(required=True) last_name = forms.CharField(required=True) class Meta: model = RegistrationForm.Meta.model fields = Registratio...
model = UserTeamRequest
Predict the next line for this snippet: <|code_start|># from registration.forms import RegistrationForm class CustomRegistrationForm(RegistrationForm): first_name = forms.CharField(required=True) last_name = forms.CharField(required=True) class Meta: model = RegistrationForm.Meta.model fi...
model = Team
Given snippet: <|code_start|> ) def user_detail(request, pk=None): user = request.user if pk is None else get_user_model().objects.get(pk=pk) solved = user.profile.percentage_solved_by_category categories_names = list(solved.keys()) categories_num_done_user = [solved[c] for c in categories_nam...
model = UserTeamRequest
Predict the next line for this snippet: <|code_start|> # TODO: use permissions def get(self, request, *args, **kwargs): if not self.request.user.created_team.first(): return redirect('index') return super(TeamAdminView, self).get(request, *args, **kwargs) def get_context_data(se...
model = UserProfile
Predict the next line for this snippet: <|code_start|> # from registration.backends.simple.views import RegistrationView def index(request): return render(request, 'accounts/teams.html', { 'teams': Team.objects.all(), 'teams_count': Team.objects.count(), }) class CustomRegistrationView(Regi...
form_class = CustomRegistrationForm
Continue the code snippet: <|code_start|> # from registration.backends.simple.views import RegistrationView def index(request): return render(request, 'accounts/teams.html', { 'teams': Team.objects.all(), 'teams_count': Team.objects.count(), }) class CustomRegistrationView(RegistrationView)...
self.profile_form = UserProfileForm(request.POST, request.FILES)
Based on the snippet: <|code_start|>def team_detail(request, pk=None): user = request.user team = user.profile.team if pk is None else Team.objects.get(pk=pk) categories = Category.objects.all() categories_num_done_user = [ c.challenges.filter(solved_by=user.profile).distinct().count() ...
def no_team_view(request, create_form=TeamCreateForm(), join_form=UserTeamRequestCreateForm()):
Given the following code snippet before the placeholder: <|code_start|>def team_detail(request, pk=None): user = request.user team = user.profile.team if pk is None else Team.objects.get(pk=pk) categories = Category.objects.all() categories_num_done_user = [ c.challenges.filter(solved_by=user.p...
def no_team_view(request, create_form=TeamCreateForm(), join_form=UserTeamRequestCreateForm()):
Predict the next line for this snippet: <|code_start|> r = self.get_object() if r.user != request.user and r.team.created_by != request.user: return HttpResponseForbidden() return super(UserTeamRequestDelete, self).dispatch(request, *args, **kwargs) class UserTeamRequestManage(Updat...
serializer_class = UserTeamRequestListSerializer
Continue the code snippet: <|code_start|> team = user.profile.team if pk is None else Team.objects.get(pk=pk) categories = Category.objects.all() categories_num_done_user = [ c.challenges.filter(solved_by=user.profile).distinct().count() for c in categories ] categories_num_done_team...
if not user_without_team(request.user):
Here is a snippet: <|code_start|> def register(self, form): # new_user = super(CustomRegistrationView, self).register(form) new_user = form.save() profile = self.profile_form.save(commit=False) profile.user = new_user profile.save() return new_user def get_contex...
'total_points_count': Challenge.objects.total_points(),
Predict the next line after this snippet: <|code_start|>class CustomRegistrationView(RegistrationView): form_class = CustomRegistrationForm profile_form = None success_url = '/' def post(self, request, *args, **kwargs): form = self.get_form() self.profile_form = UserProfileForm(request....
categories = Category.objects.all()
Next line prediction: <|code_start|> @property def failed_challenges(self): return self._all_failed_challenges.exclude(pk__in=self.solved_challenges.all()) class UserTeamRequestQuerySet(models.QuerySet): def pending(self): return self.filter(status='P') def accepted(self): ret...
if not user_without_team(self.user):
Predict the next line after this snippet: <|code_start|># Copyright (C) 2006-2011 the Mako authors and contributors <see AUTHORS file> # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """utilities for analyzing expressions and blocks of Python ...
expr = pyparser.parse(code.lstrip(), "exec", **exception_kwargs)
Here is a snippet: <|code_start|> You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' FORMATS = {'Autodetect': None, 'Binary': rawfile.format_binary, 'Text': rawfile.format_text, } DEFAULT_FO...
class LoadDialog(QtGui.QDialog, ui_loaddialog.Ui_LoadDialog):
Next line prediction: <|code_start|># encoding: utf-8 ''' @author: Jose Emilio Romero Lopez @copyright: Copyright 2013-2014, Jose Emilio Romero Lopez. @license: GPL @contact: jemromerol@gmail.com This file is part of APASVO. This program is free software: you can redistribute it and/or modify it u...
'Binary': rawfile.format_binary,
Given the code snippet: <|code_start|> else: for i in xrange(n_events): # Generate output filename if n_events > 1: filename_out = "%s%02.0i%s" % (basename, i, ext) clt.print_msg("Generating artificial signal in %s... " % filena...
program_version = "v%s" % __version__
Predict the next line after this snippet: <|code_start|> E.g. given FILEIN = None, output = 'example.out' and n_events = 5, the function will generate 5 synthetic files named: 'example00.out', 'example01.out', 'example02.out', 'example03.out' and 'example04.out'. ...
clt.print_msg("Configuring generator... ")
Using the snippet: <|code_start|> Results will be saved to 'eq00.bin', 'eq01.bin', 'eq02.bin', ..., 'eq499.bin'. \033[1m>> python apasvo-generator.py -o eq.txt -n 30 --output-format text @settings.txt\033[0m Generates a list of 30 synthetic earthquakes and takes some settings from a text file nam...
parser = parse.CustomArgumentParser(description=program_description,
Using the snippet: <|code_start|> gen_event_power: Earthquake power in dB. If FILEIN is None, this parameter has no effect. Default: 5.0. n_events: No. of signals to generate. If FILEIN is None, this parameter has no effect. Default: 1. gen_noise_c...
if futils.istextfile(gen_noise_coefficients):
Based on the snippet: <|code_start|> If FILEIN is not None, this parameter is also the format of input data. Default value is 'native'. """ fs = kwargs.get('fs', 50.0) # Configure generator clt.print_msg("Configuring generator... ") generator = eqgenerator.Earthqua...
fin_handler = rawfile.get_file_handler(f, dtype=datatype,
Using the snippet: <|code_start|> E.g. given FILEIN = None, output = 'example.out' and n_events = 5, the function will generate 5 synthetic files named: 'example00.out', 'example01.out', 'example02.out', 'example03.out' and 'example04.out'. gen_event_power: Earthq...
generator = eqgenerator.EarthquakeGenerator(**kwargs)
Predict the next line after this snippet: <|code_start|> (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f...
self._filters = filterlistmodel.FilterListModel([])
Next line prediction: <|code_start|> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' class AmpaDialog(QtGui.Q...
filterDelegate = dsbdelegate.DoubleSpinBoxDelegate(self.filtersTable,
Based on the snippet: <|code_start|> self.ampawindowstepSpinBox.setMaximum(value) def on_ampa_window_step_changed(self, value): pass def on_startf_changed(self, value): self.endfSpinBox.setMinimum(value + self.endfSpinBox.singleStep()) self.bandwidthSpinBox.setMaximum(self.nyqui...
settings = QtCore.QSettings(_organization, _application_name)
Predict the next line for this snippet: <|code_start|> self.ampawindowstepSpinBox.setMaximum(value) def on_ampa_window_step_changed(self, value): pass def on_startf_changed(self, value): self.endfSpinBox.setMinimum(value + self.endfSpinBox.singleStep()) self.bandwidthSpinBox.set...
settings = QtCore.QSettings(_organization, _application_name)
Next line prediction: <|code_start|> self.takanamiformLayout.setHorizontalSpacing(24) self.takanamiCheckBox = QtGui.QCheckBox("Apply Takanami on results", self.takanamiGroupBox) self.takanamiCheckBox.setChecked(True) self.takanamiformLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.t...
settings = QtCore.QSettings(_organization, _application_name)
Based on the snippet: <|code_start|> self.takanamiformLayout.setHorizontalSpacing(24) self.takanamiCheckBox = QtGui.QCheckBox("Apply Takanami on results", self.takanamiGroupBox) self.takanamiCheckBox.setChecked(True) self.takanamiformLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.t...
settings = QtCore.QSettings(_organization, _application_name)
Using the snippet: <|code_start|> @copyright: Copyright 2013-2014, Jose Emilio Romero Lopez. @license: GPL @contact: jemromerol@gmail.com This file is part of APASVO. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published b...
class SaveEventsDialog(QtGui.QDialog, ui_save_events_dialog.Ui_SaveEventsDialog):
Predict the next line for this snippet: <|code_start|> """Inits a BinFile object. Args: filename: Name of the file. dtype: Data-type of the data stored in the file. Possible values are: 'float16', 'float32' and 'float64'. Default value is 'float64'...
for data in futils.read_in_chunks(f, chunk_size):
Given the code snippet: <|code_start|> def fraction(arg): """Determines if an argument is a number in the range [0,1).""" value = float(arg) if value < 0 or value > 1: msg = "%r must be a value between [0,1)" % arg raise argparse.ArgumentTypeError(msg) return value class GlobInputFilen...
if futils.istextfile(fname):
Using the snippet: <|code_start|>@author: Jose Emilio Romero Lopez @copyright: Copyright 2013-2014, Jose Emilio Romero Lopez. @license: GPL @contact: jemromerol@gmail.com This file is part of APASVO. This program is free software: you can redistribute it and/or modify it under the terms of the GNU...
app.setApplicationName(_application_name)
Next line prediction: <|code_start|> You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' if __name__ == '__main__': # QtGui.QApplication.setLibraryPaths([]) # Disable looking for plugins app = QtGui.QApplication(sys....
main = mainwindow.MainWindow()
Using the snippet: <|code_start|> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU...
settings = QtCore.QSettings(_organization, _application_name)