bito-code-review[bot] commented on code in PR #44657:
URL: https://github.com/apache/superset/pull/44657#discussion_r4179780679


##########
tests/unit_tests/charts/test_client_processing.py:
##########
@@ -2144,6 +2172,164 @@ def 
test_pivot_table_v2_actual_values_uses_database_rollups():
     assert pivoted.loc[("US",), ("AVG(num)", "boy")] == 10
 
 
[email protected](
+    "aggregate_function,expected",
+    [
+        ("Sample Variance", 50.0),
+        ("Sample Standard Deviation", 50.0**0.5),
+    ],
+)
+def test_pivot_table_v2_sample_statistics_aggregations(
+    aggregate_function: str, expected: float
+):
+    """Sample variance/standard deviation must compute for two values at one
+    pivot address (10 and 20 give variance 50 and standard deviation ~7.071),
+    not raise on a misspelled ``pd.series`` or a non-callable tuple.
+    """
+    df = pd.DataFrame(
+        {
+            "nation": ["US", "US"],
+            "gender": ["boy", "boy"],
+            "SUM(num)": [10, 20],
+        }
+    )
+    form_data = {
+        "groupbyRows": ["nation"],
+        "groupbyColumns": ["gender"],
+        "metrics": ["SUM(num)"],
+        "aggregateFunction": aggregate_function,
+    }
+
+    pivoted = pivot_table_v2(df, form_data, apply_number_format=False)
+
+    assert pivoted.loc[("US",), ("SUM(num)", "boy")] == pytest.approx(expected)
+
+
[email protected](
+    "aggregate_function",
+    ["Sample Variance", "Sample Standard Deviation"],
+)
+def test_pivot_table_v2_sample_statistics_with_summaries(aggregate_function: 
str):
+    """Row and column summaries invoke the reducer with ``axis``; the sample
+    statistics must handle the DataFrame/axis form, not just a Series.
+    """
+    df = pd.DataFrame(
+        {
+            "nation": ["US", "US", "FR", "FR"],
+            "gender": ["boy", "girl", "boy", "girl"],
+            "SUM(num)": [10, 20, 30, 50],
+        }
+    )
+    form_data = {
+        "groupbyRows": ["nation"],
+        "groupbyColumns": ["gender"],
+        "metrics": ["SUM(num)"],
+        "aggregateFunction": aggregate_function,
+        "rowTotals": True,
+        "colTotals": True,
+    }
+
+    pivoted = pivot_table_v2(df, form_data, apply_number_format=False)
+
+    assert not pivoted.empty
+
+
[email protected](
+    "aggregate_function",
+    [
+        "Count",
+        "Count Unique Values",
+        "List Unique Values",
+        "First",
+        "Last",
+    ],
+)
[email protected]("totals", [{"rowTotals": True}, {"colTotals": True}])
+def test_pivot_table_v2_series_only_reducers_with_summaries(
+    aggregate_function: str, totals: dict[str, bool]
+):
+    """Series-only reducers must support each row/column summary axis rather
+    than raising ``TypeError`` on the DataFrame/``axis`` invocation.
+    """
+    df = pd.DataFrame(
+        {
+            "nation": ["US", "US", "FR", "FR"],
+            "gender": ["boy", "girl", "boy", "girl"],
+            "SUM(num)": [10, 20, 30, 50],
+        }
+    )
+    form_data = {
+        "groupbyRows": ["nation"],
+        "groupbyColumns": ["gender"],
+        "metrics": ["SUM(num)"],
+        "aggregateFunction": aggregate_function,
+        **totals,
+    }
+
+    pivoted = pivot_table_v2(df, form_data, apply_number_format=False)
+
+    assert not pivoted.empty
+
+
[email protected](
+    "aggregate_function",
+    ["Sample Variance", "Sample Standard Deviation"],
+)
+def test_pivot_table_v2_sample_statistics_sparse_summaries(aggregate_function: 
str):

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing return annotations</b></div>
   <div id="fix">
   
   Both new tests annotate parameters but omit the return annotation. BITO.md 
adaptive rules 7819 and 14234 mandate explicit return type annotations on all 
functions, including test methods (`-> None`). Adding `-> None` to the defs at 
2248 and 2278 keeps the new code compliant with the org-mandated typing 
standard.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #8e3df5</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to