Skip to content

Commit

Permalink
Add support for python 3.11 (#1496)
Browse files Browse the repository at this point in the history
* Add 311

* Update test according to sdmetrics release

* Update contextmanager for numpy>1.17

* Remove packaging
  • Loading branch information
fealho authored Aug 13, 2023
1 parent afadb34 commit 604d462
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Build
run: |
sudo apt-get install graphviz pandoc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10']
python-version: [ '3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v1
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/minimum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,14 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10']
python-version: [ '3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- if: matrix.os == 'windows-latest' && matrix.python-version != 3.10
name: Install dependencies - Windows
run: |
python -m pip install --upgrade pip
python -m pip install 'torch==1.8.0' -f https://download.pytorch.org/whl/cpu/torch/
python -m pip install 'torchvision==0.9.0' -f https://download.pytorch.org/whl/cpu/torchvision/
- if: matrix.os == 'windows-latest' && matrix.python-version == 3.10
name: Install dependencies - Windows
run: |
python -m pip install --upgrade pip
python -m pip install 'torch==1.11.0' -f https://download.pytorch.org/whl/cpu/torch/
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10']
python-version: [ '3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion sdv/multi_table/hma.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def _get_likelihoods(self, table_rows, parent_rows, table_name, foreign_key):
synthesizer = self._synthesizer(table_meta, **self._table_parameters[table_name])
synthesizer._set_parameters(parameters)
try:
with np.random.default_rng(np.random.get_state()[1]):
with np.random.Generator(np.random.get_state()[1]):
likelihoods[parent_id] = synthesizer._get_likelihood(table_rows)

except (AttributeError, np.linalg.LinAlgError):
Expand Down
14 changes: 8 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
"numpy>=1.20.0,<1.25.0;python_version<'3.10'",
"numpy>=1.23.3,<1.25.0;python_version>='3.10'",
"pandas>=1.1.3;python_version<'3.10'",
"pandas>=1.5.0;python_version>='3.10'",
"pandas>=1.3.4;python_version>='3.10' and python_version<'3.11'",
"pandas>=1.5.0;python_version>='3.11'",
'tqdm>=4.15,<5',
'copulas>=0.9.0,<0.10',
'ctgan>=0.7.2,<0.8',
'deepecho>=0.4.1,<0.5',
'rdt>=1.6.1.dev0',
'sdmetrics>=0.10.0,<0.11',
'ctgan>=0.7.4,<0.8',
'deepecho>=0.4.2,<0.5',
'rdt>=1.6.1,<2',
'sdmetrics>=0.11.0,<0.12',
'cloudpickle>=2.1.0,<3.0',
'boto3>=1.15.0,<2',
'botocore>=1.18,<2'
Expand Down Expand Up @@ -114,6 +115,7 @@
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
],
description='Generate synthetic data for single table, multi table and sequential data',
Expand All @@ -130,7 +132,7 @@
long_description_content_type='text/markdown',
name='sdv',
packages=find_packages(include=['sdv', 'sdv.*']),
python_requires='>=3.8,<3.11',
python_requires='>=3.8,<3.12',
setup_requires=setup_requires,
test_suite='tests',
tests_require=tests_require,
Expand Down
44 changes: 35 additions & 9 deletions tests/integration/evaluation/test_multi_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,49 @@

from sdv.evaluation.multi_table import evaluate_quality, run_diagnostic
from sdv.metadata.multi_table import MultiTableMetadata
from sdv.multi_table.hma import HMASynthesizer


def test_evaluation():
"""Test ``evaluate_quality`` and ``run_diagnostic``."""
# Setup
table = pd.DataFrame({'col': [1, 2, 3]})
data = {'table': table}
metadata = MultiTableMetadata()
metadata.detect_table_from_dataframe('table', table)
synthesizer = HMASynthesizer(metadata)
table = pd.DataFrame({'id': [0, 1, 2, 3], 'col': [1, 2, 3, 4]})
slightly_different_table = pd.DataFrame({'id': [0, 1, 2, 3], 'col': [1, 2, 3, 3.5]})
data = {
'table1': table,
'table2': table,
}
samples = {
'table1': table,
'table2': slightly_different_table,
}
metadata = MultiTableMetadata().load_from_dict({
'tables': {
'table1': {
'columns': {
'id': {'sdtype': 'id'},
'col': {'sdtype': 'numerical'},
},
},
'table2': {
'columns': {
'id': {'sdtype': 'id'},
'col': {'sdtype': 'numerical'},
},
}
},
'relationships': [
{
'parent_table_name': 'table1',
'parent_primary_key': 'id',
'child_table_name': 'table2',
'child_foreign_key': 'id'
}
]
})

# Run and Assert
synthesizer.fit(data)
samples = synthesizer.sample()
score = evaluate_quality(data, samples, metadata).get_score()
assert score == 0.6666666666666667
assert score == .9375

diagnostic = run_diagnostic(data, samples, metadata).get_results()
assert diagnostic == {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/constraints/test_tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MockClass:
transform_fn=dummy_transform,
reverse_transform_fn=dummy_reverse_transform
)
assert type(recreated_class) == MockClass
assert isinstance(recreated_class, MockClass)

def test__validate_inputs(self):
"""Test the ``CustomConstraint._validate_inputs`` method.
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38-lint, py3{8,9,10}-{readme,pytest,minimum}
envlist = py38-lint, py3{8,9,10,11}-{readme,pytest,minimum}

[testenv]
skipsdist = false
Expand Down

0 comments on commit 604d462

Please sign in to comment.