Skip to content

Commit 635eba3

Browse files
Merge pull request #5 from saisandeepramavath/nithikesh
Nithikesh
2 parents cb40e31 + 332e06f commit 635eba3

File tree

3 files changed

+333
-0
lines changed

3 files changed

+333
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Integration Testing - Instructions to Run Tests
2+
3+
## Test File Location
4+
5+
Integration tests are located in: **`pandas/tests/util/test_integration.py`**
6+
7+
## Prerequisites
8+
9+
```bash
10+
# Navigate to project directory
11+
cd /Volumes/T7Shield/SWEN777/SWEN_777_Pandas
12+
13+
# Activate virtual environment
14+
source venv/bin/activate
15+
```
16+
17+
## How to Run Tests to Reproduce Results
18+
19+
### Run All Integration Tests
20+
21+
```bash
22+
python -m pytest pandas/tests/util/test_integration.py -v
23+
```
24+
25+
**Expected Output:**
26+
```
27+
collected 6 items
28+
29+
pandas/tests/util/test_integration.py::TestSandeepIntegration::test_series_to_dataframe_dtype_preservation PASSED
30+
pandas/tests/util/test_integration.py::TestSandeepIntegration::test_dataframe_from_dict_mixed_series_dtypes PASSED
31+
pandas/tests/util/test_integration.
32+
py::TestNithikeshIntegration::test_validate_fillna_with_clean_method PASSED
33+
pandas/tests/util/test_integration.py::TestNithikeshIntegration::test_series_fillna_integration PASSED
34+
pandas/tests/util/test_integration.
35+
py::TestMallikarjunaIntegration::test_check_dtype_backend_with_lib_sentinel PASSED
36+
pandas/tests/util/test_integration.py::TestMallikarjunaIntegration::test_percentile_validation_with_numpy_arrays PASSED
37+
38+
=================================== 6 passed in 0.94s
39+
```
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Integration Testing Report
2+
3+
## Test Design Summary
4+
5+
This integration testing effort focuses on verifying interactions between multiple pandas modules. The tests are organized into three areas, each covering at least 2 module interactions:
6+
7+
### Test 1: Series-DataFrame-Dtype Integration (Sandeep Ramavath)
8+
**Modules Integrated:**
9+
- `pandas.core.series` (Series class)
10+
- `pandas.core.frame` (DataFrame class)
11+
- `pandas.core.internals` (internal data managers)
12+
- `pandas.core.dtypes` (data type handling)
13+
14+
**Interactions Tested:**
15+
1. **Series.to_frame()**: Tests dtype preservation when converting Series to DataFrame through internal manager conversion
16+
2. **DataFrame construction from dict**: Tests how DataFrame handles multiple Series with different dtypes (int64, float32, object) during construction
17+
18+
19+
### Test 2: Validation-Missing Data Integration (Nithikesh Bobbili)
20+
**Modules Integrated:**
21+
- `pandas.util._validators` (validation utilities)
22+
- `pandas.core.missing` (missing data handling)
23+
- `pandas.core.series` (Series operations)
24+
- `pandas.core.internals` (internal data modification)
25+
26+
**Interactions Tested:**
27+
1. **validate_fillna_kwargs with clean_fill_method**: Tests delegation from validator to missing data module for method normalization
28+
2. **Series.fillna/ffill operations**: Tests complete pipeline from user API through validation to missing data handling
29+
30+
### Test 3: Dtype Backend-Libs Integration (Mallikarjuna)
31+
**Modules Integrated:**
32+
- `pandas.util._validators` (validation functions)
33+
- `pandas._libs.lib` (C extension library with sentinel values)
34+
- `numpy` (array handling and validation)
35+
36+
**Interactions Tested:**
37+
1. **check_dtype_backend with lib.no_default**: Tests validator interaction with C library sentinel values
38+
2. **validate_percentile with numpy arrays**: Tests pandas validation with numpy array conversion and bounds checking
39+
40+
## Test Data Preparation
41+
42+
### Input Data Generation
43+
44+
**Test 1 - Series/DataFrame Integration:**
45+
- **Input**: Created Series with explicit dtype (`int32`) and sample data `[1, 2, 3]`
46+
- **Input**: Created multiple Series with different dtypes: int64, float32, object
47+
- **Rationale**: Different dtypes exercise type preservation logic across module boundaries
48+
49+
**Test 2 - Validation/Missing Data:**
50+
- **Input**: Series with `np.nan` values: `[1.0, np.nan, 3.0, np.nan, 5.0]`
51+
- **Input**: Method names `"pad"`, `"ffill"` and `None` values
52+
- **Rationale**: Missing values and various method names test validation and fill method delegation
53+
54+
**Test 3 - Backend/Libs Validation:**
55+
- **Input**: `lib.no_default` sentinel, valid backends (`"numpy_nullable"`, `"pyarrow"`), invalid backend string
56+
- **Input**: Valid percentiles (`0.5`, `[0.25, 0.5, 0.75]`) and invalid (`1.5`, `[0.25, 1.5, 0.75]`)
57+
- **Rationale**: Mix of valid/invalid inputs tests error handling across module boundaries
58+
59+
### Expected Output Data
60+
61+
All tests include explicit expected outputs:
62+
- Series/DataFrame tests verify dtype preservation and data integrity
63+
- Validation tests verify normalized method names and appropriate ValueError exceptions
64+
- Backend tests verify acceptance of valid values and rejection with specific error messages
65+
66+
## Execution and Results
67+
68+
**Test File**: `pandas/tests/util/test_integration.py`
69+
70+
**Execution Command:**
71+
```bash
72+
python -m pytest pandas/tests/util/test_integration.py -v
73+
```
74+
75+
**Test Results:**
76+
```
77+
collected 6 items
78+
79+
test_series_to_dataframe_dtype_preservation PASSED
80+
test_dataframe_from_dict_mixed_series_dtypes PASSED
81+
test_validate_fillna_with_clean_method PASSED
82+
test_series_fillna_integration PASSED
83+
test_check_dtype_backend_with_lib_sentinel PASSED
84+
test_percentile_validation_with_numpy_arrays PASSED
85+
86+
=================================== 6 passed in 0.94s
87+
```
88+
89+
**Summary:**
90+
- **Total Tests**: 6 integration tests
91+
- **Passed**: 6 (100%)
92+
- **Failed**: 0
93+
- **Execution Time**: 0.94 seconds
94+
95+
### Defects Discovered
96+
97+
**No defects were discovered during integration testing.** All module interactions functioned as expected:
98+
99+
- Series-to-DataFrame conversion preserves dtypes correctly
100+
- DataFrame construction handles mixed-dtype Series properly
101+
- Validation module correctly delegates to missing data module
102+
- Series fillna operations integrate validation and missing data modules
103+
- Backend validation properly handles C library sentinel values
104+
- Percentile validation correctly integrates with NumPy array handling
105+
106+
All error cases (ValueError for invalid inputs) behaved as designed, raising appropriate exceptions with descriptive messages.
107+
108+
## Bug Reports
109+
110+
**No bugs identified.** All integration points between modules are functioning correctly. The following expected behaviors were verified:
111+
112+
1. **Type preservation across module boundaries**: Dtypes maintained through Series→DataFrame→Internals conversions
113+
2. **Validation delegation**: Validators correctly call specialized modules (e.g., `clean_fill_method`)
114+
3. **Error propagation**: Invalid inputs raise appropriate exceptions with clear messages
115+
4. **Sentinel value handling**: C library sentinels (`lib.no_default`) recognized by validators
116+
117+
## Group Contributions
118+
119+
| Student | Test Cases | Modules Integrated | Coverage |
120+
|---------|------------|-------------------|----------|
121+
| **Sandeep Ramavath** | 2 tests | Series, DataFrame, Internals, Dtypes | Series-DataFrame conversion and construction |
122+
| **Nithikesh Bobbili** | 2 tests | Validators, Missing Data, Series, Internals | Fillna validation and operation pipeline |
123+
| **Mallikarjuna** | 2 tests | Validators, C Libs, NumPy | Backend validation and percentile checking |
124+
125+
**Total**: 6 integration tests covering 8+ distinct pandas modules with both normal and edge case scenarios.
126+

