From f452c543688f340f8076a31122fdfeeab396e06d Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Mon, 22 Dec 2025 20:15:23 +0100 Subject: [PATCH] initial commit --- .gitignore | 8 ++++++++ INSTALL | 9 +++++++++ README.md | 3 +++ pyproject.toml | 38 ++++++++++++++++++++++++++++++++++++++ src/fvr/__init__.py | 23 +++++++++++++++++++++++ src/fvr/geom.py | 16 ++++++++++++++++ src/fvr/py.typed | 0 src/fvr/typing.py | 5 +++++ 8 files changed, 102 insertions(+) create mode 100644 .gitignore create mode 100644 INSTALL create mode 100644 README.md create mode 100644 pyproject.toml create mode 100644 src/fvr/__init__.py create mode 100644 src/fvr/geom.py create mode 100644 src/fvr/py.typed create mode 100644 src/fvr/typing.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1bb85e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[codz] + +# Distribution / packaging +build/ +dist/ +*.egg-info/ \ No newline at end of file diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..d362ab1 --- /dev/null +++ b/INSTALL @@ -0,0 +1,9 @@ +* Installation +python -m pip install . --break-system-packages +# or in 'development mode' +python -m pip install -e . --break-system-packages +# or inside a virtual environment using e.g. poetry +poetry install + +* Uninstallation +python -m pip uninstall fvr --break-system-packages diff --git a/README.md b/README.md new file mode 100644 index 0000000..6946e76 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# fvr + +fvr; a suite of tools designed to enhance efficiency and productivity. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5769ccc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,38 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "fvr" +dynamic = ["version"] +description = "Various tools" +license = "MIT" +license-files = ["LICEN[CS]E.*"] +authors = [ + { name = "Daniel Weschke", email = "daniel.weschke@directbox.de" }, +] +keywords = [ + "mechanics", "materials", +] +readme = "README.md" +classifiers = [ + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Science/Research", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Topic :: Office/Business", + "Topic :: Scientific/Engineering", + "Typing :: Typed", +] + +[tool.setuptools.dynamic] +version = {attr = "fvr.__version__"} + +[tool.setuptools.packages.find] +where = ["src"] +include = ["fvr*"] +# namespaces = false diff --git a/src/fvr/__init__.py b/src/fvr/__init__.py new file mode 100644 index 0000000..8dd4e3b --- /dev/null +++ b/src/fvr/__init__.py @@ -0,0 +1,23 @@ +import sys +import pathlib +import importlib + + +__version__ = "2025.12.22" + + +def rundir(): + """ + returns the path of the script running or the current working directory. + """ + if sys.argv[0] == '-c': + return pathlib.Path.cwd() + return pathlib.Path(sys.argv[0]).parent + # return pathlib.Path(sys.argv[0]).parent.resolve() + +def reload(module): + importlib.reload(module) + +def printdoc(object): + res = object.__doc__ + print(res) diff --git a/src/fvr/geom.py b/src/fvr/geom.py new file mode 100644 index 0000000..2de9dda --- /dev/null +++ b/src/fvr/geom.py @@ -0,0 +1,16 @@ +from fvr.typing import FloatArray + +def area(vertices: FloatArray) -> float: + r"""Determine the area of a simple polygon. + + Shoelace formula, Gauss's area formula, surveyor's formula + + https://en.wikipedia.org/wiki/Shoelace_formula + """ + count = len(vertices) # of corners + result = 0.0 + for i in range(count): + j = (i + 1) % count + result += vertices[i][0] * vertices[j][1] - vertices[i][1] * vertices[j][0] + result = abs(result) / 2.0 + return result diff --git a/src/fvr/py.typed b/src/fvr/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/src/fvr/typing.py b/src/fvr/typing.py new file mode 100644 index 0000000..37b4e22 --- /dev/null +++ b/src/fvr/typing.py @@ -0,0 +1,5 @@ +from collections.abc import Sequence +import numpy as np +from numpy.typing import NDArray + +type FloatArray = Sequence[float] | NDArray[np.float64]