spells-mtg 0.7.5__tar.gz → 0.8.1__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.7.5 → spells_mtg-0.8.1}/PKG-INFO +1 -1
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/pyproject.toml +1 -1
- spells_mtg-0.8.1/spells/__init__.py +5 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/spells/draft_data.py +46 -3
- spells_mtg-0.7.5/spells/__init__.py +0 -5
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/LICENSE +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/README.md +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/spells/cache.py +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/spells/cards.py +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/spells/columns.py +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/spells/enums.py +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/spells/extension.py +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/spells/external.py +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/spells/filter.py +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/spells/manifest.py +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/spells/schema.py +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/tests/__init__.py +0 -0
- {spells_mtg-0.7.5 → spells_mtg-0.8.1}/tests/filter_test.py +0 -0
|
@@ -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
|
|
|
@@ -557,3 +557,46 @@ def summon(
|
|
|
557
557
|
)
|
|
558
558
|
|
|
559
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)
|
|
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
|