@@ -262,29 +262,25 @@ def ConstantData(
262
262
* ,
263
263
dims : Optional [Sequence [str ]] = None ,
264
264
coords : Optional [dict [str , Union [Sequence , np .ndarray ]]] = None ,
265
- export_index_as_coords = False ,
266
265
infer_dims_and_coords = False ,
267
266
** kwargs ,
268
267
) -> TensorConstant :
269
- """Alias for ``pm.Data(..., mutable=False) ``.
268
+ """Alias for ``pm.Data``.
270
269
271
270
Registers the ``value`` as a :class:`~pytensor.tensor.TensorConstant` with the model.
272
271
For more information, please reference :class:`pymc.Data`.
273
272
"""
274
- if export_index_as_coords :
275
- infer_dims_and_coords = export_index_as_coords
276
- warnings .warn (
277
- "Deprecation warning: 'export_index_as_coords; is deprecated and will be removed in future versions. Please use 'infer_dims_and_coords' instead." ,
278
- DeprecationWarning ,
279
- )
273
+ warnings .warn (
274
+ "ConstantData is deprecated. All Data variables are now mutable. Use Data instead." ,
275
+ FutureWarning ,
276
+ )
280
277
281
278
var = Data (
282
279
name ,
283
280
value ,
284
281
dims = dims ,
285
282
coords = coords ,
286
283
infer_dims_and_coords = infer_dims_and_coords ,
287
- mutable = False ,
288
284
** kwargs ,
289
285
)
290
286
return cast (TensorConstant , var )
@@ -296,29 +292,25 @@ def MutableData(
296
292
* ,
297
293
dims : Optional [Sequence [str ]] = None ,
298
294
coords : Optional [dict [str , Union [Sequence , np .ndarray ]]] = None ,
299
- export_index_as_coords = False ,
300
295
infer_dims_and_coords = False ,
301
296
** kwargs ,
302
297
) -> SharedVariable :
303
- """Alias for ``pm.Data(..., mutable=True) ``.
298
+ """Alias for ``pm.Data``.
304
299
305
300
Registers the ``value`` as a :class:`~pytensor.compile.sharedvalue.SharedVariable`
306
301
with the model. For more information, please reference :class:`pymc.Data`.
307
302
"""
308
- if export_index_as_coords :
309
- infer_dims_and_coords = export_index_as_coords
310
- warnings .warn (
311
- "Deprecation warning: 'export_index_as_coords; is deprecated and will be removed in future versions. Please use 'infer_dims_and_coords' instead." ,
312
- DeprecationWarning ,
313
- )
303
+ warnings .warn (
304
+ "MutableData is deprecated. All Data variables are now mutable. Use Data instead." ,
305
+ FutureWarning ,
306
+ )
314
307
315
308
var = Data (
316
309
name ,
317
310
value ,
318
311
dims = dims ,
319
312
coords = coords ,
320
313
infer_dims_and_coords = infer_dims_and_coords ,
321
- mutable = True ,
322
314
** kwargs ,
323
315
)
324
316
return cast (SharedVariable , var )
@@ -330,7 +322,6 @@ def Data(
330
322
* ,
331
323
dims : Optional [Sequence [str ]] = None ,
332
324
coords : Optional [dict [str , Union [Sequence , np .ndarray ]]] = None ,
333
- export_index_as_coords = False ,
334
325
infer_dims_and_coords = False ,
335
326
mutable : Optional [bool ] = None ,
336
327
** kwargs ,
@@ -373,15 +364,6 @@ def Data(
373
364
infer_dims_and_coords : bool, default=False
374
365
If True, the ``Data`` container will try to infer what the coordinates
375
366
and dimension names should be if there is an index in ``value``.
376
- mutable : bool, optional
377
- Switches between creating a :class:`~pytensor.compile.sharedvalue.SharedVariable`
378
- (``mutable=True``) vs. creating a :class:`~pytensor.tensor.TensorConstant`
379
- (``mutable=False``).
380
- Consider using :class:`pymc.ConstantData` or :class:`pymc.MutableData` as less
381
- verbose alternatives to ``pm.Data(..., mutable=...)``.
382
- If this parameter is not specified, the value it takes will depend on the
383
- version of the package. Since ``v4.1.0`` the default value is
384
- ``mutable=False``, with previous versions having ``mutable=True``.
385
367
**kwargs : dict, optional
386
368
Extra arguments passed to :func:`pytensor.shared`.
387
369
@@ -394,7 +376,7 @@ def Data(
394
376
>>> observed_data = [mu + np.random.randn(20) for mu in true_mu]
395
377
396
378
>>> with pm.Model() as model:
397
- ... data = pm.MutableData ('data', observed_data[0])
379
+ ... data = pm.Data ('data', observed_data[0])
398
380
... mu = pm.Normal('mu', 0, 10)
399
381
... pm.Normal('y', mu=mu, sigma=1, observed=data)
400
382
@@ -430,19 +412,12 @@ def Data(
430
412
"Pass them directly to `observed` if you want to trigger auto-imputation"
431
413
)
432
414
433
- if mutable is None :
415
+ if mutable is not None :
434
416
warnings .warn (
435
- "The `mutable` kwarg was not specified. Before v4.1.0 it defaulted to `pm.Data(mutable=True)`,"
436
- " which is equivalent to using `pm.MutableData()`."
437
- " In v4.1.0 the default changed to `pm.Data(mutable=False)`, equivalent to `pm.ConstantData`."
438
- " Use `pm.ConstantData`/`pm.MutableData` or pass `pm.Data(..., mutable=False/True)` to avoid this warning." ,
439
- UserWarning ,
417
+ "Data is now always mutable. Specifying the `mutable` kwarg will raise an error in a future release" ,
418
+ FutureWarning ,
440
419
)
441
- mutable = False
442
- if mutable :
443
- x = pytensor .shared (arr , name , ** kwargs )
444
- else :
445
- x = pt .as_tensor_variable (arr , name , ** kwargs )
420
+ x = pytensor .shared (arr , name , ** kwargs )
446
421
447
422
if isinstance (dims , str ):
448
423
dims = (dims ,)
@@ -453,24 +428,11 @@ def Data(
453
428
expected = x .ndim ,
454
429
)
455
430
456
- # Optionally infer coords and dims from the input value.
457
- if export_index_as_coords :
458
- infer_dims_and_coords = export_index_as_coords
459
- warnings .warn (
460
- "Deprecation warning: 'export_index_as_coords; is deprecated and will be removed in future versions. Please use 'infer_dims_and_coords' instead." ,
461
- DeprecationWarning ,
462
- )
463
-
464
431
if infer_dims_and_coords :
465
432
coords , dims = determine_coords (model , value , dims )
466
433
467
434
if dims :
468
- if not mutable :
469
- # Use the dimension lengths from the before it was tensorified.
470
- # These can still be tensors, but in many cases they are numeric.
471
- xshape = np .shape (arr )
472
- else :
473
- xshape = x .shape
435
+ xshape = x .shape
474
436
# Register new dimension lengths
475
437
for d , dname in enumerate (dims ):
476
438
if dname not in model .dim_lengths :
@@ -479,7 +441,6 @@ def Data(
479
441
# Note: Coordinate values can't be taken from
480
442
# the value, because it could be N-dimensional.
481
443
values = coords .get (dname , None ),
482
- mutable = mutable ,
483
444
length = xshape [d ],
484
445
)
485
446
0 commit comments