Skip to content
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
push:
branches: [main, develop]
pull_request:

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -e ".[dev]"
- run: python -m ruff check src test example_usage.py
- run: python -m pytest --cov

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python -m pip install build twine
- run: python -m build
- run: python -m twine check --strict dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ htmlcov/

# Other
*.zip

# Build output
build/
dist/
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ ProfielCheckPython is a conversion of the C# library `daas.fn` 1.0.1.0 by Rolf W
A first Python conversion (2025) was an intermediate step and was not released separately;
its own deviations from the C# code are listed at the end of the 2.0.0 section.

## [Unreleased]

## [2.0.0] - 2026-10-19

### API: from C# to Python

| C# (`daas.fn`) | Python 2.0.0 |
|---|---|
| Namespace `daas.fn` | Package `prflcheck` (folder `src/prflcheck/`): `from prflcheck import Profiel` |
| `new Profiel(profielData)`, `new Profiel(naam, profielData)` | `Profiel.from_string(text)` or `Profiel.from_file(path)` |
| `new Profiel(id, damtype, damhoogte, richting, kruinhoogte, voorland, damwandmodule, memo, profielpunten)` | `Profiel.from_punten(punten, voorland=..., id=..., damtype=..., damwand=..., ...)` |
| `profiel.Controleer()` | `profiel.check()` |
Expand Down Expand Up @@ -75,6 +78,11 @@ its own deviations from the C# code are listed at the end of the 2.0.0 section.
- Test suite with pytest (256 tests, 100% branch coverage), including boundary tests for
every validation limit and round-trip tests for v3 and v4. Linting with ruff.
- `example_usage.py`, README, this changelog, and `LICENSE` (EUPL-1.2).
- **Installable package:** `pyproject.toml` (build backend hatchling), so `pip install .`
works and a wheel and source distribution can be built for PyPI under the name
`prflcheck`. The version number is read from `prflcheck.__version__`. The settings of
pytest, coverage and ruff are in `pyproject.toml`, the development tools in the `dev` extra
(`pip install -e ".[dev]"`). GitHub Actions runs the tests and builds the package.

### Changed

Expand Down Expand Up @@ -128,3 +136,6 @@ C# library `daas.fn` for .NET Framework by Rolf Waterman, © HKV Services 2016,
`Profiel.cs`, `ProfielPunt.cs`, `ProfielDeel.cs`, `ProfielCheck.cs`, `ProfielEnums.cs`,
`ConvertString.cs` and `EnumeratorExtensions.cs`. Reads and writes Hydra/Ringtoets profiles
(version 3 and 4) and validates them with `Controleer()`.

[Unreleased]: https://github.com/MariovdBerg/ProfielCheckPython/compare/v2.0.0...HEAD
[2.0.0]: https://github.com/MariovdBerg/ProfielCheckPython/releases/tag/v2.0.0
62 changes: 39 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# ProfielCheckPython

A Python port of the HKV C# library for reading, writing and validating Hydra/Ringtoets
A Python port of the HKV C# library for reading, writing and validating Hydra-NL/HydraRing
profiles (`.prfl`): cross-sections of a dike with an optional foreland (voorland) and dam.

