mirror of
https://github.com/ROCm/jax.git
synced 2025-04-16 11:56:07 +00:00
Some cleanups related to dropping Python 3.7
This commit is contained in:
parent
73680b20cc
commit
e7f53479e2
@ -74,8 +74,8 @@ def get_python_version(python_bin_path):
|
||||
return major, minor
|
||||
|
||||
def check_python_version(python_version):
|
||||
if python_version < (3, 7):
|
||||
print("ERROR: JAX requires Python 3.7 or newer, found ", python_version)
|
||||
if python_version < (3, 8):
|
||||
print("ERROR: JAX requires Python 3.8 or newer, found ", python_version)
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
|
@ -934,12 +934,10 @@ def _why_alive(ignore_ids: Set[int], x: Any) -> str:
|
||||
# in _why_alive_container_info. See example:
|
||||
# https://github.com/google/jax/pull/13022#discussion_r1008456599
|
||||
# To prevent this collapsing behavior, just comment out this code block.
|
||||
# TODO(mattjj): after Python 3.7 is unsupported, replace with types.CellType
|
||||
cell_type = type((lambda x: lambda: x)(10.28).__closure__[0]) # type: ignore
|
||||
if (isinstance(parent, dict) and
|
||||
getattr(parents(parent)[0], '__dict__', None) is parents(child)[0]):
|
||||
parent = parents(parent)[0]
|
||||
elif type(parent) is cell_type:
|
||||
elif type(parent) is types.CellType:
|
||||
parent = parents(parents(parent)[0])[0]
|
||||
|
||||
line = f'<{type(child).__name__} {id(child)}> is referred to by '
|
||||
|
@ -312,9 +312,8 @@ class CPPJitTest(jtu.BufferDonationTestCase):
|
||||
def f(a, b, c):
|
||||
...
|
||||
|
||||
# TODO(phawkins): reenable this test after Python 3.7 support is dropped.
|
||||
# def g(a, /, b, *, c):
|
||||
# ...
|
||||
def g(a, /, b, *, c):
|
||||
...
|
||||
|
||||
def h(a, *args):
|
||||
...
|
||||
@ -324,7 +323,7 @@ class CPPJitTest(jtu.BufferDonationTestCase):
|
||||
|
||||
# Simplest cases
|
||||
self.jit(f, **{argnum_type: (0, 1)})
|
||||
# self.jit(g, **{argnum_type: (0, 1)})
|
||||
self.jit(g, **{argnum_type: (0, 1)})
|
||||
self.jit(f, **{argnum_type: (0, 1, -3)})
|
||||
|
||||
# Out of bounds without *args
|
||||
@ -336,13 +335,13 @@ class CPPJitTest(jtu.BufferDonationTestCase):
|
||||
with self.assertWarns(SyntaxWarning):
|
||||
self.jit(f, **{argnum_type: (0, 1, -4)})
|
||||
|
||||
# # with self.assertRaises(ValueError):
|
||||
# with self.assertWarns(SyntaxWarning):
|
||||
# self.jit(g, **{argnum_type: (0, 1, 3)})
|
||||
# with self.assertRaises(ValueError):
|
||||
with self.assertWarns(SyntaxWarning):
|
||||
self.jit(g, **{argnum_type: (0, 1, 3)})
|
||||
|
||||
# # with self.assertRaises(ValueError):
|
||||
# with self.assertWarns(SyntaxWarning):
|
||||
# self.jit(g, **{argnum_type: (0, 1, -3)})
|
||||
# with self.assertRaises(ValueError):
|
||||
with self.assertWarns(SyntaxWarning):
|
||||
self.jit(g, **{argnum_type: (0, 1, -3)})
|
||||
|
||||
# Out of bounds with *args
|
||||
self.jit(h, **{argnum_type: (0, 999)})
|
||||
@ -360,9 +359,8 @@ class CPPJitTest(jtu.BufferDonationTestCase):
|
||||
def g(a, b, **kwargs):
|
||||
...
|
||||
|
||||
# TODO(phawkins): reenable this test after Python 3.7 support is dropped.
|
||||
# def h(a, /, b, c, *args, **kwargs):
|
||||
# ...
|
||||
def h(a, /, b, c, *args, **kwargs):
|
||||
...
|
||||
|
||||
# Simplest case
|
||||
self.jit(f, static_argnames=("b", "c"))
|
||||
@ -375,19 +373,18 @@ class CPPJitTest(jtu.BufferDonationTestCase):
|
||||
# Undefined arg with **kwargs
|
||||
self.jit(g, static_argnames=("a", "b", "not_defined"))
|
||||
|
||||
# TODO(phawkins): reenable this test after Python 3.7 support is dropped.
|
||||
# self.jit(h, static_argnames=("b", "c"))
|
||||
# self.jit(h, static_argnames=("b", "c", "not_defined"))
|
||||
#
|
||||
# # Positional only
|
||||
# # with self.assertRaises(ValueError):
|
||||
# with self.assertWarns(SyntaxWarning):
|
||||
# self.jit(h, static_argnames=("a", "c"))
|
||||
self.jit(h, static_argnames=("b", "c"))
|
||||
self.jit(h, static_argnames=("b", "c", "not_defined"))
|
||||
|
||||
# # Var positional
|
||||
# # with self.assertRaises(ValueError):
|
||||
# with self.assertWarns(SyntaxWarning):
|
||||
# self.jit(h, static_argnames=("args", "c"))
|
||||
# Positional only
|
||||
# with self.assertRaises(ValueError):
|
||||
with self.assertWarns(SyntaxWarning):
|
||||
self.jit(h, static_argnames=("a", "c"))
|
||||
|
||||
# Var positional
|
||||
# with self.assertRaises(ValueError):
|
||||
with self.assertWarns(SyntaxWarning):
|
||||
self.jit(h, static_argnames=("args", "c"))
|
||||
|
||||
|
||||
def test_jit_with_many_args_works(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user