Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ __marimo__/
# Streamlit
.streamlit/secrets.toml



#######################################################################
# JUNKYARD
# Suspected no longer needed (@leehach 2026-01-23)
Expand All @@ -283,6 +285,7 @@ docsrc/_build/html/notebooks/
docsrc/_build/html/tutorial.html
docsrc/_static/auto/
docsrc/generated/esda.adbscan.ADBSCAN.rst
docs/source/generated/

tools/changelog.md
tools/changelog_2.0.0.md
Expand All @@ -298,4 +301,10 @@ tools/changelog_2.4.0.md
.pixi/*
!.pixi/config.toml

docs/source/generated/

#######################################################################
# Gaboardi addition [2026-05-10]
################################

# baseline image creation from `image_comparison` testing
result_images/
37 changes: 36 additions & 1 deletion esda/smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"Serge Rey <srey@asu.edu"
)

from functools import reduce
import warnings
from functools import reduce, wraps

import numpy as np
from libpysal.weights.distance import Kernel
Expand Down Expand Up @@ -48,6 +49,23 @@
]


def smoothing_removal_warning(obj):
@wraps(obj)
def wrapper(*args, **kwargs):
warnings.warn(
(
f"The '{__name__}' module is deprecated and '{obj.__name__}()' "
"will be removed in future release of esda."
),
FutureWarning,
stacklevel=1,
)
return obj(*args, **kwargs)

return wrapper


@smoothing_removal_warning
def flatten(l, unique=True): # noqa: E741 - Ambiguous variable name: `l`
"""flatten a list of lists

Expand Down Expand Up @@ -80,6 +98,7 @@ def flatten(l, unique=True): # noqa: E741 - Ambiguous variable name: `l`
return list(set(l))


@smoothing_removal_warning
def weighted_median(d, w):
"""A utility function to find a median of d based on w

Expand Down Expand Up @@ -128,6 +147,7 @@ def weighted_median(d, w):
return np.sort(d)[median_inx]


@smoothing_removal_warning
def sum_by_n(d, w, n):
"""A utility function to summarize a data array into n values
after weighting the array with another weight array w
Expand Down Expand Up @@ -173,6 +193,7 @@ def sum_by_n(d, w, n):
return np.array([sum(d[i : i + h]) for i in range(0, t, h)])


@smoothing_removal_warning
def crude_age_standardization(e, b, n):
"""A utility function to compute rate through crude age standardization

Expand Down Expand Up @@ -225,6 +246,7 @@ def crude_age_standardization(e, b, n):
return sum_by_n(r, age_weight, n)


@smoothing_removal_warning
def direct_age_standardization(e, b, s, n, alpha=0.05):
"""A utility function to compute rate through direct age standardization

Expand Down Expand Up @@ -310,6 +332,7 @@ def direct_age_standardization(e, b, s, n, alpha=0.05):
return res


@smoothing_removal_warning
def indirect_age_standardization(e, b, s_e, s_b, n, alpha=0.05):
"""A utility function to compute rate through indirect age standardization

Expand Down Expand Up @@ -393,6 +416,7 @@ def indirect_age_standardization(e, b, s_e, s_b, n, alpha=0.05):
return res


@smoothing_removal_warning
def standardized_mortality_ratio(e, b, s_e, s_b, n):
"""A utility function to compute standardized mortality ratio (SMR).

Expand Down Expand Up @@ -462,6 +486,7 @@ def standardized_mortality_ratio(e, b, s_e, s_b, n):
return smr


@smoothing_removal_warning
def choynowski(e, b, n, threshold=None):
"""Choynowski map probabilities [Choynowski1959]_ .

Expand Down Expand Up @@ -526,6 +551,7 @@ def choynowski(e, b, n, threshold=None):
return np.array(p)


@smoothing_removal_warning
def assuncao_rate(e, b):
"""The standardized rates where the mean and stadard deviation used for
the standardization are those of Empirical Bayes rate estimates
Expand Down Expand Up @@ -577,6 +603,7 @@ def assuncao_rate(e, b):
return (y - ebi_b) / np.sqrt(ebi_v)


@smoothing_removal_warning
class Excess_Risk:
"""Excess Risk

Expand Down Expand Up @@ -632,6 +659,7 @@ def __init__(self, e, b):
self.r = e * 1.0 / (b * r_mean)


@smoothing_removal_warning
class Empirical_Bayes:
"""Aspatial Empirical Bayes Smoothing

Expand Down Expand Up @@ -695,6 +723,7 @@ def __init__(self, e, b):
self.r = weight * rate + (1.0 - weight) * r_mean


@smoothing_removal_warning
class Spatial_Empirical_Bayes:
"""Spatial Empirical Bayes Smoothing

Expand Down Expand Up @@ -782,6 +811,7 @@ def __init__(self, e, b, w):
self.r = r_mean + (rate - r_mean) * (r_var / (r_var + (r_mean / b)))


@smoothing_removal_warning
class Spatial_Rate:
"""Spatial Rate Smoothing

Expand Down Expand Up @@ -856,6 +886,7 @@ def __init__(self, e, b, w):
w.transform = "o"


@smoothing_removal_warning
class Kernel_Smoother:
"""Kernal smoothing

Expand Down Expand Up @@ -925,6 +956,7 @@ def __init__(self, e, b, w):
self.r = w_e / w_b


@smoothing_removal_warning
class Age_Adjusted_Smoother:
"""Age-adjusted rate smoothing

Expand Down Expand Up @@ -1008,6 +1040,7 @@ def __init__(self, e, b, w, s, alpha=0.05):
w.transform = "o"


@smoothing_removal_warning
class Disk_Smoother:
"""Locally weighted averages or disk smoothing

Expand Down Expand Up @@ -1083,6 +1116,7 @@ def __init__(self, e, b, w):
self.r = slag(w, r) / np.array(weight_sum).reshape(-1, 1)


@smoothing_removal_warning
class Spatial_Median_Rate:
"""Spatial Median Rate Smoothing

Expand Down Expand Up @@ -1209,6 +1243,7 @@ def __search_median(self):
self.r = np.asarray(new_r).reshape(r.shape)


@smoothing_removal_warning
class Spatial_Filtering:
"""Spatial Filtering

Expand Down
21 changes: 21 additions & 0 deletions esda/tabular.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# from ...common import requires as _requires

import itertools as _it
import warnings
from functools import wraps

from libpysal.weights import W


def tabular_removal_warning(obj):
@wraps(obj)
def wrapper(*args, **kwargs):
warnings.warn(
(
f"The '{__name__}' module is deprecated and '{obj.__name__}()' "
"will be removed in future release of esda "
"coinciding with the complete removal of the '.by_cols()' methods."
),
FutureWarning,
stacklevel=1,
)
return obj(*args, **kwargs)

return wrapper


# I would like to define it like this, so that you could make a call like:
# Geary(df, 'HOVAL', 'INC', w=W), but this only works in Python3. So, I have to
# use a workaround
# def _statistic(df, *cols, stat=None, w=None, inplace=True,
@tabular_removal_warning
def _univariate_handler(
df,
cols,
Expand Down Expand Up @@ -122,6 +142,7 @@ def column_stat(column):
]


@tabular_removal_warning
def _bivariate_handler(
df, x, y=None, w=None, inplace=True, pvalue="sim", outvals=None, **kwargs
):
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,7 @@ filterwarnings = [
"ignore:divide by zero encountered",
"ignore:invalid value encountered",
"ignore:Numba not imported, so alpha shape construction may be slower",
"ignore:The 'esda.smoothing' module is deprecated", # TODO: -- ** remove this filter once `smoothing.py` is removed **
"ignore:The 'esda.tabular' module is deprecated", # TODO: -- ** remove this filter once `tabular.py` is removed **

]
Loading