Skip to content

Commit

Permalink
fixing naming on _count in analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
wino6687 committed Feb 12, 2020
1 parent b0bf997 commit 5705da2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions swepy/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def create_year_splits(self):
year_splits[-1] = np.shape(self.swe)[0]
return year_splits

def __count_melt(self, swe): # RENAME __COUNT
def _count_melt(self, swe): # RENAME __COUNT
"""
Count the date that each pixel reaches zero for first time of season on a given date.
Useful for comparison between years of a given region.
Expand Down Expand Up @@ -122,7 +122,7 @@ def count_melt_onset(self): # RENAME, get rid of mp
cpus = cpu_count()
swe_parts = np.array_split(self.swe, cpus, axis=2)
with Pool(cpus) as p:
parts = p.map(self.__count_melt, swe_parts)
parts = p.map(self._count_melt, swe_parts)
df = parts[0] # recombine parts
for i in range(1, len(parts)):
df["count"] = df["count"].add(parts[i]["count"])
Expand Down
6 changes: 3 additions & 3 deletions swepy/tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_display_melt():
"""
swe = np.zeros((3000, 50, 50))
a = analysis.Analysis(datetime.date(1993, 1, 1), swe)
melt = a.melt_date_year(a.__count_melt())
melt = a.melt_date_year(a._count_melt())
fig = a.display_melt_onset_change(melt, 1993, 1995, True)
assert type(fig) == matplotlib.figure.Figure

Expand All @@ -159,7 +159,7 @@ def test_display_melt_fail1():
"""
swe = np.zeros((3000, 50, 50))
a = analysis.Analysis(datetime.date(1993, 1, 1), swe)
melt = a.melt_date_year(a.__count_melt())
melt = a.melt_date_year(a._count_melt())
with pytest.raises(Exception):
a.display_melt_onset_change(melt, 1944, 1993)

Expand All @@ -170,7 +170,7 @@ def test_display_melt_fail2():
"""
swe = np.zeros((3000, 50, 50))
a = analysis.Analysis(datetime.date(1993, 1, 1), swe)
melt = a.melt_date_year(a.__count_melt())
melt = a.melt_date_year(a._count_melt())
with pytest.raises(Exception):
a.display_melt_onset_change(melt, 1993, 1944)

Expand Down
2 changes: 1 addition & 1 deletion swepy/tests/test_downsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def swe():

def test_tuple_block_fail(swe):
with pytest.raises(TypeError):
downsample.downsample(swe, [1, 2, 2], np.mean)
downsample.downsample(swe, ([1, 2, 2]), np.mean)

0 comments on commit 5705da2

Please sign in to comment.