diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 0000000..75dd804 --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,29 @@ +name: Unit tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + code_style: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v2 + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: swe4s + environment-file: environment.yml + - run: pycodestyle $(git ls-files "*.py") + + unit_tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: | + cd test/unit + python -m unittest test_utils diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..16abbdc --- /dev/null +++ b/environment.yml @@ -0,0 +1,28 @@ +name: swe4s +channels: + - conda-forge +dependencies: + - _libgcc_mutex=0.1=conda_forge + - _openmp_mutex=4.5=2_gnu + - bzip2=1.0.8=h7f98852_4 + - ca-certificates=2022.9.24=ha878542_0 + - ld_impl_linux-64=2.36.1=hea4e1c9_2 + - libffi=3.4.2=h7f98852_5 + - libgcc-ng=12.1.0=h8d9b700_16 + - libgomp=12.1.0=h8d9b700_16 + - libnsl=2.0.0=h7f98852_0 + - libsqlite=3.39.4=h753d276_0 + - libuuid=2.32.1=h7f98852_1000 + - libzlib=1.2.12=h166bdaf_4 + - ncurses=6.3=h27087fc_1 + - openssl=3.0.5=h166bdaf_2 + - pip=22.2.2=pyhd8ed1ab_0 + - pycodestyle=2.9.1=pyhd8ed1ab_0 + - python=3.10.6=ha86cf86_0_cpython + - readline=8.1.2=h0f457ee_0 + - setuptools=65.4.1=pyhd8ed1ab_0 + - tk=8.6.12=h27826a3_0 + - tzdata=2022d=h191b570_0 + - wheel=0.37.1=pyhd8ed1ab_0 + - xz=5.2.6=h166bdaf_0 +prefix: /home/jovyan/.conda/envs/swe4s diff --git a/search.py b/search.py index ebf90d7..716d040 100644 --- a/search.py +++ b/search.py @@ -32,8 +32,8 @@ def main(): linear_search_total_time += toc - tic linear_search_mean_time = linear_search_total_time / args.num_searches - print('Linear search: ' \ - + '{:.5f}'.format(linear_search_mean_time) \ + print('Linear search: ' + + '{:.5f}'.format(linear_search_mean_time) + ' seconds') tic = time.perf_counter() @@ -42,8 +42,8 @@ def main(): bsearch_idx_time = toc - tic - print('Indexing: ' \ - + '{:.5f}'.format(bsearch_idx_time) \ + print('Indexing: ' + + '{:.5f}'.format(bsearch_idx_time) + ' seconds') bsearch_total_time = 0 @@ -55,11 +55,10 @@ def main(): bsearch_total_time += toc - tic bsearch_mean_time = bsearch_total_time / args.num_searches - print('Binary search: ' \ - + '{:.5f}'.format(bsearch_mean_time) \ + print('Binary search: ' + + '{:.5f}'.format(bsearch_mean_time) + ' seconds') - if __name__ == '__main__': main()