Skip to main content

Metric

Struct Metric 

Source
pub struct Metric {
    pub relative: Option<f64>,
    pub absolute: Option<f64>,
    pub not_scored: Option<String>,
}
Expand description

One metric of a case: how far hpr may be from the reference, or why it is not scored.

In a case file that is a table of one or both bounds:

[metrics.descent_time_s]
relative = 0.03

[metrics.drift_north_m]
relative = 0.03
absolute = 0.002    # this component passes through zero, so a fraction alone means nothing

A metric whose table sets neither is refused, because that is the “ungated metric” of Loft lesson L79 by another name.

The one alternative to a gate is to say, in the case file, that the metric is not scored and why:

[metrics.drift_north_m]
not_scored = "hpr and RocketPy differ by 28x on 0.5 mm and the cause is not established (#27)"

Such a metric is still measured and still printed, with both numbers, the difference and the reason: it is a gap on the face of the report, not a quiet omission and not a pass. Loft excused its two largest misses as “no single target” (Loft lesson L82), so the reason has to be written down, and hpr_validate::tests::the_metrics_that_are_not_scored_are_these_and_no_others pins the whole set: a new excuse has to be argued in a test whose name says what it is.

Fields§

§relative: Option<f64>

How far hpr may be from the reference, as a fraction of it (0.03 for 3%).

§absolute: Option<f64>

How far hpr may be from the reference, in the metric’s own unit.

§not_scored: Option<String>

Why the metric is measured and reported but not scored. Mutually exclusive with a bound.

Implementations§

Source§

impl Metric

Source

pub fn relative(relative: f64) -> Self

A relative bound alone.

Source

pub fn tolerance(&self) -> Tolerance

The bounds it holds hpr to.

Source

pub fn reason(&self) -> Option<&str>

The reason it is not scored, if it says one.

Source

pub fn check(&self, case: &str, name: &str) -> Result<(), String>

Checks that the metric is either gated or declared, and that its bounds are real numbers that bound something.

§Errors

A sentence naming what is wrong, for crate::run::ValidateError::Case.

Trait Implementations§

Source§

impl Clone for Metric

Source§

fn clone(&self) -> Metric

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 Metric

Source§

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

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

impl Default for Metric

Source§

fn default() -> Metric

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Metric

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Metric

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Metric

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Metric

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.