Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module names #153

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions discretize/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions discretize/CylMesh.py → discretize/cylindrical_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions discretize/InnerProducts.py → discretize/inner_products.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions discretize/TensorMesh.py → discretize/tensor_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions discretize/Tests.py → discretize/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
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
from discretize.utils.codeutils import requires

try:
from discretize.TreeMesh import TreeMesh as Tree
from discretize.tree_mesh import TreeMesh as Tree
except ImportError as e:
Tree = None

Expand Down
12 changes: 7 additions & 5 deletions discretize/TreeMesh.py → discretize/tree_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, TreeCell

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.
Expand Down
7 changes: 5 additions & 2 deletions discretize/View.py → discretize/view.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import print_function
import numpy as np
import warnings
from discretize.utils import mkvc, ndgrid
from discretize.utils.codeutils import requires
from six import integer_types


from .utils import mkvc, ndgrid
from .utils.codeutils import requires

# matplotlib is a soft dependencies for discretize
try:
import matplotlib
Expand All @@ -16,6 +18,7 @@
except ImportError:
matplotlib = False

from .utils import mkvc, ndgrid

@requires({'matplotlib': matplotlib})
class TensorView(object):
Expand Down
26 changes: 13 additions & 13 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,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
Expand All @@ -46,8 +46,8 @@ Mesh IO
:toctree: generated

load_mesh
MeshIO.TensorMeshIO
MeshIO.TreeMeshIO
mesh_io.TensorMeshIO
mesh_io.TreeMeshIO


Visualization
Expand All @@ -56,10 +56,10 @@ Visualization
.. autosummary::
:toctree: generated

View.TensorView
View.CylView
View.CurviView
View.Slicer
view.TensorView
view.CylView
view.CurviView
view.Slicer
mixins.vtkModule


Expand All @@ -70,10 +70,10 @@ Testing
.. autosummary::
:toctree: generated

Tests.OrderTest
Tests.checkDerivative
Tests.getQuadratic
Tests.Rosenbrock
tests.OrderTest
tests.checkDerivative
tests.getQuadratic
tests.Rosenbrock


Utilities
Expand Down
8 changes: 4 additions & 4 deletions tests/base/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 +
Expand Down Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions tests/base/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/base/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
Loading