From 9005163dd01c10264e41ea69fd8a21e31abd0aba Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 14 Oct 2016 18:45:26 -0400 Subject: [PATCH] Clean up a bit of the import mess. --- src/dunshire/__init__.py | 10 +++++----- src/dunshire/cones.py | 5 +++-- src/dunshire/games.py | 17 +++++------------ src/dunshire/matrices.py | 2 +- test/suite.py | 10 +++++----- 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/dunshire/__init__.py b/src/dunshire/__init__.py index b5243b0..f754c92 100644 --- a/src/dunshire/__init__.py +++ b/src/dunshire/__init__.py @@ -6,9 +6,9 @@ turn pulls in everything that they would need to use the library. """ # Needed to construct the cone over which the game takes place. -from cones import (NonnegativeOrthant, - IceCream, - SymmetricPSD, - CartesianProduct) +from .cones import (NonnegativeOrthant, + IceCream, + SymmetricPSD, + CartesianProduct) -from games import SymmetricLinearGame +from .games import SymmetricLinearGame diff --git a/src/dunshire/cones.py b/src/dunshire/cones.py index 61feab4..7fc8bf9 100644 --- a/src/dunshire/cones.py +++ b/src/dunshire/cones.py @@ -4,8 +4,9 @@ Class definitions for all of the symmetric cones (and their superclass, """ from cvxopt import matrix -from matrices import eigenvalues, norm -import options + +from .matrices import eigenvalues, norm +from . import options class SymmetricCone: """ diff --git a/src/dunshire/games.py b/src/dunshire/games.py index 2cf23b2..05ab58c 100644 --- a/src/dunshire/games.py +++ b/src/dunshire/games.py @@ -12,11 +12,11 @@ from unittest import TestCase # These are mostly actually needed. from cvxopt import matrix, printing, solvers -from cones import CartesianProduct, IceCream, NonnegativeOrthant -from errors import GameUnsolvableException -from matrices import (append_col, append_row, eigenvalues_re, identity, - inner_product, norm) -import options +from .cones import CartesianProduct, IceCream, NonnegativeOrthant +from .errors import GameUnsolvableException +from .matrices import (append_col, append_row, eigenvalues_re, identity, + inner_product, norm) +from . import options printing.options['dformat'] = options.FLOAT_FORMAT solvers.options['show_progress'] = options.VERBOSE @@ -211,7 +211,6 @@ class SymmetricLinearGame: Examples -------- - >>> from cones import NonnegativeOrthant >>> K = NonnegativeOrthant(3) >>> L = [[1,-5,-15],[-1,2,-3],[-12,-15,1]] >>> e1 = [1,1,1] @@ -232,7 +231,6 @@ class SymmetricLinearGame: Lists can (and probably should) be used for every argument:: - >>> from cones import NonnegativeOrthant >>> K = NonnegativeOrthant(2) >>> L = [[1,0],[0,1]] >>> e1 = [1,1] @@ -254,7 +252,6 @@ class SymmetricLinearGame: >>> import cvxopt >>> import numpy - >>> from cones import NonnegativeOrthant >>> K = NonnegativeOrthant(2) >>> L = [[1,0],[0,1]] >>> e1 = cvxopt.matrix([1,1]) @@ -275,7 +272,6 @@ class SymmetricLinearGame: otherwise indexed by columns:: >>> import cvxopt - >>> from cones import NonnegativeOrthant >>> K = NonnegativeOrthant(2) >>> L = [[1,2],[3,4]] >>> e1 = [1,1] @@ -364,7 +360,6 @@ class SymmetricLinearGame: This example is computed in Gowda and Ravindran in the section "The value of a Z-transformation":: - >>> from cones import NonnegativeOrthant >>> K = NonnegativeOrthant(3) >>> L = [[1,-5,-15],[-1,2,-3],[-12,-15,1]] >>> e1 = [1,1,1] @@ -384,7 +379,6 @@ class SymmetricLinearGame: The value of the following game can be computed using the fact that the identity is invertible:: - >>> from cones import NonnegativeOrthant >>> K = NonnegativeOrthant(3) >>> L = [[1,0,0],[0,1,0],[0,0,1]] >>> e1 = [1,2,3] @@ -475,7 +469,6 @@ class SymmetricLinearGame: Examples -------- - >>> from cones import NonnegativeOrthant >>> K = NonnegativeOrthant(3) >>> L = [[1,-5,-15],[-1,2,-3],[-12,-15,1]] >>> e1 = [1,1,1] diff --git a/src/dunshire/matrices.py b/src/dunshire/matrices.py index ef3c4c0..6ed4f85 100644 --- a/src/dunshire/matrices.py +++ b/src/dunshire/matrices.py @@ -7,7 +7,7 @@ from math import sqrt from cvxopt import matrix from cvxopt.lapack import gees, syevr -import options +from . import options def append_col(left, right): diff --git a/test/suite.py b/test/suite.py index 714bd57..7051b9c 100644 --- a/test/suite.py +++ b/test/suite.py @@ -10,11 +10,11 @@ from doctest import DocTestSuite # Add '../' to our path. from site import addsitedir -addsitedir('./src/dunshire') -import cones -import errors -import matrices -import games +addsitedir('./src') +from dunshire import cones +from dunshire import errors +from dunshire import matrices +from dunshire import games suite = TestSuite() suite.addTest(DocTestSuite(cones)) -- 2.44.2