spells-mtg 0.11.7__py3-none-any.whl → 0.11.9__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/card_data_files.py CHANGED
@@ -18,6 +18,13 @@ DECK_COLOR_DATA_TEMPLATE = (
18
18
  "{user_group_param}&start_date={start_date_str}&end_date={end_date_str}&combine_splash=true"
19
19
  )
20
20
 
21
+ START_DATE_MAP = {
22
+ "DFT": dt.date(2025, 2, 11),
23
+ "TDM": dt.date(2025, 4, 8),
24
+ "FIN": dt.date(2025, 6, 10),
25
+ "EOE": dt.date(2025, 7, 29),
26
+ }
27
+
21
28
  ratings_col_defs = {
22
29
  ColName.NAME: pl.col("name").cast(pl.String),
23
30
  ColName.COLOR: pl.col("color").cast(pl.String),
@@ -53,11 +60,16 @@ deck_color_col_defs = {
53
60
 
54
61
  def deck_color_df(
55
62
  set_code: str,
56
- start_date: dt.date,
57
- end_date: dt.date,
58
63
  format: str = "PremierDraft",
59
64
  player_cohort: str = "all",
65
+ start_date: dt.date | None = None,
66
+ end_date: dt.date | None = None,
60
67
  ):
68
+ if start_date is None:
69
+ start_date = START_DATE_MAP[set_code]
70
+ if end_date is None:
71
+ end_date = dt.date.today() - dt.timedelta(days=1)
72
+
61
73
  target_dir, filename = cache.deck_color_file_path(
62
74
  set_code,
63
75
  format,
@@ -109,12 +121,17 @@ def deck_color_df(
109
121
 
110
122
  def base_ratings_df(
111
123
  set_code: str,
112
- start_date: dt.date,
113
- end_date: dt.date,
114
124
  format: str = "PremierDraft",
115
125
  player_cohort: str = "all",
116
126
  deck_colors: str | list[str] = "any",
127
+ start_date: dt.date | None = None,
128
+ end_date: dt.date | None = None,
117
129
  ) -> pl.DataFrame:
130
+ if start_date is None:
131
+ start_date = START_DATE_MAP[set_code]
132
+ if end_date is None:
133
+ end_date = dt.date.today() - dt.timedelta(days=1)
134
+
118
135
  if isinstance(deck_colors, str):
119
136
  deck_colors = [deck_colors]
120
137
 
spells/draft_data.py CHANGED
@@ -49,20 +49,25 @@ def _cache_key(args) -> str:
49
49
  @functools.lru_cache(maxsize=None)
50
50
  def get_names(set_code: str) -> list[str]:
51
51
  card_fp = cache.data_file_path(set_code, View.CARD)
52
- card_view = pl.read_parquet(card_fp)
53
- card_names_set = frozenset(card_view.get_column("name").to_list())
52
+ try:
53
+ card_view = pl.read_parquet(card_fp)
54
+ card_names_set = frozenset(card_view.get_column("name").to_list())
54
55
 
55
- draft_fp = cache.data_file_path(set_code, View.DRAFT)
56
- draft_view = pl.scan_parquet(draft_fp)
57
- cols = draft_view.collect_schema().names()
56
+ draft_fp = cache.data_file_path(set_code, View.DRAFT)
57
+ draft_view = pl.scan_parquet(draft_fp)
58
+ cols = draft_view.collect_schema().names()
58
59
 
59
- prefix = "pack_card_"
60
- names = [col[len(prefix) :] for col in cols if col.startswith(prefix)]
61
- draft_names_set = frozenset(names)
60
+ prefix = "pack_card_"
61
+ names = [col[len(prefix) :] for col in cols if col.startswith(prefix)]
62
+ draft_names_set = frozenset(names)
63
+
64
+ assert (
65
+ draft_names_set == card_names_set
66
+ ), "names mismatch between card and draft file"
67
+ except FileNotFoundError:
68
+ ratings_data = base_ratings_df(set_code)
69
+ names = list(ratings_data['name'])
62
70
 
63
- assert (
64
- draft_names_set == card_names_set
65
- ), "names mismatch between card and draft file"
66
71
  return names
67
72
 
68
73
 
@@ -528,7 +533,13 @@ def summon(
528
533
  else:
529
534
  this_set_context = None
530
535
 
531
- col_def_map = _hydrate_col_defs(code, specs, set_card_context, this_set_context)
536
+ col_def_map = _hydrate_col_defs(
537
+ code,
538
+ specs,
539
+ set_card_context,
540
+ this_set_context,
541
+ card_only=cdfs is not None,
542
+ )
532
543
  m = manifest.create(col_def_map, columns, group_by, filter_spec)
533
544
 
534
545
  if cdfs is None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spells-mtg
3
- Version: 0.11.7
3
+ Version: 0.11.9
4
4
  Summary: analaysis of 17Lands.com public datasets
5
5
  Author-Email: Joel Barnes <oelarnes@gmail.com>
6
6
  License: MIT
@@ -3,11 +3,11 @@ spells/.ruff_cache/0.8.6/17785301476771359756,sha256=gPYLG8psuOSo37IefLzTu5wgRrb
3
3
  spells/.ruff_cache/CACHEDIR.TAG,sha256=WVMVbX4MVkpCclExbq8m-IcOZIOuIZf5FrYw5Pk-Ma4,43
4
4
  spells/__init__.py,sha256=0pnh2NLn9FrNKncE9-tBsighp3e8YAsN--_ovUpgWGs,333
5
5
  spells/cache.py,sha256=6cl0q62erR3LCANPSfxG5-J7JQfLwNdWjzlBpfiL4IE,7174
6
- spells/card_data_files.py,sha256=uEYVmyqIrMwVKTX2HAr8rEZi3WpW3uPzv_6TcZzPQDQ,6036
6
+ spells/card_data_files.py,sha256=5W1P8Zr6vea9ztX8AKb4jQlifpm-0USDjKyGv53-UTk,6559
7
7
  spells/cards.py,sha256=6stFPhJOzHqvQnkSv9cDeylRa_7L9Y8sOaowiZhzz6I,4174
8
8
  spells/columns.py,sha256=s_PYyg2QaRL6kLWFNKCBEfbMF0x7O7-Yd9SeG1ttYL4,18206
9
9
  spells/config.py,sha256=CVE2O-ZPgthbSqAB7Pul2yeFcyLHpL52OiXH7s9yl48,246
10
- spells/draft_data.py,sha256=EC7TCAlrWWhDFQtGx6ie-SBTNvdsoPNef7oZ0w9TSW0,21012
10
+ spells/draft_data.py,sha256=INNGEQP1vL9qroE_Q89_QnjkvaEYpfU6pv9O1rtpIcA,21290
11
11
  spells/enums.py,sha256=gbwfon6tQCoKDb-m4hSaHWi9slj82yqaH3qhYMVrsck,4991
12
12
  spells/extension.py,sha256=LBqGbJbe7iSRQkxJK7npkADCfzhdnIwwVvlmTn8xvjQ,8454
13
13
  spells/external.py,sha256=I-f_vMx-h2kvunUlZthsauaeDn42vcRk0wvTURfImzs,11848
@@ -16,8 +16,8 @@ spells/log.py,sha256=3avmg65hru8K9npKLvPp1wWWxq-hoEYDUCbxqhPkKUw,2175
16
16
  spells/manifest.py,sha256=ExWVk17BRw615UmvrV817xwz457yfTNdNMNE_M00aEg,8338
17
17
  spells/schema.py,sha256=DbMvV8PIThJTp0Xzp_XIorlW6JhE1ud1kWRGf5SQ4_c,6406
18
18
  spells/utils.py,sha256=IO3brrXVvZla0LRTEB5v6NgGqZb_rYA46XtKBURGMNk,1944
19
- spells_mtg-0.11.7.dist-info/METADATA,sha256=odFdI4bYRUnk_aiFFnl0nEE5XNTOGwq-scbQ2dCFbjU,47369
20
- spells_mtg-0.11.7.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
21
- spells_mtg-0.11.7.dist-info/entry_points.txt,sha256=a9Y1omdl9MdnKuIj3aOodgrp-zZII6OCdvqwgP6BFvI,63
22
- spells_mtg-0.11.7.dist-info/licenses/LICENSE,sha256=tS54XYbJSgmq5zuHhbsQGbNQLJPVgXqhF5nu2CSRMig,1068
23
- spells_mtg-0.11.7.dist-info/RECORD,,
19
+ spells_mtg-0.11.9.dist-info/METADATA,sha256=0xmSlxnu6h52KYNYfwKpSQgYoFWI4zsbkBnGFyIxpf8,47369
20
+ spells_mtg-0.11.9.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
21
+ spells_mtg-0.11.9.dist-info/entry_points.txt,sha256=a9Y1omdl9MdnKuIj3aOodgrp-zZII6OCdvqwgP6BFvI,63
22
+ spells_mtg-0.11.9.dist-info/licenses/LICENSE,sha256=tS54XYbJSgmq5zuHhbsQGbNQLJPVgXqhF5nu2CSRMig,1068
23
+ spells_mtg-0.11.9.dist-info/RECORD,,