spells-mtg 0.7.4__py3-none-any.whl → 0.8.1__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/__init__.py +2 -2
- spells/columns.py +2 -0
- spells/draft_data.py +54 -4
- spells/manifest.py +5 -5
- {spells_mtg-0.7.4.dist-info → spells_mtg-0.8.1.dist-info}/METADATA +1 -1
- spells_mtg-0.8.1.dist-info/RECORD +16 -0
- spells_mtg-0.7.4.dist-info/RECORD +0 -16
- {spells_mtg-0.7.4.dist-info → spells_mtg-0.8.1.dist-info}/WHEEL +0 -0
- {spells_mtg-0.7.4.dist-info → spells_mtg-0.8.1.dist-info}/entry_points.txt +0 -0
- {spells_mtg-0.7.4.dist-info → spells_mtg-0.8.1.dist-info}/licenses/LICENSE +0 -0
spells/__init__.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from spells.columns import ColSpec
|
|
2
2
|
from spells.enums import ColType, ColName
|
|
3
|
-
from spells.draft_data import summon
|
|
3
|
+
from spells.draft_data import summon, view_select, get_names
|
|
4
4
|
|
|
5
|
-
__all__ = ["summon", "ColSpec", "ColType", "ColName"]
|
|
5
|
+
__all__ = ["summon", "view_select", "get_names", "ColSpec", "ColType", "ColName"]
|
spells/columns.py
CHANGED
spells/draft_data.py
CHANGED
|
@@ -35,7 +35,7 @@ def _cache_key(args) -> str:
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
@functools.lru_cache(maxsize=None)
|
|
38
|
-
def
|
|
38
|
+
def get_names(set_code: str) -> list[str]:
|
|
39
39
|
card_fp = data_file_path(set_code, View.CARD)
|
|
40
40
|
card_view = pl.read_parquet(card_fp)
|
|
41
41
|
card_names_set = frozenset(card_view.get_column("name").to_list())
|
|
@@ -86,7 +86,7 @@ def _get_card_context(
|
|
|
86
86
|
|
|
87
87
|
loaded_context = {row[ColName.NAME]: row for row in select_rows}
|
|
88
88
|
else:
|
|
89
|
-
names =
|
|
89
|
+
names = get_names(set_code)
|
|
90
90
|
loaded_context = {name: {} for name in names}
|
|
91
91
|
|
|
92
92
|
if card_context is not None:
|
|
@@ -265,7 +265,7 @@ def _hydrate_col_defs(
|
|
|
265
265
|
set_context: pl.DataFrame | dict[str, Any] | None = None,
|
|
266
266
|
card_only: bool = False,
|
|
267
267
|
):
|
|
268
|
-
names =
|
|
268
|
+
names = get_names(set_code)
|
|
269
269
|
|
|
270
270
|
set_context = _get_set_context(set_code, set_context)
|
|
271
271
|
|
|
@@ -538,7 +538,14 @@ def summon(
|
|
|
538
538
|
), "What happened? We mean to use one of the sets manifest, it shouldn't matter which."
|
|
539
539
|
|
|
540
540
|
if m.group_by:
|
|
541
|
-
|
|
541
|
+
gb = m.group_by
|
|
542
|
+
# an agg may depend on some card column that hasn't been explicitly requested, but can be safely
|
|
543
|
+
# depended on if we are grouping by name
|
|
544
|
+
if ColName.NAME in m.group_by and View.CARD in m.view_cols:
|
|
545
|
+
for col in m.view_cols[View.CARD]:
|
|
546
|
+
if col not in m.group_by:
|
|
547
|
+
gb = tuple([*gb, col])
|
|
548
|
+
full_agg_df = full_agg_df.group_by(gb).sum()
|
|
542
549
|
else:
|
|
543
550
|
full_agg_df = full_agg_df.sum()
|
|
544
551
|
|
|
@@ -550,3 +557,46 @@ def summon(
|
|
|
550
557
|
)
|
|
551
558
|
|
|
552
559
|
return ret_df
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
def view_select(
|
|
563
|
+
set_code: str,
|
|
564
|
+
view: View,
|
|
565
|
+
columns: list[str],
|
|
566
|
+
filter_spec: dict | None = None,
|
|
567
|
+
extensions: dict[str, ColSpec] | list[dict[str, ColSpec]] | None = None,
|
|
568
|
+
card_context: dict | pl.DataFrame | None = None,
|
|
569
|
+
set_context: dict | pl.DataFrame | None = None,
|
|
570
|
+
) -> pl.LazyFrame:
|
|
571
|
+
specs = get_specs()
|
|
572
|
+
|
|
573
|
+
if extensions is not None:
|
|
574
|
+
if not isinstance(extensions, list):
|
|
575
|
+
extensions = [extensions]
|
|
576
|
+
for ext in extensions:
|
|
577
|
+
specs.update(ext)
|
|
578
|
+
|
|
579
|
+
col_def_map = _hydrate_col_defs(set_code, specs, card_context, set_context)
|
|
580
|
+
|
|
581
|
+
df_path = data_file_path(set_code, view)
|
|
582
|
+
base_view_df = pl.scan_parquet(df_path)
|
|
583
|
+
|
|
584
|
+
select_cols = frozenset(columns)
|
|
585
|
+
|
|
586
|
+
filter_ = spells.filter.from_spec(filter_spec)
|
|
587
|
+
if filter_ is not None:
|
|
588
|
+
select_cols = select_cols.union(filter_.lhs)
|
|
589
|
+
|
|
590
|
+
base_df_prefilter = _view_select(
|
|
591
|
+
base_view_df,
|
|
592
|
+
select_cols,
|
|
593
|
+
col_def_map,
|
|
594
|
+
is_agg_view=False,
|
|
595
|
+
)
|
|
596
|
+
|
|
597
|
+
if filter_ is not None:
|
|
598
|
+
base_df = base_df_prefilter.filter(filter_.expr)
|
|
599
|
+
else:
|
|
600
|
+
base_df = base_df_prefilter
|
|
601
|
+
|
|
602
|
+
return base_df.select(columns)
|
spells/manifest.py
CHANGED
|
@@ -163,14 +163,14 @@ def create(
|
|
|
163
163
|
group_by: list[str] | None = None,
|
|
164
164
|
filter_spec: dict | None = None,
|
|
165
165
|
):
|
|
166
|
-
gbs = (
|
|
167
|
-
(ColName.NAME, ColName.COLOR, ColName.RARITY)
|
|
168
|
-
if group_by is None
|
|
169
|
-
else tuple(group_by)
|
|
170
|
-
)
|
|
166
|
+
gbs = (ColName.NAME,) if group_by is None else tuple(group_by)
|
|
171
167
|
|
|
172
168
|
if columns is None:
|
|
173
169
|
cols = tuple(spells.columns.default_columns)
|
|
170
|
+
if ColName.NAME not in gbs:
|
|
171
|
+
cols = tuple(
|
|
172
|
+
col for col in cols if col not in (ColName.COLOR, ColName.RARITY)
|
|
173
|
+
)
|
|
174
174
|
else:
|
|
175
175
|
cols = tuple(columns)
|
|
176
176
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
spells/__init__.py,sha256=dWkRW298GOYHFiG84S3cUrp4R-vydgA-v95CFPaWu2M,221
|
|
2
|
+
spells/cache.py,sha256=YpTmlW-U2EosvGCH9gRQdQc8gRjjcGbgQovn5gfA_WE,3165
|
|
3
|
+
spells/cards.py,sha256=EOXAB_F2yedjf6KquCERCIHl0TSIJIoOe1jv8g4JzOc,3601
|
|
4
|
+
spells/columns.py,sha256=SdNw51lA1ox5rD2M7F8M2yqo-m0Dal5sKzS4Rp4q9MQ,18092
|
|
5
|
+
spells/draft_data.py,sha256=R44E8eb7bMOT0AxnkWcOAyuVCLDUxbvYmlYCLEtqi-s,18800
|
|
6
|
+
spells/enums.py,sha256=DL7e1xDEvrsTMbA7vJB_Et1DaYkyO4rIEzvIQDz3MZk,4871
|
|
7
|
+
spells/extension.py,sha256=RFLnNdT_4fIibgw_lAsAjQsFzWmNjJp8KRXJvagdz3Y,6580
|
|
8
|
+
spells/external.py,sha256=PN0PkwdKnvx-4HkApFhI1_ZwRvBUDMUd3Vfbky0xSJA,11786
|
|
9
|
+
spells/filter.py,sha256=J-YTOOAzOQpvIX29tviYL04RVoOUlfsbjBXoQBDCEdQ,3380
|
|
10
|
+
spells/manifest.py,sha256=dOUmj2uZZ17vCWpFwv7B5F6wOIWnoQdZkEB9SDKdx9M,8310
|
|
11
|
+
spells/schema.py,sha256=DbMvV8PIThJTp0Xzp_XIorlW6JhE1ud1kWRGf5SQ4_c,6406
|
|
12
|
+
spells_mtg-0.8.1.dist-info/METADATA,sha256=fltb_cVkAsksPVHjJ77GT4C6QJ1MnjJ3CQyHBC5IXjQ,46731
|
|
13
|
+
spells_mtg-0.8.1.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
|
14
|
+
spells_mtg-0.8.1.dist-info/entry_points.txt,sha256=a9Y1omdl9MdnKuIj3aOodgrp-zZII6OCdvqwgP6BFvI,63
|
|
15
|
+
spells_mtg-0.8.1.dist-info/licenses/LICENSE,sha256=tS54XYbJSgmq5zuHhbsQGbNQLJPVgXqhF5nu2CSRMig,1068
|
|
16
|
+
spells_mtg-0.8.1.dist-info/RECORD,,
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
spells/__init__.py,sha256=iyX74sLFJIQ_5ShZ7KDOeBlbYLm21ibWxwyzCGnKdg8,169
|
|
2
|
-
spells/cache.py,sha256=YpTmlW-U2EosvGCH9gRQdQc8gRjjcGbgQovn5gfA_WE,3165
|
|
3
|
-
spells/cards.py,sha256=EOXAB_F2yedjf6KquCERCIHl0TSIJIoOe1jv8g4JzOc,3601
|
|
4
|
-
spells/columns.py,sha256=kWeDofGL0bYcxq4OOfUwkU4Ty3fm0xux6R9774v9HVQ,18053
|
|
5
|
-
spells/draft_data.py,sha256=YeixEMn9OZu9fAFH-VMC6urkbybySqlHITBhfZLFigc,17271
|
|
6
|
-
spells/enums.py,sha256=DL7e1xDEvrsTMbA7vJB_Et1DaYkyO4rIEzvIQDz3MZk,4871
|
|
7
|
-
spells/extension.py,sha256=RFLnNdT_4fIibgw_lAsAjQsFzWmNjJp8KRXJvagdz3Y,6580
|
|
8
|
-
spells/external.py,sha256=PN0PkwdKnvx-4HkApFhI1_ZwRvBUDMUd3Vfbky0xSJA,11786
|
|
9
|
-
spells/filter.py,sha256=J-YTOOAzOQpvIX29tviYL04RVoOUlfsbjBXoQBDCEdQ,3380
|
|
10
|
-
spells/manifest.py,sha256=83VCuS5AuVjvOltdNscOOwekAfeIEHSg9a2O_aKAyA0,8214
|
|
11
|
-
spells/schema.py,sha256=DbMvV8PIThJTp0Xzp_XIorlW6JhE1ud1kWRGf5SQ4_c,6406
|
|
12
|
-
spells_mtg-0.7.4.dist-info/METADATA,sha256=imq85pXWkIfPCz3xg7g5oi3vpmdLlNriPP6dy-7D8Z4,46731
|
|
13
|
-
spells_mtg-0.7.4.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
|
14
|
-
spells_mtg-0.7.4.dist-info/entry_points.txt,sha256=a9Y1omdl9MdnKuIj3aOodgrp-zZII6OCdvqwgP6BFvI,63
|
|
15
|
-
spells_mtg-0.7.4.dist-info/licenses/LICENSE,sha256=tS54XYbJSgmq5zuHhbsQGbNQLJPVgXqhF5nu2CSRMig,1068
|
|
16
|
-
spells_mtg-0.7.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|