-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manually listed all classes and functions in __init__.py and added a …
…script to generate the list (print_all.py)
- Loading branch information
Showing
2 changed files
with
85 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,69 @@ | ||
# partly from https://stackoverflow.com/questions/14426574/how-to-import-members-of-modules-within-a-package/14428820#14428820 | ||
|
||
def _import_all_modules(): | ||
"""dynamically imports all modules in the package""" | ||
import traceback | ||
import os | ||
global __all__ | ||
__all__ = [] | ||
globals_, locals_ = globals(), locals() | ||
|
||
# dynamically import all the package modules | ||
for filename in os.listdir(__name__): | ||
# process all python files in directory that don't start with underscore | ||
# (which also keeps this module from importing itself) | ||
if filename == 'assembly.py' \ | ||
or filename == 'mesh.py' \ | ||
or filename == 'utils.py' \ | ||
or filename == 'element.py' \ | ||
or filename == 'mapping.py': | ||
modulename = filename.split('.')[0] # filename without extension | ||
package_module = '.'.join([__name__, modulename]) | ||
try: | ||
module = __import__(package_module, globals_, locals_, [modulename]) | ||
except: | ||
traceback.print_exc() | ||
raise | ||
for name in module.__dict__: | ||
if not name.startswith('_'): | ||
globals_[name] = module.__dict__[name] | ||
__all__.append(name) | ||
|
||
_import_all_modules() | ||
from skfem.mesh import * | ||
from skfem.assembly import * | ||
from skfem.mapping import * | ||
from skfem.element import * | ||
from skfem.utils import * | ||
from skfem.mesh_importers import * | ||
|
||
__all__ = ['InterfaceMesh1D', | ||
'Mesh', | ||
'Mesh2D', | ||
'Mesh3D', | ||
'MeshHex', | ||
'MeshLine', | ||
'MeshQuad', | ||
'MeshTet', | ||
'MeshTri', | ||
'coo_matrix', | ||
'Dofnum', | ||
'FacetBasis', | ||
'GlobalBasis', | ||
'InteriorBasis', | ||
'asm', | ||
'coo_matrix', | ||
'get_quadrature', | ||
'MappingAffine', | ||
'MappingIsoparametric', | ||
'adaptive_theta', | ||
'bilinear_form', | ||
'build_ilu_pc', | ||
'cg', | ||
'condense', | ||
'initialize', | ||
'linear_form', | ||
'nonlinear_form', | ||
'rcm', | ||
'rcm_reordering', | ||
'smoothplot', | ||
'solve', | ||
'solver_direct_cholmod', | ||
'solver_direct_scipy', | ||
'Element', | ||
'ElementArgyris', | ||
'ElementH1', | ||
'ElementH2', | ||
'ElementHcurl', | ||
'ElementHdiv', | ||
'ElementHex1', | ||
'ElementMorley', | ||
'ElementQ1', | ||
'ElementQ2', | ||
'ElementTetN0', | ||
'ElementTetP0', | ||
'ElementTetP1', | ||
'ElementTetP2', | ||
'ElementTetRT0', | ||
'ElementTriDG', | ||
'ElementTriP0', | ||
'ElementTriP1', | ||
'ElementTriRT0', | ||
'ElementVectorH1', | ||
'MeshQuad', | ||
'MeshTet', | ||
'MeshTri', | ||
'read_array', | ||
'assert_', | ||
'read_comsol', | ||
'read_gmsh', | ||
'read_token', | ||
'skip_read_line'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import importlib | ||
import types | ||
|
||
class C: pass | ||
|
||
for fname in ['mesh', | ||
'assembly', | ||
'mapping', | ||
'utils', | ||
'element', | ||
'mesh_importers']: | ||
mod = importlib.import_module(fname, 'skfem') | ||
for x in dir(mod): | ||
if isinstance(getattr(mod, x), types.FunctionType): | ||
print(" '"+x+"',") | ||
elif isinstance(getattr(mod, x), type(C)): | ||
print(" '"+x+"',") |