14
14
15
15
"""Module for defining coreset data structures."""
16
16
17
- import warnings
18
17
from abc import abstractmethod
19
18
from typing import (
20
19
TYPE_CHECKING ,
28
27
import equinox as eqx
29
28
import jax .numpy as jnp
30
29
from jaxtyping import Array , Shaped
31
- from typing_extensions import Self , deprecated , override
30
+ from typing_extensions import Self , override
32
31
33
32
from coreax .data import Data , SupervisedData , as_data
34
33
from coreax .metrics import Metric
@@ -68,16 +67,6 @@ def points(self) -> _TPointsData_co:
68
67
def pre_coreset_data (self ) -> _TOriginalData_co :
69
68
"""The original data that this coreset is based on."""
70
69
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
-
81
70
@abstractmethod
82
71
def solve_weights (self , solver : WeightsOptimiser [Data ], ** solver_kwargs ) -> Self :
83
72
"""Return a copy of 'self' with weights solved by 'solver'."""
@@ -100,16 +89,6 @@ def __check_init__(self) -> None:
100
89
"by definition of a Coreset"
101
90
)
102
91
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
-
113
92
114
93
class PseudoCoreset (
115
94
AbstractCoreset [Data , _TOriginalData_co ], Generic [_TOriginalData_co ]
@@ -135,41 +114,15 @@ class PseudoCoreset(
135
114
136
115
def __init__ (self , nodes : Data , pre_coreset_data : _TOriginalData_co ) -> None :
137
116
"""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
-
168
117
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
+ )
170
122
if not isinstance (pre_coreset_data , Data ):
171
123
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."
173
126
)
174
127
175
128
self ._nodes = nodes
@@ -238,40 +191,20 @@ def points(self) -> Data:
238
191
def pre_coreset_data (self ):
239
192
return self ._pre_coreset_data
240
193
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
-
252
194
@override
253
195
def solve_weights (self , solver : WeightsOptimiser [Data ], ** solver_kwargs ) -> Self :
254
196
"""Return a copy of 'self' with weights solved by 'solver'."""
255
197
weights = solver .solve (self .pre_coreset_data , self .points , ** solver_kwargs )
256
198
return eqx .tree_at (lambda x : x .points .weights , self , weights )
257
199
258
200
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
-
268
201
class Coresubset (
269
202
AbstractCoreset [_TOriginalData_co , _TOriginalData_co ], Generic [_TOriginalData_co ]
270
203
):
271
204
r"""
272
205
Data structure for representing a coresubset.
273
206
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
275
208
data points/nodes must be a subset of the original data points/nodes, such that
276
209
277
210
.. math::
@@ -302,42 +235,16 @@ class Coresubset(
302
235
# pylint: enable=invalid-name
303
236
304
237
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."""
336
239
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
+ )
338
244
if not isinstance (pre_coreset_data , Data ):
339
245
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."
341
248
)
342
249
343
250
self ._indices = indices
@@ -416,17 +323,6 @@ def indices(self) -> Data:
416
323
"""The (possibly weighted) Coresubset indices."""
417
324
return self ._indices
418
325
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
-
430
326
@override
431
327
def solve_weights (self , solver : WeightsOptimiser [Data ], ** solver_kwargs ) -> Self :
432
328
"""Return a copy of 'self' with weights solved by 'solver'."""
0 commit comments