From ec71d4956e330b78bc81df328a00fe39172cae67 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 13 Mar 2018 03:27:11 +0100 Subject: [PATCH] fix module leaking for real --- onn/__init__.py | 5 ++--- onn/experimental.py | 2 ++ onn/float.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/onn/__init__.py b/onn/__init__.py index e3f95de..f7e2511 100644 --- a/onn/__init__.py +++ b/onn/__init__.py @@ -22,6 +22,5 @@ from .weight import * # this is similar to default behaviour of having no __all__ variable at all, # but ours ignores modules as well. this allows for `import sys` and such # without clobbering `from our_module import *`. -__all__ = [ - o for o in locals() - if type(o) != 'module' and not o.startswith('_')] +__all__ = [k for k, v in locals().items() + if not __import__('inspect').ismodule(v) and not k.startswith('_')] diff --git a/onn/experimental.py b/onn/experimental.py index dac12be..4d57cae 100644 --- a/onn/experimental.py +++ b/onn/experimental.py @@ -1,3 +1,5 @@ +import numpy as np + from .float import * from .layer import Layer from .loss import Loss diff --git a/onn/float.py b/onn/float.py index 948ab5d..83476de 100644 --- a/onn/float.py +++ b/onn/float.py @@ -17,4 +17,5 @@ _sqrt2 = _f(np.sqrt(2)) _invsqrt2 = _f(1/np.sqrt(2)) _pi = _f(np.pi) -__all__ = [o for o in locals() if type(o) != 'module'] +__all__ = [k for k, v in locals().items() + if not __import__('inspect').ismodule(v)]