# RMNpy
Python bindings for OCTypes, SITypes, and RMNLib C libraries.
> **🚀 Setting up on a new computer?** See **[docs/development/NEW_COMPUTER_SETUP.md](docs/development/NEW_COMPUTER_SETUP.md)** for quick setup or **[docs/development/ENVIRONMENT_SETUP.md](docs/development/ENVIRONMENT_SETUP.md)** for detailed instructions.
## Overview
RMNpy provides Python access to three scientific computing C libraries:
- **OCTypes**: Objective-C style data structures and memory management
- **SITypes**: Scientific units and dimensional analysis
- **RMNLib**: High-level analysis and computation tools
## Features
- Type-safe conversion between Python and C data structures
- Scientific units and dimensional analysis
- High-performance numerical computations
- Memory-safe interface to C libraries
## Installation
### For Development (Recommended)
See **[docs/development/ENVIRONMENT_SETUP.md](docs/development/ENVIRONMENT_SETUP.md)** for complete instructions.
Quick version:
```bash
# Clone the repo with all C libraries
git clone https://github.com/pjgrandinetti/OCTypes-SITypes.git
cd OCTypes-SITypes
# Build required C libraries first
cd OCTypes && make && make install && cd ..
cd SITypes && make && make synclib && make install && cd ..
cd RMNLib && make && make synclib && make install && cd ..
# Set up Python environment
cd RMNpy
conda env create -f environment.yml
conda activate rmnpy
pip install -e .
```
### For End Users (When Available)
```bash
pip install rmnpy
```
**Platform Support:**
- **Linux/macOS**: Python 3.8-3.12
- **Windows**: Python 3.12 only (requires MSYS2 environment)
### Windows (MSYS2/Mingw-w64 Python)
To install RMNpy with C99-based Cython extensions on Windows you must use the MSYS2 MINGW64 Python runtime:
1. Install [MSYS2](https://www.msys2.org/) and open the **MSYS2 MinGW64** shell.
2. Update packages and install dependencies:
```bash
pacman -Syu # first-time update
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-python-pip \
mingw-w64-x86_64-openblas mingw-w64-x86_64-lapack \
mingw-w64-x86_64-curl mingw-w64-x86_64-make
```
3. Create and activate a virtual environment (so pip can install into it):
```bash
python -m pip install --upgrade pip virtualenv
python -m virtualenv venv
source venv/bin/activate
```
4. Install RMNpy and test extras:
```bash
pip install numpy pytest pytest-cov
pip install -e .[test]
```
5. Run your scripts or pytest from this venv; it uses MinGW-built extensions compatible with Windows.
#### Using Conda-forge MSYS2 Environment (Optional)
If you prefer managing dependencies with conda, you can provision an MSYS2 toolchain via conda-forge:
```bash
conda create -n rmnpy-win python=3.12 pip m2-msys2-runtime m2-gcc m2-gcc-fortran m2-openblas m2-lapack m2-curl m2-make virtualenv -c conda-forge
conda activate rmnpy-win
# (Optional) isolate further via virtualenv within conda env:
python -m venv venv
source venv/bin/activate
pip install -e .[test]
```
## Quick Start
```python
from rmnpy.wrappers.sitypes import Scalar, Unit, Dimensionality
# === Flexible Scalar Creation ===
# Single string expressions (value + unit)
energy = Scalar("100 J") # 100 Joules
velocity = Scalar("25 m/s") # 25 meters per second
# Single numeric values (dimensionless)
ratio = Scalar(0.75) # 0.75 (dimensionless)
count = Scalar(42) # 42 (dimensionless)
impedance = Scalar(3+4j) # Complex number
# Value and unit pairs
distance = Scalar(100, "m") # 100 meters
power = Scalar(2.5, "W") # 2.5 Watts
current = Scalar(3+4j, "A") # Complex current
# Named parameters
unit_meter = Scalar(expression="m") # 1 meter
force = Scalar(value=9.8, expression="kg*m/s^2") # 9.8 Newtons
# === Scientific Calculations with Automatic Units ===
# Basic physics calculations
time = Scalar(2, "s")
speed = distance / time # Result: 50 m/s (automatic unit derivation)
acceleration = Scalar(9.8, "m/s^2")
force = Scalar(5, "kg") * acceleration # Result: 49 N (automatic units)
# Unit conversions
speed_kmh = speed.to("km/h") # Convert to km/h
speed_si = speed.to_coherent_si() # Convert to SI base units
# === Dimensional Analysis & Safety ===
# Automatic dimensional validation
try:
invalid = distance + time # Error: cannot add length + time
except RMNError:
print("Dimensional mismatch caught!")
# Complex calculations with unit tracking
kinetic_energy = 0.5 * Scalar(2, "kg") * speed**2 # Result: 2500 J
# === Unit and Dimensionality Operations ===
# Create and manipulate units
meter = Unit("m")
second = Unit("s")
velocity_unit = meter / second # Result: m/s
# Dimensional analysis
length_dim = Dimensionality("L")
time_dim = Dimensionality("T")
velocity_dim = length_dim / time_dim # Result: L/T
print(f"Speed: {speed}") # "50 m/s"
print(f"Unit: {speed.unit.symbol}") # "m/s"
print(f"Dimensionality: {speed.dimensionality.symbol}") # "L/T"
```
## Development
This package is built using Cython to provide efficient bindings to the underlying C libraries.
### Setting up the development environment
1. **Create conda environment:**
```bash
conda env create -f environment-dev.yml
conda activate rmnpy
```
2. **Sync libraries from local development:**
```bash
make synclib # Copy libraries from local ../OCTypes, ../SITypes, ../RMNLib
```
3. **Install in development mode:**
```bash
pip install -e .
```
### Building from source
```bash
git clone https://github.com/pjgrandinetti/RMNpy.git
cd RMNpy
conda env create -f environment.yml
conda activate rmnpy
make synclib # Copy libraries from local development
pip install -e .
```
### Makefile targets
- `make synclib` - Copy libraries from local ../OCTypes, ../SITypes, ../RMNLib directories
- `make download-libs` - Download libraries from GitHub releases (future feature)
- `make clean` - Remove generated C files and build artifacts
- `make clean-libs` - Remove local libraries to force re-download
- `make rebuild` - Clean libraries and rebuild Python package
- `make test` - Run the test suite
- `make status` - Check library status
See **[docs/development/DEVELOPMENT.md](docs/development/DEVELOPMENT.md)** for complete development workflows.
## Documentation
### User Documentation
- **API Documentation**: [Read the Docs](https://rmnpy.readthedocs.io) (when available)
### Development Documentation
- **[docs/development/README.md](docs/development/README.md)** - Navigation guide for all development docs
- **[docs/development/NEW_COMPUTER_SETUP.md](docs/development/NEW_COMPUTER_SETUP.md)** - Quick setup guide
- **[docs/development/ENVIRONMENT_SETUP.md](docs/development/ENVIRONMENT_SETUP.md)** - Detailed setup + troubleshooting
- **[docs/development/DEVELOPMENT.md](docs/development/DEVELOPMENT.md)** - Development workflow
- **[docs/development/RMNpy_Implementation_Plan.md](docs/development/RMNpy_Implementation_Plan.md)** - Project plan & progress
## License
See LICENSE file for details.
## Contributing
Contributions are welcome! Please see the development documentation for guidelines.
# Trigger CI after Unit test fix
Raw data
{
"_id": null,
"home_page": null,
"name": "rmnpy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Philip Grandinetti <grandinetti.1@osu.edu>",
"keywords": "scientific-computing, units, dimensional-analysis, nmr, spectroscopy, physics, chemistry, c-extensions, cython",
"author": null,
"author_email": "Philip Grandinetti <grandinetti.1@osu.edu>",
"download_url": null,
"platform": null,
"description": "# RMNpy\n\nPython bindings for OCTypes, SITypes, and RMNLib C libraries.\n\n> **\ud83d\ude80 Setting up on a new computer?** See **[docs/development/NEW_COMPUTER_SETUP.md](docs/development/NEW_COMPUTER_SETUP.md)** for quick setup or **[docs/development/ENVIRONMENT_SETUP.md](docs/development/ENVIRONMENT_SETUP.md)** for detailed instructions.\n\n## Overview\n\nRMNpy provides Python access to three scientific computing C libraries:\n\n- **OCTypes**: Objective-C style data structures and memory management\n- **SITypes**: Scientific units and dimensional analysis\n- **RMNLib**: High-level analysis and computation tools\n\n## Features\n\n- Type-safe conversion between Python and C data structures\n- Scientific units and dimensional analysis\n- High-performance numerical computations\n- Memory-safe interface to C libraries\n\n## Installation\n\n### For Development (Recommended)\n\nSee **[docs/development/ENVIRONMENT_SETUP.md](docs/development/ENVIRONMENT_SETUP.md)** for complete instructions.\n\nQuick version:\n```bash\n# Clone the repo with all C libraries\ngit clone https://github.com/pjgrandinetti/OCTypes-SITypes.git\ncd OCTypes-SITypes\n\n# Build required C libraries first\ncd OCTypes && make && make install && cd ..\ncd SITypes && make && make synclib && make install && cd ..\ncd RMNLib && make && make synclib && make install && cd ..\n\n# Set up Python environment\ncd RMNpy\nconda env create -f environment.yml\nconda activate rmnpy\npip install -e .\n```\n\n### For End Users (When Available)\n\n```bash\npip install rmnpy\n```\n\n**Platform Support:**\n- **Linux/macOS**: Python 3.8-3.12\n- **Windows**: Python 3.12 only (requires MSYS2 environment)\n\n### Windows (MSYS2/Mingw-w64 Python)\n\nTo install RMNpy with C99-based Cython extensions on Windows you must use the MSYS2 MINGW64 Python runtime:\n\n1. Install [MSYS2](https://www.msys2.org/) and open the **MSYS2 MinGW64** shell.\n2. Update packages and install dependencies:\n\n ```bash\n pacman -Syu # first-time update\n pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-python-pip \\\n mingw-w64-x86_64-openblas mingw-w64-x86_64-lapack \\\n mingw-w64-x86_64-curl mingw-w64-x86_64-make\n ```\n\n3. Create and activate a virtual environment (so pip can install into it):\n\n ```bash\n python -m pip install --upgrade pip virtualenv\n python -m virtualenv venv\n source venv/bin/activate\n ```\n\n4. Install RMNpy and test extras:\n\n ```bash\n pip install numpy pytest pytest-cov\n pip install -e .[test]\n ```\n\n5. Run your scripts or pytest from this venv; it uses MinGW-built extensions compatible with Windows.\n\n#### Using Conda-forge MSYS2 Environment (Optional)\nIf you prefer managing dependencies with conda, you can provision an MSYS2 toolchain via conda-forge:\n\n```bash\nconda create -n rmnpy-win python=3.12 pip m2-msys2-runtime m2-gcc m2-gcc-fortran m2-openblas m2-lapack m2-curl m2-make virtualenv -c conda-forge\nconda activate rmnpy-win\n# (Optional) isolate further via virtualenv within conda env:\npython -m venv venv\nsource venv/bin/activate\npip install -e .[test]\n```\n\n## Quick Start\n\n```python\nfrom rmnpy.wrappers.sitypes import Scalar, Unit, Dimensionality\n\n# === Flexible Scalar Creation ===\n\n# Single string expressions (value + unit)\nenergy = Scalar(\"100 J\") # 100 Joules\nvelocity = Scalar(\"25 m/s\") # 25 meters per second\n\n# Single numeric values (dimensionless)\nratio = Scalar(0.75) # 0.75 (dimensionless)\ncount = Scalar(42) # 42 (dimensionless)\nimpedance = Scalar(3+4j) # Complex number\n\n# Value and unit pairs\ndistance = Scalar(100, \"m\") # 100 meters\npower = Scalar(2.5, \"W\") # 2.5 Watts\ncurrent = Scalar(3+4j, \"A\") # Complex current\n\n# Named parameters\nunit_meter = Scalar(expression=\"m\") # 1 meter\nforce = Scalar(value=9.8, expression=\"kg*m/s^2\") # 9.8 Newtons\n\n# === Scientific Calculations with Automatic Units ===\n\n# Basic physics calculations\ntime = Scalar(2, \"s\")\nspeed = distance / time # Result: 50 m/s (automatic unit derivation)\nacceleration = Scalar(9.8, \"m/s^2\")\nforce = Scalar(5, \"kg\") * acceleration # Result: 49 N (automatic units)\n\n# Unit conversions\nspeed_kmh = speed.to(\"km/h\") # Convert to km/h\nspeed_si = speed.to_coherent_si() # Convert to SI base units\n\n# === Dimensional Analysis & Safety ===\n\n# Automatic dimensional validation\ntry:\n invalid = distance + time # Error: cannot add length + time\nexcept RMNError:\n print(\"Dimensional mismatch caught!\")\n\n# Complex calculations with unit tracking\nkinetic_energy = 0.5 * Scalar(2, \"kg\") * speed**2 # Result: 2500 J\n\n# === Unit and Dimensionality Operations ===\n\n# Create and manipulate units\nmeter = Unit(\"m\")\nsecond = Unit(\"s\")\nvelocity_unit = meter / second # Result: m/s\n\n# Dimensional analysis\nlength_dim = Dimensionality(\"L\")\ntime_dim = Dimensionality(\"T\")\nvelocity_dim = length_dim / time_dim # Result: L/T\n\nprint(f\"Speed: {speed}\") # \"50 m/s\"\nprint(f\"Unit: {speed.unit.symbol}\") # \"m/s\"\nprint(f\"Dimensionality: {speed.dimensionality.symbol}\") # \"L/T\"\n```\n\n## Development\n\nThis package is built using Cython to provide efficient bindings to the underlying C libraries.\n\n### Setting up the development environment\n\n1. **Create conda environment:**\n\n ```bash\n conda env create -f environment-dev.yml\n conda activate rmnpy\n ```\n\n2. **Sync libraries from local development:**\n\n ```bash\n make synclib # Copy libraries from local ../OCTypes, ../SITypes, ../RMNLib\n ```\n\n3. **Install in development mode:**\n\n ```bash\n pip install -e .\n ```\n\n### Building from source\n\n```bash\ngit clone https://github.com/pjgrandinetti/RMNpy.git\ncd RMNpy\nconda env create -f environment.yml\nconda activate rmnpy\nmake synclib # Copy libraries from local development\npip install -e .\n```\n\n### Makefile targets\n\n- `make synclib` - Copy libraries from local ../OCTypes, ../SITypes, ../RMNLib directories\n- `make download-libs` - Download libraries from GitHub releases (future feature)\n- `make clean` - Remove generated C files and build artifacts\n- `make clean-libs` - Remove local libraries to force re-download\n- `make rebuild` - Clean libraries and rebuild Python package\n- `make test` - Run the test suite\n- `make status` - Check library status\n\nSee **[docs/development/DEVELOPMENT.md](docs/development/DEVELOPMENT.md)** for complete development workflows.\n\n## Documentation\n\n### User Documentation\n\n- **API Documentation**: [Read the Docs](https://rmnpy.readthedocs.io) (when available)\n\n### Development Documentation\n\n- **[docs/development/README.md](docs/development/README.md)** - Navigation guide for all development docs\n- **[docs/development/NEW_COMPUTER_SETUP.md](docs/development/NEW_COMPUTER_SETUP.md)** - Quick setup guide\n- **[docs/development/ENVIRONMENT_SETUP.md](docs/development/ENVIRONMENT_SETUP.md)** - Detailed setup + troubleshooting\n- **[docs/development/DEVELOPMENT.md](docs/development/DEVELOPMENT.md)** - Development workflow\n- **[docs/development/RMNpy_Implementation_Plan.md](docs/development/RMNpy_Implementation_Plan.md)** - Project plan & progress\n\n## License\n\nSee LICENSE file for details.\n\n## Contributing\n\nContributions are welcome! Please see the development documentation for guidelines.\n# Trigger CI after Unit test fix\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python bindings for OCTypes, SITypes, and RMNLib C libraries for scientific computing with units and dimensional analysis",
"version": "0.1.0",
"project_urls": {
"Bug Reports": "https://github.com/pjgrandinetti/RMNpy/issues",
"CI/CD": "https://github.com/pjgrandinetti/RMNpy/actions",
"Changelog": "https://github.com/pjgrandinetti/RMNpy/blob/master/CHANGELOG.md",
"Documentation": "https://rmnpy.readthedocs.io",
"Homepage": "https://github.com/pjgrandinetti/RMNpy",
"Repository": "https://github.com/pjgrandinetti/RMNpy",
"Source Code": "https://github.com/pjgrandinetti/RMNpy"
},
"split_keywords": [
"scientific-computing",
" units",
" dimensional-analysis",
" nmr",
" spectroscopy",
" physics",
" chemistry",
" c-extensions",
" cython"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "610c3957f6c66344442e2e1cde8944ca432169571f37bddeabb2b9da76849b30",
"md5": "919e4b76eed404f22f875f0fd47ad89a",
"sha256": "08006fdb53f5a1b6d01f474ec3267134073c234c026dfd9befe6bc8869d0ee52"
},
"downloads": -1,
"filename": "rmnpy-0.1.0-cp310-cp310-macosx_10_9_universal2.whl",
"has_sig": false,
"md5_digest": "919e4b76eed404f22f875f0fd47ad89a",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 922204,
"upload_time": "2025-08-16T03:46:25",
"upload_time_iso_8601": "2025-08-16T03:46:25.005295Z",
"url": "https://files.pythonhosted.org/packages/61/0c/3957f6c66344442e2e1cde8944ca432169571f37bddeabb2b9da76849b30/rmnpy-0.1.0-cp310-cp310-macosx_10_9_universal2.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f6570878e7bd715080d8e64f0cfe00766da88fed6253ed87d9db672641e6d046",
"md5": "d4496d9a5b3b37f4931dd7d67fe3d11a",
"sha256": "9860ced700ae959f81e4918dee48563297617f4a218163c39d496e963e2c4443"
},
"downloads": -1,
"filename": "rmnpy-0.1.0-cp310-cp310-manylinux_2_38_x86_64.whl",
"has_sig": false,
"md5_digest": "d4496d9a5b3b37f4931dd7d67fe3d11a",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 27445221,
"upload_time": "2025-08-16T03:46:27",
"upload_time_iso_8601": "2025-08-16T03:46:27.674224Z",
"url": "https://files.pythonhosted.org/packages/f6/57/0878e7bd715080d8e64f0cfe00766da88fed6253ed87d9db672641e6d046/rmnpy-0.1.0-cp310-cp310-manylinux_2_38_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "2113ddd20d5f67ea7fa76bc6d79ed59af035ee1dc88d7c50533e8d15617b2420",
"md5": "03abe67b6a38b54d4187baa6006ef302",
"sha256": "44139dbe03da1778ebb5e5db2477e8bed8010165be575cfeb020d5bf7312ed51"
},
"downloads": -1,
"filename": "rmnpy-0.1.0-cp311-cp311-macosx_10_9_universal2.whl",
"has_sig": false,
"md5_digest": "03abe67b6a38b54d4187baa6006ef302",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 939423,
"upload_time": "2025-08-16T03:46:29",
"upload_time_iso_8601": "2025-08-16T03:46:29.975547Z",
"url": "https://files.pythonhosted.org/packages/21/13/ddd20d5f67ea7fa76bc6d79ed59af035ee1dc88d7c50533e8d15617b2420/rmnpy-0.1.0-cp311-cp311-macosx_10_9_universal2.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "feb9055fc42c434fb750a77044c362693b920d34177abd56606cc6e33ac602dd",
"md5": "45a74e6102ca5d745c8984d768ec112b",
"sha256": "d0e6300113101b2f4ba837f3c70204b1e9f956d7222a175d8bf50088401dadcf"
},
"downloads": -1,
"filename": "rmnpy-0.1.0-cp311-cp311-manylinux_2_38_x86_64.whl",
"has_sig": false,
"md5_digest": "45a74e6102ca5d745c8984d768ec112b",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 27632197,
"upload_time": "2025-08-16T03:46:32",
"upload_time_iso_8601": "2025-08-16T03:46:32.049628Z",
"url": "https://files.pythonhosted.org/packages/fe/b9/055fc42c434fb750a77044c362693b920d34177abd56606cc6e33ac602dd/rmnpy-0.1.0-cp311-cp311-manylinux_2_38_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8c7964c1ea324fdf32588bedd208f47a5c4985360d77d85f9d1b3d24f1c8ac07",
"md5": "b5b1ed3413c69548a72498b18cd6ae91",
"sha256": "114f7428c86915fb48f882eb75490f2c4ba05f7a59bfba2edc62df57f7f423ce"
},
"downloads": -1,
"filename": "rmnpy-0.1.0-cp312-cp312-macosx_10_13_universal2.whl",
"has_sig": false,
"md5_digest": "b5b1ed3413c69548a72498b18cd6ae91",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.8",
"size": 906168,
"upload_time": "2025-08-16T03:46:34",
"upload_time_iso_8601": "2025-08-16T03:46:34.012784Z",
"url": "https://files.pythonhosted.org/packages/8c/79/64c1ea324fdf32588bedd208f47a5c4985360d77d85f9d1b3d24f1c8ac07/rmnpy-0.1.0-cp312-cp312-macosx_10_13_universal2.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3976c1347aa380e79e1e4dd139797711e4caca5bd8af9ae544c104e0c5af870d",
"md5": "abfd2111ddb2d7ecdc850f5a5f61daf8",
"sha256": "690a637744a46f68e5795264bb9f2c1de0d1de317c595e0deb24c8dbb87f6370"
},
"downloads": -1,
"filename": "rmnpy-0.1.0-cp312-cp312-manylinux_2_38_x86_64.whl",
"has_sig": false,
"md5_digest": "abfd2111ddb2d7ecdc850f5a5f61daf8",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.8",
"size": 27524583,
"upload_time": "2025-08-16T03:46:36",
"upload_time_iso_8601": "2025-08-16T03:46:36.298116Z",
"url": "https://files.pythonhosted.org/packages/39/76/c1347aa380e79e1e4dd139797711e4caca5bd8af9ae544c104e0c5af870d/rmnpy-0.1.0-cp312-cp312-manylinux_2_38_x86_64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-16 03:46:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pjgrandinetti",
"github_project": "RMNpy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "rmnpy"
}