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

clean up camel case names #182

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wqio/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"BootstrappedFitEstimate", ["xhat", "yhat", "lower", "upper", "xlog", "ylog"]
)

__all__ = ["BCA", "percentile"]
__all__ = ["BCA", "percentile", "fit"]


def _acceleration(data):
Expand Down
12 changes: 6 additions & 6 deletions wqio/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def probplot(
ax.set_yticklabels([])

if rotateticklabels:
viz.rotateTickLabels(ax, 45, "x", ha="right")
viz.rotate_tick_labels(ax, 45, "x", ha="right")

if bestfit:
utils.fit_line()
Expand Down Expand Up @@ -868,7 +868,7 @@ def exclude(self):
def medianCIsOverlap(self):
overlap = True
if self.influent.hasData and self.effluent.hasData:
overlap = utils.checkIntervalOverlap(
overlap = utils.check_interval_overlap(
self.influent.median_conf_interval,
self.effluent.median_conf_interval,
oneway=False,
Expand Down Expand Up @@ -1302,7 +1302,7 @@ def probplot(
ax.set_ylabel(ylabel)

if rotateticklabels:
viz.rotateTickLabels(ax, 45, "x")
viz.rotate_tick_labels(ax, 45, "x")

return fig

Expand Down Expand Up @@ -1552,7 +1552,7 @@ def scatterplot(

# include the line of equality, if requested
if one2one:
viz.one2one(
viz.one2one_line(
ax,
linestyle="-",
linewidth=1.25,
Expand Down Expand Up @@ -1601,8 +1601,8 @@ def scatterplot(

ax.annotate(
r"$\log(y) = {} \, \log(x) + {}$".format(
utils.sigFigs(modelres.params[1], n=3),
utils.sigFigs(modelres.params[0], n=3),
utils.sig_figs(modelres.params[1], n=3),
utils.sig_figs(modelres.params[0], n=3),
),
(txt_x, txt_y),
xycoords="axes fraction",
Expand Down
2 changes: 1 addition & 1 deletion wqio/hydro.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __init__(
# tease out start/stop info
self.start = self.data.index[0]
self.end = self.data.index[-1]
self._season = utils.getSeason(self.start)
self._season = utils.get_season(self.start)

# storm duration (hours)
duration = self.end - self.start
Expand Down
8 changes: 7 additions & 1 deletion wqio/ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,13 @@ def ROS(
output = df[[result, censorship]].assign(final=df[result])

# normal ROS stuff
elif is_valid_to_ros(df, censorship, as_obj=False):
elif is_valid_to_ros(
df,
censorship,
max_fraction_censored=max_fraction_censored,
min_uncensored=min_uncensored,
as_obj=False,
):
output = _do_ros(
df,
result,
Expand Down
2 changes: 1 addition & 1 deletion wqio/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __init__(
self._markersize = None
self._linestyle = None
self._yfactor = None
self._season = utils.getSeason(self.starttime)
self._season = utils.get_season(self.starttime)
self.storm = storm

@property
Expand Down
8 changes: 4 additions & 4 deletions wqio/tests/test_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def test_rotateTickLabels_xaxis():
fig, ax = pyplot.subplots()
ax.set_xticks([1, 2, 3])
ax.set_xticklabels(["AAA", "BBB", "CCC"])
viz.rotateTickLabels(ax, 60, "x")
viz.rotate_tick_labels(ax, 60, "x")
return fig


Expand All @@ -614,7 +614,7 @@ def test_rotateTickLabels_yaxis():
fig, ax = pyplot.subplots()
ax.set_yticks([1, 2, 3])
ax.set_yticklabels(["AAA", "BBB", "CCC"])
viz.rotateTickLabels(ax, -30, "y")
viz.rotate_tick_labels(ax, -30, "y")
return fig


Expand All @@ -626,7 +626,7 @@ def test_rotateTickLabels_both():

ax.set_yticks([1, 2, 3])
ax.set_yticklabels(["AAA", "BBB", "CCC"])
viz.rotateTickLabels(ax, 45, "both")
viz.rotate_tick_labels(ax, 45, "both")
return fig


Expand Down Expand Up @@ -692,7 +692,7 @@ def test_one2one():
fig, ax = pyplot.subplots()
ax.set_xlim([-2, 5])
ax.set_ylim([-3, 3])
viz.one2one(ax, label="Equality", lw=5, ls="--")
viz.one2one_line(ax, label="Equality", lw=5, ls="--")
ax.legend()
return fig

Expand Down
16 changes: 8 additions & 8 deletions wqio/tests/utils_tests/test_dateutils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from datetime import datetime
import warnings
from datetime import datetime

import pytest
import pandas
import pytest

from wqio.utils import dateutils
from wqio.tests import helpers
from wqio.utils import dateutils


@pytest.mark.parametrize(
Expand All @@ -22,7 +22,7 @@
)
def test_getSeason(datemaker, datestring, expected):
date = datemaker(datestring)
season = dateutils.getSeason(date)
season = dateutils.get_season(date)
assert season == expected


Expand All @@ -45,21 +45,21 @@ def test_getSeason(datemaker, datestring, expected):
def test_makeTimestamp_basic(row, expected, error):
with warnings.catch_warnings(), helpers.raises(error):
warnings.simplefilter("always")
tstamp = dateutils.makeTimestamp(row)
tstamp = dateutils.make_timestamp(row)
assert tstamp == pandas.Timestamp(expected)


def test_makeTimestamp_customcols():
row = {"mydate": "2012-05-25", "mytime": "16:54"}
tstamp = dateutils.makeTimestamp(row, datecol="mydate", timecol="mytime")
tstamp = dateutils.make_timestamp(row, datecol="mydate", timecol="mytime")
assert tstamp == pandas.Timestamp("2012-05-25 16:54")


@pytest.mark.parametrize(
"datemaker", [pandas.Timestamp, lambda x: datetime.strptime(x, "%Y-%m-%d")]
)
@pytest.mark.parametrize("datestring", ["2005-10-02", "2006-09-02"])
def test_getWaterYear(datemaker, datestring):
def test_get_wateryear(datemaker, datestring):
date = datemaker(datestring)
wateryear = dateutils.getWaterYear(date)
wateryear = dateutils.get_wateryear(date)
assert wateryear == "2005/2006"
20 changes: 10 additions & 10 deletions wqio/tests/utils_tests/test_numutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
(numpy.inf * -1, 3, False, False, False, "NA", None),
],
)
def test_sigFigs(value, N, tex, forceint, pval, expected, error):
def test_sig_figs(value, N, tex, forceint, pval, expected, error):
with helpers.raises(error):
result = numutils.sigFigs(value, N, tex=tex, forceint=forceint, pval=pval)
result = numutils.sig_figs(value, N, tex=tex, forceint=forceint, pval=pval)
assert result == expected


Expand All @@ -58,8 +58,8 @@ def test_sigFigs(value, N, tex, forceint, pval, expected, error):
(0.00257, "=", 2, "=0.0026"),
],
)
def test_formatResult(num, qual, N, expected):
assert numutils.formatResult(num, qual, N) == expected
def test_format_result(num, qual, N, expected):
assert numutils.format_result(num, qual, N) == expected


@pytest.mark.parametrize(
Expand Down Expand Up @@ -143,7 +143,7 @@ def test_processAndersonDarlingResults(which):

expected = {"bad": "<85.0%", "good": "99.0%"}

assert numutils.processAndersonDarlingResults(ARs[which]) == expected[which]
assert numutils.process_AD_result(ARs[which]) == expected[which]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -287,7 +287,7 @@ def test_normalize_units_bad_conversion(units_norm_data):
)
def test_test_pH2concentration(pH, expected, error):
with helpers.raises(error):
assert abs(numutils.pH2concentration(pH) - expected) < 0.0001
assert abs(numutils.pH_to_concentration(pH) - expected) < 0.0001


@helpers.seed
Expand Down Expand Up @@ -501,9 +501,9 @@ def test_fit_line_with_xhat(fit_data):
)
def test_checkIntervalOverlap_single(oneway, expected):
result = [
numutils.checkIntervalOverlap([1, 2], [3, 4], oneway=oneway),
numutils.checkIntervalOverlap([1, 4], [2, 3], oneway=oneway),
numutils.checkIntervalOverlap([1, 3], [2, 4], oneway=oneway),
numutils.check_interval_overlap([1, 2], [3, 4], oneway=oneway),
numutils.check_interval_overlap([1, 4], [2, 3], oneway=oneway),
numutils.check_interval_overlap([1, 3], [2, 4], oneway=oneway),
]
assert result == expected

Expand All @@ -513,7 +513,7 @@ def test_checkIntervalOverlap(oneway, expected):
x = numpy.array([[1, 2], [1, 4], [1, 3]])
y = numpy.array([[3, 4], [2, 3], [2, 4]])
nptest.assert_array_equal(
numutils.checkIntervalOverlap(x, y, oneway=oneway, axis=1),
numutils.check_interval_overlap(x, y, oneway=oneway, axis=1),
numpy.array(expected, dtype=bool),
)

Expand Down
8 changes: 4 additions & 4 deletions wqio/utils/dateutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
_logger = logging.getLogger(__name__)


def getSeason(date):
def get_season(date):
"""Defines the season from a given date.

Parameters
Expand Down Expand Up @@ -50,7 +50,7 @@ def getSeason(date):
return season


def makeTimestamp(row, datecol="sampledate", timecol="sampletime", issuewarnings=False):
def make_timestamp(row, datecol="sampledate", timecol="sampletime", issuewarnings=False):
"""Makes a pandas.Timestamp from separate date/time columns

Parameters
Expand Down Expand Up @@ -114,7 +114,7 @@ def makeTimestamp(row, datecol="sampledate", timecol="sampletime", issuewarnings
return tstamp


def getWaterYear(date):
def get_wateryear(date):
"""Returns the water year of a given date

Parameters
Expand All @@ -132,7 +132,7 @@ def getWaterYear(date):
>>> import datetime
>>> import wqio
>>> x = datetime.datetime(2005, 11, 2)
>>> print(wqio.utils.getWaterYear(x))
>>> print(wqio.utils.get_wateryear(x))
2005/2006

"""
Expand Down
26 changes: 13 additions & 13 deletions wqio/utils/numutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
TheilStats = namedtuple("TheilStats", ("slope", "intercept", "low_slope", "high_slope"))


def sigFigs(x, n, expthresh=5, tex=False, pval=False, forceint=False):
def sig_figs(x, n, expthresh=5, tex=False, pval=False, forceint=False):
"""Formats a number with the correct number of sig figs.

Parameters
Expand Down Expand Up @@ -41,10 +41,10 @@ def sigFigs(x, n, expthresh=5, tex=False, pval=False, forceint=False):

Examples
--------
>>> print(sigFigs(1247.15, 3))
>>> print(sig_figs(1247.15, 3))
1,250

>>> print(sigFigs(1247.15, 7))
>>> print(sig_figs(1247.15, 7))
1,247.150

"""
Expand All @@ -54,7 +54,7 @@ def sigFigs(x, n, expthresh=5, tex=False, pval=False, forceint=False):

# check on the number provided
elif x is not None and not numpy.isinf(x) and not numpy.isnan(x):
# check on the sigFigs
# check on the sig_figs
if n < 1:
raise ValueError("number of sig figs must be greater than zero!")

Expand Down Expand Up @@ -99,7 +99,7 @@ def sigFigs(x, n, expthresh=5, tex=False, pval=False, forceint=False):
return out


def formatResult(result, qualifier, sigfigs=3):
def format_result(result, qualifier, sigfigs=3):
"""Formats a results with its qualifier

Parameters
Expand All @@ -118,12 +118,12 @@ def formatResult(result, qualifier, sigfigs=3):

Example
-------
>>> formatResult(1.23, '<', sigfigs=4)
>>> format_result(1.23, '<', sigfigs=4)
'<1.230'

"""

return f"{qualifier}{sigFigs(result, sigfigs)}"
return f"{qualifier}{sig_figs(result, sigfigs)}"


def process_p_vals(pval):
Expand All @@ -145,7 +145,7 @@ def process_p_vals(pval):
if pval is None:
out = "NA"
elif 0 < pval < 0.001:
out = formatResult(0.001, "<", sigfigs=1)
out = format_result(0.001, "<", sigfigs=1)
elif pval > 1 or pval < 0:
raise ValueError(f"p-values must be between 0 and 1 (not {pval})")
else:
Expand Down Expand Up @@ -220,7 +220,7 @@ def anderson_darling(data):
return ADResult(**values)


def processAndersonDarlingResults(ad_results):
def process_AD_result(ad_result):
"""Return a nice string of Anderson-Darling test results

Parameters
Expand All @@ -235,7 +235,7 @@ def processAndersonDarlingResults(ad_results):

"""

AD, crit, sig = ad_results
AD, crit, sig = ad_result
try:
ci = 100 - sig[crit < AD][-1]
return f"{ci:0.1f}%"
Expand Down Expand Up @@ -355,7 +355,7 @@ def normalize_units(
return normalized


def pH2concentration(pH, *args):
def pH_to_concentration(pH, *args):
"""Converts pH values to proton concentrations in mg/L

Parameters
Expand Down Expand Up @@ -528,7 +528,7 @@ def fit_line(x, y, xhat=None, fitprobs=None, fitlogs=None, dist=None, through_or
return xhat, yhat, results


def checkIntervalOverlap(interval1, interval2, oneway=False, axis=None):
def check_interval_overlap(interval1, interval2, oneway=False, axis=None):
"""Checks if two numeric intervals overlaps.

Parameters
Expand Down Expand Up @@ -560,7 +560,7 @@ def checkIntervalOverlap(interval1, interval2, oneway=False, axis=None):
if oneway:
return first_check
else:
return first_check | checkIntervalOverlap(interval2, interval1, oneway=True, axis=axis)
return first_check | check_interval_overlap(interval2, interval1, oneway=True, axis=axis)


def winsorize_dataframe(df, **limits):
Expand Down
Loading
Loading