**Authors:** Rolf Waterman (original C# code), Mario van den Berg, Claude
**Copyright:** © 2025-2026 HKV lijn in water B.V.; original C# code © 2016, 2017 HKV Services
**License:** [EUPL-1.2](LICENSE)
**Version:** 2.0.0 (see [CHANGELOG.md](CHANGELOG.md); not compatible with the C# library or 1.0.1.0)
**License:** [EUPL-1.2](https://github.com/MariovdBerg/ProfielCheckPython/blob/main/LICENSE)
**Version:** 2.0.0 (see [CHANGELOG.md](https://github.com/MariovdBerg/ProfielCheckPython/blob/main/CHANGELOG.md); not compatible with the C# library or 1.0.1.0)

## Overview

Expand All @@ -17,36 +17,34 @@ profiles (`.prfl`): cross-sections of a dike with an optional foreland (voorland

## Installation

The module is not (yet) an installable package: there is no `pyproject.toml`, so `pip install`
does not work. The code lives in the folder `src` and is imported as `src`.
The package is called `prflcheck` (folder `src/prflcheck/`) and has no dependencies.
Install it from GitHub:

### From source
```bash
pip install git+https://github.com/MariovdBerg/ProfielCheckPython.git
```

Or from a local clone, in editable mode for development:

```bash
git clone https://github.com/MariovdBerg/ProfielCheckPython.git
cd ProfielCheckPython
pip install -e .
python example_usage.py
```

Scripts in the project folder can then use `from src import ...` directly.

### Direct use from another project

Add the project folder (the folder that *contains* `src`) to the Python path:
Then import it as usual:

```python
import sys
sys.path.append(r"C:\path\to\ProfielCheckPython")

from src import Profiel, ProfielPunt, ProfielError
from prflcheck import Profiel, ProfielPunt, ProfielError
```

## Quick Start

### Creating a profile

```python
from src import Damwandmodule, DamType, Profiel, ProfielPunt, ProfielVersion
from prflcheck import Damwandmodule, DamType, Profiel, ProfielPunt, ProfielVersion

# Profile points: x (m), z (m+NAP), roughness
punten = [
Expand Down Expand Up @@ -85,7 +83,7 @@ are `NaN` (numbers) or `GEEN` (dam type and dam wall).
### Reading a profile

```python
from src import Profiel
from prflcheck import Profiel

profiel = Profiel.from_file("profile_v4.prfl") # version 3 or 4, detected from VERSIE
text = profiel.to_string(3) # the same profile in the version 3 format
Expand Down Expand Up @@ -135,11 +133,13 @@ Dutch `description`:
| 130 | Dam wall (crest height) above the end of the foreland |
| 800, 801 | Invalid dam type or dam wall module |

The limits are constants in `src/checks.py`. A missing (`NaN`) crest height or roughness
The limits are constants in `src/prflcheck/checks.py`. A missing (`NaN`) crest height or roughness
is reported as an error.

## Module Structure

The package `prflcheck` (folder `src/prflcheck/`) contains:

- **model.py**: `ProfielPunt`, `ProfielDeel` and `Profiel` (data only)
- **reader.py**: `read_file()`, `read_string()` for version 3 and 4
- **writer.py**: `write_string()` for version 3 and 4
Expand All @@ -166,16 +166,32 @@ This demonstrates:

## Testing

The tests use pytest, pytest-cov and ruff (`requirements-dev.txt`). On Windows:
The tests use pytest, pytest-cov and ruff (the `dev` extra in `pyproject.toml`, which also
installs `build` and `twine`). The tests run against the installed package. On Windows:

```bash
python -m venv .venv
.venv/Scripts/python -m pip install -r requirements-dev.txt
.venv/Scripts/python -m pytest --cov=src --cov-branch
.venv/Scripts/python -m pip install -e ".[dev]"
.venv/Scripts/python -m pytest --cov
.venv/Scripts/python -m ruff check src test example_usage.py
```

On Linux or macOS, use `.venv/bin/python` instead of `.venv/Scripts/python`.
On Linux or macOS, use `.venv/bin/python` instead of `.venv/Scripts/python`. GitHub Actions
runs the tests on Python 3.9 to 3.14 on Linux and Windows (`.github/workflows/ci.yml`).

## Building and Publishing

The version number is set in one place, `__version__` in `src/prflcheck/__init__.py`.
To make a release, update it, add a section to `CHANGELOG.md`, and build and check the
distributions:

```bash
.venv/Scripts/python -m build
.venv/Scripts/python -m twine check dist/*
```

This creates a wheel and a source distribution in `dist/`. Upload them to PyPI with
`twine upload dist/*`.

## Requirements

Expand All @@ -189,7 +205,7 @@ Copyright © 2025-2026 HKV lijn in water B.V. (Python code)

Licensed under the EUPL

This work is licensed under the [European Union Public Licence v1.2](LICENSE) (EUPL-1.2),
This work is licensed under the [European Union Public Licence v1.2](https://github.com/MariovdBerg/ProfielCheckPython/blob/main/LICENSE) (EUPL-1.2),
an open-source licence with copyleft: you may use, change and distribute the code, also
commercially, provided that you keep the copyright notices, include the licence, mark your
changes, and distribute changed versions under the EUPL (or a compatible licence listed in
Expand Down
5 changes: 3 additions & 2 deletions example_usage.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""
Voorbeelden van het gebruik van de ProfielCheckPython-module.

Uitvoeren vanuit de hoofdmap van het project:
Uitvoeren vanuit de hoofdmap van het project, met prflcheck geïnstalleerd
(pip install -e .):
python example_usage.py
"""

import tempfile
from pathlib import Path

from src import DamType, Damwandmodule, Profiel, ProfielPunt, ProfielVersion
from prflcheck import DamType, Damwandmodule, Profiel, ProfielPunt, ProfielVersion

PROFIEL_V3 = """VERSIE 3.0
DAM 0
Expand Down
81 changes: 81 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[build-system]
requires = ["hatchling>=1.27"]
build-backend = "hatchling.build"

[project]
name = "prflcheck"
dynamic = ["version"]
description = "Read, write and validate Hydra-NL/HydraRing profiles (.prfl)"
readme = "README.md"
requires-python = ">=3.9"
license = "EUPL-1.2"
license-files = ["LICENSE"]
authors = [
{ name = "Rolf Waterman" },
{ name = "Mario van den Berg", email = "M.vandenBerg@hkv.nl" },
]
keywords = ["hydra-nl", "hydraring", "ringtoets", "profiel", "dijk", "prfl"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Natural Language :: Dutch",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Scientific/Engineering :: Hydrology",
]
dependencies = []

[project.optional-dependencies]
dev = ["pytest", "pytest-cov", "ruff", "build", "twine"]

[project.urls]
Homepage = "https://github.com/MariovdBerg/ProfielCheckPython"
Source = "https://github.com/MariovdBerg/ProfielCheckPython"
Issues = "https://github.com/MariovdBerg/ProfielCheckPython/issues"
Changelog = "https://github.com/MariovdBerg/ProfielCheckPython/blob/main/CHANGELOG.md"

# Eén bron voor het versienummer: __version__ in het package
[tool.hatch.version]
path = "src/prflcheck/__init__.py"

[tool.hatch.build.targets.wheel]
packages = ["src/prflcheck"]

[tool.hatch.build.targets.sdist]
include = [
"src/prflcheck",
"test",
"example_usage.py",
"README.md",
"CHANGELOG.md",
"LICENSE",
]

[tool.pytest.ini_options]
testpaths = ["test"]
# prflcheck wordt geïnstalleerd getest (pip install -e .), . is nodig voor example_usage.py
pythonpath = ["."]
addopts = "-ra"

[tool.coverage.run]
source = ["prflcheck"]
branch = true

[tool.ruff]
line-length = 120
target-version = "py39"
# Mappen met eigen code, zodat imports van prflcheck als first-party worden gesorteerd
src = ["src", "."]

[tool.ruff.lint]
select = ["E", "F", "W", "B", "I", "UP"]
# De foutmeldingen in ProfielError zijn bewust lange regels
per-file-ignores = { "src/prflcheck/profiel_enums.py" = ["E501"] }
4 changes: 0 additions & 4 deletions pytest.ini

This file was deleted.

3 changes: 0 additions & 3 deletions requirements-dev.txt

This file was deleted.

7 changes: 0 additions & 7 deletions ruff.toml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from src import ProfielPunt
from prflcheck import ProfielPunt

TESTPROFILES_DIR = Path(__file__).parent / "testprofiles"

Expand Down
2 changes: 1 addition & 1 deletion test/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from src import Damwandmodule, Profiel, ProfielError, ProfielPunt, checks
from prflcheck import Damwandmodule, Profiel, ProfielError, ProfielPunt, checks

from .conftest import punten

Expand Down
2 changes: 1 addition & 1 deletion test/test_convert_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from src import format_float, parse_float, parse_int
from prflcheck import format_float, parse_float, parse_int


@pytest.mark.parametrize("tekst, verwacht", [
Expand Down
4 changes: 2 additions & 2 deletions test/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from src import Profiel, ProfielError, read_file
from src.reader import VERVANGTEKEN
from prflcheck import Profiel, ProfielError, read_file
from prflcheck.reader import VERVANGTEKEN

TEKST = "VERSIE 4.0\nID X\nVOORLAND 0\nKRUINHOOGTE 8.0\nDIJK 2\n0 2 0.8\n8 3 0.8\nMEMO\nDijk bij Één, café\n"

Expand Down
2 changes: 1 addition & 1 deletion test/test_example_usage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Houdt example_usage.py werkend: de voorbeelden moeten de verwachte uitkomst geven."""

import example_usage
from src import ProfielError
from prflcheck import ProfielError


def test_voorbeelden_1_tot_4_zijn_geldig(capsys):
Expand Down
2 changes: 1 addition & 1 deletion test/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from src import DamType, Damwandmodule, Profiel, ProfielDeel, ProfielDeelType, ProfielPunt
from prflcheck import DamType, Damwandmodule, Profiel, ProfielDeel, ProfielDeelType, ProfielPunt

from .conftest import punten

Expand Down
2 changes: 1 addition & 1 deletion test/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from src import DamType, Damwandmodule, Profiel, ProfielError, ProfielPunt, read_file, read_string
from prflcheck import DamType, Damwandmodule, Profiel, ProfielError, ProfielPunt, read_file, read_string

from .conftest import fixture_path

Expand Down
Loading
Loading