Skip to content

Commit

Permalink
version bump, test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
TyberiusPrime committed Nov 27, 2023
1 parent 5e345b1 commit 60de1c8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Changelog
unreleased
==========

0.26
====
- added .dir_dppd() to list just dppd registered verb, not those wrapping the object itself.
- dp(DataFrame).insert() now returns self and is therefore chainable.

0.25
====

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[metadata]
name = dppd
description = A pythonic dplyr clone
version=0.25
version=0.26
author = Florian Finkernagel
author-email = [email protected]
license = mit
Expand Down
2 changes: 1 addition & 1 deletion src/dppd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
from . import single_verbs # noqa:F401
from . import non_df_verbs # noqa:F401

__version__ = "0.25"
__version__ = "0.26"

__all_ = [dppd, register_verb, register_type_methods_as_verbs, __version__]
5 changes: 2 additions & 3 deletions src/dppd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def inner(*args, **kwargs):
if not self.ignore_redefine:
print(verb_registry.keys())
warnings.warn(f"redefining verb {real_name} for type {t}")
if t in property_registry and real_name in property_registry[t]:
if t in property_registry and real_name in property_registry[t]:
if not self.ignore_redefine:
warnings.warn(f"verb {real_name} shadows property for type {t}")

outer.__doc__ == func.__doc__
Expand Down Expand Up @@ -139,7 +140,6 @@ def __init__(self, df, dppd_proxy, X, parent):
elif isinstance(df, Dppd):
df = df.df
if df is not None and type(df) not in dppd_types:

raise ValueError(
f"Dppd was passed a {type(df)} for which no properties have "
"been registered. That sounds like a bug."
Expand Down Expand Up @@ -177,7 +177,6 @@ def dir_dppd(self):
new = total - old
return sorted(new)


def __call__(self, df=None):
if df is None:
if self.df is None:
Expand Down
21 changes: 16 additions & 5 deletions tests/test_single_verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ def test_summarise_non_tuple():

def test_summarize_auto_name():
actual = dp(mtcars).groupby("cyl").summarize(("hp", np.min)).pd
assert "hp_amin" in actual.columns or 'hp_min' in actual.columns
assert "hp_amin" in actual.columns or "hp_min" in actual.columns


def test_do():
Expand Down Expand Up @@ -911,9 +911,7 @@ def test_iter_tuples_in_group_by():
actual = {k: list(v) for (k, v) in dp(mtcars).groupby("cyl").itertuples()}
should = {}
for key, sub_df in mtcars.groupby("cyl"):
should[
key,
] = list(sub_df.itertuples())
should[key, ] = list(sub_df.itertuples())
assert actual == should


Expand Down Expand Up @@ -1002,4 +1000,17 @@ def test_dataframe_from_counter():
actual = dp(c).to_frame(key_name="X", count_name="Y").pd
actual = actual.sort_values("X").reset_index(drop=True)
should = pd.DataFrame({"X": ["a", "l", "m"], "Y": [2, 2, 1]})
assert_frame_equal(actual, should, )
assert_frame_equal(
actual,
should,
)


def test_dataframe_insert():
actual = (
dp(pd.DataFrame({"x": [1, 2, 3], "y": ["a", "b", "c"]}))
.insert(0, "a", [4, 5, 6])
.pd
)
should = pd.DataFrame({"a": [4, 5, 6], "x": [1, 2, 3], "y": ["a", "b", "c"]})
assert_frame_equal(actual, should)

0 comments on commit 60de1c8

Please sign in to comment.