Skip to content

Commit

Permalink
feat: add version numbers for deprecations slated for next version
Browse files Browse the repository at this point in the history
  • Loading branch information
rg936672 committed Feb 7, 2025
1 parent 763bc25 commit cafa90f
Showing 1 changed file with 40 additions and 20 deletions.
60 changes: 40 additions & 20 deletions coreax/coreset.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def pre_coreset_data(self) -> _TOriginalData_co:

@property
@abstractmethod
@deprecated("Narrow to a subclass, then use `.indices` or `.points` instead.")
@deprecated(
"Narrow to a subclass, then use `.indices` or `.points` instead. "
+ "Deprecated since v0.4.0. "
+ "Will be removed in v1.0.0."
)
def nodes(self) -> Data:
"""Deprecated alias for `indices` or `points`, depending on subclass."""

Expand All @@ -98,7 +102,11 @@ def __check_init__(self) -> None:
)

@property
@deprecated("Use `.points` instead.")
@deprecated(
"Use `.points` instead."
+ "Deprecated since v0.4.0. "
+ "Will be removed in v1.0.0."
)
def coreset(self) -> _TPointsData_co:
"""Deprecated alias for `.points`."""
return self.points
Expand Down Expand Up @@ -130,28 +138,28 @@ def __init__(self, nodes: Data, pre_coreset_data: _TOriginalData_co) -> None:
"""Initialise self."""
if isinstance(nodes, Array):
warnings.warn(
"Passing Arrays into PseudoCoreset() is deprecated. "
"Passing Arrays into PseudoCoreset() is deprecated since v0.4.0. "
"Use PseudoCoreset.build() instead. "
"In future, this will become a TypeError.",
"in v1.0.0, this will become a TypeError.",
DeprecationWarning,
stacklevel=2,
)
nodes = as_data(nodes) # pyright: ignore[reportAssignmentType]
if isinstance(pre_coreset_data, Array):
warnings.warn(
"Passing Arrays into PseudoCoreset() is deprecated. "
"Passing Arrays into PseudoCoreset() is deprecated since v0.4.0. "
"Use PseudoCoreset.build() instead. "
"In future, this will become a TypeError.",
"in v1.0.0, this will become a TypeError.",
DeprecationWarning,
stacklevel=2,
)
# pylint: disable-next=line-too-long
pre_coreset_data = as_data(pre_coreset_data) # pyright: ignore[reportAssignmentType]
if isinstance(pre_coreset_data, tuple):
warnings.warn(
"Passing Arrays into PseudoCoreset() is deprecated. "
"Passing Arrays into PseudoCoreset() is deprecated since v0.4.0. "
"Use PseudoCoreset.build() instead. "
"In future, this will become a TypeError.",
"in v1.0.0, this will become a TypeError.",
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -233,7 +241,11 @@ def pre_coreset_data(self):

@property
@override
@deprecated("Use `.points` instead.")
@deprecated(
"Use `.points` instead."
+ "Deprecated since v0.4.0. "
+ "Will be removed in v1.0.0."
)
def nodes(self) -> Data:
"""Deprecated alias for `points`."""
return self.points
Expand All @@ -245,7 +257,11 @@ def solve_weights(self, solver: WeightsOptimiser[Data], **solver_kwargs) -> Self
return eqx.tree_at(lambda x: x.points.weights, self, weights)


@deprecated("Use AbstractCoreset, PseudoCoreset, or Coresubset instead.")
@deprecated(
"Use AbstractCoreset, PseudoCoreset, or Coresubset instead."
+ "Deprecated since v0.4.0. "
+ "Will be removed in v1.0.0."
)
class Coreset(PseudoCoreset):
"""Deprecated - split into AbstractCoreset and PseudoCoreset."""

Expand Down Expand Up @@ -290,28 +306,28 @@ def __init__(self, indices: Data, pre_coreset_data: _TOriginalData_co) -> None:
"""Handle type conversion of ``indices`` and ``pre_coreset_data``."""
if isinstance(indices, Array):
warnings.warn(
"Passing Arrays into PseudoCoreset() is deprecated. "
"Use PseudoCoreset.build() instead. "
"In future, this will become a TypeError.",
"Passing Arrays into Coresubset() is deprecated since v0.4.0. "
"Use Coresubset.build() instead. "
"in v1.0.0, this will become a TypeError.",
DeprecationWarning,
stacklevel=2,
)
indices = as_data(indices) # pyright: ignore[reportAssignmentType]
if isinstance(pre_coreset_data, Array):
warnings.warn(
"Passing Arrays into PseudoCoreset() is deprecated. "
"Use PseudoCoreset.build() instead. "
"In future, this will become a TypeError.",
"Passing Arrays into Coresubset() is deprecated since v0.4.0. "
"Use Coresubset.build() instead. "
"in v1.0.0, this will become a TypeError.",
DeprecationWarning,
stacklevel=2,
)
# pylint: disable-next=line-too-long
pre_coreset_data = as_data(pre_coreset_data) # pyright: ignore[reportAssignmentType]
if isinstance(pre_coreset_data, tuple):
warnings.warn(
"Passing Arrays into PseudoCoreset() is deprecated. "
"Use PseudoCoreset.build() instead. "
"In future, this will become a TypeError.",
"Passing Arrays into Coresubset() is deprecated since v0.4.0. "
"Use Coresubset.build() instead. "
"in v1.0.0, this will become a TypeError.",
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -409,7 +425,11 @@ def indices(self) -> Data:

@property
@override
@deprecated("Use `.indices` instead.")
@deprecated(
"Use `.indices` instead."
+ "Deprecated since v0.4.0. "
+ "Will be removed in v1.0.0."
)
def nodes(self) -> Data:
"""Deprecated alias for `indices`."""
return self.indices
Expand Down

0 comments on commit cafa90f

Please sign in to comment.