Skip to content

Commit

Permalink
Merge pull request #4 from pwwang/dev
Browse files Browse the repository at this point in the history
Update header for notebooks
  • Loading branch information
pwwang authored Apr 28, 2021
2 parents 93d069f + c6f551d commit 8638216
Show file tree
Hide file tree
Showing 158 changed files with 20,072 additions and 8,836 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push, pull_request]
jobs:
docs:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
# if: github.ref == 'refs/heads/master'
strategy:
matrix:
python-version: [3.9]
Expand All @@ -21,7 +21,7 @@ jobs:
python -m pip install poetry
poetry config virtualenvs.create false
poetry install -v
- name: Update docs
- name: Build docs
run: |
python -m pip install mkdocs
python -m pip install -r docs/requirements.txt
Expand All @@ -32,8 +32,12 @@ jobs:
cp ../example.png example.png
cp ../example2.png example2.png
cd ..
mkdocs build
if : success()
- name: Deploy docs
run: |
mkdocs gh-deploy --clean --force
if: success()
if: success() && github.ref == 'refs/heads/master'

fix-index:
needs: docs
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# datar

Port of R data packages ([tidyr][1], [dplyr][2], [tibble][4], etc) in python, using [pipda][3].
Port of R data packages (especially from tidyverse): [tidyr][1], [dplyr][2], [tibble][4] and so on in python, using [pipda][3].

Unlike other similar packages in python that just mimic the piping sign, `datar` follows the API designs from the original packages as possible. So that nearly no extra effort is needed for those who are familar with those R packages to transition to python.

<!-- badges -->

Expand All @@ -12,10 +14,6 @@ Port of R data packages ([tidyr][1], [dplyr][2], [tibble][4], etc) in python, us
pip install -U datar
```

## Philosophy
- Try to keep APIs with the original ones from those R packages
- Try not to change python's default behaviors (i.e, 0-based indexing)

## Example usage

```python
Expand Down Expand Up @@ -85,7 +83,7 @@ from datar.core.contexts import Context
from datar.datasets import iris
from datar.dplyr import pull

dist_plot = register_verb(context=Context.EVAL)(klib.dist_plot)
dist_plot = register_verb(func=klib.dist_plot)
iris >> pull(f.Sepal_Length) >> dist_plot()
```

Expand Down
9 changes: 3 additions & 6 deletions datar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""Load operator, provide f and __version__"""
from pipda import Symbolic

# pylint: disable=unused-import
from .core import operator

f = Symbolic() # pylint: disable=invalid-name
from .core import operator as _datar_operator
from .core.defaults import f

__version__ = '0.0.1'
__version__ = '0.0.2'
19 changes: 14 additions & 5 deletions datar/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
"""Public APIs from this submodule"""
# pylint: disable=unused-import,redefined-builtin
from .constants import NA, TRUE, FALSE, NULL, pi, Inf, letters, LETTERS
from .verbs import colnames, rownames, dim, nrow, ncol, diag, t
from .constants import (
NA, TRUE, FALSE, NULL, pi, Inf, letters, LETTERS,
NA_character_,
NA_compex_,
NA_integer_,
NA_real_
)
from .verbs import (
colnames, rownames, dim, nrow, ncol, diag, t, names,
intersect, union, setdiff, setequal
)
from .funcs import (
as_date, as_character, as_double, as_factor, as_categorical,
as_int, as_integer, as_logical, as_bool, table, as_numeric,
c, ceiling, floor, cummax, cummin, cumprod, cumsum, cut, sample,
is_categorical, is_character, is_double, is_factor, is_float,
is_int, is_int64, is_integer, is_na, is_numeric, sum, mean, median,
min, max, as_int64, unique, Im, Re, is_in, is_element, length,
seq_along, seq_len, seq, abs, pmax, pmin, round, sqrt,
droplevels, sin, cos, identity, expandgrid
min, max, as_int64, unique, Im, Re, is_in, is_element, length, lengths,
seq_along, seq_len, seq, abs, pmax, pmin, round, sqrt, rev,
droplevels, levels, sin, cos, identity, expandgrid, all, any
)
# plain functions
from .funcs import factor, rep, context
15 changes: 11 additions & 4 deletions datar/base/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Some constants/alias for R counterparts"""
import math
import uuid
from string import ascii_letters

import numpy
Expand All @@ -9,8 +10,14 @@
FALSE = False
NULL = None

pi = math.pi # pylint: disable=invalid-name
Inf = numpy.inf # pylint: disable=invalid-name
# pylint: disable=invalid-name
pi = math.pi
Inf = numpy.inf

letters = list(ascii_letters[:26]) # pylint: disable=invalid-name
LETTERS = list(ascii_letters[26:])
letters = numpy.array(list(ascii_letters[:26])) # pylint: disable=invalid-name
LETTERS = numpy.array(list(ascii_letters[26:]))

NA_character_ = f"<NA_{uuid.uuid4()}_>"
NA_integer_ = numpy.random.randint(numpy.iinfo(numpy.int64).max)
NA_real_ = NA
NA_compex_ = complex(NA, NA)
Loading

0 comments on commit 8638216

Please sign in to comment.