Skip to content

Commit

Permalink
Fix interactions tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejkula committed Jul 6, 2017
1 parent 70e4d7f commit 20f0c82
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions tests/test_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _test_final_column_no_padding(sequences):
assert np.all(sequences[:, -1] > 0)


def _test_shifted(sequences, targets):
def _test_shifted(sequences):
"""
Unless there was a change of user, row i + 1's interactions
should contain row i's interactions shifted to the right by
Expand All @@ -38,9 +38,6 @@ def _test_shifted(sequences, targets):
# are padding.
continue

# The last element of the previous sequence
# is this sequence's target.
assert sequences[i - 1][-1] == targets[i]
assert np.all(sequences[i][1:] == sequences[i - 1][:-1])


Expand Down Expand Up @@ -78,17 +75,12 @@ def test_to_sequence(max_sequence_length):
sequences = interactions.to_sequence(
max_sequence_length=max_sequence_length)

assert sequences.sequences.shape == (len(interactions) -
len(np.unique(interactions.user_ids)),
min(max_sequence_length,
(interactions
.tocsr()
.getnnz(axis=1).max())))
assert sequences.sequences.shape == (len(interactions),
max_sequence_length)

_test_just_padding(sequences.sequences)
_test_final_column_no_padding(sequences.sequences)
_test_shifted(sequences.sequences,
sequences.targets)
_test_shifted(sequences.sequences)
_test_temporal_order(sequences.user_ids,
sequences.sequences,
interactions)

0 comments on commit 20f0c82

Please sign in to comment.