<commit_before>
from collections_extended.bags import _basebag, bag, frozenbag


def test_init():
	b =_basebag('abracadabra')
	assert b.count('a') == 5
	assert b.count('b') == 2
	assert b.count('r') == 2
	assert b.count('c') == 1
	assert b.count('d') == 1


def test_repr():
	ms = _basebag()
	assert ms == eval(ms.__repr__())
	ms = _basebag('abracadabra')
	assert ms == eval(ms.__repr__())


def compare_bag_string(b):
	s = str(b)
	return set(s.lstrip('{').rstrip('}').split(', '))


def test_str():
	assert str(_basebag()) == '_basebag()'
	assert "'a'^5" in str(_basebag('abracadabra'))
	assert "'b'^2" in str(_basebag('abracadabra'))
	assert "'c'" in str(_basebag('abracadabra'))
	assert compare_bag_string(bag('abracadabra')) == set(("'a'^5", "'b'^2", "'r'^2", "'c'", "'d'"))
	assert compare_bag_string(bag('abc')) == compare_bag_string(set('abc'))


def test_count():
	ms = _basebag('abracadabra')
	assert ms.count('a') == 5
	assert ms.count('x') == 0


def test_nlargest():
	assert sorted(_basebag('abracadabra').nlargest(), key=lambda e: (-e[1], e[0])) == [('a', 5), ('b', 2), ('r', 2), ('c', 1), ('d', 1)]
	assert sorted(_basebag('abracadabra').nlargest(3), key=lambda e: (-e[1], e[0])) == [('a', 5), ('b', 2), ('r', 2)]
	assert _basebag('abcaba').nlargest(3) == [('a', 3), ('b', 2), ('c', 1)]


def test_from_map():
	assert _basebag._from_map({'a': 1, 'b': 2}) == _basebag('abb')<commit_msg>Ignore test comparing bag.__str__ to set.__str__ for py2.<commit_after>
from collections_extended.bags import _basebag, bag, frozenbag, _compat


def test_init():
	b =_basebag('abracadabra')
	assert b.count('a') == 5
	assert b.count('b') == 2
	assert b.count('r') == 2
	assert b.count('c') == 1
	assert b.count('d') == 1


def test_repr():
	ms = _basebag()
	assert ms == eval(ms.__repr__())
	ms = _basebag('abracadabra')
	assert ms == eval(ms.__repr__())


def compare_bag_string(b):
	s = str(b)
	return set(s.lstrip('{').rstrip('}').split(', '))


def test_str():
	assert str(_basebag()) == '_basebag()'
	assert "'a'^5" in str(_basebag('abracadabra'))
	assert "'b'^2" in str(_basebag('abracadabra'))
	assert "'c'" in str(_basebag('abracadabra'))
	assert compare_bag_string(bag('abracadabra')) == set(("'a'^5", "'b'^2", "'r'^2", "'c'", "'d'"))
	if not _compat.is_py2:
		assert compare_bag_string(bag('abc')) == compare_bag_string(set('abc'))


def test_count():
	ms = _basebag('abracadabra')
	assert ms.count('a') == 5
	assert ms.count('x') == 0


def test_nlargest():
	assert sorted(_basebag('abracadabra').nlargest(), key=lambda e: (-e[1], e[0])) == [('a', 5), ('b', 2), ('r', 2), ('c', 1), ('d', 1)]
	assert sorted(_basebag('abracadabra').nlargest(3), key=lambda e: (-e[1], e[0])) == [('a', 5), ('b', 2), ('r', 2)]
	assert _basebag('abcaba').nlargest(3) == [('a', 3), ('b', 2), ('c', 1)]


def test_from_map():
	assert _basebag._from_map({'a': 1, 'b': 2}) == _basebag('abb')
{'fraction_non_alphanumeric': 0.2566063977746871, 'fraction_numerical': 0.022253129346314324, 'mean_word_length': 5.72196261682243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6467746', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1181, 'n_words': 264}