From 7161f983ab74475910c062f288afc0946d585d49 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sat, 17 Mar 2018 14:09:15 +0100 Subject: [PATCH] fix __name__ being incorrect due to extra __all__ this fixes tracebacks and checks for __main__, among other things. --- .gitignore | 1 - onn/activation.py | 2 +- onn/experimental.py | 2 +- onn/float.py | 3 --- onn/layer.py | 2 +- onn/learner.py | 2 +- onn/loss.py | 2 +- onn/model.py | 2 +- onn/optimizer.py | 2 +- onn/optimizer_base.py | 2 +- onn/parametric.py | 2 +- onn/regularizer.py | 2 +- onn/ritual.py | 2 +- onn/ritual_base.py | 2 +- 14 files changed, 12 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 667fa90..fb91e21 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ __pycache__ # work in progress: onn/component.py onn/extra.py -onn/run.py diff --git a/onn/activation.py b/onn/activation.py index 3f1c90d..74e87be 100644 --- a/onn/activation.py +++ b/onn/activation.py @@ -3,7 +3,7 @@ import numpy as np # just for speed, not strictly essential: from scipy.special import expit as sigmoid -from .float import * +from .float import _f, _1 from .layer_base import * diff --git a/onn/experimental.py b/onn/experimental.py index 4d57cae..1f28e1e 100644 --- a/onn/experimental.py +++ b/onn/experimental.py @@ -1,6 +1,6 @@ import numpy as np -from .float import * +from .float import _f, _0, _1 from .layer import Layer from .loss import Loss from .optimizer import Optimizer diff --git a/onn/float.py b/onn/float.py index 83476de..079bcac 100644 --- a/onn/float.py +++ b/onn/float.py @@ -16,6 +16,3 @@ _inv2 = _f(1/2) _sqrt2 = _f(np.sqrt(2)) _invsqrt2 = _f(1/np.sqrt(2)) _pi = _f(np.pi) - -__all__ = [k for k, v in locals().items() - if not __import__('inspect').ismodule(v)] diff --git a/onn/layer.py b/onn/layer.py index f8987f0..5b78311 100644 --- a/onn/layer.py +++ b/onn/layer.py @@ -1,6 +1,6 @@ from .layer_base import * from .initialization import * -from .float import * +from .float import _f, _1 # Nonparametric Layers {{{1 diff --git a/onn/learner.py b/onn/learner.py index 8673f9a..dbb961c 100644 --- a/onn/learner.py +++ b/onn/learner.py @@ -1,4 +1,4 @@ -from .float import * +from .float import _f, _1, _pi, _inv2 from .optimizer_base import * diff --git a/onn/loss.py b/onn/loss.py index 28167ec..d30d127 100644 --- a/onn/loss.py +++ b/onn/loss.py @@ -1,6 +1,6 @@ import numpy as np -from .float import * +from .float import _f class Loss: diff --git a/onn/model.py b/onn/model.py index ece35dc..e45107f 100644 --- a/onn/model.py +++ b/onn/model.py @@ -1,6 +1,6 @@ import sys -from .float import * +from .float import _f, _0 from .nodal import * from .layer_base import * from .utility import * diff --git a/onn/optimizer.py b/onn/optimizer.py index adc45b0..0350b2f 100644 --- a/onn/optimizer.py +++ b/onn/optimizer.py @@ -1,6 +1,6 @@ import numpy as np -from .float import * +from .float import _f, _0, _1 from .optimizer_base import * from .utility import * diff --git a/onn/optimizer_base.py b/onn/optimizer_base.py index 95852b5..6977539 100644 --- a/onn/optimizer_base.py +++ b/onn/optimizer_base.py @@ -1,6 +1,6 @@ import numpy as np -from .float import * +from .float import _f class Optimizer: diff --git a/onn/parametric.py b/onn/parametric.py index 52bf0ca..ea7b9b7 100644 --- a/onn/parametric.py +++ b/onn/parametric.py @@ -1,6 +1,6 @@ import numpy as np -from .float import * +from .float import _f from .layer_base import * from .initialization import * diff --git a/onn/regularizer.py b/onn/regularizer.py index eec9888..546cd8a 100644 --- a/onn/regularizer.py +++ b/onn/regularizer.py @@ -1,7 +1,7 @@ import numpy as np +from .float import _f, _0 from .layer import Layer -from .float import * class Regularizer: diff --git a/onn/ritual.py b/onn/ritual.py index 96c6b4d..eab76bb 100644 --- a/onn/ritual.py +++ b/onn/ritual.py @@ -1,6 +1,6 @@ import numpy as np -from .float import * +from .float import _f from .initialization import * from .ritual_base import * diff --git a/onn/ritual_base.py b/onn/ritual_base.py index c026994..1cbd1eb 100644 --- a/onn/ritual_base.py +++ b/onn/ritual_base.py @@ -1,7 +1,7 @@ import types import numpy as np -from .float import * +from .float import _f, _0 class Ritual: # i'm just making up names at this point.