From d98f06c46a2ac049f6cf7d11edb35a1cf7eb3232 Mon Sep 17 00:00:00 2001 From: Andrew Fiore-Gartland Date: Wed, 2 Sep 2015 14:05:28 -0700 Subject: [PATCH 1/3] Added data path example. --- shablona/shablona.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shablona/shablona.py b/shablona/shablona.py index 5974e5f..c5f99d4 100644 --- a/shablona/shablona.py +++ b/shablona/shablona.py @@ -3,7 +3,15 @@ from matplotlib import mlab from scipy.special import erf import scipy.optimize as opt +import os.path as op +def get_data_path(absolute = True): + """Use special attribute __file__ to return the path to the module data. + Optionally, return absolute path, as opposed to relative to the current working directory.""" + if absolute: + return op.abspath(__file__) + else: + return __file__ def transform_data(data): """ @@ -195,4 +203,4 @@ def predict(self, x): Predicted values of the dependent variable, corresponding to values of the independent variable. """ - return self.model.func(x, *self.params) \ No newline at end of file + return self.model.func(x, *self.params) From f2c52ab76cd20067b020798bf635c80110919f4e Mon Sep 17 00:00:00 2001 From: Andrew Fiore-Gartland Date: Wed, 2 Sep 2015 14:14:43 -0700 Subject: [PATCH 2/3] Updated get_data_path. --- shablona/shablona.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shablona/shablona.py b/shablona/shablona.py index c5f99d4..9dbd0f7 100644 --- a/shablona/shablona.py +++ b/shablona/shablona.py @@ -9,9 +9,9 @@ def get_data_path(absolute = True): """Use special attribute __file__ to return the path to the module data. Optionally, return absolute path, as opposed to relative to the current working directory.""" if absolute: - return op.abspath(__file__) + return op.join(op.dirname(op.abspath(__file__)),'data') else: - return __file__ + return op.join(op.dirname(__file__),'data') def transform_data(data): """ From 8a30b23b4f4d50b95bcb252feb58ca55be8c3d4f Mon Sep 17 00:00:00 2001 From: Andrew Fiore-Gartland Date: Wed, 2 Sep 2015 21:20:44 -0700 Subject: [PATCH 3/3] Added better documentation. --- shablona/shablona.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/shablona/shablona.py b/shablona/shablona.py index 9dbd0f7..2708b72 100644 --- a/shablona/shablona.py +++ b/shablona/shablona.py @@ -5,9 +5,20 @@ import scipy.optimize as opt import os.path as op -def get_data_path(absolute = True): - """Use special attribute __file__ to return the path to the module data. - Optionally, return absolute path, as opposed to relative to the current working directory.""" +def get_data_path(absolute=True): + """Use special attribute __file__ to return the path to the module data folder. + + Parameters + ---------- + absolute : bool + If True, return an absolute path, as opposed to a path + relative to the current working directory. + + Returns + ------- + data_path : str + Path to the data folder within this module.""" + if absolute: return op.join(op.dirname(op.abspath(__file__)),'data') else: