From 5f740c820c1f08582d16cd67383d7378877a1741 Mon Sep 17 00:00:00 2001 From: AJSTYLE-lab Date: Thu, 15 Jan 2026 15:43:32 +0500 Subject: [PATCH] Fix code formatting with ruff --- tests/test_data/example_plot_data.csv | 584 ++++++++++++++++++ tests/test_plotly_express/test_stacked_bar.py | 69 +++ 2 files changed, 653 insertions(+) create mode 100644 tests/test_data/example_plot_data.csv create mode 100644 tests/test_plotly_express/test_stacked_bar.py diff --git a/tests/test_data/example_plot_data.csv b/tests/test_data/example_plot_data.csv new file mode 100644 index 0000000000..5e0c8d3a85 --- /dev/null +++ b/tests/test_data/example_plot_data.csv @@ -0,0 +1,584 @@ +savedate_week,commanders,commander_perc_of_card +2024-10-21,"Ureni, the Song Unending", +2024-10-28,"Ureni, the Song Unending", +2024-11-04,"Ureni, the Song Unending", +2024-11-11,"Ureni, the Song Unending", +2024-11-18,"Ureni, the Song Unending", +2024-11-25,"Ureni, the Song Unending", +2024-12-02,"Ureni, the Song Unending", +2024-12-09,"Ureni, the Song Unending", +2024-12-16,"Ureni, the Song Unending", +2024-12-23,"Ureni, the Song Unending", +2024-12-30,"Ureni, the Song Unending", +2025-01-06,"Ureni, the Song Unending", +2025-01-13,"Ureni, the Song Unending", +2025-01-20,"Ureni, the Song Unending", +2025-01-27,"Ureni, the Song Unending", +2025-02-03,"Ureni, the Song Unending", +2025-02-10,"Ureni, the Song Unending", +2025-02-17,"Ureni, the Song Unending", +2025-02-24,"Ureni, the Song Unending", +2025-03-03,"Ureni, the Song Unending", +2025-03-10,"Ureni, the Song Unending", +2025-03-17,"Ureni, the Song Unending",1.4864864864864864 +2025-03-24,"Ureni, the Song Unending",1.566579634464752 +2025-03-31,"Ureni, the Song Unending",1.0185185185185186 +2025-04-07,"Ureni, the Song Unending",1.278600269179004 +2025-04-14,"Ureni, the Song Unending",1.1577424023154848 +2025-04-21,"Ureni, the Song Unending",0.889248181083266 +2025-04-28,"Ureni, the Song Unending",0.7386888273314867 +2025-05-05,"Ureni, the Song Unending",0.691699604743083 +2025-05-12,"Ureni, the Song Unending",1.0321100917431192 +2025-05-19,"Ureni, the Song Unending",1.0296010296010296 +2025-05-26,"Ureni, the Song Unending",0.8321775312066574 +2025-06-02,"Ureni, the Song Unending",0.6462035541195477 +2025-06-09,"Ureni, the Song Unending",0.9630818619582665 +2025-06-16,"Ureni, the Song Unending",0.4225352112676056 +2025-06-23,"Ureni, the Song Unending",0.7374631268436578 +2025-06-30,"Ureni, the Song Unending",0.6163328197226502 +2025-07-07,"Ureni, the Song Unending",0.29850746268656714 +2025-07-14,"Ureni, the Song Unending",0.5970149253731343 +2025-07-21,"Ureni, the Song Unending",0.14124293785310735 +2025-07-28,"Ureni, the Song Unending",0.5494505494505495 +2025-08-04,"Ureni, the Song Unending",0.7772020725388601 +2025-08-11,"Ureni, the Song Unending",0.6561679790026247 +2025-08-18,"Ureni, the Song Unending",0.5 +2025-08-25,"Ureni, the Song Unending",0.13071895424836602 +2025-09-01,"Ureni, the Song Unending",0.5988023952095808 +2025-09-08,"Ureni, the Song Unending",0.5434782608695652 +2025-09-15,"Ureni, the Song Unending",0.3811944091486658 +2025-09-22,"Ureni, the Song Unending",0.585480093676815 +2025-09-29,"Ureni, the Song Unending",0.7918552036199095 +2025-10-06,"Ureni, the Song Unending",0.23094688221709006 +2025-10-13,"Ureni, the Song Unending",0.5655042412818096 +2025-10-20,"Ureni, the Song Unending", +2024-10-21,Ureni of the Unwritten, +2024-10-28,Ureni of the Unwritten, +2024-11-04,Ureni of the Unwritten, +2024-11-11,Ureni of the Unwritten, +2024-11-18,Ureni of the Unwritten, +2024-11-25,Ureni of the Unwritten, +2024-12-02,Ureni of the Unwritten, +2024-12-09,Ureni of the Unwritten, +2024-12-16,Ureni of the Unwritten, +2024-12-23,Ureni of the Unwritten, +2024-12-30,Ureni of the Unwritten, +2025-01-06,Ureni of the Unwritten, +2025-01-13,Ureni of the Unwritten, +2025-01-20,Ureni of the Unwritten, +2025-01-27,Ureni of the Unwritten, +2025-02-03,Ureni of the Unwritten, +2025-02-10,Ureni of the Unwritten, +2025-02-17,Ureni of the Unwritten, +2025-02-24,Ureni of the Unwritten, +2025-03-03,Ureni of the Unwritten, +2025-03-10,Ureni of the Unwritten, +2025-03-17,Ureni of the Unwritten,8.783783783783784 +2025-03-24,Ureni of the Unwritten,9.312445604873803 +2025-03-31,Ureni of the Unwritten,11.296296296296296 +2025-04-07,Ureni of the Unwritten,12.113055181695827 +2025-04-14,Ureni of the Unwritten,12.228654124457309 +2025-04-21,Ureni of the Unwritten,9.781729991915926 +2025-04-28,Ureni of the Unwritten,11.0803324099723 +2025-05-05,Ureni of the Unwritten,10.968379446640316 +2025-05-12,Ureni of the Unwritten,9.747706422018348 +2025-05-19,Ureni of the Unwritten,10.553410553410554 +2025-05-26,Ureni of the Unwritten,11.095700416088766 +2025-06-02,Ureni of the Unwritten,12.277867528271406 +2025-06-09,Ureni of the Unwritten,10.754414125200642 +2025-06-16,Ureni of the Unwritten,10.56338028169014 +2025-06-23,Ureni of the Unwritten,9.144542772861357 +2025-06-30,Ureni of the Unwritten,10.939907550077042 +2025-07-07,Ureni of the Unwritten,10.149253731343284 +2025-07-14,Ureni of the Unwritten,11.044776119402986 +2025-07-21,Ureni of the Unwritten,9.887005649717514 +2025-07-28,Ureni of the Unwritten,12.225274725274724 +2025-08-04,Ureni of the Unwritten,11.528497409326425 +2025-08-11,Ureni of the Unwritten,11.811023622047244 +2025-08-18,Ureni of the Unwritten,12.625 +2025-08-25,Ureni of the Unwritten,11.241830065359476 +2025-09-01,Ureni of the Unwritten,12.095808383233534 +2025-09-08,Ureni of the Unwritten,9.23913043478261 +2025-09-15,Ureni of the Unwritten,13.087674714104192 +2025-09-22,Ureni of the Unwritten,14.402810304449648 +2025-09-29,Ureni of the Unwritten,12.217194570135746 +2025-10-06,Ureni of the Unwritten,13.394919168591224 +2025-10-13,Ureni of the Unwritten,14.420358152686145 +2025-10-20,Ureni of the Unwritten,12.359550561797754 +2024-10-21,"Eshki, Temur's Roar", +2024-10-28,"Eshki, Temur's Roar", +2024-11-04,"Eshki, Temur's Roar", +2024-11-11,"Eshki, Temur's Roar", +2024-11-18,"Eshki, Temur's Roar", +2024-11-25,"Eshki, Temur's Roar", +2024-12-02,"Eshki, Temur's Roar", +2024-12-09,"Eshki, Temur's Roar", +2024-12-16,"Eshki, Temur's Roar", +2024-12-23,"Eshki, Temur's Roar", +2024-12-30,"Eshki, Temur's Roar", +2025-01-06,"Eshki, Temur's Roar", +2025-01-13,"Eshki, Temur's Roar", +2025-01-20,"Eshki, Temur's Roar", +2025-01-27,"Eshki, Temur's Roar", +2025-02-03,"Eshki, Temur's Roar", +2025-02-10,"Eshki, Temur's Roar", +2025-02-17,"Eshki, Temur's Roar", +2025-02-24,"Eshki, Temur's Roar", +2025-03-03,"Eshki, Temur's Roar", +2025-03-10,"Eshki, Temur's Roar", +2025-03-17,"Eshki, Temur's Roar",1.2162162162162162 +2025-03-24,"Eshki, Temur's Roar",1.7406440382941688 +2025-03-31,"Eshki, Temur's Roar",1.8518518518518519 +2025-04-07,"Eshki, Temur's Roar",1.278600269179004 +2025-04-14,"Eshki, Temur's Roar",1.447178002894356 +2025-04-21,"Eshki, Temur's Roar",1.5359741309620047 +2025-04-28,"Eshki, Temur's Roar",1.4773776546629733 +2025-05-05,"Eshki, Temur's Roar",1.976284584980237 +2025-05-12,"Eshki, Temur's Roar",1.261467889908257 +2025-05-19,"Eshki, Temur's Roar",1.4157014157014156 +2025-05-26,"Eshki, Temur's Roar",0.970873786407767 +2025-06-02,"Eshki, Temur's Roar",1.1308562197092085 +2025-06-09,"Eshki, Temur's Roar",0.9630818619582665 +2025-06-16,"Eshki, Temur's Roar",1.267605633802817 +2025-06-23,"Eshki, Temur's Roar",1.9174041297935103 +2025-06-30,"Eshki, Temur's Roar",0.9244992295839753 +2025-07-07,"Eshki, Temur's Roar",0.14925373134328357 +2025-07-14,"Eshki, Temur's Roar",0.44776119402985076 +2025-07-21,"Eshki, Temur's Roar",0.9887005649717514 +2025-07-28,"Eshki, Temur's Roar",0.8241758241758241 +2025-08-04,"Eshki, Temur's Roar",1.0362694300518134 +2025-08-11,"Eshki, Temur's Roar",1.0498687664041995 +2025-08-18,"Eshki, Temur's Roar",1.5 +2025-08-25,"Eshki, Temur's Roar",1.0457516339869282 +2025-09-01,"Eshki, Temur's Roar",1.0778443113772456 +2025-09-08,"Eshki, Temur's Roar",1.358695652173913 +2025-09-15,"Eshki, Temur's Roar",0.6353240152477764 +2025-09-22,"Eshki, Temur's Roar",0.585480093676815 +2025-09-29,"Eshki, Temur's Roar",1.3574660633484164 +2025-10-06,"Eshki, Temur's Roar",1.6166281755196306 +2025-10-13,"Eshki, Temur's Roar",1.2252591894439209 +2025-10-20,"Eshki, Temur's Roar", +2024-10-21,"Rukarumel, Biologist",1.8633540372670807 +2024-10-28,"Rukarumel, Biologist",0.6578947368421053 +2024-11-04,"Rukarumel, Biologist", +2024-11-11,"Rukarumel, Biologist", +2024-11-18,"Rukarumel, Biologist",1.2903225806451613 +2024-11-25,"Rukarumel, Biologist",1.4598540145985401 +2024-12-02,"Rukarumel, Biologist", +2024-12-09,"Rukarumel, Biologist",0.8771929824561403 +2024-12-16,"Rukarumel, Biologist",1.7241379310344827 +2024-12-23,"Rukarumel, Biologist",0.4608294930875576 +2024-12-30,"Rukarumel, Biologist",1.6129032258064515 +2025-01-06,"Rukarumel, Biologist",0.6211180124223602 +2025-01-13,"Rukarumel, Biologist",0.9302325581395349 +2025-01-20,"Rukarumel, Biologist",1.1695906432748537 +2025-01-27,"Rukarumel, Biologist",0.8849557522123894 +2025-02-03,"Rukarumel, Biologist",0.5347593582887701 +2025-02-10,"Rukarumel, Biologist",0.5235602094240838 +2025-02-17,"Rukarumel, Biologist",1.345291479820628 +2025-02-24,"Rukarumel, Biologist",0.49019607843137253 +2025-03-03,"Rukarumel, Biologist",0.5882352941176471 +2025-03-10,"Rukarumel, Biologist",0.5434782608695652 +2025-03-17,"Rukarumel, Biologist",0.6756756756756757 +2025-03-24,"Rukarumel, Biologist",0.6962576153176675 +2025-03-31,"Rukarumel, Biologist",0.6481481481481481 +2025-04-07,"Rukarumel, Biologist",0.4037685060565276 +2025-04-14,"Rukarumel, Biologist",0.9406657018813314 +2025-04-21,"Rukarumel, Biologist",0.32336297493936944 +2025-04-28,"Rukarumel, Biologist",0.18467220683287167 +2025-05-05,"Rukarumel, Biologist",0.49407114624505927 +2025-05-12,"Rukarumel, Biologist",0.6880733944954128 +2025-05-19,"Rukarumel, Biologist",0.7722007722007722 +2025-05-26,"Rukarumel, Biologist",0.13869625520110956 +2025-06-02,"Rukarumel, Biologist",1.4539579967689822 +2025-06-09,"Rukarumel, Biologist",0.32102728731942215 +2025-06-16,"Rukarumel, Biologist", +2025-06-23,"Rukarumel, Biologist",0.7374631268436578 +2025-06-30,"Rukarumel, Biologist",0.15408320493066255 +2025-07-07,"Rukarumel, Biologist",0.746268656716418 +2025-07-14,"Rukarumel, Biologist",0.746268656716418 +2025-07-21,"Rukarumel, Biologist",0.9887005649717514 +2025-07-28,"Rukarumel, Biologist",0.6868131868131868 +2025-08-04,"Rukarumel, Biologist",0.6476683937823834 +2025-08-11,"Rukarumel, Biologist",0.5249343832020997 +2025-08-18,"Rukarumel, Biologist",0.625 +2025-08-25,"Rukarumel, Biologist",0.9150326797385621 +2025-09-01,"Rukarumel, Biologist",1.0778443113772456 +2025-09-08,"Rukarumel, Biologist",0.8152173913043478 +2025-09-15,"Rukarumel, Biologist",1.0165184243964422 +2025-09-22,"Rukarumel, Biologist",0.702576112412178 +2025-09-29,"Rukarumel, Biologist",1.1312217194570136 +2025-10-06,"Rukarumel, Biologist",1.1547344110854503 +2025-10-13,"Rukarumel, Biologist",0.8482563619227145 +2025-10-20,"Rukarumel, Biologist", +2024-10-21,"Kyodai, Soul of Kamigawa",1.8633540372670807 +2024-10-28,"Kyodai, Soul of Kamigawa",0.6578947368421053 +2024-11-04,"Kyodai, Soul of Kamigawa",2.684563758389262 +2024-11-11,"Kyodai, Soul of Kamigawa",0.4854368932038835 +2024-11-18,"Kyodai, Soul of Kamigawa",0.6451612903225806 +2024-11-25,"Kyodai, Soul of Kamigawa", +2024-12-02,"Kyodai, Soul of Kamigawa",2.0408163265306123 +2024-12-09,"Kyodai, Soul of Kamigawa", +2024-12-16,"Kyodai, Soul of Kamigawa",1.7241379310344827 +2024-12-23,"Kyodai, Soul of Kamigawa",0.9216589861751152 +2024-12-30,"Kyodai, Soul of Kamigawa",0.8064516129032258 +2025-01-06,"Kyodai, Soul of Kamigawa",0.6211180124223602 +2025-01-13,"Kyodai, Soul of Kamigawa",0.9302325581395349 +2025-01-20,"Kyodai, Soul of Kamigawa", +2025-01-27,"Kyodai, Soul of Kamigawa",0.8849557522123894 +2025-02-03,"Kyodai, Soul of Kamigawa",2.1390374331550803 +2025-02-10,"Kyodai, Soul of Kamigawa",0.6980802792321117 +2025-02-17,"Kyodai, Soul of Kamigawa",0.672645739910314 +2025-02-24,"Kyodai, Soul of Kamigawa",2.450980392156863 +2025-03-03,"Kyodai, Soul of Kamigawa",1.4705882352941178 +2025-03-10,"Kyodai, Soul of Kamigawa",1.9021739130434783 +2025-03-17,"Kyodai, Soul of Kamigawa",0.9459459459459459 +2025-03-24,"Kyodai, Soul of Kamigawa",0.34812880765883375 +2025-03-31,"Kyodai, Soul of Kamigawa",0.46296296296296297 +2025-04-07,"Kyodai, Soul of Kamigawa",0.47106325706594887 +2025-04-14,"Kyodai, Soul of Kamigawa",0.5788712011577424 +2025-04-21,"Kyodai, Soul of Kamigawa",0.889248181083266 +2025-04-28,"Kyodai, Soul of Kamigawa",0.554016620498615 +2025-05-05,"Kyodai, Soul of Kamigawa",0.7905138339920948 +2025-05-12,"Kyodai, Soul of Kamigawa",0.22935779816513763 +2025-05-19,"Kyodai, Soul of Kamigawa",0.7722007722007722 +2025-05-26,"Kyodai, Soul of Kamigawa",1.1095700416088765 +2025-06-02,"Kyodai, Soul of Kamigawa",0.32310177705977383 +2025-06-09,"Kyodai, Soul of Kamigawa",0.32102728731942215 +2025-06-16,"Kyodai, Soul of Kamigawa",0.5633802816901409 +2025-06-23,"Kyodai, Soul of Kamigawa",0.2949852507374631 +2025-06-30,"Kyodai, Soul of Kamigawa",0.15408320493066255 +2025-07-07,"Kyodai, Soul of Kamigawa",0.29850746268656714 +2025-07-14,"Kyodai, Soul of Kamigawa",0.5970149253731343 +2025-07-21,"Kyodai, Soul of Kamigawa",0.423728813559322 +2025-07-28,"Kyodai, Soul of Kamigawa",0.6868131868131868 +2025-08-04,"Kyodai, Soul of Kamigawa",0.5181347150259067 +2025-08-11,"Kyodai, Soul of Kamigawa",0.3937007874015748 +2025-08-18,"Kyodai, Soul of Kamigawa",0.375 +2025-08-25,"Kyodai, Soul of Kamigawa",0.7843137254901961 +2025-09-01,"Kyodai, Soul of Kamigawa",0.718562874251497 +2025-09-08,"Kyodai, Soul of Kamigawa",0.6793478260869565 +2025-09-15,"Kyodai, Soul of Kamigawa",0.25412960609911056 +2025-09-22,"Kyodai, Soul of Kamigawa",0.468384074941452 +2025-09-29,"Kyodai, Soul of Kamigawa",0.6787330316742082 +2025-10-06,"Kyodai, Soul of Kamigawa",0.23094688221709006 +2025-10-13,"Kyodai, Soul of Kamigawa",0.2827521206409048 +2025-10-20,"Kyodai, Soul of Kamigawa",0.5617977528089888 +2024-10-21,Tiamat,13.664596273291925 +2024-10-28,Tiamat,11.18421052631579 +2024-11-04,Tiamat,12.080536912751677 +2024-11-11,Tiamat,7.281553398058253 +2024-11-18,Tiamat,8.387096774193548 +2024-11-25,Tiamat,10.218978102189782 +2024-12-02,Tiamat,12.92517006802721 +2024-12-09,Tiamat,11.403508771929825 +2024-12-16,Tiamat,11.494252873563218 +2024-12-23,Tiamat,12.903225806451612 +2024-12-30,Tiamat,11.693548387096774 +2025-01-06,Tiamat,9.937888198757763 +2025-01-13,Tiamat,11.162790697674419 +2025-01-20,Tiamat,12.280701754385966 +2025-01-27,Tiamat,14.15929203539823 +2025-02-03,Tiamat,7.4866310160427805 +2025-02-10,Tiamat,13.263525305410122 +2025-02-17,Tiamat,10.986547085201794 +2025-02-24,Tiamat,12.990196078431373 +2025-03-03,Tiamat,12.058823529411764 +2025-03-10,Tiamat,9.23913043478261 +2025-03-17,Tiamat,19.18918918918919 +2025-03-24,Tiamat,20.713664055700608 +2025-03-31,Tiamat,23.51851851851852 +2025-04-07,Tiamat,19.044414535666217 +2025-04-14,Tiamat,19.03039073806078 +2025-04-21,Tiamat,20.048504446240905 +2025-04-28,Tiamat,18.097876269621423 +2025-05-05,Tiamat,17.490118577075098 +2025-05-12,Tiamat,16.28440366972477 +2025-05-19,Tiamat,17.63191763191763 +2025-05-26,Tiamat,16.78224687933426 +2025-06-02,Tiamat,15.024232633279484 +2025-06-09,Tiamat,17.174959871589085 +2025-06-16,Tiamat,15.211267605633802 +2025-06-23,Tiamat,15.486725663716815 +2025-06-30,Tiamat,16.949152542372882 +2025-07-07,Tiamat,16.71641791044776 +2025-07-14,Tiamat,12.985074626865671 +2025-07-21,Tiamat,13.135593220338983 +2025-07-28,Tiamat,17.857142857142858 +2025-08-04,Tiamat,11.658031088082902 +2025-08-11,Tiamat,12.598425196850394 +2025-08-18,Tiamat,15.25 +2025-08-25,Tiamat,14.640522875816993 +2025-09-01,Tiamat,13.293413173652695 +2025-09-08,Tiamat,11.277173913043478 +2025-09-15,Tiamat,11.562897077509529 +2025-09-22,Tiamat,15.105386416861826 +2025-09-29,Tiamat,11.990950226244344 +2025-10-06,Tiamat,14.087759815242494 +2025-10-13,Tiamat,12.818096135721017 +2025-10-20,Tiamat,15.168539325842696 +2024-10-21,"Morophon, the Boundless",4.3478260869565215 +2024-10-28,"Morophon, the Boundless",4.605263157894737 +2024-11-04,"Morophon, the Boundless",4.697986577181208 +2024-11-11,"Morophon, the Boundless",3.883495145631068 +2024-11-18,"Morophon, the Boundless",4.516129032258065 +2024-11-25,"Morophon, the Boundless",8.75912408759124 +2024-12-02,"Morophon, the Boundless",4.081632653061225 +2024-12-09,"Morophon, the Boundless",2.6315789473684212 +2024-12-16,"Morophon, the Boundless",6.32183908045977 +2024-12-23,"Morophon, the Boundless",4.147465437788019 +2024-12-30,"Morophon, the Boundless",1.6129032258064515 +2025-01-06,"Morophon, the Boundless",3.7267080745341614 +2025-01-13,"Morophon, the Boundless",4.186046511627907 +2025-01-20,"Morophon, the Boundless",5.2631578947368425 +2025-01-27,"Morophon, the Boundless",3.0973451327433628 +2025-02-03,"Morophon, the Boundless",8.556149732620321 +2025-02-10,"Morophon, the Boundless",2.094240837696335 +2025-02-17,"Morophon, the Boundless",3.1390134529147984 +2025-02-24,"Morophon, the Boundless",4.166666666666667 +2025-03-03,"Morophon, the Boundless",2.0588235294117645 +2025-03-10,"Morophon, the Boundless",5.163043478260869 +2025-03-17,"Morophon, the Boundless",4.054054054054054 +2025-03-24,"Morophon, the Boundless",2.4369016536118364 +2025-03-31,"Morophon, the Boundless",2.1296296296296298 +2025-04-07,"Morophon, the Boundless",2.624495289367429 +2025-04-14,"Morophon, the Boundless",2.894356005788712 +2025-04-21,"Morophon, the Boundless",2.8294260307194827 +2025-04-28,"Morophon, the Boundless",3.0470914127423825 +2025-05-05,"Morophon, the Boundless",4.051383399209486 +2025-05-12,"Morophon, the Boundless",3.555045871559633 +2025-05-19,"Morophon, the Boundless",3.861003861003861 +2025-05-26,"Morophon, the Boundless",3.19001386962552 +2025-06-02,"Morophon, the Boundless",3.231017770597738 +2025-06-09,"Morophon, the Boundless",2.889245585874799 +2025-06-16,"Morophon, the Boundless",2.9577464788732395 +2025-06-23,"Morophon, the Boundless",2.949852507374631 +2025-06-30,"Morophon, the Boundless",2.3112480739599386 +2025-07-07,"Morophon, the Boundless",4.776119402985074 +2025-07-14,"Morophon, the Boundless",3.7313432835820897 +2025-07-21,"Morophon, the Boundless",2.824858757062147 +2025-07-28,"Morophon, the Boundless",2.197802197802198 +2025-08-04,"Morophon, the Boundless",3.1088082901554404 +2025-08-11,"Morophon, the Boundless",3.2808398950131235 +2025-08-18,"Morophon, the Boundless",2.375 +2025-08-25,"Morophon, the Boundless",2.2222222222222223 +2025-09-01,"Morophon, the Boundless",3.1137724550898205 +2025-09-08,"Morophon, the Boundless",2.717391304347826 +2025-09-15,"Morophon, the Boundless",3.684879288437103 +2025-09-22,"Morophon, the Boundless",2.459016393442623 +2025-09-29,"Morophon, the Boundless",3.733031674208145 +2025-10-06,"Morophon, the Boundless",2.3094688221709005 +2025-10-13,"Morophon, the Boundless",2.5447690857681433 +2025-10-20,"Morophon, the Boundless",2.808988764044944 +2024-10-21,"Ramos, Dragon Engine",0.6211180124223602 +2024-10-28,"Ramos, Dragon Engine",1.3157894736842106 +2024-11-04,"Ramos, Dragon Engine",0.6711409395973155 +2024-11-11,"Ramos, Dragon Engine",1.941747572815534 +2024-11-18,"Ramos, Dragon Engine",0.6451612903225806 +2024-11-25,"Ramos, Dragon Engine",0.7299270072992701 +2024-12-02,"Ramos, Dragon Engine", +2024-12-09,"Ramos, Dragon Engine",2.6315789473684212 +2024-12-16,"Ramos, Dragon Engine",2.8735632183908044 +2024-12-23,"Ramos, Dragon Engine",1.3824884792626728 +2024-12-30,"Ramos, Dragon Engine",0.4032258064516129 +2025-01-06,"Ramos, Dragon Engine",1.8633540372670807 +2025-01-13,"Ramos, Dragon Engine",0.9302325581395349 +2025-01-20,"Ramos, Dragon Engine",1.7543859649122806 +2025-01-27,"Ramos, Dragon Engine",1.7699115044247788 +2025-02-03,"Ramos, Dragon Engine", +2025-02-10,"Ramos, Dragon Engine",1.0471204188481675 +2025-02-17,"Ramos, Dragon Engine",1.345291479820628 +2025-02-24,"Ramos, Dragon Engine",2.2058823529411766 +2025-03-03,"Ramos, Dragon Engine",1.4705882352941178 +2025-03-10,"Ramos, Dragon Engine",1.9021739130434783 +2025-03-17,"Ramos, Dragon Engine",0.9459459459459459 +2025-03-24,"Ramos, Dragon Engine",0.6092254134029591 +2025-03-31,"Ramos, Dragon Engine",0.8333333333333334 +2025-04-07,"Ramos, Dragon Engine",1.4131897711978465 +2025-04-14,"Ramos, Dragon Engine",1.2301013024602026 +2025-04-21,"Ramos, Dragon Engine",0.889248181083266 +2025-04-28,"Ramos, Dragon Engine",0.9233610341643582 +2025-05-05,"Ramos, Dragon Engine",1.383399209486166 +2025-05-12,"Ramos, Dragon Engine",1.9495412844036697 +2025-05-19,"Ramos, Dragon Engine",1.287001287001287 +2025-05-26,"Ramos, Dragon Engine",1.248266296809986 +2025-06-02,"Ramos, Dragon Engine",0.9693053311793215 +2025-06-09,"Ramos, Dragon Engine",0.48154093097913325 +2025-06-16,"Ramos, Dragon Engine",1.6901408450704225 +2025-06-23,"Ramos, Dragon Engine",1.4749262536873156 +2025-06-30,"Ramos, Dragon Engine",1.5408320493066257 +2025-07-07,"Ramos, Dragon Engine",1.1940298507462686 +2025-07-14,"Ramos, Dragon Engine",0.746268656716418 +2025-07-21,"Ramos, Dragon Engine",0.5649717514124294 +2025-07-28,"Ramos, Dragon Engine",1.098901098901099 +2025-08-04,"Ramos, Dragon Engine",0.9067357512953368 +2025-08-11,"Ramos, Dragon Engine",0.7874015748031497 +2025-08-18,"Ramos, Dragon Engine",0.5 +2025-08-25,"Ramos, Dragon Engine",1.6993464052287581 +2025-09-01,"Ramos, Dragon Engine",0.5988023952095808 +2025-09-08,"Ramos, Dragon Engine",1.6304347826086956 +2025-09-15,"Ramos, Dragon Engine",0.5082592121982211 +2025-09-22,"Ramos, Dragon Engine",0.468384074941452 +2025-09-29,"Ramos, Dragon Engine",1.1312217194570136 +2025-10-06,"Ramos, Dragon Engine",0.6928406466512702 +2025-10-13,"Ramos, Dragon Engine",0.7540056550424128 +2025-10-20,"Ramos, Dragon Engine",0.5617977528089888 +2024-10-21,The Ur-Dragon,63.35403726708075 +2024-10-28,The Ur-Dragon,73.02631578947368 +2024-11-04,The Ur-Dragon,67.78523489932886 +2024-11-11,The Ur-Dragon,76.2135922330097 +2024-11-18,The Ur-Dragon,69.6774193548387 +2024-11-25,The Ur-Dragon,64.96350364963503 +2024-12-02,The Ur-Dragon,68.70748299319727 +2024-12-09,The Ur-Dragon,64.91228070175438 +2024-12-16,The Ur-Dragon,62.06896551724138 +2024-12-23,The Ur-Dragon,70.04608294930875 +2024-12-30,The Ur-Dragon,66.93548387096774 +2025-01-06,The Ur-Dragon,75.77639751552795 +2025-01-13,The Ur-Dragon,63.72093023255814 +2025-01-20,The Ur-Dragon,65.49707602339181 +2025-01-27,The Ur-Dragon,68.58407079646018 +2025-02-03,The Ur-Dragon,63.101604278074866 +2025-02-10,The Ur-Dragon,71.02966841186736 +2025-02-17,The Ur-Dragon,69.5067264573991 +2025-02-24,The Ur-Dragon,64.46078431372548 +2025-03-03,The Ur-Dragon,70.0 +2025-03-10,The Ur-Dragon,68.47826086956522 +2025-03-17,The Ur-Dragon,51.891891891891895 +2025-03-24,The Ur-Dragon,49.260226283724975 +2025-03-31,The Ur-Dragon,48.98148148148148 +2025-04-07,The Ur-Dragon,52.28802153432032 +2025-04-14,The Ur-Dragon,52.0260492040521 +2025-04-21,The Ur-Dragon,52.95068714632175 +2025-04-28,The Ur-Dragon,55.586334256694364 +2025-05-05,The Ur-Dragon,51.87747035573123 +2025-05-12,The Ur-Dragon,53.89908256880734 +2025-05-19,The Ur-Dragon,53.41055341055341 +2025-05-26,The Ur-Dragon,56.86546463245492 +2025-06-02,The Ur-Dragon,55.73505654281099 +2025-06-09,The Ur-Dragon,55.698234349919744 +2025-06-16,The Ur-Dragon,59.57746478873239 +2025-06-23,The Ur-Dragon,57.66961651917404 +2025-06-30,The Ur-Dragon,58.089368258859785 +2025-07-07,The Ur-Dragon,57.3134328358209 +2025-07-14,The Ur-Dragon,60.44776119402985 +2025-07-21,The Ur-Dragon,61.440677966101696 +2025-07-28,The Ur-Dragon,55.76923076923077 +2025-08-04,The Ur-Dragon,59.84455958549223 +2025-08-11,The Ur-Dragon,59.84251968503937 +2025-08-18,The Ur-Dragon,59.375 +2025-08-25,The Ur-Dragon,58.169934640522875 +2025-09-01,The Ur-Dragon,57.724550898203596 +2025-09-08,The Ur-Dragon,61.95652173913044 +2025-09-15,The Ur-Dragon,59.46632782719187 +2025-09-22,The Ur-Dragon,56.440281030444964 +2025-09-29,The Ur-Dragon,58.93665158371041 +2025-10-06,The Ur-Dragon,57.390300230946885 +2025-10-13,The Ur-Dragon,57.68143261074458 +2025-10-20,The Ur-Dragon,57.30337078651685 +2024-10-21,Scion of the Ur-Dragon,6.211180124223603 +2024-10-28,Scion of the Ur-Dragon,2.6315789473684212 +2024-11-04,Scion of the Ur-Dragon,6.040268456375839 +2024-11-11,Scion of the Ur-Dragon,2.912621359223301 +2024-11-18,Scion of the Ur-Dragon,4.516129032258065 +2024-11-25,Scion of the Ur-Dragon,5.109489051094891 +2024-12-02,Scion of the Ur-Dragon,2.7210884353741496 +2024-12-09,Scion of the Ur-Dragon,7.017543859649122 +2024-12-16,Scion of the Ur-Dragon,5.172413793103448 +2024-12-23,Scion of the Ur-Dragon,2.7649769585253456 +2024-12-30,Scion of the Ur-Dragon,5.645161290322581 +2025-01-06,Scion of the Ur-Dragon,2.484472049689441 +2025-01-13,Scion of the Ur-Dragon,6.511627906976744 +2025-01-20,Scion of the Ur-Dragon,5.2631578947368425 +2025-01-27,Scion of the Ur-Dragon,4.867256637168142 +2025-02-03,Scion of the Ur-Dragon,6.4171122994652405 +2025-02-10,Scion of the Ur-Dragon,4.886561954624782 +2025-02-17,Scion of the Ur-Dragon,4.932735426008969 +2025-02-24,Scion of the Ur-Dragon,6.372549019607843 +2025-03-03,Scion of the Ur-Dragon,3.823529411764706 +2025-03-10,Scion of the Ur-Dragon,4.076086956521739 +2025-03-17,Scion of the Ur-Dragon,4.864864864864865 +2025-03-24,Scion of the Ur-Dragon,8.181026979982594 +2025-03-31,Scion of the Ur-Dragon,4.537037037037037 +2025-04-07,Scion of the Ur-Dragon,4.508748317631225 +2025-04-14,Scion of the Ur-Dragon,3.6903039073806077 +2025-04-21,Scion of the Ur-Dragon,5.173807599029911 +2025-04-28,Scion of the Ur-Dragon,3.2317636195752537 +2025-05-05,Scion of the Ur-Dragon,4.644268774703558 +2025-05-12,Scion of the Ur-Dragon,4.472477064220183 +2025-05-19,Scion of the Ur-Dragon,4.633204633204633 +2025-05-26,Scion of the Ur-Dragon,4.0221914008321775 +2025-06-02,Scion of the Ur-Dragon,4.684975767366721 +2025-06-09,Scion of the Ur-Dragon,4.49438202247191 +2025-06-16,Scion of the Ur-Dragon,4.084507042253521 +2025-06-23,Scion of the Ur-Dragon,4.277286135693215 +2025-06-30,Scion of the Ur-Dragon,3.389830508474576 +2025-07-07,Scion of the Ur-Dragon,2.6865671641791047 +2025-07-14,Scion of the Ur-Dragon,3.582089552238806 +2025-07-21,Scion of the Ur-Dragon,3.8135593220338984 +2025-07-28,Scion of the Ur-Dragon,3.159340659340659 +2025-08-04,Scion of the Ur-Dragon,3.3678756476683938 +2025-08-11,Scion of the Ur-Dragon,3.8057742782152233 +2025-08-18,Scion of the Ur-Dragon,2.5 +2025-08-25,Scion of the Ur-Dragon,3.7908496732026142 +2025-09-01,Scion of the Ur-Dragon,3.3532934131736525 +2025-09-08,Scion of the Ur-Dragon,3.3967391304347827 +2025-09-15,Scion of the Ur-Dragon,4.447268106734435 +2025-09-22,Scion of the Ur-Dragon,4.215456674473068 +2025-09-29,Scion of the Ur-Dragon,2.9411764705882355 +2025-10-06,Scion of the Ur-Dragon,3.1177829099307157 +2025-10-13,Scion of the Ur-Dragon,4.147031102733271 +2025-10-20,Scion of the Ur-Dragon,2.808988764044944 +2024-10-21,(other commanders),8.07453416149069 +2024-10-28,(other commanders),5.921052631578931 +2024-11-04,(other commanders),6.040268456375827 +2024-11-11,(other commanders),7.281553398058264 +2024-11-18,(other commanders),10.322580645161295 +2024-11-25,(other commanders),8.75912408759126 +2024-12-02,(other commanders),9.523809523809533 +2024-12-09,(other commanders),10.526315789473685 +2024-12-16,(other commanders),8.620689655172413 +2024-12-23,(other commanders),7.373271889400925 +2024-12-30,(other commanders),11.290322580645167 +2025-01-06,(other commanders),4.968944099378888 +2025-01-13,(other commanders),11.627906976744185 +2025-01-20,(other commanders),8.771929824561397 +2025-01-27,(other commanders),5.752212389380517 +2025-02-03,(other commanders),11.764705882352942 +2025-02-10,(other commanders),6.457242582897024 +2025-02-17,(other commanders),8.07174887892377 +2025-02-24,(other commanders),6.862745098039227 +2025-03-03,(other commanders),8.529411764705884 +2025-03-10,(other commanders),8.695652173913032 +2025-03-17,(other commanders),5.945945945945937 +2025-03-24,(other commanders),5.134899912967811 +2025-03-31,(other commanders),4.7222222222222285 +2025-04-07,(other commanders),4.576043068640644 +2025-04-14,(other commanders),4.775687409551381 +2025-04-21,(other commanders),4.688763136620864 +2025-04-28,(other commanders),5.078485687903978 +2025-05-05,(other commanders),5.632411067193672 +2025-05-12,(other commanders),6.8807339449541445 +2025-05-19,(other commanders),4.633204633204642 +2025-05-26,(other commanders),3.744798890429962 +2025-06-02,(other commanders),4.523424878836835 +2025-06-09,(other commanders),5.939004815409319 +2025-06-16,(other commanders),3.6619718309859337 +2025-06-23,(other commanders),5.309734513274336 +2025-06-30,(other commanders),4.930662557781204 +2025-07-07,(other commanders),5.671641791044792 +2025-07-14,(other commanders),5.0746268656716325 +2025-07-21,(other commanders),5.790960451977398 +2025-07-28,(other commanders),4.945054945054949 +2025-08-04,(other commanders),6.606217616580324 +2025-08-11,(other commanders),5.249343832020983 +2025-08-18,(other commanders),4.375 +2025-08-25,(other commanders),5.359477124183016 +2025-09-01,(other commanders),6.34730538922156 +2025-09-08,(other commanders),6.3858695652173765 +2025-09-15,(other commanders),4.955527318932653 +2025-09-22,(other commanders),4.5667447306791615 +2025-09-29,(other commanders),5.090497737556575 +2025-10-06,(other commanders),5.773672055427241 +2025-10-13,(other commanders),4.71253534401508 +2025-10-20,(other commanders),8.426966292134836 diff --git a/tests/test_plotly_express/test_stacked_bar.py b/tests/test_plotly_express/test_stacked_bar.py new file mode 100644 index 0000000000..741cca12b0 --- /dev/null +++ b/tests/test_plotly_express/test_stacked_bar.py @@ -0,0 +1,69 @@ +# tests/test_plotly_express/test_stacked_bar.py + +import sys +import pytest +import pandas as pd +import plotly.express as px +from itertools import product + +# Skip test for older Python/pandas versions to avoid build failures +pytestmark = pytest.mark.skipif( + sys.version_info < (3, 9) or pd.__version__ < "1.2.0", + reason="Requires Python >=3.9 and pandas >=1.2.0", +) + + +def test_stacked_bar_all_groups(): + """ + Test that stacked bar plots include all groups (commanders) for every week. + This ensures that missing combinations are filled with 0. + """ + + # Step 1: Load example data + plot_data = pd.read_csv("../../test_data/example_plot_data.csv") + + # Step 2: Convert the date column + plot_data["savedate_week"] = pd.to_datetime(plot_data["savedate_week"]) + + # Step 3: Get all unique weeks and commanders + all_weeks = plot_data["savedate_week"].unique() + all_commanders = plot_data["commanders"].unique() + + # Step 4: Generate full combinations of weeks and commanders + full_index = pd.DataFrame( + list(product(all_weeks, all_commanders)), + columns=["savedate_week", "commanders"], + ) + + # Step 5: Merge with original data and fill missing values with 0 + plot_data_full = full_index.merge( + plot_data, on=["savedate_week", "commanders"], how="left" + ) + plot_data_full["commander_perc_of_card"] = plot_data_full[ + "commander_perc_of_card" + ].fillna(0) + + # Step 6: Create the stacked bar plot (not shown in tests) + fig = px.bar( + plot_data_full, + x="savedate_week", + y="commander_perc_of_card", + color="commanders", + ) + + # Step 7: Assertions + weeks_in_fig = plot_data_full["savedate_week"].unique() + commanders_in_fig = plot_data_full["commanders"].unique() + + # Check that all weeks and all commanders are present + assert len(weeks_in_fig) == len(all_weeks), ( + "Some weeks are missing in the stacked bar data" + ) + assert len(commanders_in_fig) == len(all_commanders), ( + "Some commanders are missing in the stacked bar data" + ) + + # Optional: Check that no NaNs exist after filling + assert plot_data_full["commander_perc_of_card"].isna().sum() == 0, ( + "NaN values found in commander_perc_of_card" + )