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
73 changes: 73 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Publish (template-based)

# Adapted from provided template. Builds and publishes shoeboxpy to PyPI using Trusted Publishing.
# Relies on setuptools-scm, so tag the release as vMAJOR.MINOR.PATCH (e.g. v0.1.0).

on:
release:
types: [published]
workflow_dispatch:
inputs:
skip-tests:
description: "Skip pytest"
default: "false"
required: false

permissions:
contents: read
id-token: write # mandatory for trusted publishing

jobs:
pypi-publish:
name: Build & upload to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/shoeboxpy
steps:
- name: Checkout (full history for setuptools-scm)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Validate tag (release only)
if: github.event_name == 'release'
run: |
TAG_NAME="${GITHUB_REF##*/}"; echo "Tag: $TAG_NAME"
if [[ ! $TAG_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Tag must match vMAJOR.MINOR.PATCH" >&2; exit 1; fi

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install deps & build tooling
run: |
python -m pip install --upgrade pip
pip install build twine pytest
pip install -r requirements.txt || true
pip install -e .

- name: Run tests
if: ${{ github.event.inputs.skip-tests != 'true' }}
run: |
PYTHONPATH=$PWD/src pytest -q

- name: Build distributions
run: |
python -m build
ls -l dist

- name: Verify distributions
run: |
python -m twine check dist/*

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
print-hash: true

- name: Post publish note
run: echo "Published shoeboxpy (may take a minute to appear)."
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ share/python-wheels/
*.egg
MANIFEST

# (No longer generating a version file with setuptools-scm; version comes from metadata)

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down
34 changes: 3 additions & 31 deletions demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,11 @@
velocity_history[i] = velocity # Store the current velocities

# Plot final on a matplotlib figure. left side of the plot shows the position, right side shows the velocity.
# Plot final on a matplotlib figure. left side of the plot shows the position, right side shows the velocity, and bottom shows the XY plot.
plt.figure(figsize=(18, 6))
plt.subplot(1, 3, 1)

plt.figure(figsize=(12, 6))
plt.subplot(1, 2, 1)
plt.plot(T, pose_history[:, 0], label='x (m)')
plt.plot(T, pose_history[:, 1], label='y (m)')
plt.plot(T, pose_history[:, 2], label='z (m)')
plt.title('Position over Time')
plt.xlabel('Time (s)')
plt.ylabel('Position (m)')
plt.grid()
plt.legend()
plt.subplot(1, 3, 2)

plt.plot(T, velocity_history[:, 0], label='u (m/s)')
plt.plot(T, velocity_history[:, 1], label='v (m/s)')
plt.plot(T, velocity_history[:, 2], label='w (m/s)')
plt.title('Velocity over Time')
plt.xlabel('Time (s)')
plt.ylabel('Velocity (m/s)')
plt.grid()
plt.legend()

plt.subplot(1, 3, 3)
plt.plot(pose_history[:, 0], pose_history[:, 1])
plt.title('X-Y Plot')
plt.xlabel('X (m)')
plt.ylabel('Y (m)')
plt.axis('equal')
plt.grid()

plt.tight_layout()
plt.show()




Expand Down
2 changes: 1 addition & 1 deletion docs/theory.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ $$
$$

$$
\mathbf{M}_{\mathrm{eff}} \dot{\nu} &+ (\mathbf{C}_{\mathrm{RB}} + \mathbf{C}_{\mathrm{A}})\nu + \mathbf{D}\nu = \tau + \tau_{\mathrm{ext}} + \mathbf{g}_{\mathrm{restoring}}(\eta).
\mathbf{M}_{\mathrm{eff}} \dot{\nu} + (\mathbf{C}_{\mathrm{RB}} + \mathbf{C}_{\mathrm{A}})\nu + \mathbf{D}\nu = \tau + \tau_{\mathrm{ext}} + \mathbf{g}_{\mathrm{restoring}}(\eta).
$$

Implemented with classical 4th‑order Runge-Kutta (RK4) over step $\Delta t$:
Expand Down
35 changes: 24 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,32 @@ authors = [
]
description = "A shoebox approximation for a marine hydrodynamics model"
readme = "README.md"
requires-python = ">=3.8"
dynamic = ["version"]
requires-python = ">=3.9"
license = { file = "LICENSE" }
dynamic = ["version", "dependencies"]
classifiers = [
"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",
"License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
"Operating System :: OS Independent"
]

dependencies = [
"numpy",
"pandas",
"scipy",
"matplotlib"
]
keywords = ["hydrodynamics", "marine", "simulation", "dynamics", "vessel"]

keywords = []
[project.urls]
Homepage = "https://github.com/incebellipipo/shoeboxpy"
Repository = "https://github.com/incebellipipo/shoeboxpy.git"
Documentation = "https://incebellipipo.github.io/shoeboxpy/"
Issues = "https://github.com/incebellipipo/shoeboxpy/issues"
Source = "https://github.com/incebellipipo/shoeboxpy"

[tool.setuptools]
include-package-data = true
Expand All @@ -31,10 +43,11 @@ include-package-data = true
where = ["src"]

[tool.setuptools.dynamic]
version = {attr = "shoeboxpy.__version__"}
dependencies = { file = ["requirements.txt"] }

[tool.setuptools.package-data]

[tool.setuptools_scm]
version_file = "src/shoeboxpy/__version__.py"
# Basic setuptools-scm config: derive version from git tags.
# No write_to/version_file needed; importlib.metadata reads dist metadata.
version_scheme = 'post-release'
17 changes: 16 additions & 1 deletion src/shoeboxpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
from __future__ import annotations

__version__ = "0.0.1"
"""Top-level package for shoeboxpy.

The package version is derived from the installed distribution metadata via
importlib.metadata (set at build time by setuptools-scm). When the package
is imported from a source checkout without installation, a safe fallback
value is provided.
"""

from importlib import metadata as _metadata

try: # Preferred path: distribution is installed (editable or regular)
__version__ = _metadata.version("shoeboxpy")
except _metadata.PackageNotFoundError: # Source tree without installed dist
__version__ = "0.0.0" # Fallback; not an authoritative release tag

__all__ = ["__version__"]
21 changes: 0 additions & 21 deletions src/shoeboxpy/__version__.py

This file was deleted.

Loading
Loading