#[non_exhaustive]pub enum SlotErrorKind {
NotRead,
Duplicate,
Missing,
}Expand description
Names what is wrong with how a call’s crate::kernel::DistanceSources
match the slots of the kernel (GprError::DistanceSlot).
§Examples
use gprx::kernel::{RbfKernel, ScalarDistance};
use gprx::{Fixed, GaussianLikelihood, Gpr, GprError, SlotErrorKind};
let image = ScalarDistance::new();
let other = ScalarDistance::new();
let train = [0.0, 1.0, 1.0, 0.0];
let fitted = Gpr::new(image.kernel(RbfKernel::new(1.0)?), GaussianLikelihood::new(0.1)?)
.with_optimizer(Fixed)
.factor([image.borrow(&train)], 2, &[0.0, 1.0])
.map_err(|(_, e)| e)?;
// `other` is not a slot of the kernel.
let refused = fitted.predict([other.from_vec(vec![0.25, 0.25])], 1);
assert!(matches!(
refused,
Err(GprError::DistanceSlot { kind: SlotErrorKind::NotRead, slot: None })
));
// Two sources for slot 0.
let twice = fitted.predict(
[image.from_vec(vec![0.25, 0.25]), image.from_vec(vec![0.25, 0.25])],
1,
);
assert!(matches!(
twice,
Err(GprError::DistanceSlot { kind: SlotErrorKind::Duplicate, slot: Some(0) })
));
// No source for slot 0.
let none = fitted.predict(std::iter::empty(), 1);
assert!(matches!(
none,
Err(GprError::DistanceSlot { kind: SlotErrorKind::Missing, slot: Some(0) })
));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
NotRead
A source names a slot the kernel does not read. A loaded model reads
new slots (crate::persist::LoadedDistanceGpr::slots and its
twins), so a slot of the model before it was saved is one.
Duplicate
Two sources name the same slot.
Missing
A slot of the kernel has no source.
Trait Implementations§
Source§impl Clone for SlotErrorKind
impl Clone for SlotErrorKind
impl Copy for SlotErrorKind
Source§impl Debug for SlotErrorKind
impl Debug for SlotErrorKind
Source§impl Display for SlotErrorKind
impl Display for SlotErrorKind
impl Eq for SlotErrorKind
Source§impl PartialEq for SlotErrorKind
impl PartialEq for SlotErrorKind
impl StructuralPartialEq for SlotErrorKind
Auto Trait Implementations§
impl Freeze for SlotErrorKind
impl RefUnwindSafe for SlotErrorKind
impl Send for SlotErrorKind
impl Sync for SlotErrorKind
impl Unpin for SlotErrorKind
impl UnsafeUnpin for SlotErrorKind
impl UnwindSafe for SlotErrorKind
Blanket Implementations§
impl<T> Boilerplate for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more