def test_basic_methods_MatrixPreferenceDataModel():
    #Empty Dataset
    model = MatrixPreferenceDataModel({})
    assert_equals(model.dataset, {})
    assert_array_equal(np.array([]), model.user_ids())
    assert_array_equal(np.array([]), model.item_ids())
    assert_equals(True, model.has_preference_values())
    assert_equals(0, model.users_count())
    assert_equals(0, model.items_count())
    assert_equals(-np.inf, model.maximum_preference_value())
    assert_equals(np.inf, model.minimum_preference_value())

    assert("MatrixPreferenceDataModel (0 by 0)" in model.__str__())

    #Simple DataSet
    model = MatrixPreferenceDataModel(movies)
    assert_equals(model.dataset, movies)
    assert_array_equal(np.array(['Leopoldo Pires', 'Lorena Abreu', 'Luciana Nunes',
      'Marcel Caraciolo', 'Maria Gabriela', 'Penny Frewman', 'Sheldom', 'Steve Gates']),
      model.user_ids())
    assert_array_equal(np.array(['Just My Luck', 'Lady in the Water', 'Snakes on a Plane',
               'Superman Returns', 'The Night Listener', 'You, Me and Dupree']), model.item_ids())
    assert_equals(True, model.has_preference_values())
    assert_equals(8, model.users_count())
    assert_equals(6, model.items_count())
    assert_equals(5.0, model.maximum_preference_value())
    assert_equals(1.0, model.minimum_preference_value())
    assert_equals([('Just My Luck', 3.0), ('Lady in the Water', 2.5),
             ('Snakes on a Plane', 3.5), ('Superman Returns', 3.5),
             ('The Night Listener', 3.0), ('You, Me and Dupree', 2.5)], model['Marcel Caraciolo'])
    elements = [pref  for pref in model]
    assert_array_equal([('Lady in the Water', 2.5), ('Snakes on a Plane', 3.0), \
         ('Superman Returns', 3.5), ('The Night Listener', 4.0)], elements[0][1])

    assert("MatrixPreferenceDataModel (8 by 6)" in model.__str__())

    #SampleSongs DataSet
    songs = load_sample_songs()
    model = MatrixPreferenceDataModel(songs.data)
    assert_equals(model.dataset, songs.data)
    assert_array_equal(np.array([1, 2, 3, 4, 5, 6, 7, 8]),
      model.user_ids())
    assert_array_equal(np.array([1, 2, 3, 4, 5, 6, 7, 8]), model.item_ids())
    assert_equals(True, model.has_preference_values())
    assert_equals(8, model.users_count())
    assert_equals(8, model.items_count())
    assert_equals(5.0, model.maximum_preference_value())
    assert_equals(1.0, model.minimum_preference_value())
    assert_equals([(1, 2.5), (2, 3.5), (3, 5.0), (4, 2.0), (5, 4.5), (6, 1.5), (7, 2.0)], model[1])
    elements = [pref  for pref in model]
    assert_array_equal([(1, 2.5), (2, 3.5), (3, 5.0), (4, 2.0), (5, 4.5), (6, 1.5), (7, 2.0)],
            elements[0][1])
    assert("MatrixPreferenceDataModel (8 by 8)" in model.__str__())
dataset/ETHPy150Open muricoca/crab/scikits/crab/models/tests/test_models.py/test_basic_methods_MatrixPreferenceDataModel/original