spells-mtg 0.7.5__py3-none-any.whl → 0.8.2__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 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/config.py ADDED
@@ -0,0 +1 @@
1
+ all_sets = ["FDN", "DSK", "BLB", "MH3", "OTJ", "MKM", "LCI", "WOE", "LTR", "MOM", "ONE", "BRO", "DMU", "SNC", "NEO"]
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 _get_names(set_code: str) -> list[str]:
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 = _get_names(set_code)
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 = _get_names(set_code)
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spells-mtg
3
- Version: 0.7.5
3
+ Version: 0.8.2
4
4
  Summary: analaysis of 17Lands.com public datasets
5
5
  Author-Email: Joel Barnes <oelarnes@gmail.com>
6
6
  License: MIT
@@ -1,16 +1,17 @@
1
- spells/__init__.py,sha256=iyX74sLFJIQ_5ShZ7KDOeBlbYLm21ibWxwyzCGnKdg8,169
1
+ spells/__init__.py,sha256=dWkRW298GOYHFiG84S3cUrp4R-vydgA-v95CFPaWu2M,221
2
2
  spells/cache.py,sha256=YpTmlW-U2EosvGCH9gRQdQc8gRjjcGbgQovn5gfA_WE,3165
3
3
  spells/cards.py,sha256=EOXAB_F2yedjf6KquCERCIHl0TSIJIoOe1jv8g4JzOc,3601
4
4
  spells/columns.py,sha256=SdNw51lA1ox5rD2M7F8M2yqo-m0Dal5sKzS4Rp4q9MQ,18092
5
- spells/draft_data.py,sha256=2wi5u6iSAyvWZy658AVeqQLLmZ7X21VG-QnNeO02of8,17641
5
+ spells/config.py,sha256=0SxrxbKINvURzYj1-j7idoO6hs3DsQ8aLNLnxn3hQcI,117
6
+ spells/draft_data.py,sha256=R44E8eb7bMOT0AxnkWcOAyuVCLDUxbvYmlYCLEtqi-s,18800
6
7
  spells/enums.py,sha256=DL7e1xDEvrsTMbA7vJB_Et1DaYkyO4rIEzvIQDz3MZk,4871
7
8
  spells/extension.py,sha256=RFLnNdT_4fIibgw_lAsAjQsFzWmNjJp8KRXJvagdz3Y,6580
8
9
  spells/external.py,sha256=PN0PkwdKnvx-4HkApFhI1_ZwRvBUDMUd3Vfbky0xSJA,11786
9
10
  spells/filter.py,sha256=J-YTOOAzOQpvIX29tviYL04RVoOUlfsbjBXoQBDCEdQ,3380
10
11
  spells/manifest.py,sha256=dOUmj2uZZ17vCWpFwv7B5F6wOIWnoQdZkEB9SDKdx9M,8310
11
12
  spells/schema.py,sha256=DbMvV8PIThJTp0Xzp_XIorlW6JhE1ud1kWRGf5SQ4_c,6406
12
- spells_mtg-0.7.5.dist-info/METADATA,sha256=aOdLLR4bAzd7jPcStcuooaRU3l2jDUK0CvsZqZ-bSco,46731
13
- spells_mtg-0.7.5.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
14
- spells_mtg-0.7.5.dist-info/entry_points.txt,sha256=a9Y1omdl9MdnKuIj3aOodgrp-zZII6OCdvqwgP6BFvI,63
15
- spells_mtg-0.7.5.dist-info/licenses/LICENSE,sha256=tS54XYbJSgmq5zuHhbsQGbNQLJPVgXqhF5nu2CSRMig,1068
16
- spells_mtg-0.7.5.dist-info/RECORD,,
13
+ spells_mtg-0.8.2.dist-info/METADATA,sha256=Nbd8y0ioKZfYmEWIhjjKL1TInLveKmO0wHkMToYuWpw,46731
14
+ spells_mtg-0.8.2.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
15
+ spells_mtg-0.8.2.dist-info/entry_points.txt,sha256=a9Y1omdl9MdnKuIj3aOodgrp-zZII6OCdvqwgP6BFvI,63
16
+ spells_mtg-0.8.2.dist-info/licenses/LICENSE,sha256=tS54XYbJSgmq5zuHhbsQGbNQLJPVgXqhF5nu2CSRMig,1068
17
+ spells_mtg-0.8.2.dist-info/RECORD,,