text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: chinmoykalita/alphachats path: /AlphaChats/migrations/0007_alter_chat_person.py # Generated by Django 3.2 on 2021-04-30 07:21 <|fim_suffix|> class Migration(migrations.Migration): dependencies = [ ('AlphaChats', '0006_auto_20210430_1248'), ] operations = [ migration...
code_fim
easy
{ "lang": "python", "repo": "chinmoykalita/alphachats", "path": "/AlphaChats/migrations/0007_alter_chat_person.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ ('AlphaChats', '0006_auto_20210430_1248'), ] operations = [ migrations.AlterField( model_name='chat', name='person', field=models.CharField(max_length=30), ), ]<|fim_prefix|># repo: chinmoykalita/alphachats pat...
code_fim
medium
{ "lang": "python", "repo": "chinmoykalita/alphachats", "path": "/AlphaChats/migrations/0007_alter_chat_person.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: wmpauli/neurosynth path: /neurosynth/tests/basic_ma.py # this script can be used to run basic forward and reverse inference on a feature # the feature (e.g. fear) is expected to be supplied as a command line argument to the script import sys # assert that a feature has been supplied as command ...
code_fim
hard
{ "lang": "python", "repo": "wmpauli/neurosynth", "path": "/neurosynth/tests/basic_ma.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # path of WHS atlas files resource_dir = path.join(path.pardir, 'resources') # make sure we have the data dataset_dir = path.join(path.expanduser('~'), 'Documents', 'neurosynth-data') database_path = path.join(dataset_dir, 'database_bregma.txt') neurosynth_data_url = 'https://github.com/wmpauli/neur...
code_fim
hard
{ "lang": "python", "repo": "wmpauli/neurosynth", "path": "/neurosynth/tests/basic_ma.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: icysun/opencanary_web path: /service/whiteportservice.py #!/usr/bin/env python # -*- coding:utf-8 -*- """ Author: pirogue Purpose: 白名单端口过滤 Site: http://pirogue.org Created: 2018-08-17 16:15:08 """ <|fim_suffix|> list_port = [] for port in White_res.select_white_port(): l...
code_fim
medium
{ "lang": "python", "repo": "icysun/opencanary_web", "path": "/service/whiteportservice.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def whiteports(): list_port = [] for port in White_res.select_white_port(): list_port.append(port[0]) return list_port def insertports(list_port): for p in list_port: if p: White_res.insert_white_port(int(p)) return True def deleteports(): White_res....
code_fim
medium
{ "lang": "python", "repo": "icysun/opencanary_web", "path": "/service/whiteportservice.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # draw the barcode data and barcode type on the image text = "{} ({})".format(barcodeData, barcodeType) cv2.putText(frame, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2) # if the barcode text is current...
code_fim
hard
{ "lang": "python", "repo": "yellenlab/IncubatorImaging", "path": "/SmartScope/smartscope/gui/Barcode.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yellenlab/IncubatorImaging path: /SmartScope/smartscope/gui/Barcode.py import tkinter as tk from tkinter import filedialog import csv from imutils.video import VideoStream from pyzbar import pyzbar import argparse import datetime import imutils import time import cv2 import os class Barcode: ...
code_fim
hard
{ "lang": "python", "repo": "yellenlab/IncubatorImaging", "path": "/SmartScope/smartscope/gui/Barcode.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # loop over the frames from the video stream while True: # grab the frame from the threaded video stream and resize it to # have a maximum width of 400 pixels frame = vs.read() frame = imutils.resize(frame, width=400) # find the ...
code_fim
hard
{ "lang": "python", "repo": "yellenlab/IncubatorImaging", "path": "/SmartScope/smartscope/gui/Barcode.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>FULL_PRESSURE = 1.0 # force needed for full pressure, eg 0.8 pen pressure will give a full stroke<|fim_prefix|># repo: mhdchehade/pinspiroy-950 path: /config.py #user tablet settings LEFT_HANDED = False #rotate pen and track 180 if true <|fim_middle|># playing with these pressure curves types PR...
code_fim
medium
{ "lang": "python", "repo": "mhdchehade/pinspiroy-950", "path": "/config.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mhdchehade/pinspiroy-950 path: /config.py #user tablet settings LEFT_HANDED = False #rotate pen and track 180 if true <|fim_suffix|>FULL_PRESSURE = 1.0 # force needed for full pressure, eg 0.8 pen pressure will give a full stroke<|fim_middle|># playing with these pressure curves types PR...
code_fim
medium
{ "lang": "python", "repo": "mhdchehade/pinspiroy-950", "path": "/config.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: uc-cdis/workspace-token-service path: /wts/blueprints/external_oidc.py import flask import time from authutils.user import current_user from ..models import db, RefreshToken from ..utils import get_config_var, get_oauth_client blueprint = flask.Blueprint("external_oidc", __name__) blueprint....
code_fim
hard
{ "lang": "python", "repo": "uc-cdis/workspace-token-service", "path": "/wts/blueprints/external_oidc.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def get_refresh_token_expirations(username, idps): """ Returns: dict: IdP to expiration of the most recent refresh token, or None if it's expired. """ now = int(time.time()) refresh_tokens = ( db.session.query(RefreshToken) .filter_by(username=username) ...
code_fim
hard
{ "lang": "python", "repo": "uc-cdis/workspace-token-service", "path": "/wts/blueprints/external_oidc.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: comperical/MirrorEncode path: /script/CompJava.py #!/usr/bin/python import re, os, sys, fileinput from shutil import copyfile INSTALL_DIR = "/userdata/external/mirrenc" def getSrcFileList(): return ["EncoderUtil", "Symbol", "HighPrecCoder", "EventModeler", "ArithBitio", "ModelerTree"] def...
code_fim
hard
{ "lang": "python", "repo": "comperical/MirrorEncode", "path": "/script/CompJava.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Change file back to read-only chmodcall = "chmod 444 %s" % (nearpath) os.system(chmodcall) def compileDir(dirname): jcall = "javac -cp %s/jclass -d %s/jclass %s/java/%s/*.java" % (INSTALL_DIR, INSTALL_DIR, INSTALL_DIR, dirname) print("%s" % (jcall)) os.system(jcall) if __name__ == "__ma...
code_fim
hard
{ "lang": "python", "repo": "comperical/MirrorEncode", "path": "/script/CompJava.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def compileDir(dirname): jcall = "javac -cp %s/jclass -d %s/jclass %s/java/%s/*.java" % (INSTALL_DIR, INSTALL_DIR, INSTALL_DIR, dirname) print("%s" % (jcall)) os.system(jcall) if __name__ == "__main__": """ 1) Copy the code from the main trunk 2) Compile it """ #copyCode2Dir() compil...
code_fim
hard
{ "lang": "python", "repo": "comperical/MirrorEncode", "path": "/script/CompJava.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def main(): h, l = 1, 1 for i in xrange(10,99): for j in xrange(i+1, 100): if isvalid(i, j): l *= i h *= j g = gcd(h, l) print h/g if __name__=="__main__": main()<|fim_prefix|># repo: Cyborn13x/PE path: /PE33.py def isvalid(i,...
code_fim
medium
{ "lang": "python", "repo": "Cyborn13x/PE", "path": "/PE33.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|># repo: Cyborn13x/PE path: /PE33.py def isvalid(i, j): a, b = str(i), str(j) for x in xrange(2): for y in xrange(2): if a[x]==b[y] and a[x]!='0': p = ord(a[1-x])-48 q = ord(b[1-y])-48 if i*q == j*p: return True return...
code_fim
medium
{ "lang": "python", "repo": "Cyborn13x/PE", "path": "/PE33.py", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> h, l = 1, 1 for i in xrange(10,99): for j in xrange(i+1, 100): if isvalid(i, j): l *= i h *= j g = gcd(h, l) print h/g if __name__=="__main__": main()<|fim_prefix|># repo: Cyborn13x/PE path: /PE33.py def isvalid(i, j): a, ...
code_fim
medium
{ "lang": "python", "repo": "Cyborn13x/PE", "path": "/PE33.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> player = cls( json_dict["player_id"], json_dict["name"], json_dict["x"], json_dict["y"], json_dict["direction"], json_dict["status"], ) player.velocity = json_dict["velocity"] player.inventory = Invento...
code_fim
hard
{ "lang": "python", "repo": "Pytown-Citizen/pytown_model", "path": "/src/pytown_model/characters.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Pytown-Citizen/pytown_model path: /src/pytown_model/characters.py import time from pytown_core.serializers import IJSONSerializable from .inventory import Inventory, InventoryFactoryMethod class Character(IJSONSerializable): def __init__(self, name, direction="down", status="idle"): ...
code_fim
hard
{ "lang": "python", "repo": "Pytown-Citizen/pytown_model", "path": "/src/pytown_model/characters.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: signalfx/signalfx-python path: /tests/pyformance_test.py #!/usr/bin/env python # Copyright (C) 2018 SignalFx, Inc. All rights reserved. from pyformance.registry import get_qualname import os import sys import unittest sys.path.insert(0, os.path.join( os.path.dirname(os.path.abspath(__file_...
code_fim
hard
{ "lang": "python", "repo": "signalfx/signalfx-python", "path": "/tests/pyformance_test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pyf.gauge('test_gauge').set_value(1) pyf.gauge('test_gauge_with_dim', default=3, gauge_dim='hello_gauge').set_value(2) self.assertEqual( pyf.global_registry().metadata.get_metadata( 'gauge_dim=hello_gauge.test_gauge_with_dim'), ...
code_fim
hard
{ "lang": "python", "repo": "signalfx/signalfx-python", "path": "/tests/pyformance_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: oikos-cash/oikos path: /legacy/tests/contract_interfaces/self_destructible_interface.py from tests.contract_interfaces.owned_interface import OwnedInterface from utils.deployutils import mine_tx class SelfDestructibleInterface(OwnedInterface): <|fim_suffix|> self.setSelfDestructBeneficia...
code_fim
hard
{ "lang": "python", "repo": "oikos-cash/oikos", "path": "/legacy/tests/contract_interfaces/self_destructible_interface.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.initiationTime = lambda: self.contract.functions.initiationTime().call() self.selfDestructBeneficiary = lambda: self.contract.functions.selfDestructBeneficiary().call() self.selfDestructInitiated = lambda: self.contract.functions.selfDestructInitiated().call() self.SEL...
code_fim
medium
{ "lang": "python", "repo": "oikos-cash/oikos", "path": "/legacy/tests/contract_interfaces/self_destructible_interface.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def print_link_list( head: ListNode): cur = head path = [] while cur: path.append( str(cur.val) ) cur = cur.next print( '->'.join( path ) ) def test_bench(): head_1 = ListNode(3) head_1.next = ListNode(5) head_2 = ListNode(1) head_2.next = ListNo...
code_fim
hard
{ "lang": "python", "repo": "brianchiang-tw/leetcode", "path": "/No_0092_Reverse Linked List II/one_pass_scan.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: brianchiang-tw/leetcode path: /No_0092_Reverse Linked List II/one_pass_scan.py ''' Description: Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: Input: 1->2->3->4->5->NULL, m = 2, n = 4 Output: 1->4->3->2->5->NULL ''' # Definition ...
code_fim
hard
{ "lang": "python", "repo": "brianchiang-tw/leetcode", "path": "/No_0092_Reverse Linked List II/one_pass_scan.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def print_link_list( head: ListNode): cur = head path = [] while cur: path.append( str(cur.val) ) cur = cur.next print( '->'.join( path ) ) def test_bench(): head_1 = ListNode(3) head_1.next = ListNode(5) head_2 = ListNode(1) head_2.next = ListNod...
code_fim
hard
{ "lang": "python", "repo": "brianchiang-tw/leetcode", "path": "/No_0092_Reverse Linked List II/one_pass_scan.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>d = {} def process_inputs(tuples=[], limit=sys.maxint): global d count = 0 with open('/tmp/inputs.json','w') as f: for (native_url,cache_url,sha1,epoch) in tuples: try: # sans http:// uid = hashlib.sha1(native_url[7:]).hexdigest().upper() ...
code_fim
hard
{ "lang": "python", "repo": "pmnyc/Data_Engineering_Collections", "path": "/preparing_data_sets_and_delivery_tools/python/dig/publish/tsvbuild.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: pmnyc/Data_Engineering_Collections path: /preparing_data_sets_and_delivery_tools/python/dig/publish/tsvbuild.py #!/usr/bin/env python import sys import hashlib import time import datetime import requests import simplejson as json from collections import defaultdict import csv def load_inputs(li...
code_fim
hard
{ "lang": "python", "repo": "pmnyc/Data_Engineering_Collections", "path": "/preparing_data_sets_and_delivery_tools/python/dig/publish/tsvbuild.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>else: return h -1 h += 1 return h - 1<|fim_prefix|># repo: JazzikPeng/Algorithm-in-Python path: /274. H-Index.py class Solution: def hIndex(self, citations: List[int]) -> int: citations = sorted(citations, reverse=True) h = 1 for <|fim_middl...
code_fim
hard
{ "lang": "python", "repo": "JazzikPeng/Algorithm-in-Python", "path": "/274. H-Index.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: JazzikPeng/Algorithm-in-Python path: /274. H-Index.py class Solution: def hIndex(self, citations: List[int]) -> int: <|fim_suffix|>else: return h -1 h += 1 return h - 1<|fim_middle|> citations = sorted(citations, reverse=True) h = 1 f...
code_fim
hard
{ "lang": "python", "repo": "JazzikPeng/Algorithm-in-Python", "path": "/274. H-Index.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.build('test') def test_command(self): self.assertRegex(self.build('script'), re.compile(r'^\s*hello script$', re.MULTILINE)) self.assertExists(output_file('file'))<|fim_prefix|># repo: jimporter/bfg9000 path: /test/integration/test_env_vars.py im...
code_fim
easy
{ "lang": "python", "repo": "jimporter/bfg9000", "path": "/test/integration/test_env_vars.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> @skip_if_backend('msbuild') def test_test(self): self.build('test') def test_command(self): self.assertRegex(self.build('script'), re.compile(r'^\s*hello script$', re.MULTILINE)) self.assertExists(output_file('file'))<|fim_prefix|># repo: jimpo...
code_fim
medium
{ "lang": "python", "repo": "jimporter/bfg9000", "path": "/test/integration/test_env_vars.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: jimporter/bfg9000 path: /test/integration/test_env_vars.py import re from . import * class TestEnvVars(IntegrationTest): def __init__(self, *args, **kwargs): super().__init__('env_vars', *args, **kwargs) <|fim_suffix|> self.assertRegex(self.build('script'), ...
code_fim
medium
{ "lang": "python", "repo": "jimporter/bfg9000", "path": "/test/integration/test_env_vars.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: musicalmacdonald/flask-pi-iot path: /library/data_storage/test_stored_readings.py # Add a reading # List readings # Get readings for a given serial number # Get readings for a given date/time range #etc import unittest import datetime import time import random import sqlite3 import pandas from p...
code_fim
hard
{ "lang": "python", "repo": "musicalmacdonald/flask-pi-iot", "path": "/library/data_storage/test_stored_readings.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in range(0, 3): x = random.randint(0, 358) y = random.randint(0, 358) z = random.randint(0, 358) serialNumber = serialNo[i] date = datetime.datetime aSR.add_readings(serialNumber, 'date', x, y, z) fr = aSR.get_f...
code_fim
hard
{ "lang": "python", "repo": "musicalmacdonald/flask-pi-iot", "path": "/library/data_storage/test_stored_readings.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dataList = aSR.get_all_data_as_list() n = aSR.get_number_of_readings() self.assertTrue(type(dataList) == list) self.assertTrue(len(dataList) == n) def test_get_df_as_list(self): print("Starting Get Dataframe as list of Dicts test") dataframe = pandas.D...
code_fim
hard
{ "lang": "python", "repo": "musicalmacdonald/flask-pi-iot", "path": "/library/data_storage/test_stored_readings.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Displays package information.""" with open(Path(root_module_path).parent / "data" / "logo.txt", "r") as file_stream: logo_text = file_stream.read().strip() output = logo_text.split("\n") line = 3 output[line] += f" {embolden(NAME)}" line += 2 output[line] += f"...
code_fim
hard
{ "lang": "python", "repo": "kelvindecosta/picharsso", "path": "/src/cli/info.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kelvindecosta/picharsso path: /src/cli/info.py """This module defines the `picharsso info` command. Refer to https://kelvindecosta.github.io/picharsso/commands/info/. """ <|fim_suffix|> line += 1 output[line] += f" {italicize('License')} : {LICENSE}" line += 1 output[line] +=...
code_fim
hard
{ "lang": "python", "repo": "kelvindecosta/picharsso", "path": "/src/cli/info.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: abhinavsinha1991/openshifter path: /openshifter/ssh.py import logging import paramiko from jinja2 import Template class Ssh: def __init__(self, deployment, cluster): self.deployment = deployment self.cluster = cluster self.hosts = {"*": []} self.clients = {}...
code_fim
hard
{ "lang": "python", "repo": "abhinavsinha1991/openshifter", "path": "/openshifter/ssh.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> class SshClient: def __init__(self, address, deployment, cluster): self.deployment = deployment self.cluster = cluster self.client = None self.address = address self.tags = [] self.logger = logging.getLogger("SSH(%s)" % self.address) def connect(s...
code_fim
hard
{ "lang": "python", "repo": "abhinavsinha1991/openshifter", "path": "/openshifter/ssh.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> try: sftp = self.client.open_sftp() except TimeoutError: self.connect() sftp = self.client.open_sftp() file = sftp.file(target, 'r') data = file.read() file.close() return data class SshResult: def __init__(self, c...
code_fim
hard
{ "lang": "python", "repo": "abhinavsinha1991/openshifter", "path": "/openshifter/ssh.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Sylrael/TPsSpark path: /sparkDatasources.py # -*- coding: utf-8 -*- import sys from pyspark.sql import SparkSession, Row from pyspark.sql.functions import explode, lit if __name__ == "__main__": #initialize config spark = SparkSession\ .builder\ .appName("sparkDatasourcesHive")\ .confi...
code_fim
hard
{ "lang": "python", "repo": "Sylrael/TPsSpark", "path": "/sparkDatasources.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> mergedTable = spark.read.option("mergeSchema", "true").parquet("/tmp/sparkwarehouse/events1") #mergedDF = spark.read.option("mergeSchema", "true").parquet("/tmp/data/test_table") mergedTable.printSchema()<|fim_prefix|># repo: Sylrael/TPsSpark path: /sparkDatasources.py # -*- coding: utf-8 -*- import s...
code_fim
hard
{ "lang": "python", "repo": "Sylrael/TPsSpark", "path": "/sparkDatasources.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #champ.write.mode("overwrite").partitionBy("fields.department", "fields.city").parquet("/tmp/sparkwarehouse/events1/key=1") #marseille = spark.read.parquet("C:/tmp/sparkwarehouse/events/fields.department=Bouches-du-Rhône/fields.city=Marseille") #marseilleSoldout = marseille.withColumn("fields.soldout...
code_fim
hard
{ "lang": "python", "repo": "Sylrael/TPsSpark", "path": "/sparkDatasources.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: red-hat-storage/cephci path: /tests/rados/test_scrub_omap.py """ This file contains the methods to verify the OSD status during large omap entries. AS part of verification the script perform the following tasks- 1. Creating omaps 2. Perform scrub and deepscrub 3. While creating object...
code_fim
hard
{ "lang": "python", "repo": "red-hat-storage/cephci", "path": "/tests/rados/test_scrub_omap.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def verification_osd(rados_object, test_time): """ This method is used to verify the OSD status while performing the scrub,deep-scrub and creating omaps Args: rados_object : RadosOrchestrator object test_time: Used to set the test time """ # The result parameter is us...
code_fim
hard
{ "lang": "python", "repo": "red-hat-storage/cephci", "path": "/tests/rados/test_scrub_omap.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: hmeza/django-referral path: /referral/compat.py from django.conf import settings import django <|fim_suffix|># Django 1.5+ compatibility if django.VERSION >= (1, 5): User = settings.AUTH_USER_MODEL else: from django.contrib.auth.models import User<|fim_middle|>__all__ = ['User', 'AUTH_US...
code_fim
medium
{ "lang": "python", "repo": "hmeza/django-referral", "path": "/referral/compat.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.USER') # Django 1.5+ compatibility if django.VERSION >= (1, 5): User = settings.AUTH_USER_MODEL else: from django.contrib.auth.models import User<|fim_prefix|># repo: hmeza/django-referral path: /referral/compat.py from django.conf imp...
code_fim
easy
{ "lang": "python", "repo": "hmeza/django-referral", "path": "/referral/compat.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Django 1.5+ compatibility if django.VERSION >= (1, 5): User = settings.AUTH_USER_MODEL else: from django.contrib.auth.models import User<|fim_prefix|># repo: hmeza/django-referral path: /referral/compat.py from django.conf import settings import django __all__ = ['User', 'AUTH_USER_MODEL'] <|...
code_fim
medium
{ "lang": "python", "repo": "hmeza/django-referral", "path": "/referral/compat.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kopok2/CodeforcesSolutionsPython path: /src/230A/test_cdf_230A.py import unittest from unittest.mock import patch from cdf_230A import CodeforcesTask230ASolution <|fim_suffix|> self.assertEqual(expected, actual) def test_230A_acceptance_2(self): mock_input = ['10 1', '100 1...
code_fim
hard
{ "lang": "python", "repo": "kopok2/CodeforcesSolutionsPython", "path": "/src/230A/test_cdf_230A.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_230A_acceptance_2(self): mock_input = ['10 1', '100 100'] expected = 'NO' with patch('builtins.input', side_effect=mock_input): Solution = CodeforcesTask230ASolution() Solution.read_input() Solution.process_task() actual ...
code_fim
medium
{ "lang": "python", "repo": "kopok2/CodeforcesSolutionsPython", "path": "/src/230A/test_cdf_230A.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>p://mypy-lang.org/ # # Python2 support with `mypy --py2 program.py` kind of commands # def add(p1: int, p2: int) -> int: return p1 + p2<|fim_prefix|># repo: hygull/stkovrflw path: /2020/new_python_concepts/01_optional_static_typing_int_addition.py # Optional Static Typing in Python 3.6+ # # pip3.6 i...
code_fim
medium
{ "lang": "python", "repo": "hygull/stkovrflw", "path": "/2020/new_python_concepts/01_optional_static_typing_int_addition.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: hygull/stkovrflw path: /2020/new_python_concepts/01_optional_static_typing_int_addition.py # Optional Static Typing in Python 3.6+ # # pip3.6 install mypy # # <|fim_suffix|>ind of commands # def add(p1: int, p2: int) -> int: return p1 + p2<|fim_middle|>Mypy is an optional static type checker...
code_fim
medium
{ "lang": "python", "repo": "hygull/stkovrflw", "path": "/2020/new_python_concepts/01_optional_static_typing_int_addition.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> :param prompt: The prompt to display to the user. :param default: (optional) The response to return if the user provides no input. :returns: The content entered by the user. """ try: user_input = self(prompt) if default is not Non...
code_fim
hard
{ "lang": "python", "repo": "IvanaXu/PyTools", "path": "/077.Test_BeeWare_windows/beeware-tutorial/beeware-venv/Lib/site-packages/briefcase/console.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "Make Console present the same interface as input()" if not self.enabled: raise InputDisabled() return self._input(prompt) def select_option(options, input, prompt='> ', error="Invalid selection"): """ Prompt the user for a choice from a list of options. ...
code_fim
hard
{ "lang": "python", "repo": "IvanaXu/PyTools", "path": "/077.Test_BeeWare_windows/beeware-tutorial/beeware-venv/Lib/site-packages/briefcase/console.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: IvanaXu/PyTools path: /077.Test_BeeWare_windows/beeware-tutorial/beeware-venv/Lib/site-packages/briefcase/console.py import operator class InputDisabled(Exception): def __init__(self): super().__init__( "Input is disabled; cannot request user input without a default" ...
code_fim
hard
{ "lang": "python", "repo": "IvanaXu/PyTools", "path": "/077.Test_BeeWare_windows/beeware-tutorial/beeware-venv/Lib/site-packages/briefcase/console.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mutilin/klever path: /klever/core/vtg/emg/common/process/actions.py on) for key in self._process_actions: if obj in self._process_actions[key]: self._process_actions[key].remove(obj) def clone(self): """ Recursively clone the collection of ...
code_fim
hard
{ "lang": "python", "repo": "mutilin/klever", "path": "/klever/core/vtg/emg/common/process/actions.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert isinstance(root, BaseAction) or root is None, type(root).__name__ first = set() if not root: process = {self.initial_action} else: process = {root} while process: a = process.pop() if isinstance(a, Concatenati...
code_fim
hard
{ "lang": "python", "repo": "mutilin/klever", "path": "/klever/core/vtg/emg/common/process/actions.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> processes = {str(p): p for p in model.processes if restrict_to is None or str(p) in restrict_to} # Check actions for name, actions in ((name, process.actions) for name, process in processes.items()): if not self.compatible(name, actions): return False ...
code_fim
hard
{ "lang": "python", "repo": "mutilin/klever", "path": "/klever/core/vtg/emg/common/process/actions.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: nopper/wikibench path: /wikibench/metrics.py class Metrics(object): def __init__(self, fp=0, fn=0, tp=0, tn=0): # Just as recap: # FP: non c'e' ma la becco # FN: c'e' e non la becco # TP: c'e' e la becco # TN: non c'e' e non la becco self.fp = ...
code_fim
hard
{ "lang": "python", "repo": "nopper/wikibench", "path": "/wikibench/metrics.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def macro_f1(self): if not self.metrics: return 0 f1_sum = sum(map(lambda x: x.f1(), self.metrics)) return float(f1_sum) / len(self.metrics) def macro_precision(self): if not self.metrics: return 0 precision_sum = sum(map(lambda x: x...
code_fim
hard
{ "lang": "python", "repo": "nopper/wikibench", "path": "/wikibench/metrics.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> 'zones': {'zone_name': 'UnicodeString'}, 'view_dependencies': {'view_dependency': 'UnicodeString'}, 'zone_types': {'zone_type': 'UnicodeString'}, 'zone_view_assignments': {'zone_view_assignments_zone_name': 'UnicodeString', 'zone_view_assignments_view...
code_fim
hard
{ "lang": "python", "repo": "BackupGGCode/roster-dns-management", "path": "/roster-core/roster_core/constants.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: BackupGGCode/roster-dns-management path: /roster-core/roster_core/constants.py to overwrite these tables when doing a partial replay TABLES_NOT_AUDIT_LOGGED = ['audit_log', 'locks'] # This is a list of record types that can be indexed by IP address. RECORD_TYPES_INDEXED_BY_IP = ['ptr', 'a', 'aaa...
code_fim
hard
{ "lang": "python", "repo": "BackupGGCode/roster-dns-management", "path": "/roster-core/roster_core/constants.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> 'RemoveReverseRangePermission': {'check': False, 'write': True, 'access_level': ACCESS_LEVELS['dns_admin']}, 'GetCIDRBlocksByView': {'check': False, 'write': False, 'access_...
code_fim
hard
{ "lang": "python", "repo": "BackupGGCode/roster-dns-management", "path": "/roster-core/roster_core/constants.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>emowy/$', ObiegCreateView.as_view(), name='dodaj-pozasystemowy'), url(r'^(?P<slug>[\w-]+)/$', PwObiegiDetailView.as_view(), name='detail'), ]<|fim_prefix|># repo: bartoszcholewa/promax-workflow path: /src/pw_obiegi/urls.py from django.conf.urls import url from pw_obiegi.views import PwObiegiListView...
code_fim
medium
{ "lang": "python", "repo": "bartoszcholewa/promax-workflow", "path": "/src/pw_obiegi/urls.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: bartoszcholewa/promax-workflow path: /src/pw_obiegi/urls.py from django.conf.urls import url from pw_obiegi.views import PwObiegiListView, PwObiegiDetailView, ObiegCreateView from django.views.generic impo<|fim_suffix|>emowy/$', ObiegCreateView.as_view(), name='dodaj-pozasystemowy'), url(r'^(...
code_fim
hard
{ "lang": "python", "repo": "bartoszcholewa/promax-workflow", "path": "/src/pw_obiegi/urls.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ARGUMENTS = ["alias",RESOURCEID,DESIRED_ALIAS] PROCEDURE = "map" CALLREQUEST1 = {"id" : 1, "procedure":PROCEDURE, "arguments":ARGUMENTS} CALLS = [CALLREQUEST1] AUTH = { "cik" : DEVICECIK } RPC = { "auth" : AUTH, "calls":CALLS} json_rpc = json.dumps(RPC) s = socket.socket(socket.AF_INET, socket.SOCK_STRE...
code_fim
hard
{ "lang": "python", "repo": "exosite-garage/utility_scripts", "path": "/rpc_alias_a_rid.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: exosite-garage/utility_scripts path: /rpc_alias_a_rid.py #============================================================================== # rpc_alias_a_rid.py # Python script that creates an alias for a RID (dataport, datarule, dispatch, etc) # #====================================================...
code_fim
hard
{ "lang": "python", "repo": "exosite-garage/utility_scripts", "path": "/rpc_alias_a_rid.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>urlpatterns = [ # Uncomment the next line to enable the admin: path("admin/", admin.site.urls), path( "logout/", auth_views.LogoutView.as_view(next_page="/"), name="auth_logout", ), path("", HomeView.as_view(), name="home"), path( "data_apis/data/", ...
code_fim
hard
{ "lang": "python", "repo": "DemocracyClub/Website", "path": "/democracy_club/urls.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: DemocracyClub/Website path: /democracy_club/urls.py # -*- coding: utf-8 -*- from core.views import HomeView from django.conf import settings from django.conf.urls.static import static # Uncomment the next two lines to enable the admin: from django.contrib import admin from django.contrib.auth i...
code_fim
hard
{ "lang": "python", "repo": "DemocracyClub/Website", "path": "/democracy_club/urls.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> r = chazutsu.datasets.ReutersNews(kind="topics").download(directory=self.test_dir, force=True) self.assertTrue(len(r.data().columns), 3) print(r.data().columns) shutil.rmtree(r.root) def test_industries(self): r = chazutsu.datasets.ReutersNews().industries().do...
code_fim
medium
{ "lang": "python", "repo": "ahmad-abdellatif/chazutsu", "path": "/tests/test_reuters_news.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ahmad-abdellatif/chazutsu path: /tests/test_reuters_news.py import os import sys import shutil import unittest sys.path.append(os.path.join(os.path.dirname(__file__), "../")) import chazutsu.datasets from tests.dataset_base_test import DatasetTestCase class TestReutersNews(DatasetTestCase): <|...
code_fim
hard
{ "lang": "python", "repo": "ahmad-abdellatif/chazutsu", "path": "/tests/test_reuters_news.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # print print("line" , line) time.sleep(0.1) except KeyboardInterrupt: pass except IOError: print("io error") time.sleep(0.1)<|fim_prefix|># repo: i-makinori/redsight path: /raspi/test/line.py #!/usr/bin/python -u # -*- coding: utf-8 -*- import smbus import time ##...
code_fim
easy
{ "lang": "python", "repo": "i-makinori/redsight", "path": "/raspi/test/line.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: i-makinori/redsight path: /raspi/test/line.py #!/usr/bin/python -u # -*- coding: utf-8 -*- import smbus import time ## Motor Driver bus = smbus.SMBus(1) addr = 0x5e <|fim_suffix|> time.sleep(0.1) except KeyboardInterrupt: pass except IOError: print("io error") time.sl...
code_fim
medium
{ "lang": "python", "repo": "i-makinori/redsight", "path": "/raspi/test/line.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def _update_items(self): """ Update the list of all files and folders contained in the folder. Currently these items are not ordered. """ self._item_list = [] for f in os.listdir(self._folder): # Skip text files # -> It is impor...
code_fim
hard
{ "lang": "python", "repo": "Founding-Hackers/delta", "path": "/delta/imagery/disk_folder_cache.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Founding-Hackers/delta path: /delta/imagery/disk_folder_cache.py # Copyright © 2020, United States Government, as represented by the # Administrator of the National Aeronautics and Space Administration. # All rights reserved. # # The DELTA (Deep Earth Learning, Tools, and Analysis) platform is # ...
code_fim
hard
{ "lang": "python", "repo": "Founding-Hackers/delta", "path": "/delta/imagery/disk_folder_cache.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def initialize(self): """ Initializes the mean model for all of the training data. """ LOG.info("Initializing Model.") self.model = self.convert(df=self.training_df) if self.bootstraps is not None: LOG.info("Bootstrapping Data.") ...
code_fim
hard
{ "lang": "python", "repo": "ihmeuw-msca/CorrelatedCounts", "path": "/src/ccount/run.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ihmeuw-msca/CorrelatedCounts path: /src/ccount/run.py """Easy functions for initializing a correlated count model.""" import numpy as np import logging import pandas as pd import multiprocessing as mp from ccount.models import MODEL_DICT LOG = logging.getLogger(__name__) def initialize_model...
code_fim
hard
{ "lang": "python", "repo": "ihmeuw-msca/CorrelatedCounts", "path": "/src/ccount/run.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class MRPC(object): def __init__(self, guid = None, **kwargs): self.service = Service(self) self.services = {} self.transport = SocketTransport(self, **kwargs) if guid is None: guid = uuid.uuid4() self.guid = guid self.aliases = [guid.hex] ...
code_fim
hard
{ "lang": "python", "repo": "alex-sherman/mrpc-python", "path": "/mrpc/MRPC.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: alex-sherman/mrpc-python path: /mrpc/MRPC.py from __future__ import print_function import uuid import time from collections import defaultdict from .message import Message from .path import Path from .proxy import RPCRequest, Proxy import inspect from . import exception from .service import Servi...
code_fim
hard
{ "lang": "python", "repo": "alex-sherman/mrpc-python", "path": "/mrpc/MRPC.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self._request_id += 1 return self._request_id def event(self, delay, callback): self.events.append((time.time() + delay, callback)) self.events = sorted(self.events) def rpc(self, path, value = None, timeout = 3, resend_delay = 0.5): msg = Message( ...
code_fim
hard
{ "lang": "python", "repo": "alex-sherman/mrpc-python", "path": "/mrpc/MRPC.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sakost/tinkoff_fintech path: /homework1/battleship/ships.py from typing import Union from battleship.exceptions import InvalidCoordinateException from battleship.utils import Coordinate, Rotation class Ship: """ this class represents the ship """ def __init__(self, ship_size: ...
code_fim
hard
{ "lang": "python", "repo": "sakost/tinkoff_fintech", "path": "/homework1/battleship/ships.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @property def damaged_cells(self) -> frozenset[Coordinate]: """ :return: damaged cells of the ship :rtype: frozenset """ return frozenset(self._damaged_cells) @property def damaged(self) -> bool: """ check if the ship was damaged ...
code_fim
hard
{ "lang": "python", "repo": "sakost/tinkoff_fintech", "path": "/homework1/battleship/ships.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def _update_coords(self): """ updates the cached coordinates of ship """ x, y = self._head_coord.x, self._head_coord.y dx, dy = 0, 0 if self._rotation == Rotation.HORIZONTAL: dx = 1 elif self._rotation == Rotation.VERTICAL: ...
code_fim
hard
{ "lang": "python", "repo": "sakost/tinkoff_fintech", "path": "/homework1/battleship/ships.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> result = self.app.context["client"].quotas.get_free_domain_quotas() return self.setup_columns(reformat_quotas(result._info), parsed_args)<|fim_prefix|># repo: TruePack/python-selvpcclient path: /selvpcclient/commands/limit.py from selvpcclient.base import ListCommand from selvpcclient.for...
code_fim
hard
{ "lang": "python", "repo": "TruePack/python-selvpcclient", "path": "/selvpcclient/commands/limit.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> @handle_http_error def take_action(self, parsed_args): result = self.app.context["client"].quotas.get_free_domain_quotas() return self.setup_columns(reformat_quotas(result._info), parsed_args)<|fim_prefix|># repo: TruePack/python-selvpcclient path: /selvpcclient/commands/limit.py ...
code_fim
hard
{ "lang": "python", "repo": "TruePack/python-selvpcclient", "path": "/selvpcclient/commands/limit.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: TruePack/python-selvpcclient path: /selvpcclient/commands/limit.py from selvpcclient.base import ListCommand from selvpcclient.formatters import join_by_key, reformat_quotas from selvpcclient.util import handle_http_error class List(ListCommand): """Show domain quotas""" columns = ["re...
code_fim
medium
{ "lang": "python", "repo": "TruePack/python-selvpcclient", "path": "/selvpcclient/commands/limit.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> net = PlantNetwork(env, name, seed=1) # The target (q) q_target = nengo.Node(np.sin, label=('Target ' + name + q_name)) nengo.Connection(q_target, net.q_target, synapse=None) # The derivative of the target angle signal (dq) dq_target = nengo.Node(None, size_in=1, label='dq...
code_fim
hard
{ "lang": "python", "repo": "simondlevy/gym-copter", "path": "/nengo/adaptive.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: simondlevy/gym-copter path: /nengo/adaptive.py ''' Nengo adaptive controller with PES learning Copyright (C) 2021 Xuan Choo, Simon D. Levy MIT License ''' import nengo import numpy as np class PlantNetwork(nengo.Network): def __init__(self, env, label, **kwargs): ...
code_fim
hard
{ "lang": "python", "repo": "simondlevy/gym-copter", "path": "/nengo/adaptive.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> k_d = 0.2 nengo.Connection(dq_diff, net.u, transform=k_d, synapse=None) def zero(x): return [0] with nengo.Network() as adapt_ens: n_neurons = 1000 dimensions = 1 learning_rate = 1e-5 output_func = zero # Inputs and outputs f...
code_fim
hard
{ "lang": "python", "repo": "simondlevy/gym-copter", "path": "/nengo/adaptive.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Calls the renderer which handles RCS context, and then calls back to the client to show response self._renderer.render(client_context, response) def process_response(self, client_context, response): del client_context outputLog(self, response) def process_questi...
code_fim
hard
{ "lang": "python", "repo": "keiffster/program-y", "path": "/src/programy/clients/events/console/client.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def process_question(self, client_context, question): self._questions += 1 return client_context.bot.ask_question(client_context, question, responselogger=self) def render_response(self, client_context, response): # Calls the renderer which handles RCS context, and then ca...
code_fim
hard
{ "lang": "python", "repo": "keiffster/program-y", "path": "/src/programy/clients/events/console/client.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: keiffster/program-y path: /src/programy/clients/events/console/client.py """ Copyright (c) 2016-2020 Keith Sterling http://www.keithsterling.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to d...
code_fim
hard
{ "lang": "python", "repo": "keiffster/program-y", "path": "/src/programy/clients/events/console/client.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: openai/neural-mmo path: /jsuarez/Curiosity.py class PhiNet(nn.Module): def __init__(self, xdim, h): super().__init__() self.conv1 = Conv2d(8, int(h/2), 3, stride=2) self.conv2 = Conv2d(int(h/2), h, 3, stride=2) self.fc1 = torch.nn.Linear(5+4*4*h, h) self.fc2 = to...
code_fim
hard
{ "lang": "python", "repo": "openai/neural-mmo", "path": "/jsuarez/Curiosity.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #Stop both phi's on forward, train both on backward. Confirmed by Harri fLoss = self.forwardsDynamics(atn, phiPrev.detach(), phi.detach()) bLoss = self.backwardsDynamics(phiPrev, phi, atn) ri = fLoss.data[0] li = 0.20*fLoss + 0.80*bLoss else: r...
code_fim
hard
{ "lang": "python", "repo": "openai/neural-mmo", "path": "/jsuarez/Curiosity.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class BackwardsNet(nn.Module): def __init__(self, h, ydim): super().__init__() self.loss = torch.nn.CrossEntropyLoss() self.fc1 = torch.nn.Linear(2*h, h) self.fc2 = torch.nn.Linear(h, ydim) def forward(self, phiPrev, phi, atn): x = torch.cat((phiPrev, phi), 1) x...
code_fim
hard
{ "lang": "python", "repo": "openai/neural-mmo", "path": "/jsuarez/Curiosity.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> from gym_copter.rendering.twod import TwoDHoverRenderer # Create viewer if not done yet if self.viewer is None: self.viewer = TwoDHoverRenderer(self, one_d=True) return self.viewer.render(mode, self.pose, self.spinning) # return self.viewer._com...
code_fim
medium
{ "lang": "python", "repo": "simondlevy/gym-copter", "path": "/attic/gym_copter/envs/hover1d.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: simondlevy/gym-copter path: /attic/gym_copter/envs/hover1d.py ''' 2D Copter hovering Copyright (C) 2021 Simon D. Levy MIT License ''' from gym_copter.envs.hover import _Hover class Hover1D(_Hover): def __init__(self): <|fim_suffix|> # Create viewer if not done yet...
code_fim
hard
{ "lang": "python", "repo": "simondlevy/gym-copter", "path": "/attic/gym_copter/envs/hover1d.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }