From 01a6e06a59b719e2af5258f9e3afc6ba504cf4c8 Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Fri, 29 Jan 2016 21:37:59 -0800 Subject: [PATCH] WIP: misc cleanup --- pybmpdb/dataAccess.py | 34 +++++++++++----------------------- pybmpdb/summary.py | 12 ++++++------ 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/pybmpdb/dataAccess.py b/pybmpdb/dataAccess.py index c88438e..3d6c0f8 100644 --- a/pybmpdb/dataAccess.py +++ b/pybmpdb/dataAccess.py @@ -87,49 +87,37 @@ def __init__(self, filename, dbtable=None, sqlquery=None, catanalysis=False): Parameters ---------- - filename : string CSV file or MS Access database containing the data. - dbtable : optional string (defaults to the bundled data') Table in the MS Access database storing the data for analysis. Only used if `usingdb` is True. - catanalysis : optional bool (default = False) Toggles the filtering for data that have been approved for BMP Category-level analysis Attributes ---------- - - self.dbfile : string + dbfile : string Full path to the database file. - - self.driver : string + driver : string ODBC-compliant Microsoft Access driver string. - - self.category_type : string + category_type : string See Input section. - - self.usingdb : bool + usingdb : bool See Input section. - - self.excluded_parameters : list of string or None + excluded_parameters : list of string or None See `parametersToExclude` in Input section. - - self.data : pandas DataFrame + data : pandas DataFrame DataFrame of all of the data found in the DB or CSV file. Methods ------- - - (see individual docstrings for more info): - - - self.connect - - self.redefineBMPCategory - - self.convertTablesToCSV - - self.getAllData - - self.getGroupData + connect + redefineBMPCategory + convertTablesToCSV + getAllData + getGroupData ''' self.file = filename diff --git a/pybmpdb/summary.py b/pybmpdb/summary.py index a522f65..a88bfc7 100644 --- a/pybmpdb/summary.py +++ b/pybmpdb/summary.py @@ -142,7 +142,8 @@ def getSummaryData(dbpath=None, catanalysis=False, astable=False, minstorms=3, minbmps=3, name=None, useTex=False, excludedbmps=None, excludedparams=None, **selection): - '''Select offical data from database. + """ + Select offical data from database. Parameters ---------- @@ -177,7 +178,7 @@ def getSummaryData(dbpath=None, catanalysis=False, astable=False, ------- subset : pandas.DataFrame or bmpTable - ''' + """ # main dataset if dbpath is None: @@ -216,10 +217,9 @@ def getSummaryData(dbpath=None, catanalysis=False, astable=False, # retention ponds and wetland basins. Samples of an unknown # type are excluded querytxt = ( - "(sampletype == 'composite') | (" - "(category in {}) | " - "(paramgroup == 'Biological') " - ") & (sampletype != 'unknown')" + "(sampletype == 'composite') | " + "((category in {}) | (paramgroup == 'Biological')) & " + "(sampletype != 'unknown')" ).format(grab_BMPs) subset = table.data.query(querytxt)