Skip to content

Commit b871ea3

Browse files
committed
Uptade to Python < 3.13
1 parent ee1e1dc commit b871ea3

File tree

12 files changed

+87
-60
lines changed

12 files changed

+87
-60
lines changed

clarite/cli/custom_types.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,15 @@ def get_dtypes(self):
7474
if self.df is None:
7575
return None
7676
dtypes = {
77-
variable_name: {"type": str(dtype)}
78-
if str(dtype) != "category"
79-
else {
80-
"type": str(dtype),
81-
"categories": list(dtype.categories.values.tolist()),
82-
"ordered": dtype.ordered,
83-
}
77+
variable_name: (
78+
{"type": str(dtype)}
79+
if str(dtype) != "category"
80+
else {
81+
"type": str(dtype),
82+
"categories": list(dtype.categories.values.tolist()),
83+
"ordered": dtype.ordered,
84+
}
85+
)
8486
for variable_name, dtype in self.df.dtypes.iteritems()
8587
}
8688
return dtypes

clarite/modules/analyze/regression/glm_regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def _run_categorical(
313313
formula_restricted,
314314
family,
315315
use_t,
316-
report_categorical_betas
316+
report_categorical_betas,
317317
# ) -> Dict:
318318
) -> Generator[dict, None, None]:
319319
# Regress both models

clarite/modules/analyze/regression/r_survey_regression.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,23 +276,23 @@ def run(self):
276276
# Cluster IDs
277277
if self.survey_design_spec.has_cluster:
278278
kwargs["ids"] = f"{self.survey_design_spec.cluster_name}"
279-
data[
280-
self.survey_design_spec.cluster_name
281-
] = self.survey_design_spec.cluster_values
279+
data[self.survey_design_spec.cluster_name] = (
280+
self.survey_design_spec.cluster_values
281+
)
282282
else:
283283
kwargs["ids"] = ro.NULL
284284
# Strata
285285
if self.survey_design_spec.has_strata:
286286
kwargs["strata"] = f"{self.survey_design_spec.strata_name}"
287-
data[
288-
self.survey_design_spec.strata_name
289-
] = self.survey_design_spec.strata_values
287+
data[self.survey_design_spec.strata_name] = (
288+
self.survey_design_spec.strata_values
289+
)
290290
# fpc
291291
if self.survey_design_spec.has_fpc:
292292
kwargs["fpc"] = f"{self.survey_design_spec.fpc_name}"
293-
data[
294-
self.survey_design_spec.fpc_name
295-
] = self.survey_design_spec.fpc_values_original
293+
data[self.survey_design_spec.fpc_name] = (
294+
self.survey_design_spec.fpc_values_original
295+
)
296296

