diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml deleted file mode 100644 index f39f5dbe..00000000 --- a/.github/workflows/ci-lint.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Run black - -on: [push] - -jobs: - formatting: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.8] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install black - - name: Run black - run: | - black pyreisejl --check --diff diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..c5885097 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,21 @@ +name: Lint + +on: push + +jobs: + formatting: + if: "!contains(github.event.head_commit.message, 'skip_ci')" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - run: python -m pip install --upgrade tox + - run: tox -e checkformatting + flake8: + if: "!contains(github.event.head_commit.message, 'skip_ci')" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - run: python -m pip install --upgrade tox + - run: tox -e flake8 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..7df7291e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,24 @@ +name: Pytest + +on: push + +jobs: + test: + if: "!contains(github.event.head_commit.message, 'skip_ci')" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [3.6, 3.7, 3.8] + + name: Python ${{ matrix.python-version }} + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - run: python -m pip install --upgrade pip tox + - run: tox -e pytest diff --git a/pyreisejl/utility/call.py b/pyreisejl/utility/call.py index 1720eee9..75be25ed 100644 --- a/pyreisejl/utility/call.py +++ b/pyreisejl/utility/call.py @@ -1,9 +1,7 @@ import argparse import os -from collections import OrderedDict from time import time -import numpy as np import pandas as pd from pyreisejl.utility import const @@ -87,7 +85,7 @@ def launch_scenario( # Import these within function because there is a lengthy compilation step from julia.api import Julia - jl = Julia(compiled_modules=False) + Julia(compiled_modules=False) from julia import REISE start = time() diff --git a/pyreisejl/utility/extract_data.py b/pyreisejl/utility/extract_data.py index f1130fbf..3e4c1c69 100644 --- a/pyreisejl/utility/extract_data.py +++ b/pyreisejl/utility/extract_data.py @@ -1,11 +1,8 @@ import argparse -import datetime as dt import glob import os import re -import subprocess import time -from collections import OrderedDict import numpy as np import pandas as pd @@ -74,7 +71,7 @@ def extract_data(results): outputs = {} tic = time.process_time() - for filename in tqdm(results): + for i, filename in tqdm(enumerate(results)): # For each result_#.mat file output = load_mat73(filename) diff --git a/pyreisejl/utility/helpers.py b/pyreisejl/utility/helpers.py index 9db52143..5f9e623a 100644 --- a/pyreisejl/utility/helpers.py +++ b/pyreisejl/utility/helpers.py @@ -1,6 +1,6 @@ -from collections import OrderedDict import os import re +from collections import OrderedDict import h5py import numpy as np diff --git a/pyreisejl/utility/tests/test_extract_data.py b/pyreisejl/utility/tests/test_extract_data.py index f2eabaed..cbec6ad6 100644 --- a/pyreisejl/utility/tests/test_extract_data.py +++ b/pyreisejl/utility/tests/test_extract_data.py @@ -5,7 +5,6 @@ from pyreisejl.utility.extract_data import ( _cast_keys_as_lists, _get_pkl_path, - _update_outputs_labels, calculate_averaged_congestion, result_num, ) diff --git a/pyreisejl/utility/tests/test_helpers.py b/pyreisejl/utility/tests/test_helpers.py index c91b1564..2c9cb44d 100644 --- a/pyreisejl/utility/tests/test_helpers.py +++ b/pyreisejl/utility/tests/test_helpers.py @@ -1,6 +1,5 @@ from io import StringIO -import numpy as np import pandas as pd import pytest diff --git a/requirements.txt b/requirements.txt index d1ca6b0c..190f6b2e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,8 @@ -h5py>=2.9.0 -ipython>=7.0 -julia>=0.5.1 -numpy>=1.16.0 -pandas>=0.25.3 -scipy>=1.2 -tqdm>=4.29.1 +h5py~=2.10.0 +ipython~=7.0 +julia~=0.5.1 +numpy~=1.18.5 +pandas~=1.1.3 +scipy~=1.2 +tqdm~=4.29.1 +pytest~=6.1.1 diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..0b32484c --- /dev/null +++ b/tox.ini @@ -0,0 +1,21 @@ +[tox] +envlist = pytest, format, flake8 +skipsdist = true + +[testenv] +deps = + pytest: -rrequirements.txt + {format,checkformatting}: black + {format,checkformatting}: isort + flake8: flake8 +changedir = pyreisejl +commands = + pytest: pytest + format: black . + format: isort -m 3 --tc . + checkformatting: black . --check --diff + checkformatting: isort -m 3 --tc --check --diff . + flake8: flake8 + +[flake8] +ignore = E501,E731