spells-mtg 0.11.12__tar.gz → 0.11.14__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.
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/PKG-INFO +1 -1
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/pyproject.toml +1 -1
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/columns.py +62 -144
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/draft_data.py +6 -4
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/LICENSE +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/README.md +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/.ruff_cache/.gitignore +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/.ruff_cache/0.8.6/17785301476771359756 +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/.ruff_cache/CACHEDIR.TAG +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/__init__.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/cache.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/card_data_files.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/cards.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/config.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/enums.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/extension.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/external.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/filter.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/log.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/manifest.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/schema.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/spells/utils.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/tests/__init__.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/tests/filter_test.py +0 -0
- {spells_mtg-0.11.12 → spells_mtg-0.11.14}/tests/utils_test.py +0 -0
|
@@ -40,6 +40,11 @@ default_columns = [
|
|
|
40
40
|
ColName.GIH_WR,
|
|
41
41
|
]
|
|
42
42
|
|
|
43
|
+
|
|
44
|
+
def agg_col(expr: pl.Expr) -> ColSpec:
|
|
45
|
+
return ColSpec(col_type=ColType.AGG, expr=expr)
|
|
46
|
+
|
|
47
|
+
|
|
43
48
|
_specs: dict[str, ColSpec] = {
|
|
44
49
|
ColName.NAME: ColSpec(
|
|
45
50
|
col_type=ColType.GROUP_BY,
|
|
@@ -168,7 +173,8 @@ _specs: dict[str, ColSpec] = {
|
|
|
168
173
|
),
|
|
169
174
|
ColName.PICK_INDEX: ColSpec(
|
|
170
175
|
col_type=ColType.GROUP_BY,
|
|
171
|
-
expr=lambda set_context: pl.col(ColName.PICK_NUMBER)
|
|
176
|
+
expr=lambda set_context: pl.col(ColName.PICK_NUMBER)
|
|
177
|
+
+ pl.col(ColName.PACK_NUMBER) * set_context["picks_per_pack"],
|
|
172
178
|
),
|
|
173
179
|
ColName.TAKEN_AT: ColSpec(
|
|
174
180
|
col_type=ColType.PICK_SUM,
|
|
@@ -441,149 +447,61 @@ _specs: dict[str, ColSpec] = {
|
|
|
441
447
|
ColName.IMAGE_URL: ColSpec(
|
|
442
448
|
col_type=ColType.CARD_ATTR,
|
|
443
449
|
),
|
|
444
|
-
ColName.PICKED_MATCH_WR:
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
),
|
|
456
|
-
ColName.
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
),
|
|
460
|
-
ColName.
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
),
|
|
464
|
-
ColName.
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
),
|
|
468
|
-
ColName.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
),
|
|
472
|
-
ColName.
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
),
|
|
480
|
-
ColName.
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
),
|
|
484
|
-
ColName.
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
),
|
|
488
|
-
ColName.
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
),
|
|
496
|
-
ColName.
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
),
|
|
500
|
-
ColName.IWD: ColSpec(
|
|
501
|
-
col_type=ColType.AGG,
|
|
502
|
-
expr=pl.col(ColName.GIH_WR) - pl.col(ColName.GNS_WR),
|
|
503
|
-
),
|
|
504
|
-
ColName.NUM_IN_POOL: ColSpec(
|
|
505
|
-
col_type=ColType.AGG,
|
|
506
|
-
expr=pl.col(ColName.DECK) + pl.col(ColName.SIDEBOARD),
|
|
507
|
-
),
|
|
508
|
-
ColName.NUM_IN_POOL_TOTAL: ColSpec(
|
|
509
|
-
col_type=ColType.AGG,
|
|
510
|
-
expr=pl.col(ColName.NUM_IN_POOL).sum(),
|
|
511
|
-
),
|
|
512
|
-
ColName.IN_POOL_WR: ColSpec(
|
|
513
|
-
col_type=ColType.AGG,
|
|
514
|
-
expr=(pl.col(ColName.WON_DECK) + pl.col(ColName.WON_SIDEBOARD))
|
|
515
|
-
/ pl.col(ColName.NUM_IN_POOL),
|
|
516
|
-
),
|
|
517
|
-
ColName.DECK_TOTAL: ColSpec(
|
|
518
|
-
col_type=ColType.AGG,
|
|
519
|
-
expr=pl.col(ColName.DECK).sum(),
|
|
520
|
-
),
|
|
521
|
-
ColName.WON_DECK_TOTAL: ColSpec(
|
|
522
|
-
col_type=ColType.AGG,
|
|
523
|
-
expr=pl.col(ColName.WON_DECK).sum(),
|
|
524
|
-
),
|
|
525
|
-
ColName.GP_WR_MEAN: ColSpec(
|
|
526
|
-
col_type=ColType.AGG,
|
|
527
|
-
expr=pl.col(ColName.WON_DECK_TOTAL) / pl.col(ColName.DECK_TOTAL),
|
|
528
|
-
),
|
|
529
|
-
ColName.GP_WR_EXCESS: ColSpec(
|
|
530
|
-
col_type=ColType.AGG,
|
|
531
|
-
expr=pl.col(ColName.GP_WR) - pl.col(ColName.GP_WR_MEAN),
|
|
532
|
-
),
|
|
533
|
-
ColName.GP_WR_VAR: ColSpec(
|
|
534
|
-
col_type=ColType.AGG,
|
|
535
|
-
expr=(pl.col(ColName.GP_WR_EXCESS).pow(2) * pl.col(ColName.NUM_GP)).sum()
|
|
536
|
-
/ pl.col(ColName.DECK_TOTAL),
|
|
537
|
-
),
|
|
538
|
-
ColName.GP_WR_STDEV: ColSpec(
|
|
539
|
-
col_type=ColType.AGG,
|
|
540
|
-
expr=pl.col(ColName.GP_WR_VAR).sqrt(),
|
|
541
|
-
),
|
|
542
|
-
ColName.GP_WR_Z: ColSpec(
|
|
543
|
-
col_type=ColType.AGG,
|
|
544
|
-
expr=pl.col(ColName.GP_WR_EXCESS) / pl.col(ColName.GP_WR_STDEV),
|
|
545
|
-
),
|
|
546
|
-
ColName.GIH_TOTAL: ColSpec(
|
|
547
|
-
col_type=ColType.AGG,
|
|
548
|
-
expr=pl.col(ColName.NUM_GIH).sum(),
|
|
549
|
-
),
|
|
550
|
-
ColName.WON_GIH_TOTAL: ColSpec(
|
|
551
|
-
col_type=ColType.AGG,
|
|
552
|
-
expr=pl.col(ColName.NUM_GIH_WON).sum(),
|
|
553
|
-
),
|
|
554
|
-
ColName.GIH_WR_MEAN: ColSpec(
|
|
555
|
-
col_type=ColType.AGG,
|
|
556
|
-
expr=pl.col(ColName.WON_GIH_TOTAL) / pl.col(ColName.GIH_TOTAL),
|
|
557
|
-
),
|
|
558
|
-
ColName.GIH_WR_EXCESS: ColSpec(
|
|
559
|
-
col_type=ColType.AGG,
|
|
560
|
-
expr=pl.col(ColName.GIH_WR) - pl.col(ColName.GIH_WR_MEAN),
|
|
561
|
-
),
|
|
562
|
-
ColName.GIH_WR_VAR: ColSpec(
|
|
563
|
-
col_type=ColType.AGG,
|
|
564
|
-
expr=(pl.col(ColName.GIH_WR_EXCESS).pow(2) * pl.col(ColName.NUM_GIH)).sum()
|
|
565
|
-
/ pl.col(ColName.GIH_TOTAL),
|
|
566
|
-
),
|
|
567
|
-
ColName.GIH_WR_STDEV: ColSpec(
|
|
568
|
-
col_type=ColType.AGG,
|
|
569
|
-
expr=pl.col(ColName.GIH_WR_VAR).sqrt(),
|
|
570
|
-
),
|
|
571
|
-
ColName.GIH_WR_Z: ColSpec(
|
|
572
|
-
col_type=ColType.AGG,
|
|
573
|
-
expr=pl.col(ColName.GIH_WR_EXCESS) / pl.col(ColName.GIH_WR_STDEV),
|
|
574
|
-
),
|
|
575
|
-
ColName.DECK_MANA_VALUE_AVG: ColSpec(
|
|
576
|
-
col_type=ColType.AGG,
|
|
577
|
-
expr=pl.col(ColName.DECK_MANA_VALUE) / pl.col(ColName.DECK_SPELLS),
|
|
578
|
-
),
|
|
579
|
-
ColName.DECK_LANDS_AVG: ColSpec(
|
|
580
|
-
col_type=ColType.AGG,
|
|
581
|
-
expr=pl.col(ColName.DECK_LANDS) / pl.col(ColName.NUM_GAMES),
|
|
582
|
-
),
|
|
583
|
-
ColName.DECK_SPELLS_AVG: ColSpec(
|
|
584
|
-
col_type=ColType.AGG,
|
|
585
|
-
expr=pl.col(ColName.DECK_SPELLS) / pl.col(ColName.NUM_GAMES),
|
|
586
|
-
),
|
|
450
|
+
ColName.PICKED_MATCH_WR: agg_col(
|
|
451
|
+
pl.col(ColName.EVENT_MATCH_WINS_SUM) / pl.col(ColName.EVENT_MATCHES_SUM)
|
|
452
|
+
),
|
|
453
|
+
ColName.TROPHY_RATE: agg_col(
|
|
454
|
+
pl.col(ColName.IS_TROPHY_SUM) / pl.col(ColName.NUM_TAKEN),
|
|
455
|
+
),
|
|
456
|
+
ColName.GAME_WR: agg_col(
|
|
457
|
+
pl.col(ColName.NUM_WON) / pl.col(ColName.NUM_GAMES),
|
|
458
|
+
),
|
|
459
|
+
ColName.ALSA: agg_col(pl.col(ColName.LAST_SEEN) / pl.col(ColName.NUM_SEEN)),
|
|
460
|
+
ColName.ATA: agg_col(pl.col(ColName.TAKEN_AT) / pl.col(ColName.NUM_TAKEN)),
|
|
461
|
+
ColName.NUM_GP: agg_col(pl.col(ColName.DECK)),
|
|
462
|
+
ColName.PCT_GP: agg_col(
|
|
463
|
+
pl.col(ColName.DECK) / (pl.col(ColName.DECK) + pl.col(ColName.SIDEBOARD))
|
|
464
|
+
),
|
|
465
|
+
ColName.GP_WR: agg_col(pl.col(ColName.WON_DECK) / pl.col(ColName.DECK)),
|
|
466
|
+
ColName.NUM_OH: agg_col(pl.col(ColName.OPENING_HAND)),
|
|
467
|
+
ColName.OH_WR: agg_col(
|
|
468
|
+
pl.col(ColName.WON_OPENING_HAND) / pl.col(ColName.OPENING_HAND)
|
|
469
|
+
),
|
|
470
|
+
ColName.NUM_GIH: agg_col(pl.col(ColName.OPENING_HAND) + pl.col(ColName.DRAWN)),
|
|
471
|
+
ColName.NUM_GIH_WON: agg_col(
|
|
472
|
+
pl.col(ColName.WON_OPENING_HAND) + pl.col(ColName.WON_DRAWN)
|
|
473
|
+
),
|
|
474
|
+
ColName.GIH_WR: agg_col(pl.col(ColName.NUM_GIH_WON) / pl.col(ColName.NUM_GIH)),
|
|
475
|
+
ColName.GNS_WR: agg_col(pl.col(ColName.WON_NUM_GNS) / pl.col(ColName.NUM_GNS)),
|
|
476
|
+
ColName.IWD: agg_col(pl.col(ColName.GIH_WR) - pl.col(ColName.GNS_WR)),
|
|
477
|
+
ColName.NUM_IN_POOL: agg_col(pl.col(ColName.DECK) + pl.col(ColName.SIDEBOARD)),
|
|
478
|
+
ColName.NUM_IN_POOL_TOTAL: agg_col(pl.col(ColName.NUM_IN_POOL).sum()),
|
|
479
|
+
ColName.IN_POOL_WR: agg_col(
|
|
480
|
+
(pl.col(ColName.WON_DECK) + pl.col(ColName.WON_SIDEBOARD))
|
|
481
|
+
/ pl.col(ColName.NUM_IN_POOL)
|
|
482
|
+
),
|
|
483
|
+
ColName.DECK_TOTAL: agg_col(pl.col(ColName.DECK).sum()),
|
|
484
|
+
ColName.WON_DECK_TOTAL: agg_col(pl.col(ColName.WON_DECK).sum()),
|
|
485
|
+
ColName.GP_WR_MEAN: agg_col(pl.col(ColName.WON_DECK_TOTAL) / pl.col(ColName.DECK_TOTAL)),
|
|
486
|
+
ColName.GP_WR_EXCESS: agg_col(pl.col(ColName.GP_WR) - pl.col(ColName.GP_WR_MEAN)),
|
|
487
|
+
ColName.GP_WR_VAR: agg_col((pl.col(ColName.GP_WR_EXCESS).pow(2) * pl.col(ColName.NUM_GP)).sum()
|
|
488
|
+
/ pl.col(ColName.DECK_TOTAL)
|
|
489
|
+
),
|
|
490
|
+
ColName.GP_WR_STDEV: agg_col(pl.col(ColName.GP_WR_VAR).sqrt()),
|
|
491
|
+
ColName.GP_WR_Z: agg_col(pl.col(ColName.GP_WR_EXCESS) / pl.col(ColName.GP_WR_STDEV)),
|
|
492
|
+
ColName.GIH_TOTAL: agg_col(pl.col(ColName.NUM_GIH).sum()),
|
|
493
|
+
ColName.WON_GIH_TOTAL: agg_col(pl.col(ColName.NUM_GIH_WON).sum()),
|
|
494
|
+
ColName.GIH_WR_MEAN: agg_col(pl.col(ColName.WON_GIH_TOTAL) / pl.col(ColName.GIH_TOTAL)),
|
|
495
|
+
ColName.GIH_WR_EXCESS: agg_col(pl.col(ColName.GIH_WR) - pl.col(ColName.GIH_WR_MEAN)),
|
|
496
|
+
ColName.GIH_WR_VAR: agg_col(
|
|
497
|
+
(pl.col(ColName.GIH_WR_EXCESS).pow(2) * pl.col(ColName.NUM_GIH)).sum()
|
|
498
|
+
/ pl.col(ColName.GIH_TOTAL)
|
|
499
|
+
),
|
|
500
|
+
ColName.GIH_WR_STDEV: agg_col(pl.col(ColName.GIH_WR_VAR).sqrt()),
|
|
501
|
+
ColName.GIH_WR_Z: agg_col(pl.col(ColName.GIH_WR_EXCESS) / pl.col(ColName.GIH_WR_STDEV)),
|
|
502
|
+
ColName.DECK_MANA_VALUE_AVG: agg_col(pl.col(ColName.DECK_MANA_VALUE) / pl.col(ColName.DECK_SPELLS)),
|
|
503
|
+
ColName.DECK_LANDS_AVG: agg_col(pl.col(ColName.DECK_LANDS) / pl.col(ColName.NUM_GAMES)),
|
|
504
|
+
ColName.DECK_SPELLS_AVG: agg_col(pl.col(ColName.DECK_SPELLS) / pl.col(ColName.NUM_GAMES)),
|
|
587
505
|
}
|
|
588
506
|
|
|
589
507
|
for item in ColName:
|
|
@@ -347,7 +347,10 @@ def _view_select(
|
|
|
347
347
|
cdefs = [col_def_map[c] for c in sorted(view_cols)]
|
|
348
348
|
select = []
|
|
349
349
|
for cdef in cdefs:
|
|
350
|
-
if
|
|
350
|
+
if isinstance(df, pl.DataFrame) and cdef.name in df.columns:
|
|
351
|
+
base_cols = base_cols.union(frozenset({cdef.name}))
|
|
352
|
+
select.append(cdef.name)
|
|
353
|
+
elif is_agg_view:
|
|
351
354
|
if cdef.col_type == ColType.AGG:
|
|
352
355
|
base_cols = base_cols.union(cdef.dependencies)
|
|
353
356
|
select.append(cdef.expr)
|
|
@@ -471,7 +474,7 @@ def _base_agg_df(
|
|
|
471
474
|
|
|
472
475
|
if group_by:
|
|
473
476
|
joined_df = functools.reduce(
|
|
474
|
-
lambda prev, curr: prev.join(curr, on=group_by, how="
|
|
477
|
+
lambda prev, curr: prev.join(curr, on=group_by, how="full", coalesce=True),
|
|
475
478
|
join_dfs,
|
|
476
479
|
)
|
|
477
480
|
else:
|
|
@@ -565,11 +568,10 @@ def summon(
|
|
|
565
568
|
select_df = _view_select(
|
|
566
569
|
card_df, card_cols, m.col_def_map, is_agg_view=False
|
|
567
570
|
)
|
|
568
|
-
agg_df = agg_df.join(select_df, on="name", how="
|
|
571
|
+
agg_df = agg_df.join(select_df, on="name", how="full", coalesce=True)
|
|
569
572
|
else:
|
|
570
573
|
assert len(codes) == 1, "Only one set supported for loading from card data file"
|
|
571
574
|
assert codes[0] == cdfs.set_code, "Wrong set file specified"
|
|
572
|
-
assert cdfs.format == "PremierDraft", "Only PremierDraft supported"
|
|
573
575
|
agg_df = base_ratings_df(
|
|
574
576
|
set_code=cdfs.set_code,
|
|
575
577
|
format=cdfs.format,
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|