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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
12b9b721252497318c3852c5 | train | function | def test_merge_lookup_require_match():
"""Check that the 'require_match' parameter of merge_lookup() is respected when specified."""
foo, bar = TestDataset.sql_semantics()
with pytest.raises(ValueError):
rt.rt_merge.merge_lookup(
foo,
bar,
on=('col1', 'co... | def test_merge_lookup_require_match():
| """Check that the 'require_match' parameter of merge_lookup() is respected when specified."""
foo, bar = TestDataset.sql_semantics()
with pytest.raises(ValueError):
rt.rt_merge.merge_lookup(
foo,
bar,
on=('col1', 'col1'),
require_match=True,
... | , bar = TestDataset.sql_semantics()
with pytest.raises(ValueError):
rt.rt_merge.merge_lookup(
foo,
bar,
on=('col1', 'col1'),
require_match=True,
suffixes=('_foo', '_bar'),
)
def test_merge_lookup_require_match():
| 63 | 64 | 90 | 7 | 56 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_lookup_require_match | test_merge_lookup_require_match | 6,264 | 6,276 | 6,264 | 6,264 | 1f20dc1e7f45a4ab8149b6b7fe5b13528f8fc855 | bigcode/the-stack | train |
d318d7bf6114a10f43ee9493 | train | function | def test_merge2_sql_semantics_rightjoin_single_keep_lastNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.s... | def test_merge2_sql_semantics_rightjoin_single_keep_lastNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | , 3, inv, inv, inv, inv, 1, 1], dtype=np.int32)
)
assert_array_equal(
result.col2_foo,
rt.FA([1, 1, inv, inv, inv, inv, inv, inv, inv], dtype=np.int32),
)
# Cols from the right Dataset.
assert_array_equal(
result.id_bar, rt.FA([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.i... | 255 | 256 | 959 | 14 | 241 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_rightjoin_single_keep_lastNone | test_merge2_sql_semantics_rightjoin_single_keep_lastNone | 3,418 | 3,513 | 3,418 | 3,418 | c6c025917d5c654f49436f57ef53d4f32ebeb332 | bigcode/the-stack | train |
aeb5e186ebeb0b3628535c9c | train | function | def test_merge2_sql_semantics_innerjoin_single():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_s... | def test_merge2_sql_semantics_innerjoin_single():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
... | )
assert_array_equal(
result.col2_bar,
rt.FA([4, inv, inv, 3, inv, inv, 1, 5, 5, inv, inv], dtype=np.int32),
)
assert_array_equal(
result.strcol,
rt.FA(
[
b'Chestnut',
b'Pine',
b'Walnut',
... | 146 | 147 | 491 | 11 | 135 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_innerjoin_single | test_merge2_sql_semantics_innerjoin_single | 2,388 | 2,450 | 2,388 | 2,388 | e93ee99d7c1c5e3c39fc46ec39c6c7708201af71 | bigcode/the-stack | train |
5099f9d6682843d87c34a23c | train | function | def test_merge2_rowcount_is_sentinel():
# Test case from RIP-466.
N = rt.uint8.inv
symbols = N * ['A']
left_ds = rt.Dataset(dict(symbol=symbols))
right_ds = rt.Dataset(dict(symbol=sorted(set(symbols))))
right_ds['foo'] = 1.0
# This should succeed without raising an exception.
... | def test_merge2_rowcount_is_sentinel():
# Test case from RIP-466.
| N = rt.uint8.inv
symbols = N * ['A']
left_ds = rt.Dataset(dict(symbol=symbols))
right_ds = rt.Dataset(dict(symbol=sorted(set(symbols))))
right_ds['foo'] = 1.0
# This should succeed without raising an exception.
# Prior to a fix being implemented for this case, _build_left_fancyindex(... | .k1.dtype.kind != y.k1.dtype.kind
assert x.k1.dtype.itemsize != y.k1.dtype.itemsize
result = rt.merge2(x, y, on=['k1'], how='outer')
assert result.get_nrows() == 4
assert result.k1.dtype == np.dtype('<U2')
def test_merge2_rowcount_is_sentinel():
# Test case from RIP-466.
| 89 | 90 | 302 | 19 | 70 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_rowcount_is_sentinel | test_merge2_rowcount_is_sentinel | 6,170 | 6,193 | 6,170 | 6,172 | 5b51f78550c22ebbcc7f255636e668596fbee4ec | bigcode/the-stack | train |
ee848031c300b6c58477514a | train | function | @pytest.mark.parametrize("how", [
'left', 'right', 'inner',
pytest.param('outer', marks=xfail_rip260_outermerge_left_keep)
])
@pytest.mark.parametrize("keep_left", [None, pytest.param('first'), pytest.param('last')])
@pytest.mark.parametrize("keep_right", [None, pytest.param('first'), pytest.param('last')]... | @pytest.mark.parametrize("how", [
'left', 'right', 'inner',
pytest.param('outer', marks=xfail_rip260_outermerge_left_keep)
])
@pytest.mark.parametrize("keep_left", [None, pytest.param('first'), pytest.param('last')])
@pytest.mark.parametrize("keep_right", [None, pytest.param('first'), pytest.param('last')]... | x = rt.Dataset({
'k1': rt.Categorical(['a', 'b', 'c', 'b', 'a', 'a', 'c'], ['a', 'b', 'c', 'd']),
'a': [1, 2, 3, 4, 5, 6, 7]
})
y = rt.Dataset({
'k1': rt.Categorical(['b', 'c', 'd', 'd', 'b', 'd', 'c', 'b', 'f', 'c'], ['a', 'b', 'c', 'd', 'e', 'f']),
'b': [2, 3, 4, 5, 6... | '])
)
@pytest.mark.parametrize("how", [
'left', 'right', 'inner',
pytest.param('outer', marks=xfail_rip260_outermerge_left_keep)
])
@pytest.mark.parametrize("keep_left", [None, pytest.param('first'), pytest.param('last')])
@pytest.mark.parametrize("keep_right", [None, pytest.param('first'), pytest.par... | 97 | 98 | 328 | 94 | 3 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_with_unused_categories | test_merge2_with_unused_categories | 6,122 | 6,140 | 6,122 | 6,128 | 44ac9da2b9dc583d45b725536569971bd8e388f6 | bigcode/the-stack | train |
b453eef73a9dd373150d7243 | train | function | def test_merge_lookup_inplace_single():
foo, bar = TestDataset.sql_semantics()
foo.merge_lookup(
bar,
on=('col1', 'col1'),
suffix='_bar',
keep='first',
inplace=True
)
assert foo.get_nrows() == 6
# +--------+----------+----------+--------+------... | def test_merge_lookup_inplace_single():
| foo, bar = TestDataset.sql_semantics()
foo.merge_lookup(
bar,
on=('col1', 'col1'),
suffix='_bar',
keep='first',
inplace=True
)
assert foo.get_nrows() == 6
# +--------+----------+----------+--------+----------+----------+------------+
# | ... | the right Dataset has keys with multiplicity > 1."""
foo, bar = TestDataset.sql_semantics()
with pytest.raises(ValueError):
rt.rt_merge.merge_lookup(
foo,
bar,
on=('col1', 'col1'),
require_match=True,
suffixes=('_foo', '_bar'),
... | 170 | 171 | 571 | 8 | 162 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_lookup_inplace_single | test_merge_lookup_inplace_single | 6,279 | 6,316 | 6,279 | 6,279 | 5c6c5e5d4ce840faf2cc1ab0dbc44ea531aaee11 | bigcode/the-stack | train |
1b38f029cd1e4ddce498aa1c | train | function | def test_merge2_sql_semantics_leftjoin_single():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_st... | def test_merge2_sql_semantics_leftjoin_single():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
... | (s) and single-key Cats (to verify the Grouping-merging code used by merge works correctly).
],
)
def test_merge2_validate(
left: rt.Dataset, right: rt.Dataset, on, validate: str, keep, should_succeed: bool
):
"""
Test cases for how the validation logic used by 'merge2' works.
"""
# C... | 160 | 160 | 534 | 11 | 149 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_leftjoin_single | test_merge2_sql_semantics_leftjoin_single | 2,239 | 2,308 | 2,239 | 2,239 | fba6e0bbdafb4ed6a464be4e1e3a3ee0bc76aaa6 | bigcode/the-stack | train |
b359b1cbb4c9f8e1f1ec1a7d | train | function | def test_merge2_sql_semantics_rightjoin_single_keep_firstNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.... | def test_merge2_sql_semantics_rightjoin_single_keep_firstNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | (the 'on' cols)
assert_array_equal(result.col1, rt.FA([5, 5, 8, 10, 10, inv], dtype=np.int32))
# Cols from the left Dataset.
assert_array_equal(result.id_foo, rt.FA([2, 2, 3, 5, 5, 6], dtype=np.int32))
assert_array_equal(result.col2_foo, rt.FA([5, 5, inv, 1, 1, 4], dtype=np.int32))
# Cols ... | 255 | 256 | 956 | 14 | 241 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_rightjoin_single_keep_firstNone | test_merge2_sql_semantics_rightjoin_single_keep_firstNone | 3,319 | 3,415 | 3,319 | 3,319 | f78fed09476217fdf99c36af4827277442ebdf24 | bigcode/the-stack | train |
8ae929fcad202aa7422fc7e7 | train | function | @pytest.mark.parametrize("right_on", ['Bar', ['Bar']])
def test_merge_requires_left_on_columns_present(right_on):
# Test that `merge` raises a ValueError if a user calls it and specifies
# a column name in 'left_on' which does not exist in the 'left' Dataset.
(ds1, ds2) = _create_merge_paramverify_dsets... | @pytest.mark.parametrize("right_on", ['Bar', ['Bar']])
def test_merge_requires_left_on_columns_present(right_on):
# Test that `merge` raises a ValueError if a user calls it and specifies
# a column name in 'left_on' which does not exist in the 'left' Dataset.
| (ds1, ds2) = _create_merge_paramverify_dsets()
bad_colname = 'Hello'
assert (
bad_colname not in ds1.keys()
) # Make sure the bad key really isn't in the Dataset
with pytest.raises(ValueError):
rt.merge(ds1, ds2, left_on=bad_colname, right_on=right_on)
| @pytest.mark.parametrize("right_on", ['Bar', ['Bar']])
def test_merge_requires_left_on_columns_present(right_on):
# Test that `merge` raises a ValueError if a user calls it and specifies
# a column name in 'left_on' which does not exist in the 'left' Dataset.
| 65 | 64 | 147 | 65 | 0 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_requires_left_on_columns_present | test_merge_requires_left_on_columns_present | 550 | 562 | 550 | 553 | a286156e31175ed5d04ced55d131a3e9ecf317ca | bigcode/the-stack | train |
a1e19bd9cd2405b1d59d7e36 | train | function | def test_merge2_sql_semantics_innerjoin_multi_keep_lastNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.st... | def test_merge2_sql_semantics_innerjoin_multi_keep_lastNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | +----------+----------+------------+
# 1 row in set (0.0009 sec)
inv = rt.int32.inv
# Intersection cols (the 'on' cols)
assert_array_equal(result.col1, rt.FA([5], dtype=np.int32))
assert_array_equal(result.col2, rt.FA([5], dtype=np.int32))
# Cols from the left Dataset.
assert_arra... | 167 | 168 | 562 | 14 | 153 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_innerjoin_multi_keep_lastNone | test_merge2_sql_semantics_innerjoin_multi_keep_lastNone | 5,503 | 5,566 | 5,503 | 5,503 | 89605e36de9add2534424c61120b3a2c9a070130 | bigcode/the-stack | train |
a182737c948746d1d9ac16fb | train | function | def test_merge2_sql_semantics_innerjoin_single_keep_Nonelast():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.s... | def test_merge2_sql_semantics_innerjoin_single_keep_Nonelast():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
... | _equal(result.col1, rt.FA([5, 5, 8, 10], dtype=np.int32))
# Cols from the left Dataset.
assert_array_equal(result.id_foo, rt.FA([1, 2, 3, 5], dtype=np.int32))
assert_array_equal(result.col2_foo, rt.FA([inv, 5, inv, 1], dtype=np.int32))
# Cols from the right Dataset.
assert_array_equal(resul... | 209 | 210 | 701 | 16 | 193 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_innerjoin_single_keep_Nonelast | test_merge2_sql_semantics_innerjoin_single_keep_Nonelast | 2,941 | 3,006 | 2,941 | 2,941 | 6c89f81ddf2655b0f57e983e0ad8f2ed0a27ba06 | bigcode/the-stack | train |
05e69e2e5e0f3508c05335e0 | train | function | def test_merge2_sql_semantics_rightjoin_multi():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_st... | def test_merge2_sql_semantics_rightjoin_multi():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
... | | NULL | NULL | NULL |
# +--------+----------+----------+--------+----------+----------+------------+
# 6 rows in set (0.0007 sec)
inv = rt.int32.inv
# Intersection cols (the 'on' cols)
assert_array_equal(result.col1, rt.FA([5, 5, 8, inv, 10, inv], dtype=np.int32))
assert_... | 252 | 253 | 846 | 11 | 241 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_rightjoin_multi | test_merge2_sql_semantics_rightjoin_multi | 4,221 | 4,306 | 4,221 | 4,221 | bda8674a42d0643536876e88f396ea416bc88fca | bigcode/the-stack | train |
d9332504ae0e2f75c9af3dba | train | function | @xfail_rip260_outermerge_left_keep
def test_merge2_sql_semantics_outerjoin_multi_keep_firstNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_... | @xfail_rip260_outermerge_left_keep
def test_merge2_sql_semantics_outerjoin_multi_keep_firstNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
fr... | _col2 | bar_id | bar_col1 | bar_col2 | bar_strcol |
# +--------+----------+----------+--------+----------+----------+------------+
# | 2 | 5 | 5 | 8 | 5 | 5 | Lombard |
# +--------+----------+----------+--------+----------+----------+------------+
# 1 row in ... | 255 | 256 | 1,129 | 25 | 230 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_outerjoin_multi_keep_firstNone | test_merge2_sql_semantics_outerjoin_multi_keep_firstNone | 5,569 | 5,655 | 5,569 | 5,570 | e2582ac4da4696e70ed1b19bb46e44dbc8bc61ca | bigcode/the-stack | train |
cabe9b396a9d77456f6fbe7b | train | function | @pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
def test_merge_on_xor_right_on_required(left_on):
# Test that `merge` raises a ValueError if a user calls it without specifying
# either the 'on' or 'right_on' parameters.
(ds1, ds2) = _create_merge_paramverify_dsets()
with pytest.raises(Value... | @pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
def test_merge_on_xor_right_on_required(left_on):
# Test that `merge` raises a ValueError if a user calls it without specifying
# either the 'on' or 'right_on' parameters.
| (ds1, ds2) = _create_merge_paramverify_dsets()
with pytest.raises(ValueError):
rt.merge(ds1, ds2, left_on=left_on)
| _on=right_on)
@pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
def test_merge_on_xor_right_on_required(left_on):
# Test that `merge` raises a ValueError if a user calls it without specifying
# either the 'on' or 'right_on' parameters.
| 64 | 64 | 98 | 59 | 5 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_on_xor_right_on_required | test_merge_on_xor_right_on_required | 540 | 547 | 540 | 543 | d49a416083e64729dd0f5de865b642b0d2749e16 | bigcode/the-stack | train |
41546e3b95e948dcfd0e65d5 | train | function | def test_merge2_sql_semantics_outerjoin_single_keep_Nonelast():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
... | def test_merge2_sql_semantics_outerjoin_single_keep_Nonelast():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
fr... | , 1, 4, 22, 9, inv, inv, inv], dtype=np.int32))
assert_array_equal(
result.team_name, rt.FA([b'Phillies', b'Eagles', b'76ers', b'Flyers', b'Union', b'Wings', b'Fusion', b'Fight', b'', b'', b''])
)
# Cols from the right Dataset.
assert_array_equal(result.id_bar, rt.FA([8, 8, 3, inv, 1, inv... | 255 | 256 | 900 | 16 | 239 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_outerjoin_single_keep_Nonelast | test_merge2_sql_semantics_outerjoin_single_keep_Nonelast | 3,089 | 3,163 | 3,089 | 3,089 | 84034772a836196fc7ff3e5f085ede1fc0964692 | bigcode/the-stack | train |
9f70d4ac626e9bd7dd02407e | train | function | def test_merge2_sql_semantics_innerjoin_single_keep_firstlast():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.... | def test_merge2_sql_semantics_innerjoin_single_keep_firstlast():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | # Intersection cols (the 'on' cols)
assert_array_equal(result.col1, rt.FA([10, 8, inv, 5], dtype=np.int32))
# Cols from the left Dataset.
assert_array_equal(result.id_foo, rt.FA([5, 3, inv, 1], dtype=np.int32))
assert_array_equal(result.col2_foo, rt.FA([1, inv, inv, inv], dtype=np.int32))
... | 214 | 215 | 717 | 14 | 200 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_innerjoin_single_keep_firstlast | test_merge2_sql_semantics_innerjoin_single_keep_firstlast | 3,986 | 4,059 | 3,986 | 3,986 | 7c87d04eb52986b88552d61d384e8ccff943494b | bigcode/the-stack | train |
186a2d50cc3725ccec7377dd | train | function | @pytest.mark.parametrize("on", [
['f', 'g'],
['g', 'f']
])
def test_merge2_outer_on_multikey_with_string(on):
ds1 = rt.Dataset({'f': ['1', '2', '3', '4'], 'g': [1, 2, 3, 4], 'h1': [1, 1, 1, 1]})
ds2 = rt.Dataset({'f': ['2', '3', '4', '5'], 'g': [2, 3, 4, 5], 'h2': [2, 2, 2, 2]})
# Just veri... | @pytest.mark.parametrize("on", [
['f', 'g'],
['g', 'f']
])
def test_merge2_outer_on_multikey_with_string(on):
| ds1 = rt.Dataset({'f': ['1', '2', '3', '4'], 'g': [1, 2, 3, 4], 'h1': [1, 1, 1, 1]})
ds2 = rt.Dataset({'f': ['2', '3', '4', '5'], 'g': [2, 3, 4, 5], 'h2': [2, 2, 2, 2]})
# Just verifying this succeeds (and does not fail with an exception/error).
# In riptable 1.0.21 and earlier, this failed due to ... | would have been
# broken if/when cumsum was modified to respect integer invalids/NA values.
assert rt.all(result['foo'].isnotnan())
@pytest.mark.parametrize("on", [
['f', 'g'],
['g', 'f']
])
def test_merge2_outer_on_multikey_with_string(on):
| 69 | 70 | 235 | 34 | 35 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_outer_on_multikey_with_string | test_merge2_outer_on_multikey_with_string | 6,196 | 6,208 | 6,196 | 6,200 | 2dab89a894a24667a09d1bb24216c75bbe2715c8 | bigcode/the-stack | train |
8fae67255d5af9d22ef2bf8e | train | function | def test_merge2_sql_semantics_rightjoin_single_keep_Nonelast():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.s... | def test_merge2_sql_semantics_rightjoin_single_keep_Nonelast():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
... | 1, rt.FA([10, 8, inv, 5, 5], dtype=np.int32))
# Cols from the left Dataset.
assert_array_equal(result.id_foo, rt.FA([5, 3, inv, 1, 2], dtype=np.int32))
assert_array_equal(result.col2_foo, rt.FA([1, inv, inv, inv, 5], dtype=np.int32))
# Cols from the right Dataset.
assert_array_equal(result.... | 224 | 225 | 752 | 16 | 208 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_rightjoin_single_keep_Nonelast | test_merge2_sql_semantics_rightjoin_single_keep_Nonelast | 2,798 | 2,868 | 2,798 | 2,798 | 8145bcb80b430f212673ca0449d7f0897301005a | bigcode/the-stack | train |
ee3f7225d0c160a5d01cee47 | train | function | def _create_merge_column_compat_rules_integer_cases(
left_rowcount: int, right_rowcount: int
) -> list:
cases = []
types = [np.dtype(x) for x in np.typecodes['AllInteger']]
for x in types:
for y in types:
x_step, y_step = 2, 3
cases.append(
pytest... | def _create_merge_column_compat_rules_integer_cases(
left_rowcount: int, right_rowcount: int
) -> list:
| cases = []
types = [np.dtype(x) for x in np.typecodes['AllInteger']]
for x in types:
for y in types:
x_step, y_step = 2, 3
cases.append(
pytest.param(
rt.FA(
np.arange(
start=1,
... | Error):
rt.merge(
ds1, ds2, left_on=left_on, right_on='Baz', suffixes=('_x', right_suffix)
)
def _create_merge_column_compat_rules_integer_cases(
left_rowcount: int, right_rowcount: int
) -> list:
| 63 | 64 | 191 | 28 | 35 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | _create_merge_column_compat_rules_integer_cases | _create_merge_column_compat_rules_integer_cases | 729 | 758 | 729 | 731 | 3e0e571796cea53ded27214ac3453a110c1ee35d | bigcode/the-stack | train |
871d7fb1a8b87f70f08c0f76 | train | function | def _create_merge_paramverify_dsets() -> Tuple[rt.Dataset, rt.Dataset]:
ds1 = rt.Dataset()
ds1['Foo'] = [0, 1, 4, 6, 8, 9, 11, 16, 19, 30]
ds1['Bar'] = [10, 12, 15, 11, 10, 9, 13, 7, 9, 10]
# ds2 purposely has a different number of rows from ds1;
# this ensures we're not making assumptions th... | def _create_merge_paramverify_dsets() -> Tuple[rt.Dataset, rt.Dataset]:
| ds1 = rt.Dataset()
ds1['Foo'] = [0, 1, 4, 6, 8, 9, 11, 16, 19, 30]
ds1['Bar'] = [10, 12, 15, 11, 10, 9, 13, 7, 9, 10]
# ds2 purposely has a different number of rows from ds1;
# this ensures we're not making assumptions that the Datasets have the same
# number of rows, since that's going t... |
# is the product of their individual multiplicities.
result[key] = lcount * rcount
else:
# Just copy the key and it's count over.
result[key] = rcount
return result
def _create_merge_paramverify_dsets() -> Tuple[rt.Dataset, rt.... | 67 | 67 | 225 | 18 | 48 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | _create_merge_paramverify_dsets | _create_merge_paramverify_dsets | 497 | 509 | 497 | 497 | 93f08d1757e802b773c01826f4ac7b1a38db6265 | bigcode/the-stack | train |
9db0f1ebb0850199f43d2af4 | train | function | def test_merge2_sql_semantics_outerjoin_single_keep_Nonefirst():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
... | def test_merge2_sql_semantics_outerjoin_single_keep_Nonefirst():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
fr... | |
# +--------+----------+----------+--------+----------+----------+------------+
# 4 rows in set (0.0010 sec)
inv = rt.int32.inv
# Intersection cols (the 'on' cols)
assert_array_equal(result.col1, rt.FA([5, 5, 8, 10], dtype=np.int32))
# Cols from the left Dataset.
assert_ar... | 255 | 256 | 904 | 14 | 241 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_outerjoin_single_keep_Nonefirst | test_merge2_sql_semantics_outerjoin_single_keep_Nonefirst | 3,009 | 3,086 | 3,009 | 3,009 | f75db51f4822ef2fc16c2e0272e52653cb664dea | bigcode/the-stack | train |
ce57060795977472239d77a5 | train | function | def test_merge2_sql_semantics_innerjoin_single_keep_firstNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.... | def test_merge2_sql_semantics_innerjoin_single_keep_firstNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | .col2_foo, rt.FA([1, 1, inv, inv, inv, inv, inv, 5, 5], dtype=np.int32)
)
# Cols from the right Dataset.
assert_array_equal(
result.id_bar, rt.FA([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.int32)
)
assert_array_equal(
result.col2_bar, rt.FA([4, inv, inv, 3, inv, inv, 1, 5, inv], ... | 224 | 225 | 752 | 14 | 210 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_innerjoin_single_keep_firstNone | test_merge2_sql_semantics_innerjoin_single_keep_firstNone | 3,516 | 3,584 | 3,516 | 3,516 | 064ae3ecf1b0d9b4c0bccd622cb7b7ae249dbcd0 | bigcode/the-stack | train |
230f3c51f362de470352f8b4 | train | function | def test_merge2_sql_semantics_rightjoin_multi_keep_Nonelast():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.st... | def test_merge2_sql_semantics_rightjoin_multi_keep_Nonelast():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
... | 1, rt.FA([10, 10, 8, inv, inv, inv, 5, 5], dtype=np.int32)
)
assert_array_equal(
result.col2, rt.FA([4, inv, inv, 3, inv, 1, 5, inv], dtype=np.int32)
)
# Cols from the left Dataset.
assert_array_equal(
result.id_foo, rt.FA([inv, inv, inv, inv, inv, inv, 2, inv], dtype=np.int... | 255 | 256 | 886 | 16 | 239 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_rightjoin_multi_keep_Nonelast | test_merge2_sql_semantics_rightjoin_multi_keep_Nonelast | 4,688 | 4,778 | 4,688 | 4,688 | 440a9475834f95ce4a82a3517e8a4b6b914b70fd | bigcode/the-stack | train |
23fb8d4b3b7c98a47d375b9f | train | function | def test_merge2_sql_semantics_leftjoin_single_keep_firstlast():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.s... | def test_merge2_sql_semantics_leftjoin_single_keep_firstlast():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | , 9, 11, 8, 9, 11, 3, inv, 1, 2, inv, inv, inv, 4, 5, 6, 7, 10, 12], dtype=np.int32))
assert_array_equal(result.col2_bar, rt.FA([5, inv, 5, 5, inv, 5, inv, inv, 4, inv, inv, inv, inv, 3, inv, inv, 1, 9, 13], dtype=np.int32))
assert_array_equal(
result.strcol, rt.FA([b'Lombard', b'Sansom', b'Arch', b'... | 226 | 227 | 757 | 14 | 212 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_leftjoin_single_keep_firstlast | test_merge2_sql_semantics_leftjoin_single_keep_firstlast | 3,830 | 3,904 | 3,830 | 3,830 | 7f632cceff2ad1797f00c32f56f4605934b2a9e9 | bigcode/the-stack | train |
97a6cba5882a12434325224f | train | function | @pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
@pytest.mark.parametrize("right_on", ['Baz', ['Baz']])
def test_merge_columns_overlap_errorif_left_suffix_collision(left_on, right_on):
# Test that `merge` raises a ValueError if it detects a naming collision remaining
# in the non-key columns being sele... | @pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
@pytest.mark.parametrize("right_on", ['Baz', ['Baz']])
def test_merge_columns_overlap_errorif_left_suffix_collision(left_on, right_on):
# Test that `merge` raises a ValueError if it detects a naming collision remaining
# in the non-key columns being sele... | (ds1, ds2) = _create_merge_paramverify_dsets()
overlapping_colname = 'Bar'
left_suffix = '_x'
colliding_name = f'{overlapping_colname}{left_suffix}'
ds1[colliding_name] = rt.arange(len(ds1.Bar))
# Verify the test data is self-consistent before running the code we want to test.
asse... | _on, suffixes=('_x', '_x'))
@pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
@pytest.mark.parametrize("right_on", ['Baz', ['Baz']])
def test_merge_columns_overlap_errorif_left_suffix_collision(left_on, right_on):
# Test that `merge` raises a ValueError if it detects a naming collision remaining
# in th... | 107 | 108 | 360 | 96 | 11 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_columns_overlap_errorif_left_suffix_collision | test_merge_columns_overlap_errorif_left_suffix_collision | 659 | 691 | 659 | 664 | 968ddbf611a4826add087e741add09b34d81bc31 | bigcode/the-stack | train |
85dc7dc792a08dc6abf05af8 | train | function | def test_merge2_sql_semantics_leftjoin_single_keep_Nonefirst():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.s... | def test_merge2_sql_semantics_leftjoin_single_keep_Nonefirst():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
... | 2, inv, inv, inv, 4, 5, 6, 7, 10, 12], dtype=np.int32))
assert_array_equal(
result.col2_bar, rt.FA([5, inv, 5, 5, inv, 5, inv, inv, 4, inv, inv, inv, inv, 3, inv, inv, 1, 9, 13], dtype=np.int32)
)
assert_array_equal(
result.strcol,
rt.FA(
[
b'Lomb... | 236 | 237 | 791 | 14 | 222 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_leftjoin_single_keep_Nonefirst | test_merge2_sql_semantics_leftjoin_single_keep_Nonefirst | 2,578 | 2,647 | 2,578 | 2,578 | a1094bc6ad7e8b9592186111deb7e0e0989ddc45 | bigcode/the-stack | train |
1a1728544d15d47d065957cd | train | function | @xfail_rip260_outermerge_left_keep
def test_merge2_sql_semantics_outerjoin_single_keep_firstlast():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar... | @xfail_rip260_outermerge_left_keep
def test_merge2_sql_semantics_outerjoin_single_keep_firstlast():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
fr... | 10 | NULL | Pine |
# +--------+----------+----------+--------+----------+----------+------------+
# 3 rows in set (0.0011 sec)
inv = rt.int32.inv
# Intersection cols (the 'on' cols)
assert_array_equal(result.col1, rt.FA([5, 8, 10], dtype=np.int32))
# Cols from the left Datas... | 255 | 256 | 1,126 | 25 | 230 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_outerjoin_single_keep_firstlast | test_merge2_sql_semantics_outerjoin_single_keep_firstlast | 4,062 | 4,150 | 4,062 | 4,063 | fa84fdf0f43a633c092d1f3f8a5d49b419ac57bb | bigcode/the-stack | train |
9cbc947823d28c9df92107e2 | train | class | class BagHelpers:
"""
Test helper methods for bags/multisets (based on the `Counter` class).
These methods implement relational/algebraic operations on bags/multisets; they're used
for verifying that join results have the correct/expected multiplicities for the keys.
"""
@staticmethod
... | class BagHelpers:
| """
Test helper methods for bags/multisets (based on the `Counter` class).
These methods implement relational/algebraic operations on bags/multisets; they're used
for verifying that join results have the correct/expected multiplicities for the keys.
"""
@staticmethod
def from_group... | 1]
masked_s2 = merge_strings.d2_pnl_y[notnanmask_str2]
assert_array_equal(masked_c1, masked_s1)
assert_array_equal(masked_c2, masked_s2)
def test_merge_dict_backed_categorical(self):
c1 = rt.Categorical([1, 2, 3], categories={1: 'a', 2: 'b', 3: 'c'})
c2 = c1[[True, ... | 248 | 249 | 830 | 4 | 244 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | BagHelpers | BagHelpers | 401 | 494 | 401 | 401 | fc30298dc78cebcd5c1f9e1844b3387ea0accdac | bigcode/the-stack | train |
1b069e5316ffb7f9fcd52c7a | train | function | @pytest.mark.xfail(
reason="RIP-260: This test fails due to a difference in the ordering of the returned rows as compared to the test data. Need to verify the test data to determine which one is correct."
)
def test_merge2_sql_semantics_leftjoin_single_keep_lastNone():
"""
Test that merge2 matches the ... | @pytest.mark.xfail(
reason="RIP-260: This test fails due to a difference in the ordering of the returned rows as compared to the test data. Need to verify the test data to determine which one is correct."
)
def test_merge2_sql_semantics_leftjoin_single_keep_lastNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | Dataset.
assert_array_equal(result.id_foo, rt.FA([1, 1, 3, 4, 5, 5], dtype=np.int32))
assert_array_equal(result.col2_foo, rt.FA([inv, inv, inv, 1, 1, 1], dtype=np.int32))
# Cols from the right Dataset.
assert_array_equal(result.id_bar, rt.FA([8, 9, 3, inv, 1, 2], dtype=np.int32))
assert_arra... | 254 | 255 | 851 | 62 | 192 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_leftjoin_single_keep_lastNone | test_merge2_sql_semantics_leftjoin_single_keep_lastNone | 3,241 | 3,316 | 3,241 | 3,244 | 295a71359a4c68921d8283913f290eeb3212394d | bigcode/the-stack | train |
9b4ae6c83d98ac7bf11bd12d | train | function | def test_merge2_outer_overlapping_on_column_has_common_type():
x = rt.Dataset({'k1': rt.FA(['a', 'b', 'c'], unicode=True), 'a': [1, 2, 3]})
y = rt.Dataset({'k1': rt.FA(['b', 'c', 'dd']), 'b': [2, 3, 4]})
assert x.k1.dtype.kind != y.k1.dtype.kind
assert x.k1.dtype.itemsize != y.k1.dtype.itemsize
... | def test_merge2_outer_overlapping_on_column_has_common_type():
| x = rt.Dataset({'k1': rt.FA(['a', 'b', 'c'], unicode=True), 'a': [1, 2, 3]})
y = rt.Dataset({'k1': rt.FA(['b', 'c', 'dd']), 'b': [2, 3, 4]})
assert x.k1.dtype.kind != y.k1.dtype.kind
assert x.k1.dtype.itemsize != y.k1.dtype.itemsize
result = rt.merge2(x, y, on=['k1'], how='outer')
asser... | , 6, 7, 8, 9, 10, 11]
})
result = rt.merge2(x, y, on=['k1'], how='outer')
assert result.get_nrows() == 19
def test_merge2_outer_overlapping_on_column_has_common_type():
| 64 | 64 | 157 | 13 | 50 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_outer_overlapping_on_column_has_common_type | test_merge2_outer_overlapping_on_column_has_common_type | 6,157 | 6,167 | 6,157 | 6,157 | ac8344cc5c4b617f1aa18eacda801c6541d60913 | bigcode/the-stack | train |
2b49b9d563103aedbb9ae569 | train | function | def test_merge2_sql_semantics_outerjoin_single():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 a... | def test_merge2_sql_semantics_outerjoin_single():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
fr... | , 10], dtype=np.int32))
# Cols from the left Dataset.
assert_array_equal(result.id_foo, rt.FA([1, 1, 2, 2, 3, 5, 5], dtype=np.int32))
assert_array_equal(
result.col2_foo, rt.FA([inv, inv, 5, 5, inv, 1, 1], dtype=np.int32)
)
# Cols from the right Dataset.
assert_array_equal(res... | 255 | 256 | 1,192 | 11 | 244 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_outerjoin_single | test_merge2_sql_semantics_outerjoin_single | 2,453 | 2,575 | 2,453 | 2,453 | 9bc7681339c7fa67b8ebbf54707c74d1cf7fe028 | bigcode/the-stack | train |
38a0869fa7b109e8cff485d8 | train | function | def test_merge2_sql_semantics_innerjoin_multi_keep_firstNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.s... | def test_merge2_sql_semantics_innerjoin_multi_keep_firstNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | , inv, inv, inv, inv, inv, 2, inv], dtype=np.int32),
)
# Cols from the right Dataset.
assert_array_equal(
result.id_bar, rt.FA([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.int32)
)
assert_array_equal(
result.strcol,
rt.FA(
[
b'Chestnut',
... | 167 | 168 | 562 | 14 | 153 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_innerjoin_multi_keep_firstNone | test_merge2_sql_semantics_innerjoin_multi_keep_firstNone | 5,437 | 5,500 | 5,437 | 5,437 | f72e8317c6cd36a9cd331a07dc2fa989607f170b | bigcode/the-stack | train |
688d94090cbb1dcc3ce908ec | train | function | def test_merge2_sql_semantics_rightjoin_multi_keep_lastNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.st... | def test_merge2_sql_semantics_rightjoin_multi_keep_lastNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | , inv, inv, 5, 5], dtype=np.int32)
)
assert_array_equal(
result.col2, rt.FA([4, inv, inv, 3, inv, inv, 1, 5, inv], dtype=np.int32)
)
# Cols from the left Dataset.
assert_array_equal(
result.id_foo,
rt.FA([inv, inv, inv, inv, inv, inv, inv, 2, inv], dtype=np.int32),
... | 255 | 256 | 927 | 14 | 241 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_rightjoin_multi_keep_lastNone | test_merge2_sql_semantics_rightjoin_multi_keep_lastNone | 5,339 | 5,434 | 5,339 | 5,339 | 47b1d64f1c0c139d977b0bc98f15691e2d59a64f | bigcode/the-stack | train |
25663a32089da26ca4f45406 | train | function | @pytest.mark.parametrize("left_on", ['Bar', ['Bar']])
def test_merge_requires_right_on_columns_present(left_on):
# Test that `merge` raises a ValueError if a user calls it and specifies
# a column name in 'right_on' which does not exist in the 'right' Dataset.
(ds1, ds2) = _create_merge_paramverify_dset... | @pytest.mark.parametrize("left_on", ['Bar', ['Bar']])
def test_merge_requires_right_on_columns_present(left_on):
# Test that `merge` raises a ValueError if a user calls it and specifies
# a column name in 'right_on' which does not exist in the 'right' Dataset.
| (ds1, ds2) = _create_merge_paramverify_dsets()
bad_colname = 'Hello'
assert (
bad_colname not in ds2.keys()
) # Make sure the bad key really isn't in the Dataset
with pytest.raises(ValueError):
rt.merge(ds1, ds2, left_on=left_on, right_on=bad_colname)
with pytest.ra... | @pytest.mark.parametrize("left_on", ['Bar', ['Bar']])
def test_merge_requires_right_on_columns_present(left_on):
# Test that `merge` raises a ValueError if a user calls it and specifies
# a column name in 'right_on' which does not exist in the 'right' Dataset.
| 65 | 64 | 176 | 65 | 0 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_requires_right_on_columns_present | test_merge_requires_right_on_columns_present | 565 | 580 | 565 | 568 | e91c5e2ff4658ac2a0b415adb93ca70116a6120c | bigcode/the-stack | train |
f49a0f7850f824fe727682e5 | train | function | def test_merge2_sql_semantics_outerjoin_multi():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as... | def test_merge2_sql_semantics_outerjoin_multi():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
fr... | ------------+
# | foo_id | foo_col1 | foo_col2 | bar_id | bar_col1 | bar_col2 | bar_strcol |
# +--------+----------+----------+--------+----------+----------+------------+
# | 2 | 5 | 5 | 8 | 5 | 5 | Lombard |
# +--------+----------+----------+--------+------... | 255 | 256 | 1,038 | 11 | 244 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_outerjoin_multi | test_merge2_sql_semantics_outerjoin_multi | 4,365 | 4,442 | 4,365 | 4,365 | 2840f6eb9e68341dc18337831e14524e28a52c24 | bigcode/the-stack | train |
244547017535002ad88c0bd8 | train | function | @xfail_rip260_outermerge_left_keep
def test_merge2_sql_semantics_outerjoin_single_keep_firstNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar... | @xfail_rip260_outermerge_left_keep
def test_merge2_sql_semantics_outerjoin_single_keep_firstNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
fr... | = rt.int32.inv
# Intersection cols (the 'on' cols)
assert_array_equal(result.col1, rt.FA([5, 5, 8, 10, 10], dtype=np.int32))
# Cols from the left Dataset.
assert_array_equal(result.id_foo, rt.FA([2, 2, 3, 5, 5], dtype=np.int32))
assert_array_equal(result.col2_foo, rt.FA([5, 5, inv, 1, 1], dt... | 255 | 256 | 1,046 | 25 | 230 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_outerjoin_single_keep_firstNone | test_merge2_sql_semantics_outerjoin_single_keep_firstNone | 3,658 | 3,737 | 3,658 | 3,659 | c795bedf6817eb14338ae7ffd5db655e88785bf3 | bigcode/the-stack | train |
54a81be0972e43a1290dfeaa | train | function | def test_merge2_outer_with_unused_categories():
x = rt.Dataset({
'k1': rt.Categorical(['a', 'b', 'c', 'b', 'a', 'a', 'c'], ['a', 'b', 'c', 'd']),
'a': [1, 2, 3, 4, 5, 6, 7]
})
y = rt.Dataset({
'k1': rt.Categorical(['b', 'c', 'd', 'd', 'b', 'd', 'c', 'b', 'f', 'c'], ['a', 'b', '... | def test_merge2_outer_with_unused_categories():
| x = rt.Dataset({
'k1': rt.Categorical(['a', 'b', 'c', 'b', 'a', 'a', 'c'], ['a', 'b', 'c', 'd']),
'a': [1, 2, 3, 4, 5, 6, 7]
})
y = rt.Dataset({
'k1': rt.Categorical(['b', 'c', 'd', 'd', 'b', 'd', 'c', 'b', 'f', 'c'], ['a', 'b', 'c', 'd', 'e', 'f']),
'b': [2, 3, 4, 5, 6... | check the function succeeds without failing.
# TODO: Add more-robust tests that verify the result to make sure it's correct.
_ = rt.merge2(x, y, on=['k1'], how=how, keep=(keep_left, keep_right))
def test_merge2_outer_with_unused_categories():
| 63 | 64 | 213 | 9 | 54 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_outer_with_unused_categories | test_merge2_outer_with_unused_categories | 6,143 | 6,154 | 6,143 | 6,143 | ebee999e51502499e3ddc639c79bcabc9b070622 | bigcode/the-stack | train |
599dd00d11e100884cba6d28 | train | function | def test_merge_lookup_fails_with_nonunique_right_keys():
"""Check that merge_lookup() fails when the right Dataset has keys with multiplicity > 1."""
foo, bar = TestDataset.sql_semantics()
with pytest.raises(ValueError):
rt.rt_merge.merge_lookup(
foo,
bar,
... | def test_merge_lookup_fails_with_nonunique_right_keys():
| """Check that merge_lookup() fails when the right Dataset has keys with multiplicity > 1."""
foo, bar = TestDataset.sql_semantics()
with pytest.raises(ValueError):
rt.rt_merge.merge_lookup(
foo,
bar,
on=('col1', 'col1'),
require_match=True,
... | share the same physical memory as the original array."
# Also verify that the logic used for copy=False to create the array view
# preserves the array subclass (e.g. rt.Date).
assert type(left_col) == type(result_col)
def test_merge_lookup_fails_with_nonunique_right_keys():
| 64 | 64 | 92 | 12 | 52 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_lookup_fails_with_nonunique_right_keys | test_merge_lookup_fails_with_nonunique_right_keys | 6,250 | 6,261 | 6,250 | 6,250 | d3adc5c57265892122f8dc3f09e7d03dd2064f30 | bigcode/the-stack | train |
4cf53b34bcebfba38ff1389d | train | function | @pytest.mark.parametrize(
"left_keycols,right_keycols,is_allowed,is_hard_error",
itertools.chain.from_iterable(
[
_create_merge_column_compat_rules_integer_cases(10, 8),
_merge_column_compat_rules_cases,
]
),
)
def test_merge_columns_compat_rules(
left_k... | @pytest.mark.parametrize(
"left_keycols,right_keycols,is_allowed,is_hard_error",
itertools.chain.from_iterable(
[
_create_merge_column_compat_rules_integer_cases(10, 8),
_merge_column_compat_rules_cases,
]
),
)
def test_merge_columns_compat_rules(
left_k... | (ds1, ds2) = _create_merge_paramverify_dsets()
# Add the left key and right key column(s) to the corresponding Datasets.
def add_keycols_to_dataset(ds, colname_base: str, keycols) -> List[str]:
if isinstance(keycols, (list, tuple)):
colnames = []
for idx, keycol in enu... | Categorical's individual keys?
# How does this mesh with using multiple columns in the join key?
#
]
@pytest.mark.parametrize(
"left_keycols,right_keycols,is_allowed,is_hard_error",
itertools.chain.from_iterable(
[
_create_merge_column_compat_rules_integer_cases(10, 8... | 140 | 141 | 473 | 115 | 25 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_columns_compat_rules | test_merge_columns_compat_rules | 1,086 | 1,130 | 1,086 | 1,099 | 0502e4ff3bdbf2019b8dbfda28fb6fa90ec68e37 | bigcode/the-stack | train |
460368312bb0e5aff600544f | train | function | def test_merge2_sql_semantics_innerjoin_multi_keep_firstlast():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
... | def test_merge2_sql_semantics_innerjoin_multi_keep_firstlast():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
fr... | inv], dtype=np.int32))
assert_array_equal(
result.team_name,
rt.FA([b'', b'', b'', b'', b'', b'', b'', b'', b'Eagles', b''])
)
# Cols from the right Dataset.
assert_array_equal(result.id_bar, rt.FA([1, 2, 3, 4, 6, 7, 9, 10, 11, 12], dtype=np.int32))
assert_array_equal(
... | 179 | 180 | 602 | 14 | 165 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_innerjoin_multi_keep_firstlast | test_merge2_sql_semantics_innerjoin_multi_keep_firstlast | 5,940 | 6,016 | 5,940 | 5,940 | 3002f57f7b1e2f37740ac8b5b86dcc95fa93943f | bigcode/the-stack | train |
f58902f0a22b1abd84689bc5 | train | function | @pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
@pytest.mark.parametrize("right_on", ['Baz', ['Baz']])
def test_merge_columns_overlap_errorif_right_suffix_collision(left_on, right_on):
# Test that `merge` raises a ValueError if it detects a naming collision remaining
# in the non-key columns being sel... | @pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
@pytest.mark.parametrize("right_on", ['Baz', ['Baz']])
def test_merge_columns_overlap_errorif_right_suffix_collision(left_on, right_on):
# Test that `merge` raises a ValueError if it detects a naming collision remaining
# in the non-key columns being sel... | (ds1, ds2) = _create_merge_paramverify_dsets()
overlapping_colname = 'Bar'
right_suffix = '_y'
colliding_name = f'{overlapping_colname}{right_suffix}'
ds2[colliding_name] = rt.arange(len(ds2.Bar))
# Verify the test data is self-consistent before running the code we want to test.
as... | es=(left_suffix, '_y')
)
@pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
@pytest.mark.parametrize("right_on", ['Baz', ['Baz']])
def test_merge_columns_overlap_errorif_right_suffix_collision(left_on, right_on):
# Test that `merge` raises a ValueError if it detects a naming collision remaining
... | 106 | 107 | 359 | 96 | 10 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_columns_overlap_errorif_right_suffix_collision | test_merge_columns_overlap_errorif_right_suffix_collision | 694 | 726 | 694 | 699 | 67b2f301bc98e0d6e1f3e236cd03cdecabb5f038 | bigcode/the-stack | train |
e5d3c01a6476adb2d5d71473 | train | function | @pytest.mark.xfail(
reason="RIP-260: This test currently fails, but the test data used here may itself be incorrect. Need to verify the test data to determine how to proceed.",
strict=True
)
def test_merge2_sql_semantics_rightjoin_multi_keep_Nonefirst():
"""
Test that merge2 matches the following ... | @pytest.mark.xfail(
reason="RIP-260: This test currently fails, but the test data used here may itself be incorrect. Need to verify the test data to determine how to proceed.",
strict=True
)
def test_merge2_sql_semantics_rightjoin_multi_keep_Nonefirst():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
... | .int32.inv
# Intersection cols (the 'on' cols)
assert_array_equal(result.col1, rt.FA([5, 5, 8, inv, 10, inv], dtype=np.int32))
assert_array_equal(result.col2, rt.FA([inv, 5, inv, 1, 1, 4], dtype=np.int32))
# Cols from the left Dataset.
assert_array_equal(result.id_foo, rt.FA([1, 2, 3, 4, 5, 6... | 255 | 256 | 930 | 60 | 195 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_rightjoin_multi_keep_Nonefirst | test_merge2_sql_semantics_rightjoin_multi_keep_Nonefirst | 4,591 | 4,685 | 4,591 | 4,595 | e0c199d4787378f85c33a50b8ce8b6f78e5a86f5 | bigcode/the-stack | train |
1edb0e568a1c001b77f5981e | train | class | class MergeAsofTest(unittest.TestCase):
def test_merge_asof(self):
def check_merge_asof(ds, ds1, ds2):
# print(ds)
self.assertIsInstance(ds, rt.Dataset)
self.assertEqual(ds.shape[0], ds1.shape[0])
self.assertEqual(ds.shape[1], ds1.shape[1] + ds2.shape[1]... | class MergeAsofTest(unittest.TestCase):
| def test_merge_asof(self):
def check_merge_asof(ds, ds1, ds2):
# print(ds)
self.assertIsInstance(ds, rt.Dataset)
self.assertEqual(ds.shape[0], ds1.shape[0])
self.assertEqual(ds.shape[1], ds1.shape[1] + ds2.shape[1])
assert_array_equal(ds.A._n... | | 4 | NULL | NULL | NULL | NULL |
# +--------+----------+----------+--------+----------+----------+------------+
# 6 rows in set (0.0016 sec)
inv = rt.int32.inv
# Intersection cols (the 'on' cols)
assert_array_equal(foo.col1, rt.FA([5, 5, 8, inv, 10, inv], dtype=np.int... | 255 | 256 | 1,771 | 9 | 246 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | MergeAsofTest | MergeAsofTest | 6,359 | 6,510 | 6,359 | 6,359 | c47ad4ff4885e9cc66ad5d66033209b631139ebd | bigcode/the-stack | train |
f69f1209d41c7c9fc5259aec | train | function | @pytest.mark.parametrize(
"left,right,on,validate,keep,should_succeed",
[
# Validate = m:m, Keep = None
pytest.param(
rt.Dataset({'a': [1, 2, 3]}),
rt.Dataset({'a': [1, 3, 4], 'b': [10, 30, 40]}),
'a',
'm:m',
None,
... | @pytest.mark.parametrize(
"left,right,on,validate,keep,should_succeed",
[
# Validate = m:m, Keep = None
pytest.param(
rt.Dataset({'a': [1, 2, 3]}),
rt.Dataset({'a': [1, 3, 4], 'b': [10, 30, 40]}),
'a',
'm:m',
None,
... | """
Test cases for how the validation logic used by 'merge2' works.
"""
# Call the validation function, checking for expected (and unexpected) failure.
if should_succeed:
rt.merge2(left, right, on=on, validate=validate, keep=keep)
else:
with pytest.raises(ValueError):
... | @pytest.mark.parametrize(
"left,right,on,validate,keep,should_succeed",
[
# Validate = m:m, Keep = None
pytest.param(
rt.Dataset({'a': [1, 2, 3]}),
rt.Dataset({'a': [1, 3, 4], 'b': [10, 30, 40]}),
'a',
'm:m',
None,
... | 3,533 | 256 | 3,626 | 3,533 | 0 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_validate | test_merge2_validate | 1,895 | 2,236 | 1,895 | 2,225 | 8a739b79626572f0693f5109063f907e81e92862 | bigcode/the-stack | train |
e97b9b2516ad8731c07c8aa6 | train | function | def test_merge2_multikey_join_with_cats():
"""
Test how merge2 operates on multi-key-column joins with one or more Categorical columns.
"""
left_ds = rt.Dataset()
left_ds['InkColor'] = rt.Cat(['Cyan', 'Magenta', 'Yellow', 'Black', 'Magenta', 'Cyan', 'Black', 'Yellow'])
left_ds['CartridgeIn... | def test_merge2_multikey_join_with_cats():
| """
Test how merge2 operates on multi-key-column joins with one or more Categorical columns.
"""
left_ds = rt.Dataset()
left_ds['InkColor'] = rt.Cat(['Cyan', 'Magenta', 'Yellow', 'Black', 'Magenta', 'Cyan', 'Black', 'Yellow'])
left_ds['CartridgeInstallDate'] = rt.Date(['2019-06-19', '2019-0... | (merge_result)
#assert len(filt_both_merge_result) <= len(filt_left_merge_result)
#assert len(filt_both_merge_result) <= len(filt_right_merge_result)
else:
assert len(filt_left_merge_result) <= len(merge_result)
assert len(filt_right_merge_result) <= len(merge_result)
... | 122 | 122 | 408 | 11 | 111 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_multikey_join_with_cats | test_merge2_multikey_join_with_cats | 1,833 | 1,854 | 1,833 | 1,833 | b7fcfe11a6c173de9119824fe5b5e734f273fa13 | bigcode/the-stack | train |
7990f2244159173d29dcea2f | train | function | def test_merge_on_and_left_on_disallowed():
# Test that `merge` raises a ValueError if a user calls it by specifying both
# the 'on' and 'left_on' parameters.
(ds1, ds2) = _create_merge_paramverify_dsets()
with pytest.raises(ValueError):
rt.merge(ds1, ds2, on='Bar', left_on='Foo')
| def test_merge_on_and_left_on_disallowed():
# Test that `merge` raises a ValueError if a user calls it by specifying both
# the 'on' and 'left_on' parameters.
| (ds1, ds2) = _create_merge_paramverify_dsets()
with pytest.raises(ValueError):
rt.merge(ds1, ds2, on='Bar', left_on='Foo')
| , 24, 25, 26, 27]
return ds1, ds2
def test_merge_on_and_left_on_disallowed():
# Test that `merge` raises a ValueError if a user calls it by specifying both
# the 'on' and 'left_on' parameters.
| 64 | 64 | 85 | 43 | 20 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_on_and_left_on_disallowed | test_merge_on_and_left_on_disallowed | 512 | 518 | 512 | 514 | fb2f7f00c650097ba580501a9ab26026bd16acf9 | bigcode/the-stack | train |
e5d7860cb2af1a7dd0c09ff5 | train | function | @pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
@pytest.mark.parametrize("right_on", ['Baz', ['Baz']])
def test_merge_requires_columns_left_columns_present(left_on, right_on):
# Test that `merge` raises a ValueError if a user calls it and specifies
# a column name in 'columns_left' which does not exis... | @pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
@pytest.mark.parametrize("right_on", ['Baz', ['Baz']])
def test_merge_requires_columns_left_columns_present(left_on, right_on):
# Test that `merge` raises a ValueError if a user calls it and specifies
# a column name in 'columns_left' which does not exis... | (ds1, ds2) = _create_merge_paramverify_dsets()
bad_colname = 'Hello'
assert (
bad_colname not in ds1.keys()
) # Make sure the bad key really isn't in the Dataset
with pytest.raises(ValueError):
rt.merge(ds1, ds2, left_on=left_on, right_on=right_on, columns_left=bad_colname... | @pytest.mark.parametrize("left_on", ['Foo', ['Foo']])
@pytest.mark.parametrize("right_on", ['Baz', ['Baz']])
def test_merge_requires_columns_left_columns_present(left_on, right_on):
# Test that `merge` raises a ValueError if a user calls it and specifies
# a column name in 'columns_left' which does not exis... | 82 | 74 | 248 | 82 | 0 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_requires_columns_left_columns_present | test_merge_requires_columns_left_columns_present | 583 | 606 | 583 | 587 | a56d82010076a30f62e7b23e0d9b2926758c2049 | bigcode/the-stack | train |
2fd7daf63ff01cc20e568f74 | train | function | def test_merge_on_and_right_on_disallowed():
# Test that `merge` raises a ValueError if a user calls it by specifying both
# the 'on' and 'right_on' parameters.
(ds1, ds2) = _create_merge_paramverify_dsets()
with pytest.raises(ValueError):
rt.merge(ds1, ds2, on='Bar', right_on='Baz')
| def test_merge_on_and_right_on_disallowed():
# Test that `merge` raises a ValueError if a user calls it by specifying both
# the 'on' and 'right_on' parameters.
| (ds1, ds2) = _create_merge_paramverify_dsets()
with pytest.raises(ValueError):
rt.merge(ds1, ds2, on='Bar', right_on='Baz')
| Error):
rt.merge(ds1, ds2, on='Bar', left_on='Foo')
def test_merge_on_and_right_on_disallowed():
# Test that `merge` raises a ValueError if a user calls it by specifying both
# the 'on' and 'right_on' parameters.
| 63 | 64 | 85 | 43 | 20 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge_on_and_right_on_disallowed | test_merge_on_and_right_on_disallowed | 521 | 527 | 521 | 523 | 212cf87f11b6dcfde6bcacc66be8b0d3b18ecf6a | bigcode/the-stack | train |
d5102dee41b581051014e74e | train | function | def test_merge2_sql_semantics_innerjoin_multi_keep_Nonefirst():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.s... | def test_merge2_sql_semantics_innerjoin_multi_keep_Nonefirst():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
... | (
result.id_foo, rt.FA([inv, inv, inv, inv, inv, inv, 2, inv], dtype=np.int32)
)
# Cols from the right Dataset.
assert_array_equal(result.id_bar, rt.FA([1, 2, 3, 4, 6, 7, 8, 9], dtype=np.int32))
assert_array_equal(
result.strcol,
rt.FA(
[
b'... | 167 | 168 | 563 | 14 | 153 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_innerjoin_multi_keep_Nonefirst | test_merge2_sql_semantics_innerjoin_multi_keep_Nonefirst | 4,781 | 4,844 | 4,781 | 4,781 | 2286cf1f8a7c5edaffc0d6cd165fbcdcc65199f8 | bigcode/the-stack | train |
67de8ff169ba0fa7f56aa8bb | train | function | def test_merge2_sql_semantics_leftjoin_multi_keep_firstNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.st... | def test_merge2_sql_semantics_leftjoin_multi_keep_firstNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | (
result.team_name,
rt.FA([b'Phillies', b'Eagles', b'76ers', b'Flyers', b'Union', b'Wings', b'Fusion', b'Fight', b'', b'', b'', b'', b'', b'', b'', b'', b'']))
# Cols from the right Dataset.
assert_array_equal(
result.id_bar, rt.FA([inv, 11, inv, inv, inv, inv, inv, inv, 1, 2, 3, ... | 229 | 230 | 767 | 14 | 215 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_leftjoin_multi_keep_firstNone | test_merge2_sql_semantics_leftjoin_multi_keep_firstNone | 5,093 | 5,165 | 5,093 | 5,093 | ecb19a7069de6ab96172c1117e77a60793cbec91 | bigcode/the-stack | train |
37d2c212b21971fabe177b6d | train | function | def test_lookup_copy_when_right_already_unique():
"""
Test case for RIP-491.
Verifies that the 'copy' parameter behaves as expected when the right
Dataset is already a unique key (i.e. keep does not need to be specified).
"""
left_ds = rt.Dataset()
left_ds['Symbol'] = rt.FA(['AAPL... | def test_lookup_copy_when_right_already_unique():
| """
Test case for RIP-491.
Verifies that the 'copy' parameter behaves as expected when the right
Dataset is already a unique key (i.e. keep does not need to be specified).
"""
left_ds = rt.Dataset()
left_ds['Symbol'] = rt.FA(['AAPL', 'AMZN', 'AA', 'AAN', 'AAPL', 'AMZN', 'AAP', 'AMZ... | ds2 = rt.Dataset({'f': ['2', '3', '4', '5'], 'g': [2, 3, 4, 5], 'h2': [2, 2, 2, 2]})
# Just verifying this succeeds (and does not fail with an exception/error).
# In riptable 1.0.21 and earlier, this failed due to the _create_column_valid_mask() function
# returning None; the None was passed into g... | 158 | 159 | 530 | 10 | 148 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_lookup_copy_when_right_already_unique | test_lookup_copy_when_right_already_unique | 6,211 | 6,247 | 6,211 | 6,211 | 188f95d32641553607873eb4e83094f9450137fa | bigcode/the-stack | train |
4ead47796bd255fa6ba60393 | train | function | def test_merge2_sql_semantics_innerjoin_single_keep_lastNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.s... | def test_merge2_sql_semantics_innerjoin_single_keep_lastNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | assert_array_equal(result.col1, rt.FA([5, 5, 8, 10, 10], dtype=np.int32))
# Cols from the left Dataset.
assert_array_equal(result.id_foo, rt.FA([1, 1, 3, 5, 5], dtype=np.int32))
assert_array_equal(result.col2_foo, rt.FA([inv, inv, inv, 1, 1], dtype=np.int32))
# Cols from the right Dataset.
... | 225 | 226 | 755 | 14 | 211 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_innerjoin_single_keep_lastNone | test_merge2_sql_semantics_innerjoin_single_keep_lastNone | 3,587 | 3,655 | 3,587 | 3,587 | 423a5dfe67af5ce86ead9b3bb223b46e9416b677 | bigcode/the-stack | train |
abf93de28361122ce39fc2b9 | train | function | def test_merge2_sql_semantics_leftjoin_single_keep_firstNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.s... | def test_merge2_sql_semantics_leftjoin_single_keep_firstNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from (
select *
from s... | 4, 22, 9, inv, inv, inv], dtype=np.int32))
assert_array_equal(result.team_name, rt.FA([b'Phillies', b'Eagles', b'76ers', b'Flyers', b'Union', b'Wings', b'Fusion', b'Fight', b'', b'', b'']))
# Cols from the right Dataset.
assert_array_equal(result.id_bar, rt.FA([11, 11, 3, inv, 2, inv, inv, inv, 7, 10,... | 238 | 239 | 798 | 14 | 224 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_leftjoin_single_keep_firstNone | test_merge2_sql_semantics_leftjoin_single_keep_firstNone | 3,166 | 3,238 | 3,166 | 3,166 | f71eb576837f2546d316a82b9e72e24cb0763528 | bigcode/the-stack | train |
b9fb1f9abfe939d770980464 | train | function | @xfail_rip260_outermerge_left_keep
def test_merge2_sql_semantics_outerjoin_multi_keep_lastNone():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_i... | @xfail_rip260_outermerge_left_keep
def test_merge2_sql_semantics_outerjoin_multi_keep_lastNone():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
f.team_name as foo_teamname,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
fr... | rt.FA([b'Phillies', b'Eagles', b'Eagles', b'76ers', b'Flyers', b'Union', b'Wings', b'Fusion', b'Fight', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'']))
# Cols from the right Dataset.
assert_array_equal(
result.id_bar, rt.FA([inv, 8, 11, inv, inv, inv, inv, inv, inv, 1, 2, 3, 4, 5, 6, 7,... | 255 | 256 | 1,142 | 25 | 230 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_outerjoin_multi_keep_lastNone | test_merge2_sql_semantics_outerjoin_multi_keep_lastNone | 5,658 | 5,748 | 5,658 | 5,659 | db1c0fa41940fd8e3d95598203a7d0aa40d10fff | bigcode/the-stack | train |
931e22c6b8077be047d26b11 | train | function | def test_merge2_sql_semantics_leftjoin_multi_keep_Nonefirst():
"""
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.st... | def test_merge2_sql_semantics_leftjoin_multi_keep_Nonefirst():
| """
Test that merge2 matches the following SQL query:
select
f.id as foo_id,
f.col1 as foo_col1,
f.col2 as foo_col2,
b.id as bar_id,
b.col1 as bar_col1,
b.col2 as bar_col2,
b.strcol as bar_strcol
from
sql_semantics.foo as f
... | 76ers', b'Flyers', b'Union', b'Wings', b'Fusion', b'Fight', b'', b'', b'', b'', b'', b'', b'', b'', b'', b''])
)
# Cols from the right Dataset.
assert_array_equal(
result.id_bar, rt.FA([inv, 8, 11, inv, inv, inv, inv, inv, inv, 1, 2, 3, 4, 5, 6, 7, 9, 10, 12], dtype=np.int32)
)
asser... | 227 | 228 | 762 | 14 | 213 | 972d5defe3218bd62b741e6a2f11f5b3/riptable | riptable/tests/test_merge.py | Python | test_merge2_sql_semantics_leftjoin_multi_keep_Nonefirst | test_merge2_sql_semantics_leftjoin_multi_keep_Nonefirst | 4,445 | 4,515 | 4,445 | 4,445 | 218fc2f0b77c470872ec7b22e305ad28217ddd5f | bigcode/the-stack | train |
88e23caf767837e2446521d4 | train | function | def make_no_mining_config(root_dir, file_name):
sys_config = os.path.join(root_dir, file_name)
f = open(sys_config, "w")
# if autostart is not true - there will be no miner
conf ='[{aecore, [{autostart, false},' + \
' {expected_mine_rate, 100},' + \
' {aec_pow_cuc... | def make_no_mining_config(root_dir, file_name):
| sys_config = os.path.join(root_dir, file_name)
f = open(sys_config, "w")
# if autostart is not true - there will be no miner
conf ='[{aecore, [{autostart, false},' + \
' {expected_mine_rate, 100},' + \
' {aec_pow_cuckoo, {"mean16s-generic", "-t 5", 16}}]}].'
f... | expected_mine_rate, 100},' + \
' {aec_pow_cuckoo, {"mean16s-generic", "-t 5", 16}}]}].'
f.write(conf)
f.close()
return sys_config
def make_no_mining_config(root_dir, file_name):
| 64 | 64 | 123 | 12 | 51 | AndyHongSir/epoch | py/tests/integration/test_use_cases.py | Python | make_no_mining_config | make_no_mining_config | 234 | 243 | 234 | 234 | c978bd025b6e97bf32ab5d03e72a6895a6a79c0c | bigcode/the-stack | train |
3bd21df3bdd1df0ec5febd1a | train | function | def node_peer_url(node_name):
host = common.node_config(node_name)["host"]
port = common.node_config(node_name)["ports"]["external_api"]
return "http://" + host + ":" + str(port) + "/"
| def node_peer_url(node_name):
| host = common.node_config(node_name)["host"]
port = common.node_config(node_name)["ports"]["external_api"]
return "http://" + host + ":" + str(port) + "/"
| + (", ").join(peers) + ']},' +\
mining_str + ']},' +\
'{aehttp, [{local_peer_address, "' + node_url + '"}]}].'
f.write(conf)
f.close()
return sys_config
def node_peer_url(node_name):
| 64 | 64 | 48 | 7 | 56 | AndyHongSir/epoch | py/tests/integration/test_use_cases.py | Python | node_peer_url | node_peer_url | 218 | 221 | 218 | 218 | 59df98bc29052b011c94b11a0e5b760be4658fef | bigcode/the-stack | train |
879d55ff1fa108bf8361729a | train | function | def test_syncing():
"""
Test node syncing:
Alice should be able to connect to peers on startup and download the
blockchain up to the current height.
"""
test_settings = settings["test_syncing"]
root_dir = tempfile.mkdtemp()
mining_sys_config = make_fast_mining_config(root_dir, "mining_s... | def test_syncing():
| """
Test node syncing:
Alice should be able to connect to peers on startup and download the
blockchain up to the current height.
"""
test_settings = settings["test_syncing"]
root_dir = tempfile.mkdtemp()
mining_sys_config = make_fast_mining_config(root_dir, "mining_sys.config")
no_m... | # coding: utf-8
import tempfile
import os
import shutil
import time
from nose.tools import assert_equals, assert_not_equals, with_setup
import common
from waiting import wait
from swagger_client.models.ping import Ping
from swagger_client.models.spend_tx import SpendTx
settings = common.test_settings(__name__.split(... | 80 | 142 | 474 | 5 | 75 | AndyHongSir/epoch | py/tests/integration/test_use_cases.py | Python | test_syncing | test_syncing | 15 | 62 | 15 | 15 | 1ca4ba09696a727fe9ed3ba3fa8a9cb5edb85a76 | bigcode/the-stack | train |
6d770d9edd3540843d7bbada | train | function | def test_node_discovery():
"""
Test node discovery
Assuming Carol's node only knows about Bob upon startup and that Bob's
node knows Alice, Carol's node should be able to discover Alice and
sync with her node.
"""
test_settings = settings["test_node_discovery"]
alice_node = test_settings... | def test_node_discovery():
| """
Test node discovery
Assuming Carol's node only knows about Bob upon startup and that Bob's
node knows Alice, Carol's node should be able to discover Alice and
sync with her node.
"""
test_settings = settings["test_node_discovery"]
alice_node = test_settings["nodes"]["alice"]
bob_... | )
bob_api = common.external_api(bob_node)
# Insert some blocks in Bob's chain
blocks_to_mine = test_settings["blocks_to_mine"]
common.wait_until_height(bob_api, blocks_to_mine)
bob_top = bob_api.get_top()
assert_equals(bob_top.height >= blocks_to_mine, True)
# Now Bob has at least blocks_to... | 231 | 231 | 771 | 6 | 225 | AndyHongSir/epoch | py/tests/integration/test_use_cases.py | Python | test_node_discovery | test_node_discovery | 121 | 198 | 121 | 121 | f31233522b1301caeae8afbba30d306744371992 | bigcode/the-stack | train |
2d868864fd46009a83aba0ca | train | function | def make_fast_mining_config(root_dir, file_name):
sys_config = os.path.join(root_dir, file_name)
f = open(sys_config, "w")
# if autostart is not true - there will be no miner
conf ='[{aecore, [{autostart, true},' + \
' {expected_mine_rate, 100},' + \
' {aec_pow_cu... | def make_fast_mining_config(root_dir, file_name):
| sys_config = os.path.join(root_dir, file_name)
f = open(sys_config, "w")
# if autostart is not true - there will be no miner
conf ='[{aecore, [{autostart, true},' + \
' {expected_mine_rate, 100},' + \
' {aec_pow_cuckoo, {"mean16s-generic", "-t 5", 16}}]}].'
f.... | return sys_config
def node_peer_url(node_name):
host = common.node_config(node_name)["host"]
port = common.node_config(node_name)["ports"]["external_api"]
return "http://" + host + ":" + str(port) + "/"
def make_fast_mining_config(root_dir, file_name):
| 64 | 64 | 123 | 12 | 51 | AndyHongSir/epoch | py/tests/integration/test_use_cases.py | Python | make_fast_mining_config | make_fast_mining_config | 223 | 232 | 223 | 223 | c9f85394a7fc3d1ce0cbac462068e86fe5807611 | bigcode/the-stack | train |
f5dd8fc39219c5e6e661d3ed | train | function | def make_peers_config(root_dir, file_name, node_url, peers0, mining=False):
sys_config = os.path.join(root_dir, file_name)
mining_str = ""
if mining:
mining_str = ' {autostart, true},' + \
' {expected_mine_rate, 100},' + \
' {aec_pow_cuckoo, {"mean16s-generi... | def make_peers_config(root_dir, file_name, node_url, peers0, mining=False):
| sys_config = os.path.join(root_dir, file_name)
mining_str = ""
if mining:
mining_str = ' {autostart, true},' + \
' {expected_mine_rate, 100},' + \
' {aec_pow_cuckoo, {"mean16s-generic", "-t 5", 16}}'
else:
mining_str = ' {autostart, false}'
... | ice_top.height, carol_top.height)
# cleanup
common.stop_node(alice_node)
common.stop_node(bob_node)
common.stop_node(carol_node)
shutil.rmtree(root_dir)
def make_peers_config(root_dir, file_name, node_url, peers0, mining=False):
| 64 | 64 | 207 | 20 | 44 | AndyHongSir/epoch | py/tests/integration/test_use_cases.py | Python | make_peers_config | make_peers_config | 200 | 216 | 200 | 200 | 505571b973638c755ce47a865ce19e7690f6b24b | bigcode/the-stack | train |
a58f8c7bb665340f5acefd6e | train | function | def test_persistence():
"""
Test persistence:
Bob's downloaded blockchain should persist between restarts. He should
only download updates to his blockchain when his node starts.
"""
test_settings = settings["test_persistence"]
# prepare a dir to hold the config and DB files
root_dir =... | def test_persistence():
| """
Test persistence:
Bob's downloaded blockchain should persist between restarts. He should
only download updates to his blockchain when his node starts.
"""
test_settings = settings["test_persistence"]
# prepare a dir to hold the config and DB files
root_dir = tempfile.mkdtemp()
... | , blocks_to_mine)
alice_top = alice_api.get_top()
assert_equals(alice_top.height >= blocks_to_mine, True)
if alice_top.height > bob_top.height: # bob had mined more blocks
bob_block = bob_api.get_block_by_hash(alice_top.hash) # this block is presnet
assert_equals(bob_block.height, alice_top.... | 166 | 166 | 556 | 5 | 161 | AndyHongSir/epoch | py/tests/integration/test_use_cases.py | Python | test_persistence | test_persistence | 64 | 119 | 64 | 64 | 9f786ea171dabed2e4aefd815363d1c8ba34e868 | bigcode/the-stack | train |
ea9e755263a19b22e4b329b7 | train | function | def channels_list_by_username(service, **kwargs):
results = service.channels().list(
**kwargs
).execute()
print('This channel\'s ID is %s. Its title is %s, and it has %s views.' %
(results['items'][0]['id'],
results['items'][0]['snippet']['title'],
results['items'][0]['statistics']['... | def channels_list_by_username(service, **kwargs):
| results = service.channels().list(
**kwargs
).execute()
print('This channel\'s ID is %s. Its title is %s, and it has %s views.' %
(results['items'][0]['id'],
results['items'][0]['snippet']['title'],
results['items'][0]['statistics']['viewCount']))
| _VERSION = 'v3'
def get_authenticated_service():
flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)
credentials = flow.run_console()
return build(API_SERVICE_NAME, API_VERSION, credentials = credentials)
def channels_list_by_username(service, **kwargs):
| 64 | 64 | 86 | 10 | 54 | franciscoGPS/youtdl | quickstart.py | Python | channels_list_by_username | channels_list_by_username | 27 | 35 | 27 | 27 | 1d9bda0471579fe39e9719967a95335c2ae28e64 | bigcode/the-stack | train |
87125360900664d0cd4f2c7e | train | function | def get_authenticated_service():
flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)
credentials = flow.run_console()
return build(API_SERVICE_NAME, API_VERSION, credentials = credentials)
| def get_authenticated_service():
| flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)
credentials = flow.run_console()
return build(API_SERVICE_NAME, API_VERSION, credentials = credentials)
| 2.0 access scope allows for full read/write access to the
# authenticated user's account and requires requests to use an SSL connection.
SCOPES = ['https://www.googleapis.com/auth/youtube.force-ssl']
API_SERVICE_NAME = 'youtube'
API_VERSION = 'v3'
def get_authenticated_service():
| 64 | 64 | 48 | 5 | 59 | franciscoGPS/youtdl | quickstart.py | Python | get_authenticated_service | get_authenticated_service | 22 | 25 | 22 | 22 | acacf9480ccd06beadc49736405d26cf6cde6bf0 | bigcode/the-stack | train |
f7a3b9a2c5be97cb86ccb109 | train | class | class UserAccesPermission(permissions.BasePermission):
"""Set permissions to users for actions with ther profiles"""
def has_object_permission(self, request, view, obj):
return obj.id==request.user.id | class UserAccesPermission(permissions.BasePermission):
| """Set permissions to users for actions with ther profiles"""
def has_object_permission(self, request, view, obj):
return obj.id==request.user.id | """Set permissions to users for actions with ther profiles"""
def has_object_permission(self, request, view, obj):
"""Checking user privileges"""
if request.method in permissions.SAFE_METHODS:
return True
return obj.id==request.user.id
class UserAccesPermission(permissions.Base... | 64 | 64 | 43 | 10 | 53 | Hir0v0/SNS-API | project0001api/user/permissions.py | Python | UserAccesPermission | UserAccesPermission | 12 | 15 | 12 | 12 | f704c2c3acaf936a0a4d3407425f06b690747353 | bigcode/the-stack | train |
9d52038eccf15452b52f6577 | train | class | class UserEditPermission(permissions.BasePermission):
"""Set permissions to users for actions with ther profiles"""
def has_object_permission(self, request, view, obj):
"""Checking user privileges"""
if request.method in permissions.SAFE_METHODS:
return True
return obj.id==r... | class UserEditPermission(permissions.BasePermission):
| """Set permissions to users for actions with ther profiles"""
def has_object_permission(self, request, view, obj):
"""Checking user privileges"""
if request.method in permissions.SAFE_METHODS:
return True
return obj.id==request.user.id
| from rest_framework import permissions
class UserEditPermission(permissions.BasePermission):
| 15 | 64 | 64 | 9 | 5 | Hir0v0/SNS-API | project0001api/user/permissions.py | Python | UserEditPermission | UserEditPermission | 3 | 10 | 3 | 3 | 46353df4b2ec584865ca1dc5d9a3e9496d11e314 | bigcode/the-stack | train |
b741d59a8ddefb5a255b41fd | train | function | @contextmanager
def no_alsa_error():
try:
asound = cdll.LoadLibrary('libasound.so')
asound.snd_lib_error_set_handler(c_error_handler)
yield
asound.snd_lib_error_set_handler(None)
except:
yield
pass
| @contextmanager
def no_alsa_error():
| try:
asound = cdll.LoadLibrary('libasound.so')
asound.snd_lib_error_set_handler(c_error_handler)
yield
asound.snd_lib_error_set_handler(None)
except:
yield
pass
| py_error_handler(filename, line, function, err, fmt):
pass
ERROR_HANDLER_FUNC = CFUNCTYPE(None, c_char_p, c_int, c_char_p, c_int, c_char_p)
c_error_handler = ERROR_HANDLER_FUNC(py_error_handler)
@contextmanager
def no_alsa_error():
| 64 | 64 | 63 | 10 | 54 | Awkee/wukong-robot | robot/Player.py | Python | no_alsa_error | no_alsa_error | 20 | 29 | 20 | 21 | 77bb47de184693de00f726c371173f0f17e1be2b | bigcode/the-stack | train |
5e479459091e148484826166 | train | function | def py_error_handler(filename, line, function, err, fmt):
pass
| def py_error_handler(filename, line, function, err, fmt):
| pass
| platform
from . import utils
import _thread as thread
from robot import logging
from ctypes import CFUNCTYPE, c_char_p, c_int, cdll
from contextlib import contextmanager
logger = logging.getLogger(__name__)
def py_error_handler(filename, line, function, err, fmt):
| 64 | 64 | 17 | 14 | 50 | Awkee/wukong-robot | robot/Player.py | Python | py_error_handler | py_error_handler | 13 | 14 | 13 | 13 | 0dfce33cf12b3405aea35877bbe5fb999b8633bd | bigcode/the-stack | train |
0f9a97b5c0e5d8d18d090311 | train | function | def getPlayerByFileName(fname):
foo, ext = os.path.splitext(fname)
if ext in ['.mp3', '.wav']:
return SoxPlayer()
| def getPlayerByFileName(fname):
| foo, ext = os.path.splitext(fname)
if ext in ['.mp3', '.wav']:
return SoxPlayer()
| asound.snd_lib_error_set_handler(None)
except:
yield
pass
def play(fname, onCompleted=None, wait=False):
player = getPlayerByFileName(fname)
player.play(fname, onCompleted=onCompleted, wait=wait)
def getPlayerByFileName(fname):
| 64 | 64 | 35 | 8 | 56 | Awkee/wukong-robot | robot/Player.py | Python | getPlayerByFileName | getPlayerByFileName | 35 | 38 | 35 | 35 | 1115a2142a71896c0acb23aa8eaaf7597e5e1bd9 | bigcode/the-stack | train |
c37f18d7e1302e2512c0329f | train | class | class SoxPlayer(AbstractPlayer):
SLUG = 'SoxPlayer'
def __init__(self, **kwargs):
super(SoxPlayer, self).__init__(**kwargs)
self.playing = False
self.proc = None
self.delete = False
self.onCompleteds = []
def doPlay(self):
cmd = ['play', str(self.src)]
... | class SoxPlayer(AbstractPlayer):
| SLUG = 'SoxPlayer'
def __init__(self, **kwargs):
super(SoxPlayer, self).__init__(**kwargs)
self.playing = False
self.proc = None
self.delete = False
self.onCompleteds = []
def doPlay(self):
cmd = ['play', str(self.src)]
logger.debug('Executing %s', '... | , onCompleted=onCompleted, wait=wait)
def getPlayerByFileName(fname):
foo, ext = os.path.splitext(fname)
if ext in ['.mp3', '.wav']:
return SoxPlayer()
class AbstractPlayer(object):
def __init__(self, **kwargs):
super(AbstractPlayer, self).__init__()
def play(self):
pass
... | 112 | 112 | 374 | 6 | 105 | Awkee/wukong-robot | robot/Player.py | Python | SoxPlayer | SoxPlayer | 58 | 111 | 58 | 58 | 5cf8fa1d86a0c7fe148573334c75dff9e48b4ab8 | bigcode/the-stack | train |
bccba32bb737c711bcf67de5 | train | function | def play(fname, onCompleted=None, wait=False):
player = getPlayerByFileName(fname)
player.play(fname, onCompleted=onCompleted, wait=wait)
| def play(fname, onCompleted=None, wait=False):
| player = getPlayerByFileName(fname)
player.play(fname, onCompleted=onCompleted, wait=wait)
| try:
asound = cdll.LoadLibrary('libasound.so')
asound.snd_lib_error_set_handler(c_error_handler)
yield
asound.snd_lib_error_set_handler(None)
except:
yield
pass
def play(fname, onCompleted=None, wait=False):
| 64 | 64 | 36 | 11 | 52 | Awkee/wukong-robot | robot/Player.py | Python | play | play | 31 | 33 | 31 | 31 | 53143416b4dd872856d5bd2ac291256ec95e8767 | bigcode/the-stack | train |
8f6a6ea3dfbc534ee624af79 | train | class | class AbstractPlayer(object):
def __init__(self, **kwargs):
super(AbstractPlayer, self).__init__()
def play(self):
pass
def play_block(self):
pass
def stop(self):
pass
def is_playing(self):
return False
| class AbstractPlayer(object):
| def __init__(self, **kwargs):
super(AbstractPlayer, self).__init__()
def play(self):
pass
def play_block(self):
pass
def stop(self):
pass
def is_playing(self):
return False
| player = getPlayerByFileName(fname)
player.play(fname, onCompleted=onCompleted, wait=wait)
def getPlayerByFileName(fname):
foo, ext = os.path.splitext(fname)
if ext in ['.mp3', '.wav']:
return SoxPlayer()
class AbstractPlayer(object):
| 64 | 64 | 60 | 5 | 59 | Awkee/wukong-robot | robot/Player.py | Python | AbstractPlayer | AbstractPlayer | 40 | 55 | 40 | 41 | 09845853aaccdc4095fcbca764e8e65166304b25 | bigcode/the-stack | train |
274dc723149c30e84571d7e1 | train | class | class MusicPlayer(SoxPlayer):
"""
给音乐播放器插件使用的,
在 SOXPlayer 的基础上增加了列表的支持,
并支持暂停和恢复播放
"""
SLUG = 'MusicPlayer'
def __init__(self, playlist, plugin, **kwargs):
super(MusicPlayer, self).__init__(**kwargs)
self.playlist = playlist
self.plugin = plugin
self.idx = 0... | class MusicPlayer(SoxPlayer):
| """
给音乐播放器插件使用的,
在 SOXPlayer 的基础上增加了列表的支持,
并支持暂停和恢复播放
"""
SLUG = 'MusicPlayer'
def __init__(self, playlist, plugin, **kwargs):
super(MusicPlayer, self).__init__(**kwargs)
self.playlist = playlist
self.plugin = plugin
self.idx = 0
self.pausing = False
... | ()
self.playing = False
if self.delete:
utils.check_and_delete(self.src)
logger.debug('play completed')
if self.proc.returncode == 0:
for onCompleted in self.onCompleteds:
if onCompleted is not None:
onCompleted()
def p... | 256 | 256 | 1,064 | 7 | 248 | Awkee/wukong-robot | robot/Player.py | Python | MusicPlayer | MusicPlayer | 114 | 232 | 114 | 114 | 465e41f5656a690e0e2de9cf6054e1ecfda80202 | bigcode/the-stack | train |
c1266cbce902f77ca0e50851 | train | class | class ProductAdminModelForm(WagtailAdminModelForm):
def clean_ean(self):
if self.cleaned_data['ean'] == '':
self.cleaned_data['ean'] = None
return self.cleaned_data['ean']
def clean_sku(self):
if self.cleaned_data['sku'] == '':
self.cleaned_data['sku'] = None
... | class ProductAdminModelForm(WagtailAdminModelForm):
| def clean_ean(self):
if self.cleaned_data['ean'] == '':
self.cleaned_data['ean'] = None
return self.cleaned_data['ean']
def clean_sku(self):
if self.cleaned_data['sku'] == '':
self.cleaned_data['sku'] = None
return self.cleaned_data['sku']
| from wagtail.wagtailadmin.forms import WagtailAdminModelForm
class ProductAdminModelForm(WagtailAdminModelForm):
| 28 | 64 | 84 | 12 | 15 | bobslee/django_commerce_wagtail | forms.py | Python | ProductAdminModelForm | ProductAdminModelForm | 3 | 14 | 3 | 3 | 0b144144209c340fb7bb5b28191dc34144d7f5bf | bigcode/the-stack | train |
6d236a95acf6975e3d342b3d | train | function | def even_q_to_cube(col, row):
x = col
z = row - (col + (col % 2)) // 2
y = -x - z
return x, y, z
| def even_q_to_cube(col, row):
| x = col
z = row - (col + (col % 2)) // 2
y = -x - z
return x, y, z
| ) == 0
def sign(x):
return -1 if x < 0 else 1 if x > 0 else 0
# http://www.redblobgames.com/grids/hexagons
#
# The game uses even-q offset coordinates
def even_q_to_cube(col, row):
| 64 | 64 | 48 | 9 | 54 | man-group/hiveminder | hiveminder/_util.py | Python | even_q_to_cube | even_q_to_cube | 17 | 21 | 17 | 17 | 7fc5195cadb5107c8f196fe1575b1910aa599130 | bigcode/the-stack | train |
af914c34763c8d6b779c7913 | train | function | def cube_add(cube1, cube2):
return tuple(cube1[i] + cube2[i] for i in range(3))
| def cube_add(cube1, cube2):
| return tuple(cube1[i] + cube2[i] for i in range(3))
| = -x - z
return x, y, z
def cube_to_even_q(x, y, z):
col = x
row = z + (x + (x % 2)) // 2
return col, row
def cube_add(cube1, cube2):
| 64 | 64 | 30 | 10 | 53 | man-group/hiveminder | hiveminder/_util.py | Python | cube_add | cube_add | 30 | 31 | 30 | 30 | 2be7ef51bd3111c9ca047cf19b7db70a47d7cafa | bigcode/the-stack | train |
7f41cccf53274db074ea8d43 | train | function | def cube_to_even_q(x, y, z):
col = x
row = z + (x + (x % 2)) // 2
return col, row
| def cube_to_even_q(x, y, z):
| col = x
row = z + (x + (x % 2)) // 2
return col, row
| even-q offset coordinates
def even_q_to_cube(col, row):
x = col
z = row - (col + (col % 2)) // 2
y = -x - z
return x, y, z
def cube_to_even_q(x, y, z):
| 64 | 64 | 40 | 11 | 52 | man-group/hiveminder | hiveminder/_util.py | Python | cube_to_even_q | cube_to_even_q | 24 | 27 | 24 | 24 | 093b0e2eba2524c018f8b66ee915678ed68b2202 | bigcode/the-stack | train |
a35b4786be2cb87956087c8c | train | function | def cube_in_range(centre, N):
return (cube_add(centre, (dx, dy, -dx - dy))
for dx in range(-N, N + 1)
for dy in range(max(-N, -dx - N), min(N, -dx + N) + 1))
| def cube_in_range(centre, N):
| return (cube_add(centre, (dx, dy, -dx - dy))
for dx in range(-N, N + 1)
for dy in range(max(-N, -dx - N), min(N, -dx + N) + 1))
|
row = z + (x + (x % 2)) // 2
return col, row
def cube_add(cube1, cube2):
return tuple(cube1[i] + cube2[i] for i in range(3))
def cube_in_range(centre, N):
| 64 | 64 | 66 | 9 | 55 | man-group/hiveminder | hiveminder/_util.py | Python | cube_in_range | cube_in_range | 34 | 37 | 34 | 34 | ecb54d2fb71c9ecd06340b01c0aa2c6e56544035 | bigcode/the-stack | train |
657ddab1b116c851b8b031a6 | train | function | def _first(seq):
for i in seq:
return i
| def _first(seq):
| for i in seq:
return i
| for i1, i2 in zip(c1, c2)) // 2
def even_q_distance(col1, row1, col2, row2):
return cube_distance(even_q_to_cube(col1, row1), even_q_to_cube(col2, row2))
def _first(seq):
| 64 | 64 | 15 | 5 | 59 | man-group/hiveminder | hiveminder/_util.py | Python | _first | _first | 52 | 54 | 52 | 52 | 1029f3f8a051f22b2f6a983f62b705fa06545eeb | bigcode/the-stack | train |
e9c7cc9efa0bd8012b969b11 | train | function | def sign(x):
return -1 if x < 0 else 1 if x > 0 else 0
| def sign(x):
| return -1 if x < 0 else 1 if x > 0 else 0
| from __future__ import absolute_import, division
from itertools import starmap
def is_even(x):
return (x % 2) == 0
def sign(x):
| 38 | 64 | 25 | 4 | 33 | man-group/hiveminder | hiveminder/_util.py | Python | sign | sign | 9 | 10 | 9 | 9 | 63aed5304468fcdb29adfd700c63c4582c25360a | bigcode/the-stack | train |
e894ba950fdadbb0f56c42c5 | train | function | def even_q_distance(col1, row1, col2, row2):
return cube_distance(even_q_to_cube(col1, row1), even_q_to_cube(col2, row2))
| def even_q_distance(col1, row1, col2, row2):
| return cube_distance(even_q_to_cube(col1, row1), even_q_to_cube(col2, row2))
| (even_q_to_cube(col, row), N))
def cube_distance(c1, c2):
return sum(abs(i1 - i2) for i1, i2 in zip(c1, c2)) // 2
def even_q_distance(col1, row1, col2, row2):
| 64 | 64 | 41 | 16 | 47 | man-group/hiveminder | hiveminder/_util.py | Python | even_q_distance | even_q_distance | 48 | 49 | 48 | 48 | b254279d03d3901e2d45fa9793fdc4abde985e2b | bigcode/the-stack | train |
7e57d46fdd2fb489b38e126d | train | function | def is_even(x):
return (x % 2) == 0
| def is_even(x):
| return (x % 2) == 0
| from __future__ import absolute_import, division
from itertools import starmap
def is_even(x):
| 22 | 64 | 17 | 5 | 16 | man-group/hiveminder | hiveminder/_util.py | Python | is_even | is_even | 5 | 6 | 5 | 5 | 283c69e89bf4a16964ba770ea194a51003ead444 | bigcode/the-stack | train |
f6175c5c362e3c1da0e1c93f | train | function | def cube_distance(c1, c2):
return sum(abs(i1 - i2) for i1, i2 in zip(c1, c2)) // 2
| def cube_distance(c1, c2):
| return sum(abs(i1 - i2) for i1, i2 in zip(c1, c2)) // 2
| N, -dx - N), min(N, -dx + N) + 1))
def even_q_in_range(col, row, N):
return starmap(cube_to_even_q, cube_in_range(even_q_to_cube(col, row), N))
def cube_distance(c1, c2):
| 64 | 64 | 37 | 9 | 55 | man-group/hiveminder | hiveminder/_util.py | Python | cube_distance | cube_distance | 44 | 45 | 44 | 44 | eb064da3b71dc1443424a90bb903209372c68a1a | bigcode/the-stack | train |
63ccae882e3f333654f8bca1 | train | function | def even_q_in_range(col, row, N):
return starmap(cube_to_even_q, cube_in_range(even_q_to_cube(col, row), N))
| def even_q_in_range(col, row, N):
| return starmap(cube_to_even_q, cube_in_range(even_q_to_cube(col, row), N))
| _add(centre, (dx, dy, -dx - dy))
for dx in range(-N, N + 1)
for dy in range(max(-N, -dx - N), min(N, -dx + N) + 1))
def even_q_in_range(col, row, N):
| 64 | 64 | 36 | 11 | 53 | man-group/hiveminder | hiveminder/_util.py | Python | even_q_in_range | even_q_in_range | 40 | 41 | 40 | 40 | 308bd543adff121a3dbc85ae5a454a65aebdbcf7 | bigcode/the-stack | train |
2e53334b9ce8bb57b1b311fd | train | function | def get_iou(base_bbox, bbox_array: np.ndarray):
"""
:param base_bbox:
:param bbox_array:
:return:
"""
left = bbox_array[..., 0]
right = bbox_array[..., 1]
bottom = bbox_array[..., 2]
top = bbox_array[..., 3]
inter_area = intersection_area(base_bbox, bbox_array)
areas = (righ... | def get_iou(base_bbox, bbox_array: np.ndarray):
| """
:param base_bbox:
:param bbox_array:
:return:
"""
left = bbox_array[..., 0]
right = bbox_array[..., 1]
bottom = bbox_array[..., 2]
top = bbox_array[..., 3]
inter_area = intersection_area(base_bbox, bbox_array)
areas = (right - left + 1) * (top - bottom + 1)
base_area... | 3])
else:
raise ValueError
w = _ew_max_func(min_value, right - left + 1)
h = _ew_max_func(min_value, top - bottom + 1)
return w * h
def get_iou(base_bbox, bbox_array: np.ndarray):
| 64 | 64 | 136 | 13 | 50 | jianantian/yolo3-pytorch | yolo/boundingbox.py | Python | get_iou | get_iou | 106 | 121 | 106 | 106 | 0abe9ed1b113cd6de88dd643170e13ea62f6922b | bigcode/the-stack | train |
2c04abaf1b93b5fd9290a0d0 | train | function | def from_center_representation(center_bboxes):
"""
transform bbox from center representation to border representation
:param center_bboxes: tensor of bbox like torch.tensor([center_x, center_y, length, width])
:return: tensor of bbox like torch.tensor([left, right, bottom, top])
"""
shape = cent... | def from_center_representation(center_bboxes):
| """
transform bbox from center representation to border representation
:param center_bboxes: tensor of bbox like torch.tensor([center_x, center_y, length, width])
:return: tensor of bbox like torch.tensor([left, right, bottom, top])
"""
shape = center_bboxes.shape
batch_size = center_bboxes.... | """
:param bbox: torch.tensor([left, right, bottom, top]) or np.array([left, right, bottom, top])
:return:
"""
return (bbox[..., 1] - bbox[..., 0] + 1) * (bbox[..., 3] - bbox[..., 2] + 1)
def from_center_representation(center_bboxes):
| 79 | 79 | 265 | 9 | 70 | jianantian/yolo3-pytorch | yolo/boundingbox.py | Python | from_center_representation | from_center_representation | 14 | 37 | 14 | 14 | 6b2ff5781b19894dee86ad9099143d5ebe9becde | bigcode/the-stack | train |
89357ec9c8ff1e2459ded890 | train | function | def nms(bboxes, thresh):
"""
Non-Maximum Suppression
Inspired by the code written by Ross Girshick for Fast R-CNN, the original code is MIT licensed.
:param bboxes: 2d np.array(list of np.array([left, right, bottom, top]))
:param thresh: thresh value, float type
:return:
"""
try:
... | def nms(bboxes, thresh):
| """
Non-Maximum Suppression
Inspired by the code written by Ross Girshick for Fast R-CNN, the original code is MIT licensed.
:param bboxes: 2d np.array(list of np.array([left, right, bottom, top]))
:param thresh: thresh value, float type
:return:
"""
try:
left = bboxes[..., 0]
... | :param bbox_array:
:return:
"""
left = bbox_array[..., 0]
right = bbox_array[..., 1]
bottom = bbox_array[..., 2]
top = bbox_array[..., 3]
inter_area = intersection_area(base_bbox, bbox_array)
areas = (right - left + 1) * (top - bottom + 1)
base_area = get_area(base_bbox).unsqueeze(-... | 122 | 122 | 409 | 8 | 113 | jianantian/yolo3-pytorch | yolo/boundingbox.py | Python | nms | nms | 124 | 170 | 124 | 124 | c6442c970c8f615fa8c907bfa33c3078052c1d81 | bigcode/the-stack | train |
16fd2f4fca31589817f677dd | train | function | def to_center_representation(bboxes):
"""
transform bbox from center representation to border representation
:param bboxes: np.array of bbox like torch.tensor([left, right, bottom, top])
:return: np.array of bbox like torch.tensor([center_x, center_y, length, width])
"""
shape = bboxes.shape
... | def to_center_representation(bboxes):
| """
transform bbox from center representation to border representation
:param bboxes: np.array of bbox like torch.tensor([left, right, bottom, top])
:return: np.array of bbox like torch.tensor([center_x, center_y, length, width])
"""
shape = bboxes.shape
batch_size = bboxes.shape[0]
lef... | .cat(_seq, 1).reshape(batch_size, 4, -1).transpose(2, 1)
elif len(shape) == 2:
return torch.cat(_seq, 0).reshape(4, -1).transpose(1, 0)
else:
return torch.Tensor(_seq)
def to_center_representation(bboxes):
| 75 | 75 | 253 | 8 | 67 | jianantian/yolo3-pytorch | yolo/boundingbox.py | Python | to_center_representation | to_center_representation | 40 | 67 | 40 | 40 | 5222dca4d1872dc4e568b325ed08c1e02c8ae666 | bigcode/the-stack | train |
6a10900ff9815f7341379673 | train | function | def get_area(bbox):
"""
:param bbox: torch.tensor([left, right, bottom, top]) or np.array([left, right, bottom, top])
:return:
"""
return (bbox[..., 1] - bbox[..., 0] + 1) * (bbox[..., 3] - bbox[..., 2] + 1)
| def get_area(bbox):
| """
:param bbox: torch.tensor([left, right, bottom, top]) or np.array([left, right, bottom, top])
:return:
"""
return (bbox[..., 1] - bbox[..., 0] + 1) * (bbox[..., 3] - bbox[..., 2] + 1)
| import numpy as np
import torch
def get_area(bbox):
| 14 | 64 | 77 | 6 | 7 | jianantian/yolo3-pytorch | yolo/boundingbox.py | Python | get_area | get_area | 5 | 11 | 5 | 5 | 8c291cc60ffef7c7b970553914834557014c5d7a | bigcode/the-stack | train |
bdc4c9186df428807218845a | train | function | def intersection_area(base_bbox, bbox_array: np.ndarray):
"""
area of intersection bbox
:param base_bbox: 1d np.array([left, right, bottom, top])
:param bbox_array: 2d np.array(list of bbox)
:return:
"""
# ew is short for element wise
if isinstance(base_bbox, np.ndarray):
_ew_max... | def intersection_area(base_bbox, bbox_array: np.ndarray):
| """
area of intersection bbox
:param base_bbox: 1d np.array([left, right, bottom, top])
:param bbox_array: 2d np.array(list of bbox)
:return:
"""
# ew is short for element wise
if isinstance(base_bbox, np.ndarray):
_ew_max_func = np.maximum
_ew_min_func = np.minimum
... | _center = (bottom + top) / 2
length = right - left
width = top - bottom
_seq = (x_center, y_center, length, width)
if len(shape) == 3:
return np.concatenate(_seq, 1).reshape(batch_size, 4, -1).transpose(2, 1)
elif len(shape) == 2:
return np.concatenate(_seq, 0).reshape(4, -1).tran... | 131 | 131 | 438 | 12 | 119 | jianantian/yolo3-pytorch | yolo/boundingbox.py | Python | intersection_area | intersection_area | 70 | 103 | 70 | 70 | 453f80fab7488e80df43cf02d3efcfae6af7d58d | bigcode/the-stack | train |
5d1be44d6d6807ffa42585d0 | train | class | class Scenario:
def __init__(self, start, end, mmap, dvmap, tc_id: int, park=None, side=0):
self.start = start
self.end = end
self.map = mmap
self.ID = str(tc_id)
self.park = park
self.dvmap = dvmap
self.side = side
def __str__(self):
return str(s... | class Scenario:
| def __init__(self, start, end, mmap, dvmap, tc_id: int, park=None, side=0):
self.start = start
self.end = end
self.map = mmap
self.ID = str(tc_id)
self.park = park
self.dvmap = dvmap
self.side = side
def __str__(self):
return str(self.__class__) +... | class Scenario:
| 3 | 64 | 101 | 3 | 0 | TrackerSB/IEEEAITestChallenge2021 | deliverable2/models/scenario.py | Python | Scenario | Scenario | 1 | 12 | 1 | 1 | 18a0b62c167b2df263515e0d4f74175cbffeabbf | bigcode/the-stack | train |
50dbbdc1bf56a899b70c1b35 | train | class | class TestFullConvertionCombined(unittest.TestCase):
"""
Run a full convertion test:
int -> roman -> int
and checks that the two integers are equals.
This test is run on both fast and safe version
This test ensure safe and fast version interoperability
and consistency
"""
def fu... | class TestFullConvertionCombined(unittest.TestCase):
| """
Run a full convertion test:
int -> roman -> int
and checks that the two integers are equals.
This test is run on both fast and safe version
This test ensure safe and fast version interoperability
and consistency
"""
def full_convertion_run(self, upper):
"""
G... | =upper)
arabic = roman_to_int(roman)
self.assertEqual(i, arabic)
def test_full_convertion_lower_fast(self):
"""
Test lower case output
"""
self.full_convertion_run_fast(False)
def test_full_convertion_upper_fast(self):
"""
Test upper ca... | 95 | 95 | 317 | 11 | 84 | FilippoRanza/roman_numbers | test_roman_numbers.py | Python | TestFullConvertionCombined | TestFullConvertionCombined | 203 | 245 | 203 | 203 | e18a3c9e91a72a45b4bce9edf042f04996b56b86 | bigcode/the-stack | train |
3127c29fbce884af0b6fc12a | train | class | class TestIntToRoman(unittest.TestCase):
"""
Test int to roman convertion.
This test is run only on safe version
"""
def test_errors(self):
"""
Check that wrong input raises
an exception
Here safe version is mandatory.
"""
for i in ['yt', 5.6, (4.5, 7... | class TestIntToRoman(unittest.TestCase):
| """
Test int to roman convertion.
This test is run only on safe version
"""
def test_errors(self):
"""
Check that wrong input raises
an exception
Here safe version is mandatory.
"""
for i in ['yt', 5.6, (4.5, 7)]:
with self.assertRaises(Va... | ):
"""
Test for lower case numerals
"""
self.full_regex(False)
def test_wrong(self):
"""
Check that wrong values are rejected
"""
for i in WRONG_ROMAN:
self.assertFalse(is_valid_roman(i))
class TestIntToRoman(unittest.TestCase):
| 64 | 64 | 168 | 9 | 55 | FilippoRanza/roman_numbers | test_roman_numbers.py | Python | TestIntToRoman | TestIntToRoman | 81 | 105 | 81 | 81 | 094db2db4cf38f9cce4b5302488d20acf8dde0b4 | bigcode/the-stack | train |
c8f9d78831b2cb7d3423a6ca | train | class | class TestFullConvertionFast(unittest.TestCase):
"""
Run a full convertion test:
int -> roman -> int
and checks that the two integers are equals.
This test is run only on fast version.
"""
def full_convertion_run_fast(self, upper):
"""
Generate all possibile integers fro... | class TestFullConvertionFast(unittest.TestCase):
| """
Run a full convertion test:
int -> roman -> int
and checks that the two integers are equals.
This test is run only on fast version.
"""
def full_convertion_run_fast(self, upper):
"""
Generate all possibile integers from 1 to 9999
run test on fast (without inp... | (self):
"""
Test lower case output
"""
self.full_convertion_run_safe(False)
def test_full_convertion_upper_safe(self):
"""
Test upper case output
"""
self.full_convertion_run_safe(True)
class TestFullConvertionFast(unittest.TestCase):
| 64 | 64 | 197 | 11 | 53 | FilippoRanza/roman_numbers | test_roman_numbers.py | Python | TestFullConvertionFast | TestFullConvertionFast | 170 | 200 | 170 | 170 | 83ecf9e8ffbf14e7bf875c5a3f47a483ae3411db | bigcode/the-stack | train |
dc905fab34d18eed9b0d7570 | train | class | class TestIsValidRoman(unittest.TestCase):
"""
Test that is_valid_roman actualy finds
correct and wrong roman numerals
"""
def full_regex(self, upper):
"""
Generate all Roman Numerals
from 1 up to 9999 and run the check
against them
"""
for i in range... | class TestIsValidRoman(unittest.TestCase):
| """
Test that is_valid_roman actualy finds
correct and wrong roman numerals
"""
def full_regex(self, upper):
"""
Generate all Roman Numerals
from 1 up to 9999 and run the check
against them
"""
for i in range(1, 10000):
roman = int_to_roma... | XIX', 2019),
('XCIX', 99)
]
WRONG_ROMAN = [
'IC',
'XD',
'IIII',
'XXXX',
'XIXI',
'CIDI',
'CCM'
]
class TestIsValidRoman(unittest.TestCase):
| 64 | 64 | 194 | 9 | 55 | FilippoRanza/roman_numbers | test_roman_numbers.py | Python | TestIsValidRoman | TestIsValidRoman | 45 | 78 | 45 | 45 | 9e8fe46b82d954f21ec60c72b35ae1f13e7967c9 | bigcode/the-stack | train |
090cec1da68e095989df7f19 | train | class | class TestFullConvertionSafe(unittest.TestCase):
"""
Run a full convertion test:
int -> roman -> int
and checks that the two integers are equals.
This test is run only on safe version.
"""
def full_convertion_run_safe(self, upper):
"""
Generate all possibile integers fro... | class TestFullConvertionSafe(unittest.TestCase):
| """
Run a full convertion test:
int -> roman -> int
and checks that the two integers are equals.
This test is run only on safe version.
"""
def full_convertion_run_safe(self, upper):
"""
Generate all possibile integers from 1 to 9999
run test on safe (with input ... | [45, 5.6, (6, '8')]:
with self.assertRaises(ValueError):
roman_to_int_safe(i)
for i in WRONG_ROMAN:
with self.assertRaises(ValueError):
roman_to_int_safe(i)
class TestFullConvertionSafe(unittest.TestCase):
| 64 | 64 | 199 | 11 | 53 | FilippoRanza/roman_numbers | test_roman_numbers.py | Python | TestFullConvertionSafe | TestFullConvertionSafe | 137 | 167 | 137 | 137 | 019dc91271cbc767e7b2e17c45cc348a13849136 | bigcode/the-stack | train |
41e441a0d1c100d5706b2e0c | train | class | class TestRomanToInt(unittest.TestCase):
"""
Test Roman to integer conversion.
This test is run only on safe version
"""
def test_roman_to_int_value(self):
"""
Using a set of correct (roman, int) couples
converts the roman and checks the result is
correct
"""... | class TestRomanToInt(unittest.TestCase):
| """
Test Roman to integer conversion.
This test is run only on safe version
"""
def test_roman_to_int_value(self):
"""
Using a set of correct (roman, int) couples
converts the roman and checks the result is
correct
"""
for roman, integer in CORRECT_RE... | (self):
"""
Using a set of correct (roman, int) couples
converts the integer and checks the result is
correct
"""
for roman, integer in CORRECT_RESULTS:
self.assertEqual(int_to_roman_safe(integer), roman)
class TestRomanToInt(unittest.TestCase):
| 64 | 64 | 176 | 9 | 55 | FilippoRanza/roman_numbers | test_roman_numbers.py | Python | TestRomanToInt | TestRomanToInt | 108 | 134 | 108 | 108 | 5563ba0d4087510b33f889f048328d36e6d0c72d | bigcode/the-stack | train |
48d0511164fd9d3ac3dc0136 | train | function | def get_vba(workbook):
vba_parser = VBA_Parser(workbook)
vba_modules = vba_parser.extract_all_macros() if vba_parser.detect_vba_macros() else []
modules = {}
for _, _, _, content in vba_modules:
decoded_content = content
lines = []
if '\r\n' in decoded_content:
line... | def get_vba(workbook):
| vba_parser = VBA_Parser(workbook)
vba_modules = vba_parser.extract_all_macros() if vba_parser.detect_vba_macros() else []
modules = {}
for _, _, _, content in vba_modules:
decoded_content = content
lines = []
if '\r\n' in decoded_content:
lines = decoded_content.spl... | import sys
import os
from difflib import unified_diff
import colorama
from oletools.olevba3 import VBA_Parser
from colorama import Fore, Back, Style, init
def get_vba(workbook):
| 50 | 64 | 182 | 7 | 42 | oledid-forks/git-xl | src/diff.py | Python | get_vba | get_vba | 10 | 29 | 10 | 10 | 578b8701a13ad64ba259905ed5b34b55d4240601 | bigcode/the-stack | train |
ee056171194264d4fa2a73c3 | train | function | @pytest.mark.slow
@pytest.mark.parametrize("alg", learn_kwargs.keys())
def test_cartpole(alg):
'''
Test if the algorithm (with an mlp policy)
can learn to balance the cartpole
'''
kwargs = common_kwargs.copy()
kwargs.update(learn_kwargs[alg])
learn_fn = lambda e: get_learn_function(alg)(en... | @pytest.mark.slow
@pytest.mark.parametrize("alg", learn_kwargs.keys())
def test_cartpole(alg):
| '''
Test if the algorithm (with an mlp policy)
can learn to balance the cartpole
'''
kwargs = common_kwargs.copy()
kwargs.update(learn_kwargs[alg])
learn_fn = lambda e: get_learn_function(alg)(env=e, **kwargs)
def env_fn():
env = gym.make('CartPole-v0')
env.se... | steps=32, value_network='copy'),
'deepq': dict(total_timesteps=20000),
'ppo2': dict(value_network='copy'),
'trpo_mpi': {}
}
@pytest.mark.slow
@pytest.mark.parametrize("alg", learn_kwargs.keys())
def test_cartpole(alg):
| 64 | 64 | 124 | 22 | 42 | yeocy/CDMCH-Pytorch | ddpg_curiosity_mc_her/common/tests/test_cartpole.py | Python | test_cartpole | test_cartpole | 22 | 40 | 22 | 24 | 9ef7f5f05ab5079d6f7916a9413e3d21e94c19be | bigcode/the-stack | train |
8d1fb954872acb6cd3b33b72 | train | class | class BrocoliDialog(tksimpledialog.Dialog, object):
def buttonbox(self):
# tweak to allow body expansion inside the simpledialog
self.initial_focus.master.pack(padx=5, pady=5, expand=True,
fill=tk.BOTH, side=tk.TOP)
self.initial_focus.master.columnconfi... | class BrocoliDialog(tksimpledialog.Dialog, object):
| def buttonbox(self):
# tweak to allow body expansion inside the simpledialog
self.initial_focus.master.pack(padx=5, pady=5, expand=True,
fill=tk.BOTH, side=tk.TOP)
self.initial_focus.master.columnconfigure(1, weight=1)
super(BrocoliDialog, self... | from six import print_
from six.moves import tkinter as tk
from six.moves import tkinter_tksimpledialog as tksimpledialog
class BrocoliDialog(tksimpledialog.Dialog, object):
| 40 | 64 | 84 | 12 | 27 | mesocentre-mcia/brocoli | brocoli/dialog.py | Python | BrocoliDialog | BrocoliDialog | 5 | 12 | 5 | 5 | 3d4ed5bb554c92c5df3c4bd59b24885cfba8ce4e | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.