Skip to content

Commit

Permalink
feat: change not to use Result in Instant Value Diff
Browse files Browse the repository at this point in the history
  • Loading branch information
tibetsou authored and tibetsou committed Jul 5, 2022
1 parent f9d8922 commit a695112
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opensrdk-probability"
version = "0.6.3"
version = "0.6.4"
authors = ["Kimura Yu <[email protected]>"]
edition = "2018"
description = "Standard probability library for OpenSRDK toolchain."
Expand Down
16 changes: 8 additions & 8 deletions src/distribution/instant_value_differentiable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ where
U: RandomVariable,
FF: Fn(&T, &U) -> Result<f64, DistributionError> + Clone + Send + Sync,
FS: Fn(&U, &mut dyn RngCore) -> Result<T, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Result<Vec<f64>, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Vec<f64> + Clone + Send + Sync,
{
instant_distribution: InstantDistribution<T, U, FF, FS>,
value_diff: G,
Expand All @@ -29,7 +29,7 @@ where
U: RandomVariable,
FF: Fn(&T, &U) -> Result<f64, DistributionError> + Clone + Send + Sync,
FS: Fn(&U, &mut dyn RngCore) -> Result<T, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Result<Vec<f64>, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Vec<f64> + Clone + Send + Sync,
{
pub fn new(instant_distribution: InstantDistribution<T, U, FF, FS>, value_diff: G) -> Self {
Self {
Expand All @@ -46,7 +46,7 @@ where
U: RandomVariable,
FF: Fn(&T, &U) -> Result<f64, DistributionError> + Clone + Send + Sync,
FS: Fn(&U, &mut dyn RngCore) -> Result<T, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Result<Vec<f64>, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Vec<f64> + Clone + Send + Sync,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "InstantDistribution")
Expand All @@ -59,7 +59,7 @@ where
U: RandomVariable,
FF: Fn(&T, &U) -> Result<f64, DistributionError> + Clone + Send + Sync,
FS: Fn(&U, &mut dyn RngCore) -> Result<T, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Result<Vec<f64>, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Vec<f64> + Clone + Send + Sync,
{
type Value = T;
type Condition = U;
Expand Down Expand Up @@ -90,7 +90,7 @@ where
TRhs: RandomVariable,
FF: Fn(&T, &U) -> Result<f64, DistributionError> + Clone + Send + Sync,
FS: Fn(&U, &mut dyn RngCore) -> Result<T, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Result<Vec<f64>, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Vec<f64> + Clone + Send + Sync,
{
type Output = IndependentJoint<Self, Rhs, T, TRhs, U>;

Expand All @@ -108,7 +108,7 @@ where
URhs: RandomVariable,
FF: Fn(&T, &U) -> Result<f64, DistributionError> + Clone + Send + Sync,
FS: Fn(&U, &mut dyn RngCore) -> Result<T, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Result<Vec<f64>, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Vec<f64> + Clone + Send + Sync,
{
type Output = DependentJoint<Self, Rhs, T, U, URhs>;

Expand All @@ -124,14 +124,14 @@ where
U: RandomVariable,
FF: Fn(&T, &U) -> Result<f64, DistributionError> + Clone + Send + Sync,
FS: Fn(&U, &mut dyn RngCore) -> Result<T, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Result<Vec<f64>, DistributionError> + Clone + Send + Sync,
G: Fn(&T, &U) -> Vec<f64> + Clone + Send + Sync,
{
fn ln_diff_value(
&self,
x: &Self::Value,
_theta: &Self::Condition,
) -> Result<Vec<f64>, DistributionError> {
let g = (self.value_diff)(x, _theta)?;
let g = (self.value_diff)(x, _theta);
Ok(g)
}
}

0 comments on commit a695112

Please sign in to comment.