Miscellaneous stuff from NIST internship (2016) As of now, this just contains the mM problem and its related unit tests.
This code goes line by line through the input file, going character by character through each line. The code writes characters to the named output file.tmp, and then moves the .tmp to the given name.
for line in mM_file:
for char in line:
if char == "m":
out_file.write("M".encode("utf-8"))
elif char == "M":
out_file.write("m".encode("utf-8"))
else:
out_file.write(char.encode("utf-8"))
To use this code, clone the repository and run the code using Python 2.6. This code may work with other versions of Python 2, but this is not tested.
Code comments should be enough for such a small project. If you want more explanations, mark it as an issue.
The current tests for this are located at src/[subproject]/[subproject]_test.py
. For example, the mM problem tests are
at src/mM/mM_test.py
. The input and output files are generated by this program and are stored in
data/[subproject]/testfiles
. For example, for mM, they are at data/mM/testfiles
.
To run the tests, just run the test py file. This will go through the tests, and give an AssertionError if it fails. To add more tests, just add them to the corresponding test py file,
If someone wants to contribute to this for whatever reason (really, why would you do this), just submit a pull request.
GPL 3.0