Skip to main content

ClimateError

Enum ClimateError 

Source
#[non_exhaustive]
pub enum ClimateError { ShapeMismatch { argument: &'static str, expected: usize, actual: usize, }, EmptyPeriod { argument: &'static str, }, NonFinite { index_type: &'static str, }, IndexOutOfRange { argument: &'static str, value: i64, minimum: i64, maximum: i64, }, UnknownNanPolicy { value: String, }, RowsOutOfRange { argument: &'static str, start: usize, end: usize, length: usize, }, NoConvergence { message: &'static str, }, InsufficientData { required: usize, available: usize, }, }
Expand description

A structural input error or a numerical failure reported by a kernel.

Variants and their typed fields form the error contract. Diagnostic strings, including Display output, are not stable identifiers.

use climate_indices::{ClimateError, flood::effective_precipitation};
use ndarray::array;

let rain = array![[1.0]];
match effective_precipitation(rain.view(), 0) {
    Err(ClimateError::EmptyPeriod { argument }) => assert_eq!(argument, "duration"),
    Err(_) => panic!("unexpected error"),
    Ok(_) => panic!("a zero-day window must fail"),
}

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.
§

ShapeMismatch

An argument whose shape does not match the kernel’s expected shape.

Fields

§argument: &'static str

The argument that has the wrong shape.

§expected: usize

The expected axis length or total element count, as the kernel specifies.

§actual: usize

The supplied axis length or total element count.

§

EmptyPeriod

A calendar-period parameter with no calendar steps.

Fields

§argument: &'static str

The empty period argument.

§

NonFinite

A recurrence step produced a non-finite value from finite inputs.

Fields

§index_type: &'static str

The recurrence that failed.

§

IndexOutOfRange

A per-day or per-cell index outside the table it selects from.

Fields

§argument: &'static str

The table-index argument.

§value: i64

The supplied index.

§minimum: i64

The inclusive lower bound.

§maximum: i64

The inclusive upper bound.

§

UnknownNanPolicy

A missing-day policy name a kernel does not implement.

Fields

§value: String

The unrecognized policy name.

§

RowsOutOfRange

A row window (a Calibration Period) that does not lie inside its axis.

Fields

§argument: &'static str

The row-window argument.

§start: usize

The inclusive first row.

§end: usize

The exclusive last row.

§length: usize

The number of available rows.

§

NoConvergence

A calibration or recurrence stage that cannot produce a usable value.

Fields

§message: &'static str

A diagnostic description, not a stable failure identifier.

§

InsufficientData

A series too short (or too sparse) to fill a rolling window.

Fields

§required: usize

The minimum number of periods the window needs.

§available: usize

The number of non-missing periods supplied.

Trait Implementations§

Source§

impl Clone for ClimateError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClimateError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ClimateError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ClimateError

Source§

impl Error for ClimateError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for ClimateError

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ClimateError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.