Skip to content

Merge pull request #447 from ranaroussi/vk-2b7f-please-fix #30

Merge pull request #447 from ranaroussi/vk-2b7f-please-fix

Merge pull request #447 from ranaroussi/vk-2b7f-please-fix #30

name: Test Pandas/Numpy Compatibility
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
jobs:
test-compatibility:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
pandas-version: ['1.5.0', '2.0.0', '2.1.0', '2.2.0']
numpy-version: ['1.21.0', '1.24.0', '1.26.0']
exclude:
# Exclude incompatible combinations
- python-version: '3.12'
pandas-version: '1.5.0'
- python-version: '3.12'
numpy-version: '1.21.0'
- python-version: '3.8'
pandas-version: '2.2.0'
- python-version: '3.8'
numpy-version: '1.26.0'
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install specific pandas and numpy versions
run: |
python -m pip install --upgrade pip
pip install pandas==${{ matrix.pandas-version }}
pip install numpy==${{ matrix.numpy-version }}
pip install packaging
- name: Install other dependencies
run: |
pip install seaborn>=0.11.0
pip install matplotlib>=3.3.0
pip install scipy>=1.7.0
pip install tabulate>=0.8.9
pip install yfinance>=0.2.18
pip install python-dateutil>=2.8.0
pip install pytest
- name: Install quantstats in development mode
run: |
pip install -e .
- name: Print versions
run: |
python -c "import pandas as pd; import numpy as np; print(f'pandas: {pd.__version__}, numpy: {np.__version__}')"
- name: Run compatibility tests
run: |
python test_fixes.py
- name: Run pytest compatibility tests
run: |
pytest tests/test_compatibility.py -v
- name: Test frequency aliases
run: |
python -c "
import sys
sys.path.insert(0, '.')
from quantstats._compat import get_frequency_alias
print('M ->', get_frequency_alias('M'))
print('Q ->', get_frequency_alias('Q'))
print('Y ->', get_frequency_alias('Y'))
"
- name: Test safe resample operations
run: |
python -c "
import sys
sys.path.insert(0, '.')
import pandas as pd
import numpy as np
from quantstats._compat import safe_resample
# Create test data
dates = pd.date_range('2020-01-01', periods=100, freq='D')
data = pd.Series(np.random.randn(100), index=dates)
# Test resample operations
monthly = safe_resample(data, 'M', 'sum')
quarterly = safe_resample(data, 'Q', 'mean')
yearly = safe_resample(data, 'Y', 'sum')
print('Monthly periods:', len(monthly))
print('Quarterly periods:', len(quarterly))
print('Yearly periods:', len(yearly))
print('All resample operations successful!')
"
test-latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12 with latest packages
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install latest versions
run: |
python -m pip install --upgrade pip
pip install pandas numpy
pip install packaging
- name: Install other dependencies
run: |
pip install seaborn matplotlib scipy tabulate yfinance python-dateutil pytest
- name: Install quantstats in development mode
run: |
pip install -e .
- name: Print versions
run: |
python -c "import pandas as pd; import numpy as np; print(f'pandas: {pd.__version__}, numpy: {np.__version__}')"
- name: Run compatibility tests with latest versions
run: |
python test_fixes.py
- name: Run pytest compatibility tests
run: |
pytest tests/test_compatibility.py -v
test-python-313:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pandas numpy packaging
pip install seaborn matplotlib scipy tabulate yfinance python-dateutil pytest
- name: Install quantstats in development mode
run: |
pip install -e .
- name: Print versions
run: |
python -c "import pandas as pd; import numpy as np; print(f'pandas: {pd.__version__}, numpy: {np.__version__}')"
- name: Run compatibility tests with Python 3.13
run: |
python test_fixes.py
- name: Run pytest compatibility tests
run: |
pytest tests/test_compatibility.py -v