Skip to content

Commit 8b740f6

Browse files
Added pytest Future Warning in relavant tests
1 parent f3abb76 commit 8b740f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+666
-589
lines changed

pytensor/configdefaults.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import socket
77
import sys
88
import textwrap
9+
import warnings
910

1011
import numpy as np
1112
from setuptools._distutils.spawn import find_executable
@@ -1447,6 +1448,12 @@ def add_caching_dir_configvars():
14471448
else:
14481449
gcc_version_str = "GCC_NOT_FOUND"
14491450

1451+
if config.compute_test_value != "off":
1452+
warnings.warn(
1453+
"test_value machinery is deprecated and will stop working in the future.",
1454+
FutureWarning,
1455+
)
1456+
14501457
# TODO: The caching dir resolution is a procedural mess of helper functions, local variables
14511458
# and config definitions. And the result is also not particularly pretty..
14521459
add_caching_dir_configvars()

pytensor/graph/basic.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,12 @@ def __init__(
451451

452452
self.tag = ValidatingScratchpad("test_value", type.filter)
453453

454+
# if hasattr(self.tag, "test_value"):
455+
# warnings.warn(
456+
# "test_value machinery is deprecated and will stop working in the future.",
457+
# FutureWarning,
458+
# )
459+
454460
self.type = type
455461

456462
self._owner = owner
@@ -479,10 +485,7 @@ def get_test_value(self):
479485
if not hasattr(self.tag, "test_value"):
480486
detailed_err_msg = get_variable_trace_string(self)
481487
raise TestValueError(f"{self} has no test value {detailed_err_msg}")
482-
warnings.warn(
483-
"test_value machinery is deprecated and will stop working in the future.",
484-
FutureWarning,
485-
)
488+
486489
return self.tag.test_value
487490

488491
def __str__(self):

pytensor/graph/fg.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""A container for specifying and manipulating a graph with distinct inputs and outputs."""
22

33
import time
4-
import warnings
54
from collections import OrderedDict
65
from collections.abc import Iterable, Sequence
76
from typing import TYPE_CHECKING, Any, Literal, Union, cast
@@ -494,10 +493,6 @@ def replace(
494493
return
495494

496495
if config.compute_test_value != "off":
497-
warnings.warn(
498-
"test_value machinery is deprecated and will stop working in the future.",
499-
FutureWarning,
500-
)
501496
try:
502497
tval = pytensor.graph.op.get_test_value(var)
503498
new_tval = pytensor.graph.op.get_test_value(new_var)

pytensor/graph/op.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ def compute_test_value(node: Apply):
7070
"""
7171
# Gather the test values for each input of the node
7272

73-
warnings.warn(
74-
"compute_test_value is deprecated and will stop working in the future.",
75-
FutureWarning,
76-
)
77-
7873
storage_map = {}
7974
compute_map = {}
8075
for i, ins in enumerate(node.inputs):
@@ -307,10 +302,6 @@ def __call__(
307302
n.name = f"{name}_{i}"
308303

309304
if config.compute_test_value != "off":
310-
warnings.warn(
311-
"test_value machinery is deprecated and will stop working in the future.",
312-
FutureWarning,
313-
)
314305
compute_test_value(node)
315306

316307
if self.default_output is not None:
@@ -721,11 +712,6 @@ def get_test_values(*args: Variable) -> Any | list[Any]:
721712
if config.compute_test_value == "off":
722713
return []
723714

724-
warnings.warn(
725-
"test_value machinery is deprecated and will stop working in the future.",
726-
FutureWarning,
727-
)
728-
729715
rval = []
730716

731717
for i, arg in enumerate(args):

pytensor/graph/rewriting/basic.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -983,10 +983,6 @@ def transform(self, fgraph, node, *args, **kwargs):
983983
if isinstance(input, pytensor.compile.SharedVariable):
984984
pass
985985
elif hasattr(input.tag, "test_value"):
986-
warnings.warn(
987-
"compute_test_value is deprecated and will stop working in the future.",
988-
FutureWarning,
989-
)
990986
givens[input] = pytensor.shared(
991987
input.type.filter(input.tag.test_value),
992988
input.name,

pytensor/graph/utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import linecache
22
import sys
33
import traceback
4+
import warnings
45
from abc import ABCMeta
56
from collections.abc import Sequence
67
from io import StringIO
@@ -283,9 +284,19 @@ def info(self):
283284

284285
# These two methods have been added to help Mypy
285286
def __getattribute__(self, name):
287+
if name == "test_value":
288+
warnings.warn(
289+
"test_value machinery is deprecated and will stop working in the future.",
290+
FutureWarning,
291+
)
286292
return super().__getattribute__(name)
287293

288294
def __setattr__(self, name: str, value: Any) -> None:
295+
if name == "test_value":
296+
warnings.warn(
297+
"test_value machinery is deprecated and will stop working in the future.",
298+
FutureWarning,
299+
)
289300
self.__dict__[name] = value
290301

291302

@@ -300,6 +311,11 @@ def __init__(self, attr, attr_filter):
300311

301312
def __setattr__(self, attr, obj):
302313
if getattr(self, "attr", None) == attr:
314+
if attr == "test_value":
315+
warnings.warn(
316+
"test_value machinery is deprecated and will stop working in the future.",
317+
FutureWarning,
318+
)
303319
obj = self.attr_filter(obj)
304320

305321
return object.__setattr__(self, attr, obj)

pytensor/misc/pkl_utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import pickle
1010
import sys
1111
import tempfile
12-
import warnings
1312
import zipfile
1413
from collections import defaultdict
1514
from contextlib import closing
@@ -62,10 +61,6 @@ class StripPickler(Pickler):
6261
def __init__(self, file, protocol=0, extra_tag_to_remove=None):
6362
# Can't use super as Pickler isn't a new style class
6463
super().__init__(file, protocol)
65-
warnings.warn(
66-
"compute_test_value is deprecated and will stop working in the future.",
67-
FutureWarning,
68-
)
6964
self.tag_to_remove = ["trace", "test_value"]
7065
if extra_tag_to_remove:
7166
self.tag_to_remove.extend(extra_tag_to_remove)

pytensor/scalar/basic.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import builtins
1414
import math
15-
import warnings
1615
from collections.abc import Callable, Mapping
1716
from copy import copy
1817
from itertools import chain
@@ -4415,10 +4414,6 @@ def apply(self, fgraph):
44154414
if i.dtype == "float16":
44164415
mapping[i] = get_scalar_type("float32")()
44174416
if hasattr(i.tag, "test_value"):
4418-
warnings.warn(
4419-
"test_value machinery is deprecated and will stop working in the future.",
4420-
FutureWarning,
4421-
)
44224417
mapping[i].tag.test_value = i.tag.test_value
44234418
else:
44244419
mapping[i] = i

pytensor/scan/basic.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,6 @@ def wrap_into_list(x):
598598

599599
# Try to transfer test_value to the new variable
600600
if config.compute_test_value != "off":
601-
warnings.warn(
602-
"test_value machinery is deprecated and will stop working in the future.",
603-
FutureWarning,
604-
)
605601
try:
606602
nw_slice.tag.test_value = get_test_value(_seq_val_slice)
607603
except TestValueError:
@@ -729,10 +725,6 @@ def wrap_into_list(x):
729725

730726
# Try to transfer test_value to the new variable
731727
if config.compute_test_value != "off":
732-
warnings.warn(
733-
"test_value machinery is deprecated and will stop working in the future.",
734-
FutureWarning,
735-
)
736728
try:
737729
arg.tag.test_value = get_test_value(actual_arg)
738730
except TestValueError:
@@ -788,10 +780,6 @@ def wrap_into_list(x):
788780

789781
# Try to transfer test_value to the new variable
790782
if config.compute_test_value != "off":
791-
warnings.warn(
792-
"test_value machinery is deprecated and will stop working in the future.",
793-
FutureWarning,
794-
)
795783
try:
796784
nw_slice.tag.test_value = get_test_value(_init_out_var_slice)
797785
except TestValueError:

pytensor/scan/op.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import dataclasses
4747
import logging
4848
import time
49-
import warnings
5049
from collections import OrderedDict
5150
from collections.abc import Callable, Iterable
5251
from copy import copy
@@ -2651,10 +2650,6 @@ def compute_all_gradients(known_grads):
26512650
# fct add and we want to keep it for all Scan op. This is
26522651
# used in T_Scan.test_grad_multiple_outs_taps to test
26532652
# that.
2654-
warnings.warn(
2655-
"test_value machinery is deprecated and will stop working in the future.",
2656-
FutureWarning,
2657-
)
26582653
if info.as_while:
26592654
n = n_steps.tag.test_value
26602655
else:

0 commit comments

Comments
 (0)