Skip to content

Commit

Permalink
Merge pull request #39 from zStupan/main
Browse files Browse the repository at this point in the history
Updated Workflow
  • Loading branch information
firefly-cpp authored Apr 5, 2022
2 parents 3b98566 + 9bd7a3e commit 4217f77
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 189 deletions.
53 changes: 40 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,53 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.9"
python-version: ${{ matrix.python-version }}
- name: Get full Python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
- name: Update path
if: ${{ matrix.os != 'windows-latest' }}
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Update Windows path
if: ${{ matrix.os == 'windows-latest' }}
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s poetry run pip --version || rm -rf .venv
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest numpy niapy pandas
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
poetry install
poetry run pip install flake8
- name: Lint
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- name: Run tests
run: poetry run pytest
8 changes: 4 additions & 4 deletions niaarm/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ def __analyse_types(self):
for head in self.header:
col = self.transactions[head]

if col.dtype == "float":
if np.issubdtype(col.dtype, np.floating):
dtype = "float"
min_value = col.min()
max_value = col.max()
unique_categories = None
elif col.dtype == "int":
elif np.issubdtype(col.dtype, np.integer):
dtype = "int"
min_value = col.min()
max_value = col.max()
unique_categories = None
elif col.dtype == 'bool':
elif col.dtype == np.bool_:
self.transactions[head] = self.transactions[head].astype(int)
dtype = 'int'
min_value = 0
Expand All @@ -76,7 +76,7 @@ def __problem_dimension(self):

def __repr__(self):
def dtype(x):
return str(x.dtype)[:-2] if x.dtype in ('int', 'float') else 'category'
return str(x.dtype)[:-2] if np.issubdtype(x.dtype, np.number) else 'category'

def min_val(x):
return x.min() if x.dtype != 'category' else np.nan
Expand Down
Loading

0 comments on commit 4217f77

Please sign in to comment.