-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from AleCandido/prepare_for_ndinterpolation
Update the code for n-d
- Loading branch information
Showing
11 changed files
with
178 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
[package] | ||
name = "ndinterp" | ||
version = "0.0.1" | ||
authors = ["Alessandro Candido <alessandro.candido@sns.it>"] | ||
edition = "2021" | ||
license = "GPL-3.0-or-later" | ||
repository = "https://github.com/AleCandido/ndinterp" | ||
edition.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
categories.workspace = true | ||
readme = "README.md" | ||
categories = ["science"] | ||
description = "N-dimensional interpolation library" | ||
keywords = ["math", "science"] | ||
|
||
[dependencies] | ||
ndarray = "0.15.4" | ||
ndarray-linalg = "0.14.1" | ||
petgraph = "0.6.2" | ||
thiserror = "1.0.40" | ||
itertools = "0.11.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,49 @@ | ||
use std::iter::zip; | ||
//! This module implements interpolation rutines | ||
use thiserror::Error; | ||
|
||
use crate::metric::Metric; | ||
|
||
/// Errors encountered during interpolation | ||
#[derive(Debug, Error)] | ||
pub enum InterpolationError { | ||
/// Raised when the queried value is above the maximum | ||
#[error("The value queried ({0}) is above the maximum")] | ||
ExtrapolationAbove(f64), | ||
|
||
/// Raised when the queried value is below the minimum | ||
#[error("The value queried ({0}) is below the minimum")] | ||
ExtrapolationBelow(f64), | ||
} | ||
|
||
/// Methods which all interpolator must implement | ||
pub trait Interpolator<T> { | ||
/// Produce the result of the inteprolation given a (nd) point 'query' | ||
fn interpolate(&self, query: T) -> Result<f64, InterpolationError>; | ||
} | ||
|
||
/// ---- deal with the stuff below later ---- | ||
pub trait Interpolate { | ||
type Point: Metric; | ||
|
||
fn interpolate(&self, query: &Self::Point) -> f64; | ||
} | ||
|
||
pub struct Input<Point: Metric> { | ||
pub point: Point, | ||
pub value: f64, | ||
} | ||
|
||
impl<Point: Metric> From<(Point, f64)> for Input<Point> { | ||
fn from(item: (Point, f64)) -> Self { | ||
Self { | ||
point: item.0, | ||
value: item.1, | ||
} | ||
} | ||
} | ||
|
||
impl<Point: Metric> Input<Point> { | ||
pub fn stack(points: Vec<Point>, values: Vec<f64>) -> Vec<Self> { | ||
zip(points.into_iter(), values.into_iter()) | ||
.map(|t| t.into()) | ||
.collect() | ||
} | ||
} | ||
///// ---- deal with the stuff below later ---- | ||
//pub trait Interpolate { | ||
// type Point: Metric; | ||
// | ||
// fn interpolate(&self, query: &Self::Point) -> f64; | ||
//} | ||
// | ||
//pub struct Input<Point: Metric> { | ||
// pub point: Point, | ||
// pub value: f64, | ||
//} | ||
// | ||
//impl<Point: Metric> From<(Point, f64)> for Input<Point> { | ||
// fn from(item: (Point, f64)) -> Self { | ||
// Self { | ||
// point: item.0, | ||
// value: item.1, | ||
// } | ||
// } | ||
//} | ||
// | ||
//impl<Point: Metric> Input<Point> { | ||
// pub fn stack(points: Vec<Point>, values: Vec<f64>) -> Vec<Self> { | ||
// zip(points.into_iter(), values.into_iter()) | ||
// .map(|t| t.into()) | ||
// .collect() | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
#![warn(clippy::all, clippy::cargo, clippy::nursery, clippy::pedantic)] | ||
#![warn(clippy::all, clippy::cargo)] | ||
#![warn(missing_docs)] | ||
#![doc = include_str!("../README.md")] | ||
#![warn(clippy::all, clippy::pedantic, clippy::restriction, clippy::cargo)] | ||
#![warn(missing_docs)] | ||
|
||
pub mod grid; | ||
pub mod interpolate; | ||
pub mod metric; | ||
pub mod scatter; | ||
//pub mod metric; | ||
//pub mod scatter; |
Oops, something went wrong.