Skip to content

Commit

Permalink
OWFeatureStatistics: Use valid timestamps in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlin-policar committed Oct 28, 2018
1 parent 242dd0f commit deb1a0f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Orange/widgets/data/tests/test_owfeaturestatistics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from collections import namedtuple
from functools import wraps, partial
from itertools import chain
Expand Down Expand Up @@ -91,22 +92,29 @@

discrete = list(chain(rgb, ints))

# Time variable variations

def _to_timestamps(years):
return [datetime.datetime(year, 1, 1).timestamp() if not np.isnan(year)
else np.nan for year in years]


# Time variable variations, windows timestamps need to be valid timestamps so
# we'll just fill it in with arbitrary years
time_full = VarDataPair(
TimeVariable('time_full'),
np.array([0, 1, 2, 3, 4], dtype=float),
np.array(_to_timestamps([2000, 2001, 2002, 2003, 2004]), dtype=float),
)
time_missing = VarDataPair(
TimeVariable('time_missing'),
np.array([0, np.nan, 2, 3, 4], dtype=float),
np.array(_to_timestamps([2000, np.nan, 2001, 2003, 2004]), dtype=float),
)
time_all_missing = VarDataPair(
TimeVariable('time_all_missing'),
np.array([np.nan] * 5, dtype=float),
np.array(_to_timestamps([np.nan] * 5), dtype=float),
)
time_same = VarDataPair(
TimeVariable('time_same'),
np.array([4] * 5, dtype=float),
np.array(_to_timestamps([2004] * 5), dtype=float),
)
time = [
time_full, time_missing, time_all_missing, time_same
Expand Down

0 comments on commit deb1a0f

Please sign in to comment.