spells-mtg 0.10.2__tar.gz → 0.10.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of spells-mtg might be problematic. Click here for more details.
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/PKG-INFO +3 -3
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/README.md +2 -2
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/pyproject.toml +1 -1
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/draft_data.py +9 -1
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/extension.py +20 -2
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/LICENSE +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/__init__.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/cache.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/cards.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/columns.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/config.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/enums.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/external.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/filter.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/log.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/manifest.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/schema.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/spells/utils.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/tests/__init__.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/tests/filter_test.py +0 -0
- {spells_mtg-0.10.2 → spells_mtg-0.10.4}/tests/utils_test.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: spells-mtg
|
|
3
|
-
Version: 0.10.
|
|
3
|
+
Version: 0.10.4
|
|
4
4
|
Summary: analaysis of 17Lands.com public datasets
|
|
5
5
|
Author-Email: Joel Barnes <oelarnes@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -304,7 +304,7 @@ summon(
|
|
|
304
304
|
set_context: pl.DataFrame | dict[str, Any] | None = None,
|
|
305
305
|
read_cache: bool = True,
|
|
306
306
|
write_cache: bool = True,
|
|
307
|
-
use_streaming: bool =
|
|
307
|
+
use_streaming: bool = True,
|
|
308
308
|
log_to_console: int = logging.ERROR,
|
|
309
309
|
) -> polars.DataFrame
|
|
310
310
|
```
|
|
@@ -365,7 +365,7 @@ Used to define extensions in `summon`
|
|
|
365
365
|
and `AGG` must be derivable at the individual row level on one or both base views. `CARD_ATTR` must be derivable at the individual row level from the card file. `AGG` can depend on any column present after
|
|
366
366
|
summing over groups, and can include polars Expression aggregations. Arbitrarily long chains of aggregate dependencies are supported.
|
|
367
367
|
|
|
368
|
-
- `expr`: A polars expression or function returning a polars expression giving the derivation of the column value at the first level where it is defined.
|
|
368
|
+
- `expr`: A polars expression or function returning a polars expression giving the derivation of the column value at the first level where it is defined. The name is inferred from the dictionary key in the extensions argument, you do not need to specify an alias.
|
|
369
369
|
- For `NAME_SUM` columns, `expr` must be a function of `name` which will result in a list of expressions mapped over all card names.
|
|
370
370
|
- `PICK_SUM` columns can also be functions on `name`, in which case the value will be a function of the value of the `PICK` field.
|
|
371
371
|
- `AGG` columns that depend on `NAME_SUM` columns reference the prefix (`cdef.name`) only, since the unpivot has occured prior to selection.
|
|
@@ -293,7 +293,7 @@ summon(
|
|
|
293
293
|
set_context: pl.DataFrame | dict[str, Any] | None = None,
|
|
294
294
|
read_cache: bool = True,
|
|
295
295
|
write_cache: bool = True,
|
|
296
|
-
use_streaming: bool =
|
|
296
|
+
use_streaming: bool = True,
|
|
297
297
|
log_to_console: int = logging.ERROR,
|
|
298
298
|
) -> polars.DataFrame
|
|
299
299
|
```
|
|
@@ -354,7 +354,7 @@ Used to define extensions in `summon`
|
|
|
354
354
|
and `AGG` must be derivable at the individual row level on one or both base views. `CARD_ATTR` must be derivable at the individual row level from the card file. `AGG` can depend on any column present after
|
|
355
355
|
summing over groups, and can include polars Expression aggregations. Arbitrarily long chains of aggregate dependencies are supported.
|
|
356
356
|
|
|
357
|
-
- `expr`: A polars expression or function returning a polars expression giving the derivation of the column value at the first level where it is defined.
|
|
357
|
+
- `expr`: A polars expression or function returning a polars expression giving the derivation of the column value at the first level where it is defined. The name is inferred from the dictionary key in the extensions argument, you do not need to specify an alias.
|
|
358
358
|
- For `NAME_SUM` columns, `expr` must be a function of `name` which will result in a list of expressions mapped over all card names.
|
|
359
359
|
- `PICK_SUM` columns can also be functions on `name`, in which case the value will be a function of the value of the `PICK` field.
|
|
360
360
|
- `AGG` columns that depend on `NAME_SUM` columns reference the prefix (`cdef.name`) only, since the unpivot has occured prior to selection.
|
|
@@ -612,4 +612,12 @@ def view_select(
|
|
|
612
612
|
else:
|
|
613
613
|
base_df = base_df_prefilter
|
|
614
614
|
|
|
615
|
-
|
|
615
|
+
select_defs = [col_def_map[c] for c in columns]
|
|
616
|
+
select_names = []
|
|
617
|
+
for d in select_defs:
|
|
618
|
+
if d.col_type == ColType.NAME_SUM:
|
|
619
|
+
select_names.extend([expr.meta.output_name() for expr in d.expr])
|
|
620
|
+
else:
|
|
621
|
+
select_names.append(d.expr.meta.output_name())
|
|
622
|
+
|
|
623
|
+
return base_df.select(select_names)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
1
3
|
import math
|
|
2
4
|
|
|
3
5
|
import polars as pl
|
|
@@ -13,7 +15,20 @@ def print_ext(ext: dict[str, ColSpec]) -> None:
|
|
|
13
15
|
print("\t" + key)
|
|
14
16
|
|
|
15
17
|
|
|
16
|
-
def
|
|
18
|
+
def seen_greatest_name_fn(attr: str) -> Callable:
|
|
19
|
+
def inner(names: list[str]) -> pl.Expr:
|
|
20
|
+
expr = pl.lit(None)
|
|
21
|
+
for name in names:
|
|
22
|
+
expr = (
|
|
23
|
+
pl.when(pl.col(f"seen_{attr}_is_greatest_{name}"))
|
|
24
|
+
.then(pl.lit(name))
|
|
25
|
+
.otherwise(expr)
|
|
26
|
+
)
|
|
27
|
+
return expr
|
|
28
|
+
return inner
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def context_cols(attr, silent: bool = True) -> dict[str, ColSpec]:
|
|
17
32
|
ext = {
|
|
18
33
|
f"seen_{attr}": ColSpec(
|
|
19
34
|
col_type=ColType.NAME_SUM,
|
|
@@ -41,6 +56,9 @@ def context_cols(attr, silent: bool = False) -> dict[str, ColSpec]:
|
|
|
41
56
|
expr=lambda name: pl.col(f"seen_{attr}_{name}")
|
|
42
57
|
== pl.col(f"greatest_{attr}_seen"),
|
|
43
58
|
),
|
|
59
|
+
f"seen_greatest_{attr}_name": ColSpec(
|
|
60
|
+
col_type=ColType.GROUP_BY, expr=seen_greatest_name_fn(attr)
|
|
61
|
+
),
|
|
44
62
|
f"seen_{attr}_greater": ColSpec(
|
|
45
63
|
col_type=ColType.NAME_SUM,
|
|
46
64
|
expr=lambda name: pl.col(f"seen_{attr}_{name}")
|
|
@@ -127,7 +145,7 @@ def context_cols(attr, silent: bool = False) -> dict[str, ColSpec]:
|
|
|
127
145
|
return ext
|
|
128
146
|
|
|
129
147
|
|
|
130
|
-
def stat_cols(attr: str, silent: bool =
|
|
148
|
+
def stat_cols(attr: str, silent: bool = True) -> dict[str, ColSpec]:
|
|
131
149
|
ext = {
|
|
132
150
|
f"{attr}_deck_weight_group": ColSpec(
|
|
133
151
|
col_type=ColType.AGG, expr=pl.col(f"{attr}") * pl.col(ColName.DECK)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|