Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Python package

on: [push]

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest
62 changes: 62 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# https://pre-commit.com/
ci:
# The repos are quite stable and doesn't effectively change the code that
# often. So no need for the bot to update the rev that often.
autoupdate_schedule: quarterly

# Dont format test dcm-files at all as they contain typical errors that the
# parser has to handle.
exclude: "tests/Sample.dcm"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: mixed-line-ending
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
name: absolufy-imports
files: ^src/dcmReader/
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.235'
hooks:
- id: ruff
args: ["--fix"]
# https://github.com/python/black#version-control-integration
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc
additional_dependencies: ["black==22.12.0"]
- id: blackdoc-autoupdate-black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
# This is slow and so we take it out of the fast-path; requires passing
# `--hook-stage manual` to pre-commit
stages: [manual]
additional_dependencies: [
# Type stubs
types-python-dateutil,
types-pkg_resources,
types-PyYAML,
types-pytz,
typing-extensions,
]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ This can also be used to sort a DCM file:

## UnitTests
The UnitTests can be run in the tests directory by running
python Tests.py
python Tests.py
32 changes: 31 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,34 @@ disable = [
"too-many-statements",
"duplicate-code",
"invalid-name",
]
]

[tool.ruff]
target-version = "py39"
builtins = ["ellipsis"]
exclude = [
".eggs",
"doc",
]
# E402: module level import not at top of file
# E501: line too long - let black worry about that
# E731: do not assign a lambda expression, use a def
ignore = [
"E402",
"E501",
"E731",
]
select = [
# Pyflakes
"F",
# Pycodestyle
"E",
"W",
# isort
"I",
# Pyupgrade
"UP",
]

[tool.ruff.isort]
known-first-party = ["dcmReader"]
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is redundant with setup.cfg;
# it exists to let GitHub build the repository dependency graph
# https://help.github.com/en/github/visualizing-repository-data-with-graphs/listing-the-packages-that-a-repository-depends-on

numpy >= 1.21
27 changes: 25 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,30 @@ classifiers =
package_dir =
= src
packages = find:
python_requires = >=3.6
python_requires = >=3.9
install_requires =
numpy >= 1.21

[options.packages.find]
where = src
where = src

[flake8]
ignore =
# E203: whitespace before ':' - doesn't work well with black
# E402: module level import not at top of file
# E501: line too long - let black worry about that
# E731: do not assign a lambda expression, use a def
# W503: line break before binary operator
E203, E402, E501, E731, W503
exclude =
.eggs
doc
builtins =
ellipsis

[isort]
profile = black
skip_gitignore = true
float_to_top = true
default_section = THIRDPARTY
known_first_party = dcmReader
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import setuptools

with open("README.md", "r", encoding="utf-8") as fh:
with open("README.md", encoding="utf-8") as fh:
long_description = fh.read()

setuptools.setup(
Expand Down
6 changes: 3 additions & 3 deletions src/dcmReader/dcm_characteristic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ def __str__(self):
if self.unit_values:
value += f' EINHEIT_W "{self.unit_values}"\n'
if self.x_mapping:
value += f'*SSTX {self.x_mapping}\n'
value += f"*SSTX {self.x_mapping}\n"
if self.values:
x_entries = ""
value_entries = ""
for x_entry, value_entry in self.values.items():
x_entries += f"{str(x_entry)} "
value_entries += f"{str(value_entry)} "
value += f' ST/X {x_entries.strip()}\n'
value += f' WERT {value_entries.strip()}\n'
value += f" ST/X {x_entries.strip()}\n"
value += f" WERT {value_entries.strip()}\n"
for var_name, var_value in self.variants.items():
value += f" VAR {var_name}={var_value}\n"

Expand Down
10 changes: 5 additions & 5 deletions src/dcmReader/dcm_characteristic_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def __str__(self):
if self.unit_values:
value += f' EINHEIT_W "{self.unit_values}"\n'
if self.x_mapping:
value += f'*SSTX {self.x_mapping}\n'
value += f"*SSTX {self.x_mapping}\n"
if self.y_mapping:
value += f'*SSTY {self.y_mapping}\n'
value += f"*SSTY {self.y_mapping}\n"
stx_written = False
for y_entry, map_values in self.values.items():
x_entries = ""
Expand All @@ -75,10 +75,10 @@ def __str__(self):
x_entries += f"{str(x_entry)} "
value_entries += f"{str(value_entry)} "
if not stx_written:
value += f' ST/X {x_entries.strip()}\n'
value += f" ST/X {x_entries.strip()}\n"
stx_written = True
value += f' ST/Y {str(y_entry).strip()}\n'
value += f' WERT {value_entries.strip()}\n'
value += f" ST/Y {str(y_entry).strip()}\n"
value += f" WERT {value_entries.strip()}\n"
for var_name, var_value in self.variants.items():
value += f" VAR {var_name}={var_value}\n"

Expand Down
2 changes: 1 addition & 1 deletion src/dcmReader/dcm_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __str__(self):
x_entries = ""
for x_entry in self.values:
x_entries += f"{str(x_entry)} "
value += f' ST/X {x_entries.strip()}\n'
value += f" ST/X {x_entries.strip()}\n"
for var_name, var_value in self.variants.items():
value += f" VAR {var_name}={var_value}\n"

Expand Down
1 change: 1 addition & 0 deletions src/dcmReader/dcm_fixed_characteristic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from dataclasses import dataclass

from dcmReader.dcm_characteristic_line import DcmCharacteristicLine


Expand Down
1 change: 1 addition & 0 deletions src/dcmReader/dcm_fixed_characteristic_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from dataclasses import dataclass

from dcmReader.dcm_characteristic_map import DcmCharacteristicMap


Expand Down
1 change: 1 addition & 0 deletions src/dcmReader/dcm_group_characteristic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Definition of DCM group characteristic line
"""
from dataclasses import dataclass

from dcmReader.dcm_characteristic_line import DcmCharacteristicLine


Expand Down
1 change: 1 addition & 0 deletions src/dcmReader/dcm_group_characteristic_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Definition of DCM fixed characteristic map
"""
from dataclasses import dataclass

from dcmReader.dcm_characteristic_map import DcmCharacteristicMap


Expand Down
Loading