From adb7480e66cb33a1c9e796733a2669e6e97df734 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Mon, 22 Apr 2019 15:24:56 -0700 Subject: [PATCH 1/3] renaming modeules --- discretize/{CurvilinearMesh.py => curvilinear_mesh.py} | 0 discretize/{CylMesh.py => cylindrical_mesh.py} | 0 discretize/{DiffOperators.py => differential_operators.py} | 0 discretize/{InnerProducts.py => inner_products.py} | 0 discretize/{MeshIO.py => mesh_io.py} | 0 discretize/{TensorMesh.py => tensor_mesh.py} | 0 discretize/{Tests.py => tmp_tests.py} | 0 discretize/{View.py => tmp_view.py} | 0 discretize/{TreeMesh.py => tree_mesh.py} | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename discretize/{CurvilinearMesh.py => curvilinear_mesh.py} (100%) rename discretize/{CylMesh.py => cylindrical_mesh.py} (100%) rename discretize/{DiffOperators.py => differential_operators.py} (100%) rename discretize/{InnerProducts.py => inner_products.py} (100%) rename discretize/{MeshIO.py => mesh_io.py} (100%) rename discretize/{TensorMesh.py => tensor_mesh.py} (100%) rename discretize/{Tests.py => tmp_tests.py} (100%) rename discretize/{View.py => tmp_view.py} (100%) rename discretize/{TreeMesh.py => tree_mesh.py} (100%) diff --git a/discretize/CurvilinearMesh.py b/discretize/curvilinear_mesh.py similarity index 100% rename from discretize/CurvilinearMesh.py rename to discretize/curvilinear_mesh.py diff --git a/discretize/CylMesh.py b/discretize/cylindrical_mesh.py similarity index 100% rename from discretize/CylMesh.py rename to discretize/cylindrical_mesh.py diff --git a/discretize/DiffOperators.py b/discretize/differential_operators.py similarity index 100% rename from discretize/DiffOperators.py rename to discretize/differential_operators.py diff --git a/discretize/InnerProducts.py b/discretize/inner_products.py similarity index 100% rename from discretize/InnerProducts.py rename to discretize/inner_products.py diff --git a/discretize/MeshIO.py b/discretize/mesh_io.py similarity index 100% rename from discretize/MeshIO.py rename to discretize/mesh_io.py diff --git a/discretize/TensorMesh.py b/discretize/tensor_mesh.py similarity index 100% rename from discretize/TensorMesh.py rename to discretize/tensor_mesh.py diff --git a/discretize/Tests.py b/discretize/tmp_tests.py similarity index 100% rename from discretize/Tests.py rename to discretize/tmp_tests.py diff --git a/discretize/View.py b/discretize/tmp_view.py similarity index 100% rename from discretize/View.py rename to discretize/tmp_view.py diff --git a/discretize/TreeMesh.py b/discretize/tree_mesh.py similarity index 100% rename from discretize/TreeMesh.py rename to discretize/tree_mesh.py From 132d475254d536b5fd6ccc9aabb6257f2f7194b4 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Mon, 22 Apr 2019 15:26:39 -0700 Subject: [PATCH 2/3] update init file --- discretize/__init__.py | 13 ++++++------- discretize/{tmp_tests.py => tests.py} | 0 discretize/{tmp_view.py => view.py} | 0 3 files changed, 6 insertions(+), 7 deletions(-) rename discretize/{tmp_tests.py => tests.py} (100%) rename discretize/{tmp_view.py => view.py} (100%) diff --git a/discretize/__init__.py b/discretize/__init__.py index f5a1b6cd3..17a6928d0 100644 --- a/discretize/__init__.py +++ b/discretize/__init__.py @@ -1,11 +1,10 @@ -# from discretize.BaseMesh import BaseMesh -from discretize.TensorMesh import TensorMesh -from discretize.CylMesh import CylMesh -from discretize.CurvilinearMesh import CurvilinearMesh -from discretize import Tests -from discretize.MeshIO import load_mesh +from discretize.tensor_mesh import TensorMesh +from discretize.cylindrical_mesh import CylMesh +from discretize.curvilinear_mesh import CurvilinearMesh +from discretize import tests +from discretize.mesh_io import load_mesh try: - from discretize.TreeMesh import TreeMesh + from discretize.tree_mesh import TreeMesh except ImportError as err: print(err) import os diff --git a/discretize/tmp_tests.py b/discretize/tests.py similarity index 100% rename from discretize/tmp_tests.py rename to discretize/tests.py diff --git a/discretize/tmp_view.py b/discretize/view.py similarity index 100% rename from discretize/tmp_view.py rename to discretize/view.py From 7ac9254bcdaeb94d0b9b3d90a9e861475c3528c7 Mon Sep 17 00:00:00 2001 From: Lindsey Heagy Date: Mon, 22 Apr 2019 16:01:28 -0700 Subject: [PATCH 3/3] update module names in the tests and docs --- discretize/curvilinear_mesh.py | 8 ++-- discretize/cylindrical_mesh.py | 8 ++-- discretize/differential_operators.py | 3 +- discretize/inner_products.py | 5 ++- discretize/tensor_mesh.py | 8 ++-- discretize/tests.py | 4 +- discretize/tree_mesh.py | 12 +++--- discretize/view.py | 3 +- docs/api/index.rst | 26 ++++++------ tests/base/test_interpolation.py | 8 ++-- tests/base/test_operators.py | 30 ++++++------- tests/base/test_tensor.py | 2 +- tests/base/test_tensor_boundary.py | 6 +-- tests/base/test_tensor_boundary_poisson.py | 12 +++--- tests/base/test_tensor_innerproduct.py | 6 +-- tests/base/test_tensor_innerproduct_derivs.py | 4 +- tests/base/test_utils.py | 2 +- tests/base/test_view.py | 2 +- tests/cyl/test_cyl.py | 16 +++---- tests/cyl/test_cylOperators.py | 24 +++++------ tests/cyl/test_cyl_innerproducts.py | 42 +++++++++---------- tests/tree/test_tree_innerproduct_derivs.py | 4 +- tests/tree/test_tree_interpolation.py | 4 +- tests/tree/test_tree_operators.py | 24 +++++------ 24 files changed, 134 insertions(+), 129 deletions(-) diff --git a/discretize/curvilinear_mesh.py b/discretize/curvilinear_mesh.py index a668a45e9..15f3cb989 100644 --- a/discretize/curvilinear_mesh.py +++ b/discretize/curvilinear_mesh.py @@ -3,11 +3,11 @@ import properties from properties.math import TYPE_MAPPINGS -from discretize import utils from .base import BaseRectangularMesh -from discretize.DiffOperators import DiffOperators -from discretize.InnerProducts import InnerProducts -from discretize.View import CurviView +from . import utils +from .differential_operators import DiffOperators +from .inner_products import InnerProducts +from .view import CurviView # Some helper functions. diff --git a/discretize/cylindrical_mesh.py b/discretize/cylindrical_mesh.py index 5b9032648..779223a24 100644 --- a/discretize/cylindrical_mesh.py +++ b/discretize/cylindrical_mesh.py @@ -8,10 +8,10 @@ from .utils import ( kron3, ndgrid, av, speye, ddx, sdiag, interpmat, spzeros, cyl2cart ) -from .TensorMesh import BaseTensorMesh, BaseRectangularMesh -from .InnerProducts import InnerProducts -from .View import CylView -from .DiffOperators import DiffOperators +from .tensor_mesh import BaseTensorMesh, BaseRectangularMesh +from .inner_products import InnerProducts +from .view import CylView +from .differential_operators import DiffOperators class CylMesh( diff --git a/discretize/differential_operators.py b/discretize/differential_operators.py index ce7473ae2..81c6c7fa7 100644 --- a/discretize/differential_operators.py +++ b/discretize/differential_operators.py @@ -3,7 +3,8 @@ from scipy import sparse as sp from six import string_types import warnings -from discretize.utils import sdiag, speye, kron3, spzeros, ddx, av, av_extrap + +from .utils import sdiag, speye, kron3, spzeros, ddx, av, av_extrap def checkBC(bc): diff --git a/discretize/inner_products.py b/discretize/inner_products.py index 94a86bc0d..1977ba862 100644 --- a/discretize/inner_products.py +++ b/discretize/inner_products.py @@ -1,10 +1,11 @@ from scipy import sparse as sp -from discretize.utils import ( +import numpy as np + +from .utils import ( sub2ind, sdiag, invPropertyTensor, TensorType, makePropertyTensor, ndgrid, inv2X2BlockDiagonal, getSubArray, inv3X3BlockDiagonal, spzeros, sdInv ) -import numpy as np class InnerProducts(object): diff --git a/discretize/tensor_mesh.py b/discretize/tensor_mesh.py index 07220409e..1d1a0ba11 100644 --- a/discretize/tensor_mesh.py +++ b/discretize/tensor_mesh.py @@ -4,10 +4,10 @@ from discretize import utils from .base import BaseRectangularMesh, BaseTensorMesh -from .View import TensorView -from .DiffOperators import DiffOperators -from .InnerProducts import InnerProducts -from .MeshIO import TensorMeshIO +from .view import TensorView +from .differential_operators import DiffOperators +from .inner_products import InnerProducts +from .mesh_io import TensorMeshIO class TensorMesh( diff --git a/discretize/tests.py b/discretize/tests.py index fe822b896..eae7fc254 100644 --- a/discretize/tests.py +++ b/discretize/tests.py @@ -2,12 +2,12 @@ import numpy as np import scipy.sparse as sp -from discretize.utils import mkvc, sdiag +from .utils import mkvc, sdiag from discretize import utils from discretize import TensorMesh, CurvilinearMesh, CylMesh try: - from discretize.TreeMesh import TreeMesh as Tree + from discretize.tree_mesh import TreeMesh as Tree except ImportError as e: Tree = None diff --git a/discretize/tree_mesh.py b/discretize/tree_mesh.py index 1c77f8b88..0383a55d1 100644 --- a/discretize/tree_mesh.py +++ b/discretize/tree_mesh.py @@ -84,16 +84,18 @@ # | | ^ # |___________| |___> x # 0 e3 1 -from .base import BaseTensorMesh -from .InnerProducts import InnerProducts -from .MeshIO import TreeMeshIO -from . import utils -from .tree_ext import _TreeMesh + import numpy as np from scipy.spatial import Delaunay import scipy.sparse as sp from six import integer_types +from .base import BaseTensorMesh +from .inner_products import InnerProducts +from .mesh_io import TreeMeshIO +from . import utils +from .tree_ext import _TreeMesh + class TreeMesh(_TreeMesh, BaseTensorMesh, InnerProducts, TreeMeshIO): """ TreeMesh is a class for adaptive QuadTree (2D) and OcTree (3D) meshes. diff --git a/discretize/view.py b/discretize/view.py index 0f934195d..ff73c0734 100644 --- a/discretize/view.py +++ b/discretize/view.py @@ -1,7 +1,7 @@ from __future__ import print_function import numpy as np import warnings -from discretize.utils import mkvc, ndgrid + from six import integer_types try: import matplotlib.pyplot as plt @@ -11,6 +11,7 @@ except ImportError: print('Trouble importing matplotlib.') +from .utils import mkvc, ndgrid class TensorView(object): """Provides viewing functions for TensorMesh diff --git a/docs/api/index.rst b/docs/api/index.rst index aaf6717d4..c3cf63008 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -27,15 +27,15 @@ Meshes Numerical Operators ------------------- -.. automodule:: discretize.InnerProducts +.. automodule:: discretize.inner_products .. currentmodule:: discretize .. autosummary:: :toctree: generated - DiffOperators.DiffOperators - InnerProducts.InnerProducts + differential_operators.DiffOperators + inner_products.InnerProducts Mesh IO @@ -45,8 +45,8 @@ Mesh IO :toctree: generated load_mesh - MeshIO.TensorMeshIO - MeshIO.TreeMeshIO + mesh_io.TensorMeshIO + mesh_io.TreeMeshIO Visualization @@ -55,10 +55,10 @@ Visualization .. autosummary:: :toctree: generated - View.TensorView - View.CylView - View.CurviView - View.Slicer + view.TensorView + view.CylView + view.CurviView + view.Slicer mixins.vtkModule @@ -69,10 +69,10 @@ Testing .. autosummary:: :toctree: generated - Tests.OrderTest - Tests.checkDerivative - Tests.getQuadratic - Tests.Rosenbrock + tests.OrderTest + tests.checkDerivative + tests.getQuadratic + tests.Rosenbrock Utilities diff --git a/tests/base/test_interpolation.py b/tests/base/test_interpolation.py index 7fe5f8922..e28248b63 100644 --- a/tests/base/test_interpolation.py +++ b/tests/base/test_interpolation.py @@ -23,7 +23,7 @@ TOL = 1e-7 -class TestInterpolation1D(discretize.Tests.OrderTest): +class TestInterpolation1D(discretize.tests.OrderTest): LOCS = np.random.rand(50)*0.6+0.2 name = "Interpolation 1D" meshTypes = MESHTYPES @@ -69,7 +69,7 @@ def test_outliers(self): Q = M.getInterpolationMat(np.array([[-1], [0.126], [0.127]]), 'CC', zerosOutside=True) self.assertTrue(np.linalg.norm(Q*x - np.r_[0, 1.004, 1.008]) < TOL) -class TestInterpolation2d(discretize.Tests.OrderTest): +class TestInterpolation2d(discretize.tests.OrderTest): name = "Interpolation 2D" LOCS = np.random.rand(50, 2)*0.6+0.2 meshTypes = MESHTYPES @@ -152,7 +152,7 @@ def test_exceptions(self): self.assertRaises(Exception, lambda:M.getInterpolationMat(locs, 'Ez')) -class TestInterpolation2dCyl(discretize.Tests.OrderTest): +class TestInterpolation2dCyl(discretize.tests.OrderTest): name = "Interpolation 2D" LOCS = np.c_[np.random.rand(4)*0.6+0.2, np.zeros(4), np.random.rand(4)*0.6+0.2] meshTypes = ['uniformCylMesh'] # MESHTYPES + @@ -221,7 +221,7 @@ def test_orderEy(self): self.orderTest() -class TestInterpolation3D(discretize.Tests.OrderTest): +class TestInterpolation3D(discretize.tests.OrderTest): name = "Interpolation" LOCS = np.random.rand(50, 3)*0.6+0.2 meshTypes = MESHTYPES diff --git a/tests/base/test_operators.py b/tests/base/test_operators.py index b2f6e52c1..4dff015a8 100644 --- a/tests/base/test_operators.py +++ b/tests/base/test_operators.py @@ -25,7 +25,7 @@ cartE3 = lambda M, ex, ey, ez: np.vstack((cart_row3(M.gridEx, ex, ey, ez), cart_row3(M.gridEy, ex, ey, ez), cart_row3(M.gridEz, ex, ey, ez))) -class TestCurl(discretize.Tests.OrderTest): +class TestCurl(discretize.tests.OrderTest): name = "Curl" meshTypes = MESHTYPES @@ -60,7 +60,7 @@ def test_order(self): self.orderTest() -class TestCurl2D(discretize.Tests.OrderTest): +class TestCurl2D(discretize.tests.OrderTest): name = "Cell Grad 2D - Dirichlet" meshTypes = ['uniformTensorMesh'] meshDimension = 2 @@ -82,7 +82,7 @@ def getError(self): def test_order(self): self.orderTest() -class TestCellGrad1D_InhomogeneousDirichlet(discretize.Tests.OrderTest): +class TestCellGrad1D_InhomogeneousDirichlet(discretize.tests.OrderTest): name = "Cell Grad 1D - Dirichlet" meshTypes = ['uniformTensorMesh'] meshDimension = 1 @@ -111,7 +111,7 @@ def test_order(self): self.orderTest() -class TestCellGrad2D_Dirichlet(discretize.Tests.OrderTest): +class TestCellGrad2D_Dirichlet(discretize.tests.OrderTest): name = "Cell Grad 2D - Dirichlet" meshTypes = ['uniformTensorMesh'] meshDimension = 2 @@ -139,7 +139,7 @@ def test_order(self): self.orderTest() -class TestCellGrad3D_Dirichlet(discretize.Tests.OrderTest): +class TestCellGrad3D_Dirichlet(discretize.tests.OrderTest): name = "Cell Grad 3D - Dirichlet" meshTypes = ['uniformTensorMesh'] meshDimension = 3 @@ -167,7 +167,7 @@ def getError(self): def test_order(self): self.orderTest() -class TestCellGrad2D_Neumann(discretize.Tests.OrderTest): +class TestCellGrad2D_Neumann(discretize.tests.OrderTest): name = "Cell Grad 2D - Neumann" meshTypes = ['uniformTensorMesh'] meshDimension = 2 @@ -195,7 +195,7 @@ def test_order(self): self.orderTest() -class TestCellGrad3D_Neumann(discretize.Tests.OrderTest): +class TestCellGrad3D_Neumann(discretize.tests.OrderTest): name = "Cell Grad 3D - Neumann" meshTypes = ['uniformTensorMesh'] meshDimension = 3 @@ -224,7 +224,7 @@ def test_order(self): self.orderTest() -class TestFaceDiv3D(discretize.Tests.OrderTest): +class TestFaceDiv3D(discretize.tests.OrderTest): name = "Face Divergence 3D" meshTypes = MESHTYPES meshSizes = [8, 16, 32, 64] @@ -254,7 +254,7 @@ def test_order(self): self.orderTest() -class TestFaceDiv2D(discretize.Tests.OrderTest): +class TestFaceDiv2D(discretize.tests.OrderTest): name = "Face Divergence 2D" meshTypes = MESHTYPES meshDimension = 2 @@ -280,7 +280,7 @@ def test_order(self): self.orderTest() -class TestNodalGrad(discretize.Tests.OrderTest): +class TestNodalGrad(discretize.tests.OrderTest): name = "Nodal Gradient" meshTypes = MESHTYPES @@ -306,7 +306,7 @@ def test_order(self): self.orderTest() -class TestNodalGrad2D(discretize.Tests.OrderTest): +class TestNodalGrad2D(discretize.tests.OrderTest): name = "Nodal Gradient 2D" meshTypes = MESHTYPES meshDimension = 2 @@ -349,7 +349,7 @@ def test_constantFaces(self): assert all(self.mesh.aveF2CCV * face_vec == 1.) -class TestAveraging2D(discretize.Tests.OrderTest): +class TestAveraging2D(discretize.tests.OrderTest): name = "Averaging 2D" meshTypes = MESHTYPES meshDimension = 2 @@ -458,7 +458,7 @@ def test_constantFaces(self): assert all(np.absolute(self.mesh.aveF2CCV * face_vec - 1.) < TOL) -class TestAveraging3D(discretize.Tests.OrderTest): +class TestAveraging3D(discretize.tests.OrderTest): name = "Averaging 3D" meshTypes = MESHTYPES meshDimension = 3 @@ -561,7 +561,7 @@ class MimeticProperties(unittest.TestCase): def test_DivCurl(self): for meshType in self.meshTypes: - mesh, _ = discretize.Tests.setupMesh( + mesh, _ = discretize.tests.setupMesh( meshType, self.meshSize, self.meshDimension ) v = np.random.rand(mesh.nE) @@ -578,7 +578,7 @@ def test_DivCurl(self): def test_CurlGrad(self): for meshType in self.meshTypes: - mesh, _ = discretize.Tests.setupMesh( + mesh, _ = discretize.tests.setupMesh( meshType, self.meshSize, self.meshDimension ) v = np.random.rand(mesh.nN) diff --git a/tests/base/test_tensor.py b/tests/base/test_tensor.py index 523fd8fa0..6df43f8e7 100644 --- a/tests/base/test_tensor.py +++ b/tests/base/test_tensor.py @@ -118,7 +118,7 @@ def test_tensor(self): self.assertLess(np.abs(M.hx - np.r_[10., 10.]).sum(), TOL) -class TestPoissonEqn(discretize.Tests.OrderTest): +class TestPoissonEqn(discretize.tests.OrderTest): name = "Poisson Equation" meshSizes = [10, 16, 20] diff --git a/tests/base/test_tensor_boundary.py b/tests/base/test_tensor_boundary.py index e096b4dc8..9349e70e9 100644 --- a/tests/base/test_tensor_boundary.py +++ b/tests/base/test_tensor_boundary.py @@ -178,7 +178,7 @@ def getxBCyBC_CC(mesh, alpha, beta, gamma): return xBC, yBC -class Test1D_InhomogeneousMixed(discretize.Tests.OrderTest): +class Test1D_InhomogeneousMixed(discretize.tests.OrderTest): name = "1D - Mixed" meshTypes = MESHTYPES meshDimension = 1 @@ -244,7 +244,7 @@ def test_order(self): self.orderTest() -class Test2D_InhomogeneousMixed(discretize.Tests.OrderTest): +class Test2D_InhomogeneousMixed(discretize.tests.OrderTest): name = "2D - Mixed" meshTypes = MESHTYPES meshDimension = 2 @@ -343,7 +343,7 @@ def test_order(self): self.orderTest() -class Test3D_InhomogeneousMixed(discretize.Tests.OrderTest): +class Test3D_InhomogeneousMixed(discretize.tests.OrderTest): name = "3D - Mixed" meshTypes = MESHTYPES meshDimension = 3 diff --git a/tests/base/test_tensor_boundary_poisson.py b/tests/base/test_tensor_boundary_poisson.py index 4c15c7c1e..bb5278e0b 100644 --- a/tests/base/test_tensor_boundary_poisson.py +++ b/tests/base/test_tensor_boundary_poisson.py @@ -11,7 +11,7 @@ MESHTYPES = ['uniformTensorMesh'] -class Test1D_InhomogeneousDirichlet(discretize.Tests.OrderTest): +class Test1D_InhomogeneousDirichlet(discretize.tests.OrderTest): name = "1D - Dirichlet" meshTypes = MESHTYPES meshDimension = 1 @@ -92,7 +92,7 @@ def test_orderXJ(self): self.orderTest() -class Test2D_InhomogeneousDirichlet(discretize.Tests.OrderTest): +class Test2D_InhomogeneousDirichlet(discretize.tests.OrderTest): name = "2D - Dirichlet" meshTypes = MESHTYPES meshDimension = 2 @@ -173,7 +173,7 @@ def test_orderXJ(self): self.myTest = 'xcJ' self.orderTest() -class Test1D_InhomogeneousNeumann(discretize.Tests.OrderTest): +class Test1D_InhomogeneousNeumann(discretize.tests.OrderTest): name = "1D - Neumann" meshTypes = MESHTYPES meshDimension = 1 @@ -249,7 +249,7 @@ def test_orderXJ(self): self.myTest = 'xcJ' self.orderTest() -class Test2D_InhomogeneousNeumann(discretize.Tests.OrderTest): +class Test2D_InhomogeneousNeumann(discretize.tests.OrderTest): name = "2D - Neumann" meshTypes = MESHTYPES meshDimension = 2 @@ -337,7 +337,7 @@ def test_orderXJ(self): self.orderTest() -class Test1D_InhomogeneousMixed(discretize.Tests.OrderTest): +class Test1D_InhomogeneousMixed(discretize.tests.OrderTest): name = "1D - Mixed" meshTypes = MESHTYPES meshDimension = 1 @@ -415,7 +415,7 @@ def test_orderXJ(self): self.orderTest() -class Test2D_InhomogeneousMixed(discretize.Tests.OrderTest): +class Test2D_InhomogeneousMixed(discretize.tests.OrderTest): name = "2D - Mixed" meshTypes = MESHTYPES meshDimension = 2 diff --git a/tests/base/test_tensor_innerproduct.py b/tests/base/test_tensor_innerproduct.py index 4db007d1b..fa39f559c 100644 --- a/tests/base/test_tensor_innerproduct.py +++ b/tests/base/test_tensor_innerproduct.py @@ -4,7 +4,7 @@ import discretize -class TestInnerProducts(discretize.Tests.OrderTest): +class TestInnerProducts(discretize.tests.OrderTest): """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" @@ -152,7 +152,7 @@ def test_order6_faces_invProp(self): self.orderTest() -class TestInnerProducts2D(discretize.Tests.OrderTest): +class TestInnerProducts2D(discretize.tests.OrderTest): """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" @@ -294,7 +294,7 @@ def test_order3_faces_invProp(self): self.orderTest() -class TestInnerProducts1D(discretize.Tests.OrderTest): +class TestInnerProducts1D(discretize.tests.OrderTest): """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" diff --git a/tests/base/test_tensor_innerproduct_derivs.py b/tests/base/test_tensor_innerproduct_derivs.py index 6765ebee9..627790e8d 100644 --- a/tests/base/test_tensor_innerproduct_derivs.py +++ b/tests/base/test_tensor_innerproduct_derivs.py @@ -26,7 +26,7 @@ def fun(sig): Md = mesh.getFaceInnerProductDeriv(sig, invProp=invProp, invMat=invMat, doFast=fast) return M*v, Md(v) print(meshType, 'Face', h, rep, fast, ('harmonic' if invProp and invMat else 'standard')) - return discretize.Tests.checkDerivative(fun, sig, num=5, plotIt=False) + return discretize.tests.checkDerivative(fun, sig, num=5, plotIt=False) def doTestEdge(self, h, rep, fast, meshType, invProp=False, invMat=False): if meshType == 'Curv': @@ -45,7 +45,7 @@ def fun(sig): Md = mesh.getEdgeInnerProductDeriv(sig, invProp=invProp, invMat=invMat, doFast=fast) return M*v, Md(v) print(meshType, 'Edge', h, rep, fast, ('harmonic' if invProp and invMat else 'standard')) - return discretize.Tests.checkDerivative(fun, sig, num=5, plotIt=False) + return discretize.tests.checkDerivative(fun, sig, num=5, plotIt=False) def test_FaceIP_1D_float(self): self.assertTrue(self.doTestFace([10], 0, False, 'Tensor')) diff --git a/tests/base/test_utils.py b/tests/base/test_utils.py index 9d432e63f..c7c2878af 100644 --- a/tests/base/test_utils.py +++ b/tests/base/test_utils.py @@ -9,7 +9,7 @@ ind2sub, asArray_N_x_Dim, TensorType, Zero, Identity, ExtractCoreMesh ) -from discretize.Tests import checkDerivative +from discretize.tests import checkDerivative import discretize import sys diff --git a/tests/base/test_view.py b/tests/base/test_view.py index 78b6b3589..2da661301 100644 --- a/tests/base/test_view.py +++ b/tests/base/test_view.py @@ -5,7 +5,7 @@ import matplotlib.pyplot as plt import discretize -from discretize import Tests, utils +from discretize import utils import pytest diff --git a/tests/cyl/test_cyl.py b/tests/cyl/test_cyl.py index 905728ab4..2b577f78d 100644 --- a/tests/cyl/test_cyl.py +++ b/tests/cyl/test_cyl.py @@ -3,7 +3,7 @@ import numpy as np import discretize -from discretize import Tests, utils +from discretize import tests, utils np.random.seed(13) @@ -307,7 +307,7 @@ def test_getInterpMatCartMesh_Edges2Faces(self): cylF2 = lambda M, fx, fy: np.vstack((cyl_row2(M.gridFx, fx, fy), cyl_row2(M.gridFz, fx, fy))) -class TestFaceDiv2D(Tests.OrderTest): +class TestFaceDiv2D(tests.OrderTest): name = "FaceDiv" meshTypes = MESHTYPES meshDimension = 2 @@ -333,7 +333,7 @@ def test_order(self): self.orderTest() -class TestEdgeCurl2D(Tests.OrderTest): +class TestEdgeCurl2D(tests.OrderTest): name = "EdgeCurl" meshTypes = MESHTYPES meshDimension = 2 @@ -434,7 +434,7 @@ def test_constantFaces(self): ) -class TestAveE2CC(Tests.OrderTest): +class TestAveE2CC(tests.OrderTest): name = "aveE2CC" meshTypes = MESHTYPES meshDimension = 2 @@ -456,7 +456,7 @@ def test_order(self): self.orderTest() -class TestAveE2CCV(Tests.OrderTest): +class TestAveE2CCV(tests.OrderTest): name = "aveE2CCV" meshTypes = MESHTYPES meshDimension = 2 @@ -478,7 +478,7 @@ def test_order(self): self.orderTest() -class TestAveF2CCV(Tests.OrderTest): +class TestAveF2CCV(tests.OrderTest): name = "aveF2CCV" meshTypes = MESHTYPES meshDimension = 2 @@ -506,7 +506,7 @@ def test_order(self): self.orderTest() -class TestAveF2CC(Tests.OrderTest): +class TestAveF2CC(tests.OrderTest): name = "aveF2CC" meshTypes = MESHTYPES meshDimension = 2 @@ -529,7 +529,7 @@ def test_order(self): self.orderTest() -class TestInnerProducts2D(Tests.OrderTest): +class TestInnerProducts2D(tests.OrderTest): """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" meshTypes = MESHTYPES diff --git a/tests/cyl/test_cylOperators.py b/tests/cyl/test_cylOperators.py index 17472bce1..a81a48d64 100644 --- a/tests/cyl/test_cylOperators.py +++ b/tests/cyl/test_cylOperators.py @@ -5,7 +5,7 @@ from sympy.abc import r, t, z import discretize -from discretize import Tests +from discretize import tests np.random.seed(16) @@ -37,7 +37,7 @@ )) -# class TestCellGradx3D(Tests.OrderTest): +# class TestCellGradx3D(tests.OrderTest): # name = "CellGradx" # MESHTYPES = MESHTYPES # meshDimension = 3 @@ -63,7 +63,7 @@ # self.orderTest() -class TestFaceDiv3D(Tests.OrderTest): +class TestFaceDiv3D(tests.OrderTest): name = "FaceDiv" meshTypes = MESHTYPES meshDimension = 3 @@ -95,7 +95,7 @@ def test_order(self): self.orderTest() -class TestEdgeCurl3D(Tests.OrderTest): +class TestEdgeCurl3D(tests.OrderTest): name = "edgeCurl" meshTypes = MESHTYPES @@ -199,7 +199,7 @@ def test_simplefct(self): assert np.linalg.norm(aveF - aveF_ana) < 1e-10 -class TestAveF2CCV(Tests.OrderTest): +class TestAveF2CCV(tests.OrderTest): name = "aveF2CCV" meshTypes = MESHTYPES meshSizes = [8, 16, 32, 64] @@ -236,7 +236,7 @@ def test_order(self): self.orderTest() -class TestAveF2CC(Tests.OrderTest): +class TestAveF2CC(tests.OrderTest): name = "aveF2CC" meshTypes = MESHTYPES meshSizes = [8, 16, 32, 64] @@ -314,7 +314,7 @@ def vectors(self, mesh): return sig, np.r_[jr, jt, jz] -class TestAveE2CCV(Tests.OrderTest): +class TestAveE2CCV(tests.OrderTest): name = "aveE2CCV" meshTypes = MESHTYPES meshSizes = [8, 16, 32, 64] @@ -350,7 +350,7 @@ def test_order(self): self.orderTest() -class TestAveE2CC(Tests.OrderTest): +class TestAveE2CC(tests.OrderTest): name = "aveE2CC" meshTypes = MESHTYPES meshSizes = [8, 16, 32, 64] @@ -466,7 +466,7 @@ def test_EdgeInnerProduct(self): assert(np.abs(ans-numeric_ans) < TOL) -class TestCylFaceInnerProducts_Order(Tests.OrderTest): +class TestCylFaceInnerProducts_Order(tests.OrderTest): meshTypes = ['uniformCylMesh'] meshDimension = 3 @@ -481,7 +481,7 @@ def test_order(self): self.orderTest() -class TestCylEdgeInnerProducts_Order(Tests.OrderTest): +class TestCylEdgeInnerProducts_Order(tests.OrderTest): meshTypes = ['uniformCylMesh'] meshDimension = 3 @@ -504,7 +504,7 @@ class MimeticProperties(unittest.TestCase): def test_DivCurl(self): for meshType in self.meshTypes: - mesh, _ = discretize.Tests.setupMesh( + mesh, _ = discretize.tests.setupMesh( meshType, self.meshSize, self.meshDimension ) v = np.random.rand(mesh.nE) @@ -521,7 +521,7 @@ def test_DivCurl(self): # # Nodal Grad has not been implemented yet # def test_CurlGrad(self): # for meshType in self.meshTypes: - # mesh, _ = discretize.Tests.setupMesh( + # mesh, _ = discretize.tests.setupMesh( # meshType, self.meshSize, self.meshDimension # ) # v = np.random.rand(mesh.nN) diff --git a/tests/cyl/test_cyl_innerproducts.py b/tests/cyl/test_cyl_innerproducts.py index 63031b01f..17ebb66cd 100644 --- a/tests/cyl/test_cyl_innerproducts.py +++ b/tests/cyl/test_cyl_innerproducts.py @@ -1,6 +1,6 @@ from __future__ import print_function import discretize -from discretize import Tests +from discretize import tests import numpy as np import sympy from sympy.abc import r, t, z @@ -226,7 +226,7 @@ def test_EdgeInnerProductDiagAnisotropic(self): assert(np.abs(ans-numeric_ans) < TOL) -class TestCylFaceInnerProducts_Order(Tests.OrderTest): +class TestCylFaceInnerProducts_Order(tests.OrderTest): meshTypes = ['uniformCylMesh'] meshDimension = 2 @@ -241,7 +241,7 @@ def test_order(self): self.orderTest() -class TestCylEdgeInnerProducts_Order(Tests.OrderTest): +class TestCylEdgeInnerProducts_Order(tests.OrderTest): meshTypes = ['uniformCylMesh'] meshDimension = 2 @@ -256,7 +256,7 @@ def test_order(self): self.orderTest() -class TestCylFaceInnerProductsDiagAnisotropic_Order(Tests.OrderTest): +class TestCylFaceInnerProductsDiagAnisotropic_Order(tests.OrderTest): meshTypes = ['uniformCylMesh'] meshDimension = 2 @@ -271,7 +271,7 @@ def test_order(self): self.orderTest() -class TestCylEdgeInnerProducts_Order(Tests.OrderTest): +class TestCylEdgeInnerProducts_Order(tests.OrderTest): meshTypes = ['uniformCylMesh'] meshDimension = 2 @@ -304,7 +304,7 @@ def fun(x): return MfSig*self.face_vec, MfSigDeriv(self.face_vec) print('Testing FaceInnerProduct Isotropic') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) def test_FaceInnerProductIsotropicDerivInvProp(self): @@ -316,7 +316,7 @@ def fun(x): return MfSig*self.face_vec, MfSigDeriv(self.face_vec) print('Testing FaceInnerProduct Isotropic InvProp') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -329,7 +329,7 @@ def fun(x): return MfSig*self.face_vec, MfSigDeriv(self.face_vec) print('Testing FaceInnerProduct Isotropic InvMat') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -344,7 +344,7 @@ def fun(x): return MfSig*self.face_vec, MfSigDeriv(self.face_vec) print('Testing FaceInnerProduct Isotropic InvProp InvMat') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -356,7 +356,7 @@ def fun(x): return MeSig*self.edge_vec, MeSigDeriv(self.edge_vec) print('Testing EdgeInnerProduct Isotropic') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -369,7 +369,7 @@ def fun(x): return MeSig*self.edge_vec, MeSigDeriv(self.edge_vec) print('Testing EdgeInnerProduct Isotropic InvProp') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -382,7 +382,7 @@ def fun(x): return MeSig*self.edge_vec, MeSigDeriv(self.edge_vec) print('Testing EdgeInnerProduct Isotropic InvMat') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -396,7 +396,7 @@ def fun(x): return MeSig*self.edge_vec, MeSigDeriv(self.edge_vec) print('Testing EdgeInnerProduct Isotropic InvProp InvMat') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -429,7 +429,7 @@ def fun(x): return MfSig*self.face_vec , MfSigDeriv(self.face_vec) * P.T print('Testing FaceInnerProduct Anisotropic') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) def test_FaceInnerProductAnisotropicDerivInvProp(self): @@ -448,7 +448,7 @@ def fun(x): return MfSig*self.face_vec, MfSigDeriv(self.face_vec) * P.T print('Testing FaceInnerProduct Anisotropic InvProp') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -467,7 +467,7 @@ def fun(x): return MfSig*self.face_vec, MfSigDeriv(self.face_vec) * P.T print('Testing FaceInnerProduct Anisotropic InvMat') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -488,7 +488,7 @@ def fun(x): return MfSig*self.face_vec, MfSigDeriv(self.face_vec) * P.T print('Testing FaceInnerProduct Anisotropic InvProp InvMat') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -507,7 +507,7 @@ def fun(x): return MeSig*self.edge_vec, MeSigDeriv(self.edge_vec) * P.T print('Testing EdgeInnerProduct Anisotropic') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -526,7 +526,7 @@ def fun(x): return MeSig*self.edge_vec, MeSigDeriv(self.edge_vec) * P.T print('Testing EdgeInnerProduct Anisotropic InvProp') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -545,7 +545,7 @@ def fun(x): return MeSig*self.edge_vec, MeSigDeriv(self.edge_vec) * P.T print('Testing EdgeInnerProduct Anisotropic InvMat') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) @@ -566,7 +566,7 @@ def fun(x): return MeSig*self.edge_vec, MeSigDeriv(self.edge_vec) * P.T print('Testing EdgeInnerProduct Anisotropic InvProp InvMat') - return self.assertTrue(Tests.checkDerivative(fun, self.x0, num=7, + return self.assertTrue(tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False)) diff --git a/tests/tree/test_tree_innerproduct_derivs.py b/tests/tree/test_tree_innerproduct_derivs.py index 355cbda74..492126062 100644 --- a/tests/tree/test_tree_innerproduct_derivs.py +++ b/tests/tree/test_tree_innerproduct_derivs.py @@ -21,7 +21,7 @@ def fun(sig): Md = mesh.getFaceInnerProductDeriv(sig, invProp=invProp, invMat=invMat, doFast=fast) return M*v, Md(v) print(meshType, 'Face', h, rep, fast, ('harmonic' if invProp and invMat else 'standard')) - return discretize.Tests.checkDerivative(fun, sig, num=5, plotIt=False) + return discretize.tests.checkDerivative(fun, sig, num=5, plotIt=False) @@ -41,7 +41,7 @@ def fun(sig): Md = mesh.getEdgeInnerProductDeriv(sig, invProp=invProp, invMat=invMat, doFast=fast) return M*v, Md(v) print(meshType, 'Edge', h, rep, fast, ('harmonic' if invProp and invMat else 'standard')) - return discretize.Tests.checkDerivative(fun, sig, num=5, plotIt=False) + return discretize.tests.checkDerivative(fun, sig, num=5, plotIt=False) class TestInnerProductsDerivsTensor(unittest.TestCase): diff --git a/tests/tree/test_tree_interpolation.py b/tests/tree/test_tree_interpolation.py index d5cc6b756..5666eb7f9 100644 --- a/tests/tree/test_tree_interpolation.py +++ b/tests/tree/test_tree_interpolation.py @@ -19,7 +19,7 @@ MESHTYPES = ['uniformTree', 'notatreeTree'] -class TestInterpolation2d(discretize.Tests.OrderTest): +class TestInterpolation2d(discretize.tests.OrderTest): """Face interpolation is O(h) Edge interpolation is O(h^2) """ @@ -109,7 +109,7 @@ def test_orderEy(self): self.orderTest() -class TestInterpolation3D(discretize.Tests.OrderTest): +class TestInterpolation3D(discretize.tests.OrderTest): name = "Interpolation" #LOCS = np.random.rand(50, 3)*0.6+0.2 X, Y, Z = np.mgrid[0:1:50j, 0:1:50j, 0:1:50j] diff --git a/tests/tree/test_tree_operators.py b/tests/tree/test_tree_operators.py index efcf7d6d8..260d24ed6 100644 --- a/tests/tree/test_tree_operators.py +++ b/tests/tree/test_tree_operators.py @@ -17,7 +17,7 @@ # np.random.seed(None) # np.random.seed(7) -class TestCellGrad2D(discretize.Tests.OrderTest): +class TestCellGrad2D(discretize.tests.OrderTest): name = "Cell Gradient 2D, using cellGradx and cellGrady" meshTypes = MESHTYPES meshDimension = 2 @@ -45,7 +45,7 @@ def test_order(self): self.orderTest() -class TestCellGrad3D(discretize.Tests.OrderTest): +class TestCellGrad3D(discretize.tests.OrderTest): name = "Cell Gradient 3D, using cellGradx, cellGrady, and cellGradz" meshTypes = MESHTYPES @@ -74,7 +74,7 @@ def test_order(self): self.orderTest() -class TestFaceDivxy2D(discretize.Tests.OrderTest): +class TestFaceDivxy2D(discretize.tests.OrderTest): name = "Face Divergence 2D, Testing faceDivx and faceDivy" meshTypes = MESHTYPES meshDimension = 2 @@ -105,7 +105,7 @@ def test_order(self): self.orderTest() -class TestFaceDiv3D(discretize.Tests.OrderTest): +class TestFaceDiv3D(discretize.tests.OrderTest): name = "Face Divergence 3D" meshTypes = MESHTYPES meshSizes = [8, 16, 32] @@ -130,7 +130,7 @@ def test_order(self): self.orderTest() -class TestFaceDivxyz3D(discretize.Tests.OrderTest): +class TestFaceDivxyz3D(discretize.tests.OrderTest): name = "Face Divergence 3D, Testing faceDivx, faceDivy, and faceDivz" meshTypes = MESHTYPES meshDimension = 3 @@ -164,7 +164,7 @@ def test_order(self): self.orderTest() -class TestCurl(discretize.Tests.OrderTest): +class TestCurl(discretize.tests.OrderTest): name = "Curl" meshTypes = ['notatreeTree', 'uniformTree'] #, 'randomTree']#, 'uniformTree'] meshSizes = [8, 16]#, 32] @@ -200,7 +200,7 @@ def test_order(self): self.orderTest() -class TestNodalGrad(discretize.Tests.OrderTest): +class TestNodalGrad(discretize.tests.OrderTest): name = "Nodal Gradient" meshTypes = ['notatreeTree', 'uniformTree'] #['randomTree', 'uniformTree'] meshSizes = [8, 16]#, 32] @@ -229,7 +229,7 @@ def test_order(self): self.orderTest() -class TestNodalGrad2D(discretize.Tests.OrderTest): +class TestNodalGrad2D(discretize.tests.OrderTest): name = "Nodal Gradient 2D" meshTypes = ['notatreeTree', 'uniformTree'] #['randomTree', 'uniformTree'] meshSizes = [8, 16]#, 32] @@ -259,7 +259,7 @@ def test_order(self): -class TestTreeInnerProducts(discretize.Tests.OrderTest): +class TestTreeInnerProducts(discretize.tests.OrderTest): """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" meshTypes = ['uniformTree', 'notatreeTree'] #['uniformTensorMesh', 'uniformCurv', 'rotateCurv'] @@ -406,7 +406,7 @@ def test_order6_faces_invProp(self): self.orderTest() -class TestTreeInnerProducts2D(discretize.Tests.OrderTest): +class TestTreeInnerProducts2D(discretize.tests.OrderTest): """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" meshTypes = ['uniformTree'] @@ -546,7 +546,7 @@ def test_order3_faces_invProp(self): self.invProp = True self.orderTest() -class TestTreeAveraging2D(discretize.Tests.OrderTest): +class TestTreeAveraging2D(discretize.tests.OrderTest): """Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts.""" meshTypes = ['notatreeTree', 'uniformTree']# 'randomTree'] @@ -628,7 +628,7 @@ def test_orderCC2F(self): self.expectedOrders = 2 -class TestAveraging3D(discretize.Tests.OrderTest): +class TestAveraging3D(discretize.tests.OrderTest): name = "Averaging 3D" meshTypes = ['notatreeTree', 'uniformTree']#, 'randomTree'] meshDimension = 3