Skip to content

Commit

Permalink
Merge pull request #36 from westandskif/add/unordered_chunk_by
Browse files Browse the repository at this point in the history
added c.unordered_chunk_by` + misc
  • Loading branch information
westandskif authored Sep 1, 2024
2 parents 2e8fbb3 + b0a49b4 commit 48b0cf7
Show file tree
Hide file tree
Showing 74 changed files with 543 additions and 47 deletions.
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@
install:
poetry install --with=test,lint,docs

docs:
dynamic_docs_examples:
python build-docs-examples.py

dynamic_docs_performance:
python build-docs-performance.py

docs_drop:
docs_drop_dynamic_md:
rm docs/examples-md/.last_build.csv || true

docs_serve: docs
docs:
mkdocs serve

build:
find dist -delete || true
hatch build

upload:
hatch publish

spellcheck:
find . \( -name "*.rst" -o -name "*.py" \) -not -path "./build/*" -not -path "./tests/*" -exec aspell/aspell {} \;

Expand Down
1 change: 1 addition & 0 deletions build-docs-examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def write_md_example(raw_example_path, output):
```python
{output}
```
{{ data-search-exclude }}
///
"""
Expand Down
6 changes: 6 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.14.0 (2024-09-01)

- added `c.unordered_chunk_by`
- added short paths for `Sum` and `DictLast` in single-reducer cases of
`c.aggregate`

## 1.13.2 (2024-08-29)

- sped up code generation for aggregations
Expand Down
16 changes: 16 additions & 0 deletions docs/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ We'll cover aggregations later, but bear with me -- chunk conversions have

{!examples-md/api__chunk_aggregate.md!}

#### unordered_chunk_by

Slice an iterable into chunks by values and sizes without keeping order of
items.

```python
c.unordered_chunk_by(
--8<-- "src/convtools/_chunks.py:unordered_chunk_by_signature"
)
```

--8<-- "src/convtools/_chunks.py:unordered_chunk_by_args_docs"


{!examples-md/api__unordered_chunk.md!}


#### take_while, drop_while

Expand Down
1 change: 1 addition & 0 deletions docs/examples-md/api__and_then.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__as_type.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__chunk.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__chunk_aggregate.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__collections_optional.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__comp.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

5 changes: 3 additions & 2 deletions docs/examples-md/api__cumulative.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ assert (
/// tab | debug stdout
```python
def pipe_(_labels, input_):
result_ = (input_ + _labels["b657550eadad4341883c89be21642274"]) if ("b657550eadad4341883c89be21642274" in _labels) else input_
_labels["b657550eadad4341883c89be21642274"] = result_
result_ = (input_ + _labels["2e4a2feb28e740e5a3a7f341339d091d"]) if ("2e4a2feb28e740e5a3a7f341339d091d" in _labels) else input_
_labels["2e4a2feb28e740e5a3a7f341339d091d"] = result_
return result_

def _converter(data_):
Expand All @@ -30,5 +30,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__cumulative_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

5 changes: 3 additions & 2 deletions docs/examples-md/api__dates_format.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ assert converter(date(2020, 12, 31)) == "Thu Dec 31 00:00:00 2020"

/// tab | debug stdout
```python
def _converter(data_, *, __datetime=__naive_values__["__datetime"], __v=__naive_values__["__v"]):
def _converter(data_, *, __v=__naive_values__["__v"], __datetime=__naive_values__["__datetime"]):
try:
is_datetime = isinstance(data_, __datetime)
hour = data_.hour if is_datetime else 0
Expand All @@ -38,7 +38,7 @@ def _converter(data_, *, __datetime=__naive_values__["__datetime"]):
__convtools__code_storage.dump_sources()
raise

def _converter(data_, *, __strftime=__naive_values__["__strftime"], __datetime=__naive_values__["__datetime"], __v=__naive_values__["__v"]):
def _converter(data_, *, __strftime=__naive_values__["__strftime"], __v=__naive_values__["__v"], __datetime=__naive_values__["__datetime"]):
try:
return __strftime(data_, __v)
except __exceptions_to_dump_sources:
Expand All @@ -47,5 +47,6 @@ def _converter(data_, *, __strftime=__naive_values__["__strftime"], __datetime=_


```
{ data-search-exclude }
///

9 changes: 5 additions & 4 deletions docs/examples-md/api__dates_parse.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ assert converter({"dt": "12/31/2020 15:40"}) == datetime(

/// tab | debug stdout
```python
def _datetime_parse(data_, *, __v=__naive_values__["__v"], __datetime=__naive_values__["__datetime"]):
def _datetime_parse(data_, *, __datetime=__naive_values__["__datetime"], __v=__naive_values__["__v"]):
match = __v.match(data_)
if not match:
raise ValueError("time data %r does not match format %r" % (data_, """%m/%d/%Y"""))
Expand All @@ -49,7 +49,7 @@ def _converter(data_):
__convtools__code_storage.dump_sources()
raise

def _datetime_parse(data_, *, __v=__naive_values__["__v"], __datetime=__naive_values__["__datetime"]):
def _datetime_parse(data_, *, __datetime=__naive_values__["__datetime"], __v=__naive_values__["__v"]):
match = __v.match(data_)
if not match:
raise ValueError("time data %r does not match format %r" % (data_, """%m/%d/%Y"""))
Expand All @@ -58,7 +58,7 @@ def _datetime_parse(data_, *, __v=__naive_values__["__v"], __datetime=__naive_va
groups_ = match.groups()
return __datetime(int(groups_[2]), int(groups_[0]), int(groups_[1]), 0, 0, 0, 0)

def _datetime_parse_e(data_, *, __v_q=__naive_values__["__v_q"], __datetime=__naive_values__["__datetime"]):
def _datetime_parse_e(data_, *, __datetime=__naive_values__["__datetime"], __v_q=__naive_values__["__v_q"]):
match = __v_q.match(data_)
if not match:
raise ValueError("time data %r does not match format %r" % (data_, """%Y-%m-%d"""))
Expand All @@ -81,7 +81,7 @@ def _converter(data_):
__convtools__code_storage.dump_sources()
raise

def _datetime_parse(data_, *, __v=__naive_values__["__v"], __datetime=__naive_values__["__datetime"]):
def _datetime_parse(data_, *, __datetime=__naive_values__["__datetime"], __v=__naive_values__["__v"]):
match = __v.match(data_)
if not match:
raise ValueError("time data %r does not match format %r" % (data_, """%m/%d/%Y %H:%M"""))
Expand All @@ -99,5 +99,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__dates_parse__default.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__dates_trunc.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@ def _converter(data_, *, __datetime_trunc_to_microsecond=__naive_values__["__dat


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__dispatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ def _converter(data_, *, __v=__naive_values__["__v"], ___branch_else=__naive_val


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__expect.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__if.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__inline_n_escaped.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__iter_mut.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ def _converter(data_, *, extra):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__iter_unique.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__iter_windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ def _converter(data_, *, __iter_windows=__naive_values__["__iter_windows"]):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@ def _converter(data_, *, __v=__naive_values__["__v"]):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__pipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__pipe_callable.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ def _converter(data_, *, __v=__naive_values__["__v"], __strptime=__naive_values_


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__pipe_labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ def _converter(data_, *, __repeat=__naive_values__["__repeat"]):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__sorting_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__take_drop_while.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__tap.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ def _converter(data_, *, data):


```
{ data-search-exclude }
///

1 change: 1 addition & 0 deletions docs/examples-md/api__try.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ def _converter(data_):


```
{ data-search-exclude }
///

Loading

0 comments on commit 48b0cf7

Please sign in to comment.