Skip to content

BUG: raising DeprecationWarning halts execution instead of warning in smoothing.py #428

@samay2504

Description

@samay2504

Description

In esda/smoothing.py, both Headbanging_Triples.__init__ and Headbanging_Median_Rate.__init__ use the statement:

raise DeprecationWarning("Deprecated")

In Python, raise throws an exception immediately, halting execution. A deprecation should emit a warning via the warnings module so that users can see the deprecation notice without their code breaking abruptly.

To Reproduce

import esda
from libpysal import examples, weights, io
import numpy as np

sids = io.open(examples.get_path('sids2.shp'), 'r')
sids_d = np.array([i.centroid for i in sids])
sids_w = weights.KNN(sids_d, k=5)

# This will raise an exception rather than warn
s_ht = esda.smoothing.Headbanging_Triples(sids_d, sids_w, k=5)

Expected behavior

It should print a DeprecationWarning to stderr but allow execution to continue smoothly using warnings.warn("Deprecated", DeprecationWarning, stacklevel=2).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions