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
learningas the name of the project./makePythonTdd.sh learningAttention
on Windows without Windows Subsystem for Linux use makePythonTdd.ps1 instead of makePythonTdd.sh
./makePythonTdd.ps1 learningit 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: AssertionErrorI hold ctrl (Windows/Linux) or option/command (MacOS) on the keyboard and use the mouse to click on
tests/test_learning.py:7to open it in the editorthen I change True to False in the assertion
7 self.assertFalse(False)the test passes
I change the text in
test_learning.pywithimport 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 seen # AssertionErrorthe 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 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 leave a 5 star review. It helps other people get into the book too