can we measure learning?

What follows is an exercise in measuring learning. It is somewhat philosophical in its meaning and arithmetic in its representation. I am curious to know what you think and what solutions you come up with

An Infinite Learning Model

RED: make it fail


  • I open a terminal to run makePythonTdd with learning as the name of the project

    ./makePythonTdd.sh learning
    

    Note

    on Windows without Windows Subsystem for Linux use makePythonTdd instead of makePythonTdd

    .\makePythonTdd.ps1 learning
    

    it makes the folders and files that are needed, installs packages, runs the first test, and the terminal is my friend, and shows AssertionError

    E       AssertionError: True is not false
    
    tests/test_learning.py:7: AssertionError
    
  • I hold ctrl (Windows/Linux) or option/command (MacOS) on the keyboard and use the mouse to click on tests/test_learning.py:7 to put the cursor on line 7

  • I change True to False in the assertion

    7        self.assertFalse(False)
    

    the test passes.

  • I change the text in test_learning.py with

    import random
    import src.learning
    import unittest
    
    
    class TestInfiniteLearningModel(unittest.TestCase):
    
        def setUp(self):
            self.reality = random.randint(-10**100, 10**100)
    
        def test_expectations_are_less_than_reality(self):
            expectations = self.reality - 1
    
            self.assertGreater(
                src.learning.model(expectations, self.reality),
                self.reality,
                (
                    'When expectations are less than reality, '
                    'increase expectations '
                    'until they are greater than reality'
                )
            )
    
        def test_expectations_equal_reality(self):
            expectations = self.reality
    
            self.assertGreater(
                src.learning.model(expectations, self.reality),
                expectations,
                'When expectations equal reality, '
                'increase expectations'
            )
    
        def test_expectations_are_greater_than_reality(self):
            expectations = self.reality + 1
    
            self.assertGreater(
                src.learning.model(expectations, self.reality),
                expectations,
                (
                    'When expectations are greater than reality, '
                    'increase reality '
                    'until it is greater than expectations'
                )
            )
    
    
    # Exceptions seen
    # AssertionError
    
  • the terminal is my friend, and shows AttributeError

    AttributeError: module 'src.learning' has no attribute 'model'
    

GREEN: make it pass


If you’ve gone through any of the other exercises in this book, then you have what you need to solve these problems

I would love to see your solutions, please send them to jacobitegboje@gmail.com


rate pumping python

If this has been a 7 star experience for you, please CLICK HERE to leave a 5 star review of pumping python. It helps other people get into the book too.