Skip to content

Commit 0d92550

Browse files
authored
0.4.0 (#39)
* Fix SettingwithCopyWarning in pivot_longer; Use regular calling internally to make sure it works in some cases that node cannot be detected (ie Gooey) * Adopt pipda v0.4.2 * Refactor core.grouped to adopt pandas's groupby * Add performance notebook * 0.4.0 * `datar.datar_versions()` to show versions of related packages for bug reporting. * Fix testing * Fix cov reporting
1 parent c95a4b4 commit 0d92550

File tree

117 files changed

+23469
-9601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+23469
-9601
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
if: matrix.python-version == 3.8
6060
with:
6161
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
62-
coverage-reports: .coverage.xml
62+
coverage-reports: cov.xml
6363

6464
deploy:
6565
needs: build

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ docs/logo.png
111111
docs/example.png
112112
docs/example2.png
113113
docs/api/
114+
docs/*.nbconvert.ipynb
115+
docs/*/*.nbconvert.ipynb
114116

115117
# vscode's local history extension
116118
.history/

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ repos:
5454
args: [tests/]
5555
pass_filenames: false
5656
files: ^tests/.+$|^datar/.+$
57-
# - id: mkdocs
58-
# name: Compile docs
59-
# entry: mkdocs
60-
# language: system
61-
# args: [build]
62-
# pass_filenames: false
63-
# files: ^datar/.+$
57+
- id: notebooks
58+
name: Executing all notebooks
59+
entry: jupyter nbconvert --to notebook --execute
60+
language: system
61+
pass_filenames: true
62+
files: ^docs/.+\.ipynb$
63+
exclude: '^docs/.+\.nbconvert\.ipynb$'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Port of [dplyr][2] and other related R packages in python, using [pipda][3].
99

1010
<img width="30%" style="margin: 10px 10px 10px 30px" align="right" src="logo.png">
1111

12-
Unlike other similar packages in python that just mimic the piping syntax, `datar` follows the API designs from the original packages as much as possible. So that minimal effort is needed for those who are familar with those R packages to transition to python.
12+
Unlike other similar packages in python that just mimic the piping syntax, `datar` follows the API designs from the original packages as much as possible, and is tested thoroughly with the cases from the original packages. So that minimal effort is needed for those who are familar with those R packages to transition to python.
1313

1414

1515
## Installtion

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Port of `dplyr <https://dplyr.tidyverse.org/index.html>`_ and other related R pa
3838

3939
:raw-html-m2r:`<img width="30%" style="margin: 10px 10px 10px 30px" align="right" src="logo.png">`
4040

41-
Unlike other similar packages in python that just mimic the piping syntax, ``datar`` follows the API designs from the original packages as much as possible. So that minimal effort is needed for those who are familar with those R packages to transition to python.
41+
Unlike other similar packages in python that just mimic the piping syntax, ``datar`` follows the API designs from the original packages as much as possible, and is tested thoroughly with the cases from the original packages. So that minimal effort is needed for those who are familar with those R packages to transition to python.
4242

4343
Installtion
4444
-----------

datar/__init__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
"""Load operator, provide f and __version__"""
22
# pylint: disable=unused-import
3+
from typing import Mapping
4+
35
from .core import operator as _
46
from .core import _frame_format_patch
57
from .core.defaults import f
68

7-
__version__ = "0.3.2"
9+
__all__ = ('f', 'datar_versions')
10+
__version__ = "0.4.0"
11+
12+
def datar_versions() -> Mapping[str, str]: # pragma: no cover
13+
"""Get related versions which help for bug reporting."""
14+
15+
import pandas
16+
import pipda
17+
import varname
18+
from diot import Diot
19+
20+
return Diot(
21+
pandas=pandas.__version__,
22+
pipda=pipda.__version__,
23+
varname=varname.__version__,
24+
)

datar/base/arithmetic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def _register_arithmetic_agg(
1919
) -> Callable:
2020
"""Register an arithmetic function"""
2121

22-
@register_func(None, context=Context.EVAL)
2322
def _arithmetric(x: Iterable, na_rm: bool = False) -> Iterable:
2423
"""Arithmetric function"""
2524
# na_rm not working for numpy functions
@@ -32,7 +31,7 @@ def _arithmetric(x: Iterable, na_rm: bool = False) -> Iterable:
3231

3332
_arithmetric.__name__ = name
3433
_arithmetric.__doc__ = doc
35-
return _arithmetric
34+
return register_func(None, context=Context.EVAL, func=_arithmetric)
3635

3736

3837
# pylint: disable=invalid-name

datar/core/_frame_format_patch.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,13 @@ def grouping_info(self) -> str:
9696
from .grouped import DataFrameGroupBy, DataFrameRowwise
9797

9898
if isinstance(self.frame, DataFrameRowwise):
99-
return f"\n[Rowwise: {', '.join(self.frame._group_vars)}]"
99+
return f"\n[Rowwise: {', '.join(self.frame.attrs['_group_vars'])}]"
100100

101101
if isinstance(self.frame, DataFrameGroupBy):
102102
ngroups = self.frame._group_data.shape[0]
103103
return (
104-
f"\n[Groups: {', '.join(self.frame._group_vars)} (n={ngroups})]"
104+
f"\n[Groups: {', '.join(self.frame.attrs['_group_vars'])} "
105+
f"(n={ngroups})]"
105106
)
106107

107108
return None
@@ -463,10 +464,13 @@ def render(self) -> List[str]:
463464
self._write_table()
464465

465466
if isinstance(self.frame, DataFrameRowwise):
466-
self.write(f"<p>Rowwise: {self.frame._group_vars}</p>")
467+
self.write(f"<p>Rowwise: {self.frame.attrs['_group_vars']}</p>")
467468
elif isinstance(self.frame, DataFrameGroupBy):
468469
ngroups = self.frame._group_data.shape[0]
469-
self.write(f"<p>Groups: {self.frame._group_vars} (n={ngroups})</p>")
470+
self.write(
471+
f"<p>Groups: {self.frame.attrs['_group_vars']} "
472+
f"(n={ngroups})</p>"
473+
)
470474

471475
if self.should_show_dimensions:
472476
by = chr(215) # ×

0 commit comments

Comments
 (0)