1414
1515"""Module for defining coreset data structures."""
1616
17- import warnings
1817from abc import abstractmethod
1918from typing import (
2019 TYPE_CHECKING ,
2827import equinox as eqx
2928import jax .numpy as jnp
3029from jaxtyping import Array , Shaped
31- from typing_extensions import Self , deprecated , override
30+ from typing_extensions import Self , override
3231
3332from coreax .data import Data , SupervisedData , as_data
3433from coreax .metrics import Metric
@@ -68,16 +67,6 @@ def points(self) -> _TPointsData_co:
6867 def pre_coreset_data (self ) -> _TOriginalData_co :
6968 """The original data that this coreset is based on."""
7069
71- @property
72- @abstractmethod
73- @deprecated (
74- "Narrow to a subclass, then use `.indices` or `.points` instead. "
75- + "Deprecated since v0.4.0. "
76- + "Will be removed in v0.5.0."
77- )
78- def nodes (self ) -> Data :
79- """Deprecated alias for `indices` or `points`, depending on subclass."""
80-
8170 @abstractmethod
8271 def solve_weights (self , solver : WeightsOptimiser [Data ], ** solver_kwargs ) -> Self :
8372 """Return a copy of 'self' with weights solved by 'solver'."""
@@ -100,16 +89,6 @@ def __check_init__(self) -> None:
10089 "by definition of a Coreset"
10190 )
10291
103- @property
104- @deprecated (
105- "Use `.points` instead. "
106- + "Deprecated since v0.4.0. "
107- + "Will be removed in v0.5.0."
108- )
109- def coreset (self ) -> _TPointsData_co :
110- """Deprecated alias for `.points`."""
111- return self .points
112-
11392
11493class PseudoCoreset (
11594 AbstractCoreset [Data , _TOriginalData_co ], Generic [_TOriginalData_co ]
@@ -135,41 +114,15 @@ class PseudoCoreset(
135114
136115 def __init__ (self , nodes : Data , pre_coreset_data : _TOriginalData_co ) -> None :
137116 """Initialise self."""
138- if isinstance (nodes , Array ):
139- warnings .warn (
140- "Passing Arrays into PseudoCoreset() is deprecated since v0.4.0. "
141- "Use PseudoCoreset.build() instead. "
142- "In v0.5.0, this will become a TypeError." ,
143- DeprecationWarning ,
144- stacklevel = 2 ,
145- )
146- nodes = as_data (nodes ) # pyright: ignore[reportAssignmentType]
147- if isinstance (pre_coreset_data , Array ):
148- warnings .warn (
149- "Passing Arrays into PseudoCoreset() is deprecated since v0.4.0. "
150- "Use PseudoCoreset.build() instead. "
151- "In v0.5.0, this will become a TypeError." ,
152- DeprecationWarning ,
153- stacklevel = 2 ,
154- )
155- # pylint: disable-next=line-too-long
156- pre_coreset_data = as_data (pre_coreset_data ) # pyright: ignore[reportAssignmentType]
157- if isinstance (pre_coreset_data , tuple ):
158- warnings .warn (
159- "Passing Arrays into PseudoCoreset() is deprecated since v0.4.0. "
160- "Use PseudoCoreset.build() instead. "
161- "In v0.5.0, this will become a TypeError." ,
162- DeprecationWarning ,
163- stacklevel = 2 ,
164- )
165- # pylint: disable-next=line-too-long
166- pre_coreset_data = SupervisedData (* pre_coreset_data ) # pyright: ignore[reportAssignmentType]
167-
168117 if not isinstance (nodes , Data ):
169- raise TypeError ("`nodes` must be of type `Data`" )
118+ raise TypeError (
119+ "`nodes` must be of type `Data`. "
120+ "To use an array, use PseudoCoreset.build() instead."
121+ )
170122 if not isinstance (pre_coreset_data , Data ):
171123 raise TypeError (
172- "`pre_coreset_data` must be of type `Data` or `SupervisedData`"
124+ "`pre_coreset_data` must be of type `Data` or `SupervisedData`. "
125+ "To use an array or tuple of arrays, use PseudoCoreset.build() instead."
173126 )
174127
175128 self ._nodes = nodes
@@ -238,40 +191,20 @@ def points(self) -> Data:
238191 def pre_coreset_data (self ):
239192 return self ._pre_coreset_data
240193
241- @property
242- @override
243- @deprecated (
244- "Use `.points` instead. "
245- + "Deprecated since v0.4.0. "
246- + "Will be removed in v0.5.0."
247- )
248- def nodes (self ) -> Data :
249- """Deprecated alias for `points`."""
250- return self .points
251-
252194 @override
253195 def solve_weights (self , solver : WeightsOptimiser [Data ], ** solver_kwargs ) -> Self :
254196 """Return a copy of 'self' with weights solved by 'solver'."""
255197 weights = solver .solve (self .pre_coreset_data , self .points , ** solver_kwargs )
256198 return eqx .tree_at (lambda x : x .points .weights , self , weights )
257199
258200
259- @deprecated (
260- "Use AbstractCoreset, PseudoCoreset, or Coresubset instead. "
261- + "Deprecated since v0.4.0. "
262- + "Will be removed in v0.5.0."
263- )
264- class Coreset (PseudoCoreset ):
265- """Deprecated - split into AbstractCoreset and PseudoCoreset."""
266-
267-
268201class Coresubset (
269202 AbstractCoreset [_TOriginalData_co , _TOriginalData_co ], Generic [_TOriginalData_co ]
270203):
271204 r"""
272205 Data structure for representing a coresubset.
273206
274- A coresubset is a :class:`Coreset` , with the additional condition that the coreset
207+ A coresubset is a coreset , with the additional condition that the coreset
275208 data points/nodes must be a subset of the original data points/nodes, such that
276209
277210 .. math::
@@ -302,42 +235,16 @@ class Coresubset(
302235 # pylint: enable=invalid-name
303236
304237 def __init__ (self , indices : Data , pre_coreset_data : _TOriginalData_co ) -> None :
305- """Handle type conversion of ``indices`` and ``pre_coreset_data``."""
306- if isinstance (indices , Array ):
307- warnings .warn (
308- "Passing Arrays into Coresubset() is deprecated since v0.4.0. "
309- "Use Coresubset.build() instead. "
310- "In v0.5.0, this will become a TypeError." ,
311- DeprecationWarning ,
312- stacklevel = 2 ,
313- )
314- indices = as_data (indices ) # pyright: ignore[reportAssignmentType]
315- if isinstance (pre_coreset_data , Array ):
316- warnings .warn (
317- "Passing Arrays into Coresubset() is deprecated since v0.4.0. "
318- "Use Coresubset.build() instead. "
319- "In v0.5.0, this will become a TypeError." ,
320- DeprecationWarning ,
321- stacklevel = 2 ,
322- )
323- # pylint: disable-next=line-too-long
324- pre_coreset_data = as_data (pre_coreset_data ) # pyright: ignore[reportAssignmentType]
325- if isinstance (pre_coreset_data , tuple ):
326- warnings .warn (
327- "Passing Arrays into Coresubset() is deprecated since v0.4.0. "
328- "Use Coresubset.build() instead. "
329- "In v0.5.0, this will become a TypeError." ,
330- DeprecationWarning ,
331- stacklevel = 2 ,
332- )
333- # pylint: disable-next=line-too-long
334- pre_coreset_data = SupervisedData (* pre_coreset_data ) # pyright: ignore[reportAssignmentType]
335-
238+ """Initialise self."""
336239 if not isinstance (indices , Data ):
337- raise TypeError ("`indices` must be of type `Data`" )
240+ raise TypeError (
241+ "`indices` must be of type `Data`. "
242+ "To use an array, use PseudoCoreset.build() instead."
243+ )
338244 if not isinstance (pre_coreset_data , Data ):
339245 raise TypeError (
340- "`pre_coreset_data` must be of type `Data` or `SupervisedData`"
246+ "`pre_coreset_data` must be of type `Data` or `SupervisedData`. "
247+ "To use an array or tuple of arrays, use PseudoCoreset.build() instead."
341248 )
342249
343250 self ._indices = indices
@@ -416,17 +323,6 @@ def indices(self) -> Data:
416323 """The (possibly weighted) Coresubset indices."""
417324 return self ._indices
418325
419- @property
420- @override
421- @deprecated (
422- "Use `.indices` instead. "
423- + "Deprecated since v0.4.0. "
424- + "Will be removed in v0.5.0."
425- )
426- def nodes (self ) -> Data :
427- """Deprecated alias for `indices`."""
428- return self .indices
429-
430326 @override
431327 def solve_weights (self , solver : WeightsOptimiser [Data ], ** solver_kwargs ) -> Self :
432328 """Return a copy of 'self' with weights solved by 'solver'."""
0 commit comments