297297
# Single cluster setting
298298
ro.r(

clarite/modules/analyze/utils.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,19 @@ def add_corrected_pvalues(
9595
).to_dict()
9696
# Expand results to duplicated rows
9797
data[bonf_name] = data[groupby].apply(
98-
lambda g: bonf_result.get(g, np.nan)
99-
if isinstance(g, str)
100-
else bonf_result.get(tuple(g.values), np.nan),
98+
lambda g: (
99+
bonf_result.get(g, np.nan)
100+
if isinstance(g, str)
101+
else bonf_result.get(tuple(g.values), np.nan)
102+
),
101103
axis=1,
102104
)
103105
data[fdr_name] = data[groupby].apply(
104-
lambda g: bonf_result.get(g, np.nan)
105-
if isinstance(g, str)
106-
else fdr_result.get(tuple(g.values), np.nan),
106+
lambda g: (
107+
bonf_result.get(g, np.nan)
108+
if isinstance(g, str)
109+
else fdr_result.get(tuple(g.values), np.nan)
110+
),
107111
axis=1,
108112
)
109113
# Sort

clarite/modules/modify.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def remove_outliers(
700700
# Remove outliers
701701
# Note: This could be faster by performing calculations on the entire dataset at once, but in practice this should
702702
# be used on more of a limited basis, reviewing changes in each variable.
703-
for col_name, process_col in columns.iteritems():
703+
for col_name, process_col in columns.items():
704704
if not process_col:
705705
continue
706706
if method == "iqr":
@@ -804,12 +804,14 @@ def merge_observations(top: pd.DataFrame, bottom: pd.DataFrame):
804804
# Exclude cases where either variable was an object originally
805805
combined = combined.astype(
806806
{
807-
col: "category"
808-
if (dt == "object")
809-
& (top.dtypes[col] != "object")
810-
& (bottom.dtypes[col] != "object")
811-
else dt
812-
for col, dt in combined.dtypes.iteritems()
807+
col: (
808+
"category"
809+
if (dt == "object")
810+
& (top.dtypes[col] != "object")
811+
& (bottom.dtypes[col] != "object")
812+
else dt
813+
)
814+
for col, dt in combined.dtypes.items()
813815
}
814816
)
815817

clarite/modules/survey/survey_design.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ def __init__(
112112
self.multi_weight: bool = (
113113
False # If True, weight_values is a dict of weight name : Series
114114
)
115-
self.weight_names: Optional[
116-
Dict[str, str]
117-
] = None # Dict of regression variable name : weight name
115+
self.weight_names: Optional[Dict[str, str]] = (
116+
None # Dict of regression variable name : weight name
117+
)
118118
self.weight_values: Optional[Union[pd.Series, Dict[str, pd.Series]]] = None
119119
# FPC
120120
self.has_fpc: bool = False

clarite/modules/survey/survey_model.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ def center_strata(data, single_cluster_setting, pop_mean):
155155
np.float64
156156
)
157157
mh = np.sqrt(nh / (nh - 1))
158-
mh[
159-
mh == np.inf
160-
] = 1 # Replace infinity with 1.0 (due to single cluster where nh==1)
158+
mh[mh == np.inf] = (
159+
1 # Replace infinity with 1.0 (due to single cluster where nh==1)
160+
)
161161
fh = np.sqrt(
162162
1 - self.design.fpc
163163
) # self.design.fpc has fpc value for each cluster (one row per cluster)
@@ -195,9 +195,9 @@ def _jackknife_vcov(self, X, y):
195195
np.float64
196196
)
197197
mh = np.sqrt((nh - 1) / nh)
198-
mh[
199-
mh == np.inf
200-
] = 1 # Replace infinity with 1.0 (due to single cluster where nh==1)
198+
mh[mh == np.inf] = (
199+
1 # Replace infinity with 1.0 (due to single cluster where nh==1)
200+
)
201201
fh = np.sqrt(1 - self.design.fpc)
202202
self.replicate_params *= mh[:, None] * fh[:, None]
203203

pyproject.toml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[tool.poetry]
22
name = "clarite"
3-
version = "2.3.6"
3+
version = "2.4.0"
44
description = "CLeaning to Analysis: Reproducibility-based Interface for Traits and Exposures"
5-
authors = ["Andre Rico <alr6366@psu.edu>"]
5+
authors = ["Andre Rico <[email protected].edu>"]
66
license = "BSD-3-Clause"
77
readme = "README.rst"
88
repository = "https://github.com/HallLab/clarite-python/"
@@ -16,43 +16,44 @@ classifiers=[
1616
]
1717

1818
[tool.poetry.dependencies]
19-
python = ">=3.8.0,<3.11.0"
19+
python = ">=3.10,<3.13"
2020
click = ">7"
21-
pandas = "^1.3"
21+
pandas = ">=1.3,<2.2"
2222
scipy = "^1.9"
2323
seaborn = ">0.9"
24-
statsmodels = "^0.13"
24+
statsmodels = "^0.14"
2525
matplotlib = "^3.4.2"
26-
numpy = "^1.24"
27-
rpy2 = "^3.4.5"
26+
numpy = ">=1.24,<2.0"
2827
tzlocal = "^2.1"
29-
sphinx = {version = "^3.2.1", optional = true}
3028
numpydoc = {version = "^1.1.0", optional = true}
31-
sphinx_rtd_theme = {version = "^0.5.0", optional = true}
32-
sphinx-copybutton = {version = "^0.3.0", optional = true}
3329
ipython = {version = "^7.18.1", optional = true}
34-
sphinx-click = {version = "^4", optional = true}
35-
importlib-metadata = "^5.2.0"
36-
pandas-genomics = "^0.12"
30+
pandas-genomics = "^1.0.0"
31+
rpy2 = "^3.6.0"
3732

38-
[tool.poetry.dev-dependencies]
33+
[tool.poetry.group.dev.dependencies]
34+
mypy = "^1.5.1"
35+
tox = "^4.26.0"
36+
pytest = "^7"
3937
codecov = "^2.1.11"
4038
coverage = "^5.5"
41-
flake8 = "^3.9.2"
42-
pytest = ">=4.6"
39+
flake8 = "^6"
4340
pytest-cov = "^2.12.1"
4441
pytest-xdist = "^2.3.0"
4542
black = ">=22"
43+
sphinx = {version = "^4.0.0", optional = true}
44+
sphinx-click = {version = "^4", optional = true}
45+
sphinx_rtd_theme = {version = "^0.5.0", optional = true}
46+
sphinx-copybutton = {version = "^0.3.0", optional = true}
4647

4748
[tool.poetry.extras]
4849
docs = ["sphinx", "numpydoc", "sphinx_rtd_theme", "sphinx-copybutton", "ipython", "sphinx-click"]
4950

5051
[tool.poetry.scripts]
5152
clarite-cli = 'clarite.cli:entry_point'
5253

53-
[tool.poetry.group.dev.dependencies]
54-
mypy = "^1.5.1"
55-
5654
[build-system]
57-
requires = ["poetry>=0.12"]
58-
build-backend = "poetry.masonry.api"
55+
requires = ["poetry-core>=1.0.0"]
56+
build-backend = "poetry.core.masonry.api"
57+
58+
[tool.tox]
59+
legacy_tox_ini = true
-12.2 KB
Loading
-8.73 KB
Loading

0 commit comments

Comments
 (0)