-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
115 additions
and
7 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
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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::collections::HashMap; | ||
|
||
use vortex::scalar::Scalar; | ||
use vortex::stats::Stat; | ||
use vortex_error::VortexResult; | ||
|
||
pub trait ArrayStatistics { | ||
fn statistics(&self) -> &dyn Statistics { | ||
&EmptyStatistics | ||
} | ||
|
||
/// Compute the requested statistic. Can return additional stats. | ||
fn compute_statistics(&self, _stat: &Stat) -> VortexResult<HashMap<Stat, Scalar>> { | ||
Ok(HashMap::new()) | ||
} | ||
} | ||
|
||
pub trait Statistics { | ||
fn compute(&self, stat: &Stat) -> VortexResult<Option<Scalar>>; | ||
fn get(&self, stat: &Stat) -> Option<Scalar>; | ||
} | ||
|
||
impl dyn Statistics { | ||
fn compute_as<T: TryFrom<Scalar>>(&self, _stat: &Stat) -> VortexResult<Option<T>> { | ||
// TODO(ngates): should we panic if conversion fails? | ||
todo!() | ||
} | ||
|
||
fn get_as<T: TryFrom<Scalar>>(&self, _stat: &Stat) -> Option<T> { | ||
todo!() | ||
} | ||
} | ||
|
||
pub struct EmptyStatistics; | ||
impl Statistics for EmptyStatistics { | ||
fn compute(&self, _stat: &Stat) -> VortexResult<Option<Scalar>> { | ||
Ok(None) | ||
} | ||
|
||
fn get(&self, _stat: &Stat) -> Option<Scalar> { | ||
None | ||
} | ||
} |
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