notebooks are used to test informal ideas. in this workshop, we're learn about the nearness between informal and formal tests, and the value of formal testing.
## trivia
* what python testing framework, and part of the face, is deprecated?
* what formal testing approach was introduced by tim peeters in 1999 that is recognized as literate programming?
* who is the co-author of markdown, alongside john gruber, that became a martyr for information freedom and open access?
* in usd, how big is the market for standardized testing in education?
* Jan Hendrik Schön was a german research at bell labs that studied lasers, and their
widely cited papers were deemed fraudulent. what does the acronym LASER stand for?
widely cited papers were deemed fraudulent. what does the acronym LASER stand for?
we are to focus on unit testing
## communicating units of thought
> A testing unit should focus on one tiny bit of functionality and prove it correct.
A testing unit should focus on one tiny bit of functionality and prove it correct.
https://docs.python-guide.org/writing/tests/
https://www.merriam-webster.com/dictionary/veracity
### why is veracity important?
https://en.m.wikipedia.org/wiki/Replication_crisis
https://en.m.wikipedia.org/wiki/Signified_and_signifier
#### signifier and signified in literate programming
literature survives only with language. when narrative relies solely on
language signs we suffer the arbitriness of signification.
on the other hand, literate programs rely on a metalanguages (more than one language cooperating together)
of signs in language and symbols in coded languages.
in literate programming we can mitigate some lack of clarity by
controlling what is expressed to our reader using programmatic symbols to complement language signs.
in literate programming, we have a little more control over the expression of meaning
in our work than with conventional literature. we rely on our expressions of code to
reassure our readers that we are telling the truth.
literature survives only with language. when narrative relies solely on language signs we suffer the arbitriness of signification.
on the other hand, literate programs rely on a metalanguages (more than one language cooperating together) of signs in language and symbols in coded languages. in literate programming we can mitigate some lack of clarity by controlling what is expressed to our reader using programmatic symbols to complement language signs.
in literate programming, we have a little more control over the expression of meaning in our work than with conventional literature. we rely on our expressions of code to reassure our readers that we are telling the truth.
## restart and run all
we trust a notebook that will __restart and run all__
### inside and outside the notebook
dynamic or static, inside or outside, in the kernel or at rest, there are two very different states of the
content in a notebook. notebooks, after we stop editting, remain static and at rest.
we can increase the value of our work if we can find ways to make our writing
valuable at rest.
an efficient for literate programs authors is consider their notebooks so that,
at rest, they may still provide you value.
we trust a notebook that will restart and run all
dynamic or static, inside or outside, in the kernel or at rest, there are two very different states of the content in a notebook. notebooks, after we stop editting, remain static and at rest. we can increase the value of our work if we can find ways to make our writing valuable at rest. an efficient for literate programs authors is consider their notebooks so that, at rest, they may still provide you value.
the teacher's personal preference is use the final cell for testing, i personally, use the
__name__= "__main__"
convention.
doctest
¶ # NBVAL_SKIP
if __name__ == "__main__":
import doctest
print(doctest.testmod())
TestResults(failed=0, attempted=0)
# NBVAL_SKIP
if __name__ == "__main__":
import doctest
print(doctest.testmod())
unittest
¶ # NBVAL_SKIP
if __name__ == "__main__":
import unittest
unittest.main(argv=["discover"], exit=False)
---------------------------------------------------------------------- Ran 0 tests in 0.000s OK
# NBVAL_SKIP
if __name__ == "__main__":
import unittest
unittest.main(argv=["discover"], exit=False)
nbval and pytest
¶ # NBVAL_SKIP
if __name__ == "__main__" and "pytest" not in sys.modules:
result = !pytest --nbval testing-notebooks.md.ipynb
print("\n".join(result[:10]))
============================= test session starts ============================== platform linux -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 rootdir: /home/tonyfast plugins: anyio-3.2.1, importnb-0.7.0, cov-2.12.1, nbval-0.9.6, hypothesis-6.14.1 collected 16 items testing-notebooks.md.ipynb ..FF.FF..ssssFF. [100%] =================================== FAILURES =================================== ______________________ testing-notebooks.md.ipynb::Cell 2 ______________________
# NBVAL_SKIP
if __name__ == "__main__" and "pytest" not in sys.modules:
result = !pytest --nbval testing-notebooks.md.ipynb
print("\n".join(result[:10]))
# NBVAL_SKIP
if __name__ == "__main__" and "pytest" not in sys.modules:
"convert notebook to script"
"run pytest or unittest on the script"
# NBVAL_SKIP
if __name__ == "__main__" and "pytest" not in sys.modules:
"convert notebook to script"
"run pytest or unittest on the script"
https://www.quansight.com/post/formal-interactive-notebook-testing
https://web.archive.org/web/20201111060706/https://github.com/deathbeds/LitAF
## discussion on lasting impact
* what does it mean for science to have a lasting impact?
* how does science and its literature effect language?