Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add missing integration stuff #1

Merged
merged 9 commits into from
May 5, 2024
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
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Summary

...

## Content

- Scope:
- [ ] Code: if relevant, add affected target
- [ ] Build script: if relevant, add affected target
- [ ] Documentation
- [ ] CI
- [ ] Repository
- [ ] Other: ...
- Type of change:
- [ ] New feature(s)
- [ ] Fix: if relevant, add issue #...
- [ ] Testing
- [ ] Refactor
- [ ] Revert
- [ ] Chore
- Other:
- [ ] Breaking change
- [ ] New dependency
- Necessary follow-up:
- [ ] Needs documentation
- [ ] Needs testing
- [ ] Other: ...
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build

on:
push:
branches: [ master ]
branches: [ trunk ]
pull_request:
branches: [ master ]
branches: [ trunk ]

env:
CARGO_TERM_COLOR: always
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: codecov

on:
push:
branches: [ trunk ]
pull_request:
branches: [ trunk ]

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: 1

jobs:
coverage:
runs-on: ubuntu-latest
steps:
# checkout
- uses: actions/checkout@v4
with:
submodules: recursive
# install requirements
- uses: dtolnay/rust-toolchain@stable
- name: Install llvm-tools-preview
run: rustup component add llvm-tools-preview
- name: Install grcov
run: cargo install grcov
- uses: Swatinem/rust-cache@v2
# generate raw coverage data
- name: Build code
run: cargo build --all-features
env:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"
- name: Run tests
run: cargo test --all-features
env:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"
# generate lcov file using grcov
- name: Run grcov
run: |
grcov . \
--binary-path ./target/debug/ \
-s . \
-t lcov \
--branch \
--ignore-not-existing \
--ignore '../*' \
--ignore "/*" \
-o target/tests.lcov
# upload results
- name: Upload reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/tests.lcov
slug: imrn99/integraal
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Documentation

on:
push:
branches: [ master ]
branches: [ trunk ]

env:
CARGO_TERM_COLOR: always
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish Crates

on:
release:
types: [ published ]

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: 1

jobs:
publish:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

# Publish
- name: Publish core
run: cargo publish
env:
CIO_TOKEN: ${{ secrets.CRATESIO_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tests

on:
push:
branches: [ master ]
branches: [ trunk ]
pull_request:
branches: [ master ]
branches: [ trunk ]

env:
CARGO_TERM_COLOR: always
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
# Integraal

![Current Version](https://img.shields.io/crates/v/integraal?label=latest%20release)
![GitHub commits since latest release](https://img.shields.io/github/commits-since/imrn99/integraal/latest)
![Build Status](https://github.com/imrn99/integraal/actions/workflows/build.yml/badge.svg)
![Rust Tests](https://github.com/imrn99/integraal/actions/workflows/rust-test.yml/badge.svg)
[![codecov](https://codecov.io/gh/imrn99/integraal/graph/badge.svg?token=YNIE4B0ZXS)](https://codecov.io/gh/imrn99/integraal)

*Integraal* aims to provide generic and efficient tools for [numerical integration][NI] in the Rust Programming
Language.

[NI]: https://en.wikipedia.org/wiki/Numerical_integration

## Quickstart

You can add Integraal to your project by adding this to its manifest:

```
# Cargo.toml

[dependencies]
# other deps...
integraal = { version = "*" }

```

The Rust Doc is available for usage instructions, examples are provided with the source code / in the repository.

## Contributing

Contributions are welcome and accepted as pull requests on [GitHub][GH]. Feel free to file an issue to report bugs,
Expand Down
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
//! crate doc
//! # Integraal
//!
//! *Integraal* aims to provide generic and efficient tools for [numerical integration][NI] in
//! the Rust Programming Language.
//!
//! The crate currently implements a very specific subsection of its ambitious scope. It roughly
//! corresponds to the example provided for the [`Integraal`] example.
//!
//! [NI]: https://en.wikipedia.org/wiki/Numerical_integration

// --- CUSTOM LINTS

Expand All @@ -7,6 +15,8 @@
// more lints
#![warn(clippy::pedantic)]
#![warn(missing_docs)]
// allow some exceptions
#![allow(clippy::cast_precision_loss)]

// --- MODULES DECLARATION

Expand All @@ -16,4 +26,4 @@ mod structure;
// --- RE-EXPORTS

pub use parameters::{ComputeMethod, DomainDescriptor, FunctionDescriptor};
pub use structure::Integraal;
pub use structure::{Integraal, IntegraalError};
25 changes: 21 additions & 4 deletions src/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,24 @@ pub enum IntegraalError {
/// ## Example
///
/// ```rust
/// todo!()
/// # use integraal::{DomainDescriptor, ComputeMethod, FunctionDescriptor, Integraal, IntegraalError};
/// # fn main() {
/// // describe domain, function & computation method
/// let domain = DomainDescriptor::Uniform {
/// start: 0.0,
/// step: 0.00001,
/// n_step: 100_001,
/// };
///
/// // decribe the function and numerical integration method
/// let function = FunctionDescriptor::Closure(Box::new(|x: f64| 2.0 * x));
/// let method = ComputeMethod::Trapezoid;
///
/// // build the integral & compute it
/// let mut integral = Integraal::default();
/// integral.domain(domain).function(function).method(method);
/// assert!(integral.compute().is_ok())
/// # }
/// ```
#[derive(Default)]
pub struct Integraal<'a> {
Expand Down Expand Up @@ -89,7 +106,7 @@ impl<'a> Integraal<'a> {
Some(FunctionDescriptor::Values(vals)),
Some(DomainDescriptor::Uniform {
start: _,
step,
step: _,
n_step,
}),
) => {
Expand All @@ -99,8 +116,8 @@ impl<'a> Integraal<'a> {
todo!()
}
(
Some(FunctionDescriptor::Closure(closure)),
Some(DomainDescriptor::Explicit(args)),
Some(FunctionDescriptor::Closure(_closure)),
Some(DomainDescriptor::Explicit(_args)),
) => {
todo!()
}
Expand Down