text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>import bocco
bocco.cli.cli(obj={})<|fim_prefix|># repo: YUKAI/bocco-api-python path: /bin/boccotools.py
# encoding: utf-8
from __future__ import absolute_import
import os
import sys
<|fim_middle|>ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
sys.path.append(ROOT... | code_fim | medium | {
"lang": "python",
"repo": "YUKAI/bocco-api-python",
"path": "/bin/boccotools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YUKAI/bocco-api-python path: /bin/boccotools.py
# encoding: utf-8
from __future__ import absolute_import
import os
import sys
<|fim_suffix|>import bocco
bocco.cli.cli(obj={})<|fim_middle|>ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
sys.path.append(ROOT... | code_fim | medium | {
"lang": "python",
"repo": "YUKAI/bocco-api-python",
"path": "/bin/boccotools.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # brightness
ha_brightness = self.brightness
new_range = self._tuya_brightness_range()
tuya_brightness = self.remap(
ha_brightness, 0, 255, new_range[0], new_range[1]
)
commands += [{"code": self.dp_code_bright, "value... | code_fim | hard | {
"lang": "python",
"repo": "macbury/SmartHouse",
"path": "/home-assistant/custom_components/tuya_v2/light.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: macbury/SmartHouse path: /home-assistant/custom_components/tuya_v2/light.py
"""Support for the Tuya lights."""
from __future__ import annotations
import json
import logging
from typing import Any
from tuya_iot import TuyaDevice, TuyaDeviceManager
from homeassistant.components.light import (
... | code_fim | hard | {
"lang": "python",
"repo": "macbury/SmartHouse",
"path": "/home-assistant/custom_components/tuya_v2/light.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> hsv_data_range = self._tuya_hsv_function()
if hsv_data_range is not None:
hsv_s = hsv_data_range.get("s", {"min": 0, "max": 255})
return hsv_s.get("min", 0), hsv_s.get("max", 255)
return 0, 255
def _tuya_hsv_v_range(self) -> tuple[int, int]:
hsv... | code_fim | hard | {
"lang": "python",
"repo": "macbury/SmartHouse",
"path": "/home-assistant/custom_components/tuya_v2/light.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jpedrocm/noise-detection-ensemble path: /src/majority_filtering.py
###############################################################################
from sklearn.ensemble import RandomForestClassifier as RF
from sklearn.model_selection import StratifiedKFold
from pandas import DataFrame, Series
... | code_fim | hard | {
"lang": "python",
"repo": "jpedrocm/noise-detection-ensemble",
"path": "/src/majority_filtering.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> clean_X = DataFrame(columns=X.columns)
clean_y = Series(name=y.name)
skf = StratifiedKFold(n_splits=MajorityFiltering.k_folds,
shuffle=True)
for train_idxs, val_idxs in skf.split(X=range(len(y)), y=y):
train_X = DataHelper.select_rows(X, train_idxs, copy=False)
train_y = DataHel... | code_fim | medium | {
"lang": "python",
"repo": "jpedrocm/noise-detection-ensemble",
"path": "/src/majority_filtering.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PLOS/sesceph path: /_modules/ceph_cfg/__init__.py
uster_uuid'='cluster_uuid'
Notes:
keyring_type
Required paramter
Can be set to:
admin, mon, osd, rgw, mds
cluster_uuid
Set the cluster UUID. Defaults to value found in ceph config file.
cluste... | code_fim | hard | {
"lang": "python",
"repo": "PLOS/sesceph",
"path": "/_modules/ceph_cfg/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> salt '*' ceph_cfg.keyring_rgw_auth_add \\
'[rgw.]\n\tkey = AQA/vZ9WyDwsKRAAxQ6wjGJH6WV8fDJeyzxHrg==\n\tcaps rgw = \"allow *\"\n' \\
'cluster_name'='ceph' \\
'cluster_uuid'='cluster_uuid'
Notes:
cluster_uuid
Set the cluster UUID. Defa... | code_fim | hard | {
"lang": "python",
"repo": "PLOS/sesceph",
"path": "/_modules/ceph_cfg/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PLOS/sesceph path: /_modules/ceph_cfg/__init__.py
cluster_name'='ceph' \\
'osd_number'='23' \\
'weight'='0'
Notes:
osd_number
OSD number to reweight.
weight
The new weight for the osd. Weight is a float, and must be
in the ran... | code_fim | hard | {
"lang": "python",
"repo": "PLOS/sesceph",
"path": "/_modules/ceph_cfg/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> input_text = open("day_2_input.txt").read().splitlines()[0]
data = [int(val) for val in input_text.split(",")]
data[1] = 12
data[2] = 2
calc(data)
print('Answer is: ', data[0])
if __name__ == "__main__":
main()<|fim_prefix|># repo: Boraz/Advent-of-code-2019 path: /Day_1/main... | code_fim | medium | {
"lang": "python",
"repo": "Boraz/Advent-of-code-2019",
"path": "/Day_1/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Boraz/Advent-of-code-2019 path: /Day_1/main.py
def calc(Day2):
i = 0
while Day2[i] != 99: #look for the exit code
print('...')
if Day2[i] == 1: # 1 for +
print('more gravity...')
Day2[Day2[i + 3]] = Day2[Day2[i + 2]] + Day2[Day2[i + 1]]
elif... | code_fim | medium | {
"lang": "python",
"repo": "Boraz/Advent-of-code-2019",
"path": "/Day_1/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: orion-search/orion path: /orion/packages/projection/faiss_index.py
import numpy as np
import faiss
def faiss_index(vectors, ids=None):
"""Create a brute-force FAISS index.
<|fim_suffix|> """
index = faiss.IndexFlatL2(vectors.shape[1])
if ids:
index = faiss.IndexIDMap(ind... | code_fim | hard | {
"lang": "python",
"repo": "orion-search/orion",
"path": "/orion/packages/projection/faiss_index.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
vectors (:obj:`numpy.array` of `float`): Usually document vectors
ids (:obj:`list` of `int`, None): FAISS creates a numerical index which
can be substituted by a list of ids. Here, it can be paper IDs.
Returns:
index (`faiss.swigfaiss.IndexIDMap`)
""... | code_fim | medium | {
"lang": "python",
"repo": "orion-search/orion",
"path": "/orion/packages/projection/faiss_index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: puechtom/nlp path: /src/python_language_tokenizer.py
bs4 import BeautifulSoup
import re
import random
import string
import time
import copy
## Regex expressions##################################
methodpattern = (r"(?:\b)(?:[a-zA-Z_])(?:\.\w|\w)*(?:\([^\(\)]*(?:\([^\(\)]*(?:\([^\(\)]*(?:\(... | code_fim | hard | {
"lang": "python",
"repo": "puechtom/nlp",
"path": "/src/python_language_tokenizer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: puechtom/nlp path: /src/python_language_tokenizer.py
t BeautifulSoup
import re
import random
import string
import time
import copy
## Regex expressions##################################
methodpattern = (r"(?:\b)(?:[a-zA-Z_])(?:\.\w|\w)*(?:\([^\(\)]*(?:\([^\(\)]*(?:\([^\(\)]*(?:\([^\(\)]*\... | code_fim | hard | {
"lang": "python",
"repo": "puechtom/nlp",
"path": "/src/python_language_tokenizer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('time taken to consolidate irregulars: %f' %(time.time()-start))
######################################################################################################
############### tokenize dataset into sentences ############################
start = time.time()
sent... | code_fim | hard | {
"lang": "python",
"repo": "puechtom/nlp",
"path": "/src/python_language_tokenizer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> PythiaParameters = cms.PSet(
pythiaUESettingsBlock,
processParameters = cms.vstring(
'MSEL=1 ! QCD hight pT processes',
'CKIN(3)=30 ! minimum pt hat for hard interactions',
),
parameterSets = cms.vstring(
'pythiaUESettings',
'processParameters',
)
)
)
ProductionFilterSequence =... | code_fim | hard | {
"lang": "python",
"repo": "simonecid/cmssw",
"path": "/Configuration/Generator/python/QCD_Pt_30_TuneZ2_7TeV_pythia6_cff.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: simonecid/cmssw path: /Configuration/Generator/python/QCD_Pt_30_TuneZ2_7TeV_pythia6_cff.py
import FWCore.ParameterSet.Config as cms
from Configuration.Generator.PythiaUEZ2Settings_cfi import *
<|fim_suffix|> PythiaParameters = cms.PSet(
pythiaUESettingsBlock,
processParameters = cms.vstring... | code_fim | hard | {
"lang": "python",
"repo": "simonecid/cmssw",
"path": "/Configuration/Generator/python/QCD_Pt_30_TuneZ2_7TeV_pythia6_cff.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 1pani/fund-rank-dashboard path: /venv/Lib/site-packages/pandas/tests/util/test_hashing.py
import pytest
import datetime
from warnings import catch_warnings
import numpy as np
import pandas as pd
from pandas import DataFrame, Series, Index, MultiIndex
from pandas.util import hash_array, hash_pan... | code_fim | hard | {
"lang": "python",
"repo": "1pani/fund-rank-dashboard",
"path": "/venv/Lib/site-packages/pandas/tests/util/test_hashing.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # these are equal
assert mi.equals(recons)
assert Index(mi.values).equals(Index(recons.values))
# _hashed_values and hash_pandas_object(..., index=False)
# equivalency
expected = hash_pandas_object(
mi, index=False).values
result = mi._h... | code_fim | hard | {
"lang": "python",
"repo": "1pani/fund-rank-dashboard",
"path": "/venv/Lib/site-packages/pandas/tests/util/test_hashing.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jackmaney/pg-utils path: /pg_utils/util/__init__.py
"""
This module just contains utility functions that don't directly fit anywhere else. You shouldn't need to tinker with these.
"""
import inspect
from functools import wraps
from getpass import getuser
from six import PY2
from ..connection im... | code_fim | hard | {
"lang": "python",
"repo": "jackmaney/pg-utils",
"path": "/pg_utils/util/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @wraps(f)
def decorator(*args, **kwargs):
args = list(args) # args is given as a tuple, and we may need to alter it...
kwargs.setdefault("conn", Connection())
schema = kwargs.get("schema")
idx = position_of_positional_arg("table_name", f)
table_name = a... | code_fim | hard | {
"lang": "python",
"repo": "jackmaney/pg-utils",
"path": "/pg_utils/util/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert np.mean(np.abs(yfilt - yfilt_scipy)) < 1e-7<|fim_prefix|># repo: SamProell/yarppg path: /tests/test_digital_filter.py
import numpy as np
import scipy.signal
from yarppg.rppg.filters import DigitalFilter, get_butterworth_filter
def test_process():
fs, cutoff = 10., 3.
ba = scipy.sign... | code_fim | medium | {
"lang": "python",
"repo": "SamProell/yarppg",
"path": "/tests/test_digital_filter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SamProell/yarppg path: /tests/test_digital_filter.py
import numpy as np
import scipy.signal
from yarppg.rppg.filters import DigitalFilter, get_butterworth_filter
def test_process():
fs, cutoff = 10., 3.
ba = scipy.signal.butter(2, Wn=cutoff/fs*2, btype="low")
lfilter = get_butterwo... | code_fim | medium | {
"lang": "python",
"repo": "SamProell/yarppg",
"path": "/tests/test_digital_filter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adarnimrod/bgp-spamd path: /tests/test_bgp_spamd.py
def test_spamd_service(Service):
assert Service('spamd').is_running
def test_spamd_config(File):
<|fim_suffix|>def test_bgpd_config(File, Sudo):
with Sudo():
assert File('/etc/bgpd.conf').contains('spamdAS')
def test_pf_ancho... | code_fim | medium | {
"lang": "python",
"repo": "adarnimrod/bgp-spamd",
"path": "/tests/test_bgp_spamd.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_bgpd_user(User, File):
assert User('_bgpd').exists
assert File('/etc/mail/aliases').contains('_bgpd: root')
def test_spamd_user(User, File):
assert User('_spamd').exists
assert File('/etc/mail/aliases').contains('_spamd: root')
def test_allowed_domains(File):
assert File('... | code_fim | hard | {
"lang": "python",
"repo": "adarnimrod/bgp-spamd",
"path": "/tests/test_bgp_spamd.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@swagger.model
class OperationResponse(BaseResponse):
resource_fields = {
'id': fields.String,
'name': fields.String,
'state': fields.String,
}
@swagger.model
class License(BaseResponse):
resource_fields = {
'customer_id': fields.String,
'expiration_d... | code_fim | hard | {
"lang": "python",
"repo": "cloudify-cosmo/cloudify-manager",
"path": "/rest-service/manager_rest/rest/responses_v3.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cloudify-cosmo/cloudify-manager path: /rest-service/manager_rest/rest/responses_v3.py
from typing import Dict
from flask_restful import fields
from manager_rest.rest import swagger
class BaseResponse(object):
resource_fields: Dict[str, fields.Raw] = {}
def __init__(self, **kwargs):
... | code_fim | hard | {
"lang": "python",
"repo": "cloudify-cosmo/cloudify-manager",
"path": "/rest-service/manager_rest/rest/responses_v3.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: banro21/alexa-truth-or-dare path: /tests/voice_interface_test.py
"application": {
"applicationId": voice_interface.ALEXA_SKILL_ID
},
"user": {
"userId": "amzn1.ask.account.1234"
},
"new": False
},
... | code_fim | hard | {
"lang": "python",
"repo": "banro21/alexa-truth-or-dare",
"path": "/tests/voice_interface_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: banro21/alexa-truth-or-dare path: /tests/voice_interface_test.py
"applicationId": voice_interface.ALEXA_SKILL_ID
},
"user": {
"userId": "amzn1.ask.account.1234"
},
"new": False
},
"request": {
... | code_fim | hard | {
"lang": "python",
"repo": "banro21/alexa-truth-or-dare",
"path": "/tests/voice_interface_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@mock.patch('tod.model.Model.get_questions_of_type_and_category')
def test_get_truth_or_dare_question_category_completed(get_questions_of_type_and_category):
get_questions_of_type_and_category.return_value = [
(1, "truth question 1", "truth", 6),
(2, "truth question 2", "truth", 6),
... | code_fim | hard | {
"lang": "python",
"repo": "banro21/alexa-truth-or-dare",
"path": "/tests/voice_interface_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FirebirdSQL/firebird-qa path: /tests/bugs/core_3801_test.py
#coding:utf-8
"""
ID: issue-4144
ISSUE: 4144
TITLE: Warnings could be put twice in status-vector
DESCRIPTION:
JIRA: CORE-3801
FBTEST: bugs.core_3801
"""
import pytest
from firebird.qa import *
db = db_... | code_fim | medium | {
"lang": "python",
"repo": "FirebirdSQL/firebird-qa",
"path": "/tests/bugs/core_3801_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> act.expected_stderr = expected_stderr
act.execute()
assert act.clean_stderr == act.clean_expected_stderr<|fim_prefix|># repo: FirebirdSQL/firebird-qa path: /tests/bugs/core_3801_test.py
#coding:utf-8
"""
ID: issue-4144
ISSUE: 4144
TITLE: Warnings could be put twice in st... | code_fim | hard | {
"lang": "python",
"repo": "FirebirdSQL/firebird-qa",
"path": "/tests/bugs/core_3801_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
n = 1000
i = 10000
prob_id = 704
timed.caller(dummy, n, i, prob_id)<|fim_prefix|># repo: lcsm29/project-euler path: /py/py_0704_factors_of_two_in_binomial_coefficients.py
# Solution of;
# Project Euler Problem 704: Factors of Two in Binomial Coefficients
# http... | code_fim | medium | {
"lang": "python",
"repo": "lcsm29/project-euler",
"path": "/py/py_0704_factors_of_two_in_binomial_coefficients.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
n = 1000
i = 10000
prob_id = 704
timed.caller(dummy, n, i, prob_id)<|fim_prefix|># repo: lcsm29/project-euler path: /py/py_0704_factors_of_two_in_binomial_coefficients.py
# Solution of;
# Project Euler Problem 704: Factors of Two in Binomial Coefficients
# https... | code_fim | medium | {
"lang": "python",
"repo": "lcsm29/project-euler",
"path": "/py/py_0704_factors_of_two_in_binomial_coefficients.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lcsm29/project-euler path: /py/py_0704_factors_of_two_in_binomial_coefficients.py
# Solution of;
# Project Euler Problem 704: Factors of Two in Binomial Coefficients
# https://projecteuler.net/problem=704
#
# Define $g(n, m)$ to be the largest integer $k$ such that $2^k$ divides
# $\binom{n}m$.... | code_fim | medium | {
"lang": "python",
"repo": "lcsm29/project-euler",
"path": "/py/py_0704_factors_of_two_in_binomial_coefficients.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aviral14/MyDrive path: /django_project/Dashboard/forms.py
from django import forms
from . import models
class DocumentForm(forms.ModelForm):
<|fim_suffix|> model = models.Filedata
fields = ('filename', 'userfile')<|fim_middle|> class Meta:
| code_fim | easy | {
"lang": "python",
"repo": "Aviral14/MyDrive",
"path": "/django_project/Dashboard/forms.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = models.Filedata
fields = ('filename', 'userfile')<|fim_prefix|># repo: Aviral14/MyDrive path: /django_project/Dashboard/forms.py
from django import forms
from . import models
class DocumentForm(forms.ModelForm):
<|fim_middle|> class Meta:
| code_fim | easy | {
"lang": "python",
"repo": "Aviral14/MyDrive",
"path": "/django_project/Dashboard/forms.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021 path: /answers/justshivam/Day 12/question1.py
def checkPalindorme(string, start, end):
string = string[start-1:end]
l = len(string)
for i in range(l):
j = -1-i
if not string[i] == string[-1-i]:
res.append('N... | code_fim | medium | {
"lang": "python",
"repo": "Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021",
"path": "/answers/justshivam/Day 12/question1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
arr = input('Enter first line: ').split()
l = int(arr[0])
n = int(arr[1])
string = input('Enter the string: ')
res = []
for i in range(n):
op = input().split()
if int(op[0]) == 2:
checkPalindorme(string, int(op[1]), int(op[2]))
elif int(op[0]) == 1:
swap(string, int(op[1]))
... | code_fim | medium | {
"lang": "python",
"repo": "Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021",
"path": "/answers/justshivam/Day 12/question1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # if the file type is found in the
# command line arguments, open the file
if file_type in args:
f = open(str(directory_file))
directory_file_name = str(directory_file)
print(directory_file_name + ":")
for... | code_fim | hard | {
"lang": "python",
"repo": "brandorags/WordCounter",
"path": "/python/word_counter_console.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # display the total number of times
# the word was found in the file
print(word + " was found " + str(word_counter) + " times.")
else:
# if the user didn't put any arguments in,
# let them know how to use the script
print('Usage: ... | code_fim | medium | {
"lang": "python",
"repo": "brandorags/WordCounter",
"path": "/python/word_counter_console.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brandorags/WordCounter path: /python/word_counter_console.py
"""
Name: word_counter_console.py
Author: Brandon Ragsdale
Description: This script counts the number of times
a particular word occurs within a set of files.
Copyright (c) 2015 Brandon Ragsdale
Permission is hereby granted, free of c... | code_fim | hard | {
"lang": "python",
"repo": "brandorags/WordCounter",
"path": "/python/word_counter_console.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> char = builder.call(getchar, ())
is_eof = builder.icmp_unsigned("==", char, eof)
with builder.if_else(is_eof) as (then, otherwise):
with then:
builder.store(zero8, location)
with otherwise:
char =... | code_fim | hard | {
"lang": "python",
"repo": "PurpleMyst/bf_compiler",
"path": "/bf_compiler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PurpleMyst/bf_compiler path: /bf_compiler.py
#!/usr/bin/env python3
import argparse
import ctypes
import os
import sys
from llvmlite import ir, binding as llvm
INDEX_BIT_SIZE = 16
def parse(bf):
bf = iter(bf)
result = []
for c in bf:
if c == "[":
result.append... | code_fim | hard | {
"lang": "python",
"repo": "PurpleMyst/bf_compiler",
"path": "/bf_compiler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> builder.call(putchar, (tape_value,))
elif instruction == ",":
location = get_tape_location()
char = builder.call(getchar, ())
is_eof = builder.icmp_unsigned("==", char, eof)
with builder.if_else(is_eof) as (then, otherwise):
... | code_fim | hard | {
"lang": "python",
"repo": "PurpleMyst/bf_compiler",
"path": "/bf_compiler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.graphs = []
self.create_trail_of_effective_edges()
self.create_trail_of_backwards_jumps()
self.create_highlight_points_of_return()
def _set_dataset_path(self, pandas_dataset):
assert os.path.isfile(pandas_dataset)
self.dataset_path = pandas_datase... | code_fim | hard | {
"lang": "python",
"repo": "christian-fr/QmlReaderTools",
"path": "/advancedFlowchart/advancedFlowchart.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: christian-fr/QmlReaderTools path: /advancedFlowchart/advancedFlowchart.py
__author__ = "Christian Friedrich"
__maintainer__ = "Christian Friedrich"
__license__ = "MIT"
__version__ = "0.1.0"
__status__ = "Prototype"
__name__ = "advancedFlowchart"
import os
import pandas as pd
import pygraphviz
fr... | code_fim | hard | {
"lang": "python",
"repo": "christian-fr/QmlReaderTools",
"path": "/advancedFlowchart/advancedFlowchart.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, digraph, pandas_dataset, input_graph):
self.dataset_path = None
self._set_dataset_path(pandas_dataset)
self.history_dataset = None
self.history_as_list = []
self._read_dataset()
self._colorfader = create_blue_red_color_gradient_list(... | code_fim | hard | {
"lang": "python",
"repo": "christian-fr/QmlReaderTools",
"path": "/advancedFlowchart/advancedFlowchart.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fitresults = modifypdf.prune(fitresults)
columnheaders = fitresults.keys()
columnheaders.sort()
nparam = len(columnheaders)
nrow = nparam / ncol + 1
if uvfitdir == uvfitdirs[0]:
fig = plt.figure(figsize=(8.0, 2.0 * nrow))
counter = 1
... | code_fim | hard | {
"lang": "python",
"repo": "sbussmann/Bussmann2015",
"path": "/Code/modelcompare.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for itarg in range(0, ntarg):
dataname = targlist['dataname'][itarg]
print "Working on " + dataname
for uvfitdir in uvfitdirs:
fitdir = modelloc + dataname + '/' + uvfitdir + '/'
fitfiles = glob.glob(fitdir + pdflocs)
fitfile = fitfiles[-1]
fitresults = Table.... | code_fim | hard | {
"lang": "python",
"repo": "sbussmann/Bussmann2015",
"path": "/Code/modelcompare.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sbussmann/Bussmann2015 path: /Code/modelcompare.py
"""
2014 February 11
Shane Bussmann
Compare uvfit10 and uvfit11 model results.
uvfit10 = MLE + statwt + CASA-bin
uvfit11 = chi2 + statwt + CASA-bin
"""
from astropy.table import Table
import glob
import modifypdf
import matplotlib.pyplot as p... | code_fim | hard | {
"lang": "python",
"repo": "sbussmann/Bussmann2015",
"path": "/Code/modelcompare.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tongxindao/shiyanlou path: /shiyanlou_cs356-3ce9619c86/templatemethod.py
# _*_ coding: utf-8 _*_
import abc
class Fishing(object):
__metaclass__ = abc.ABCMeta
def finishing(self):
self.prepare_bait()
self.go_to_riverbank()
self.find_location()
print("star... | code_fim | hard | {
"lang": "python",
"repo": "tongxindao/shiyanlou",
"path": "/shiyanlou_cs356-3ce9619c86/templatemethod.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
f = JohnFishing()
f.finishing()
f = SimonFishing()
f.finishing()<|fim_prefix|># repo: tongxindao/shiyanlou path: /shiyanlou_cs356-3ce9619c86/templatemethod.py
# _*_ coding: utf-8 _*_
import abc
class Fishing(object):
__metaclass__ = abc.ABCMeta
def fi... | code_fim | hard | {
"lang": "python",
"repo": "tongxindao/shiyanlou",
"path": "/shiyanlou_cs356-3ce9619c86/templatemethod.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class FacebookConnect(SocialConnectView):
adapter_class = FacebookOAuth2Adapter<|fim_prefix|># repo: robertoassuncaofilho/break2moveapi path: /game/social_login.py
from allauth.socialaccount.providers.facebook.views import FacebookOAuth2Adapter
from dj_rest_auth.registration.views import SocialLoginV... | code_fim | medium | {
"lang": "python",
"repo": "robertoassuncaofilho/break2moveapi",
"path": "/game/social_login.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: robertoassuncaofilho/break2moveapi path: /game/social_login.py
from allauth.socialaccount.providers.facebook.views import FacebookOAuth2Adapter
from dj_rest_auth.registration.views import SocialLoginView, SocialConnectView
<|fim_suffix|> adapter_class = FacebookOAuth2Adapter
class FacebookCo... | code_fim | easy | {
"lang": "python",
"repo": "robertoassuncaofilho/break2moveapi",
"path": "/game/social_login.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Clean aml file for demo-aml
aml_path = os.path.join(demo_dir, 'demo-aml.txt')
aml_clean_path = os.path.join(demo_dir, 'demo-aml-clean.csv')
write_aml_clean(aml_path, aml_clean_path)
# Classify species in demo
aml_clean_path = os.path.join(demo_dir, 'demo-aml-clean.csv')
class_path = os.path.join(data_d... | code_fim | hard | {
"lang": "python",
"repo": "jkitzes/batid",
"path": "/src/runall.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jkitzes/batid path: /src/runall.py
#!/usr/bin/python
'''
Run all analysis, including fitting classifier and classifying demo data.
File should be run with cwd as src dir.
'''
import os
from classify import write_aml_clean, fit_classifier, classify_calls
from utils import read_params
# ------... | code_fim | hard | {
"lang": "python",
"repo": "jkitzes/batid",
"path": "/src/runall.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("running mcs=", mcs)
for i, cell in enumerate(self.cell_list):
if i > 3:
break
# print ('cell=', cell)
print('cell.id=', cell.id)
print('sleeping')
time.sleep(0.3)
print('woke up')
if mcs == 50:
... | code_fim | medium | {
"lang": "python",
"repo": "CompuCell3D/CompuCell3D",
"path": "/CompuCell3D/core/Demos/cellsort_project_py_step_new_style/Simulation/cellsort_2D_steppables.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('woke up')
if mcs == 50:
self.stop_simulation()<|fim_prefix|># repo: CompuCell3D/CompuCell3D path: /CompuCell3D/core/Demos/cellsort_project_py_step_new_style/Simulation/cellsort_2D_steppables.py
from cc3d.core.PySteppables import *
import sys
import time
class Cellsor... | code_fim | hard | {
"lang": "python",
"repo": "CompuCell3D/CompuCell3D",
"path": "/CompuCell3D/core/Demos/cellsort_project_py_step_new_style/Simulation/cellsort_2D_steppables.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CompuCell3D/CompuCell3D path: /CompuCell3D/core/Demos/cellsort_project_py_step_new_style/Simulation/cellsort_2D_steppables.py
from cc3d.core.PySteppables import *
import sys
import time
class CellsortSteppable(SteppableBasePy):
<|fim_suffix|> def step(self, mcs):
print("running mcs="... | code_fim | medium | {
"lang": "python",
"repo": "CompuCell3D/CompuCell3D",
"path": "/CompuCell3D/core/Demos/cellsort_project_py_step_new_style/Simulation/cellsort_2D_steppables.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AugustoMonteiro/flask-postgres-CRUD path: /project/db/access_database.py
from typing import Dict, List, Union
import psycopg2
from project.db.config_database import ConfigDatabase
class AccessDataBase(ConfigDatabase):
def __init__(self) -> None:
self.logger.debug('Init Class Acces... | code_fim | hard | {
"lang": "python",
"repo": "AugustoMonteiro/flask-postgres-CRUD",
"path": "/project/db/access_database.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_message_length(self):
self.logger.debug('GETTING DATA')
conn = psycopg2.connect(**self.postgres_access)
self.logger.debug('DB CONNECTED')
cursor = conn.cursor()
select_query = f"select count(*) from {self.table_name};"
cursor.execute(select_... | code_fim | hard | {
"lang": "python",
"repo": "AugustoMonteiro/flask-postgres-CRUD",
"path": "/project/db/access_database.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BAMresearch/NFDI4IngScientificWorkflowRequirements path: /exemplary_workflow/source/postprocessing.py
"""
$ pvbatch postprocessing.py -h
"""
import sys
import argparse
from paraview.simple import (
PlotOverLine,
PVDReader,
SaveData,
UpdatePipeline,
)
<|fim_suffix|> # save dat... | code_fim | hard | {
"lang": "python",
"repo": "BAMresearch/NFDI4IngScientificWorkflowRequirements",
"path": "/exemplary_workflow/source/postprocessing.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (xmin, xmax, ymin, ymax, zmin, zmax) = source.GetDataInformation().GetBounds()
# init the 'Line' selected for 'Source'
plotOverLine1 = PlotOverLine(
registrationName="PlotOverLine1", Input=source, Source="Line"
)
plotOverLine1.Source.Point1 = [xmin, ymin, zmin]
plotOverLine... | code_fim | medium | {
"lang": "python",
"repo": "BAMresearch/NFDI4IngScientificWorkflowRequirements",
"path": "/exemplary_workflow/source/postprocessing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.parametrize(
"name",
(
"",
".",
"1",
"#ephemeral",
"VERY_BIG_NAME_VERY_BIG_NAME_VERY_BIG_NAME_VERY_BIG_NAME_VERY_BIG_",
"maybe try this",
"or_this_one?",
"-how-about-this-\name",
),
)
def test_validation_topic_channel... | code_fim | medium | {
"lang": "python",
"repo": "Ivashkaization/ansq",
"path": "/tests/test_validation_topic_channel_name.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ivashkaization/ansq path: /tests/test_validation_topic_channel_name.py
import pytest
from ansq.utils import validate_topic_channel_name
@pytest.mark.parametrize(
"name",
(
"test_topic_name",
"test_channel_name1",
"123456",
"test_topic_name#ephemeral",
... | code_fim | medium | {
"lang": "python",
"repo": "Ivashkaization/ansq",
"path": "/tests/test_validation_topic_channel_name.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.policyEvaluation()
stable = self.policyImprovement()
self.visualize(count)
self.saveModel()
if stable:
print("policy has been stable!")
break
else:
print("iter ", count, " end!")
... | code_fim | hard | {
"lang": "python",
"repo": "HuXiao-THU/Reinforcement-Learning-2nd-Exercise",
"path": "/4.7 Jacks Car Rental/Exercise 4-7.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HuXiao-THU/Reinforcement-Learning-2nd-Exercise path: /4.7 Jacks Car Rental/Exercise 4-7.py
# This model runs very slow, each iteration may need up to 30 minutes
import numpy as np
import math
import matplotlib.pyplot as plt
import seaborn as sns
import time
import pickle
import os
class CarRent... | code_fim | hard | {
"lang": "python",
"repo": "HuXiao-THU/Reinforcement-Learning-2nd-Exercise",
"path": "/4.7 Jacks Car Rental/Exercise 4-7.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
return the q value of the state-action tuple
state: a list of numbers of cars in the two stations, like [10, 15]
action: LEGAL number of cars moved from 1 to 2
"""
value = 0
# here we do a simplification to speed up the algorithm
... | code_fim | hard | {
"lang": "python",
"repo": "HuXiao-THU/Reinforcement-Learning-2nd-Exercise",
"path": "/4.7 Jacks Car Rental/Exercise 4-7.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chschenk/cybercamp_backoffice path: /src/cybercamp_backoffice/camp/urls.py
from django.urls import include, path
from cybercamp_backoffice.camp.views import StartView, LoginUrlView, MapView, MembershipView, CheckUserView,\
CheckModerateUserView, GoToCybercampView, WorkshopCreateView, Workshop... | code_fim | hard | {
"lang": "python",
"repo": "chschenk/cybercamp_backoffice",
"path": "/src/cybercamp_backoffice/camp/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
urlpatterns = [
path('', StartView.as_view(), name='start'),
path('goToCybercamp', GoToCybercampView.as_view(), name='go_to_cybercamp'),
path('api/login-url/<login_token>', LoginUrlView.as_view(), name='login_url'),
path('api/map', MapView.as_view(), name='map'),
path('api/membership... | code_fim | medium | {
"lang": "python",
"repo": "chschenk/cybercamp_backoffice",
"path": "/src/cybercamp_backoffice/camp/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Azure/WALinuxAgent path: /tests/common/test_telemetryevent.py
# Copyright 2019 Microsoft Corporation
#
# 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://www.... | code_fim | medium | {
"lang": "python",
"repo": "Azure/WALinuxAgent",
"path": "/tests/common/test_telemetryevent.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_contains_works_for_TelemetryEvent(self):
test_event = get_test_event(message="Dummy Event")
self.assertTrue(GuestAgentExtensionEventsSchema.Name in test_event)
self.assertTrue(GuestAgentExtensionEventsSchema.Version in test_event)
self.assertTrue(GuestAgentExt... | code_fim | medium | {
"lang": "python",
"repo": "Azure/WALinuxAgent",
"path": "/tests/common/test_telemetryevent.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gksmfzz1/JavaProject path: /mymodule.py
#모듈 사용하기
#프로그램을 구성하는 독립적인 단위(함수/클래스)를
#각각 정의하고 관리하는 방법
#자주 사용하는 일반적인 기능은 모듈로 한번 만들어 두면
#필요할때 마다 도입해서 활용할 수 있다
#모듈 : 관련성 있는 데이터들, 함수, 클래스
#모듈을 사용하려면 import 명령으로
#인터프리터에게 사용여부를 알려야 한다
#import random
<|fim_suffix|>
sky.isLeapYear()
#파이썬 패키지
#다수의 개발자가 만든 모듈의... | code_fim | hard | {
"lang": "python",
"repo": "gksmfzz1/JavaProject",
"path": "/mymodule.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#한편, python IDE나 다른 프로젝트에서 모듈을 참조하려면
#pythonPath 가 정의한 위치에 모듈을 저장해둔다
# 파이썬설치위치 or 파이썬설치위치/Lib
sky.isLeapYear()
#파이썬 패키지
#다수의 개발자가 만든 모듈의 이름이 서로 같을 경우
#파이썬에서는 패키지라는 개념을 이용해서 해결
#. 연산자를 이용해서 모듈을 계층적(디렉토리)으로 관리
#파이썬에서 디렉토리가 패키지로 인식되려면
#_init_.py 라는 파일이 반드시 있어야함<|fim_prefix|># repo: gksmfzz1/JavaProject p... | code_fim | hard | {
"lang": "python",
"repo": "gksmfzz1/JavaProject",
"path": "/mymodule.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nthon/google-cloud-python path: /phishingprotection/google/cloud/phishingprotection_v1beta1/proto/phishingprotection_pb2.py
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: google/cloud/phishingprotection_v1beta1/proto/phishingprotection.proto
import sys
_b = sys.version_inf... | code_fim | hard | {
"lang": "python",
"repo": "nthon/google-cloud-python",
"path": "/phishingprotection/google/cloud/phishingprotection_v1beta1/proto/phishingprotection_pb2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>DESCRIPTOR._options = None
_PHISHINGPROTECTIONSERVICEV1BETA1 = _descriptor.ServiceDescriptor(
name="PhishingProtectionServiceV1Beta1",
full_name="google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1",
file=DESCRIPTOR,
index=0,
serialized_options=None,
serialize... | code_fim | hard | {
"lang": "python",
"repo": "nthon/google-cloud-python",
"path": "/phishingprotection/google/cloud/phishingprotection_v1beta1/proto/phishingprotection_pb2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HorizonFTT/Simple-Interpreter path: /src/Lexer/lexer.py
from .token_types import *
class Token(object):
def __init__(self, type, value):
self.type = type
self.value = value
def __str__(self):
"""String representation of the class instance.
Examples:
... | code_fim | hard | {
"lang": "python",
"repo": "HorizonFTT/Simple-Interpreter",
"path": "/src/Lexer/lexer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.current_char == '\'':
return self._string()
if self.current_char == ':' and self.peek() == '=':
self.advance()
self.advance()
return Token(ASSIGN, ':=')
if self.current_char == ';':
... | code_fim | hard | {
"lang": "python",
"repo": "HorizonFTT/Simple-Interpreter",
"path": "/src/Lexer/lexer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def reshape_qkv_to_seq(
self,
q,
k,
v,
q_n,
v_n,
k_n,
b,
c,
) -> Tuple[int]:
"""
Args:
q(torch.Tensor):
q tensor.
k(torch.Tensor):
... | code_fim | hard | {
"lang": "python",
"repo": "NbnbZero/towhee",
"path": "/towhee/models/layers/multi_scale_attention.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
q_shape,
k_shape,
v_shape,
) -> Tuple[int]:
"""
Args:
q_shape(List[int]):
q tensor shape.
k_shape(List[int]):
k tensor shape.
v_shape(List[int]):
v ... | code_fim | hard | {
"lang": "python",
"repo": "NbnbZero/towhee",
"path": "/towhee/models/layers/multi_scale_attention.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NbnbZero/towhee path: /towhee/models/layers/multi_scale_attention.py
# Copyright 2021 Zilliz and Facebook. All rights reserved.
#
# 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 Lic... | code_fim | hard | {
"lang": "python",
"repo": "NbnbZero/towhee",
"path": "/towhee/models/layers/multi_scale_attention.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Grulfen/game_of_life path: /tests/test_world.py
""" Test for the World class of game of life """
# pylint: disable=no-self-use
# pylint: disable=missing-docstring
# pylint: disable=redefined-outer-name
# pylint: disable=invalid-name
from itertools import combinations
import pytest # type: igno... | code_fim | hard | {
"lang": "python",
"repo": "Grulfen/game_of_life",
"path": "/tests/test_world.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> world.randomize(num, size_x=4, size_y=4)
assert len(world) == num
def test_random_init_with_too_many_cells_raises_exception(self, world):
with pytest.raises(ValueError):
world.randomize(3 * 3 + 1, size_x=3, size_y=3)
class TestWorldNeighbours:
""" Test the ne... | code_fim | hard | {
"lang": "python",
"repo": "Grulfen/game_of_life",
"path": "/tests/test_world.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
positions = [(0, 2), (1, 1), (2, 0), (3, 1)]
for pos in positions:
world.set_cell(pos)
print(world)
out, _ = capsys.readouterr()
string = "\n".join([
"{d}{d}{a}{d}".format(d=gol.DEAD_SYMBOL, a=gol.ALIVE_SYMBOL),
"{d}{a... | code_fim | hard | {
"lang": "python",
"repo": "Grulfen/game_of_life",
"path": "/tests/test_world.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _pause(self, _, duration):
return task.deferLater(reactor, duration, lambda: None)
def testConnectionMade(self):
"""Validates the setup only
"""
d = self._getClientConnection()
d.addCallback(lambda _: self.client.disconnect())
return d
... | code_fim | hard | {
"lang": "python",
"repo": "foxpass/divvy-client-python",
"path": "/tests/test_twisted_socket.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: foxpass/divvy-client-python path: /tests/test_twisted_socket.py
import sys
from twisted.python import log
from twisted.internet import reactor
from twisted.internet import task
from twisted.internet.defer import Deferred, maybeDeferred, succeed
from twisted.internet.protocol import Factory, Clie... | code_fim | hard | {
"lang": "python",
"repo": "foxpass/divvy-client-python",
"path": "/tests/test_twisted_socket.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Validates the setup only
"""
d = self._getClientConnection()
d.addCallback(lambda _: self.client.disconnect())
return d
def testSimpleRequest(self):
"""Connect, send request and check response
"""
d = self._getClientConnection()
... | code_fim | hard | {
"lang": "python",
"repo": "foxpass/divvy-client-python",
"path": "/tests/test_twisted_socket.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return (self > other) - (self < other)
def __lt__(self, other):
if not isinstance(self, type(other)):
raise TypeError("Date interval type mismatch")
return (self.date_a, self.date_b) < (other.date_a, other.date_b)
def __le__(self, other):
if not isinst... | code_fim | hard | {
"lang": "python",
"repo": "databand-ai/dbnd",
"path": "/modules/dbnd/src/dbnd/_core/utils/date_interval.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Year(DateInterval):
def __init__(self, y):
date_a = datetime.date(y, 1, 1)
date_b = datetime.date(y + 1, 1, 1)
super(Year, self).__init__(date_a, date_b)
def to_string(self):
return self.date_a.strftime("%Y")
@classmethod
def from_date(cls, d):
... | code_fim | hard | {
"lang": "python",
"repo": "databand-ai/dbnd",
"path": "/modules/dbnd/src/dbnd/_core/utils/date_interval.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: databand-ai/dbnd path: /modules/dbnd/src/dbnd/_core/utils/date_interval.py
# -*- coding: utf-8 -*-
#
# Copyright 2012-2015 Spotify AB
# Modifications copyright (C) 2018 databand.ai
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance... | code_fim | hard | {
"lang": "python",
"repo": "databand-ai/dbnd",
"path": "/modules/dbnd/src/dbnd/_core/utils/date_interval.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spencercjh/rabbitMQdemo path: /src/consumer.py
import pika
def consumer():
# 消费者
credentials = pika.PlainCredentials(username='guest', password='guest')
# 连接到rabbit_mq服务器
connection = pika.BlockingConnection(pika.ConnectionParameters('127.0.0.1', 5672, credentials=credentials))
... | code_fim | hard | {
"lang": "python",
"repo": "spencercjh/rabbitMQdemo",
"path": "/src/consumer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 开始接收信息,并进入阻塞状态,队列里有信息才会调用callback进行处理。按ctrl+c退出。
channel.start_consuming()
if __name__ == '__main__':
consumer()<|fim_prefix|># repo: spencercjh/rabbitMQdemo path: /src/consumer.py
import pika
def consumer():
# 消费者
credentials = pika.PlainCredentials(username='guest', password='... | code_fim | medium | {
"lang": "python",
"repo": "spencercjh/rabbitMQdemo",
"path": "/src/consumer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_resource_createSaveModifyRead(tmpdir, lib):
f = tmpdir.mkdir('pyecore-tmp').join('test.xmi')
resource = XMIResource(URI(str(f)))
# we create some instances
root = lib.MyRoot()
a1 = lib.A()
suba1 = lib.SubA()
root.a_container.extend([a1, suba1])
# we add the elem... | code_fim | hard | {
"lang": "python",
"repo": "qvitech/pyecore",
"path": "/tests/xmi/test_xmi_serialization.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@Ecore.EMetaclass
class A(object):
name = Ecore.EAttribute('name', Ecore.EString)
age = Ecore.EAttribute('age', Ecore.EInt)
def test_xmi_ecore_save_load(tmpdir):
f = tmpdir.mkdir('pyecore-tmp').join('test.xmi')
resource = XMIResource(URI(str(f)))
resource.append(eClass)
resource... | code_fim | hard | {
"lang": "python",
"repo": "qvitech/pyecore",
"path": "/tests/xmi/test_xmi_serialization.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qvitech/pyecore path: /tests/xmi/test_xmi_serialization.py
import pytest
import os
import pyecore.ecore as Ecore
from pyecore.resources import *
from pyecore.resources.xmi import XMIResource
@pytest.fixture(scope='module')
def lib():
package = Ecore.EPackage('mypackage')
package.nsURI =... | code_fim | hard | {
"lang": "python",
"repo": "qvitech/pyecore",
"path": "/tests/xmi/test_xmi_serialization.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fact-project/photon_stream_production path: /photon_stream_production/ethz/scoop_jsonl2binary.py
"""
Call with 'python -m scoop --hostfile scoop_hosts.txt'
Usage: phs.scoop.jsonl.2.phs --obs_dir=DIR --out_dir=DIR
Options:
--obs_dir=DIR The input phs/obs/ directory with the '.phs.jsonl' ru... | code_fim | hard | {
"lang": "python",
"repo": "fact-project/photon_stream_production",
"path": "/photon_stream_production/ethz/scoop_jsonl2binary.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> jobs = []
for jsonl_path in glob(join(obs_dir, '*', '*', '*', '*.phs.jsonl.gz')):
p = fact.path.parse(jsonl_path)
phs_path = fact.path.tree_path(
p['night'],
p['run'],
out_dir,
'.phs.gz'
)
... | code_fim | medium | {
"lang": "python",
"repo": "fact-project/photon_stream_production",
"path": "/photon_stream_production/ethz/scoop_jsonl2binary.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.