Skip to content

Commit 0663b60

Browse files
committed
💄 Linting library using ruff
The two commands run were: - `ruff check .` then with `--fix` - `ruff format .`
1 parent d8a0265 commit 0663b60

File tree

4 files changed

+40
-28
lines changed

4 files changed

+40
-28
lines changed

‎docs/conf.py‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,28 @@
66
# -- Project information -----------------------------------------------------
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88

9-
project = 'sagittal-average'
10-
copyright = '2019, Charlene Bultoc'
11-
author = 'Charlene Bultoc'
12-
release = '0.1'
9+
project = "sagittal-average"
10+
copyright = "2019, Charlene Bultoc"
11+
author = "Charlene Bultoc"
12+
release = "0.1"
1313

1414
# -- General configuration ---------------------------------------------------
1515
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1616

1717
extensions = [
18-
'sphinx.ext.autodoc', # Support automatic documentation
19-
'sphinx.ext.coverage', # Automatically check if functions are documented
20-
'sphinx.ext.mathjax', # Allow support for algebra
21-
'sphinx.ext.viewcode', # Include the source code in documentation
22-
'sphinx.ext.githubpages', # Publish HTML docs in GitHub Pages¶
18+
"sphinx.ext.autodoc", # Support automatic documentation
19+
"sphinx.ext.coverage", # Automatically check if functions are documented
20+
"sphinx.ext.mathjax", # Allow support for algebra
21+
"sphinx.ext.viewcode", # Include the source code in documentation
22+
"sphinx.ext.githubpages", # Publish HTML docs in GitHub Pages¶
2323
]
2424

25-
templates_path = ['_templates']
26-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
27-
25+
templates_path = ["_templates"]
26+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
2827

2928

3029
# -- Options for HTML output -------------------------------------------------
3130
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
3231

33-
html_theme = 'alabaster'
34-
html_static_path = ['_static']
32+
html_theme = "alabaster"
33+
html_static_path = ["_static"]

‎src/sagittal_average/command.py‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22

33
from .sagittal_brain import run_averages
44

5+
56
def process():
6-
parser = ArgumentParser(description="Calculates the average for each sagittal-horizontal plane.",
7-
formatter_class=ArgumentDefaultsHelpFormatter)
8-
parser.add_argument('file_input', nargs='?', default="brain_sample.csv",
9-
help="Input CSV file with the results from scikit-brain binning algorithm.")
10-
parser.add_argument('--file_output', '-o', default="brain_average.csv",
11-
help="Name of the output CSV file.")
7+
parser = ArgumentParser(
8+
description="Calculates the average for each sagittal-horizontal plane.",
9+
formatter_class=ArgumentDefaultsHelpFormatter,
10+
)
11+
parser.add_argument(
12+
"file_input",
13+
nargs="?",
14+
default="brain_sample.csv",
15+
help="Input CSV file with the results from scikit-brain binning algorithm.",
16+
)
17+
parser.add_argument(
18+
"--file_output",
19+
"-o",
20+
default="brain_average.csv",
21+
help="Name of the output CSV file.",
22+
)
1223
arguments = parser.parse_args()
1324

1425
run_averages(arguments.file_input, arguments.file_output)
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
21

32
import numpy as np
43

54

6-
def run_averages(file_input='brain_sample.csv', file_output='brain_average.csv'):
5+
def run_averages(file_input="brain_sample.csv", file_output="brain_average.csv"):
76
"""
87
Calculates the average through the coronal planes
98
The input file should has as many columns as coronal planes
@@ -12,11 +11,11 @@ def run_averages(file_input='brain_sample.csv', file_output='brain_average.csv')
1211
The result is the average for each sagittal/horizontal plane (rows)
1312
"""
1413
# Open the file to analyse
15-
planes = np.loadtxt(file_input, dtype=int, delimiter=',')
14+
planes = np.loadtxt(file_input, dtype=int, delimiter=",")
1615

1716
# Calculates the averages through the sagittal/horizontal planes
1817
# and makes it as a row vector
1918
averages = planes.mean(axis=1)[np.newaxis, :]
2019

2120
# write it out on my file
22-
np.savetxt(file_output, averages, fmt='%.1f', delimiter=',')
21+
np.savetxt(file_output, averages, fmt="%.1f", delimiter=",")

‎tests/test_sagittal_brain.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
TEST_DIR = Path(__file__).parent
77

8+
89
def test_average():
910
# Creates input file
1011
data_input = np.zeros((20, 20))
@@ -13,12 +14,14 @@ def test_average():
1314
expected = np.zeros(20)
1415
expected[-1] = 1
1516

16-
np.savetxt(TEST_DIR / "brain_sample.csv", data_input, fmt='%d', delimiter=',')
17+
np.savetxt(TEST_DIR / "brain_sample.csv", data_input, fmt="%d", delimiter=",")
1718

1819
# run python program
19-
run_averages(file_input=TEST_DIR / "brain_sample.csv",
20-
file_output=TEST_DIR / "brain_average.csv")
20+
run_averages(
21+
file_input=TEST_DIR / "brain_sample.csv",
22+
file_output=TEST_DIR / "brain_average.csv",
23+
)
2124

2225
# Check result
23-
result = np.loadtxt(TEST_DIR / "brain_average.csv", delimiter=',')
26+
result = np.loadtxt(TEST_DIR / "brain_average.csv", delimiter=",")
2427
np.testing.assert_array_equal(result, expected)

0 commit comments

Comments
 (0)