From 883a5526a8ace789f7d2392b48176a456c36dc63 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:34:10 +0100 Subject: [PATCH 1/5] Add Cargo.lock to .gitignore for library management --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 0078be9..77b701d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ + +# Adding Cargo.lock as this is a library +Cargo.lock + /target dev/ From 74e0731c110d66f2df63a0e36055bc731dbc9516 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:34:41 +0100 Subject: [PATCH 2/5] Remove commented-out dependency for rayon in Cargo.toml --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 78b383b..524f55f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,4 +13,3 @@ crate-type = ["cdylib", "lib"] [dependencies] chrono = "0.4.38" -# rayon = "1.5" From 5883095bcc2c3cc33727f68e3f9ac42248d2bc6d Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:34:48 +0100 Subject: [PATCH 3/5] Add documentation comments for matrix, frame, and utils modules --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 7ea02d4..a68c8c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,10 @@ #![doc = include_str!("../README.md")] +/// Documentation for the [`crate::matrix`] module. pub mod matrix; +/// Documentation for the [`crate::frame`] module. pub mod frame; +/// Documentation for the [`crate::utils`] module. pub mod utils; From 4af584a748c2a7d45f629251ea3c3d9b63f82f51 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:35:38 +0100 Subject: [PATCH 4/5] Revise README.md for clarity and structure; enhance documentation and quick start section --- README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a1e4d0b..0388311 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,74 @@ # rustframe -___ -[![github-homepage](https://img.shields.io/endpoint?url=https://magnus167.github.io/rustframe/rustframe/last-commit-date.json)](https://github.com/Magnus167/rustframe) -[![codecov](https://codecov.io/gh/Magnus167/rustframe/graph/badge.svg?token=J7ULJEFTVI)](https://codecov.io/gh/Magnus167/rustframe) [![tarpaulin-badge](https://img.shields.io/endpoint?url=https://magnus167.github.io/rustframe/rustframe/tarpaulin-badge.json)](https://magnus167.github.io/rustframe/rustframe/tarpaulin-report.html) -___ +📚 [Docs](https://magnus167.github.io/rustframe/) | 🐙 [GitHub](https://github.com/Magnus167/rustframe) | 🌐 [Gitea mirror](https://gitea.nulltech.uk/Magnus167/rustframe) | 🦀 [Crates.io](https://crates.io/crates/rustframe) | 🔖 [docs.rs](https://docs.rs/rustframe/latest/rustframe/) -A simple dataframe library. + +[![codecov](https://codecov.io/gh/Magnus167/rustframe/graph/badge.svg?token=J7ULJEFTVI)](https://codecov.io/gh/Magnus167/rustframe) +[![Coverage](https://img.shields.io/endpoint?url=https://magnus167.github.io/rustframe/rustframe/tarpaulin-badge.json)](https://magnus167.github.io/rustframe/rustframe/tarpaulin-report.html) -Link to documentation: [https://magnus167.github.io/rustframe/](https://magnus167.github.io/rustframe/) +--- -Link to GitHub repo: [https://github.com/Magnus167/rustframe](https://github.com/Magnus167/rustframe) +## Rustframe: *A lightweight dataframe helper for Rust* -Link to crates.io: [https://crates.io/crates/rustframe](https://crates.io/crates/rustframe) +Rustframe is a simple dataframe helper for simple math and data manipulation in Rust. -Link to Gitea Mirror: [https://gitea.nulltech.uk/Magnus167/rustframe](https://gitea.nulltech.uk/Magnus167/rustframe) +Rustframe keeps things simple, safe, and readable. It is handy for quick numeric experiments and small analytical tasks, but it is **not** meant to compete with powerhouse crates like `polars` or `ndarray`. + +### What it offers + +- **Math that reads like math** – element‑wise `+`, `−`, `×`, `÷` on entire frames or scalars. +- **Broadcast & reduce** – sum, product, any/all across rows or columns without boilerplate. +- **Boolean masks made simple** – chain comparisons, combine with `&`/`|`, get a tidy `BoolMatrix` back. +- **Date‑centric row index** – business‑day ranges and calendar slicing built in. +- **Pure safe Rust** – 100 % safe, zero `unsafe`. + +### Heads up + +- **Not memory‑efficient (yet)** – footprint needs work. +- **Feature set still small** – expect missing pieces. + +### On the horizon + +- Optional GPU help (Vulkan or similar) for heavier workloads. +- Straightforward Python bindings using `pyo3`. + +--- + +## Quick start + +```rust +use chrono::NaiveDate; +use rustframe::{ + frame::{Frame, RowIndex}, + matrix::{BoolOps, Matrix, SeriesOps}, + utils::{BDateFreq, BDatesList}, +}; + +let n_periods = 4; + +// Four business days starting 2024‑01‑02 +a let dates: Vec = + BDatesList::from_n_periods("2024-01-02", BDateFreq::Daily, n_periods) + .unwrap() + .list() + .unwrap(); + +let col_names = vec!["a".into(), "b".into()]; + +let ma = Matrix::from_cols(vec![ + vec![1.0, 2.0, 3.0, 4.0], + vec![5.0, 6.0, 7.0, 8.0], +]); +let mb = Matrix::from_cols(vec![ + vec![4.0, 3.0, 2.0, 1.0], + vec![8.0, 7.0, 6.0, 5.0], +]); + +let fa = Frame::new(ma, col_names.clone(), Some(RowIndex::Date(dates.clone()))); +let fb = Frame::new(mb, col_names, Some(RowIndex::Date(dates))); + +// Math that reads like math +let result = &fa * &fb; // element‑wise multiply +let total = result.matrix().sum_vertical().iter().sum::(); +assert_eq!(total, 184.0); +``` From 3d5ef1a94ec80b3fe9f62a7ce16f733186227ac7 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sat, 26 Apr 2025 02:38:23 +0100 Subject: [PATCH 5/5] Fix string conversion in example code for clarity and consistency --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0388311..c3a69da 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,13 @@ use rustframe::{ let n_periods = 4; // Four business days starting 2024‑01‑02 -a let dates: Vec = - BDatesList::from_n_periods("2024-01-02", BDateFreq::Daily, n_periods) +let dates: Vec = + BDatesList::from_n_periods("2024-01-02".to_string(), BDateFreq::Daily, n_periods) .unwrap() .list() .unwrap(); -let col_names = vec!["a".into(), "b".into()]; +let col_names = vec!["a".to_string(), "b".to_string()]; let ma = Matrix::from_cols(vec![ vec![1.0, 2.0, 3.0, 4.0],