Skip to content

Commit

Permalink
Add a type annotation to empirical_test to fix a type-checking timeout.
Browse files Browse the repository at this point in the history
The type checker was timing out on this file due to trying to analyze the
extremely large `_functions` dictionary every time it was indexed into. Adding
a type annotation fixes this problem.

PiperOrigin-RevId: 514925119
  • Loading branch information
rchen152 authored and romanngg committed Mar 9, 2023
1 parent 65004a5 commit 9cfdc28
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/empirical_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,10 @@ def apply_fn(params, x, **kwargs):
self.assertAllClose(ntk_ref, ntk, err_msg=f'{i} vmapped impl. fails.')


_functions = {
PyTree = Any


_functions: Dict[str, Callable[[PyTree, PyTree], PyTree]] = {
'[p[0]**(p[1] + x), p[2] * x + p[0]]':
lambda p, x: [np.abs(p[0])**(p[1] + x), p[2] * x + p[0]],
'[p[0]**(p[1] + x), p[2] / x + p[0]]':
Expand Down

0 comments on commit 9cfdc28

Please sign in to comment.