Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test():
import os
import numpy
import tensorflow.contrib
import returnn.TFUtil
funcs = [f for name, f in globals().items() if name.startswith("get_mod_from_dict_")]
mods = [sys, os, gc, pprint, better_exchook, numpy, tensorflow, tensorflow.contrib, returnn, returnn.TFUtil]
for f in funcs:
print("Testing func:", f)
for mod in mods:
print("Testing mod:", mod)
d = get_dict_from_mod(mod)
mod2 = f(d)
assert mod2 and vars(mod2) is d
# Note: For lazy module loaders, such as in RETURNN,
# we do not necessarily have `mod is mod2`.
if mod is not mod2:
print("Note: Mod is different:", mod2)