text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> ctx = {} ctx['ip'] = get_ip() ctx['main_url'] = 'http://{ip}:8000'.format(**ctx) ctx['wallet'] = Wallet.objects.first() return ctx<|fim_prefix|># repo: one-quaker/imfs path: /web/context_processors.py import os import sys from .models import Photo, Wallet def get_ip(): if sys.p...
code_fim
medium
{ "lang": "python", "repo": "one-quaker/imfs", "path": "/web/context_processors.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def get_base_data(request): ctx = {} ctx['ip'] = get_ip() ctx['main_url'] = 'http://{ip}:8000'.format(**ctx) ctx['wallet'] = Wallet.objects.first() return ctx<|fim_prefix|># repo: one-quaker/imfs path: /web/context_processors.py import os import sys from .models import Photo, Wallet...
code_fim
hard
{ "lang": "python", "repo": "one-quaker/imfs", "path": "/web/context_processors.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def main(): with open("Input.txt", "r") as input_file: string = input_file.readline().strip() gc_counts = [float(num) for num in input_file.readline().strip().split()] print(''.join('{:5.3f} '.format(lgsum) for lgsum in map(lambda x : get_string_probability_lg(string, x), gc_counts))) main()<|fim...
code_fim
medium
{ "lang": "python", "repo": "Daerdemandt/Learning-bioinformatics", "path": "/PROB/Solution.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> with open("Input.txt", "r") as input_file: string = input_file.readline().strip() gc_counts = [float(num) for num in input_file.readline().strip().split()] print(''.join('{:5.3f} '.format(lgsum) for lgsum in map(lambda x : get_string_probability_lg(string, x), gc_counts))) main()<|fim_prefix|># r...
code_fim
medium
{ "lang": "python", "repo": "Daerdemandt/Learning-bioinformatics", "path": "/PROB/Solution.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Daerdemandt/Learning-bioinformatics path: /PROB/Solution.py #!/usr/bin/env python3 from math import log10 def get_string_probability_lg(string, gc): gc_count = string.count('G') + string.count('C') gc_log, at_log = log10(gc/2), log10((1 - gc)/2) return gc_count * gc_log + (len(string) - gc_co...
code_fim
medium
{ "lang": "python", "repo": "Daerdemandt/Learning-bioinformatics", "path": "/PROB/Solution.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: sauerseb/Week-Nine-Assignment path: /lab9.py # Evan Sauers & Daniel Rush # Intro to Computer Science I # Collabortaed with Dr. Neumann # lab9.py #Take the word, turn it into a list, and create spaces inbetween letters def sortString(word): word = word.lower() myList = list(word) myL...
code_fim
hard
{ "lang": "python", "repo": "sauerseb/Week-Nine-Assignment", "path": "/lab9.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Ask Question if word[0] == "v": sortedWord = sortString(word) dictionary[sortedWord] = word fileHandle.close() # Find the Anagram in the dictionary, read the file, print def findAnagrams(fileName, aDict): fileHandle = open(fileName, "r") ...
code_fim
hard
{ "lang": "python", "repo": "sauerseb/Week-Nine-Assignment", "path": "/lab9.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> aDict = {} filename = 'wordList.txt' quizList = 'quizwords.txt' createDictionary(filename, aDict) findAnagrams(quizList, aDict) main()<|fim_prefix|># repo: sauerseb/Week-Nine-Assignment path: /lab9.py # Evan Sauers & Daniel Rush # Intro to Computer Science I # Collabortaed with Dr. N...
code_fim
hard
{ "lang": "python", "repo": "sauerseb/Week-Nine-Assignment", "path": "/lab9.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jiajunshen/partsNet path: /pnet/parts_layer.py from __future__ import division, print_function, absolute_import # TODO: Temp import matplotlib as mpl mpl.use('Agg') from scipy.special import logit import numpy as np import itertools as itr import amitgroup as ag from pnet.layer import Layer im...
code_fim
hard
{ "lang": "python", "repo": "jiajunshen/partsNet", "path": "/pnet/parts_layer.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> from pylab import cm D = self._parts.shape[-1] N = self._num_parts # Plot all the parts grid = pnet.plot.ImageGrid(N, D, self._part_shape) print('SHAPE', self._parts.shape) cdict1 = {'red': ((0.0, 0.0, 0.0), (0.5, 0.0, 0...
code_fim
hard
{ "lang": "python", "repo": "jiajunshen/partsNet", "path": "/pnet/parts_layer.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> np.random.seed(42) X = from_2d_array_to_nested( pd.DataFrame(data=np.random.randn(n_instances, len_series)) ) trans = PCATransformer(n_components=n_components) Xt = trans.fit_transform(X) # Check number of rows and output type. assert isinstance(Xt, pd.DataFrame) ...
code_fim
hard
{ "lang": "python", "repo": "earthinversion/sktime", "path": "/sktime/transformations/panel/tests/test_PCATransformer.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: earthinversion/sktime path: /sktime/transformations/panel/tests/test_PCATransformer.py # -*- coding: utf-8 -*- import numpy as np import pandas as pd import pytest from sklearn.decomposition import PCA from sktime.exceptions import NotFittedError from sktime.transformations.panel.pca import PCAT...
code_fim
hard
{ "lang": "python", "repo": "earthinversion/sktime", "path": "/sktime/transformations/panel/tests/test_PCATransformer.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # Check number of principal components in the output. assert from_nested_to_2d_array(Xt).shape[1] == min( n_components, from_nested_to_2d_array(X).shape[1] ) # Check that the returned values agree with those produced by # ``sklearn.decomposition.PCA`` @pytest.mark.parametrize("n_comp...
code_fim
hard
{ "lang": "python", "repo": "earthinversion/sktime", "path": "/sktime/transformations/panel/tests/test_PCATransformer.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> elif nn == "0x001e": # Adds VX to I. self.i += self.v[x] elif nn == "0x0029": # Sets I to the location of the sprite for the character in VX. # Characters 0-F (in hexadecimal) are represented by a 4x5 ...
code_fim
hard
{ "lang": "python", "repo": "LeoLamCY/c8emu", "path": "/chip8.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> elif n == "0x0005": # VY is subtracted from VX. VF is set to 0 when there's a # borrow, and 1 when there isn't. self.v[x] -= self.v[y] if self.v[x] < 0: self.v[0xF] = 0 self.v[x] += 256 ...
code_fim
hard
{ "lang": "python", "repo": "LeoLamCY/c8emu", "path": "/chip8.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: LeoLamCY/c8emu path: /chip8.py import random class Chip8(object): ERROR_UNKNOWN_OPCODE = "ERROR: unknown opcode" running = False count = 0 font_set = [ 0xF0, 0x90, 0x90, 0x90, 0xF0, 0x20, 0x60, 0x20, 0x20, 0x70, 0xF0, 0x10, 0xF0, 0x80, 0xF0, 0xF0...
code_fim
hard
{ "lang": "python", "repo": "LeoLamCY/c8emu", "path": "/chip8.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> func_groups : :class:`tuple` of :class:`.FunctionalGroup` The functional group clones added to the constructed molecule. vertices : :class:`tuple` of :class:`.Vertex` All vertices in the topology graph. The index of each vertex must match it...
code_fim
hard
{ "lang": "python", "repo": "llsonkimm/stk", "path": "/src/stk/molecular/topology_graphs/cage/base.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: llsonkimm/stk path: /src/stk/molecular/topology_graphs/cage/base.py lf._place_linear_building_block( building_block=building_block, vertices=vertices, edges=edges ) return self._place_nonlinear_building_block( buildin...
code_fim
hard
{ "lang": "python", "repo": "llsonkimm/stk", "path": "/src/stk/molecular/topology_graphs/cage/base.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> building_block, fg0_direction, bonder_centroid, axis ): def angle(fg_id): func_group = building_block.func_groups[fg_id] coord = building_block.get_centroid( atom_ids=func_group.get_bonder_ids() ) ...
code_fim
hard
{ "lang": "python", "repo": "llsonkimm/stk", "path": "/src/stk/molecular/topology_graphs/cage/base.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>wait = 10 * 60 while True: repo.remotes.origin.pull() if last_build == repo.head.object.hexsha: logging.debug("Up-to-date, sleeping %d seconds" % wait) import time time.sleep(wait) continue logging.info("Update! Our head %s, remote head %s", last_build...
code_fim
hard
{ "lang": "python", "repo": "BitcoinUnlimited/ElectrsCash", "path": "/contrib/build/latest-build-publisher.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>try: import git except Exception as e: logging.error("Failed to 'import git'") logging.error("Tip: On Debian/Ubuntu you need to install python3-git") sys.exit(1) # Start webserver class HTTPHandler(http.server.SimpleHTTPRequestHandler): def __init__(self, *init_args, **init_kwargs): ...
code_fim
hard
{ "lang": "python", "repo": "BitcoinUnlimited/ElectrsCash", "path": "/contrib/build/latest-build-publisher.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: BitcoinUnlimited/ElectrsCash path: /contrib/build/latest-build-publisher.py #!/usr/bin/env python3 # Copyright (c) 2019 The Bitcoin Unlimited developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. ''' Th...
code_fim
hard
{ "lang": "python", "repo": "BitcoinUnlimited/ElectrsCash", "path": "/contrib/build/latest-build-publisher.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: patrick-luo/Leet-Code path: /482. License Key Formatting.py """Something wrong with Leetcode's testing""" class Solution(object): def licenseKeyFormatting(self, S, K): """ :type S: str :type K: int :rtype: str <|fim_suffix|>el buff[:] buff.reverse...
code_fim
hard
{ "lang": "python", "repo": "patrick-luo/Leet-Code", "path": "/482. License Key Formatting.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>el buff[:] buff.reverse() words.append(''.join(buff)) ans = words[-1] for i in xrange(len(words)-2, -1, -1): ans += '-' + words[i] return ans<|fim_prefix|># repo: patrick-luo/Leet-Code path: /482. License Key Formatting.py """Something wrong with Leetco...
code_fim
hard
{ "lang": "python", "repo": "patrick-luo/Leet-Code", "path": "/482. License Key Formatting.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: asmello/source-bot path: /src/sauce_bot/schemas/user_feed.py from sqlalchemy import Column, Integer, ForeignKey <|fim_suffix|> return f"<UserFeed(user_id='{self.user_id}', feed_id='{self.feed_id}')>" def to_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}<|...
code_fim
hard
{ "lang": "python", "repo": "asmello/source-bot", "path": "/src/sauce_bot/schemas/user_feed.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def to_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}<|fim_prefix|># repo: asmello/source-bot path: /src/sauce_bot/schemas/user_feed.py from sqlalchemy import Column, Integer, ForeignKey from . import Base class UserFeed(Base): <|fim_middle|> __tablename__ = 'use...
code_fim
hard
{ "lang": "python", "repo": "asmello/source-bot", "path": "/src/sauce_bot/schemas/user_feed.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class UserFeed(Base): __tablename__ = 'user_feeds' user_id = Column('user_id', ForeignKey('users.db_id'), primary_key=True) feed_id = Column('feed_id', ForeignKey('feeds.db_id'), primary_key=True) def __repr__(self): return f"<UserFeed(user_id='{self.user_id}', feed_id='{self.feed_id}')>" def to...
code_fim
easy
{ "lang": "python", "repo": "asmello/source-bot", "path": "/src/sauce_bot/schemas/user_feed.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: magico13/KCTR path: /version.py import sys import json import os build = 0 if len(sys.argv) > 1: build = int(sys.argv[1]) # read data out of the version file with open('KCTR.version') as f: data = json.load(f) <|fim_suffix|># write to the version.cs file with the updated version with o...
code_fim
hard
{ "lang": "python", "repo": "magico13/KCTR", "path": "/version.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># write back to the version file with the updated build number with open('KCTR.version', 'w') as f: json.dump(data, f, indent=2) with open('version.txt', 'w') as f: f.write(f'{fullVer}\n') # write to the version.cs file with the updated version with open('KCTR/Properties/VersionInfo.cs', 'w') as...
code_fim
medium
{ "lang": "python", "repo": "magico13/KCTR", "path": "/version.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Parallel(n_jobs=20)(delayed(helper)(x) for x in train_file_names)<|fim_prefix|># repo: VENHEADs/kaggle_camera path: /filter_new_flickr.py from pathlib import Path import jpeg4py import os from joblib import Parallel, delayed data_path = Path('data') train_path = data_path / 'new_flickr' <|fim_middle|>...
code_fim
medium
{ "lang": "python", "repo": "VENHEADs/kaggle_camera", "path": "/filter_new_flickr.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: VENHEADs/kaggle_camera path: /filter_new_flickr.py from pathlib import Path import jpeg4py import os from joblib import Parallel, delayed data_path = Path('data') train_path = data_path / 'new_flickr' <|fim_suffix|> Parallel(n_jobs=20)(delayed(helper)(x) for x in train_file_names)<|fim_middle|>...
code_fim
medium
{ "lang": "python", "repo": "VENHEADs/kaggle_camera", "path": "/filter_new_flickr.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def Log_Analysis(self): count_404 = 0 count_500 = 0 ip = 0 pv = 0 filelist = self.getFilelist() print filelist log = LogToMysql("/data/woyaoce/201605") log.Log_Analysis()<|fim_prefix|># repo: hulm/nlog path: /nlog/script/log_to_db.py #!/usr/bin/env python # -*- coding:utf-8 —*- import sys i...
code_fim
hard
{ "lang": "python", "repo": "hulm/nlog", "path": "/nlog/script/log_to_db.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>log = LogToMysql("/data/woyaoce/201605") log.Log_Analysis()<|fim_prefix|># repo: hulm/nlog path: /nlog/script/log_to_db.py #!/usr/bin/env python # -*- coding:utf-8 —*- import sys import os class LogToMysql: def __init__(self,log_path): self.log_path = log_path def getFilelist(self): file...
code_fim
medium
{ "lang": "python", "repo": "hulm/nlog", "path": "/nlog/script/log_to_db.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: hulm/nlog path: /nlog/script/log_to_db.py #!/usr/bin/env python # -*- coding:utf-8 —*- import sys import os class LogToMysql: def __init__(self,log_path): <|fim_suffix|> def getFilelist(self): filelist=[] for file in os.listdir(self.log_path): filelist.append(self.log_path+'/'+file...
code_fim
easy
{ "lang": "python", "repo": "hulm/nlog", "path": "/nlog/script/log_to_db.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def test_update_emergency_settings(self, request_mock): telnyx.PhoneNumberJob.update_emergency_settings( emergency_address_id="53829456729313", emergency_enabled=True, phone_numbers=[], ) request_mock.assert_requested( "post", "/v...
code_fim
hard
{ "lang": "python", "repo": "team-telnyx/telnyx-python", "path": "/tests/api_resources/test_phone_number_job.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: team-telnyx/telnyx-python path: /tests/api_resources/test_phone_number_job.py from __future__ import absolute_import, division, print_function import telnyx TEST_RESOURCE_ID = "1293384261075731499" class TestPhoneNumberJob(object): def test_is_listable(self, request_mock): resourc...
code_fim
hard
{ "lang": "python", "repo": "team-telnyx/telnyx-python", "path": "/tests/api_resources/test_phone_number_job.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: WealthCity/realtime_talib path: /test.py import indicators as ind import pipeline as pl <|fim_suffix|>HistData = pl.pullHistoricalData(ticker, endDate) LiveData = pl.pullLiveData(ticker, True) SPY_Ind = ind.Indicator(ticker, endDate) print SPY_Ind.MA(0, 14) print SPY_Ind.RSI(12)<|fim_middle|>t...
code_fim
easy
{ "lang": "python", "repo": "WealthCity/realtime_talib", "path": "/test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>print SPY_Ind.MA(0, 14) print SPY_Ind.RSI(12)<|fim_prefix|># repo: WealthCity/realtime_talib path: /test.py import indicators as ind import pipeline as pl <|fim_middle|>ticker = 'SPY' endDate = '2016-05-12' HistData = pl.pullHistoricalData(ticker, endDate) LiveData = pl.pullLiveData(ticker, True) SPY_...
code_fim
medium
{ "lang": "python", "repo": "WealthCity/realtime_talib", "path": "/test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Platron/python-sdk path: /tests/integration/receipt_test.py from xml.etree.ElementTree import fromstring from .base_integration_test import BaseIntegrationTest from platron.request.clients.post_client import PostClient from platron.request.request_builders.receipt_builder import ReceiptBuilder f...
code_fim
hard
{ "lang": "python", "repo": "Platron/python-sdk", "path": "/tests/integration/receipt_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_create_transaction_chain(self): builder = InitPaymentBuilder('20.00', 'test') client = PostClient(self.get_merchant_id(), self.get_secret_key()) result = client.request(builder) root = fromstring(result) pg_payment_id = root.find('pg_payment_id').text ...
code_fim
medium
{ "lang": "python", "repo": "Platron/python-sdk", "path": "/tests/integration/receipt_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_create_transaction_chain(self): builder = InitPaymentBuilder('20.00', 'test') client = PostClient(self.get_merchant_id(), self.get_secret_key()) result = client.request(builder) root = fromstring(result) pg_payment_id = root.find('pg_payment_id').text ...
code_fim
medium
{ "lang": "python", "repo": "Platron/python-sdk", "path": "/tests/integration/receipt_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>GPG_NO_DEFAULT_KEYRING_OPTION = "--no-default-keyring" GPG_KEYRING_ARG = "--keyring" def verify_signature(signed_file_path, output_file_path): """Verifies the signed file's signature. Returns: True : If the signature is valid. False : If the signature is invalid. """ ...
code_fim
medium
{ "lang": "python", "repo": "Bpoe/PowerShell-DSC-for-Linux", "path": "/Providers/nxOMSAutomationWorker/automationworker/worker/gpg.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if proc.poll() == 0: tracer.log_debug_trace("Signature is valid.") return True tracer.log_sandbox_job_runbook_signature_validation_failed(stderr) return False<|fim_prefix|># repo: Bpoe/PowerShell-DSC-for-Linux path: /Providers/nxOMSAutomationWorker/automationworker/worker/gpg...
code_fim
hard
{ "lang": "python", "repo": "Bpoe/PowerShell-DSC-for-Linux", "path": "/Providers/nxOMSAutomationWorker/automationworker/worker/gpg.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Bpoe/PowerShell-DSC-for-Linux path: /Providers/nxOMSAutomationWorker/automationworker/worker/gpg.py #!/usr/bin/env python2 # # Copyright (C) Microsoft Corporation, All rights reserved. """Gpg module. Used for runbook signature validation.""" import os import subprocess import configuration imp...
code_fim
hard
{ "lang": "python", "repo": "Bpoe/PowerShell-DSC-for-Linux", "path": "/Providers/nxOMSAutomationWorker/automationworker/worker/gpg.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jamartinh/ReinforcementLearning path: /FAReinforcement/Environments/ProleEnvironment.py from numpy import * from numpy.random import * from visual import * from visual.graph import * from math import * LIM_X0=0.0000000000000000000000000000000000000000001 class InertMachine: def...
code_fim
hard
{ "lang": "python", "repo": "jamartinh/ReinforcementLearning", "path": "/FAReinforcement/Environments/ProleEnvironment.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if sqrt(sum((self.Zorro.state.x-self.Pata.state.x)**2 )) > 2.0: self.Zorro.react(self.Patito,1) else: self.Zorro.react(self.Pata,-1) self.Patito.react(self.Pata,1) self.Patito2.react(self.Patito,1) self.Pata.update() se...
code_fim
hard
{ "lang": "python", "repo": "jamartinh/ReinforcementLearning", "path": "/FAReinforcement/Environments/ProleEnvironment.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # Goal Position goalPos = (8,8,0) def __init__(self): self.initGraphs() def GetInitialState(self): self.StartEpisode() return self.cur_state def UpdateState(self): temp1 = array([self.goal.x,self.goal.y,self.Zorro.x,self.Zorro.y,self.Pat...
code_fim
hard
{ "lang": "python", "repo": "jamartinh/ReinforcementLearning", "path": "/FAReinforcement/Environments/ProleEnvironment.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: hegu2692/autism_rnaseq path: /post_processing/diff_genes/split_gene_name.py import pandas as pd import sys data=open(sys.argv[1],'r').read().strip().split('\n') header=data[0].split('\<|fim_suffix|>enename=''.join(gene[1::]) outf.write(ensgid+'\t'+genename+'\t'+'\t'.join(tokens[1::])+'\n') ou...
code_fim
hard
{ "lang": "python", "repo": "hegu2692/autism_rnaseq", "path": "/post_processing/diff_genes/split_gene_name.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>enename=''.join(gene[1::]) outf.write(ensgid+'\t'+genename+'\t'+'\t'.join(tokens[1::])+'\n') outf.close()<|fim_prefix|># repo: hegu2692/autism_rnaseq path: /post_processing/diff_genes/split_gene_name.py import pandas as pd import sys data=open(sys.argv[1],'r').read().strip().split('\n') header=data[0...
code_fim
hard
{ "lang": "python", "repo": "hegu2692/autism_rnaseq", "path": "/post_processing/diff_genes/split_gene_name.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> x = XOR(1001, 0010) = 1011, which is 11 in decimal. y = f(1011) = 'k' c = 'i' + 'k' = "ik" So the encrypted text c = "ik". To decrypt we simply apply the one-time pad with the same key but to c = "ik". ### How does the XOR operation work in general? Given two binary strings A ...
code_fim
hard
{ "lang": "python", "repo": "nbro/ands", "path": "/ands/algorithms/crypto/one_time_pad.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nbro/ands path: /ands/algorithms/crypto/one_time_pad.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ # Meta-info Author: Nelson Brochado Created: 10/08/2015 Updated: 18/09/2017 # Description One time pad (or, in short, OTP) is an encryption technique that cannot be cracked, but requir...
code_fim
hard
{ "lang": "python", "repo": "nbro/ands", "path": "/ands/algorithms/crypto/one_time_pad.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> i = 'h' j = 'a' h(i) = 8 h(j) = 1 In binary, h(i) = 8 is 1000 and h(j) = 1 is 0001. x = XOR(1000, 0001) = 1001, which is 9 in decimal. y = f(1001) = 'i' c = '' + 'i' = "i" Let n = 2. i = 'i' j = 'b' h(i) = 9 ...
code_fim
hard
{ "lang": "python", "repo": "nbro/ands", "path": "/ands/algorithms/crypto/one_time_pad.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # # Vary the pool of individuals offspring = algorithms.varAnd(offspring, toolbox, cxpb, mutpb) # Evaluate the individuals with an invalid fitness invalid_ind = [ind for ind in offspring if not ind.fitness.valid] fitnesses = toolbox.map(toolbox.evaluate, invalid_i...
code_fim
hard
{ "lang": "python", "repo": "jacksonpradolima/tcpci-search-based", "path": "/algorithm.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jacksonpradolima/tcpci-search-based path: /algorithm.py from deap import algorithms def eaSimple(population, toolbox, cxpb, mutpb, ngen, stats=None, halloffame=None, verbose=__debug__): """This algorithm reproduce the simplest evolutionary algorithm as presented in chapter ...
code_fim
hard
{ "lang": "python", "repo": "jacksonpradolima/tcpci-search-based", "path": "/algorithm.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Begin the generational process gen = 1 found_best = False # Run the algorithm until a "convergence" while gen <= ngen and not found_best: # Select the next generation individuals offspring = toolbox.select(population, len(population)) # # Vary the pool of in...
code_fim
hard
{ "lang": "python", "repo": "jacksonpradolima/tcpci-search-based", "path": "/algorithm.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: qookei/xbstrap path: /xbstrap/util.py # SPDX-License-Identifier: MIT import os import urllib.parse import urllib.request <|fim_suffix|> if not prepend: return joined = ':'.join(prepend) if varname in environ and environ[varname]: environ[varname] = joined + ':' + environ[varname] else: ...
code_fim
medium
{ "lang": "python", "repo": "qookei/xbstrap", "path": "/xbstrap/util.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> temp_path = path + '.download' urllib.request.urlretrieve(url, temp_path, show_progress) os.rename(temp_path, path) print()<|fim_prefix|># repo: qookei/xbstrap path: /xbstrap/util.py # SPDX-License-Identifier: MIT import os import urllib.parse import urllib.request def build_environ_paths(environ, ...
code_fim
hard
{ "lang": "python", "repo": "qookei/xbstrap", "path": "/xbstrap/util.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if isinstance(dset, xr.DataArray): dset = dset.to_dataset(name="data") encoding = {k: {"zlib": True} for k in dset.data_vars} logger.info(f"saving to {f}") dset.to_netcdf(f, engine=engine, encoding=encoding) logger.info(f"Wrote {f.stem}.nc size={f.stat().st_size/1e6} M")<|fim_p...
code_fim
medium
{ "lang": "python", "repo": "icarofua/seq2seq-time", "path": "/seq2seq_time/util.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: icarofua/seq2seq-time path: /seq2seq_time/util.py from pathlib import Path import torch import xarray as xr import logging logger = logging.getLogger(__file__) project_dir = Path(__file__).parent.parent def to_numpy(x): """Helper function to avoid repeating code""" if isinstance(x, torc...
code_fim
medium
{ "lang": "python", "repo": "icarofua/seq2seq-time", "path": "/seq2seq_time/util.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Checks if the current day is weekend. :returns: True when the current day is weekend. """ return datetime.today().weekday() > 3<|fim_prefix|># repo: lulivi/gol-bot path: /gol/utils.py # Copyright (c) 2021 Luis Liñán Villafranca. All rights reserved. # # This work is licensed under th...
code_fim
easy
{ "lang": "python", "repo": "lulivi/gol-bot", "path": "/gol/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: lulivi/gol-bot path: /gol/utils.py # Copyright (c) 2021 Luis Liñán Villafranca. All rights reserved. # # This work is licensed under the terms of the MIT license. # For a copy, see <https://opensource.org/licenses/MIT> """Utitilites for the push-ups counter.""" from datetime import datetime <|f...
code_fim
medium
{ "lang": "python", "repo": "lulivi/gol-bot", "path": "/gol/utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ return datetime.today().weekday() > 3<|fim_prefix|># repo: lulivi/gol-bot path: /gol/utils.py # Copyright (c) 2021 Luis Liñán Villafranca. All rights reserved. # # This work is licensed under the terms of the MIT license. # For a copy, see <https://opensource.org/licenses/MIT> """Utitilites f...
code_fim
medium
{ "lang": "python", "repo": "lulivi/gol-bot", "path": "/gol/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # fill the function, too numberOfDays = daysByMonth[month] sameDayMonths = monthByDays[numberOfDays] for month in sameDayMonths: if month != inputMonth: print(month)<|fim_prefix|># repo: rongpenl/k16math-course path: /exercises/solution_01_11_02.py daysByMonth = { ...
code_fim
hard
{ "lang": "python", "repo": "rongpenl/k16math-course", "path": "/exercises/solution_01_11_02.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rongpenl/k16math-course path: /exercises/solution_01_11_02.py daysByMonth = { "January": 31, "February": 28, "March": 31, "April": 30, "May": 31, "June": 30, "July": 31, "August": 31, "September": 30, "October": 31, "November": 30, "December": 31 } ...
code_fim
hard
{ "lang": "python", "repo": "rongpenl/k16math-course", "path": "/exercises/solution_01_11_02.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def end_test(self, name, attributes): """ The `end test` hook """ print(f"test ended with result : {attributes['status']} ") if attributes['status'] == "FAIL": CustomUtils.take_screenshot(f"{name}.png") def close(self): ''' ''' print("c...
code_fim
hard
{ "lang": "python", "repo": "sohailchd/RobotAndLocust", "path": "/nba_automation/utilities/CustomListener.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: sohailchd/RobotAndLocust path: /nba_automation/utilities/CustomListener.py from utilities.BrowserManager import BrowserManager from robot.libraries.BuiltIn import BuiltIn from robot.libraries.Screenshot import Screenshot import conf from utilities.CustomUtils import CustomUtils from robot.api imp...
code_fim
medium
{ "lang": "python", "repo": "sohailchd/RobotAndLocust", "path": "/nba_automation/utilities/CustomListener.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: decentral1se/django-stubs path: /django-stubs/db/models/manager.pyi from typing import Any, Optional class BaseManager: creation_counter: int = ... auto_created: bool = ... use_in_migrations: bool = ... def __new__(cls, *args: Any, **kwargs: Any): ... model: Any = ... na...
code_fim
medium
{ "lang": "python", "repo": "decentral1se/django-stubs", "path": "/django-stubs/db/models/manager.pyi", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> class EmptyManager(Manager): model: Any = ... def __init__(self, model: Any) -> None: ... def get_queryset(self): ...<|fim_prefix|># repo: decentral1se/django-stubs path: /django-stubs/db/models/manager.pyi from typing import Any, Optional class BaseManager: creation_counter: int = ......
code_fim
hard
{ "lang": "python", "repo": "decentral1se/django-stubs", "path": "/django-stubs/db/models/manager.pyi", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def distinct(self, column): """ Count the number of distinct fields in the currently selected MongoDB collection's specified column. :param str field: name of the column for counting distinct addresses. :returns: the number of packets matching the filter in th...
code_fim
hard
{ "lang": "python", "repo": "Totoro2205/CovertMark", "path": "/CovertMark/data/retrieve.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> :returns: if all input filters present are valid, returns the filters, otherwise returns False. """ collections = self.list(in_string=False) this_collection = None for collection in collections: if collection["name"] == self._collection: ...
code_fim
hard
{ "lang": "python", "repo": "Totoro2205/CovertMark", "path": "/CovertMark/data/retrieve.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Totoro2205/CovertMark path: /CovertMark/data/retrieve.py from . import utils, constants, mongo from base64 import b64decode class Retriever: def __init__(self): self.__db = mongo.MongoDBManager(db_server=constants.MONGODB_SERVER) self._collection = None def list(self,...
code_fim
hard
{ "lang": "python", "repo": "Totoro2205/CovertMark", "path": "/CovertMark/data/retrieve.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: DincerDogan/Data-Science-Learning-Path path: /Data Scientist Career Path/9. Data Visualization/1. Matplotlib/3. Recreate Graphs/2. side.py import codecademylib from matplotlib import pyplot as plt unit_topics = ['Limits', 'Derivatives', 'Integrals', 'Diff Eq', 'Applications'] middle_school_a = [...
code_fim
hard
{ "lang": "python", "repo": "DincerDogan/Data-Science-Learning-Path", "path": "/Data Scientist Career Path/9. Data Visualization/1. Matplotlib/3. Recreate Graphs/2. side.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return [t*x + w*n for x in range(d)] # Make your chart here school_a_x = create_x(2, 0.8, 1, 5) school_b_x = create_x(2, 0.8, 2, 5) # Make your chart here plt.figure(figsize=(10,8)) ax = plt.subplot() plt.bar(school_a_x, middle_school_a) plt.bar(school_b_x,middle_school_b) middle_x = [ (a + b) / 2.0...
code_fim
medium
{ "lang": "python", "repo": "DincerDogan/Data-Science-Learning-Path", "path": "/Data Scientist Career Path/9. Data Visualization/1. Matplotlib/3. Recreate Graphs/2. side.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #### Generate boundary-planpe orientations l_p_po = l1.l_p_po l_po_p = np.linalg.inv(l_p_po) T_p1top2_po1 = np.dot(l_p_po, np.dot(T_p1top2_p1, l_po_p)) ## Find the corresponding disorientation quat1 = gbt.mat2quat(T_p1top2_po1) # print(quat1) ...
code_fim
hard
{ "lang": "python", "repo": "spatala/gbpy", "path": "/gbpy/byxtal/tests/enumerate_cubicCSL_props.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: spatala/gbpy path: /gbpy/byxtal/tests/enumerate_cubicCSL_props.py ################################################################## ## Code to enumerate the properties of the CSL/DSC lattices for ## Sigma misorientations ## The code currently works for cubic lattices. ###########################...
code_fim
hard
{ "lang": "python", "repo": "spatala/gbpy", "path": "/gbpy/byxtal/tests/enumerate_cubicCSL_props.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: appcoreopc/python-polar-coding path: /tests/test_sc_list/test_codec.py from unittest import TestCase from python_polar_coding.polar_codes.sc_list import SCListPolarCodec from tests.base import BasicVerifyPolarCode class TestSCListPolarCode1024_512_4(BasicVerifyPolarCode, TestCase): <|fim_suffi...
code_fim
medium
{ "lang": "python", "repo": "appcoreopc/python-polar-coding", "path": "/tests/test_sc_list/test_codec.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> polar_code_class = SCListPolarCodec code_parameters = { 'N': 1024, 'K': 512, 'L': 4, } class TestSCListPolarCode1024_512_8(BasicVerifyPolarCode, TestCase): polar_code_class = SCListPolarCodec code_parameters = { 'N': 1024, 'K': 512, 'L'...
code_fim
medium
{ "lang": "python", "repo": "appcoreopc/python-polar-coding", "path": "/tests/test_sc_list/test_codec.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mstepniowski/django-newtagging path: /newtagging/models.py """ Create a queryset matching all tags associated with the given object. """ ctype = ContentType.objects.get_for_model(obj) return self.filter(items__content_type__pk=ctype.pk, ...
code_fim
hard
{ "lang": "python", "repo": "mstepniowski/django-newtagging", "path": "/newtagging/models.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> class TaggedItemManager(models.Manager): """ FIXME There's currently no way to get the ``GROUP BY`` and ``HAVING`` SQL clauses required by many of this manager's methods into Django's ORM. For now, we manually execute a query to retrieve the PKs of objects...
code_fim
hard
{ "lang": "python", "repo": "mstepniowski/django-newtagging", "path": "/newtagging/models.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if not tag_count: return model._default_manager.none() model_table = qn(model._meta.db_table) # This query selects the ids of all objects which have any of # the given tags. query = """ SELECT %(model_pk)s FROM %(model)s, %(tagged_item)s...
code_fim
hard
{ "lang": "python", "repo": "mstepniowski/django-newtagging", "path": "/newtagging/models.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ataque" ): print("Jogador 2 venceu") elif (d == "pedra"): print("Jogador 2 venceu") else : print("Ambos venceram")<|fim_prefix|># repo: rmaycon7/uri-codes path: /python_python3/2031.py b = input() for i in range (b): c = raw_input () d = raw_input () if (c == "ataque"): if(d=="ataque"):...
code_fim
hard
{ "lang": "python", "repo": "rmaycon7/uri-codes", "path": "/python_python3/2031.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rmaycon7/uri-codes path: /python_python3/2031.py b = input() for i in range (b): c = raw_input () d = raw_input () if (c == "ataque"): if(d=="ataque"): print("Aniquila<|fim_suffix|>f(d == "papel"): print("Jogador 1 venceu") elif(d == "pedra"): print("Sem ganhador") elif (c == "pa...
code_fim
medium
{ "lang": "python", "repo": "rmaycon7/uri-codes", "path": "/python_python3/2031.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> damage = TurnBuilder()\ .attack(AttackBuilder(d(10)) .prof(3) .amod(3) .adv() .gwm() .attbon(3) .dmgbon(2), times=2)\ .attack(AttackBuilder(d(4)) .prof(3) .am...
code_fim
hard
{ "lang": "python", "repo": "s-zhang/DnDnProbabilities", "path": "/src/tests/attack_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert 1.0000000000000002 == AttackBuilder(d(1))\ .attbon(-20)\ .crit(0)\ .resolve(0)\ .p(2) def test_resolve_turn_attacks(): damage = TurnBuilder()\ .attack(AttackBuilder(d(10)) .prof(3) .amod(3) .adv() ...
code_fim
hard
{ "lang": "python", "repo": "s-zhang/DnDnProbabilities", "path": "/src/tests/attack_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: s-zhang/DnDnProbabilities path: /src/tests/attack_test.py from dnd import AttackBuilder, HitOutcome, TurnBuilder, d def test_resolve_hit(): test_attack = AttackBuilder(d(10))\ .prof(3)\ .amod(3)\ .adv()\ .gwm()\ .attbon(3)\ .dmgbon(2)\ ...
code_fim
hard
{ "lang": "python", "repo": "s-zhang/DnDnProbabilities", "path": "/src/tests/attack_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nikankind/Reproduce-Article-Representation-Flow-for-Action-Recognition-with-PaddlePaddle path: /hmdb_dataset.py # import torch # import torch.utils.data as data_utl import numpy as np import random import os from PIL import Image from io import BytesIO import pickle import paddle import funct...
code_fim
hard
{ "lang": "python", "repo": "nikankind/Reproduce-Article-Representation-Flow-for-Action-Recognition-with-PaddlePaddle", "path": "/hmdb_dataset.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> np_imgs = (np.array(imgs[0]).astype('float32').transpose( (2, 0, 1))).reshape(1, 3, target_size, target_size) / 255 for i in range(len(imgs) - 1): img = (np.array(imgs[i + 1]).astype('float32').transpose( (2, 0, 1))).reshape(1, 3, target_size, target...
code_fim
hard
{ "lang": "python", "repo": "nikankind/Reproduce-Article-Representation-Flow-for-Action-Recognition-with-PaddlePaddle", "path": "/hmdb_dataset.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ) return paddle.reader.xmap_readers(mapper, reader, num_threads, buf_size) def __len__(self): return len(self.data) ''' def imgs_transform(imgs, label, mode, seg_num, seglen, short_size, target_size, img_mean, img_std): imgs = group_...
code_fim
hard
{ "lang": "python", "repo": "nikankind/Reproduce-Article-Representation-Flow-for-Action-Recognition-with-PaddlePaddle", "path": "/hmdb_dataset.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: hypothesis/h path: /tests/h/models/document/_meta_test.py from datetime import datetime, timedelta from unittest.mock import Mock import pytest import sqlalchemy as sa from h_matchers import Any from h.models import Document, DocumentMeta from h.models.document import ConcurrentUpdateError, cre...
code_fim
hard
{ "lang": "python", "repo": "hypothesis/h", "path": "/tests/h/models/document/_meta_test.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> document = db_session.query(Document).get(document.id) assert document.title == final_title def test_it_logs_a_warning_with_existing_meta_on_a_different_doc( self, log, mock_db_session, factories, meta_attrs ): document_one = factories.Document() document_t...
code_fim
hard
{ "lang": "python", "repo": "hypothesis/h", "path": "/tests/h/models/document/_meta_test.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> finally: sdk_marathon.destroy_app(client_id) @pytest.mark.dcos_min_version('1.10') @sdk_utils.dcos_ee_only @pytest.mark.sanity def test_client_can_read_and_write(kafka_client): topics = sdk_cmd.svc_cli(config.PACKAGE_NAME, config.SERVICE_NAME, "topic create securetest", json=True) l...
code_fim
hard
{ "lang": "python", "repo": "olsky/dcos-commons", "path": "/frameworks/kafka/tests/test_auth.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: olsky/dcos-commons path: /frameworks/kafka/tests/test_auth.py import logging import pytest import subprocess import uuid import sdk_auth import sdk_cmd import sdk_hosts import sdk_install import sdk_marathon import sdk_tasks import sdk_utils from tests import config log = logging.getLogger(__n...
code_fim
hard
{ "lang": "python", "repo": "olsky/dcos-commons", "path": "/frameworks/kafka/tests/test_auth.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> try: client_id = "kafka-client" client = { "id": client_id, "mem": 512, "user": "nobody", "container": { "type": "MESOS", "docker": { "image": "elezar/kafka-client:latest", ...
code_fim
hard
{ "lang": "python", "repo": "olsky/dcos-commons", "path": "/frameworks/kafka/tests/test_auth.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # self.runner.step_var+=1 data = self.runner.get_next() loss = self.alg.step(data) # save_to_file('new_logs/random_loss.csv', {'loss':loss}) yield data, loss while not self.runner.trajectory_is_stale(): data = self.runner.get_next() l...
code_fim
hard
{ "lang": "python", "repo": "NinaMaz/NAS_RL_torch", "path": "/learners/learners.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: NinaMaz/NAS_RL_torch path: /learners/learners.py import numpy as np import torch from base.base import Learner from runners.runners import make_ppo_runner, SavedRewardsResetsRunner from selection.select_layers import SelectModelFromLayers from utils.additional import GPU_ids from .policies_algs ...
code_fim
hard
{ "lang": "python", "repo": "NinaMaz/NAS_RL_torch", "path": "/learners/learners.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: liujuanLT/InsightFace_TF path: /nets/mobilenetv2.py # Architecture based on MobileNetV2 https://arxiv.org/pdf/1801.04381.pdf #https://github.com/ohadlights/mobilenetv2/blob/master/mobilenetv2.py import tensorflow as tf import tensorflow.contrib.slim as slim def block(net, input_filters, output_...
code_fim
hard
{ "lang": "python", "repo": "liujuanLT/InsightFace_TF", "path": "/nets/mobilenetv2.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> net = blocks(net=net, expansion=expansion, output_filters=24, repeat=2, stride=2) net = blocks(net=net, expansion=expansion, output_filters=32, repeat=3, stride=2) net = blocks(net=net, expansion=expansion, output_filters=64, repeat=4, stride=2) net = blo...
code_fim
hard
{ "lang": "python", "repo": "liujuanLT/InsightFace_TF", "path": "/nets/mobilenetv2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pick_list = [slice_stats] # Read picks for pick_file_name in os.listdir(subdir_full_path): # Parse name name_split = pick_file_name.split('.') if type(name_split) is not list: continue ...
code_fim
hard
{ "lang": "python", "repo": "jamm1985/seismo-ml-phase-picker", "path": "/utils/picks_slicing.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Check if picks section started if len(line) > 25: if line[0:len(picks_line)] == picks_line: picks_started = True return [id, picks_dists, picks_seconds] def get_picks(reading_path, archive_definitions=[]): """ Reads S-file and sl...
code_fim
hard
{ "lang": "python", "repo": "jamm1985/seismo-ml-phase-picker", "path": "/utils/picks_slicing.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jamm1985/seismo-ml-phase-picker path: /utils/picks_slicing.py # if id_str == '20140413140958': # print(x[0]) # if True:#x[0] == 'NKL': # trace.integrate() ...
code_fim
hard
{ "lang": "python", "repo": "jamm1985/seismo-ml-phase-picker", "path": "/utils/picks_slicing.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }