can we measure learning?

What follows is an exercise in measuring learning. It is somewhat philosophical in its meaning but 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.sh with learning as the name of the project

    ./makePythonTdd.sh learning
    

    on Windows without `Windows Subsystem Linux`_ use makePythonTdd.ps1

    ./makePythonTdd.ps1 learning
    

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

    E       AssertionError: True is not false
    
    tests/test_learning.py:7: AssertionError
    
  • I hold ctrl (windows/linux) or option (mac) on the keyboard and use the mouse to click on tests/test_learning.py:7 to open it in the editor

  • then change True to False to make the test pass

  • and 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_learning_model_when_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_learning_model_when_expectations_equal_reality(self):
            expectations = self.reality
    
            self.assertGreater(
                src.learning.model(expectations, self.reality),
                expectations,
                'When expectations equal reality, increase expectations'
            )
    
        def test_learning_model_when_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 Encountered
    # AssertionError
    
  • the terminal 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, then you have what you need to solve these problems

Please send me your solutions. I would love to see them