pandas/tests/test_integration.py

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
"""
2+
Integration tests for pandas modules.
3+
4+
These tests verify interactions between multiple modules/components:
5+
- pandas.core.series (Series construction)
6+
- pandas.core.frame (DataFrame construction)
7+
- pandas.core.dtypes (dtype handling)
8+
- pandas.core.internals (internal data management)
9+
- pandas.util._validators (validation utilities)
10+
- pandas.core.missing (missing data handling)
11+
"""
12+
import numpy as np
13+
import pytest
14+
15+
import pandas as pd
16+
from pandas import Series, DataFrame, Index
17+
from pandas.core.missing import clean_fill_method
18+
from pandas._libs import lib
19+
from pandas.util._validators import (
20+
validate_args_and_kwargs,
21+
validate_fillna_kwargs,
22+
check_dtype_backend,
23+
validate_percentile,
24+
)
25+
26+
27+
class TestSandeepIntegration:
28+
"""Integration tests by Sandeep Ramavath covering Series-DataFrame-dtype interactions."""
29+
30+
def test_series_to_dataframe_dtype_preservation(self):
31+
"""Test Series.to_frame() preserves dtype through internals conversion.
32+
33+
This exercises interaction between:
34+
- pandas.core.series.Series.to_frame()
35+
- pandas.core.internals (manager conversion)
36+
- pandas.core.frame.DataFrame
37+
- pandas.core.dtypes (dtype preservation)
38+
"""
39+
# Create Series with specific dtype
40+
s = Series([1, 2, 3], name="test_col", dtype="int32")
41+
42+
# Convert to DataFrame - should preserve dtype through internal conversion
43+
df = s.to_frame()
44+
45+
assert isinstance(df, DataFrame)
46+
assert df.columns[0] == "test_col"
47+
assert df["test_col"].dtype == np.dtype("int32")
48+
assert len(df) == 3
49+
assert (df["test_col"] == s).all()
50+
51+
def test_dataframe_from_dict_mixed_series_dtypes(self):
52+
"""Test DataFrame construction from dict with mixed Series dtypes.
53+
54+
This exercises interaction between:
55+
- pandas.core.frame.DataFrame.__init__
56+
- pandas.core.internals.construction.dict_to_mgr
57+
- pandas.core.series.Series (multiple instances with different dtypes)
58+
- pandas.core.dtypes (type coercion and preservation)
59+
"""
60+
# Create Series with different dtypes
61+
s1 = Series([1, 2, 3], dtype="int64")
62+
s2 = Series([1.0, 2.0, 3.0], dtype="float32")
63+
s3 = Series(["a", "b", "c"], dtype="object")
64+
65+
# Build DataFrame from dict of Series
66+
df = DataFrame({"col1": s1, "col2": s2, "col3": s3})
67+
68+
# Verify each column maintains its original dtype
69+
assert df["col1"].dtype == np.dtype("int64")
70+
assert df["col2"].dtype == np.dtype("float32")
71+
assert df["col3"].dtype == np.dtype("object")
72+
assert len(df) == 3
73+
74+
75+
class TestNithikeshIntegration:
76+
"""Integration tests by Nithikesh Bobbili covering validation-missing data interactions."""
77+
78+
def test_validate_fillna_with_clean_method(self):
79+
"""Test validate_fillna_kwargs delegates to clean_fill_method.
80+
81+
This exercises interaction between:
82+
- pandas.util._validators.validate_fillna_kwargs
83+
- pandas.core.missing.clean_fill_method
84+
- method normalization and validation
85+
"""
86+
# Test method normalization through validate_fillna_kwargs
87+
value, method = validate_fillna_kwargs(None, "pad")
88+
assert value is None
89+
assert method == clean_fill_method("pad")
90+
91+
# Test alternate method names
92+
value, method = validate_fillna_kwargs(None, "ffill")
93+
assert method == clean_fill_method("ffill")
94+
95+
# Both None should raise
96+
with pytest.raises(ValueError, match="Must specify a fill"):
97+
validate_fillna_kwargs(None, None)
98+
99+
def test_series_fillna_integration(self):
100+
"""Test Series.fillna() and ffill() use validation and missing data modules.
101+
102+
This exercises interaction between:
103+
- pandas.core.series.Series.fillna() / ffill()
104+
- pandas.util._validators.validate_fillna_kwargs (internally)
105+
- pandas.core.missing (fill methods)
106+
- pandas.core.internals (data modification)
107+
"""
108+
# Create Series with missing values
109+
s = Series([1.0, np.nan, 3.0, np.nan, 5.0])
110+
111+
# ffill uses forward fill method - interacts with missing data module
112+
result = s.ffill()
113+
expected = Series([1.0, 1.0, 3.0, 3.0, 5.0])
114+
pd.testing.assert_series_equal(result, expected)
115+
116+
# fillna with value - validation ensures value is acceptable
117+
result = s.fillna(value=0.0)
118+
expected = Series([1.0, 0.0, 3.0, 0.0, 5.0])
119+
pd.testing.assert_series_equal(result, expected)
120+
121+
class TestMallikarjunaIntegration:
122+
"""Integration tests by Mallikarjuna covering dtype_backend-libs interactions."""
123+
124+
def test_check_dtype_backend_with_lib_sentinel(self):
125+
"""Test check_dtype_backend with lib.no_default sentinel.
126+
127+
This exercises interaction between:
128+
- pandas.util._validators.check_dtype_backend
129+
- pandas._libs.lib.no_default (sentinel value)
130+
- validation of backend options
131+
"""
132+
# Should accept sentinel without exception
133+
check_dtype_backend(lib.no_default)
134+
135+
# Should accept valid backends
136+
check_dtype_backend("numpy_nullable")
137+
check_dtype_backend("pyarrow")
138+
139+
# Should reject unknown backend
140+
with pytest.raises(ValueError, match="dtype_backend .* is invalid"):
141+
check_dtype_backend("not_a_backend")
142+
143+
def test_percentile_validation_with_numpy_arrays(self):
144+
"""Test validate_percentile with numpy array interaction.
145+
146+
This exercises interaction between:
147+
- pandas.util._validators.validate_percentile
148+
- numpy array conversion and validation
149+
- pandas statistical methods that use percentiles
150+
"""
151+
# Single percentile as float
152+
result = validate_percentile(0.5)
153+
assert isinstance(result, np.ndarray)
154+
assert result == 0.5
155+
156+
# Multiple percentiles as list
157+
result = validate_percentile([0.25, 0.5, 0.75])
158+
expected = np.array([0.25, 0.5, 0.75])
159+
np.testing.assert_array_equal(result, expected)
160+
161+
# Invalid percentile should raise
162+
with pytest.raises(ValueError, match="percentiles should all be"):
163+
validate_percentile(1.5)
164+
165+
with pytest.raises(ValueError, match="percentiles should all be"):
166+
validate_percentile([0.25, 1.5, 0.75])
167+
168+

0 commit comments

Comments
 (0)