<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from runner.koan import *


class AboutSets(Koan):
    def test_sets_make_keep_lists_unique(self):
        highlanders = ['MacLeod', 'Ramirez', 'MacLeod', 'Matunas',
            'MacLeod', 'Malcolm', 'MacLeod']
        
        there_can_only_be_only_one = set(highlanders)

        self.assertEqual(__, there_can_only_be_only_one)

    def test_sets_are_unordered(self):
        self.assertEqual(set([__, __, __, __, __]), set('12345'))
        
    def test_convert_the_set_into_a_list_to_sort_it(self):
        self.assertEqual(__, sorted(set('13245')))
        
    # ------------------------------------------------------------------

    def chars_in(self, a_set):
        return ''.join(sorted(a_set))

    def test_set_have_arithmetic_operators(self):
        good_guy = set('macleod')
        bad_guy = set('mutunas')
        
        self.assertEqual(__, self.chars_in(good_guy - bad_guy))
        self.assertEqual(__, self.chars_in(good_guy | bad_guy))
        self.assertEqual(__, self.chars_in(good_guy & bad_guy))
        self.assertEqual(__, self.chars_in(good_guy ^ bad_guy))

    # ------------------------------------------------------------------

    def test_we_can_query_set_membership(self):
        self.assertEqual(__, 127 in set([127, 0, 0, 1]))
        self.assertEqual(__, 'cow' not in set('apocalypse now'))
        
    def test_we_can_compare_subsets(self):
        self.assertEqual(__, set('cake') <= set('cherry cake'))
        self.assertEqual(__, set('cake').issubset(set('cherry cake')))
        
        self.assertEqual(__, set('cake') > set('pie'))<commit_msg>Change sets for set operators to be more intuitive<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from runner.koan import *


class AboutSets(Koan):
    def test_sets_make_keep_lists_unique(self):
        highlanders = ['MacLeod', 'Ramirez', 'MacLeod', 'Matunas',
            'MacLeod', 'Malcolm', 'MacLeod']
        
        there_can_only_be_only_one = set(highlanders)

        self.assertEqual(__, there_can_only_be_only_one)

    def test_sets_are_unordered(self):
        self.assertEqual(set([__, __, __, __, __]), set('12345'))
        
    def test_convert_the_set_into_a_list_to_sort_it(self):
        self.assertEqual(__, sorted(set('13245')))
        
    # ------------------------------------------------------------------

    def test_set_have_arithmetic_operators(self):
        scotsmen = set(["MacLeod","Wallace","Willie"])
        warriors = set(["MacLeod", "Wallace", "Leonidas"])

        self.assertEqual(__, scotsmen - warriors)
        self.assertEqual(__, scotsmen | warriors)
        self.assertEqual(__, scotsmen & warriors)
        self.assertEqual(__, scotsmen ^ warriors)

    # ------------------------------------------------------------------

    def test_we_can_query_set_membership(self):
        self.assertEqual(__, 127 in set([127, 0, 0, 1]))
        self.assertEqual(__, 'cow' not in set('apocalypse now'))
        
    def test_we_can_compare_subsets(self):
        self.assertEqual(__, set('cake') <= set('cherry cake'))
        self.assertEqual(__, set('cake').issubset(set('cherry cake')))
        
        self.assertEqual(__, set('cake') > set('pie'))
{'fraction_non_alphanumeric': 0.2093520782396088, 'fraction_numerical': 0.012224938875305624, 'mean_word_length': 2.279559118236473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4483256', 'n_tokens_mistral': 1065, 'n_tokens_neox': 988, 'n_words': 166}