Merge branch 'main' into matr_eq

This commit is contained in:
Palash Tyagi 2025-04-26 02:39:48 +01:00 committed by GitHub
commit a188d162a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 74 additions and 10 deletions

4
.gitignore vendored
View File

@ -1,3 +1,7 @@
# Adding Cargo.lock as this is a library
Cargo.lock
/target /target
dev/ dev/

View File

@ -13,4 +13,3 @@ crate-type = ["cdylib", "lib"]
[dependencies] [dependencies]
chrono = "0.4.38" chrono = "0.4.38"
# rayon = "1.5"

View File

@ -1,16 +1,74 @@
# rustframe # rustframe
___ 📚 [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/)
[![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)
___
A simple dataframe library. <!-- [![Last commit](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)
[![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** elementwise `+`, ``, `×`, `÷` 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.
- **Datecentric row index** businessday ranges and calendar slicing built in.
- **Pure safe Rust** 100% safe, zero `unsafe`.
### Heads up
- **Not memoryefficient (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 20240102
let dates: Vec<NaiveDate> =
BDatesList::from_n_periods("2024-01-02".to_string(), BDateFreq::Daily, n_periods)
.unwrap()
.list()
.unwrap();
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],
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; // elementwise multiply
let total = result.matrix().sum_vertical().iter().sum::<f64>();
assert_eq!(total, 184.0);
```

View File

@ -1,7 +1,10 @@
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
/// Documentation for the [`crate::matrix`] module.
pub mod matrix; pub mod matrix;
/// Documentation for the [`crate::frame`] module.
pub mod frame; pub mod frame;
/// Documentation for the [`crate::utils`] module.
pub mod utils; pub mod utils;