From c5d8fff883b64ca7b20b5b50b2b653e195f53dda Mon Sep 17 00:00:00 2001 From: "smcquay@cfdviz2" Date: Mon, 8 Mar 2010 13:05:42 -0700 Subject: [PATCH] moved some files around to conform to python best practicies --HG-- rename : lib/baker.py => lib/baker/__init__.py rename : lib/tools.py => lib/baker/tools.py rename : lib/grid.py => lib/grid/__init__.py rename : lib/smcqdelaunay.py => lib/grid/smcqdelaunay.py --- bin/driver.py | 2 +- bin/grid_regular.py | 7 +++---- lib/{baker.py => baker/__init__.py} | 2 +- lib/{ => baker}/tools.py | 7 ++++++- lib/{grid.py => grid/__init__.py} | 8 ++++---- lib/{ => grid}/smcqdelaunay.py | 0 6 files changed, 15 insertions(+), 11 deletions(-) rename lib/{baker.py => baker/__init__.py} (99%) rename lib/{ => baker}/tools.py (74%) rename lib/{grid.py => grid/__init__.py} (97%) rename lib/{ => grid}/smcqdelaunay.py (100%) diff --git a/bin/driver.py b/bin/driver.py index a6e8985..764c388 100755 --- a/bin/driver.py +++ b/bin/driver.py @@ -5,7 +5,7 @@ from optparse import OptionParser import numpy as np -from tools import rms, exact_func +from baker.tools import rms, exact_func import grid diff --git a/bin/grid_regular.py b/bin/grid_regular.py index 545e483..515fc68 100755 --- a/bin/grid_regular.py +++ b/bin/grid_regular.py @@ -3,10 +3,9 @@ import sys import pickle -from grid import simple_rect_grid, simple_random_grid -from baker import run_baker - -from tools import smberror +from grid import simple_rect_grid, simple_random_grid +from baker import run_baker +from baker.tools import smberror qfile = '/tmp/grid_regular.txt' diff --git a/lib/baker.py b/lib/baker/__init__.py similarity index 99% rename from lib/baker.py rename to lib/baker/__init__.py index d2289fb..57f52d8 100644 --- a/lib/baker.py +++ b/lib/baker/__init__.py @@ -1,7 +1,7 @@ import numpy as np import sys -from tools import smberror +from baker.tools import smberror def get_phis(X, R): """ diff --git a/lib/tools.py b/lib/baker/tools.py similarity index 74% rename from lib/tools.py rename to lib/baker/tools.py index 77bcb11..3ad8a4c 100644 --- a/lib/tools.py +++ b/lib/baker/tools.py @@ -1,6 +1,9 @@ import numpy as np class smberror(Exception): + """ + this is a silly little exception subclass + """ def __init__(self, val): self.value = val def __str__(self): @@ -17,5 +20,7 @@ def rms(errors): return r def exact_func(x, y): + """ + the exact function used from baker's article (for testing) + """ return np.power((np.sin(x * np.pi) * np.cos(y * np.pi)), 2) - return np.sin(x * np.pi) * np.cos(y * np.pi) diff --git a/lib/grid.py b/lib/grid/__init__.py similarity index 97% rename from lib/grid.py rename to lib/grid/__init__.py index 950245f..ead5d24 100755 --- a/lib/grid.py +++ b/lib/grid/__init__.py @@ -2,14 +2,14 @@ import sys import re -from collections import defaultdict +from collections import defaultdict import numpy as np import scipy.spatial -from baker import run_baker, get_phis -from tools import exact_func, smberror -from smcqdelaunay import * +from baker import run_baker, get_phis +from baker.tools import exact_func, smberror +from grid.smcqdelaunay import * class face(object): def __init__(self, name): diff --git a/lib/smcqdelaunay.py b/lib/grid/smcqdelaunay.py similarity index 100% rename from lib/smcqdelaunay.py rename to lib/grid/smcqdelaunay.py