<jupyter_start><jupyter_text>Defensive programming (2)   We have seen the basic idea that we can insert   assert statments into code, to check that the    results are what we expect, but how can we test   software more fully? Can doing this help us    avoid bugs in the first place?      One possible approach is **test driven development**.   Many people think this reduces the number of bugs in    software as it is written, but evidence for this in the    sciences is somewhat limited as it is not always easy    to say what the right answer should be before writing the   software. Having said that, the tests involved in test   driven development are certanly useful even if some of   them are written after the software.      We will look at a new (and quite difficult) problem,    finding the overlap between ranges of numbers. For    example, these could be the dates that different    sensors were running, and you need to find the    date ranges where all sensors recorded data before   running further analysis.  Start off by imagining you have a working function `range_overlap` that takesa list of tuples. Write some assert statments that would check if the answer from thisfunction is correct. Put these in a function. Think of different cases and about edge cases (which may show a subtle bug).<jupyter_code>def test_range_overlap():<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.031204644412191583, 'fraction_numerical': 0.000725689404934688, 'mean_word_length': 3.996376811594203, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '398882', 'license': 'MIT', 'n_tokens_mistral': 314, 'n_tokens_neox': 313, 'n_words': 213, 'path': 'DefensiveProgramming_2.ipynb', 'repo_name': 'andreww/end_of_day_two', 'size': '1378'}