text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>
parser = argparse.ArgumentParser()
parser.add_argument("--data_path",
type=str,
default="data.joblib")
parser.add_argument("--test_strat",
type=int,
default=0)
parser.add_argument("--device_id... | code_fim | hard | {
"lang": "python",
"repo": "arewellborn/s2cnn",
"path": "/examples/molecules/run_experiment.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JornVoegtli/BCI path: /User Interface/Pre-13thMarch/word_predictor.py
import re, collections
def words(text): return re.findall('[a-z]+', text.lower())
def train(features):
model = collections.defaultdict(lambda: 1)
for f in features:
model[f] += 1
return model
<|fim_suffi... | code_fim | medium | {
"lang": "python",
"repo": "JornVoegtli/BCI",
"path": "/User Interface/Pre-13thMarch/word_predictor.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def known(words): return set(w for w in words if w in NWORDS)
def correct(word):
word1 = word + "a"
word2 = word + "e"
candidate0 = known([word]) or known(edits1(word)) or known_edits2(word) or [word]
candidate1 = known([word1]) or known(edits1(word1)) or known_edits2(word1) or [word]
... | code_fim | hard | {
"lang": "python",
"repo": "JornVoegtli/BCI",
"path": "/User Interface/Pre-13thMarch/word_predictor.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in NWORDS)
def known(words): return set(w for w in words if w in NWORDS)
def correct(word):
word1 = word + "a"
word2 = word + "e"
candidate0 = known([word]) or known(edits1(word)) or known_edits2(word) or [word]
candidat... | code_fim | hard | {
"lang": "python",
"repo": "JornVoegtli/BCI",
"path": "/User Interface/Pre-13thMarch/word_predictor.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
def update_summer():
pass
def update_autumn():
for leaf in LEAVES:
leaf.x += randint(4, 7)
leaf.y += 3
if leaf.x > WIDTH:
leaf.x = -leaf.size
elif leaf.y > HEIGHT:
leaf.y = -leaf.size
def update_winter():
pass
def update(... | code_fim | hard | {
"lang": "python",
"repo": "PyconUK/dojo18",
"path": "/team_8/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
def update():
global SEASON
{
'spring': update_spring,
'summer': update_summer,
'autumn': update_autumn,
'winter': update_winter,
}[SEASON]()
def on_key_down(key, mod, unicode):
global SEASON
if key == keys.SPACE:
SEASON = next(Seaso... | code_fim | hard | {
"lang": "python",
"repo": "PyconUK/dojo18",
"path": "/team_8/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PyconUK/dojo18 path: /team_8/main.py
from colorsys import hls_to_rgb
from random import randint, choice, random
from itertools import cycle
WIDTH = 800
HEIGHT = 600
class Colours:
GREEN = (0, 255, 0)
LIGHT_GREEN = (0, 192, 0)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
AUTUMN... | code_fim | hard | {
"lang": "python",
"repo": "PyconUK/dojo18",
"path": "/team_8/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @app.get("/api/{api_key}/openapi.json")
async def get_open_api_endpoint(
api_key: str,
user: User = Depends(get_current_user)
):
return JSONResponse(get_openapi(title=__title__, version=__version__, routes=app.routes))
@app.get("/api/{api_key}/docs")
as... | code_fim | medium | {
"lang": "python",
"repo": "marirs/fastApiSimple",
"path": "/server/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: marirs/fastApiSimple path: /server/app.py
"""
Main App
"""
from starlette.responses import JSONResponse
from fastapi import FastAPI, Request, Depends, Response
from fastapi.openapi.utils import get_openapi
from fastapi.openapi.docs import get_swagger_ui_html
from fastapi.openapi.docs import get_r... | code_fim | hard | {
"lang": "python",
"repo": "marirs/fastApiSimple",
"path": "/server/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # (II) Sample Gaussian noise processes
eta = np.random.multivariate_normal(np.zeros(d), Q, size = T).T
zeta = np.random.multivariate_normal(np.zeros(m), R, size = T).T
# (III) Initialize Kalman filter variables
mu = np.zeros([d,T]) # hidden state estimator
Sigma = np.zeros([d,... | code_fim | hard | {
"lang": "python",
"repo": "giorgosmamakoukas/SLIP",
"path": "/SLIP.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for iteration in range(num_iterations):
t_start = time.time()
# (I) Sample/specify inputs
#Rx = 0.01 # max entry for inputs used for uniform inputs
x = norm.rvs(0,1,size = [n,T])
x[:,0] = 0 # initial input is zero
# (II) Sample Gaussian noise processes
eta = np.random... | code_fim | hard | {
"lang": "python",
"repo": "giorgosmamakoukas/SLIP",
"path": "/SLIP.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: giorgosmamakoukas/SLIP path: /SLIP.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Code for the paper
"SLIP: Learning to predict in unknown dynamical systems with long-term memory"
Authors: Paria Rashidinejad, Jiantao Jiao, Stuart Russell
"""
##### Imports #####
import matplotlib.pyplot a... | code_fim | hard | {
"lang": "python",
"repo": "giorgosmamakoukas/SLIP",
"path": "/SLIP.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: letztes/achtelbass2web path: /achtelbass/note_values.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import random
class NoteValues(object):
def __init__(self, selectable_note_values, time_signature, tuplets, tuplets_frequency):
self.Selectable_Note_Values = selectable_note_values
self.T... | code_fim | hard | {
"lang": "python",
"repo": "letztes/achtelbass2web",
"path": "/achtelbass/note_values.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> remaining_bar_length = self.Time_Signature # Zum Beispiel 3.0/4 = 0.75
selectable_note_values_in_this_bar = self.Selectable_Note_Values
abc_note_value = ''
while remaining_bar_length > 0.0:
selectable_note_values_in_this_bar = [selectable_note_values_in_this_bar[selectable_note_values_in_this_b... | code_fim | medium | {
"lang": "python",
"repo": "letztes/achtelbass2web",
"path": "/achtelbass/note_values.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @freeze_time("2021-01-01T12:00:00Z")
def test_performance_events_doesnt_list_other_team(self):
session_id = str(uuid.uuid4())
team = Team.objects.create(name="Test Team", organization=self.organization)
create_performance_event(team.id, "user_1", session_id, current_url="ht... | code_fim | hard | {
"lang": "python",
"repo": "dorucioclea/posthog",
"path": "/ee/api/test/test_performance_events.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> res = self.client.get(
f"/api/projects/@current/performance_events/recent_pageviews?date_from={thirty_days_ago.isoformat()}"
)
assert res.status_code == 200
res = self.client.get(
f"/api/projects/@current/performance_events/recent_pageviews?date_fro... | code_fim | hard | {
"lang": "python",
"repo": "dorucioclea/posthog",
"path": "/ee/api/test/test_performance_events.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dorucioclea/posthog path: /ee/api/test/test_performance_events.py
import datetime
import uuid
from freezegun import freeze_time
from ee.api.test.base import APILicensedTest
from ee.test.fixtures.performance_event_fixtures import create_performance_event
from posthog.models.team.team import Team... | code_fim | hard | {
"lang": "python",
"repo": "dorucioclea/posthog",
"path": "/ee/api/test/test_performance_events.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> def set_group_part(self, char: str) -> None:
self.temp += char
return
def is_split_char(self, char: str) -> bool:
return char in self.split_chars
def set_split_char(self, char: str) -> None:
self.flush_temp()
if char not in self.whitespace_chars:
... | code_fim | hard | {
"lang": "python",
"repo": "lcary/tranq",
"path": "/src/lexer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.temp += char
return
def flush_temp(self):
if self.temp != '':
try:
int(self.temp)
except ValueError:
self.tokens.append(Token(TokenType.identifier, self.temp))
else:
self.tokens.append(Tok... | code_fim | hard | {
"lang": "python",
"repo": "lcary/tranq",
"path": "/src/lexer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lcary/tranq path: /src/lexer.py
from typing import List, Optional
from .token import Token, TokenType
class Lexer(object):
"""
Produces ordered lists of tokens from input text.
Inspired by https://medium.freecodecamp.org/the-programming-language-pipeline-91d3f449c919 # noqa: E501... | code_fim | hard | {
"lang": "python",
"repo": "lcary/tranq",
"path": "/src/lexer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maximus8907/zha-device-handlers path: /zhaquirks/xiaomi/__init__.py
"""Xiaomi common components for custom device handlers."""
import asyncio
import binascii
import logging
from zigpy import types as t
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import Ba... | code_fim | hard | {
"lang": "python",
"repo": "maximus8907/zha-device-handlers",
"path": "/zhaquirks/xiaomi/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _turn_off(self):
self._timer_handle = None
self._update_attribute(OCCUPANCY_STATE, OFF)
class MotionCluster(LocalDataCluster, IasZone):
"""Motion cluster."""
cluster_id = IasZone.cluster_id
def __init__(self, *args, **kwargs):
"""Init."""
super().__i... | code_fim | hard | {
"lang": "python",
"repo": "maximus8907/zha-device-handlers",
"path": "/zhaquirks/xiaomi/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get(self, name):
return self.jsonMapping[name][self.mVal]
def get_mapping_names(self):
tagName = self.get('tagName')
nodeType = self.get('nodeType')
nodeName = self.get('nodeName')
nodeValue = self.get('nodeValue')
position = self.get('position'... | code_fim | hard | {
"lang": "python",
"repo": "CoffeeIO/DOM-based-VRT",
"path": "/TreeDistance/domvrt/parser_mapping.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CoffeeIO/DOM-based-VRT path: /TreeDistance/domvrt/parser_mapping.py
class ParserMapping(object):
"""docstring for ParserMapping."""
def __init__(self, minify):
self.minify = minify
self.mVal = 1 if minify else 0
mVal = 0
# Mapping of minified names.
jsonMapp... | code_fim | medium | {
"lang": "python",
"repo": "CoffeeIO/DOM-based-VRT",
"path": "/TreeDistance/domvrt/parser_mapping.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.jsonMapping[name][self.mVal]
def get_mapping_names(self):
tagName = self.get('tagName')
nodeType = self.get('nodeType')
nodeName = self.get('nodeName')
nodeValue = self.get('nodeValue')
position = self.get('position')
childNodes = se... | code_fim | hard | {
"lang": "python",
"repo": "CoffeeIO/DOM-based-VRT",
"path": "/TreeDistance/domvrt/parser_mapping.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: broadinstitute/AncestralGeneRator path: /Related_Scripts/MakeGeneFluxSpreadsheet.py
import os
import sys
from collections import defaultdict
parent_child_file = sys.argv[1]
paup_result_file = sys.argv[2]
ortholog_name_file = sys.argv[3]
node_naming_file = sys.argv[4]
outdir = os.path.abspath(sys... | code_fim | hard | {
"lang": "python",
"repo": "broadinstitute/AncestralGeneRator",
"path": "/Related_Scripts/MakeGeneFluxSpreadsheet.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> num_tot_genes = 0
num_uniq_clusts = 0
for i in range(0, len(samp_data)):
par_val = int(parent_data[i])
sam_val = int(samp_data[i])
num_tot_genes += sam_val
if sam_val > 0:
num_uniq_clusts += 1
allgcs.ad... | code_fim | hard | {
"lang": "python",
"repo": "broadinstitute/AncestralGeneRator",
"path": "/Related_Scripts/MakeGeneFluxSpreadsheet.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# revision identifiers, used by Alembic.
revision = 'eda8fa199eed'
down_revision = '67ddc453032f'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('blogs', sa.Column('date_of_blog', sa.DateTime(), nullable=True))
... | code_fim | medium | {
"lang": "python",
"repo": "Kernael92/personal-blog",
"path": "/migrations/versions/eda8fa199eed_update_both_user_and_blog_models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kernael92/personal-blog path: /migrations/versions/eda8fa199eed_update_both_user_and_blog_models.py
"""update both user and blog models
Revision ID: eda8fa199eed
Revises: 67ddc453032f
Create Date: 2018-11-27 23:54:13.288435
"""
from alembic import op
import sqlalchemy as sa
<|fim_suffix|>def ... | code_fim | hard | {
"lang": "python",
"repo": "Kernael92/personal-blog",
"path": "/migrations/versions/eda8fa199eed_update_both_user_and_blog_models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mehrdad-shokri/cryptotrader path: /cryptotrader/db.py
localcontext, ROUND_UP, ROUND_DOWN
from .utils import send_email
from .utils import Logger
from time import sleep
from .utils import floor_datetime
class DBClient(object):
def __init__(self, db, api, email, period):
self.deposits... | code_fim | hard | {
"lang": "python",
"repo": "mehrdad-shokri/cryptotrader",
"path": "/cryptotrader/db.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mehrdad-shokri/cryptotrader path: /cryptotrader/db.py
from .utils import send_email
from .utils import Logger
from time import sleep
from .utils import floor_datetime
class DBClient(object):
def __init__(self, db, api, email, period):
self.deposits = db.deposits
self.withdraw... | code_fim | hard | {
"lang": "python",
"repo": "mehrdad-shokri/cryptotrader",
"path": "/cryptotrader/db.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.report(date,
profit,
cumulative_profits,
profits.astype('f').mean(),
profits.astype('f').var(),
deposits,
withdrawals,
po... | code_fim | hard | {
"lang": "python",
"repo": "mehrdad-shokri/cryptotrader",
"path": "/cryptotrader/db.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AshkanZirakzadeh/SnuffedMapGen path: /src/factionModule.py
'''
Created on Aug 20, 2017
@author: Ashkan Zirakzadeh
'''
class faction:
def __init__(self,color):
self.area=None
self.bonus=None
self.ally=False
self.color=color
def becomeAlly(self):
<|fim_suffi... | code_fim | easy | {
"lang": "python",
"repo": "AshkanZirakzadeh/SnuffedMapGen",
"path": "/src/factionModule.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.ally=True
def isAlly(self):
return self.ally
def getColor(self):
return self.color<|fim_prefix|># repo: AshkanZirakzadeh/SnuffedMapGen path: /src/factionModule.py
'''
Created on Aug 20, 2017
@author: Ashkan Zirakzadeh
'''
class faction:
def __init__(self,color):
... | code_fim | medium | {
"lang": "python",
"repo": "AshkanZirakzadeh/SnuffedMapGen",
"path": "/src/factionModule.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.ally
def getColor(self):
return self.color<|fim_prefix|># repo: AshkanZirakzadeh/SnuffedMapGen path: /src/factionModule.py
'''
Created on Aug 20, 2017
@author: Ashkan Zirakzadeh
'''
class faction:
def __init__(self,color):
<|fim_middle|> self.area=None
... | code_fim | medium | {
"lang": "python",
"repo": "AshkanZirakzadeh/SnuffedMapGen",
"path": "/src/factionModule.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tokenizer.save_pretrained('C:/stss-2021-eval-master/pretrained-model/')
model.save_pretrained('C:/stss-2021-eval-master/pretrained-model/')<|fim_prefix|># repo: SGombert/ssts-2021-sego path: /dl.py
from transformers import BertTokenizer, BertConfig, BertModel
<|fim_middle|>tokenizer = BertTokenizer.f... | code_fim | medium | {
"lang": "python",
"repo": "SGombert/ssts-2021-sego",
"path": "/dl.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SGombert/ssts-2021-sego path: /dl.py
from transformers import BertTokenizer, BertConfig, BertModel
<|fim_suffix|>tokenizer.save_pretrained('C:/stss-2021-eval-master/pretrained-model/')
model.save_pretrained('C:/stss-2021-eval-master/pretrained-model/')<|fim_middle|>tokenizer = BertTokenizer.f... | code_fim | medium | {
"lang": "python",
"repo": "SGombert/ssts-2021-sego",
"path": "/dl.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BeenleTian/ttk path: /testing/evaluate.py
"""evaluate.py
Script to create a system response for a given gold standard and then compare
the system response to that gold standard.
USAGE:
There are two invocations:
$ python evaluate.py --run-system --gold DIR1 --system DIR2 (--limit INT)
$ pytho... | code_fim | hard | {
"lang": "python",
"repo": "BeenleTian/ttk",
"path": "/testing/evaluate.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, directory, statistics_list):
self.tagname = statistics_list[0].tagname
self.filename = directory
self.statistics = statistics_list
self.tp = sum([stats.tp for stats in statistics_list])
self.fp = sum([stats.fp for stats in statistics_list])
... | code_fim | hard | {
"lang": "python",
"repo": "BeenleTian/ttk",
"path": "/testing/evaluate.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for j in hash_table:
if j == '1':
return hash_table[j]
else:
return 0
class Solution2:
def hammingWeight(self, n: int) -> int:
binary_num = list(bin(n)[2:])
nn = binary_num.count('1')
return nn
class Solution:
... | code_fim | medium | {
"lang": "python",
"repo": "ActonMartin/leetcode",
"path": "/191.位-1-的个数.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ActonMartin/leetcode path: /191.位-1-的个数.py
#
# @lc app=leetcode.cn id=191 lang=python3
#
# [191] 位1的个数
#
# @lc code=start
from collections import defaultdict
class Solution1:
def hammingWeight(self, n: int) -> int:
binary_num = list(bin(n)[2:])
hash_table = defaultdict(int)
... | code_fim | medium | {
"lang": "python",
"repo": "ActonMartin/leetcode",
"path": "/191.位-1-的个数.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Solution2:
def hammingWeight(self, n: int) -> int:
binary_num = list(bin(n)[2:])
nn = binary_num.count('1')
return nn
class Solution:
def hammingWeight(self, n: int) -> int:
# 位运算 无符号的整数
res = 0
while n>0:
res += n&1
n ... | code_fim | medium | {
"lang": "python",
"repo": "ActonMartin/leetcode",
"path": "/191.位-1-的个数.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> OSCAR('rm')
self.assertEqual(ocli.delete_service.call_args_list[0][0][0], 'oname')
@patch('scar.providers.oscar.controller.OSCARClient')
@patch('scar.providers.aws.controller.FileUtils.load_tmp_config_file')
def test_ls(self, load_tmp_config_file, oscar_client):
load_... | code_fim | hard | {
"lang": "python",
"repo": "grycap/scar",
"path": "/test/unit/oscar/test_controller.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: grycap/scar path: /test/unit/oscar/test_controller.py
#! /usr/bin/python
# Copyright (C) GRyCAP - I3M - UPV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://... | code_fim | hard | {
"lang": "python",
"repo": "grycap/scar",
"path": "/test/unit/oscar/test_controller.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Moustikitos/dpos path: /dposlib/ark/mixin.py
# -*- coding: utf-8 -*-
from datetime import datetime, timezone
from collections import OrderedDict
from dposlib import rest
from dposlib.ark import slots
class DataIterator:
def __init__(self, endpoint, tries=10):
if not i... | code_fim | hard | {
"lang": "python",
"repo": "Moustikitos/dpos",
"path": "/dposlib/ark/mixin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> total_elapsed_time = \
(last_block_timestamp - rest.cfg.begintime).total_seconds()
theorical_height = int(
(datetime.now(timezone.utc) - rest.cfg.begintime).total_seconds()
/ rest.cfg.blocktime
)
return OrderedDict({
"real blocktime": total_elapse... | code_fim | hard | {
"lang": "python",
"repo": "Moustikitos/dpos",
"path": "/dposlib/ark/mixin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def call(self, method, *args):
async with self:
return await method(*args)
class MultiRateLimiter(object):
def __init__(self, *limiters):
self.loop = asyncio.get_event_loop()
# Returns a sorted list of limiters
dict_limiters ... | code_fim | hard | {
"lang": "python",
"repo": "bcarrancho/lissandra",
"path": "/lissandra/limiter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
async def call(self, method, *args):
async with self:
return await method(*args)
class MultiRateLimiter(object):
def __init__(self, *limiters):
self.loop = asyncio.get_event_loop()
# Returns a sorted list of limiters
dict... | code_fim | hard | {
"lang": "python",
"repo": "bcarrancho/lissandra",
"path": "/lissandra/limiter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bcarrancho/lissandra path: /lissandra/limiter.py
import asyncio
import time
class SingleRateLimiter(object):
def __init__(self, calls_per_epoch, seconds_per_epoch):
self.loop = asyncio.get_event_loop()
self.calls_per_epoch = calls_per_epoch
self.seconds_per_e... | code_fim | hard | {
"lang": "python",
"repo": "bcarrancho/lissandra",
"path": "/lissandra/limiter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JaeMinYooon/capstone-design-Recognition-in-CCTV-py path: /exServer.py
import socket
import threading
import time
def main():
PYPORT = 5803
PYIP = "192.168.0.35"
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((PYIP, PYPORT))
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "JaeMinYooon/capstone-design-Recognition-in-CCTV-py",
"path": "/exServer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> senStartStr = filename
client_socket.send(senStartStr.encode())
# data, addr = server_socket.recvfrom(512)
# print(data.decode())
data = client_socket.recv(1024)
if data.decode() == "go":
# yoloed_file = open(filename... | code_fim | hard | {
"lang": "python",
"repo": "JaeMinYooon/capstone-design-Recognition-in-CCTV-py",
"path": "/exServer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Campbell-Muscle-Lab/PyMyoVent path: /Python_code/single_ventricle_circulation/half_sarcomere/membranes/grandi_2009.py
constants[111])/constants[112]
constants[122] = (1.00000/constants[109])*log(constants[115]/constants[116])
return (states, constants)
def computeRates(voi, states, const... | code_fim | hard | {
"lang": "python",
"repo": "Campbell-Muscle-Lab/PyMyoVent",
"path": "/Python_code/single_ventricle_circulation/half_sarcomere/membranes/grandi_2009.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>]*constants[37]*(power(constants[45], constants[110]))*algebraic[79]*(algebraic[81]-algebraic[84]))/algebraic[85])/(1.00000+constants[42]*exp((constants[43]-1.00000)*states[0]*constants[109]))
algebraic[106] = algebraic[35]+algebraic[38]+3.00000*algebraic[87]+3.00000*algebraic[42]+algebraic[75]
ra... | code_fim | hard | {
"lang": "python",
"repo": "Campbell-Muscle-Lab/PyMyoVent",
"path": "/Python_code/single_ventricle_circulation/half_sarcomere/membranes/grandi_2009.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "\n".join(filter(lambda x: x != "", map(lambda x: clear(x), filter(lambda x: x is not None,
[contact.home_phonenumber,
contact.mobile_phon... | code_fim | hard | {
"lang": "python",
"repo": "lukasz-nieweglowski86/py_pol_22",
"path": "/pythonProject/test/test_compare_contact_info.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lukasz-nieweglowski86/py_pol_22 path: /pythonProject/test/test_compare_contact_info.py
from random import randrange
import re
def test_compare_contact_info(app):
index = randrange(len(app.contact.get_contact_list()))
contact_from_home_page = app.contact.get_contact_list()[index]
con... | code_fim | hard | {
"lang": "python",
"repo": "lukasz-nieweglowski86/py_pol_22",
"path": "/pythonProject/test/test_compare_contact_info.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hipo/team-directory path: /api/team_directory/questions/serializers.py
from drf_extra_fields.relations import PresentablePrimaryKeyRelatedField
<|fim_suffix|>
class AnswerSerializer(serializers.ModelSerializer):
question = QuestionSerializer(read_only=True)
class Meta:
model = ... | code_fim | hard | {
"lang": "python",
"repo": "Hipo/team-directory",
"path": "/api/team_directory/questions/serializers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = Question
fields = [
"category",
"body"
]
class AnswerSerializer(serializers.ModelSerializer):
question = QuestionSerializer(read_only=True)
class Meta:
model = Answer
fields = [
"id",
"question",
... | code_fim | medium | {
"lang": "python",
"repo": "Hipo/team-directory",
"path": "/api/team_directory/questions/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ShiboXing/Visual-Feature-Attribution-Using-Wasserstein-GANs-Pytorch path: /src/models/mask_generators.py
import torch.nn as nn
from models.model_utils import (ACTIVATION,
deconv2d_bn_block,
conv2d_bn_block,
... | code_fim | hard | {
"lang": "python",
"repo": "ShiboXing/Visual-Feature-Attribution-Using-Wasserstein-GANs-Pytorch",
"path": "/src/models/mask_generators.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(UNet, self).__init__()
if dimensions == 2:
conv_block = conv2d_bn_block if batch_norm else conv2d_block
else:
conv_block = conv3d_block
max_pool = nn.MaxPool2d(2) if int(dimensions) is 2 else nn.MaxPool3d(2)
act = activation
se... | code_fim | hard | {
"lang": "python",
"repo": "ShiboXing/Visual-Feature-Attribution-Using-Wasserstein-GANs-Pytorch",
"path": "/src/models/mask_generators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: polowis/virtComp path: /app/views/api/v1/user/__init__.py
from .user_ import UserView
from .user_company import <|fim_suffix|>Sign
from .user_valid import UserValid
__all__ = ['UserView', 'UserCompany', 'UserValid', 'UserCompanySign']<|fim_middle|>UserCompany
from .user_company_sign import UserC... | code_fim | easy | {
"lang": "python",
"repo": "polowis/virtComp",
"path": "/app/views/api/v1/user/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>erView', 'UserCompany', 'UserValid', 'UserCompanySign']<|fim_prefix|># repo: polowis/virtComp path: /app/views/api/v1/user/__init__.py
from .user_ import UserView
from .user_company import UserCompany
from .user_company_sign import UserCompany<|fim_middle|>Sign
from .user_valid import UserValid
__all__ ... | code_fim | easy | {
"lang": "python",
"repo": "polowis/virtComp",
"path": "/app/views/api/v1/user/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def build(video_dir, out_dir):
category_annotattion = dict()
path_dir = video_dir
categories = []
annotations = {}
for dir_name in next(os.walk(path_dir))[1]:
print(dir_name)
categories.append(dir_name)
action_path = os.path.join(path_dir, dir_name)
for ... | code_fim | medium | {
"lang": "python",
"repo": "ioir123ju/mmskeleton",
"path": "/mmskeleton/processor/build_label.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> category_annotattion = dict()
path_dir = video_dir
categories = []
annotations = {}
for dir_name in next(os.walk(path_dir))[1]:
print(dir_name)
categories.append(dir_name)
action_path = os.path.join(path_dir, dir_name)
for file in next(os.walk(action_pat... | code_fim | medium | {
"lang": "python",
"repo": "ioir123ju/mmskeleton",
"path": "/mmskeleton/processor/build_label.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ioir123ju/mmskeleton path: /mmskeleton/processor/build_label.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : build_label.py
@Contact : JZ
@License : (C)Copyright 2018-2019, Liugroup-NLPR-CASIA
@Modify Time @Author @Version @Desciption
------------ ----... | code_fim | medium | {
"lang": "python",
"repo": "ioir123ju/mmskeleton",
"path": "/mmskeleton/processor/build_label.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def close(self, info=None):
print(f'GAME OVER\n')
sleep(self.delay)
def __adjust_matrix(self, matrix):
return np.flip(np.transpose(matrix), axis=0)<|fim_prefix|># repo: etigerstudio/zilong-on-fire path: /renderers/rpg/text.py
from renderers.base import BaseRenderer
from t... | code_fim | medium | {
"lang": "python",
"repo": "etigerstudio/zilong-on-fire",
"path": "/renderers/rpg/text.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: etigerstudio/zilong-on-fire path: /renderers/rpg/text.py
from renderers.base import BaseRenderer
from time import sleep
import numpy as np
class TextRPGRenderer(BaseRenderer):
def __init__(self, delay=0.1):
self.delay = delay
def setup(self, info=None):
print(f'GAME STA... | code_fim | medium | {
"lang": "python",
"repo": "etigerstudio/zilong-on-fire",
"path": "/renderers/rpg/text.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def setup(self, info=None):
print(f'GAME START')
sleep(self.delay)
def update(self, state, info=None):
print(self.__adjust_matrix(state), info)
sleep(self.delay)
def close(self, info=None):
print(f'GAME OVER\n')
sleep(self.delay)
def __adj... | code_fim | medium | {
"lang": "python",
"repo": "etigerstudio/zilong-on-fire",
"path": "/renderers/rpg/text.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mhubrich/parkingCV path: /ML/models/xception/cross_val.py
import numpy as np
from ML.training import train
from utils.stratification import kfold_train_val_test_split
from utils.misc import list_files
def preprocess_input(x):
x /= 255.
x -= 0.5
x *= 2.
return x
<|fim_suffix|>... | code_fim | hard | {
"lang": "python",
"repo": "mhubrich/parkingCV",
"path": "/ML/models/xception/cross_val.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('Results of the %d-fold cross-validation:' % k)
print('Mean: Loss: %.3f - Acc: %.3f' % (np.mean(losses), np.mean(accs)))
print(' Std: Loss: %.3f - Acc: %.3f' % (np.std(losses), np.std(accs)))<|fim_prefix|># repo: mhubrich/parkingCV path: /ML/models/xception/cross_val.py
import numpy as ... | code_fim | hard | {
"lang": "python",
"repo": "mhubrich/parkingCV",
"path": "/ML/models/xception/cross_val.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: QAlexBall/Python_Module path: /Python_Core/Web/urlopen_auth.py
import urllib.request, urllib.error, urllib.parse
LOGIN = 'wesley'
PASSWD = "you'NeverGuess"
URL = 'http://localhost'
REALM = 'Secure Archive'
<|fim_suffix|>
def request_verson(url):
from base64 import encodestring
req = url... | code_fim | hard | {
"lang": "python",
"repo": "QAlexBall/Python_Module",
"path": "/Python_Core/Web/urlopen_auth.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for funcType in ('handler', 'request'):
print('*** Using %s:' % funcType.upper())
url = eval('%s_version' % funcType)(URL)
f = urllib.request.urlopen(url)
print(str(f.readline(), 'utf-8'))
f.close()<|fim_prefix|># repo: QAlexBall/Python_Module path: /Python_Core/Web/urlopen_auth.py
im... | code_fim | hard | {
"lang": "python",
"repo": "QAlexBall/Python_Module",
"path": "/Python_Core/Web/urlopen_auth.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> from base64 import encodestring
req = urllib.request.Request(url)
b64str = encodestring(
bytes('%s:%s' % (LOGIN, PASSWD), 'utf-8'))[:-1]
req.add_header("Authorization", "Basic %s" % b64str)
return req
for funcType in ('handler', 'request'):
print('*** Using %s:' % funcTyp... | code_fim | hard | {
"lang": "python",
"repo": "QAlexBall/Python_Module",
"path": "/Python_Core/Web/urlopen_auth.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Robert-xiaoqiang/Fast-and-Scalable-Graph-Similarity-Computation path: /src/gwmatching/gwmatching.py
from . import GromovWassersteinGraphToolkit as GwGt
import pickle
import numpy as np
from scipy.sparse import csr_matrix
def adjacency_matrix_from_edge_index(edge_index, v):
'''
graph(... | code_fim | medium | {
"lang": "python",
"repo": "Robert-xiaoqiang/Fast-and-Scalable-Graph-Similarity-Computation",
"path": "/src/gwmatching/gwmatching.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> num_iter = 2000
ot_dict = { 'loss_type': 'L2', # the key hyperparameters of GW distance
'ot_method': 'proximal',
'beta': 0.15,
'outer_iteration': num_iter,
# outer, inner iteration, error bound of optimal transport
'i... | code_fim | medium | {
"lang": "python",
"repo": "Robert-xiaoqiang/Fast-and-Scalable-Graph-Similarity-Computation",
"path": "/src/gwmatching/gwmatching.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for article in cur.fetchall():
article = Article(*article)
print(article.entry.encode('utf8'))
if __name__ == '__main__':
main()<|fim_prefix|># repo: chagge/gv-crawl path: /gv-crawl/db2mono.py
import sqlite3
import argparse
from articles import Article
def main():
parser = a... | code_fim | medium | {
"lang": "python",
"repo": "chagge/gv-crawl",
"path": "/gv-crawl/db2mono.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chagge/gv-crawl path: /gv-crawl/db2mono.py
import sqlite3
import argparse
from articles import Article
def main():
<|fim_suffix|> conn = sqlite3.connect(args.database)
cur = conn.cursor()
cur.execute('select * from articles where lang = ?', (args.lang,))
for article in cur.fetch... | code_fim | hard | {
"lang": "python",
"repo": "chagge/gv-crawl",
"path": "/gv-crawl/db2mono.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Data(aspecd.utils.ToDictMixin):
"""
Unit containing both, numeric data and corresponding axes.
The data class ensures consistency in terms of dimensions between
numerical data and axes.
Parameters
----------
data : `numpy.array`
Numerical data
axes : :class... | code_fim | hard | {
"lang": "python",
"repo": "tillbiskup/aspecd",
"path": "/aspecd/dataset.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def from_dict(self, dict_=None):
"""
Set properties from dictionary, e.g., from serialised dataset.
Only parameters in the dictionary that are valid properties of the
class are set accordingly.
The list of axes is handled appropriately.
Parameters
... | code_fim | hard | {
"lang": "python",
"repo": "tillbiskup/aspecd",
"path": "/aspecd/dataset.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tillbiskup/aspecd path: /aspecd/dataset.py
step=processing_step)
# Important: Need a copy, not the reference to the original object
processing_step = copy.deepcopy(processing_step)
processing_step.process(self, from_dataset=True)
history_record = processing_step.cr... | code_fim | hard | {
"lang": "python",
"repo": "tillbiskup/aspecd",
"path": "/aspecd/dataset.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ptracton/SportsMonkey path: /python/SportsMonkey.py
#! /usr/bin/env python3
import logging
import pandas as pd
import ORM
if __name__ == "__main__":
logging.basicConfig(filename="SportsMonkey.log",
level=logging.INFO,
format='%(asctime)s,%(le... | code_fim | hard | {
"lang": "python",
"repo": "ptracton/SportsMonkey",
"path": "/python/SportsMonkey.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> TableName = "Players"
if not ORM.tableExists(ORM.inspector, TableName):
logging.info("Creating Table {} from {}".format(TableName, CSVFile))
ORM.csvToTable(CSVFile, tableName="Players", db=ORM.db)
RBPlayers = ORM.session.query(ORM.Players).filter(
ORM.Players.position ... | code_fim | medium | {
"lang": "python",
"repo": "ptracton/SportsMonkey",
"path": "/python/SportsMonkey.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> targLayer[i] = np.resize(imageio.imread(pathLabel + labelsList[nimg]), (1, 483, 483)) / 255.
acc = [0] # do not use default accurate
net.training(lr, inLayer, outLayer, targLayer, acc)
accuratSumm += acc[0]
print(datetime.datetime.now().strftime('%H:%M:%S'), n, "accurate", accu... | code_fim | hard | {
"lang": "python",
"repo": "catcherochek/skynet",
"path": "/example/unet/python_example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: catcherochek/skynet path: /example/unet/python_example.py
import os
from libskynet import*
import numpy as np
import imageio
import random
import ctypes
import datetime
# create net
net = snNet.Net()
net.addNode("In", snOperator.Input(), "C1") \
.addNode("C1", snOperator.Convolution(10, (3... | code_fim | medium | {
"lang": "python",
"repo": "catcherochek/skynet",
"path": "/example/unet/python_example.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def search_in_cookpad(word):
# keyword = unicode(word, errors='ignore')
keyword = urllib.quote(word.encode('utf-8'))
searchurl = urlparse.urljoin("http://cookpad.com/search/", keyword)
sock = urllib.urlopen(searchurl)
htmlSource = sock.read()
sock.close()
urls = re.findall(r'http://cookpad.com/reci... | code_fim | hard | {
"lang": "python",
"repo": "TechResidence/CookResidence",
"path": "/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TechResidence/CookResidence path: /main.py
"""`main` is the top level module for your Flask application."""
# -*- coding: utf-8 -*-
from secret import *
import logging
import json
from google.appengine.ext import vendor
vendor.add('lib')
from google.appengine.api import urlfetch
# Import the F... | code_fim | hard | {
"lang": "python",
"repo": "TechResidence/CookResidence",
"path": "/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: imolloy/gpx_geotagger path: /GoogleMaps.py
import os
import os.path
import re
class GoogleMaps(object):
exif_keys = ['EXIF ISOSpeedRatings', 'EXIF FocalLength', 'EXIF ExposureTime', 'EXIF FocalLengthIn35mmFilm', 'EXIF FNumber', 'EXIF Flash', 'EXIF ExposureBiasValue', 'EXIF ExposureProgram', ... | code_fim | hard | {
"lang": "python",
"repo": "imolloy/gpx_geotagger",
"path": "/GoogleMaps.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Make a little HTML Snippet that will display in Google Maps InfoWindow
# Might as well present the EXIF Metadata in a table...
res = '<table>'
for k in self.exif_keys:
res += '<tr><td><b>%s</b></td><td>%s</td></tr>' % (self.exif_map[k], kwargs['exif'][k])
... | code_fim | hard | {
"lang": "python",
"repo": "imolloy/gpx_geotagger",
"path": "/GoogleMaps.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def write_suffix(self):
# Write a canned suffix to cloe remainng tags and initialize the canvas
self.fd.write("""
var meanderPath = new google.maps.Polyline({
path: meanderPathCoordinates,
strokeColor: "#000000",
strokeOpa... | code_fim | hard | {
"lang": "python",
"repo": "imolloy/gpx_geotagger",
"path": "/GoogleMaps.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>alor {dados["idade"]}\n'
f' - ctps tem o valor {dados["ctps"]}')
else:
dados['contratação'] = int(input('Ano de contratação: '))
dados['salário'] = float(input('Salario: R$'))
dados['aposentadoria'] = dados['idade'] + ((dados['contratação'] + 35) - date.today().year)
for v, c in dados.i... | code_fim | medium | {
"lang": "python",
"repo": "LeoWshington/Exercicios_CursoEmVideo_Python",
"path": "/ex092.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>put('Salario: R$'))
dados['aposentadoria'] = dados['idade'] + ((dados['contratação'] + 35) - date.today().year)
for v, c in dados.items():
print(f' - {v} tem o valor {c}')<|fim_prefix|># repo: LeoWshington/Exercicios_CursoEmVideo_Python path: /ex092.py
from datetime import date
dados = {'nome': str(... | code_fim | medium | {
"lang": "python",
"repo": "LeoWshington/Exercicios_CursoEmVideo_Python",
"path": "/ex092.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LeoWshington/Exercicios_CursoEmVideo_Python path: /ex092.py
from datetime import date
dados = {'nome': str(input('Nome: ')).strip(),
'idade': int(input('Ano de nascimento: ')),
'ctps': int(input('Carteira de trabalho <|fim_suffix|>put('Salario: R$'))
dados['aposentadoria'] = dad... | code_fim | hard | {
"lang": "python",
"repo": "LeoWshington/Exercicios_CursoEmVideo_Python",
"path": "/ex092.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(len(layers), 2)
self.assertEqual(layers[0], "123456")
self.assertEqual(layers[1], "789012")
class TestGetLayers(unittest.TestCase):
def test_simple(self):
layer = "123456"
infos = parse_infos(layer)
self.assertEqual(infos, {"1": 1, "2... | code_fim | medium | {
"lang": "python",
"repo": "SabatierBoris/adventofcode",
"path": "/2019/08/test_common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> layer = "123456"
infos = parse_infos(layer)
self.assertEqual(infos, {"1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1})
class TestMergeLayers(unittest.TestCase):
def test_simple(self):
layers = ["0222", "1122", "2212", "0000"]
layer = merge_layers(layers)
... | code_fim | medium | {
"lang": "python",
"repo": "SabatierBoris/adventofcode",
"path": "/2019/08/test_common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SabatierBoris/adventofcode path: /2019/08/test_common.py
#!/usr/bin/env python3
import unittest
from common import get_layers, parse_infos, merge_layers
class TestGetLayers(unittest.TestCase):
def test_simple(self):
wide = 3
tall = 2
data = "123456789012"
<|fim_suf... | code_fim | hard | {
"lang": "python",
"repo": "SabatierBoris/adventofcode",
"path": "/2019/08/test_common.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bryanmorganoverbey/atty-cxn path: /main/migrations/0005_auto_20180424_1443.py
# Generated by Django 2.0.4 on 2018-04-24 14:43
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('main', '0004_auto_20180424_1439'),
]
operations = [
migrations.A... | code_fim | hard | {
"lang": "python",
"repo": "bryanmorganoverbey/atty-cxn",
"path": "/main/migrations/0005_auto_20180424_1443.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('main', '0004_auto_20180424_1439'),
]
operations = [
migrations.AlterField(
model_name='attorney',
name='email',
field=models.CharField(max_length=50, unique=True),
),
migrations.AlterField(
mod... | code_fim | hard | {
"lang": "python",
"repo": "bryanmorganoverbey/atty-cxn",
"path": "/main/migrations/0005_auto_20180424_1443.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AI-HUB-Deep-Learning-Fundamental/Tensorflow2-Tutorial-1 path: /reuse_model_layer.py
from tensorflow import keras
import numpy as np
data_x = np.random.normal(size=[1000, 1])
noise = np.random.normal(size=[1000, 1]) * 0.2
data_y = data_x * 3. + 2. + noise
train_x, train_y = data_x[:900], data_y[... | code_fim | hard | {
"lang": "python",
"repo": "AI-HUB-Deep-Learning-Fundamental/Tensorflow2-Tutorial-1",
"path": "/reuse_model_layer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>model1 = Model()
model2 = Model()
model1.build((None, 1))
model2.build((None, 1))
model1.compile(
optimizer=keras.optimizers.SGD(0.01),
loss=keras.losses.MeanSquaredError(),
metrics=[keras.metrics.MeanSquaredError()],
)
# train model1 for a while
model1.fit(train_x, train_y, batch_size=32, ... | code_fim | hard | {
"lang": "python",
"repo": "AI-HUB-Deep-Learning-Fundamental/Tensorflow2-Tutorial-1",
"path": "/reuse_model_layer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MartinThoma/hwrt path: /hwrt/datasets/inkml.py
# Core Library modules
import json
import logging
import signal
import sys
from xml.dom.minidom import parseString
# Third party modules
from natsort import natsorted
# Local modules
from .. import handwritten_data
from ..datasets import formula_to... | code_fim | hard | {
"lang": "python",
"repo": "MartinThoma/hwrt",
"path": "/hwrt/datasets/inkml.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Get LaTeX
formula_in_latex = None
annotations = root.findall("{http://www.w3.org/2003/InkML}annotation")
for annotation in annotations:
if annotation.attrib["type"] == "truth":
formula_in_latex = annotation.text
hw = handwritten_data.HandwrittenData(
json.... | code_fim | hard | {
"lang": "python",
"repo": "MartinThoma/hwrt",
"path": "/hwrt/datasets/inkml.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.