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

mesh in FiPy name space #223

Closed
wd15 opened this issue Sep 19, 2014 · 3 comments
Closed

mesh in FiPy name space #223

wd15 opened this issue Sep 19, 2014 · 3 comments
Labels

Comments

@wd15
Copy link
Contributor

wd15 commented Sep 19, 2014

 >>> from fipy import *
 >>> print mesh
 <module 'fipy.meshes.mesh' from '/users/wd15/Documents/python/fipy/trunk/fipy/meshes/mesh.pyc'>

This could cause no end of confusion

Imported from trac ticket #319, created by wd15 on 02-15-2011 at 12:03, last modified: 11-09-2011 at 20:29

@jamesob
Copy link
Contributor

jamesob commented Sep 19, 2014

The only apparent remedy for this (without renaming classes) would entail changing a line in fipy/__init__.py from

from meshes import *

to

from meshes import (Grid1D, Grid2D, Grid3D,
CylindricalGrid1D, CylindricalGrid2D,
PeriodicGrid1D, PeriodicGrid2D,
PeriodicGrid2DLeftRight, PeriodicGrid2DTopBottom,
SkewedGrid2D,
Tri2D,
GmshImporter2D, GmshImporter3D, GmshImporter2DIn3DSpace,
Gmsh2D, Gmsh3D, Gmsh2DIn3DSpace,
GmshGrid2D, GmshGrid3D)

This is sort of ugly because, under this change, whenever a new mesh is added to FiPy, two __init__s must be updated instead of one. Otherwise, though, I think the appearance of mesh in the global namespace is unavoidable, as it is necessarily brought into scope by from meshes import *.

An alternative would be to change mesh's name to AbstractMesh, or something similar. This may even be a more accurate reflection of the class' purpose.

Trac comment by obeirne on 02-15-2011 at 14:45

@guyer
Copy link
Member

guyer commented Sep 19, 2014

Rather than

from meshes import (Grid1D, Grid2D, Grid3D,
CylindricalGrid1D, CylindricalGrid2D,
PeriodicGrid1D, PeriodicGrid2D,
PeriodicGrid2DLeftRight, PeriodicGrid2DTopBottom,
SkewedGrid2D,
Tri2D,
GmshImporter2D, GmshImporter3D, GmshImporter2DIn3DSpace,
Gmsh2D, Gmsh3D, Gmsh2DIn3DSpace,
GmshGrid2D, GmshGrid3D)

in fipy/__init__.py, it is more correct (but no less work) to set

__all__ = ["Grid1D", "Grid2D", "Grid3D",
"CylindricalGrid1D", "CylindricalGrid2D", ...]

in fipy/meshes/__init__.py.

There's an argument that we should be much more explicit about what the user gets by from fipy import * anyway.

Trac comment by guyer on 02-15-2011 at 15:17

@guyer
Copy link
Member

guyer commented Sep 19, 2014

fipy namespace cleaned up with pervasive use of __all__ in r4847

Trac comment by guyer on 11-09-2011 at 20:29

@wd15 wd15 closed this as completed Sep 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants