You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -626,12 +631,12 @@ <h2>Test code<a class="headerlink" href="#test-code" title="Link to this heading
626
631
<h3>Functional test<aclass="headerlink" href="#functional-test" title="Link to this heading">#</a></h3>
627
632
<p>You will want to test your code like a <em>user</em> would do: import the function, execute it on some input data, and examine whether the results are correct. You may install additional software such as <aclass="reference external" href="https://jupyter.org/">Jupyter</a> in the same conda environment to make the testing process convenient and pleasant. There is no need to reinstall the modified scikit-bio package in a separate environment in order to test. As soon as you edit the code, the changes will immediately reflect when you use the code.</p>
628
633
<p>For example, you wrote a function <codeclass="docutils literal notranslate"><spanclass="pre">gc_content</span></code>, which calculates the fraction of <codeclass="docutils literal notranslate"><spanclass="pre">G</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">C</span></code> in a nucleotide sequence:</p>
<p>You added this function to the code file <codeclass="docutils literal notranslate"><spanclass="pre">skbio/sequence/nucl.py</span></code>. It will be available for use in any Python code launched in the same conda environment:</p>
<p>Now test the function on some data. For example, you would expect that <codeclass="docutils literal notranslate"><spanclass="pre">gc_content("ACGT")</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">gc_content("GGATCCGC")</span></code> return 0.5 and 0.75, respectively. Is that the case?</p>
@@ -641,7 +646,7 @@ <h3>Functional test<a class="headerlink" href="#functional-test" title="Link to
641
646
<h3>Unit test<aclass="headerlink" href="#unit-test" title="Link to this heading">#</a></h3>
642
647
<p><aclass="reference external" href="https://en.wikipedia.org/wiki/Unit_testing">Unit testing</a> involves testing the smallest units of your code, such as classes, functions, and methods, to ensure they function correctly in isolation. It is a fundamental best practice in software engineering, but is often overlooked by beginners. Unit testing is made easier by writing test code alongside the algorithm code. Both types of code are integrated into the scikit-bio codebase. This test code is then regularly executed whenever changes are made to ensure that the intended behavior remains consistent over time.</p>
643
648
<p>For example, the test code for the <codeclass="docutils literal notranslate"><spanclass="pre">gc_content</span></code> may live in <codeclass="docutils literal notranslate"><spanclass="pre">skbio/sequence/tests/test_nucl.py</span></code>, under class <codeclass="docutils literal notranslate"><spanclass="pre">TestNucl</span></code>, as a method <codeclass="docutils literal notranslate"><spanclass="pre">test_gc_content</span></code>. It may read like:</p>
@@ -699,7 +704,7 @@ <h3>Comments<a class="headerlink" href="#comments" title="Link to this heading">
699
704
<h3>Docstrings<aclass="headerlink" href="#docstrings" title="Link to this heading">#</a></h3>
700
705
<p><aclass="reference external" href="https://en.wikipedia.org/wiki/Docstring">Docstrings</a> are structured text blocks associated with each unit of the code that detail the usage of the code. Docstrings will be rendered to the software documentation. That is, <em>users</em> (not just developers) will read them. Therefore, docstrings are critical if you want your code to be used, and in the correct way.</p>
701
706
<p>Below is a very simple example for the <codeclass="docutils literal notranslate"><spanclass="pre">gc_content</span></code>. The lines between the triple double quotes (<codeclass="docutils literal notranslate"><spanclass="pre">"""</span></code>) are the docstring:</p>
0 commit comments