text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: sk1010k/nussl path: /tests/test_run_and_eval.py #!/usr/bin/env python # -*- coding: utf-8 -*- import unittest import os import nussl class RunAndEvalUnitTest(unittest.TestCase): def test_simple(self): drums_path = os.path.join('Input', 'src1.wav') flute_path = os.path.joi...
code_fim
medium
{ "lang": "python", "repo": "sk1010k/nussl", "path": "/tests/test_run_and_eval.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> repet = nussl.Repet scores_repet = nussl.run_and_eval_prf(repet, repet_kwargs, mixtures, true_sources) i = 0<|fim_prefix|># repo: sk1010k/nussl path: /tests/test_run_and_eval.py #!/usr/bin/env python # -*- coding: utf-8 -*- import unittest import os import nussl class RunAndE...
code_fim
hard
{ "lang": "python", "repo": "sk1010k/nussl", "path": "/tests/test_run_and_eval.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> scores_sim = nussl.run_and_eval_prf(repet_sim, repet_kwargs, mixtures, true_sources) repet = nussl.Repet scores_repet = nussl.run_and_eval_prf(repet, repet_kwargs, mixtures, true_sources) i = 0<|fim_prefix|># repo: sk1010k/nussl path: /tests/test_run_and_eval.py #!/usr/b...
code_fim
hard
{ "lang": "python", "repo": "sk1010k/nussl", "path": "/tests/test_run_and_eval.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: shivangeerathi/sedkit path: /sedkit/tests/test_query.py """A suite of tests for the query.py module""" import astropy.units as q from astropy.coordinates import SkyCoord from .. import query def test_query_vizier(): """Test for the query_vizier function""" # 2MASS catalog catalog ...
code_fim
hard
{ "lang": "python", "repo": "shivangeerathi/sedkit", "path": "/sedkit/tests/test_query.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # Some results results = query.query_SDSS_apogee_spectra(sky_coords, search_radius=10 * q.degree) assert len(results) > 0 # No results results = query.query_SDSS_apogee_spectra(sky_coords, search_radius=0.1 * q.arcsec) assert len(results) > 0<|fim_prefix|># repo: shivangeerathi/se...
code_fim
hard
{ "lang": "python", "repo": "shivangeerathi/sedkit", "path": "/sedkit/tests/test_query.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> return render_template("index.html", connected=client._connected)<|fim_prefix|># repo: soulnothing/TouchaTouchaTouchMe path: /dist/TTTM/rest.py from flask import Flask, request, jsonify, render_template, Blueprint, url_for from TTTM import app, client import os <|fim_middle|>@app.route('/') def inde...
code_fim
easy
{ "lang": "python", "repo": "soulnothing/TouchaTouchaTouchMe", "path": "/dist/TTTM/rest.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: soulnothing/TouchaTouchaTouchMe path: /dist/TTTM/rest.py from flask import Flask, request, jsonify, render_template, Blueprint, url_for from TTTM import app, client import os <|fim_suffix|> return render_template("index.html", connected=client._connected)<|fim_middle|>@app.route('/') def inde...
code_fim
easy
{ "lang": "python", "repo": "soulnothing/TouchaTouchaTouchMe", "path": "/dist/TTTM/rest.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def fix_ssl_monkeypatching(): """ eventlet works by monkey-patching core IO libraries (such as ssl) to be non-blocking. However, there's currently a bug: In the normal socket library it may throw a timeout error as a `socket.timeout` exception. However eventlet.green.ssl's patch raises an ...
code_fim
medium
{ "lang": "python", "repo": "alphagov/document-download-api", "path": "/gunicorn_config.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: alphagov/document-download-api path: /gunicorn_config.py import os import socket import eventlet from gds_metrics.gunicorn import child_exit # noqa bind = "0.0.0.0:{}".format(os.getenv("PORT")) <|fim_suffix|>errorlog = "/home/vcap/logs/gunicorn_error.log" def fix_ssl_monkeypatching(): "...
code_fim
medium
{ "lang": "python", "repo": "alphagov/document-download-api", "path": "/gunicorn_config.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def get_urls(self): urls = [ url(r'^settings/profile/$', login_required(self.profile_settings_view.as_view()), name='profile-settings'), url(r'^settings/appearance/$', login_required(self.appearance_settings_view.as_view()), name='appearance-settings'), # C...
code_fim
medium
{ "lang": "python", "repo": "lyoniionly/django-cobra", "path": "/src/cobra/apps/accounts/app.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: lyoniionly/django-cobra path: /src/cobra/apps/accounts/app.py from django.conf.urls import url from django.contrib.auth.decorators import login_required from allauth.account import views as allauth_views from cobra.core.application import Application from cobra.core.loading import get_class c...
code_fim
hard
{ "lang": "python", "repo": "lyoniionly/django-cobra", "path": "/src/cobra/apps/accounts/app.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> urls = [ url(r'^settings/profile/$', login_required(self.profile_settings_view.as_view()), name='profile-settings'), url(r'^settings/appearance/$', login_required(self.appearance_settings_view.as_view()), name='appearance-settings'), # Copy from django-allauth,...
code_fim
hard
{ "lang": "python", "repo": "lyoniionly/django-cobra", "path": "/src/cobra/apps/accounts/app.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: kapil87/Object-Oriented-Python-Code path: /Chapter_6/PygameDemo6_BallBounceObjectOriented/Ball.py import pygame from pygame.locals import * import random # Ball class class Ball(): def __init__(self, window, windowWidth, windowHeight): self.window = window # remember the window, s...
code_fim
medium
{ "lang": "python", "repo": "kapil87/Object-Oriented-Python-Code", "path": "/Chapter_6/PygameDemo6_BallBounceObjectOriented/Ball.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def update(self): # Check for hitting a wall. If so, change that direction. if (self.x < 0) or (self.x >= self.maxWidth): self.xSpeed = -self.xSpeed if (self.y < 0) or (self.y >= self.maxHeight): self.ySpeed = -self.ySpeed # Update the Ball's ...
code_fim
hard
{ "lang": "python", "repo": "kapil87/Object-Oriented-Python-Code", "path": "/Chapter_6/PygameDemo6_BallBounceObjectOriented/Ball.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|># Global variable set by parameter VERBOSE = False # Pretty colors if 'TERM' in os.environ and 'color' in os.environ['TERM']: RED = '\033[91m' YEL = '\033[93m' UYEL = '\033[93m'+'\033[4m' ENDC = '\033[0m' else: RED = '' YEL = '' UYEL = '' ENDC = '' def is_word_in(word, l...
code_fim
hard
{ "lang": "python", "repo": "jdanders/svdac", "path": "/svdac.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def remove_ignored_lines(file_contents, rule): ''' Replace lines marked with rule.ignore with blank lines ''' lines = file_contents.splitlines() result = [] for line in lines: if rule.ignore in line: # Add \n to preserve line number count result.append("\n")...
code_fim
hard
{ "lang": "python", "repo": "jdanders/svdac", "path": "/svdac.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jdanders/svdac path: /svdac.py #! /usr/bin/env python3 """System Verilog Domain Assignment Checker Given a set of rules, check verilog files that all assignments meet the rules. Rules are to ensure that "domains" are maintained, for example pipe stage or clock domains. A rule is an instance of ...
code_fim
hard
{ "lang": "python", "repo": "jdanders/svdac", "path": "/svdac.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: cbpowell/SenseLink path: /senselink/__main__.py import logging import asyncio import os import argparse from senselink import SenseLink if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("-c", "--config", help="specify config file path") parser.add_argu...
code_fim
hard
{ "lang": "python", "repo": "cbpowell/SenseLink", "path": "/senselink/__main__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> server = SenseLink(config) if os.environ.get('SENSE_RESPONSE', 'True').upper() == 'TRUE' and not args.quiet: logging.info("Will respond to Sense broadcasts") server.should_respond = True # Create instances server.create_instances() # Start and run indefinitely log...
code_fim
hard
{ "lang": "python", "repo": "cbpowell/SenseLink", "path": "/senselink/__main__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Tenebrar/codebase path: /util/enums/tests/test_defaulting.py from util.enums.defaulting import DefaultingEnum class DEnum(DefaultingEnum): <|fim_suffix|>def test_fetch_incorrect_name(): assert DEnum('c') == DEnum.UNKNOWN<|fim_middle|> A = 'a' B = 'b' UNKNOWN = 'unknown' def te...
code_fim
medium
{ "lang": "python", "repo": "Tenebrar/codebase", "path": "/util/enums/tests/test_defaulting.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>def test_fetch_incorrect_name(): assert DEnum('c') == DEnum.UNKNOWN<|fim_prefix|># repo: Tenebrar/codebase path: /util/enums/tests/test_defaulting.py from util.enums.defaulting import DefaultingEnum class DEnum(DefaultingEnum): A = 'a' B = 'b' UNKNOWN = 'unknown' def test_fetch_by_na...
code_fim
easy
{ "lang": "python", "repo": "Tenebrar/codebase", "path": "/util/enums/tests/test_defaulting.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: guilouro/devent path: /core/migrations/0005_auto_20150814_1143.py # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations <|fim_suffix|> operations = [ migrations.RemoveField( model_name='event', name='from_day'...
code_fim
medium
{ "lang": "python", "repo": "guilouro/devent", "path": "/core/migrations/0005_auto_20150814_1143.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.RemoveField( model_name='event', name='from_day', ), migrations.RemoveField( model_name='event', name='to_day', ), migrations.AddField( model_name='event', name='st...
code_fim
medium
{ "lang": "python", "repo": "guilouro/devent", "path": "/core/migrations/0005_auto_20150814_1143.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sunmengnan/city_brain path: /algorithms/03-routing/01-osrm/match.py import osrm points = [(-33.45017046193167, -70.6528186798<|fim_suffix|> (-33.453867464504555, -70.65277576446533)] result = osrm.match(points, steps=False, overview="simplified")<|fim_middle|>0957), (-33.4523...
code_fim
easy
{ "lang": "python", "repo": "sunmengnan/city_brain", "path": "/algorithms/03-routing/01-osrm/match.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (-33.453867464504555, -70.65277576446533)] result = osrm.match(points, steps=False, overview="simplified")<|fim_prefix|># repo: sunmengnan/city_brain path: /algorithms/03-routing/01-osrm/match.py import osrm points = [(-33.45017046193167, -70.6528186798<|fim_middle|>0957), (-33.4523...
code_fim
easy
{ "lang": "python", "repo": "sunmengnan/city_brain", "path": "/algorithms/03-routing/01-osrm/match.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return run_metrics def format_gnuplot(tds): """Generates a series of lines to plot Tile Data Structure in GNUPlot. """ if tds['type'] == '%': fname = "Occupancy-By-Tile" xlabel = "% Occupied" ylabel = "% Pass Filter" xrange = yrange = 100.0 p...
code_fim
hard
{ "lang": "python", "repo": "EdinburghGenomics/illuminatus", "path": "/pf_vs_occupied.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """ Load the goodies from the .bin files in the InterOp directory. This black magic is copy-pasted straight out of the tutorial linked above! """ #print("Examining: {}".format(run_dir)) valid_to_load = py_interop_run.uchar_vector(py_interop_run.MetricCount, 0) for v2l in (py_i...
code_fim
hard
{ "lang": "python", "repo": "EdinburghGenomics/illuminatus", "path": "/pf_vs_occupied.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: EdinburghGenomics/illuminatus path: /pf_vs_occupied.py #!/usr/bin/env python3 # This script reads InterOp for a run and generates GNUPlot # instructions to make a plot of %Occupied vs. %Pass Filter, # as requested by Matt. # To make my life simpler, I'll use the Python bindings to read the Inte...
code_fim
hard
{ "lang": "python", "repo": "EdinburghGenomics/illuminatus", "path": "/pf_vs_occupied.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> print('Fetching pool hashrate data ... ', end="") sys.stdout.flush() new_v = poolrate(cfg) print('Done.') string = "" i = 0 for v in new_v: key = cfg['pool_list'][i]['label'] if key not in vp: vp[key] = [] ...
code_fim
hard
{ "lang": "python", "repo": "XzxEmbedded/Avalon-extras", "path": "/farm-manager/status-report/chkrate.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> string = "" i = 0 for v in new_v: key = cfg['pool_list'][i]['label'] if key not in vp: vp[key] = [] vp[key].append(float(v)) string += ";" + key + ":" + v i += 1 label = ['Local Method 1', 'Local M...
code_fim
hard
{ "lang": "python", "repo": "XzxEmbedded/Avalon-extras", "path": "/farm-manager/status-report/chkrate.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: XzxEmbedded/Avalon-extras path: /farm-manager/status-report/chkrate.py #!/usr/bin/env python2 from __future__ import print_function import datetime import sys from poolrate import poolrate def chkrate(data, data0, cfg, time, time0): if data is not None: print('Calculating hashrat...
code_fim
hard
{ "lang": "python", "repo": "XzxEmbedded/Avalon-extras", "path": "/farm-manager/status-report/chkrate.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: MetOffice/forest path: /test/test_scaling_group.py from unittest.mock import Mock import forest.scaling_group def test_scaling_group_scale_up(): n = 5 pool = Mock() scaling_group = forest.scaling_group.ScalingGroup(pool) scaling_group.scale_to(n) assert len(scaling_group.ins...
code_fim
medium
{ "lang": "python", "repo": "MetOffice/forest", "path": "/test/test_scaling_group.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def test_scaling_group_scale_down(): pool = Mock() large = 10 small = 3 scaling_group = forest.scaling_group.ScalingGroup(pool) scaling_group.scale_to(large) scaling_group.scale_to(small) assert len(scaling_group.instances) == small assert pool.acquire.call_count == large ...
code_fim
hard
{ "lang": "python", "repo": "MetOffice/forest", "path": "/test/test_scaling_group.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "url": "https://insights.twilio.com/v1/Video/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?PageSize=50&Page=0", ...
code_fim
hard
{ "lang": "python", "repo": "TheOther-Guy/twilio-python", "path": "/tests/integration/insights/v1/room/test_participant.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: TheOther-Guy/twilio-python path: /tests/integration/insights/v1/room/test_participant.py # coding=utf-8 r""" This code was generated by \ / _ _ _| _ _ | (_)\/(_)(_|\/| |(/_ v1.0.0 / / """ from tests import IntegrationTestCase from tests.holodeck import Request from twilio.ba...
code_fim
hard
{ "lang": "python", "repo": "TheOther-Guy/twilio-python", "path": "/tests/integration/insights/v1/room/test_participant.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.assertIsNotNone(actual) def test_read_full_response(self): self.holodeck.mock(Response( 200, ''' { "meta": { "url": "https://insights.twilio.com/v1/Video/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Participants?...
code_fim
hard
{ "lang": "python", "repo": "TheOther-Guy/twilio-python", "path": "/tests/integration/insights/v1/room/test_participant.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def generate_token(length=30, chars=UNICODE_ASCII_CHARACTER_SET): rand = random.SystemRandom() return ''.join(rand.choice(chars) for _ in range(length))<|fim_prefix|># repo: voegtlel/auth-manager-mailu-man path: /mailu_man_mini/token_gen.py import random import string <|fim_middle|>UNICODE_ASCI...
code_fim
medium
{ "lang": "python", "repo": "voegtlel/auth-manager-mailu-man", "path": "/mailu_man_mini/token_gen.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: voegtlel/auth-manager-mailu-man path: /mailu_man_mini/token_gen.py import random import string UNICODE_ASCII_CHARACTER_SET = string.ascii_letters + string.digits <|fim_suffix|> rand = random.SystemRandom() return ''.join(rand.choice(chars) for _ in range(length))<|fim_middle|> def genera...
code_fim
medium
{ "lang": "python", "repo": "voegtlel/auth-manager-mailu-man", "path": "/mailu_man_mini/token_gen.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> rand = random.SystemRandom() return ''.join(rand.choice(chars) for _ in range(length))<|fim_prefix|># repo: voegtlel/auth-manager-mailu-man path: /mailu_man_mini/token_gen.py import random import string UNICODE_ASCII_CHARACTER_SET = string.ascii_letters + string.digits <|fim_middle|> def genera...
code_fim
medium
{ "lang": "python", "repo": "voegtlel/auth-manager-mailu-man", "path": "/mailu_man_mini/token_gen.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> tfidf_mat_selection = None features_template = None tfidf_mat_template = None selected_idx = [] now = datetime.now() dt_string = now.strftime("%d%m%Y_%H%M%S") # ---------------------------- TRAINING ----------------------------- mi = mutual_info_classif(tfidf_mat, tags) ...
code_fim
hard
{ "lang": "python", "repo": "Muhammad-Yunus/Hoax-Classifier-App", "path": "/ml_core/feature_selection_training.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Muhammad-Yunus/Hoax-Classifier-App path: /ml_core/feature_selection_training.py from sklearn.feature_selection import mutual_info_classif from ml_core.json_utils import readJson_config, writeJson_config from datetime import datetime from scipy import sparse import pandas as pd import numpy as np ...
code_fim
hard
{ "lang": "python", "repo": "Muhammad-Yunus/Hoax-Classifier-App", "path": "/ml_core/feature_selection_training.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> column_idx = [i for i, mi_item in enumerate(norm_mi) if mi_item < 0.01] tfidf_mat_selection = np.delete(tfidf_mat, column_idx ,1) # template data selected_idx = [j for j in range(len(norm_mi)) if j not in column_idx] selected_features = [] for idx in selected_idx: selected...
code_fim
medium
{ "lang": "python", "repo": "Muhammad-Yunus/Hoax-Classifier-App", "path": "/ml_core/feature_selection_training.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>## Space Complexity: O( 1 ) # # The overhead in space is the storage for vote and majority, which is of O( 1 ). from collections import namedtuple TestEntry = namedtuple('TestEntry', 'vote_sequence') def test_bench(): test_data = [ TestEntry( vote_sequence= [3,2,3] ), ...
code_fim
hard
{ "lang": "python", "repo": "brianchiang-tw/leetcode", "path": "/2020_May_Leetcode_30_days_challenge/Week_1_Majority Element/by_boyer_moore_voting_algorithm.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: brianchiang-tw/leetcode path: /2020_May_Leetcode_30_days_challenge/Week_1_Majority Element/by_boyer_moore_voting_algorithm.py ''' Description: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the ...
code_fim
hard
{ "lang": "python", "repo": "brianchiang-tw/leetcode", "path": "/2020_May_Leetcode_30_days_challenge/Week_1_Majority Element/by_boyer_moore_voting_algorithm.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Print out info about whats going on # Update Training rate # Save the model (if we need to save the model)<|fim_prefix|># repo: chekfung/GauGAN_Reimplementation path: /code/train.py # import Pix2PixTrainer import tensorflow as tf # TODO: Line to create the trainer object that has all...
code_fim
medium
{ "lang": "python", "repo": "chekfung/GauGAN_Reimplementation", "path": "/code/train.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: chekfung/GauGAN_Reimplementation path: /code/train.py # import Pix2PixTrainer import tensorflow as tf # TODO: Line to create the trainer object that has all the info we need trainer = Pix2PixTrainer <|fim_suffix|> # Otherwise use default hyperparameters for epoch in range(begin_epoch, hp.num...
code_fim
medium
{ "lang": "python", "repo": "chekfung/GauGAN_Reimplementation", "path": "/code/train.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>for epoch in range(begin_epoch, hp.num_epochs): # Run the Generator every two times of i # Run the Discriminator # Print out info about whats going on # Update Training rate # Save the model (if we need to save the model)<|fim_prefix|># repo: chekfung/GauGAN_Reimplementation p...
code_fim
medium
{ "lang": "python", "repo": "chekfung/GauGAN_Reimplementation", "path": "/code/train.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Block #2: second CONV => RELU => POOL layer set conv2_1 = mx.sym.Convolution(data=do1, kernel=(5, 5), pad=(2, 2), num_filter=256) act2_1 = mx.sym.LeakyReLU(data=conv2_1, act_type="elu") bn2_1 = mx.sym.BatchNorm(data=act2_1) pool2 = mx.sym.Pooling(data=bn2_1, pool_...
code_fim
hard
{ "lang": "python", "repo": "miroso/pis_code", "path": "/imagenet_bundle/ch05-alexnet/mxalexnet.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: miroso/pis_code path: /imagenet_bundle/ch05-alexnet/mxalexnet.py # -*- coding: utf-8 -*- """Implementation of AlexNet architecture with MXNet. """ import mxnet as mx class MxAlexNet: """AlexNet architecture """ @staticmethod def build(classes): """Build AlexNet with MXNe...
code_fim
hard
{ "lang": "python", "repo": "miroso/pis_code", "path": "/imagenet_bundle/ch05-alexnet/mxalexnet.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>DEFAULT_TENSE_WEIGHTS = ( 1, # infinitive 3, # present 1, # present continuous 3, # imperfect 1, # imperfect continuous 3, # perfect 2, # future simple 0, # future formal (NOT LEARNED) 0, # future conditional (NOT LEARNED) 0, # imperative negative (NOT LEARNED) ...
code_fim
hard
{ "lang": "python", "repo": "lawrencesim/portuguese-verb-cards", "path": "/bin/constants.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: lawrencesim/portuguese-verb-cards path: /bin/constants.py from types import SimpleNamespace PERSON = SimpleNamespace(FIRST=1, SECOND=2, THIRD=3) PERSON_VALUES = tuple(sorted(getattr(PERSON, n) for n in dir(PERSON) if not n.startswith("_"))) PERSON_NAMES = {getattr(PERSON, n): n for n in dir(PER...
code_fim
hard
{ "lang": "python", "repo": "lawrencesim/portuguese-verb-cards", "path": "/bin/constants.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nipengmath/Distributed-Tensorflow-Template path: /models/example_model.py import tensorflow as tf from base.model import BaseModel from typing import Dict class Mnist(BaseModel): def __init__(self, config: dict) -> None: """ Create a model used to classify hand written image...
code_fim
hard
{ "lang": "python", "repo": "nipengmath/Distributed-Tensorflow-Template", "path": "/models/example_model.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return tf.estimator.EstimatorSpec(mode, loss=loss, train_op=train_op) def _fc_block(x: tf.Tensor, size: int, is_training: bool, drop: float) -> tf.Tensor: """ Create a fully connected block using batch-norm and drop out :param x: input layer which proceeds this block :param size:...
code_fim
hard
{ "lang": "python", "repo": "nipengmath/Distributed-Tensorflow-Template", "path": "/models/example_model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>async def test_connected_event(hass: HomeAssistant, mock_litejet) -> None: """Test handling an event from LiteJet.""" await async_init_integration(hass, use_switch=True) # Initial state is available. assert hass.states.get(ENTITY_SWITCH).state == STATE_OFF assert hass.states.get(ENTI...
code_fim
hard
{ "lang": "python", "repo": "home-assistant/core", "path": "/tests/components/litejet/test_switch.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: home-assistant/core path: /tests/components/litejet/test_switch.py """The tests for the litejet component.""" from homeassistant.components import switch from homeassistant.const import ( ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON, STATE_OFF, STATE_ON, STATE_UNAVAIL...
code_fim
hard
{ "lang": "python", "repo": "home-assistant/core", "path": "/tests/components/litejet/test_switch.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.add( EmphasisElement( content=content, level=level, )) return self def add_lang( self, content, xmllang=None, ): self.add( LangElement( content=content, ...
code_fim
hard
{ "lang": "python", "repo": "plivo/plivo-python", "path": "/plivo/xml/speakElement.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: plivo/plivo-python path: /plivo/xml/speakElement.py from plivo.utils.validators import * from plivo.xml import ( PlivoXMLElement, map_type, BreakElement, EmphasisElement, LangElement, ) class SpeakElement(PlivoXMLElement): _name = 'Speak' _nestable = [ 'break...
code_fim
hard
{ "lang": "python", "repo": "plivo/plivo-python", "path": "/plivo/xml/speakElement.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return socket.inet_ntoa(struct.pack("!I", ipInt))<|fim_prefix|># repo: 3ev0/rdns-monitor path: /rdnsmonitor/handy.py import struct import socket <|fim_middle|>def ipToInt(ipstr): return struct.unpack("!I", socket.inet_aton(ipstr))[0] def intToIp(ipInt):
code_fim
medium
{ "lang": "python", "repo": "3ev0/rdns-monitor", "path": "/rdnsmonitor/handy.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: 3ev0/rdns-monitor path: /rdnsmonitor/handy.py import struct import socket <|fim_suffix|> return socket.inet_ntoa(struct.pack("!I", ipInt))<|fim_middle|>def ipToInt(ipstr): return struct.unpack("!I", socket.inet_aton(ipstr))[0] def intToIp(ipInt):
code_fim
medium
{ "lang": "python", "repo": "3ev0/rdns-monitor", "path": "/rdnsmonitor/handy.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def intToIp(ipInt): return socket.inet_ntoa(struct.pack("!I", ipInt))<|fim_prefix|># repo: 3ev0/rdns-monitor path: /rdnsmonitor/handy.py import struct import socket <|fim_middle|>def ipToInt(ipstr): return struct.unpack("!I", socket.inet_aton(ipstr))[0]
code_fim
medium
{ "lang": "python", "repo": "3ev0/rdns-monitor", "path": "/rdnsmonitor/handy.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: mwtoews/surface-water-network path: /swn/file.py """File reading/writing helpers.""" __all__ = [ "topnet2ts", "gdf_to_shapefile", "read_formatted_frame", "write_formatted_frame", ] import geopandas import numpy as np import pandas as pd from .logger import get_logger, logging ...
code_fim
hard
{ "lang": "python", "repo": "mwtoews/surface-water-network", "path": "/swn/file.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """Write a data frame as a free formatted table. Parameters ---------- df : pandas.DataFrame DataFrame to write. fname : str, path-like or file-like object Path to write file. index : bool, default True Write row names (index). comment_header : bool, de...
code_fim
hard
{ "lang": "python", "repo": "mwtoews/surface-water-network", "path": "/swn/file.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def write_formatted_frame(df, fname, index=True, comment_header=True): """Write a data frame as a free formatted table. Parameters ---------- df : pandas.DataFrame DataFrame to write. fname : str, path-like or file-like object Path to write file. index : bool, defa...
code_fim
hard
{ "lang": "python", "repo": "mwtoews/surface-water-network", "path": "/swn/file.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> ax[0].set_title(data_title) ax[0].set_xlabel('longitude [m]') ax[0].set_ylabel('lateral [m]') ax[0].plot(p_obs[:, non_target_inds, 1], p_obs[:, non_target_inds, 0], alpha=0.1, marker='x', color='blue') if np.isnan(p_obs).any(): is_nan_endpoint = np.isnan(p_obs) ...
code_fim
hard
{ "lang": "python", "repo": "umautobots/kinematic_highway", "path": "/display/predictions_2d.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: umautobots/kinematic_highway path: /display/predictions_2d.py import numpy as np from scipy import stats as ss import matplotlib.pyplot as plt def display_prediction_density(ax, p, w): # p: 2, n_samples | [lon, lat] position p_min = 1e-2 jitter = np.random.randn(*p.shape) * np.array...
code_fim
hard
{ "lang": "python", "repo": "umautobots/kinematic_highway", "path": "/display/predictions_2d.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if __name__ == "__main__": print(Solution().powerfulIntegers(2, 3, 10)) print(Solution().powerfulIntegers(3, 5, 15)) print(Solution().powerfulIntegers(1, 2, 100))<|fim_prefix|># repo: Satily/leetcode_python_solution path: /solutions/solution970.py class Solution: def powerfulIntegers(sel...
code_fim
hard
{ "lang": "python", "repo": "Satily/leetcode_python_solution", "path": "/solutions/solution970.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Satily/leetcode_python_solution path: /solutions/solution970.py class Solution: def powerfulIntegers(self, x, y, bound): """ :type x: int :type y: int :type bound: int :rtype: List[int] """ def powers(n, bound): if n == 1: ...
code_fim
hard
{ "lang": "python", "repo": "Satily/leetcode_python_solution", "path": "/solutions/solution970.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == "__main__": print(Solution().powerfulIntegers(2, 3, 10)) print(Solution().powerfulIntegers(3, 5, 15)) print(Solution().powerfulIntegers(1, 2, 100))<|fim_prefix|># repo: Satily/leetcode_python_solution path: /solutions/solution970.py class Solution: def powerfulIntegers(self...
code_fim
hard
{ "lang": "python", "repo": "Satily/leetcode_python_solution", "path": "/solutions/solution970.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>Test utils can be found in `serious.test_utils`. `More on Read The Docs.`_ `Sources on GitHub.`_ .. _More on Read The Docs.: https://serious.readthedocs.io/en/latest/ .. _Sources on GitHub.: https://github.com/mdrachuk/serious """ from .dict import DictModel from .errors import ModelError, ValidationEr...
code_fim
medium
{ "lang": "python", "repo": "mdrachuk/serious", "path": "/serious/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mdrachuk/serious path: /serious/__init__.py """Serious is a Python dataclass model toolkit for serialization, validation, and more. <|fim_suffix|>To provide custom field serialization use `serious.serialization`. Test utils can be found in `serious.test_utils`. `More on Read The Docs.`_ `Sourc...
code_fim
medium
{ "lang": "python", "repo": "mdrachuk/serious", "path": "/serious/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: SiChiTong/prlite-pc path: /pr2lite_moveit_config/nodes/point_head.py #! /usr/bin/env python # Copyright (c) 2010, Arizona Robotics Research Group, University of Arizona # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted pro...
code_fim
hard
{ "lang": "python", "repo": "SiChiTong/prlite-pc", "path": "/pr2lite_moveit_config/nodes/point_head.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> rospy.loginfo( "ref frames: " + pan_ref_frame + ", " + tilt_ref_frame) rospy.loginfo( "target point " + str(target.header.frame_id) + " x " + str( target.point.x) + " y " + str(target.point.y) + " z " + str(target.point.z)) # atan2 (opposite, adjacent) # Transform target p...
code_fim
hard
{ "lang": "python", "repo": "SiChiTong/prlite-pc", "path": "/pr2lite_moveit_config/nodes/point_head.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: AP-Atul/ml path: /linear_regression/sk.py from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_absolute_error, mean_squared_error from matplotlib import pyplot as plt import pandas as pd import numpy as np data ...
code_fim
medium
{ "lang": "python", "repo": "AP-Atul/ml", "path": "/linear_regression/sk.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>X = data.iloc[:, 3: 7] y = data.iloc[:, -1] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3) print(f"Training samples:: {len(X_train)}") print(f"Testing samples:: {len(X_test)}") model = LinearRegression() model.fit(X_train, y_train) print(f"Coefficients :: {model.coef_}") p...
code_fim
medium
{ "lang": "python", "repo": "AP-Atul/ml", "path": "/linear_regression/sk.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: spykard/pomegranate path: /tests/test_markov_chain.py [ 'C', 'C', 'D', 0.15 ], [ 'C', 'D', 'A', 0.8 ], [ 'C', 'D', 'B', 0.1 ], [ 'C', 'D', 'C', 0.05 ], [ 'C', 'D', 'D', 0.05 ], [ 'D', 'A', 'A', 0.5 ], [ 'D', 'A', 'B', 0.0 ], [ 'D', 'A', 'C', 0.5 ], [ 'D', 'A', 'D', 0.0 ], [ 'D', 'B', 'A'...
code_fim
hard
{ "lang": "python", "repo": "spykard/pomegranate", "path": "/tests/test_markov_chain.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: spykard/pomegranate path: /tests/test_markov_chain.py 05 ], [ 'A', 'C', 0.05 ], [ 'A', 'D', 0.1 ], [ 'B', 'A', 0.1 ], [ 'B', 'B', 0.2 ], [ 'B', 'C', 0.6 ], [ 'B', 'D', 0.1 ], [ 'C', 'A', 0.15 ], [ 'C', 'B', 0.1 ], [ 'C', 'C', 0.25 ], [ 'C', 'D', 0.5 ], [ 'D', 'A', 0.25 ], [ 'D', 'B', 0.2...
code_fim
hard
{ "lang": "python", "repo": "spykard/pomegranate", "path": "/tests/test_markov_chain.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_almost_equal( second_chain.log_probability( list('A') ), -2.30258509299 ) assert_almost_equal( second_chain.log_probability( list('B') ), -1.60943791243 ) assert_almost_equal( second_chain.log_probability( list('AC') ), -5.29831736655 ) assert_almost_equal( second_chain.log_probability( list('...
code_fim
hard
{ "lang": "python", "repo": "spykard/pomegranate", "path": "/tests/test_markov_chain.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> user = Usuario.objects.get(username=usrk) serializerU = UsuarioSerializer(user) usrk = serializerU.data['id'] bookmarkSet = Bookmark.objects.filter(Usuario = usrk, Libro = libk) #bookmark = get_object_or_404(bookmark, Usuario = usrk, Libro = libk) serializer...
code_fim
medium
{ "lang": "python", "repo": "UNIZAR-30226-2021-05/Lector--Backend", "path": "/bookmark/views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: UNIZAR-30226-2021-05/Lector--Backend path: /bookmark/views.py from usuario import views from django.shortcuts import render import usuario from .serializers import BookmarkSerializer from usuario.serializers import UsuarioSerializer from .models import Bookmark, Usuario, Libro from rest_framewo...
code_fim
hard
{ "lang": "python", "repo": "UNIZAR-30226-2021-05/Lector--Backend", "path": "/bookmark/views.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def post(self, request, usrk, libk): user = Usuario.objects.get(username=usrk) lib = Libro.objects.get(ISBN=libk) bookm = Bookmark(Usuario=user, Libro=lib, esAnotacion=True, titulo=request.data["titulo"], cuerpo=request.data["cuerpo"], offset=request.data["offset"]) boo...
code_fim
hard
{ "lang": "python", "repo": "UNIZAR-30226-2021-05/Lector--Backend", "path": "/bookmark/views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> videos = [] for video in response: music = { "music_id": video['id'], "name": video['title'], "channel_name": video['user']['username'], "description": video['description'][:200] + "..." if video['description'] else '', "thumbnail...
code_fim
hard
{ "lang": "python", "repo": "Amoki/Amoki-Music", "path": "/sources/soundcloud.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Sometimes soundcloud send us a result like: [music1, music2] # sometimes, it: {"collection": [music1, music2]} # In the second case, the lib crash. So we parse ourselves the response response = json.loads(raw_response.raw_data) if 'collection' in response: ...
code_fim
hard
{ "lang": "python", "repo": "Amoki/Amoki-Music", "path": "/sources/soundcloud.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Amoki/Amoki-Music path: /sources/soundcloud.py import re import soundcloud import json from django.conf import settings client = soundcloud.Client(client_id=settings.SOUNDCLOUD_KEY) URL_REGEX = "^https?:\/\/(soundcloud.com|snd.sc)\/(.*)$" def search(query): <|fim_suffix|> videos = [] ...
code_fim
hard
{ "lang": "python", "repo": "Amoki/Amoki-Music", "path": "/sources/soundcloud.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: liaogx/python3-cookbook path: /第九章:元编程/9.7.py #!/usr/bin/env python # -*- coding:utf-8 -*- # __author__ = 'liao gao xiang' class Fib(object): """""" def __init__(self, n): self.pre = 0 self.cur = 1 self.n = n <|fim_suffix|> def __next__(self): if sel...
code_fim
easy
{ "lang": "python", "repo": "liaogx/python3-cookbook", "path": "/第九章:元编程/9.7.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def __iter__(self): return self def __next__(self): if self.n < 0: self.pre, self.cur = self.cur, self.pre + self.cur return self.cur else: raise StopIteration f = Fib(10) print([i for i in f])<|fim_prefix|># repo: liaogx/python3-cookb...
code_fim
medium
{ "lang": "python", "repo": "liaogx/python3-cookbook", "path": "/第九章:元编程/9.7.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.pre = 0 self.cur = 1 self.n = n def __iter__(self): return self def __next__(self): if self.n < 0: self.pre, self.cur = self.cur, self.pre + self.cur return self.cur else: raise StopIteration f = Fib(10) p...
code_fim
easy
{ "lang": "python", "repo": "liaogx/python3-cookbook", "path": "/第九章:元编程/9.7.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: slevi105/PyFBA path: /PyFBA/metabolism/__init__.py from .reaction import Reaction from .compound import Compound from .enzyme import Enzyme from .<|fim_suffix|>mass_equation', 'Reaction', 'Compound', 'Enzyme']<|fim_middle|>biomass import biomass_equation __all__ = ['bio
code_fim
easy
{ "lang": "python", "repo": "slevi105/PyFBA", "path": "/PyFBA/metabolism/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mass_equation', 'Reaction', 'Compound', 'Enzyme']<|fim_prefix|># repo: slevi105/PyFBA path: /PyFBA/metabolism/__init__.py from .reaction import Reaction from .compound i<|fim_middle|>mport Compound from .enzyme import Enzyme from .biomass import biomass_equation __all__ = ['bio
code_fim
medium
{ "lang": "python", "repo": "slevi105/PyFBA", "path": "/PyFBA/metabolism/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Else we may have a file if not data['bl_type']: # Try for file ext = tools.what_ext(data["extensions"].keys(), blog_result) if ext: config['blog_title'] += ' : %s' % data['pi_bl'] data['bl_type'] = 'file' data['root_datadir'] = blog_re...
code_fim
hard
{ "lang": "python", "repo": "llimllib/personal_code", "path": "/web/newf2o/blog/Pyblosxom/pyblosxom.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if not r: # get the renderer we want to use r = config.get("renderer", "blosxom") # import the renderer r = tools.importName("renderers", r) # get the renderer object r = r.Renderer(request, config.get("stdoutput", sys.stdout)) data['renderer'] = ...
code_fim
hard
{ "lang": "python", "repo": "llimllib/personal_code", "path": "/web/newf2o/blog/Pyblosxom/pyblosxom.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: llimllib/personal_code path: /web/newf2o/blog/Pyblosxom/pyblosxom.py hen we render only the ones that have changed. @type incremental: boolean """ self.initialize() config = self._request.getConfiguration() data = self._request.getData() print "Pe...
code_fim
hard
{ "lang": "python", "repo": "llimllib/personal_code", "path": "/web/newf2o/blog/Pyblosxom/pyblosxom.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if 'organization_pk' in request.session: request.organization = Organization.objects.get(pk=request.session['organization_pk']) else: request.organization = None<|fim_prefix|># repo: SVArago/alexia path: /utils/middleware.py from apps.organization.models import Org...
code_fim
medium
{ "lang": "python", "repo": "SVArago/alexia", "path": "/utils/middleware.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: SVArago/alexia path: /utils/middleware.py from apps.organization.models import Organization, Profile class ProfileRequirementMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): <|fim_suffix|> def process_request(self, request): if 'organization...
code_fim
medium
{ "lang": "python", "repo": "SVArago/alexia", "path": "/utils/middleware.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: PennyLaneAI/pennylane path: /tests/templates/test_layers/test_cv_neural_net.py # Copyright 2018-2021 Xanadu Quantum Technologies Inc. # 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 th...
code_fim
hard
{ "lang": "python", "repo": "PennyLaneAI/pennylane", "path": "/tests/templates/test_layers/test_cv_neural_net.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """Tests the jax interface.""" import jax import jax.numpy as jnp shapes = expected_shapes(1, 2) weights = [np.random.random(shape) for shape in shapes] weights = [jnp.array(w) for w in weights] dev = DummyDevice(wires=2) circuit = qml.QN...
code_fim
hard
{ "lang": "python", "repo": "PennyLaneAI/pennylane", "path": "/tests/templates/test_layers/test_cv_neural_net.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Interferometer (replace with operation once this template is refactored) qml.Beamsplitter(weights[0][0, 0], weights[1][0, 0], wires=[0, 1]) qml.Rotation(weights[2][0, 0], wires=0) qml.Rotation(weights[2][0, 1], wires=1) qml.Squeezing(weights[3][0, 0], weights[4][0, 0], wires=0) ...
code_fim
hard
{ "lang": "python", "repo": "PennyLaneAI/pennylane", "path": "/tests/templates/test_layers/test_cv_neural_net.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for it in range(self.iterations): batch_size = spc * cpi batch = torch.LongTensor(batch_size) c_idxs = torch.randperm(len(self.classes))[:cpi] for i, c in enumerate(self.classes[c_idxs]): s = slice(i * spc, (i + 1) * spc) ...
code_fim
hard
{ "lang": "python", "repo": "orobix/Prototypical-Networks-for-Few-shot-Learning-PyTorch", "path": "/src/prototypical_batch_sampler.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: orobix/Prototypical-Networks-for-Few-shot-Learning-PyTorch path: /src/prototypical_batch_sampler.py # coding=utf-8 import numpy as np import torch class PrototypicalBatchSampler(object): ''' PrototypicalBatchSampler: yield a batch of indexes at each iteration. Indexes are calculated...
code_fim
hard
{ "lang": "python", "repo": "orobix/Prototypical-Networks-for-Few-shot-Learning-PyTorch", "path": "/src/prototypical_batch_sampler.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ''' yield a batch of indexes ''' spc = self.sample_per_class cpi = self.classes_per_it for it in range(self.iterations): batch_size = spc * cpi batch = torch.LongTensor(batch_size) c_idxs = torch.randperm(len(self.classes...
code_fim
hard
{ "lang": "python", "repo": "orobix/Prototypical-Networks-for-Few-shot-Learning-PyTorch", "path": "/src/prototypical_batch_sampler.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: cobanov/demc-homework path: /dataset_download.py from bs4 import BeautifulSoup from urllib.request import urlopen import requests from requests.api import get def get_links(): html = requests.get('https://datasets.imdbws.com/').text soup = BeautifulSoup(html, "html.parser") hrefs = ...
code_fim
hard
{ "lang": "python", "repo": "cobanov/demc-homework", "path": "/dataset_download.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }