Skip to content

Commit

Permalink
chore: Drop support for python 3.9 and add support for 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
JabobKrauskopf committed Jan 15, 2025
1 parent 816ee6f commit 4950f90
Show file tree
Hide file tree
Showing 25 changed files with 58 additions and 157 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.10"
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.10"
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<a href="https://black.readthedocs.io/en/stable/">
<img alt="Code Style" src="https://img.shields.io/badge/code_style-black-black.svg">
</a>
<img alt="Python Versions" src="https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue">
<img alt="Python Versions" src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue">
<a href="https://github.com/limebit/medmodels/blob/main/LICENSE">
<img alt="MedModels License" src="https://img.shields.io/github/license/limebit/medmodels.svg">
</a>
Expand Down
2 changes: 1 addition & 1 deletion docs/developer_guide/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MedModels leverages a combination of Python and Rust code. To contribute effecti

**Requirements:**

- Python (3.9, 3.10, 3.11 or 3.12)
- Python (3.10, 3.11, 3.12 or 3.13)
- Rust compiler (follow instructions from [https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install))

**Using the Makefile:**
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ API Reference

```{only} html
[![black](https://img.shields.io/badge/code_style-black-black.svg)](https://black.readthedocs.io/en/stable/)
![python versions](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)
![python versions](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)
[![license](https://img.shields.io/github/license/limebit/medmodels.svg)](https://github.com/limebit/medmodels/blob/main/LICENSE)
[![license](https://github.com/limebit/medmodels/actions/workflows/testing.yml/badge.svg?branch=main)](https://github.com/limebit/medmodels/actions/workflows/testing.yml)
```
Expand Down
8 changes: 1 addition & 7 deletions medmodels/_medmodels.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
from enum import Enum
from typing import Callable, Dict, List, Optional, Sequence, Union
from typing import Callable, Dict, List, Optional, Sequence, TypeAlias, Union

from medmodels.medrecord.types import (
Attributes,
Expand All @@ -19,11 +18,6 @@ from medmodels.medrecord.types import (
PolarsNodeDataFrameInput,
)

if sys.version_info >= (3, 10):
from typing import TypeAlias
else:
from typing_extensions import TypeAlias

PyDataType: TypeAlias = Union[
PyString,
PyInt,
Expand Down
15 changes: 7 additions & 8 deletions medmodels/medrecord/_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

import copy
from datetime import datetime
from typing import TYPE_CHECKING, Dict, List, Literal, Optional, Union
from typing import TYPE_CHECKING, Dict, List, Literal, Optional, TypeAlias, Union

import polars as pl

from medmodels.medrecord.schema import AttributesSchema, AttributeType
from medmodels.medrecord.types import Attributes, EdgeIndex, NodeIndex
from medmodels.medrecord.types import (
Attributes,
EdgeIndex,
NodeIndex,
)

if TYPE_CHECKING:
import sys
from typing import TypeAlias

from medmodels.medrecord.types import (
AttributeInfo,
Expand All @@ -23,11 +27,6 @@
TemporalAttributeInfo,
)

if sys.version_info >= (3, 10):
from typing import TypeAlias
else:
from typing_extensions import TypeAlias

AttributeDictionary: TypeAlias = Union[
Dict[EdgeIndex, Attributes], Dict[NodeIndex, Attributes]
]
Expand Down
10 changes: 5 additions & 5 deletions medmodels/medrecord/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union

if TYPE_CHECKING:
from typing_extensions import TypeIs

from medmodels.medrecord.schema import Schema

import medmodels as mm
from medmodels.medrecord.types import (
EdgeTuple,
Expand All @@ -34,6 +29,11 @@
is_polars_node_dataframe_input_list,
)

if TYPE_CHECKING:
from typing_extensions import TypeIs

from medmodels.medrecord.schema import Schema

NodeInputBuilder = Union[
NodeTuple,
List[NodeTuple],
Expand Down
9 changes: 1 addition & 8 deletions medmodels/medrecord/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import typing
from abc import ABC, abstractmethod
from typing import TypeAlias

from medmodels._medmodels import (
PyAny,
Expand All @@ -18,14 +19,6 @@
PyUnion,
)

if typing.TYPE_CHECKING:
import sys

if sys.version_info >= (3, 10):
from typing import TypeAlias
else:
from typing_extensions import TypeAlias

PyDataType: TypeAlias = typing.Union[
PyString,
PyInt,
Expand Down
10 changes: 1 addition & 9 deletions medmodels/medrecord/querying.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from enum import Enum
from typing import TYPE_CHECKING, Callable, List, Union
from typing import Callable, List, TypeAlias, Union

from medmodels._medmodels import (
PyAttributesTreeOperand,
Expand All @@ -27,14 +27,6 @@
NodeIndex,
)

if TYPE_CHECKING:
import sys

if sys.version_info >= (3, 10):
from typing import TypeAlias
else:
from typing_extensions import TypeAlias

NodeQuery: TypeAlias = Callable[["NodeOperand"], None]
EdgeQuery: TypeAlias = Callable[["EdgeOperand"], None]

Expand Down
13 changes: 2 additions & 11 deletions medmodels/medrecord/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,20 @@

from datetime import datetime, timedelta
from typing import (
TYPE_CHECKING,
Dict,
List,
Literal,
Mapping,
Sequence,
Tuple,
TypeAlias,
TypedDict,
Union,
)

import pandas as pd
import polars as pl

if TYPE_CHECKING:
import sys

if sys.version_info >= (3, 10):
from typing import TypeAlias

from typing_extensions import TypeIs
else:
from typing_extensions import TypeAlias, TypeIs
from typing_extensions import TypeIs

#: A type alias for attributes of a medical record.
MedRecordAttribute: TypeAlias = Union[str, int]
Expand Down
13 changes: 4 additions & 9 deletions medmodels/treatment_effect/continuous_estimators.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
"""Functions to estimate the treatment effect for continuous outcomes."""

from __future__ import annotations

import logging
from math import sqrt
from typing import TYPE_CHECKING, Literal, Optional, Set
from typing import Literal, Optional, Set

import numpy as np

from medmodels.medrecord.medrecord import MedRecord
from medmodels.medrecord.querying import EdgeOperand
from medmodels.medrecord.types import Group, MedRecordAttribute, NodeIndex
from medmodels.treatment_effect.temporal_analysis import find_reference_edge

if TYPE_CHECKING:
from medmodels.medrecord.medrecord import MedRecord
from medmodels.medrecord.querying import EdgeOperand
from medmodels.medrecord.types import Group, MedRecordAttribute, NodeIndex


logger = logging.getLogger(__name__)


Expand Down
8 changes: 3 additions & 5 deletions medmodels/treatment_effect/estimate.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
"""Estimators class for calculating treatment effect metrics."""

from __future__ import annotations

from typing import TYPE_CHECKING, Literal, Set, Tuple, TypedDict

from medmodels.medrecord.medrecord import MedRecord
from medmodels.medrecord.types import MedRecordAttribute, NodeIndex
from medmodels.treatment_effect.continuous_estimators import (
average_treatment_effect,
cohens_d,
hedges_g,
)
from medmodels.treatment_effect.matching.neighbors import NeighborsMatching
from medmodels.treatment_effect.matching.propensity import PropensityMatching
from medmodels.treatment_effect.treatment_effect import TreatmentEffect

if TYPE_CHECKING:
from medmodels.medrecord.medrecord import MedRecord
from medmodels.medrecord.types import MedRecordAttribute, NodeIndex
from medmodels.treatment_effect.matching.matching import Matching
from medmodels.treatment_effect.treatment_effect import TreatmentEffect


class SubjectIndices(TypedDict):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
"""Models for matching treated and control units based on distance metrics."""

from __future__ import annotations

from typing import TYPE_CHECKING, Optional, Tuple
from typing import Optional, Tuple

import numpy as np
import polars as pl
from numpy.typing import NDArray
from scipy.optimize import linear_sum_assignment

if TYPE_CHECKING:
from numpy.typing import NDArray

from medmodels.medrecord.types import MedRecordAttributeInputList
from medmodels.medrecord.types import MedRecordAttributeInputList


def nearest_neighbor(
Expand Down
19 changes: 3 additions & 16 deletions medmodels/treatment_effect/matching/algorithms/propensity_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,20 @@
two groups are comparable.
"""

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Dict, Literal, Optional, Tuple, Union
from typing import Any, Dict, Literal, Optional, Tuple, TypeAlias, Union

import numpy as np
import polars as pl
from numpy.typing import NDArray
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier

from medmodels.medrecord.types import MedRecordAttributeInputList
from medmodels.treatment_effect.matching.algorithms.classic_distance_models import (
nearest_neighbor,
)

if TYPE_CHECKING:
import sys

from numpy.typing import NDArray

from medmodels.medrecord.types import MedRecordAttributeInputList

if sys.version_info >= (3, 10):
from typing import TypeAlias
else:
from typing_extensions import TypeAlias


Model: TypeAlias = Literal["logit", "dec_tree", "forest"]


Expand Down
16 changes: 3 additions & 13 deletions medmodels/treatment_effect/matching/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,13 @@
score matching and nearest neighbor matching.
"""

from __future__ import annotations

from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Literal, Optional, Set, Tuple
from typing import Literal, Optional, Set, Tuple, TypeAlias

import polars as pl

if TYPE_CHECKING:
import sys

from medmodels.medrecord.medrecord import MedRecord
from medmodels.medrecord.types import MedRecordAttributeInputList, NodeIndex

if sys.version_info >= (3, 10):
from typing import TypeAlias
else:
from typing_extensions import TypeAlias
from medmodels.medrecord.medrecord import MedRecord
from medmodels.medrecord.types import MedRecordAttributeInputList, NodeIndex

MatchingMethod: TypeAlias = Literal["propensity", "nearest_neighbors"]

Expand Down
10 changes: 3 additions & 7 deletions medmodels/treatment_effect/matching/neighbors.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
"""Module for the nearest neighbor matching."""

from __future__ import annotations

from typing import TYPE_CHECKING, Optional, Set
from typing import Optional, Set

from medmodels import MedRecord
from medmodels.medrecord.types import MedRecordAttributeInputList, NodeIndex
from medmodels.treatment_effect.matching.algorithms.classic_distance_models import (
nearest_neighbor,
)
from medmodels.treatment_effect.matching.matching import Matching

if TYPE_CHECKING:
from medmodels import MedRecord
from medmodels.medrecord.types import MedRecordAttributeInputList, NodeIndex


class NeighborsMatching(Matching):
"""Class for the nearest neighbor matching.
Expand Down
Loading

0 comments on commit 4950f90

Please sign in to comment.