Skip to content

Commit

Permalink
[#147] feat: Apply ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
lovit committed Feb 4, 2025
1 parent 6ad4d8a commit 2a4bf0a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 39 deletions.
5 changes: 4 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Pull Request

## Checklist

- [ ] 해당 PR 관련 이슈가 작성되었나요?
- [ ] 테스트 코드를 작성하였나요?
- [ ] 기존에 작성된 테스트코드가 정상적으로 작동하나요? (`tests/test*.py`)

## 1. 해당 PR은 어떤 내용인가요?

<!-- 해당 PR이 어떠한 내용인지 상세하게 명시 부탁드립니다. -->

## 2. PR과 관련된 이슈가 있나요?
<!-- PR이 참고하고 있는 이슈가 있다면 이슈번호를 `#123` 형식으로 남겨주세요. 여러 개의 이슈가 포함되어도 됩니다.-->

<!-- PR이 참고하고 있는 이슈가 있다면 이슈번호를 `#123` 형식으로 남겨주세요. 여러 개의 이슈가 포함되어도 됩니다.-->
53 changes: 26 additions & 27 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,34 @@ name: Pytest
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
pull_request:
branches:
- master
- dev
- refactoring
pull_request:
branches:
- master
- dev
- refactoring

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Pytest:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- 3.x
timeout-minutes: 60
Pytest:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- 3.x
timeout-minutes: 60

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Prerequeist
run: |
pip3 install --upgrade pip setuptools
pip3 install pytest pytest-cov --no-cache --user
pip3 install -r requirements.txt --user
- name: test with pytest
run: python3 -m pytest -s -v --cov-report=xml --cov=./ tests/test*.py
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Prerequeist
run: |
pip3 install --upgrade pip setuptools
pip3 install pytest pytest-cov --no-cache --user
pip3 install -r requirements.txt --user
- name: test with pytest
run: python3 -m pytest -s -v --cov-report=xml --cov=./ tests/test*.py
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# soynlp

Renewing ...
Renewing ...

## Install

```
pipx install poetry==1.8.0
poetry install
```
16 changes: 7 additions & 9 deletions data/loader.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
from glob import glob


installpath = os.path.abspath(os.path.dirname(__file__))


def load(idx='134963', mode='norm', max_samples=-1):
def load(idx="134963", mode="norm", max_samples=-1):
"""
Args:
idx: str
idx: str
movie idx
mode: str
`mode` = 'norm' or not
Expand All @@ -21,17 +20,16 @@ def load(idx='134963', mode='norm', max_samples=-1):
scores: list of int
Annotated scores
"""
suffix = '' if mode != 'norm' else '_norm'
paths = glob(f'{installpath}/{idx}{suffix}.txt')
suffix = "" if mode != "norm" else "_norm"
paths = glob(f"{installpath}/{idx}{suffix}.txt")
if not paths:
raise ValueError(f'Not found file. Check idx {idx}')
with open(paths[0], encoding='utf-8') as f:
raise ValueError(f"Not found file. Check idx {idx}")
with open(paths[0], encoding="utf-8") as f:
docs = [line.strip() for line in f]
docs = [line.rsplit('\t', 1) for line in docs]
docs = [line.rsplit("\t", 1) for line in docs]
docs = [row for row in docs if len(row) == 2]
if max_samples > 0:
docs = docs[:max_samples]
texts, scores = zip(*docs)
scores = [int(s) for s in scores]
return texts, scores

0 comments on commit 2a4bf0a

Please sign in to comment.