spells-mtg 0.10.1__py3-none-any.whl → 0.10.3__py3-none-any.whl
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/draft_data.py +14 -5
- spells/extension.py +18 -0
- spells/manifest.py +1 -1
- {spells_mtg-0.10.1.dist-info → spells_mtg-0.10.3.dist-info}/METADATA +3 -3
- {spells_mtg-0.10.1.dist-info → spells_mtg-0.10.3.dist-info}/RECORD +8 -8
- {spells_mtg-0.10.1.dist-info → spells_mtg-0.10.3.dist-info}/WHEEL +0 -0
- {spells_mtg-0.10.1.dist-info → spells_mtg-0.10.3.dist-info}/entry_points.txt +0 -0
- {spells_mtg-0.10.1.dist-info → spells_mtg-0.10.3.dist-info}/licenses/LICENSE +0 -0
spells/draft_data.py
CHANGED
|
@@ -407,7 +407,11 @@ def _base_agg_df(
|
|
|
407
407
|
for c in cols_for_view
|
|
408
408
|
if m.col_def_map[c].col_type in (ColType.PICK_SUM, ColType.GAME_SUM)
|
|
409
409
|
)
|
|
410
|
-
|
|
410
|
+
name_sum_cols = tuple(
|
|
411
|
+
c for c in cols_for_view if m.col_def_map[c].col_type == ColType.NAME_SUM
|
|
412
|
+
)
|
|
413
|
+
|
|
414
|
+
if sum_cols or not name_sum_cols:
|
|
411
415
|
# manifest will verify that GAME_SUM manifests do not use NAME grouping
|
|
412
416
|
name_col_tuple = (
|
|
413
417
|
(pl.col(ColName.PICK).alias(ColName.NAME),) if is_name_gb else ()
|
|
@@ -418,9 +422,6 @@ def _base_agg_df(
|
|
|
418
422
|
grouped = sum_col_df.group_by(group_by) if group_by else sum_col_df
|
|
419
423
|
join_dfs.append(grouped.sum().collect(streaming=use_streaming))
|
|
420
424
|
|
|
421
|
-
name_sum_cols = tuple(
|
|
422
|
-
c for c in cols_for_view if m.col_def_map[c].col_type == ColType.NAME_SUM
|
|
423
|
-
)
|
|
424
425
|
for col in name_sum_cols:
|
|
425
426
|
names = get_names(set_code)
|
|
426
427
|
expr = tuple(pl.col(f"{col}_{name}").alias(name) for name in names)
|
|
@@ -611,4 +612,12 @@ def view_select(
|
|
|
611
612
|
else:
|
|
612
613
|
base_df = base_df_prefilter
|
|
613
614
|
|
|
614
|
-
|
|
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)
|
spells/extension.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
1
3
|
import math
|
|
2
4
|
|
|
3
5
|
import polars as pl
|
|
@@ -13,6 +15,19 @@ def print_ext(ext: dict[str, ColSpec]) -> None:
|
|
|
13
15
|
print("\t" + key)
|
|
14
16
|
|
|
15
17
|
|
|
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
|
+
|
|
16
31
|
def context_cols(attr, silent: bool = False) -> dict[str, ColSpec]:
|
|
17
32
|
ext = {
|
|
18
33
|
f"seen_{attr}": ColSpec(
|
|
@@ -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}")
|
spells/manifest.py
CHANGED
|
@@ -208,7 +208,7 @@ def create(
|
|
|
208
208
|
else:
|
|
209
209
|
needed_views = needed_views.union({View.GAME, View.DRAFT})
|
|
210
210
|
|
|
211
|
-
view_cols = {v: view_cols
|
|
211
|
+
view_cols = {v: view_cols.get(v, frozenset({ColName.PICK})) for v in needed_views}
|
|
212
212
|
|
|
213
213
|
return Manifest(
|
|
214
214
|
columns=cols,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: spells-mtg
|
|
3
|
-
Version: 0.10.
|
|
3
|
+
Version: 0.10.3
|
|
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.
|
|
@@ -3,17 +3,17 @@ spells/cache.py,sha256=7XDcltmlpagK2nkhuCCcAQVyrFMYkw9Acr7iVsLs3JU,3799
|
|
|
3
3
|
spells/cards.py,sha256=6stFPhJOzHqvQnkSv9cDeylRa_7L9Y8sOaowiZhzz6I,4174
|
|
4
4
|
spells/columns.py,sha256=tQPhFpG4vOMIjV111p8DK4V-d_8634xoE-csBzou_sw,18008
|
|
5
5
|
spells/config.py,sha256=_t98dc_uY3Wp3d5tsU3CJgVcWOD3wVlwMo98-tN2KRY,213
|
|
6
|
-
spells/draft_data.py,sha256=
|
|
6
|
+
spells/draft_data.py,sha256=xoL82NTgTJWxZK1p-6LjxnYzkeYOr-Dc9-_T0m-WZ1Y,19946
|
|
7
7
|
spells/enums.py,sha256=MwJ9694AVoaKE22WlFjzHPcRfrU0DKI2_mrWC6_YjhE,4931
|
|
8
|
-
spells/extension.py,sha256=
|
|
8
|
+
spells/extension.py,sha256=sqlMSzJgNLj_B1QY97TAnPPLmCTFI8ixqae_929upJ0,7509
|
|
9
9
|
spells/external.py,sha256=XZpZ0mn8_BmiF76xEiu2KblZ-dwOxmbs6vrDftl2XbI,11846
|
|
10
10
|
spells/filter.py,sha256=J-YTOOAzOQpvIX29tviYL04RVoOUlfsbjBXoQBDCEdQ,3380
|
|
11
11
|
spells/log.py,sha256=3avmg65hru8K9npKLvPp1wWWxq-hoEYDUCbxqhPkKUw,2175
|
|
12
|
-
spells/manifest.py,sha256=
|
|
12
|
+
spells/manifest.py,sha256=iOmhxIVMHu_Av3nd23zGjmUwLvZ2hAM0oc1ErPzZ_oE,8341
|
|
13
13
|
spells/schema.py,sha256=DbMvV8PIThJTp0Xzp_XIorlW6JhE1ud1kWRGf5SQ4_c,6406
|
|
14
14
|
spells/utils.py,sha256=IO3brrXVvZla0LRTEB5v6NgGqZb_rYA46XtKBURGMNk,1944
|
|
15
|
-
spells_mtg-0.10.
|
|
16
|
-
spells_mtg-0.10.
|
|
17
|
-
spells_mtg-0.10.
|
|
18
|
-
spells_mtg-0.10.
|
|
19
|
-
spells_mtg-0.10.
|
|
15
|
+
spells_mtg-0.10.3.dist-info/METADATA,sha256=m6PPLlYg905iivI0pXkrmeg7TTPUkOSEvFE7Dx8cMEU,47227
|
|
16
|
+
spells_mtg-0.10.3.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
|
17
|
+
spells_mtg-0.10.3.dist-info/entry_points.txt,sha256=a9Y1omdl9MdnKuIj3aOodgrp-zZII6OCdvqwgP6BFvI,63
|
|
18
|
+
spells_mtg-0.10.3.dist-info/licenses/LICENSE,sha256=tS54XYbJSgmq5zuHhbsQGbNQLJPVgXqhF5nu2CSRMig,1068
|
|
19
|
+
spells_mtg-0.10.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|