Skip to content

Commit

Permalink
Merge pull request #71 from phobson/minor-cleanup
Browse files Browse the repository at this point in the history
Minor cleanup of easily removed deprecated items
  • Loading branch information
phobson committed Oct 22, 2015
2 parents 1ed10fb + 43f501f commit 43da4d7
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 108 deletions.
12 changes: 6 additions & 6 deletions .travis_coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ omit =

# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain if tests don't hit defensive assertion code:
def __repr__
if self.debug:
if settings.DEBUG
raise AssertionError
raise NotImplementedError
except NotImplementedError
# Ignore pass
pass
if 0:
if __name__ == .__main__.:
14 changes: 7 additions & 7 deletions wqio/algo/ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


@np.deprecate(message="algo.ros is deprectated. use algo.robustros instead.")
def rosSort(dataframe, rescol='res', qualcol='qual', ndsymbol='ND'):
def rosSort(dataframe, rescol='res', qualcol='qual', ndsymbol='ND'): # pragma: no cover
""" Prepare a dataframe for ROS. It sorts ascending with non-detects
on top. So something like this:
[2, 4, 4, 10, 3, 5, 6, 10, 12, 40, 78, 120]
Expand Down Expand Up @@ -53,7 +53,7 @@ def rosSort(dataframe, rescol='res', qualcol='qual', ndsymbol='ND'):
return ros_data #.reset_index(drop=True)

@np.deprecate(message="algo.ros is deprectated. use algo.robustros instead.")
class MR(object):
class MR(object): # pragma: no cover
""" Censored data analysis via regression on order statistics (ROS)
This class implements the MR method outlined Hirsch and Stedinger
Expand Down Expand Up @@ -111,7 +111,7 @@ class MR(object):
"""

def __init__(self, data, rescol='res', qualcol='qual', finalcol='final_data',
ndsymbol='ND', fitlogs=True, dist='norm'):
ndsymbol='ND', fitlogs=True, dist='norm'): # pragma: no cover

self.rescol = rescol
self.qualcol = qualcol
Expand Down Expand Up @@ -184,7 +184,7 @@ def _ros_DL_index(row):
# select out only the necessary columns for data
self.data = self.data[[self.finalcol, self.rescol, self.qualcol]]

def cohn(self):
def cohn(self): # pragma: no cover
""" Creates a DataFrame of the unique detection limits in the
dataset and the other Cohn numbers (A, B, C).
"""
Expand Down Expand Up @@ -269,7 +269,7 @@ def _C(row):

return DLs

def _ros_ranks(self):
def _ros_ranks(self): # pragma: no cover
""" Determine the ranks of the data according to the following
logic:
1) rank[n] = rank[n-1] + 1 when:
Expand Down Expand Up @@ -315,7 +315,7 @@ def avgrank(r):

self.data['Avg Ranks'] = self.data.apply(avgrank, axis=1)

def estimator(self):
def estimator(self): # pragma: no cover
""" Estimates the values of the censored data """

def _ros_plotting_pos(row):
Expand Down Expand Up @@ -407,7 +407,7 @@ def _select_half_DLs(row):

return self.data

def plot(self, filename):
def plot(self, filename): # pragma: no cover
""" Makes a simple plot showing the original and modeled data
Parameters
Expand Down
55 changes: 0 additions & 55 deletions wqio/core/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@
}


def sanitizeTexParam(x):
return x


def sanitizeTexUnit(x):
return x


class Parameter(object):
def __init__(self, name, units, usingTex=False):
""" Class representing a single analytical parameter (pollutant).
Expand Down Expand Up @@ -102,10 +94,6 @@ def paramunit(self, usecomma=False):
else:
paramunit = '{0} ({1})'

#if self.usingTex:
# n = sanitizeTexParam(self.name)
# u = sanitizeTexUnit(self.units)
#else:
n = self.name
u = self.units

Expand Down Expand Up @@ -282,11 +270,6 @@ def dataframe(self):
self._dataframe = df[[self.rescol, self.cencol]]
return self._dataframe

@property
@np.deprecate
def filtered_data(self):
return self.dataframe

@property
@np.deprecate
def full_data(self):
Expand Down Expand Up @@ -883,44 +866,6 @@ def verticalScatter(self, ax=None, pos=1, jitter=0.4, alpha=0.75,

return fig

# other methods
@np.deprecate
def applyFilter(self, filterfxn, **fxnkwargs):
""" Filter the dataset and set the `include`/`exclude`
properties based on a user-defined function.
Warning
-------
This is very advanced functionality. Proceed with caution and
ask for help.
Parameters
----------
filterfxn : callable
A user defined function that filters the data and determines
if the `include` attribute should be True or False. It *must*
return a pandas.DataFrame and a bool (in that order), or an
error will be raised. The `filterfxn` must accept the
`Location.data` attribute as its first argument.
**fxnkwargs : keyword arguments
Optional named arguments pass to `filterfxn`.
Returns
-------
None
"""

newdata, include = filterfxn(self.full_data, **fxnkwargs)
if not isinstance(newdata, pandas.DataFrame):
raise ValueError ('first item returned by filterfxn must be a pandas.DataFrame')

if not isinstance(include, bool):
raise ValueError ('second item returned by filterfxn must be a bool')

self.include = include


class Dataset(object):
""" Dataset: object for comparings two Location objects
Expand Down
32 changes: 9 additions & 23 deletions wqio/testing/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,11 @@ def assert_timestamp_equal(x, y):
nptest.assert_equal(x.strftime('%x %X'), y.strftime('%x %X'))


def setup_prefix(folder):
for imgdir in ['baseline_images', 'result_images']:
subdir = os.path.join('.', imgdir)
subsubdir = os.path.join(subdir, folder)

if not os.path.exists(subdir):
os.mkdir(subdir)

if not os.path.exists(subsubdir):
os.mkdir(subsubdir)

return subsubdir


def fail(message):
def fail(message): # pragma: no cover
raise AssertionError(message)


def wip(f):
def wip(f): # pragma: no cover
@wraps(f)
def run_test(*args, **kwargs):
try:
Expand All @@ -74,7 +60,7 @@ def run_test(*args, **kwargs):
return attr('wip')(run_test)


def compare_versions(utility='latex'):
def compare_versions(utility='latex'): # pragma: no cover
"return True if a is greater than or equal to b"
requirements = {
'latex': '3.1415'
Expand All @@ -97,12 +83,12 @@ def compare_versions(utility='latex'):
return False


def _show_package_info(package, name):
def _show_package_info(package, name): # pragma: no cover
packagedir = os.path.dirname(package.__file__)
print("%s version %s is installed in %s" % (name, package.__version__, packagedir))


def _show_system_info():
def _show_system_info(): # pragma: no cover
import nose

pyversion = sys.version.replace('\n','')
Expand All @@ -125,7 +111,7 @@ def _show_system_info():
_show_package_info(pandas, 'pandas')


class NoseWrapper(nptest.Tester):
class NoseWrapper(nptest.Tester): # pragma: no cover
'''
This is simply a monkey patch for numpy.testing.Tester.
Expand Down Expand Up @@ -188,13 +174,13 @@ def ascii(s): return bytes(s, 'ascii')

def byte2str(b): return b.decode('ascii')

else:
else: # pragma: no cover
ascii = str

def byte2str(b): return b


def checkdep_tex():
def checkdep_tex(): # pragma: no cover
try:
s = subprocess.Popen(['tex','-version'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Expand All @@ -207,7 +193,7 @@ def checkdep_tex():
return None


def assert_bigstring_equal(input_string, known_string, input_out, known_out):
def assert_bigstring_equal(input_string, known_string, input_out, known_out): # pragma: no cover
try:
nt.assert_equal(input_string, known_string)
except:
Expand Down
1 change: 0 additions & 1 deletion wqio/tests/core_tests/features_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import numpy.testing as nptest

from wqio import testing
from wqio.testing.testutils import setup_prefix
usetex = testing.compare_versions(utility='latex')

import matplotlib
Expand Down
2 changes: 1 addition & 1 deletion wqio/tests/core_tests/hydro_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pandas.util.testing as pdtest

from wqio import testing
from wqio.testing.testutils import assert_timestamp_equal, setup_prefix
from wqio.testing.testutils import assert_timestamp_equal
usetex = testing.compare_versions(utility='latex')

import matplotlib
Expand Down
2 changes: 1 addition & 1 deletion wqio/tests/core_tests/samples_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pandas.util.testing as pdtest

from wqio import testing
from wqio.testing.testutils import assert_timestamp_equal, setup_prefix
from wqio.testing.testutils import assert_timestamp_equal
usetex = testing.compare_versions(utility='latex')

import matplotlib
Expand Down
25 changes: 13 additions & 12 deletions wqio/tests/utils_tests/misc_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,31 @@ def test_stringify_None(self):


class test_uniqueIndex(object):
def setup():
def setup(self):
dates = range(5)
params = list('ABCDE')
locations = ['Inflow', 'Outflow']
dual = []
for d in dates:
for p in params:
for loc in locations:
dual.append([d,p,loc])

dual_array = np.array(dual)
index = pandas.MultiIndex.from_arrays([dual_array[:,0],
dual_array[:,1],
dual_array[:,2]])
dual_array[:,1],
dual_array[:,2]])
index.names = ['date', 'param', 'loc']

self.data = pandas.DataFrame(np.range.normal(size=len(index)), index=index)
self.data = pandas.DataFrame(np.random.normal(size=len(index)), index=index)

def test_getUniqueDataframeIndexVal():
test = misc.getUniqueDataframeIndexVal(self.data.select(lambda x: x[0]=='0'), 'date')
known = '0'
nt.assert_equal(test, known)
def test_getUniqueDataframeIndexVal(self):
test = misc.getUniqueDataframeIndexVal(self.data.select(lambda x: x[0]=='0'), 'date')
known = '0'
nt.assert_equal(test, known)

@nptest.raises(ValueError)
def test_getUniqueDataframeIndexVal_error():
misc.getUniqueDataframeIndexVal(self.data, 'date')
@nptest.raises(ValueError)
def test_getUniqueDataframeIndexVal_error(self):
misc.getUniqueDataframeIndexVal(self.data, 'date')


class test_redefineIndexLevel(object):
Expand Down
3 changes: 1 addition & 2 deletions wqio/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ def stringify(value, fmt, attribute=None):
return fmt % quantity



class ProgressBar:
class ProgressBar: # pragma: no cover
def __init__(self, sequence, width=50, labels=None, labelfxn=None):
'''Progress bar for notebookes:
Expand Down

0 comments on commit 43da4d7

Please sign in to comment.