Skip to content

Commit

Permalink
deprecations and test corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
kavvkon committed Feb 5, 2020
1 parent 45f0bc9 commit 0c8c0c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions enlopy/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import datetime as dt
import logging

import numpy as np
import pandas as pd
import logging

__all__ = ['make_timeseries', 'clean_convert']

Expand All @@ -21,8 +23,8 @@ def make_timeseries(x=None, year=None, length=None, startdate=None, freq=None):
if startdate is None:
if year is None:
logging.info('No info on the year was provided. Using current year')
year = pd.datetime.now().year
startdate = pd.datetime(year, 1, 1, 0, 0, 0)
year = dt.datetime.now().year
startdate = dt.datetime(year, 1, 1, 0, 0, 0)

if x is None:
if length is None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ def test_reshape_timeseries():

def test_reshape_multiannual():
a = np.random.rand(8760*2)
a = make_timeseries(a, freq='h')
a = make_timeseries(a, year=2019, freq='h')
b = reshape_timeseries(a, x='dayofyear', y='hour', aggfunc='sum')
assert b.shape == (24,365)
assert np.isclose(b.sum().sum(), a.sum())

def test_reshape_multiannual_dataframe():
a = np.random.rand(8760*2)
a = pd.DataFrame(make_timeseries(a, freq='h'))
a = pd.DataFrame(make_timeseries(a, year=2019, freq='h'))
b = reshape_timeseries(a, x='dayofyear', y='hour', aggfunc='sum')
assert b.shape == (24,365)
assert np.isclose(b.sum().sum(), a.sum())
Expand Down

0 comments on commit 0c8c0c9

Please sign in to comment.