uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
686c49960f49d549a8c668c4 | train | class | class Migration(migrations.Migration):
dependencies = [
('dataset', '0008_remove_task_name'),
]
operations = [
migrations.AddField(
model_name='task',
name='name',
field=models.TextField(default=''),
preserve_default=False,
),
]
| class Migration(migrations.Migration):
| dependencies = [
('dataset', '0008_remove_task_name'),
]
operations = [
migrations.AddField(
model_name='task',
name='name',
field=models.TextField(default=''),
preserve_default=False,
),
]
| # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
| 31 | 64 | 61 | 7 | 23 | rwblair/open_fmri | open_fmri/apps/dataset/migrations/0009_task_name.py | Python | Migration | Migration | 7 | 20 | 7 | 8 | 8ead908bc5de57b93f7903b8917e608c8c6b3a7d | bigcode/the-stack | train |
0b982a01b807b54961b66ec8 | train | function | def parse_wmm_header(line):
""" Parse the WMM COF file header. """
fields = line.split()
return {
"epoch": float(fields[0]),
"name": fields[1],
"version": fields[2],
}
| def parse_wmm_header(line):
| """ Parse the WMM COF file header. """
fields = line.split()
return {
"epoch": float(fields[0]),
"name": fields[1],
"version": fields[2],
}
| , epoch + WMM_VALIDITY_PERIOD])
nm_index = array(nm_index)
coeff = array(coeff)
coeff[:, 1] = coeff[:, 0] + coeff[:, 1]*WMM_VALIDITY_PERIOD
return nm_index, coeff, times
def parse_wmm_header(line):
| 64 | 64 | 55 | 7 | 56 | CHEN-Zhaohui/geoist | geoist/magmod/magnetic_model/parser_wmm.py | Python | parse_wmm_header | parse_wmm_header | 77 | 84 | 77 | 77 | f4b8d2f2f2b70aa464bea86b8b99d02d250c5d69 | bigcode/the-stack | train |
cc209db59fc1189d95e64df7 | train | function | def parse_wmm_coefficients(lines, data):
""" Parse the WMM COF coefficients. """
nm_index = []
coeff = []
# parse coefficients and convert them to a sparse structure
for line in lines:
fields = line.split()
if len(fields) == 1 and RE_TERMINATING_LINE.match(fields[0]):
br... | def parse_wmm_coefficients(lines, data):
| """ Parse the WMM COF coefficients. """
nm_index = []
coeff = []
# parse coefficients and convert them to a sparse structure
for line in lines:
fields = line.split()
if len(fields) == 1 and RE_TERMINATING_LINE.match(fields[0]):
break
n_idx, m_idx = int(fields[0])... | lines = file_in
data = parse_wmm_header(next(lines))
data["nm"], data["gh"], data["t"] = parse_wmm_coefficients(lines, data)
data["degree_min"] = data["nm"][:, 0].min()
data["degree_max"] = data["nm"][:, 0].max()
return data
def parse_wmm_coefficients(lines, data):
| 87 | 87 | 290 | 10 | 76 | CHEN-Zhaohui/geoist | geoist/magmod/magnetic_model/parser_wmm.py | Python | parse_wmm_coefficients | parse_wmm_coefficients | 48 | 74 | 48 | 48 | 02eb00e2a025b650f4cfedf4416351a05559eb28 | bigcode/the-stack | train |
03e3970a2a72b7941bff88ad | train | function | def parse_wmm_file(file_in):
""" Parse World Magnetic Model COF file format and return a dictionary
containing the parsed model data.
"""
lines = file_in
data = parse_wmm_header(next(lines))
data["nm"], data["gh"], data["t"] = parse_wmm_coefficients(lines, data)
data["degree_min"] = data["nm... | def parse_wmm_file(file_in):
| """ Parse World Magnetic Model COF file format and return a dictionary
containing the parsed model data.
"""
lines = file_in
data = parse_wmm_header(next(lines))
data["nm"], data["gh"], data["t"] = parse_wmm_coefficients(lines, data)
data["degree_min"] = data["nm"][:, 0].min()
data["degr... | OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#-------------------------------------------------------------------------------
import re
from numpy import array
RE_TERMINATING_LINE = re.compile(r'^9+$')
WMM_VALIDITY_PERIOD = 5.0 # years
def parse_wmm_file(file_in):
| 64 | 64 | 109 | 8 | 55 | CHEN-Zhaohui/geoist | geoist/magmod/magnetic_model/parser_wmm.py | Python | parse_wmm_file | parse_wmm_file | 36 | 45 | 36 | 36 | ff222a42486b2a7db92d245e744b186b63c858b5 | bigcode/the-stack | train |
ef550f1904e79a58755fb37e | train | class | class WalletBackupTest(NuwaCoinTestFramework):
def set_test_params(self):
self.num_nodes = 4
self.setup_clean_chain = True
# nodes 1, 2,3 are spenders, let's give them a keypool=100
self.extra_args = [["-keypool=100"], ["-keypool=100"], ["-keypool=100"], []]
def setup_network(se... | class WalletBackupTest(NuwaCoinTestFramework):
| def set_test_params(self):
self.num_nodes = 4
self.setup_clean_chain = True
# nodes 1, 2,3 are spenders, let's give them a keypool=100
self.extra_args = [["-keypool=100"], ["-keypool=100"], ["-keypool=100"], []]
def setup_network(self, split=False):
self.setup_nodes()
... | -license.php.
"""Test the wallet backup features.
Test case is:
4 nodes. 1 2 and 3 send transactions between each other,
fourth node is a miner.
1 2 3 each mine a block to start, then
Miner creates 100 blocks so 1 2 3 each have 50 mature
coins to spend.
Then 5 iterations of 1/2/3 sending coins amongst
themselves to ge... | 256 | 256 | 1,530 | 10 | 246 | martin-braun/Nuwa | test/functional/wallet_backup.py | Python | WalletBackupTest | WalletBackupTest | 39 | 201 | 39 | 39 | 4d8b4b39050aba4a29a7a7b217a20f63e49b7992 | bigcode/the-stack | train |
a50f21dcc49841cbc30e181c | train | class | class EESwap():
"""Manage Swap"""
def __init__():
"""Initialize """
pass
def add(self):
"""Swap addition with EasyEngine"""
if EEVariables.ee_ram < 512:
if EEVariables.ee_swap < 1000:
Log.info(self, "Adding SWAP file, please wait...")
... | class EESwap():
| """Manage Swap"""
def __init__():
"""Initialize """
pass
def add(self):
"""Swap addition with EasyEngine"""
if EEVariables.ee_ram < 512:
if EEVariables.ee_swap < 1000:
Log.info(self, "Adding SWAP file, please wait...")
# Install ... | """EasyEngine SWAP creation"""
from ee.core.variables import EEVariables
from ee.core.shellexec import EEShellExec
from ee.core.fileutils import EEFileUtils
from ee.core.aptget import EEAptGet
from ee.core.logging import Log
import os
class EESwap():
| 65 | 108 | 362 | 5 | 59 | zorrobyte/easyengine | ee/core/addswap.py | Python | EESwap | EESwap | 10 | 48 | 10 | 10 | 36a91e2505a6eb983694d266768b43504341de62 | bigcode/the-stack | train |
2cf2056542b4f61928a4f510 | train | function | def model_action(model, X_train, y_train, X_test,
sample_weight=None, action=None,):
"""choose fit,predict or predict_proba(only avaliable for classification)"""
if 'fit' == action:
if sample_weight is not None:
return model.fit(X_train, y_train, sample_weight=sample_we... | def model_action(model, X_train, y_train, X_test,
sample_weight=None, action=None,):
| """choose fit,predict or predict_proba(only avaliable for classification)"""
if 'fit' == action:
if sample_weight is not None:
return model.fit(X_train, y_train, sample_weight=sample_weight)
else:
return model.fit(X_train, y_train)
elif 'predict' == action:
... | '
else:
s = 'Model has no ability to show parameters (has no <get_params> or <__repr__>)\n'
s += '\n'
return s
def model_action(model, X_train, y_train, X_test,
sample_weight=None, action=None,):
| 64 | 64 | 140 | 23 | 40 | DAIM-ML/autotf | autotf/ensemble/stack.py | Python | model_action | model_action | 37 | 50 | 37 | 38 | 8339351ca63e4d171d7874d7477fa4b76fb7ee8f | bigcode/the-stack | train |
06d130f2f470446299256bd6 | train | class | class Stacking():
"""
sample_weight:Individual weights for each sample
regression : boolean, default True
If True - perform stacking for regression task,
if False - perform stacking for classification task
bagged_pred : boolean, default True
If True - bagged predictions fo... | class Stacking():
| """
sample_weight:Individual weights for each sample
regression : boolean, default True
If True - perform stacking for regression task,
if False - perform stacking for classification task
bagged_pred : boolean, default True
If True - bagged predictions for tests set(model i... | :
max_len = len(key)
sorted_keys = sorted(params_dict.keys())
for key in sorted_keys:
s += '%-*s %s\n' % (max_len, key, params_dict[key])
elif hasattr(model, '__repr__'):
s = model.__repr__()
print(s)
s += '\n'
else:
s = 'Mode... | 256 | 256 | 3,224 | 4 | 252 | DAIM-ML/autotf | autotf/ensemble/stack.py | Python | Stacking | Stacking | 52 | 355 | 52 | 52 | 3a4c3215e89c15542eb557ad9f5321d265ad703d | bigcode/the-stack | train |
ddc73befa5876989164ed90c | train | function | def model_params(model):
"""get the parameters of the model"""
s = ''
if hasattr(model, 'get_params'):
params_dict = model.get_params()
max_len = 0
for key in params_dict:
if len(key) > max_len:
max_len = len(key)
sorted_keys = sorted(para... | def model_params(model):
| """get the parameters of the model"""
s = ''
if hasattr(model, 'get_params'):
params_dict = model.get_params()
max_len = 0
for key in params_dict:
if len(key) > max_len:
max_len = len(key)
sorted_keys = sorted(params_dict.keys())
f... |
import scipy.stats as st
from sklearn.model_selection import KFold
from sklearn.model_selection import StratifiedKFold
from sklearn.metrics import mean_absolute_error
from sklearn.metrics import accuracy_score
from sklearn.metrics import log_loss
from sklearn.utils.validation import check_X_y, check_array
def m... | 64 | 64 | 169 | 5 | 58 | DAIM-ML/autotf | autotf/ensemble/stack.py | Python | model_params | model_params | 15 | 34 | 15 | 15 | e1a5117539cd1ccd3d3dbea208b8d9cebfbb6166 | bigcode/the-stack | train |
59d928158c1ab4a33375f1a4 | train | function | def no_boring_zeros(n):
try:
return int(str(n).rstrip('0'))
except ValueError:
return 0 | def no_boring_zeros(n):
| try:
return int(str(n).rstrip('0'))
except ValueError:
return 0 | def no_boring_zeros(n):
| 8 | 64 | 30 | 8 | 0 | anubhab-code/Competitive-Programming | CodeWars/8 Kyu/No zeros for heros.py | Python | no_boring_zeros | no_boring_zeros | 1 | 5 | 1 | 1 | cba4f5fdbf86a7cde8e0a4fc2ed4a246d8a5521d | bigcode/the-stack | train |
2ca6752ea0821e3b123b2624 | train | function | @deprecated(since="2.0.0",
update_to="paddle.nn.utils.weight_norm",
level=1,
reason="weight_norm in paddle.nn will be removed in future")
def weight_norm(*args):
'''
alias name of paddle.nn.utils.weight_norm
'''
return utils.weight_norm(*args)
| @deprecated(since="2.0.0",
update_to="paddle.nn.utils.weight_norm",
level=1,
reason="weight_norm in paddle.nn will be removed in future")
def weight_norm(*args):
| '''
alias name of paddle.nn.utils.weight_norm
'''
return utils.weight_norm(*args)
| .nn.utils.remove_weight_norm
'''
return utils.remove_weight_norm(*args)
@deprecated(since="2.0.0",
update_to="paddle.nn.utils.weight_norm",
level=1,
reason="weight_norm in paddle.nn will be removed in future")
def weight_norm(*args):
| 64 | 64 | 69 | 47 | 17 | SmirnovKol/Paddle | python/paddle/nn/__init__.py | Python | weight_norm | weight_norm | 182 | 190 | 182 | 186 | 87a4affdf61ef7894ca8a2b4933979e7efe4d6eb | bigcode/the-stack | train |
2b5d84c354f50271a46bde3d | train | function | @deprecated(since="2.0.0",
update_to="paddle.nn.funcitional.diag_embed",
level=1,
reason="diag_embed in paddle.nn will be removed in future")
def diag_embed(*args):
'''
alias name of paddle.nn.functional.diag_embed
'''
return functional.diag_embed(*args)
| @deprecated(since="2.0.0",
update_to="paddle.nn.funcitional.diag_embed",
level=1,
reason="diag_embed in paddle.nn will be removed in future")
def diag_embed(*args):
| '''
alias name of paddle.nn.functional.diag_embed
'''
return functional.diag_embed(*args)
| 'weight_norm' months later.
import paddle.utils.deprecated as deprecated
@deprecated(since="2.0.0",
update_to="paddle.nn.funcitional.diag_embed",
level=1,
reason="diag_embed in paddle.nn will be removed in future")
def diag_embed(*args):
| 64 | 64 | 73 | 49 | 14 | SmirnovKol/Paddle | python/paddle/nn/__init__.py | Python | diag_embed | diag_embed | 160 | 168 | 160 | 164 | d4366e7ef5b78f1d59798d895f6cdf1c5401637f | bigcode/the-stack | train |
8239cee6a8074a6f82681755 | train | function | @deprecated(since="2.0.0",
update_to="paddle.nn.utils.remove_weight_norm",
level=1,
reason="remove_weight_norm in paddle.nn will be removed in future")
def remove_weight_norm(*args):
'''
alias name of paddle.nn.utils.remove_weight_norm
'''
return utils.remove_weig... | @deprecated(since="2.0.0",
update_to="paddle.nn.utils.remove_weight_norm",
level=1,
reason="remove_weight_norm in paddle.nn will be removed in future")
def remove_weight_norm(*args):
| '''
alias name of paddle.nn.utils.remove_weight_norm
'''
return utils.remove_weight_norm(*args)
| ag_embed
'''
return functional.diag_embed(*args)
@deprecated(since="2.0.0",
update_to="paddle.nn.utils.remove_weight_norm",
level=1,
reason="remove_weight_norm in paddle.nn will be removed in future")
def remove_weight_norm(*args):
| 64 | 64 | 74 | 50 | 14 | SmirnovKol/Paddle | python/paddle/nn/__init__.py | Python | remove_weight_norm | remove_weight_norm | 171 | 179 | 171 | 175 | 3631cd8887f2faccac3a8c02905721a9a9c0b952 | bigcode/the-stack | train |
350c9515f70b7ee3914d9abe | train | class | class TestAE(unittest.TestCase):
"""
A class for testing that the AEJob class functions properly.
"""
@classmethod
def setUpClass(cls):
cls.species_energies = {lbl: i+1 for i, lbl in enumerate(SPECIES_LABELS)}
cls.ae = AE(cls.species_energies)
def test_load_refdata(self):
... | class TestAE(unittest.TestCase):
| """
A class for testing that the AEJob class functions properly.
"""
@classmethod
def setUpClass(cls):
cls.species_energies = {lbl: i+1 for i, lbl in enumerate(SPECIES_LABELS)}
cls.ae = AE(cls.species_energies)
def test_load_refdata(self):
"""
Test that the spec... | above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMP... | 207 | 207 | 691 | 7 | 199 | tza0035/RMG-Py | arkane/encorr/aeTest.py | Python | TestAE | TestAE | 43 | 114 | 43 | 43 | 78030153b4a21f8c6f929a93d1c8d31285138338 | bigcode/the-stack | train |
89e4c1115204f20eee72d0ed | train | class | class BadgeTestCase(BaseTestCase):
def setUp(self):
super(BadgeTestCase, self).setUp()
self.check = Check.objects.create(project=self.project, tags="foo bar")
sig = base64_hmac(str(self.project.badge_key), "foo", settings.SECRET_KEY)
sig = sig[:8]
self.svg_url = "/badge/%s/%... | class BadgeTestCase(BaseTestCase):
| def setUp(self):
super(BadgeTestCase, self).setUp()
self.check = Check.objects.create(project=self.project, tags="foo bar")
sig = base64_hmac(str(self.project.badge_key), "foo", settings.SECRET_KEY)
sig = sig[:8]
self.svg_url = "/badge/%s/%s/foo.svg" % (self.project.badge_ke... | from datetime import timedelta as td
from django.conf import settings
from django.core.signing import base64_hmac
from django.utils.timezone import now
from hc.api.models import Check
from hc.test import BaseTestCase
class BadgeTestCase(BaseTestCase):
| 55 | 237 | 791 | 8 | 46 | sumonst21/healthchecks | hc/api/tests/test_badge.py | Python | BadgeTestCase | BadgeTestCase | 11 | 96 | 11 | 11 | 2efc05a407b71bb3304bb47028e93522152109d0 | bigcode/the-stack | train |
ed3394a508f0b7ec0d81c812 | train | function | def create_0_10_0_run_tables():
if not has_table("runs"):
return
if not has_table("secondary_indexes"):
op.create_table(
"secondary_indexes",
db.Column("id", db.Integer, primary_key=True, autoincrement=True),
db.Column("name", db.String, unique=True),
... | def create_0_10_0_run_tables():
| if not has_table("runs"):
return
if not has_table("secondary_indexes"):
op.create_table(
"secondary_indexes",
db.Column("id", db.Integer, primary_key=True, autoincrement=True),
db.Column("name", db.String, unique=True),
db.Column("create_timestamp... | _INSTANCE
# alembic magic breaks pylint
# pylint: disable=no-member
# These intentionally use the schema at the time of the 0.10.0 release, to be used
# during the 0.10.0 new tables migration
def create_0_10_0_run_tables():
| 64 | 64 | 181 | 11 | 52 | chasleslr/dagster | python_modules/dagster/dagster/core/storage/migration/utils.py | Python | create_0_10_0_run_tables | create_0_10_0_run_tables | 57 | 77 | 57 | 57 | 93fb616043cef7cc1eafb7c6c7bf564ec3ed165f | bigcode/the-stack | train |
2ec21a2734bc0ff05095ad2a | train | function | def create_0_10_0_schedule_tables():
if not has_table("schedules") and not has_table("jobs"):
return
if not has_table("jobs"):
op.create_table(
"jobs",
db.Column("id", db.Integer, primary_key=True, autoincrement=True),
db.Column("job_origin_id", db.String(255... | def create_0_10_0_schedule_tables():
| if not has_table("schedules") and not has_table("jobs"):
return
if not has_table("jobs"):
op.create_table(
"jobs",
db.Column("id", db.Integer, primary_key=True, autoincrement=True),
db.Column("job_origin_id", db.String(255), unique=True),
db.Colum... | , unique=True),
db.Column("create_timestamp", db.DateTime, server_default=db.text("CURRENT_TIMESTAMP")),
db.Column("migration_completed", db.DateTime),
)
if not has_table("asset_keys"):
op.create_table(
"asset_keys",
db.Column("id", db.Integer, primar... | 118 | 118 | 396 | 11 | 107 | chasleslr/dagster | python_modules/dagster/dagster/core/storage/migration/utils.py | Python | create_0_10_0_schedule_tables | create_0_10_0_schedule_tables | 102 | 142 | 102 | 102 | 431b5d1ce0c2395b918280b068b0d6913b80b3b1 | bigcode/the-stack | train |
67ca389086efbd683e9a662d | train | function | def create_0_10_0_event_log_tables():
if not has_table("event_logs"):
return
if not has_table("secondary_indexes"):
op.create_table(
"secondary_indexes",
db.Column("id", db.Integer, primary_key=True, autoincrement=True),
db.Column("name", db.String, unique=Tr... | def create_0_10_0_event_log_tables():
| if not has_table("event_logs"):
return
if not has_table("secondary_indexes"):
op.create_table(
"secondary_indexes",
db.Column("id", db.Integer, primary_key=True, autoincrement=True),
db.Column("name", db.String, unique=True),
db.Column("create_tim... | ("daemon_type", db.String(255), unique=True, nullable=False),
db.Column("daemon_id", db.String(255)),
db.Column("timestamp", db.types.TIMESTAMP, nullable=False),
db.Column("body", db.Text),
)
def create_0_10_0_event_log_tables():
| 64 | 64 | 176 | 12 | 52 | chasleslr/dagster | python_modules/dagster/dagster/core/storage/migration/utils.py | Python | create_0_10_0_event_log_tables | create_0_10_0_event_log_tables | 80 | 99 | 80 | 80 | ac144031f9c65febddc6f2363daea9a0cb3f1e42 | bigcode/the-stack | train |
4a6ca287b4557080113f5636 | train | function | @contextmanager
def upgrading_instance(instance):
global _UPGRADING_INSTANCE # pylint: disable=global-statement
check.invariant(_UPGRADING_INSTANCE is None, "update already in progress")
try:
_UPGRADING_INSTANCE = instance
yield
finally:
_UPGRADING_INSTANCE = None
| @contextmanager
def upgrading_instance(instance):
| global _UPGRADING_INSTANCE # pylint: disable=global-statement
check.invariant(_UPGRADING_INSTANCE is None, "update already in progress")
try:
_UPGRADING_INSTANCE = instance
yield
finally:
_UPGRADING_INSTANCE = None
| has_column(table_name, column_name):
if not has_table(table_name):
return False
columns = [x.get("name") for x in get_inspector().get_columns(table_name)]
return column_name in columns
_UPGRADING_INSTANCE = None
@contextmanager
def upgrading_instance(instance):
| 64 | 64 | 71 | 9 | 54 | chasleslr/dagster | python_modules/dagster/dagster/core/storage/migration/utils.py | Python | upgrading_instance | upgrading_instance | 33 | 41 | 33 | 34 | c3437a549cf7f82742be1cd97b90039bcf226fe6 | bigcode/the-stack | train |
8a3119d7c6d54b3da1bcc517 | train | function | def has_column(table_name, column_name):
if not has_table(table_name):
return False
columns = [x.get("name") for x in get_inspector().get_columns(table_name)]
return column_name in columns
| def has_column(table_name, column_name):
| if not has_table(table_name):
return False
columns = [x.get("name") for x in get_inspector().get_columns(table_name)]
return column_name in columns
| pylint: disable=no-member
bind = op.get_context().bind
return reflection.Inspector.from_engine(bind)
def get_table_names():
return get_inspector().get_table_names()
def has_table(table_name):
return table_name in get_table_names()
def has_column(table_name, column_name):
| 64 | 64 | 49 | 9 | 55 | chasleslr/dagster | python_modules/dagster/dagster/core/storage/migration/utils.py | Python | has_column | has_column | 23 | 27 | 23 | 23 | aee736d2711a0952ca57e3c5dee0baf567b76208 | bigcode/the-stack | train |
94673b82955b0277d4a41d8f | train | function | def get_inspector():
# pylint: disable=no-member
bind = op.get_context().bind
return reflection.Inspector.from_engine(bind)
| def get_inspector():
# pylint: disable=no-member
| bind = op.get_context().bind
return reflection.Inspector.from_engine(bind)
| from contextlib import contextmanager
import sqlalchemy as db
from alembic import op
from dagster import check
from sqlalchemy.engine import reflection
def get_inspector():
# pylint: disable=no-member
| 44 | 64 | 32 | 13 | 30 | chasleslr/dagster | python_modules/dagster/dagster/core/storage/migration/utils.py | Python | get_inspector | get_inspector | 9 | 12 | 9 | 10 | 72f9095393f86dc6af02825c1a510577df00d2f6 | bigcode/the-stack | train |
33b29e6b6943573a7bf24f1d | train | function | def get_currently_upgrading_instance():
global _UPGRADING_INSTANCE # pylint: disable=global-statement
check.invariant(_UPGRADING_INSTANCE is not None, "currently upgrading instance not set")
return _UPGRADING_INSTANCE
| def get_currently_upgrading_instance():
| global _UPGRADING_INSTANCE # pylint: disable=global-statement
check.invariant(_UPGRADING_INSTANCE is not None, "currently upgrading instance not set")
return _UPGRADING_INSTANCE
| _INSTANCE # pylint: disable=global-statement
check.invariant(_UPGRADING_INSTANCE is None, "update already in progress")
try:
_UPGRADING_INSTANCE = instance
yield
finally:
_UPGRADING_INSTANCE = None
def get_currently_upgrading_instance():
| 64 | 64 | 53 | 8 | 55 | chasleslr/dagster | python_modules/dagster/dagster/core/storage/migration/utils.py | Python | get_currently_upgrading_instance | get_currently_upgrading_instance | 44 | 47 | 44 | 44 | 958bf8936095d6ef63cee4ae58cff3591e897dee | bigcode/the-stack | train |
db8904be8ad03e63901b922c | train | function | def has_table(table_name):
return table_name in get_table_names()
| def has_table(table_name):
| return table_name in get_table_names()
| dagster import check
from sqlalchemy.engine import reflection
def get_inspector():
# pylint: disable=no-member
bind = op.get_context().bind
return reflection.Inspector.from_engine(bind)
def get_table_names():
return get_inspector().get_table_names()
def has_table(table_name):
| 64 | 64 | 15 | 6 | 58 | chasleslr/dagster | python_modules/dagster/dagster/core/storage/migration/utils.py | Python | has_table | has_table | 19 | 20 | 19 | 19 | 4ee3832439787c10b5db57b21052aad67f21df5c | bigcode/the-stack | train |
99c5bc77e900fd768e5997dc | train | function | def get_table_names():
return get_inspector().get_table_names()
| def get_table_names():
| return get_inspector().get_table_names()
| contextmanager
import sqlalchemy as db
from alembic import op
from dagster import check
from sqlalchemy.engine import reflection
def get_inspector():
# pylint: disable=no-member
bind = op.get_context().bind
return reflection.Inspector.from_engine(bind)
def get_table_names():
| 64 | 64 | 15 | 5 | 59 | chasleslr/dagster | python_modules/dagster/dagster/core/storage/migration/utils.py | Python | get_table_names | get_table_names | 15 | 16 | 15 | 15 | c0f02f2fe8dd8d969b3894d620f80b3cbc109f39 | bigcode/the-stack | train |
b4328d62da1c32a964210f5f | train | function | @pytest.mark.parametrize(('model_class', 'mode'), list(itertools.product(test_models_2D, modes)))
def test_pixel_sum_2D(model_class, mode):
"""
Test if the sum of all pixels corresponds nearly to the integral.
"""
if model_class == Box2D and mode == "center":
pytest.skip("Non integrating mode. S... | @pytest.mark.parametrize(('model_class', 'mode'), list(itertools.product(test_models_2D, modes)))
def test_pixel_sum_2D(model_class, mode):
| """
Test if the sum of all pixels corresponds nearly to the integral.
"""
if model_class == Box2D and mode == "center":
pytest.skip("Non integrating mode. Skip integral test.")
parameters = models_2D[model_class]
model = create_model(model_class, parameters)
values = discretize_mod... | discretize_model(model, (-100, 101), mode=mode)
assert_allclose(values, disc_values, atol=0.001)
@pytest.mark.parametrize(('model_class', 'mode'), list(itertools.product(test_models_2D, modes)))
def test_pixel_sum_2D(model_class, mode):
| 64 | 64 | 159 | 34 | 30 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_pixel_sum_2D | test_pixel_sum_2D | 57 | 70 | 57 | 58 | f4c4644a53264c40112ddd1e5aa92faf12325268 | bigcode/the-stack | train |
ae59150ad28ad130ed7e271a | train | function | @pytest.mark.parametrize('mode', modes)
def test_gaussian_eval_1D(mode):
"""
Discretize Gaussian with different modes and check
if result is at least similar to Gaussian1D.eval().
"""
model = Gaussian1D(1, 0, 20)
x = np.arange(-100, 101)
values = model(x)
disc_values = discretize_model(m... | @pytest.mark.parametrize('mode', modes)
def test_gaussian_eval_1D(mode):
| """
Discretize Gaussian with different modes and check
if result is at least similar to Gaussian1D.eval().
"""
model = Gaussian1D(1, 0, 20)
x = np.arange(-100, 101)
values = model(x)
disc_values = discretize_model(model, (-100, 101), mode=mode)
assert_allclose(values, disc_values, at... | = discretize_model(model, models_1D[model_class]['x_lim'], mode=mode)
assert_allclose(values.sum(), models_1D[model_class]['integral'], atol=0.0001)
@pytest.mark.parametrize('mode', modes)
def test_gaussian_eval_1D(mode):
| 64 | 64 | 112 | 18 | 46 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_gaussian_eval_1D | test_gaussian_eval_1D | 44 | 54 | 44 | 45 | f3db5d434b5d3b39c4c3564e9cf3c803427d584a | bigcode/the-stack | train |
e15a530cd2d4579f10ab89e5 | train | function | def test_type_exception():
"""
Test type exception.
"""
with pytest.raises(TypeError) as exc:
discretize_model(float(0), (-10, 11))
assert exc.value.args[0] == 'Model must be callable.'
| def test_type_exception():
| """
Test type exception.
"""
with pytest.raises(TypeError) as exc:
discretize_model(float(0), (-10, 11))
assert exc.value.args[0] == 'Model must be callable.'
| actual = discretize_model(f, (-5, 6), (-5, 6))
y, x = (np.indices((11, 11)) - 5)
desired = x ** 2 + y ** 2
assert_allclose(actual, desired)
def test_type_exception():
| 64 | 64 | 53 | 5 | 59 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_type_exception | test_type_exception | 127 | 133 | 127 | 127 | fe095ecdf07e21d191822e1e060d63d094f31ed7 | bigcode/the-stack | train |
e508842572d372263ffd4042 | train | function | def test_discretize_callable_2d():
"""
Test discretize when a 2d function is passed.
"""
def f(x, y):
return x ** 2 + y ** 2
actual = discretize_model(f, (-5, 6), (-5, 6))
y, x = (np.indices((11, 11)) - 5)
desired = x ** 2 + y ** 2
assert_allclose(actual, desired)
| def test_discretize_callable_2d():
| """
Test discretize when a 2d function is passed.
"""
def f(x, y):
return x ** 2 + y ** 2
actual = discretize_model(f, (-5, 6), (-5, 6))
y, x = (np.indices((11, 11)) - 5)
desired = x ** 2 + y ** 2
assert_allclose(actual, desired)
| a 1d function is passed.
"""
def f(x):
return x ** 2
y = discretize_model(f, (-5, 6))
assert_allclose(y, np.arange(-5, 6) ** 2)
def test_discretize_callable_2d():
| 64 | 64 | 105 | 10 | 54 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_discretize_callable_2d | test_discretize_callable_2d | 116 | 125 | 116 | 116 | a4b75dace592e129b718b3ae62ed9bd5f43dd184 | bigcode/the-stack | train |
f0424372ed861d6d72461616 | train | function | @pytest.mark.skipif('not HAS_SCIPY')
def test_subpixel_gauss_2D():
"""
Test subpixel accuracy of the oversample mode with gaussian 2D model.
"""
gauss_2D = Gaussian2D(1, 0, 0, 0.1, 0.1)
values = discretize_model(gauss_2D, (-1, 2), (-1, 2), mode='integrate', factor=100)
assert_allclose(values.sum... | @pytest.mark.skipif('not HAS_SCIPY')
def test_subpixel_gauss_2D():
| """
Test subpixel accuracy of the oversample mode with gaussian 2D model.
"""
gauss_2D = Gaussian2D(1, 0, 0, 0.1, 0.1)
values = discretize_model(gauss_2D, (-1, 2), (-1, 2), mode='integrate', factor=100)
assert_allclose(values.sum(), 2 * np.pi * 0.01, atol=0.00001)
| (-1, 2), mode='integrate', factor=100)
assert_allclose(values.sum(), np.sqrt(2 * np.pi) * 0.1, atol=0.00001)
@pytest.mark.skipif('not HAS_SCIPY')
def test_subpixel_gauss_2D():
| 64 | 64 | 130 | 21 | 43 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_subpixel_gauss_2D | test_subpixel_gauss_2D | 98 | 105 | 98 | 99 | 54e00c52a7e2cbe84af016df212ece80eb7a1e3d | bigcode/the-stack | train |
a59df2d965435e81a3f6d780 | train | function | def test_dim_exception_2d():
"""
Test dimension exception 2d.
"""
def f(x, y):
return x ** 2 + y ** 2
with pytest.raises(ValueError) as exc:
discretize_model(f, (-10, 11))
assert exc.value.args[0] == "y range not specified, but model is 2-d"
| def test_dim_exception_2d():
| """
Test dimension exception 2d.
"""
def f(x, y):
return x ** 2 + y ** 2
with pytest.raises(ValueError) as exc:
discretize_model(f, (-10, 11))
assert exc.value.args[0] == "y range not specified, but model is 2-d"
| return x ** 2
with pytest.raises(ValueError) as exc:
discretize_model(f, (-10, 11), (-10, 11))
assert exc.value.args[0] == "y range specified, but model is only 1-d."
def test_dim_exception_2d():
| 64 | 64 | 83 | 8 | 56 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_dim_exception_2d | test_dim_exception_2d | 145 | 153 | 145 | 145 | 6ba5afa6085946ba702255ccf58852a422da21aa | bigcode/the-stack | train |
6671ead18fce428086775563 | train | function | @pytest.mark.parametrize('mode', modes)
def test_gaussian_eval_2D(mode):
"""
Discretize Gaussian with different modes and check
if result is at least similar to Gaussian1D.eval()
"""
model = Gaussian2D(1, 0, 0, 20, 20)
x = np.arange(-100, 101)
y = np.arange(-100, 101)
x, y = np.meshgrid(... | @pytest.mark.parametrize('mode', modes)
def test_gaussian_eval_2D(mode):
| """
Discretize Gaussian with different modes and check
if result is at least similar to Gaussian1D.eval()
"""
model = Gaussian2D(1, 0, 0, 20, 20)
x = np.arange(-100, 101)
y = np.arange(-100, 101)
x, y = np.meshgrid(x, y)
values = model(x, y)
disc_values = discretize_model(model, ... | _class]['x_lim'],
models_2D[model_class]['y_lim'], mode=mode)
assert_allclose(values.sum(), models_2D[model_class]['integral'], atol=0.0001)
@pytest.mark.parametrize('mode', modes)
def test_gaussian_eval_2D(mode):
| 64 | 64 | 149 | 18 | 46 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_gaussian_eval_2D | test_gaussian_eval_2D | 73 | 85 | 73 | 74 | b1ebb4790250dee6dc33945aeca7c2af1d25b0a1 | bigcode/the-stack | train |
61e19187fa61c4888dcbb130 | train | function | @pytest.mark.skipif('not HAS_SCIPY')
def test_subpixel_gauss_1D():
"""
Test subpixel accuracy of the oversample mode with gaussian 1D model.
"""
gauss_1D = Gaussian1D(1, 0, 0.1)
values = discretize_model(gauss_1D, (-1, 2), mode='integrate', factor=100)
assert_allclose(values.sum(), np.sqrt(2 * n... | @pytest.mark.skipif('not HAS_SCIPY')
def test_subpixel_gauss_1D():
| """
Test subpixel accuracy of the oversample mode with gaussian 1D model.
"""
gauss_1D = Gaussian1D(1, 0, 0.1)
values = discretize_model(gauss_1D, (-1, 2), mode='integrate', factor=100)
assert_allclose(values.sum(), np.sqrt(2 * np.pi) * 0.1, atol=0.00001)
| , y)
disc_values = discretize_model(model, (-100, 101), (-100, 101), mode=mode)
assert_allclose(values, disc_values, atol=0.001)
@pytest.mark.skipif('not HAS_SCIPY')
def test_subpixel_gauss_1D():
| 64 | 64 | 119 | 21 | 43 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_subpixel_gauss_1D | test_subpixel_gauss_1D | 88 | 95 | 88 | 89 | 0d7718e929540fab7f9b609d55e38c4b9ba9100b | bigcode/the-stack | train |
bcb69ec2486c6f31ed844a23 | train | function | def test_discretize_callable_1d():
"""
Test discretize when a 1d function is passed.
"""
def f(x):
return x ** 2
y = discretize_model(f, (-5, 6))
assert_allclose(y, np.arange(-5, 6) ** 2)
| def test_discretize_callable_1d():
| """
Test discretize when a 1d function is passed.
"""
def f(x):
return x ** 2
y = discretize_model(f, (-5, 6))
assert_allclose(y, np.arange(-5, 6) ** 2)
| _model(gauss_2D, (-1, 2), (-1, 2), mode='integrate', factor=100)
assert_allclose(values.sum(), 2 * np.pi * 0.01, atol=0.00001)
def test_discretize_callable_1d():
| 64 | 64 | 71 | 10 | 54 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_discretize_callable_1d | test_discretize_callable_1d | 107 | 114 | 107 | 107 | 5e8e497fc69a747ec517dca7dd430d12c568fb78 | bigcode/the-stack | train |
904b08f2c5edde873e487f65 | train | function | def test_dim_exception_1d():
"""
Test dimension exception 1d.
"""
def f(x):
return x ** 2
with pytest.raises(ValueError) as exc:
discretize_model(f, (-10, 11), (-10, 11))
assert exc.value.args[0] == "y range specified, but model is only 1-d."
| def test_dim_exception_1d():
| """
Test dimension exception 1d.
"""
def f(x):
return x ** 2
with pytest.raises(ValueError) as exc:
discretize_model(f, (-10, 11), (-10, 11))
assert exc.value.args[0] == "y range specified, but model is only 1-d."
| , desired)
def test_type_exception():
"""
Test type exception.
"""
with pytest.raises(TypeError) as exc:
discretize_model(float(0), (-10, 11))
assert exc.value.args[0] == 'Model must be callable.'
def test_dim_exception_1d():
| 64 | 64 | 82 | 8 | 56 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_dim_exception_1d | test_dim_exception_1d | 135 | 143 | 135 | 135 | d74c66901e8901b0a3bc6eba3bde1714e653e6b8 | bigcode/the-stack | train |
829c0859684d6261fa0aadc0 | train | function | @pytest.mark.parametrize(('model_class', 'mode'), list(itertools.product(test_models_1D, modes)))
def test_pixel_sum_1D(model_class, mode):
"""
Test if the sum of all pixels corresponds nearly to the integral.
"""
if model_class == Box1D and mode == "center":
pytest.skip("Non integrating mode. S... | @pytest.mark.parametrize(('model_class', 'mode'), list(itertools.product(test_models_1D, modes)))
def test_pixel_sum_1D(model_class, mode):
| """
Test if the sum of all pixels corresponds nearly to the integral.
"""
if model_class == Box1D and mode == "center":
pytest.skip("Non integrating mode. Skip integral test.")
parameters = models_1D[model_class]
model = create_model(model_class, parameters)
values = discretize_mode... | , Box1D, MexicanHat1D]
test_models_2D = [Gaussian2D, Box2D, MexicanHat2D]
@pytest.mark.parametrize(('model_class', 'mode'), list(itertools.product(test_models_1D, modes)))
def test_pixel_sum_1D(model_class, mode):
| 64 | 64 | 147 | 34 | 30 | sahirsharma/Martian | NASA SPACEAPPS CHALLENGE/Solution/Software part/Astronomical Data and Python Libraries/Astropy/astropy-1.1.2/astropy/convolution/tests/test_discretize.py | Python | test_pixel_sum_1D | test_pixel_sum_1D | 30 | 41 | 30 | 31 | 8ba183847273b43e4f93d8115b65482fe8d089da | bigcode/the-stack | train |
d3595bdc58c52c1021d56033 | train | function | def rain_update(frame):
global R, scatter
R["color"][:, 3] = np.maximum(0, R["color"][:, 3] - 1 / len(R))
R["size"] += 1 / len(R)
i = frame % len(R)
R["position"][i] = np.random.uniform(0, 1, 2)
R["size"][i] = 0
R["color"][i, 3] = 1
scatter.set_edgecolors(R["color"])
scatter.set_s... | def rain_update(frame):
| global R, scatter
R["color"][:, 3] = np.maximum(0, R["color"][:, 3] - 1 / len(R))
R["size"] += 1 / len(R)
i = frame % len(R)
R["position"][i] = np.random.uniform(0, 1, 2)
R["size"][i] = 0
R["color"][i, 3] = 1
scatter.set_edgecolors(R["color"])
scatter.set_sizes(1000 * R["size"].ra... | # ----------------------------------------------------------------------------
# Title: Scientific Visualisation - Python & Matplotlib
# Author: Nicolas P. Rougier
# License: BSD
# ----------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import m... | 57 | 64 | 164 | 5 | 51 | geo7/scientific-visualization-book | code/animation/rain.py | Python | rain_update | rain_update | 11 | 28 | 11 | 11 | ea510bece512a26206b690b5b4ea255ffd78a6b0 | bigcode/the-stack | train |
1c82a28faf7a30185efd19e7 | train | class | class TagAndPushPlugin(PostBuildPlugin):
"""
Use tags from workflow.tag_conf and push the images to workflow.push_conf
"""
key = "tag_and_push"
is_allowed_to_fail = False
args_from_user_params = map_to_user_params("koji_target")
def __init__(self, workflow, koji_target=None):
"""
... | class TagAndPushPlugin(PostBuildPlugin):
| """
Use tags from workflow.tag_conf and push the images to workflow.push_conf
"""
key = "tag_and_push"
is_allowed_to_fail = False
args_from_user_params = map_to_user_params("koji_target")
def __init__(self, workflow, koji_target=None):
"""
constructor
:param workf... | """
Copyright (c) 2015 Red Hat, Inc
All rights reserved.
This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.
"""
import subprocess
import time
import platform
import random
from atomic_reactor.constants import (IMAGE_TYPE_DOCKER_ARCHIVE, IMAGE_TYPE_OCI,... | 249 | 256 | 1,707 | 9 | 240 | tveverka-RH/atomic-reactor | atomic_reactor/plugins/post_tag_and_push.py | Python | TagAndPushPlugin | TagAndPushPlugin | 35 | 238 | 35 | 35 | 2bcb730d4ffa10ae10a0a6dd21be1baea3738fc5 | bigcode/the-stack | train |
86862c4d93a9846f4929cff9 | train | class | class ExceedsImageSizeError(RuntimeError):
"""Error of exceeding image size"""
| class ExceedsImageSizeError(RuntimeError):
| """Error of exceeding image size"""
| fg,
get_all_manifests, map_to_user_params)
from atomic_reactor.utils import retries
from osbs.utils import ImageName
import osbs.utils
from osbs.constants import RAND_DIGITS
__all__ = ('TagAndPushPlugin', )
class ExceedsImageSizeError(RuntimeError):
| 64 | 64 | 17 | 9 | 55 | tveverka-RH/atomic-reactor | atomic_reactor/plugins/post_tag_and_push.py | Python | ExceedsImageSizeError | ExceedsImageSizeError | 31 | 32 | 31 | 31 | ec82b077c76fa99c7a205d41e8a407b40fa4a66a | bigcode/the-stack | train |
835bf34b475841280e4f6bea | train | class | class SocketStreamCapturer(object):
"""Class for logging socket data to a PCAP file."""
def __init__(self, capture_handlers, address, conn_type):
"""
Args:
capture_handlers:
A list of handler configuration dictionaries that contains the
following valu... | class SocketStreamCapturer(object):
| """Class for logging socket data to a PCAP file."""
def __init__(self, capture_handlers, address, conn_type):
"""
Args:
capture_handlers:
A list of handler configuration dictionaries that contains the
following values
name
... | access to foreign persons.
"""
AIT Binary Stream Capturer
The ait.bsc module handles logging of network data to PCAP files
along with the server definition for RESTful manipulation of running
loggers.
"""
import calendar
import json
import os
import socket
import time
from bottle import request, Bottle
import geve... | 256 | 256 | 2,665 | 7 | 248 | davidryanshay/AIT-Core | ait/core/bsc.py | Python | SocketStreamCapturer | SocketStreamCapturer | 61 | 458 | 61 | 61 | 1489b0caacb36dcc1bac8ddbf424740d66a1a12b | bigcode/the-stack | train |
0197a032ac1f3e2e83a07258 | train | function | def identity_transform(data):
"""Example data transformation function for a capture handler."""
return data
| def identity_transform(data):
| """Example data transformation function for a capture handler."""
return data
| object of running handler stats
Returns a JSON object containing data read statistics for all
running handlers. Structure of the JOSN objects is controlled by
:func:`StreamCaptureManager.dump_all_handler_stats`.
"""
return json.dumps(self._logger_manager.get_handler_stats())
de... | 64 | 64 | 20 | 5 | 59 | davidryanshay/AIT-Core | ait/core/bsc.py | Python | identity_transform | identity_transform | 821 | 823 | 821 | 821 | f476036dbe47a237727e348137cf0ccd0b00b94c | bigcode/the-stack | train |
fe2b267dbe7d94a61e8e3737 | train | class | class StreamCaptureManagerServer(Bottle):
"""Webserver for management of Binary Stream Capturers."""
def __init__(self, logger_manager, host, port):
"""
Args:
logger_manager:
Instance of :class:`StreamCaptureManager` which the
server will use to manag... | class StreamCaptureManagerServer(Bottle):
| """Webserver for management of Binary Stream Capturers."""
def __init__(self, logger_manager, host, port):
"""
Args:
logger_manager:
Instance of :class:`StreamCaptureManager` which the
server will use to manage logger instances.
host:
... | def get_capture_handler_config_by_name(self, name):
"""Return data for handlers of a given name.
Args:
name:
Name of the capture handler(s) to return config data for.
Returns:
Dictionary dump from the named capture handler as given by
the... | 256 | 256 | 973 | 8 | 248 | davidryanshay/AIT-Core | ait/core/bsc.py | Python | StreamCaptureManagerServer | StreamCaptureManagerServer | 699 | 818 | 699 | 699 | 7dcd88e996226bd1c63362f12b6d7726772e9411 | bigcode/the-stack | train |
b76fdc025b388bd7a84b4bb6 | train | class | class StreamCaptureManager(object):
"""Manage handlers for binary data capture and logging"""
def __init__(self, mngr_conf, lgr_conf):
"""
Args:
mngr_conf:
Configuration dictionary for the manager. At
the minimum this should contain the following:
... | class StreamCaptureManager(object):
| """Manage handlers for binary data capture and logging"""
def __init__(self, mngr_conf, lgr_conf):
"""
Args:
mngr_conf:
Configuration dictionary for the manager. At
the minimum this should contain the following:
.. code-block:: none
... | The handler configuration dictionary for which a log file
path should be generated.
"""
if "file_name_pattern" not in handler:
filename = "%Y-%m-%d-%H-%M-%S-{name}.pcap"
else:
filename = handler["file_name_pattern"]
log_file = handler["log_dir"]
... | 256 | 256 | 1,704 | 6 | 250 | davidryanshay/AIT-Core | ait/core/bsc.py | Python | StreamCaptureManager | StreamCaptureManager | 461 | 696 | 461 | 461 | d85f00de8ca45792adc68d0620bc609d11bebcd5 | bigcode/the-stack | train |
fa656592dd74f12fa600fc78 | train | function | def main():
file = open('input1.txt', 'r')
tab = file.readlines()
counter = 0
for i in range(len(tab)-1):
if int(tab[i+1]) > int(tab[i]):
counter += 1
print(counter)
| def main():
| file = open('input1.txt', 'r')
tab = file.readlines()
counter = 0
for i in range(len(tab)-1):
if int(tab[i+1]) > int(tab[i]):
counter += 1
print(counter)
| def main():
| 3 | 64 | 55 | 3 | 0 | Saff-Buraq-Dev/advent-of-code-2021 | day1/day1-1.py | Python | main | main | 1 | 9 | 1 | 1 | 2ae74d96bdf4a3be9c41dca8d0e99601d5d84e0f | bigcode/the-stack | train |
c1b92643afb7940192623435 | train | function | def group(links, start):
todo = set(links[start])
visited = set([start])
while todo:
for elem in todo.copy():
todo.remove(elem)
visited.add(elem)
todo |= set(links[elem]) - visited
return visited
| def group(links, start):
| todo = set(links[start])
visited = set([start])
while todo:
for elem in todo.copy():
todo.remove(elem)
visited.add(elem)
todo |= set(links[elem]) - visited
return visited
| def group(links, start):
| 7 | 64 | 59 | 7 | 0 | bovarysme/advent | 2017/day12.py | Python | group | group | 1 | 12 | 1 | 1 | e669df38b77f0c055b04313607372f0edcae17be | bigcode/the-stack | train |
f8d861ae3182b8ecd8328693 | train | function | def part_two(links):
total = 0
i = 0
visited = set()
while i < len(links):
visited |= group(links, i)
total += 1
while i in visited:
i += 1
return total
| def part_two(links):
| total = 0
i = 0
visited = set()
while i < len(links):
visited |= group(links, i)
total += 1
while i in visited:
i += 1
return total
| todo:
for elem in todo.copy():
todo.remove(elem)
visited.add(elem)
todo |= set(links[elem]) - visited
return visited
def part_one(links):
group0 = group(links, 0)
return len(group0)
def part_two(links):
| 64 | 64 | 62 | 6 | 58 | bovarysme/advent | 2017/day12.py | Python | part_two | part_two | 20 | 33 | 20 | 20 | a1f314af3cd5e20fca3a12b590ae1a74ca699431 | bigcode/the-stack | train |
1b2a13a32557ec12a1176cf5 | train | function | def part_one(links):
group0 = group(links, 0)
return len(group0)
| def part_one(links):
| group0 = group(links, 0)
return len(group0)
| group(links, start):
todo = set(links[start])
visited = set([start])
while todo:
for elem in todo.copy():
todo.remove(elem)
visited.add(elem)
todo |= set(links[elem]) - visited
return visited
def part_one(links):
| 64 | 64 | 23 | 6 | 57 | bovarysme/advent | 2017/day12.py | Python | part_one | part_one | 15 | 17 | 15 | 15 | 89f4ea49479376e78565ee5fbf1527344c816566 | bigcode/the-stack | train |
80d172a5343e74cb7a15fb3d | train | function | def smartify(nlp, sent):
#if type(sent) is not unicode:
# sent = unicode(sent)
from whitelist import whitelist
words = [Word.new(token) for token in nlp(sent)]
results = []
for word in words:
#convert word if it is a specific class
#only smartify noun/verb/ad[j|v]
... | def smartify(nlp, sent):
#if type(sent) is not unicode:
# sent = unicode(sent)
| from whitelist import whitelist
words = [Word.new(token) for token in nlp(sent)]
results = []
for word in words:
#convert word if it is a specific class
#only smartify noun/verb/ad[j|v]
base = word.base().lower()
invalid_pos = word.Pos_word is None or "'" in base
... | self.pos[2:3]
desc = tag_to_desc.get(hint) or "inf" #base
self.word = pattern.conjugate(new_base, desc)
def smartify(nlp, sent):
#if type(sent) is not unicode:
# sent = unicode(sent)
| 64 | 64 | 179 | 26 | 38 | stensonowen/Smartifier | smartifier.py | Python | smartify | smartify | 188 | 210 | 188 | 191 | 24744a6a73ce8b5a7480996c4936bedf2b7b44ed | bigcode/the-stack | train |
4e7bf402addf514a5a7dd97d | train | function | def longest(lis):
#lis a list of tuples of (word, len(word))
#returns whichever tuple has the longest second part
best = ("",-1)
for entry in lis:
if entry[1] > best[1]:
best = entry
return best
| def longest(lis):
#lis a list of tuples of (word, len(word))
#returns whichever tuple has the longest second part
| best = ("",-1)
for entry in lis:
if entry[1] > best[1]:
best = entry
return best
| ")
except KeyError:
print("Failed to find part of speech " + str(word) + " (" + str(pos) + ")")
return synonyms
def longest(lis):
#lis a list of tuples of (word, len(word))
#returns whichever tuple has the longest second part
| 64 | 64 | 63 | 30 | 33 | stensonowen/Smartifier | smartifier.py | Python | longest | longest | 36 | 43 | 36 | 38 | 49ff5a17e24e00a88d84a1262b1cffbf670b2ed2 | bigcode/the-stack | train |
a2957f1bc44c6adfff3fa90a | train | class | class Word():
Wn_tag = Pos_word = None
#ProperNoun is kind of assymetric;
# What's the best way to handle it?
@staticmethod
def new_(token):
tag_decode = {
"JJ": Adjective,
"RB": Adverb,
"NNP:": ProperNoun,
"NN": Noun,
"VB":... | class Word():
| Wn_tag = Pos_word = None
#ProperNoun is kind of assymetric;
# What's the best way to handle it?
@staticmethod
def new_(token):
tag_decode = {
"JJ": Adjective,
"RB": Adverb,
"NNP:": ProperNoun,
"NN": Noun,
"VB": Verb,
... | it
#TODO: should maybe hyphenate multi-word synonyms so results will make more sense?
groups = [
[(syn,len(word)) for word in syn.split()]
for syn in syns]
bests = [longest(entry) for entry in groups]
return longest(bests)[0]
def parse_(nlp, sent):
#TODO: delete
#if ty... | 117 | 118 | 395 | 3 | 114 | stensonowen/Smartifier | smartifier.py | Python | Word | Word | 66 | 123 | 66 | 66 | 8b6b72d69450fa484501856ee782c6a482e7448b | bigcode/the-stack | train |
8487cb3eab185cd5b44be745 | train | class | class Adjective(Degree):
Wn_tag = wordnet.ADJ
Pos_word = "adjective"
| class Adjective(Degree):
| Wn_tag = wordnet.ADJ
Pos_word = "adjective"
| , new_base):
if self.pos[-1] == "S":
self.word = pattern.superlative(new_base)
elif self.pos[-1] == "R":
self.word = pattern.comparative(new_base)
else:
self.word = new_base
class Adjective(Degree):
| 64 | 64 | 24 | 6 | 57 | stensonowen/Smartifier | smartifier.py | Python | Adjective | Adjective | 141 | 143 | 141 | 141 | 6b9d4d52d6b97c847e1b36f0887aa80cb0f2106c | bigcode/the-stack | train |
351a29f391c92bbf8f118a60 | train | function | def select_synonym(syns):
#return the synonym or phrase which contains the longest word
#If you want to change how the 'best' synonym is selected,
# this is the place to do it
#TODO: should maybe hyphenate multi-word synonyms so results will make more sense?
groups = [
[(syn,len(word)) f... | def select_synonym(syns):
#return the synonym or phrase which contains the longest word
#If you want to change how the 'best' synonym is selected,
# this is the place to do it
#TODO: should maybe hyphenate multi-word synonyms so results will make more sense?
| groups = [
[(syn,len(word)) for word in syn.split()]
for syn in syns]
bests = [longest(entry) for entry in groups]
return longest(bests)[0]
| def select_synonym(syns):
#return the synonym or phrase which contains the longest word
#If you want to change how the 'best' synonym is selected,
# this is the place to do it
#TODO: should maybe hyphenate multi-word synonyms so results will make more sense?
| 66 | 64 | 111 | 66 | 0 | stensonowen/Smartifier | smartifier.py | Python | select_synonym | select_synonym | 46 | 55 | 46 | 50 | c2bd205d2b22152f09e3bdaa9f81a14a5dbfeea6 | bigcode/the-stack | train |
7cfae26dd0038b520445548e | train | class | class Degree(Word):
#adj or adv
def re_base(self, new_base):
if self.pos[-1] == "S":
self.word = pattern.superlative(new_base)
elif self.pos[-1] == "R":
self.word = pattern.comparative(new_base)
else:
self.word = new_base
| class Degree(Word):
#adj or adv
| def re_base(self, new_base):
if self.pos[-1] == "S":
self.word = pattern.superlative(new_base)
elif self.pos[-1] == "R":
self.word = pattern.comparative(new_base)
else:
self.word = new_base
| , new_base):
self.word = new_base
def __str__(self):
return self.word + " "*self.space
#subclasses categorized/defined by what attribute they have
#adjectives and adverbs both have 'degree'
class Degree(Word):
#adj or adv
| 64 | 64 | 74 | 11 | 53 | stensonowen/Smartifier | smartifier.py | Python | Degree | Degree | 130 | 138 | 130 | 131 | 69880e681b742c3ec7549f8e2201a6eabaf20524 | bigcode/the-stack | train |
0f5b374f4954da09ea5c48c7 | train | class | class ProperNoun(Noun):
#Just exists for organization's sake
#Do not try to parse this; it's probably a waste of time
Wn_tag = Pos_word = None
| class ProperNoun(Noun):
#Just exists for organization's sake
#Do not try to parse this; it's probably a waste of time
| Wn_tag = Pos_word = None
| _base)
elif self.pos.startswith("NNP"):
#proper noun
self.word = self.word
else:
self.word = new_base
class ProperNoun(Noun):
#Just exists for organization's sake
#Do not try to parse this; it's probably a waste of time
| 64 | 64 | 41 | 31 | 32 | stensonowen/Smartifier | smartifier.py | Python | ProperNoun | ProperNoun | 165 | 168 | 165 | 167 | 63bbdbdd7431733a12ec3fa6620c9c4213d2382e | bigcode/the-stack | train |
d20a5fd935c5837eb2904fd9 | train | function | def get_synonyms(word, pos):
#fetch synonyms from bighugelabs.com
#only interested in synonyms; ignore other results
try:
synonyms = [word]
url = "http://words.bighugelabs.com/api/2/{}/{}/json".format(
"11f898808fffe257228d17890b1101f1",
word)
json = r... | def get_synonyms(word, pos):
#fetch synonyms from bighugelabs.com
#only interested in synonyms; ignore other results
| try:
synonyms = [word]
url = "http://words.bighugelabs.com/api/2/{}/{}/json".format(
"11f898808fffe257228d17890b1101f1",
word)
json = requests.get(url).json()
#get synonyms of the correct POS only
synonyms += json[pos]['syn']
except ValueEr... | for "things" is "belongings"
# which is assumed to also be singular
# so pattern tries to pluralize it by adding an s
def get_synonyms(word, pos):
#fetch synonyms from bighugelabs.com
#only interested in synonyms; ignore other results
| 64 | 64 | 171 | 30 | 33 | stensonowen/Smartifier | smartifier.py | Python | get_synonyms | get_synonyms | 18 | 33 | 18 | 20 | 6a8f3f38872e01743fe999b4722587cba7bae200 | bigcode/the-stack | train |
4122d98f3fc487f2aaf57bc4 | train | class | class Adverb(Degree):
Wn_tag = wordnet.ADV
Pos_word = "adverb"
| class Adverb(Degree):
| Wn_tag = wordnet.ADV
Pos_word = "adverb"
| _base)
elif self.pos[-1] == "R":
self.word = pattern.comparative(new_base)
else:
self.word = new_base
class Adjective(Degree):
Wn_tag = wordnet.ADJ
Pos_word = "adjective"
class Adverb(Degree):
| 64 | 64 | 24 | 6 | 58 | stensonowen/Smartifier | smartifier.py | Python | Adverb | Adverb | 146 | 148 | 146 | 146 | bac2f0b962939670e5e13eeab829367084f72345 | bigcode/the-stack | train |
db7478f4696c72ebc4777b8b | train | class | class Noun(Word):
Wn_tag = wordnet.NOUN
Pos_word = "noun"
def re_base(self, new_base):
if self.pos == "NNS":
#plural common noun
self.word = pattern.pluralize(new_base)
elif self.pos.startswith("NNP"):
#proper noun
self.word = self.word
... | class Noun(Word):
| Wn_tag = wordnet.NOUN
Pos_word = "noun"
def re_base(self, new_base):
if self.pos == "NNS":
#plural common noun
self.word = pattern.pluralize(new_base)
elif self.pos.startswith("NNP"):
#proper noun
self.word = self.word
else:
... | else:
self.word = new_base
class Adjective(Degree):
Wn_tag = wordnet.ADJ
Pos_word = "adjective"
class Adverb(Degree):
Wn_tag = wordnet.ADV
Pos_word = "adverb"
class Noun(Word):
| 64 | 64 | 90 | 6 | 58 | stensonowen/Smartifier | smartifier.py | Python | Noun | Noun | 151 | 163 | 151 | 151 | 3cfc6b4841dd6a52e2877c780c1b38156da08954 | bigcode/the-stack | train |
d76397a8946dbb8b34ef341f | train | function | def fix(words):
#words is a list of words;
#most of this stuff is fixed by using spacy's spacing
'''Things to fix:
* spaces around hyphens
* a/an fixes
* capitalize: proper nouns / first words
* quotation marks?
'''
sent = ""
for i in range(len(w... | def fix(words):
#words is a list of words;
#most of this stuff is fixed by using spacy's spacing
| '''Things to fix:
* spaces around hyphens
* a/an fixes
* capitalize: proper nouns / first words
* quotation marks?
'''
sent = ""
for i in range(len(words)):
#iterating by index allows easier lookahead/-behind
#make sure all changes that co... | onyms(base, word.Pos_word)
syn = select_synonym(syns)
word.re_base(syn)
results.append(str(word))
return results
def fix(words):
#words is a list of words;
#most of this stuff is fixed by using spacy's spacing
| 64 | 64 | 195 | 29 | 34 | stensonowen/Smartifier | smartifier.py | Python | fix | fix | 212 | 237 | 212 | 214 | ac508b6f1f11d5221f059949af2bb268295bea88 | bigcode/the-stack | train |
55a3126290a5a45f36c8016d | train | function | def parse_(nlp, sent):
#TODO: delete
#if type(sent) is not unicode:
# sent = unicode(sent)
return [(w.text, w.tag_) for w in nlp(sent)]
| def parse_(nlp, sent):
#TODO: delete
#if type(sent) is not unicode:
# sent = unicode(sent)
| return [(w.text, w.tag_) for w in nlp(sent)]
| syn.split()]
for syn in syns]
bests = [longest(entry) for entry in groups]
return longest(bests)[0]
def parse_(nlp, sent):
#TODO: delete
#if type(sent) is not unicode:
# sent = unicode(sent)
| 64 | 64 | 48 | 32 | 32 | stensonowen/Smartifier | smartifier.py | Python | parse_ | parse_ | 58 | 62 | 58 | 61 | bf99d6ae197ac8c898660f0457c1346cc8a030fd | bigcode/the-stack | train |
708aad1d4253218f65f18e75 | train | class | class Verb(Word):
Wn_tag = wordnet.VERB
Pos_word = "verb"
def re_base(self, new_base):
#get description based on third char of tag
tag_to_desc = {
"D": "p", #past tense
"G": "part", #gerund
"N": "ppart", #past part
"... | class Verb(Word):
| Wn_tag = wordnet.VERB
Pos_word = "verb"
def re_base(self, new_base):
#get description based on third char of tag
tag_to_desc = {
"D": "p", #past tense
"G": "part", #gerund
"N": "ppart", #past part
"P": "1sg", #no... |
self.word = self.word
else:
self.word = new_base
class ProperNoun(Noun):
#Just exists for organization's sake
#Do not try to parse this; it's probably a waste of time
Wn_tag = Pos_word = None
class Verb(Word):
| 64 | 64 | 163 | 5 | 58 | stensonowen/Smartifier | smartifier.py | Python | Verb | Verb | 171 | 186 | 171 | 171 | 7547e86939e82e5a5581a0bfa61ce7d7deb0cddf | bigcode/the-stack | train |
996eb6743b51e9ba897087c5 | train | class | class MultiFactor(base.Auth):
"""A plugin for authenticating with multiple auth methods.
:param string auth_url: Identity service endpoint for authentication.
:param string auth_methods: names of the methods to authenticate with.
:param string trust_id: Trust ID for trust scoping.
:param string sys... | class MultiFactor(base.Auth):
| """A plugin for authenticating with multiple auth methods.
:param string auth_url: Identity service endpoint for authentication.
:param string auth_methods: names of the methods to authenticate with.
:param string trust_id: Trust ID for trust scoping.
:param string system_scope: System information ... | License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. S... | 127 | 127 | 426 | 6 | 121 | raghulnarayanasami/python | Lib/site-packages/keystoneauth1/identity/v3/multi_factor.py | Python | MultiFactor | MultiFactor | 20 | 59 | 20 | 20 | 536ee1c291ebea2fbc9eb7705868ebe16252e697 | bigcode/the-stack | train |
2690be3b5a1bdb7db95244d8 | train | function | async def ping(message):
await message.channel.send('...pong')
| async def ping(message):
| await message.channel.send('...pong')
| async def ping(message):
| 5 | 64 | 14 | 5 | 0 | Paprikar/default-discord-bot-python | bot/commands/ping.py | Python | ping | ping | 1 | 2 | 1 | 1 | 4d007198de66736420654cf4078f580c93149081 | bigcode/the-stack | train |
61afaf47ff7a59f89ac8513c | train | class | class AuctionOwnershipChangeResourceTest(BaseInsiderAuctionWebTest,
AuctionOwnershipChangeTestCaseMixin):
first_owner = 'broker3'
second_owner = 'broker3'
concierge = 'concierge'
test_owner = 'broker3t'
invalid_owner = 'broker1'
initial_auth = ('Basic', (... | class AuctionOwnershipChangeResourceTest(BaseInsiderAuctionWebTest,
AuctionOwnershipChangeTestCaseMixin):
| first_owner = 'broker3'
second_owner = 'broker3'
concierge = 'concierge'
test_owner = 'broker3t'
invalid_owner = 'broker1'
initial_auth = ('Basic', (first_owner, ''))
test_new_owner_can_change = None # tessel auction can not be changed during enquiryPeriod
test_create_auction_by_concie... | .plugins.transferring.mixins import AuctionOwnershipChangeTestCaseMixin
from openprocurement.auctions.core.tests.plugins.transferring.blanks.resource_blanks import (
create_auction_by_concierge
)
class AuctionOwnershipChangeResourceTest(BaseInsiderAuctionWebTest,
AuctionOwne... | 64 | 64 | 145 | 21 | 43 | oleksiyVeretiuk/openprocurement.auctions.tessel | openprocurement/auctions/tessel/tests/transferring.py | Python | AuctionOwnershipChangeResourceTest | AuctionOwnershipChangeResourceTest | 11 | 26 | 11 | 12 | 842faa18ea9ff60edbae4ff8fd94dec7262fc58b | bigcode/the-stack | train |
223b0c33f2a9c11bccc72d3a | train | function | def suite():
tests = unittest.TestSuite()
tests.addTest(unittest.makeSuite(AuctionOwnershipChangeResourceTest))
return tests
| def suite():
| tests = unittest.TestSuite()
tests.addTest(unittest.makeSuite(AuctionOwnershipChangeResourceTest))
return tests
| tessel auction can not be changed during enquiryPeriod
test_create_auction_by_concierge = snitch(create_auction_by_concierge)
def setUp(self):
super(AuctionOwnershipChangeResourceTest, self).setUp()
self.not_used_transfer = self.create_transfer()
def suite():
| 64 | 64 | 28 | 3 | 61 | oleksiyVeretiuk/openprocurement.auctions.tessel | openprocurement/auctions/tessel/tests/transferring.py | Python | suite | suite | 28 | 31 | 28 | 28 | e379817a62e901027998c6b2db8554f0143248fd | bigcode/the-stack | train |
76b693f5b6ca5c89e26e9e2e | train | function | def requirements() -> list:
return [
'click==6.7',
'curio==0.8',
]
| def requirements() -> list:
| return [
'click==6.7',
'curio==0.8',
]
| from setuptools import setup, find_packages
def requirements() -> list:
| 14 | 64 | 28 | 6 | 7 | povilasb/udptest | setup.py | Python | requirements | requirements | 4 | 8 | 4 | 4 | b2112b7eb95495e9a1f8761d68cb23caef61a7c7 | bigcode/the-stack | train |
72cdd945f00c3c62bf17fd05 | train | class | class Test_culvert_routines_pipe_10pct(unittest.TestCase):
"""
This unit test sets up 6 tests for various culvert conditions for a Circular Pipe Culvert on a 10% Slope
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_boyd_1(self):
"""test_boyd_1
... | class Test_culvert_routines_pipe_10pct(unittest.TestCase):
| """
This unit test sets up 6 tests for various culvert conditions for a Circular Pipe Culvert on a 10% Slope
"""
def setUp(self):
pass
def tearDown(self):
pass
def test_boyd_1(self):
"""test_boyd_1
This tests the Boyd routine with data obtained from ??? ... | #!/usr/bin/env python
from __future__ import division
from past.utils import old_div
import unittest
import os.path
import sys
from anuga.utilities.system_tools import get_pathname_from_package
from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model
import numpy as num
class Test_culvert_rout... | 86 | 256 | 3,301 | 15 | 70 | samcom12/anuga_core | anuga/culvert_flows/tests/test_culvert_routines_pipe_10pct.py | Python | Test_culvert_routines_pipe_10pct | Test_culvert_routines_pipe_10pct | 15 | 333 | 15 | 15 | 7bfec16f3f462f2aeae25e556c777d5c22a38a2c | bigcode/the-stack | train |
69fde99877a09294cee78032 | train | class | class TestNetwork(zt.PluginTestCase):
def setUp(self):
# set up test computer
self.code = zt.get_code(entry_point='zeopp.network')
def get_calc(self, parameters):
"""Set up a simple calculation
Uses example cif file.
:param parameters: A zeopp.parameters obje... | class TestNetwork(zt.PluginTestCase):
| def setUp(self):
# set up test computer
self.code = zt.get_code(entry_point='zeopp.network')
def get_calc(self, parameters):
"""Set up a simple calculation
Uses example cif file.
:param parameters: A zeopp.parameters object
:return calc: A zeopp.calcu... | """ Tests for parsers
"""
from __future__ import absolute_import
import os
import aiida_zeopp.tests as zt
from six.moves import zip
class TestNetwork(zt.PluginTestCase):
| 44 | 179 | 598 | 9 | 34 | yakutovicha/aiida-zeopp | aiida_zeopp/parsers/test_network.py | Python | TestNetwork | TestNetwork | 11 | 90 | 11 | 11 | b9976bb1c398c49f5051a32864621c7eac336c88 | bigcode/the-stack | train |
f8c66396915605711fb4b2f0 | train | class | class QCollapsible(QFrame):
"""A collapsible widget to hide and unhide child widgets.
Based on https://stackoverflow.com/a/68141638
"""
_EXPANDED = "▼ "
_COLLAPSED = "▲ "
def __init__(self, title: str = "", parent: Optional[QWidget] = None):
super().__init__(parent)
self._lo... | class QCollapsible(QFrame):
| """A collapsible widget to hide and unhide child widgets.
Based on https://stackoverflow.com/a/68141638
"""
_EXPANDED = "▼ "
_COLLAPSED = "▲ "
def __init__(self, title: str = "", parent: Optional[QWidget] = None):
super().__init__(parent)
self._locked = False
self._... | """A collapsible widget to hide and unhide child widgets"""
from typing import Optional
from qtpy.QtCore import (
QAbstractAnimation,
QEasingCurve,
QMargins,
QPropertyAnimation,
Qt,
)
from qtpy.QtWidgets import QFrame, QPushButton, QVBoxLayout, QWidget
class QCollapsible(QFrame):
| 73 | 256 | 949 | 7 | 65 | lukasz-migas/superqt | src/superqt/collapsible/_collapsible.py | Python | QCollapsible | QCollapsible | 14 | 128 | 14 | 14 | 88f8c7cf05cf8927507bc7fbfcccbdd38bbf9b03 | bigcode/the-stack | train |
94f4ce4e222d010617dba60c | train | function | def test_addfield_uneven_rows():
table = (('foo', 'bar'),
('M',),
('F', 34),
('-', 56, 'spong'))
result = addfield(table, 'baz', 42)
expectation = (('foo', 'bar', 'baz'),
('M', None, 42),
('F', 34, 42),
('-', 56,... | def test_addfield_uneven_rows():
| table = (('foo', 'bar'),
('M',),
('F', 34),
('-', 56, 'spong'))
result = addfield(table, 'baz', 42)
expectation = (('foo', 'bar', 'baz'),
('M', None, 42),
('F', 34, 42),
('-', 56, 42))
ieq(expectation, result... | ', 12, 23, 44, 12),
('F', None, 23, 11, 23),
('-', None, None, 42, 42))
ieq(expect, result)
ieq(expect, result)
def test_addfield_uneven_rows():
| 64 | 64 | 111 | 9 | 55 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_addfield_uneven_rows | test_addfield_uneven_rows | 333 | 344 | 333 | 333 | c518511b89c4097bf6aade440218546f46702fd6 | bigcode/the-stack | train |
cbaf90d51c8cc34fe3bbd032 | train | function | def test_tail():
table1 = (('foo', 'bar'),
('a', 1),
('b', 2),
('c', 5),
('d', 7),
('f', 42),
('f', 3),
('h', 90),
('k', 12),
('l', 77),
('q', 2))
table2 = tail(table1, 4... | def test_tail():
| table1 = (('foo', 'bar'),
('a', 1),
('b', 2),
('c', 5),
('d', 7),
('f', 42),
('f', 3),
('h', 90),
('k', 12),
('l', 77),
('q', 2))
table2 = tail(table1, 4)
expect = (('... | 2))
table2 = head(table1, 4)
expect = (('foo', 'bar'),
('a', 1),
('b', 2),
('c', 5),
('d', 7))
ieq(expect, table2)
def test_tail():
| 64 | 64 | 142 | 4 | 60 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_tail | test_tail | 419 | 439 | 419 | 420 | d32e5cb238c6ae992a4d3825e1d1ce5245a2efa9 | bigcode/the-stack | train |
a6f531d25feca34900fd5ef9 | train | function | def test_cutout():
table = (('foo', 'bar', 'baz'),
('A', 1, 2),
('B', '2', '3.4'),
(u'B', u'3', u'7.8', True),
('D', 'xyz', 9.0),
('E', None))
cut1 = cutout(table, 'bar', 'baz')
expectation = (('foo',),
('A',),
... | def test_cutout():
| table = (('foo', 'bar', 'baz'),
('A', 1, 2),
('B', '2', '3.4'),
(u'B', u'3', u'7.8', True),
('D', 'xyz', 9.0),
('E', None))
cut1 = cutout(table, 'bar', 'baz')
expectation = (('foo',),
('A',),
('B',),
... | 4'),
(u'B', u'7.8'),
('D', 9.0),
('E', None))
ieq(expectation, cut5)
def test_cut_empty():
table = (('foo', 'bar'),)
expect = (('bar',),)
actual = cut(table, 'bar')
ieq(expect, actual)
def test_cutout():
| 84 | 84 | 280 | 5 | 79 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_cutout | test_cutout | 73 | 107 | 73 | 74 | fb0e24bbde137fac00de08a1e1e357b2c3c4568d | bigcode/the-stack | train |
43fc3cde2d0222810951efda | train | function | def test_empty_addcolumn():
table1 = empty()
table2 = addcolumn(table1, 'foo', ['A', 'B'])
table3 = addcolumn(table2, 'bar', [1, 2])
expect = (('foo', 'bar'),
('A', 1),
('B', 2))
ieq(expect, table3)
ieq(expect, table3)
| def test_empty_addcolumn():
| table1 = empty()
table2 = addcolumn(table1, 'foo', ['A', 'B'])
table3 = addcolumn(table2, 'bar', [1, 2])
expect = (('foo', 'bar'),
('A', 1),
('B', 2))
ieq(expect, table3)
ieq(expect, table3)
| ('foo', 'bar', 'baz'),
('A', 1, True),
('B', 2, False),
(None, None, False))
table5 = addcolumn(table1, 'baz', col)
ieq(expect5, table5)
def test_empty_addcolumn():
| 64 | 64 | 88 | 6 | 58 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_empty_addcolumn | test_empty_addcolumn | 587 | 596 | 587 | 588 | 67c14325bf0f51b3a1906fa2585444d21ca70d42 | bigcode/the-stack | train |
46547765c1a7ef98cbb49e1a | train | function | def test_head():
table1 = (('foo', 'bar'),
('a', 1),
('b', 2),
('c', 5),
('d', 7),
('f', 42),
('f', 3),
('h', 90),
('k', 12),
('l', 77),
('q', 2))
table2 = head(table1, 4... | def test_head():
| table1 = (('foo', 'bar'),
('a', 1),
('b', 2),
('c', 5),
('d', 7),
('f', 42),
('f', 3),
('h', 90),
('k', 12),
('l', 77),
('q', 2))
table2 = head(table1, 4)
expect = (('... | 9.0))
ieq(expectation, result)
def test_rowslice_empty():
table = (('foo', 'bar'),)
expect = (('foo', 'bar'),)
actual = rowslice(table, 1, 2)
ieq(expect, actual)
def test_head():
| 64 | 64 | 142 | 4 | 60 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_head | test_head | 396 | 416 | 396 | 397 | 1a108bd30d5cec6ac1fb835af79086811bf8d3e7 | bigcode/the-stack | train |
f7beb2556c3a6fecbba2d959 | train | function | def test_cat_dupfields():
table1 = (('foo', 'foo'),
(1, 'A'),
(2,),
(3, 'B', True))
# these cases are pathological, including to confirm expected behaviour,
# but user needs to rename fields to get something sensible
actual = cat(table1)
expect = (('foo', ... | def test_cat_dupfields():
| table1 = (('foo', 'foo'),
(1, 'A'),
(2,),
(3, 'B', True))
# these cases are pathological, including to confirm expected behaviour,
# but user needs to rename fields to get something sensible
actual = cat(table1)
expect = (('foo', 'foo'),
(1, ... | 2 = (('bar', 'baz'),)
expect = (('foo', 'bar', 'baz'),
(1, 'A', None),
(2, 'B', None))
actual = cat(table1, table2)
ieq(expect, actual)
def test_cat_dupfields():
| 64 | 64 | 215 | 6 | 58 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_cat_dupfields | test_cat_dupfields | 200 | 226 | 200 | 200 | 7066992a6df74b6cd6f660c75f3f46357791d1ab | bigcode/the-stack | train |
5240c19faab327400b7d3e81 | train | function | def test_cat_with_header():
table1 = (('bar', 'foo'),
('A', 1),
('B', 2))
table2 = (('bar', 'baz'),
('C', True),
('D', False))
actual = cat(table1, header=['A', 'foo', 'B', 'bar', 'C'])
expect = (('A', 'foo', 'B', 'bar', 'C'),
(Non... | def test_cat_with_header():
| table1 = (('bar', 'foo'),
('A', 1),
('B', 2))
table2 = (('bar', 'baz'),
('C', True),
('D', False))
actual = cat(table1, header=['A', 'foo', 'B', 'bar', 'C'])
expect = (('A', 'foo', 'B', 'bar', 'C'),
(None, 1, None, 'A', None),
... | False),
('A', 1, 2),
('B', '2', '3.4'),
(u'B', u'3', u'7.8'),
('D', 'xyz', 9.0),
('E', None, None))
ieq(expectation, cat4)
def test_cat_with_header():
| 75 | 75 | 251 | 6 | 69 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_cat_with_header | test_cat_with_header | 161 | 185 | 161 | 162 | cb59f6122faba4e2fcd72d0f1f62cd23e68eb036 | bigcode/the-stack | train |
1196836ba8380994511864d6 | train | function | def test_addfield_empty():
table = (('foo', 'bar'),)
expect = (('foo', 'bar', 'baz'),)
actual = addfield(table, 'baz', 42)
ieq(expect, actual)
ieq(expect, actual)
| def test_addfield_empty():
| table = (('foo', 'bar'),)
expect = (('foo', 'bar', 'baz'),)
actual = addfield(table, 'baz', 42)
ieq(expect, actual)
ieq(expect, actual)
| )
expectation = (('baz', 'foo', 'bar'),
(42, 'M', 12),
(42, 'F', 34),
(42, '-', 56))
ieq(expectation, result)
ieq(expectation, result)
def test_addfield_empty():
| 64 | 64 | 58 | 6 | 58 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_addfield_empty | test_addfield_empty | 302 | 307 | 302 | 302 | d7a760cbec37ef6734162deeb0fbc0bdcc93fec0 | bigcode/the-stack | train |
f31f5093b7c63579bb6d6a89 | train | function | def test_addfield():
table = (('foo', 'bar'),
('M', 12),
('F', 34),
('-', 56))
result = addfield(table, 'baz', 42)
expectation = (('foo', 'bar', 'baz'),
('M', 12, 42),
('F', 34, 42),
('-', 56, 42))
ieq(expec... | def test_addfield():
| table = (('foo', 'bar'),
('M', 12),
('F', 34),
('-', 56))
result = addfield(table, 'baz', 42)
expectation = (('foo', 'bar', 'baz'),
('M', 12, 42),
('F', 34, 42),
('-', 56, 42))
ieq(expectation, result)
i... | foo'),
(1, 'A'),
(2, None),
(3, 'B'))
ieq(expect, actual)
table2 = (('foo', 'foo', 'bar'),
(4, 'C', True),
(5, 'D', False))
actual = stack(table1, table2)
expect = (('foo', 'foo'),
(1, 'A'),
(2, None),
... | 127 | 127 | 424 | 5 | 122 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_addfield | test_addfield | 255 | 299 | 255 | 255 | f3706668efe2deb01c29879601a67316a2bc2666 | bigcode/the-stack | train |
40f40565cbb829129c1e0c07 | train | function | def test_addcolumn():
table1 = (('foo', 'bar'),
('A', 1),
('B', 2))
col = [True, False]
expect2 = (('foo', 'bar', 'baz'),
('A', 1, True),
('B', 2, False))
table2 = addcolumn(table1, 'baz', col)
ieq(expect2, table2)
ieq(expect2, table2)... | def test_addcolumn():
| table1 = (('foo', 'bar'),
('A', 1),
('B', 2))
col = [True, False]
expect2 = (('foo', 'bar', 'baz'),
('A', 1, True),
('B', 2, False))
table2 = addcolumn(table1, 'baz', col)
ieq(expect2, table2)
ieq(expect2, table2)
# test short colu... | foo', 'bar'),
('A', 9),
('C', 2))
expect = (('id', 'foo', 'bar'),
(1, 'A', 9),
(2, 'C', 2))
actual = addrownumbers(table1, field='id')
ieq(expect, actual)
ieq(expect, actual)
def test_addcolumn():
| 84 | 84 | 283 | 5 | 79 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_addcolumn | test_addcolumn | 550 | 584 | 550 | 551 | 330a4beacbde36063dd5f78f00aed860fb630ec0 | bigcode/the-stack | train |
5d4465d0704c62ab960054fd | train | function | def test_cat_empty():
table1 = (('foo', 'bar'),
(1, 'A'),
(2, 'B'))
table2 = (('bar', 'baz'),)
expect = (('foo', 'bar', 'baz'),
(1, 'A', None),
(2, 'B', None))
actual = cat(table1, table2)
ieq(expect, actual)
| def test_cat_empty():
| table1 = (('foo', 'bar'),
(1, 'A'),
(2, 'B'))
table2 = (('bar', 'baz'),)
expect = (('foo', 'bar', 'baz'),
(1, 'A', None),
(2, 'B', None))
actual = cat(table1, table2)
ieq(expect, actual)
| 'A', None),
(None, 2, None, 'B', None),
(None, None, None, 'C', None),
(None, None, None, 'D', None))
ieq(expect, actual)
ieq(expect, actual)
def test_cat_empty():
| 64 | 64 | 90 | 5 | 59 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_cat_empty | test_cat_empty | 188 | 197 | 188 | 188 | bf0a78f7945bdda67c7385a3230f2f5bcb3a78e9 | bigcode/the-stack | train |
ca680ef1c35ab75f840c5a72 | train | function | def test_addfieldusingcontext_stateful():
table1 = (('foo', 'bar'),
('A', 1),
('B', 4),
('C', 5),
('D', 9))
expect = (('foo', 'bar', 'baz', 'quux'),
('A', 1, 1, 5),
('B', 4, 5, 10),
('C', 5, 10, 19),
... | def test_addfieldusingcontext_stateful():
| table1 = (('foo', 'bar'),
('A', 1),
('B', 4),
('C', 5),
('D', 9))
expect = (('foo', 'bar', 'baz', 'quux'),
('A', 1, 1, 5),
('B', 4, 5, 10),
('C', 5, 10, 19),
('D', 9, 19, 19))
def upstream(prv, ... | :
return None
else:
return nxt.bar - cur.bar
table2 = addfieldusingcontext(table1, 'baz', upstream)
table3 = addfieldusingcontext(table2, 'quux', downstream)
ieq(expect, table3)
ieq(expect, table3)
def test_addfieldusingcontext_stateful():
| 74 | 74 | 247 | 9 | 65 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_addfieldusingcontext_stateful | test_addfieldusingcontext_stateful | 630 | 661 | 630 | 631 | 70205f1f6d5d8f77c4cf7cd423ac6af5dc791553 | bigcode/the-stack | train |
7aa12c667e5f204f5ac83bb7 | train | function | def test_addrownumbers_field_name():
table1 = (('foo', 'bar'),
('A', 9),
('C', 2))
expect = (('id', 'foo', 'bar'),
(1, 'A', 9),
(2, 'C', 2))
actual = addrownumbers(table1, field='id')
ieq(expect, actual)
ieq(expect, actual)
| def test_addrownumbers_field_name():
| table1 = (('foo', 'bar'),
('A', 9),
('C', 2))
expect = (('id', 'foo', 'bar'),
(1, 'A', 9),
(2, 'C', 2))
actual = addrownumbers(table1, field='id')
ieq(expect, actual)
ieq(expect, actual)
| 'bar'),
(1, 'A', 9),
(2, 'C', 2),
(3, 'F', 1))
actual = addrownumbers(table1)
ieq(expect, actual)
ieq(expect, actual)
def test_addrownumbers_field_name():
| 64 | 64 | 93 | 8 | 56 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_addrownumbers_field_name | test_addrownumbers_field_name | 536 | 547 | 536 | 537 | 3e7588f74e76a2f7d6f5d75fff93e9d6c6d4d57b | bigcode/the-stack | train |
99afad8f08050286df742f49 | train | function | def test_cat():
table1 = (('foo', 'bar'),
(1, 'A'),
(2, 'B'))
table2 = (('bar', 'baz'),
('C', True),
('D', False))
cat1 = cat(table1, table2, missing=None)
expectation = (('foo', 'bar', 'baz'),
(1, 'A', None),
... | def test_cat():
| table1 = (('foo', 'bar'),
(1, 'A'),
(2, 'B'))
table2 = (('bar', 'baz'),
('C', True),
('D', False))
cat1 = cat(table1, table2, missing=None)
expectation = (('foo', 'bar', 'baz'),
(1, 'A', None),
(2, 'B', None)... | '),
('A', 2),
('B', '3.4'),
(u'B', u'7.8'),
('D', 9.0),
('E', None))
ieq(expectation, cut2)
cut3 = cutout(table, 1)
expectation = (('foo', 'baz'),
('A', 2),
('B', '3.4'),
... | 130 | 130 | 435 | 4 | 126 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_cat | test_cat | 110 | 158 | 110 | 111 | dcd430f73f8678500276cd49caee809d5eb63706 | bigcode/the-stack | train |
c56ae678b97c9aac86924017 | train | function | def test_skipcomments_empty():
table1 = (('##aaa', 'bbb', 'ccc'),
('##mmm',),
('#foo', 'bar'),
('##nnn', 1))
table2 = skipcomments(table1, '##')
expect2 = (('#foo', 'bar'),)
ieq(expect2, table2)
| def test_skipcomments_empty():
| table1 = (('##aaa', 'bbb', 'ccc'),
('##mmm',),
('#foo', 'bar'),
('##nnn', 1))
table2 = skipcomments(table1, '##')
expect2 = (('#foo', 'bar'),)
ieq(expect2, table2)
| = skipcomments(table1, '##')
expect2 = (('#foo', 'bar'),
('a', 1),
('b', 2))
ieq(expect2, table2)
ieq(expect2, table2) # can iterate twice?
def test_skipcomments_empty():
| 64 | 64 | 77 | 6 | 58 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_skipcomments_empty | test_skipcomments_empty | 465 | 473 | 465 | 466 | 64907001f3d022a2e98d73abda1d698f83ce0492 | bigcode/the-stack | train |
89f88d7f44f6021de9906edb | train | function | def test_annex_uneven_rows():
table1 = (('foo', 'bar'),
('A', 9, True),
('C', 2),
('F',))
table2 = (('foo', 'baz'),
('B', 3),
('D', 10))
expect = (('foo', 'bar', 'foo', 'baz'),
('A', 9, 'B', 3),
('C', 2, 'D', ... | def test_annex_uneven_rows():
| table1 = (('foo', 'bar'),
('A', 9, True),
('C', 2),
('F',))
table2 = (('foo', 'baz'),
('B', 3),
('D', 10))
expect = (('foo', 'bar', 'foo', 'baz'),
('A', 9, 'B', 3),
('C', 2, 'D', 10),
('F', None, ... | ),
('D', 10, 'C', 2),
(None, None, 'F', 1))
actual21 = annex(table2, table1)
ieq(expect21, actual21)
ieq(expect21, actual21)
def test_annex_uneven_rows():
| 64 | 64 | 142 | 9 | 55 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_annex_uneven_rows | test_annex_uneven_rows | 502 | 517 | 502 | 503 | f3d2c3f56ee414ef2650fcb52cb0fb13c0ed99ce | bigcode/the-stack | train |
eaf1520b98018efdb8f15c95 | train | function | def test_skipcomments():
table1 = (('##aaa', 'bbb', 'ccc'),
('##mmm',),
('#foo', 'bar'),
('##nnn', 1),
('a', 1),
('b', 2))
table2 = skipcomments(table1, '##')
expect2 = (('#foo', 'bar'),
('a', 1),
('b', 2))
... | def test_skipcomments():
| table1 = (('##aaa', 'bbb', 'ccc'),
('##mmm',),
('#foo', 'bar'),
('##nnn', 1),
('a', 1),
('b', 2))
table2 = skipcomments(table1, '##')
expect2 = (('#foo', 'bar'),
('a', 1),
('b', 2))
ieq(expect2, table2)
... | ', 77),
('q', 2))
ieq(expect, table2)
def test_tail_empty():
table = (('foo', 'bar'),)
expect = (('foo', 'bar'),)
actual = tail(table)
ieq(expect, actual)
def test_skipcomments():
| 64 | 64 | 118 | 5 | 59 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_skipcomments | test_skipcomments | 449 | 462 | 449 | 450 | 00f771218aa6e6bbfd92b7a413f1374ef1d73eb7 | bigcode/the-stack | train |
bd4a28f3016c7001d364dbf5 | train | function | def test_rowslice_empty():
table = (('foo', 'bar'),)
expect = (('foo', 'bar'),)
actual = rowslice(table, 1, 2)
ieq(expect, actual)
| def test_rowslice_empty():
| table = (('foo', 'bar'),)
expect = (('foo', 'bar'),)
actual = rowslice(table, 1, 2)
ieq(expect, actual)
| rowslice(table, 1, 5, 2)
expectation = (('foo', 'bar', 'baz'),
('B', '2', '3.4'),
('D', 'xyz', 9.0))
ieq(expectation, result)
def test_rowslice_empty():
| 64 | 64 | 48 | 6 | 58 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_rowslice_empty | test_rowslice_empty | 389 | 393 | 389 | 389 | b8abb09e096d2acce3a67bcfd3dea3cc2f39302c | bigcode/the-stack | train |
5ac3febaff18a4e2de15cdab | train | function | def test_cut():
table = (('foo', 'bar', 'baz'),
('A', 1, 2),
('B', '2', '3.4'),
(u'B', u'3', u'7.8', True),
('D', 'xyz', 9.0),
('E', None))
cut1 = cut(table, 'foo')
expectation = (('foo',),
('A',),
('B',... | def test_cut():
| table = (('foo', 'bar', 'baz'),
('A', 1, 2),
('B', '2', '3.4'),
(u'B', u'3', u'7.8', True),
('D', 'xyz', 9.0),
('E', None))
cut1 = cut(table, 'foo')
expectation = (('foo',),
('A',),
('B',),
... | from __future__ import absolute_import, print_function, division
from petl.test.helpers import ieq
from petl.util import expr, empty, coalesce
from petl.transform.basics import cut, cat, addfield, rowslice, head, tail, \
cutout, skipcomments, annex, addrownumbers, addcolumn, \
addfieldusingcontext, movefield,... | 88 | 127 | 424 | 4 | 83 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_cut | test_cut | 11 | 63 | 11 | 12 | 934aef169ca4a7eb2bdfaff507b55403d5d63c46 | bigcode/the-stack | train |
403975bd608de0c57ced096e | train | function | def test_stack_dupfields():
table1 = (('foo', 'foo'),
(1, 'A'),
(2,),
(3, 'B', True))
actual = stack(table1)
expect = (('foo', 'foo'),
(1, 'A'),
(2, None),
(3, 'B'))
ieq(expect, actual)
table2 = (('foo', 'foo', 'ba... | def test_stack_dupfields():
| table1 = (('foo', 'foo'),
(1, 'A'),
(2,),
(3, 'B', True))
actual = stack(table1)
expect = (('foo', 'foo'),
(1, 'A'),
(2, None),
(3, 'B'))
ieq(expect, actual)
table2 = (('foo', 'foo', 'bar'),
(4, 'C', ... | 'foo', 'bar'),
(1, 1, None),
(2, 2, None),
(3, 3, None),
(4, 4, True),
(5, 5, False))
ieq(expect, actual)
def test_stack_dupfields():
| 64 | 64 | 174 | 6 | 58 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_stack_dupfields | test_stack_dupfields | 229 | 252 | 229 | 229 | bfa6fdd165fbfeedbc456b42a04899b867513bbf | bigcode/the-stack | train |
7eef379dbc7dc439c62772ae | train | function | def test_addfield_dupfield():
table = (('foo', 'foo'),
('M', 12),
('F', 34),
('-', 56))
result = addfield(table, 'bar', 42)
expectation = (('foo', 'foo', 'bar'),
('M', 12, 42),
('F', 34, 42),
('-', 56, 42))
... | def test_addfield_dupfield():
| table = (('foo', 'foo'),
('M', 12),
('F', 34),
('-', 56))
result = addfield(table, 'bar', 42)
expectation = (('foo', 'foo', 'bar'),
('M', 12, 42),
('F', 34, 42),
('-', 56, 42))
ieq(expectation, result)
i... | expectation = (('foo', 'bar', 'baz'),
('M', None, 42),
('F', 34, 42),
('-', 56, 42))
ieq(expectation, result)
ieq(expectation, result)
def test_addfield_dupfield():
| 64 | 64 | 108 | 7 | 57 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_addfield_dupfield | test_addfield_dupfield | 347 | 359 | 347 | 347 | d728326aac4d82ee39dc0240d93793270703f9dd | bigcode/the-stack | train |
391925abd82a58918a2a06d2 | train | function | def test_addrownumbers():
table1 = (('foo', 'bar'),
('A', 9),
('C', 2),
('F', 1))
expect = (('row', 'foo', 'bar'),
(1, 'A', 9),
(2, 'C', 2),
(3, 'F', 1))
actual = addrownumbers(table1)
ieq(expect, actual)
ieq(expec... | def test_addrownumbers():
| table1 = (('foo', 'bar'),
('A', 9),
('C', 2),
('F', 1))
expect = (('row', 'foo', 'bar'),
(1, 'A', 9),
(2, 'C', 2),
(3, 'F', 1))
actual = addrownumbers(table1)
ieq(expect, actual)
ieq(expect, actual)
| A', 9, 'B', 3),
('C', 2, 'D', 10),
('F', None, None, None))
actual = annex(table1, table2)
ieq(expect, actual)
ieq(expect, actual)
def test_addrownumbers():
| 64 | 64 | 104 | 6 | 58 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_addrownumbers | test_addrownumbers | 520 | 533 | 520 | 521 | 634d1458c31bd280a319dbb864bd1ef7527c16b6 | bigcode/the-stack | train |
9c46df2256d87514cd91f0e3 | train | function | def test_addfieldusingcontext():
table1 = (('foo', 'bar'),
('A', 1),
('B', 4),
('C', 5),
('D', 9))
expect = (('foo', 'bar', 'baz', 'quux'),
('A', 1, None, 3),
('B', 4, 3, 1),
('C', 5, 1, 4),
('D', 9... | def test_addfieldusingcontext():
| table1 = (('foo', 'bar'),
('A', 1),
('B', 4),
('C', 5),
('D', 9))
expect = (('foo', 'bar', 'baz', 'quux'),
('A', 1, None, 3),
('B', 4, 3, 1),
('C', 5, 1, 4),
('D', 9, 4, None))
def upstream(prv,... | B'])
table3 = addcolumn(table2, 'bar', [1, 2])
expect = (('foo', 'bar'),
('A', 1),
('B', 2))
ieq(expect, table3)
ieq(expect, table3)
def test_addfieldusingcontext():
| 67 | 67 | 224 | 7 | 60 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_addfieldusingcontext | test_addfieldusingcontext | 599 | 628 | 599 | 600 | 2a4b02524fabc04edbbb2ed7adc8db78def7b95c | bigcode/the-stack | train |
86f23b9e97ddc304a853df54 | train | function | def test_annex():
table1 = (('foo', 'bar'),
('A', 9),
('C', 2),
('F', 1))
table2 = (('foo', 'baz'),
('B', 3),
('D', 10))
expect = (('foo', 'bar', 'foo', 'baz'),
('A', 9, 'B', 3),
('C', 2, 'D', 10),
... | def test_annex():
| table1 = (('foo', 'bar'),
('A', 9),
('C', 2),
('F', 1))
table2 = (('foo', 'baz'),
('B', 3),
('D', 10))
expect = (('foo', 'bar', 'foo', 'baz'),
('A', 9, 'B', 3),
('C', 2, 'D', 10),
('F', 1, None, N... | bbb', 'ccc'),
('##mmm',),
('#foo', 'bar'),
('##nnn', 1))
table2 = skipcomments(table1, '##')
expect2 = (('#foo', 'bar'),)
ieq(expect2, table2)
def test_annex():
| 66 | 66 | 223 | 5 | 61 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_annex | test_annex | 476 | 499 | 476 | 477 | 5e2ad9e52edc03cb0bf06c0eaa2a601412eda3de | bigcode/the-stack | train |
c26f3599245dfc0b8f3dd25c | train | function | def test_rowslice():
table = (('foo', 'bar', 'baz'),
('A', 1, 2),
('B', '2', '3.4'),
(u'B', u'3', u'7.8', True),
('D', 'xyz', 9.0),
('E', None))
result = rowslice(table, 2)
expectation = (('foo', 'bar', 'baz'),
('A', 1, 2)... | def test_rowslice():
| table = (('foo', 'bar', 'baz'),
('A', 1, 2),
('B', '2', '3.4'),
(u'B', u'3', u'7.8', True),
('D', 'xyz', 9.0),
('E', None))
result = rowslice(table, 2)
expectation = (('foo', 'bar', 'baz'),
('A', 1, 2),
(... | , 'bar', 42)
expectation = (('foo', 'foo', 'bar'),
('M', 12, 42),
('F', 34, 42),
('-', 56, 42))
ieq(expectation, result)
ieq(expectation, result)
def test_rowslice():
| 70 | 70 | 236 | 5 | 65 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_rowslice | test_rowslice | 362 | 386 | 362 | 363 | c9c74e13c342491be64d2b53635e006efe0c819d | bigcode/the-stack | train |
67993937d2f6c6fc97785f91 | train | function | def test_addfield_coalesce():
table = (('foo', 'bar', 'baz', 'quux'),
('M', 12, 23, 44),
('F', None, 23, 11),
('-', None, None, 42))
result = addfield(table, 'spong', coalesce('bar', 'baz', 'quux'))
expect = (('foo', 'bar', 'baz', 'quux', 'spong'),
('M',... | def test_addfield_coalesce():
| table = (('foo', 'bar', 'baz', 'quux'),
('M', 12, 23, 44),
('F', None, 23, 11),
('-', None, None, 42))
result = addfield(table, 'spong', coalesce('bar', 'baz', 'quux'))
expect = (('foo', 'bar', 'baz', 'quux', 'spong'),
('M', 12, 23, 44, 12),
... | (expectation, result)
ieq(expectation, result)
def test_addfield_empty():
table = (('foo', 'bar'),)
expect = (('foo', 'bar', 'baz'),)
actual = addfield(table, 'baz', 42)
ieq(expect, actual)
ieq(expect, actual)
def test_addfield_coalesce():
| 78 | 78 | 262 | 7 | 71 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_addfield_coalesce | test_addfield_coalesce | 310 | 330 | 310 | 310 | 0d950f6fd64106eccec9f466f95593cdcd91c70c | bigcode/the-stack | train |
0ee742b5c9897d48cfbf45c8 | train | function | def test_movefield():
table1 = (('foo', 'bar', 'baz'),
(1, 'A', True),
(2, 'B', False))
expect = (('bar', 'foo', 'baz'),
('A', 1, True),
('B', 2, False))
actual = movefield(table1, 'bar', 0)
ieq(expect, actual)
ieq(expect, actual)
actua... | def test_movefield():
| table1 = (('foo', 'bar', 'baz'),
(1, 'A', True),
(2, 'B', False))
expect = (('bar', 'foo', 'baz'),
('A', 1, True),
('B', 2, False))
actual = movefield(table1, 'bar', 0)
ieq(expect, actual)
ieq(expect, actual)
actual = movefield(table1, '... | :
return nxt.bar + prv.quux
table2 = addfieldusingcontext(table1, 'baz', upstream)
table3 = addfieldusingcontext(table2, 'quux', downstream)
ieq(expect, table3)
ieq(expect, table3)
def test_movefield():
| 64 | 64 | 124 | 5 | 59 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_movefield | test_movefield | 664 | 680 | 664 | 665 | ce34089fd66676d9ce4d3906fdd068947badbc8b | bigcode/the-stack | train |
acd8307f11cc62958fee0f50 | train | function | def test_tail_empty():
table = (('foo', 'bar'),)
expect = (('foo', 'bar'),)
actual = tail(table)
ieq(expect, actual)
| def test_tail_empty():
| table = (('foo', 'bar'),)
expect = (('foo', 'bar'),)
actual = tail(table)
ieq(expect, actual)
| 2))
table2 = tail(table1, 4)
expect = (('foo', 'bar'),
('h', 90),
('k', 12),
('l', 77),
('q', 2))
ieq(expect, table2)
def test_tail_empty():
| 64 | 64 | 40 | 5 | 59 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_tail_empty | test_tail_empty | 442 | 446 | 442 | 442 | 1e0cee62773d941a90575f6c04e05e95560156d6 | bigcode/the-stack | train |
0a5dfff1d0dcdf85b350dc14 | train | function | def test_cut_empty():
table = (('foo', 'bar'),)
expect = (('bar',),)
actual = cut(table, 'bar')
ieq(expect, actual)
| def test_cut_empty():
| table = (('foo', 'bar'),)
expect = (('bar',),)
actual = cut(table, 'bar')
ieq(expect, actual)
| (('foo', 'baz'),
('A', 2),
('B', '3.4'),
(u'B', u'7.8'),
('D', 9.0),
('E', None))
ieq(expectation, cut5)
def test_cut_empty():
| 64 | 64 | 41 | 5 | 59 | OptionMetrics/petl | petl/test/transform/test_basics.py | Python | test_cut_empty | test_cut_empty | 66 | 70 | 66 | 66 | 952eab8d54101ecc227a2a5eff223ccad7887141 | bigcode/the-stack | train |
2bbda9a10dc212f8456fb3a4 | train | class | class MiddlewareTestCase(oslotest.BaseTestCase):
"""Base class for all test-cases."""
def setUp(self):
"""Set up the test."""
super(MiddlewareTestCase, self).setUp()
# If auditmiddleware calls any deprecated function this will raise
# an exception.
warnings.filterwarnin... | class MiddlewareTestCase(oslotest.BaseTestCase):
| """Base class for all test-cases."""
def setUp(self):
"""Set up the test."""
super(MiddlewareTestCase, self).setUp()
# If auditmiddleware calls any deprecated function this will raise
# an exception.
warnings.filterwarnings('error', category=DeprecationWarning,
... | in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Common classes and utils for the tes... | 110 | 110 | 368 | 11 | 98 | Pagolin/openstack-audit-middleware | auditmiddleware/tests/unit/utils.py | Python | MiddlewareTestCase | MiddlewareTestCase | 23 | 71 | 23 | 23 | f92c2f15b9d86551b4fe1b82c584dd70b51b2cd8 | bigcode/the-stack | train |
359ce8a015f99505ed0e5b03 | train | class | @pytest.mark.incremental
class TestRememberContract:
@pytest.mark.parametrize(
"contract_name,non_originated_contract_address",
[
("test", "KT1BuEZtb68c1Q4yjtckcNjGELqWt56Xyesc"),
("test-2", "KT1TZCh8fmUbuDqFxetPWC2fsQanAHzLx4W9"),
],
)
def test_non_originated... | @pytest.mark.incremental
class TestRememberContract:
@pytest.mark.parametrize(
"contract_name,non_originated_contract_address",
[
("test", "KT1BuEZtb68c1Q4yjtckcNjGELqWt56Xyesc"),
("test-2", "KT1TZCh8fmUbuDqFxetPWC2fsQanAHzLx4W9"),
],
)
| def test_non_originated_contract_no_forcing_not_saved_before(
self,
client,
contract_name,
non_originated_contract_address,
):
client.remember_contract(contract_name, non_originated_contract_address)
# As it is always the same client, the contracts have been saved
... | def test_duplicate_alias(self, client: Client):
client.add_address("baz", "foo", force=True)
show_foo = client.show_address("foo", show_secret=True)
assert show_foo.secret_key is not None
@pytest.mark.incremental
class TestRememberContract:
@pytest.mark.parametrize(
"contract_name,n... | 144 | 144 | 483 | 95 | 48 | daachi/tezos | tests_python/tests_008/test_basic.py | Python | TestRememberContract | TestRememberContract | 166 | 222 | 166 | 174 | f1b2558dee2ecd5becf1cdd9ae4dae367f362154 | bigcode/the-stack | train |
7f3a7e3a14bb71aea0a149e3 | train | class | @pytest.mark.incremental
class TestRawContext:
def test_delegates(self, client: Client):
path = '/chains/main/blocks/head/context/raw/bytes/delegates/?depth=3'
res = client.rpc('get', path)
expected = {
"ed25519": {
"02": {"29": None},
"a9": {"ce":... | @pytest.mark.incremental
class TestRawContext:
| def test_delegates(self, client: Client):
path = '/chains/main/blocks/head/context/raw/bytes/delegates/?depth=3'
res = client.rpc('get', path)
expected = {
"ed25519": {
"02": {"29": None},
"a9": {"ce": None},
"c5": {"5c": None},
... | from os import path
import pytest
from client.client import Client
from tools import utils
from tools.paths import ACCOUNT_PATH
from tools.utils import assert_run_failure
from .contract_paths import CONTRACT_PATH
TRANSFER_ARGS = ['--burn-cap', '0.257']
@pytest.mark.incremental
class TestRawContext:
| 65 | 256 | 1,419 | 10 | 55 | daachi/tezos | tests_python/tests_008/test_basic.py | Python | TestRawContext | TestRawContext | 13 | 163 | 13 | 14 | a8048a645da33be42df8d10ac6e1e97a89c6b389 | bigcode/the-stack | train |
dacf734d0ad06cf650c4a713 | train | class | class TestCheck(unittest.TestCase):
"""Check unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testCheck(self):
"""Test Check"""
# FIXME: construct object with mandatory attributes with example values
# model = onfido.models.check.Check() #... | class TestCheck(unittest.TestCase):
| """Check unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testCheck(self):
"""Test Check"""
# FIXME: construct object with mandatory attributes with example values
# model = onfido.models.check.Check() # noqa: E501
pass
| .0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import onfido
from onfido.models.check import Check # noqa: E501
from onfido.rest import ApiException
class TestCheck(unittest.TestCase):
| 64 | 64 | 78 | 7 | 56 | onfido/api-python-client | test/test_check.py | Python | TestCheck | TestCheck | 22 | 35 | 22 | 22 | 08139822862b2e39f14fef924b63eee557f5dddf | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.