Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_row_drop_xor_reducer():
"""Testing the ColDrop pipeline stage."""
res_df = RowDrop([lambda x: x < 3]).apply(DF3)
assert 1 not in res_df.index
assert 2 not in res_df.index
assert 3 in res_df.index
res_df = RowDrop([lambda x: x < 3], reduce='xor').apply(DF3)
assert 1 in res_df.index
assert 2 not in res_df.index
assert 3 in res_df.index
def test_row_drop_all_reducer():
"""Testing the ColDrop pipeline stage."""
res_df = RowDrop([lambda x: x < 3]).apply(DF3)
assert 1 not in res_df.index
assert 2 not in res_df.index
assert 3 in res_df.index
res_df = RowDrop([lambda x: x < 3], reduce='all').apply(DF3)
assert 1 not in res_df.index
assert 2 in res_df.index
assert 3 in res_df.index
def test_row_drop_bad_reducer():
"""Testing the ColDrop pipeline stage."""
with pytest.raises(ValueError):
RowDrop([lambda x: x < 2], reduce='al')
def test_row_drop_all_reducer():
"""Testing the ColDrop pipeline stage."""
res_df = RowDrop([lambda x: x < 3]).apply(DF3)
assert 1 not in res_df.index
assert 2 not in res_df.index
assert 3 in res_df.index
res_df = RowDrop([lambda x: x < 3], reduce='all').apply(DF3)
assert 1 not in res_df.index
assert 2 in res_df.index
assert 3 in res_df.index
def test_row_drop_columns():
"""Testing the ColDrop pipeline stage."""
res_df = RowDrop([lambda x: x < 2]).apply(DF2)
assert 1 not in res_df.index
assert 2 not in res_df.index
assert 3 in res_df.index
res_df = RowDrop([lambda x: x < 2], columns=['a', 'b']).apply(DF2)
assert 1 not in res_df.index
assert 2 in res_df.index
assert 3 in res_df.index
def test_row_drop_xor_reducer():
"""Testing the ColDrop pipeline stage."""
res_df = RowDrop([lambda x: x < 3]).apply(DF3)
assert 1 not in res_df.index
assert 2 not in res_df.index
assert 3 in res_df.index
res_df = RowDrop([lambda x: x < 3], reduce='xor').apply(DF3)
assert 1 in res_df.index
assert 2 not in res_df.index
assert 3 in res_df.index
def test_row_drop_verbose():
"""Testing the ColDrop pipeline stage."""
res_df = RowDrop([lambda x: x < 2]).apply(DF1, verbose=True)
assert 1 not in res_df.index
assert 2 in res_df.index
assert 3 in res_df.index
def test_row_droo_bad_columns():
"""Testing the ColDrop pipeline stage."""
with pytest.raises(FailedPreconditionError):
RowDrop([lambda x: x < 2], columns=['d']).apply(DF1)
self._columns_str = ""
if self._cond_is_dict:
valid = all([callable(cond) for cond in conditions.values()])
if not valid:
raise ValueError(
"Condition dicts given to RowDrop must map to callables!")
self._columns = list(conditions.keys())
self._columns_str = _list_str(self._columns)
else:
valid = all([callable(cond) for cond in conditions])
if not valid:
raise ValueError(
"RowDrop condition lists can contain only callables!")
self._row_cond = self._row_condition_builder(conditions, reduce)
super_kwargs = {
'exmsg': RowDrop._DEF_ROWDROP_EXC_MSG.format(self._columns_str),
'appmsg': RowDrop._DEF_ROWDROP_APPLY_MSG.format(self._columns_str),
'desc': self._default_desc()
}
super_kwargs.update(**kwargs)
super().__init__(**super_kwargs)
if self._cond_is_dict:
valid = all([callable(cond) for cond in conditions.values()])
if not valid:
raise ValueError(
"Condition dicts given to RowDrop must map to callables!")
self._columns = list(conditions.keys())
self._columns_str = _list_str(self._columns)
else:
valid = all([callable(cond) for cond in conditions])
if not valid:
raise ValueError(
"RowDrop condition lists can contain only callables!")
self._row_cond = self._row_condition_builder(conditions, reduce)
super_kwargs = {
'exmsg': RowDrop._DEF_ROWDROP_EXC_MSG.format(self._columns_str),
'appmsg': RowDrop._DEF_ROWDROP_APPLY_MSG.format(self._columns_str),
'desc': self._default_desc()
}
super_kwargs.update(**kwargs)
super().__init__(**super_kwargs)