From f1b6961dd7139880587f0c9d8d773ae6ec16709e Mon Sep 17 00:00:00 2001 From: raphaelDkhn <113879115+raphaelDkhn@users.noreply.github.com> Date: Sun, 11 Aug 2024 20:06:45 +0300 Subject: [PATCH] restructure --- packages/algo/.tool-versions => .tool-versions | 0 Scarb.toml | 8 ++++++-- packages/algo/Scarb.toml | 1 + packages/algo/src/algo/cdf.cairo | 2 +- packages/algo/src/algo/linear_fit.cairo | 2 +- packages/algo/src/lib.cairo | 1 - packages/data_structures/Scarb.toml | 15 +++++++++++++++ packages/data_structures/src/lib.cairo | 3 +++ packages/data_structures/src/span.cairo | 14 ++++++++++++++ .../src/span}/span_fixed.cairo | 2 +- packages/ml/.tool-versions | 1 - packages/numbers/.tool-versions | 1 - 12 files changed, 42 insertions(+), 8 deletions(-) rename packages/algo/.tool-versions => .tool-versions (100%) create mode 100644 packages/data_structures/Scarb.toml create mode 100644 packages/data_structures/src/lib.cairo create mode 100644 packages/data_structures/src/span.cairo rename packages/{algo/src/span_math => data_structures/src/span}/span_fixed.cairo (99%) delete mode 100644 packages/ml/.tool-versions delete mode 100644 packages/numbers/.tool-versions diff --git a/packages/algo/.tool-versions b/.tool-versions similarity index 100% rename from packages/algo/.tool-versions rename to .tool-versions diff --git a/Scarb.toml b/Scarb.toml index e21692474..9c687bebc 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -1,5 +1,10 @@ [workspace] -members = ["packages/algo", "packages/ml", "packages/numbers"] +members = [ + "packages/algo", + "packages/ml", + "packages/numbers", + "package/data_structures", +] name = "orion" version = "0.1.0" description = "Cairo libraries to build the intelligence of verifiable agents" @@ -15,4 +20,3 @@ definitions = "proto/orion.proto" [cairo] enable-gas = false - diff --git a/packages/algo/Scarb.toml b/packages/algo/Scarb.toml index 4ec5559d1..d7385a216 100644 --- a/packages/algo/Scarb.toml +++ b/packages/algo/Scarb.toml @@ -10,6 +10,7 @@ cairo_test = "2.7.0" [dependencies] orion_numbers = { path = "../numbers" } +orion_data_structures = { path = "../data_structures" } [cairo] enable-gas=false \ No newline at end of file diff --git a/packages/algo/src/algo/cdf.cairo b/packages/algo/src/algo/cdf.cairo index 5ddc8f761..033e8715d 100644 --- a/packages/algo/src/algo/cdf.cairo +++ b/packages/algo/src/algo/cdf.cairo @@ -1,6 +1,6 @@ use core::array::{SpanTrait, SpanIter}; -use orion_algo::span_math::SpanMathTrait; use orion_numbers::FixedTrait; +use orion_data_structures::SpanMathTrait; /// Computes the cumulative distribution function (CDF) for a given set of values using the /// standard normal distribution formula. This implementation allows for optional location (`loc`) diff --git a/packages/algo/src/algo/linear_fit.cairo b/packages/algo/src/algo/linear_fit.cairo index 1b18efbdb..7728d8e18 100644 --- a/packages/algo/src/algo/linear_fit.cairo +++ b/packages/algo/src/algo/linear_fit.cairo @@ -1,4 +1,4 @@ -use orion_algo::span_math::SpanMathTrait; +use orion_data_structures::SpanMathTrait; use orion_numbers::FixedTrait; /// Performs a linear least squares fitting to provided data points. This function calculates diff --git a/packages/algo/src/lib.cairo b/packages/algo/src/lib.cairo index 24839e0c9..a17cc750c 100644 --- a/packages/algo/src/lib.cairo +++ b/packages/algo/src/lib.cairo @@ -1,2 +1 @@ -pub mod span_math; pub mod algo; diff --git a/packages/data_structures/Scarb.toml b/packages/data_structures/Scarb.toml new file mode 100644 index 000000000..91cb267ee --- /dev/null +++ b/packages/data_structures/Scarb.toml @@ -0,0 +1,15 @@ +[package] +name = "orion_data_structures" +version = "0.1.0" +edition = "2023_11" + +# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html + +[dev-dependencies] +cairo_test = "2.7.0" + +[dependencies] +orion_numbers = { path = "../numbers" } + +[cairo] +enable-gas=false \ No newline at end of file diff --git a/packages/data_structures/src/lib.cairo b/packages/data_structures/src/lib.cairo new file mode 100644 index 000000000..a742cedc3 --- /dev/null +++ b/packages/data_structures/src/lib.cairo @@ -0,0 +1,3 @@ +pub mod span; + +pub use {span::FixedSpanMath, span::SpanMathTrait}; diff --git a/packages/data_structures/src/span.cairo b/packages/data_structures/src/span.cairo new file mode 100644 index 000000000..d31ddf755 --- /dev/null +++ b/packages/data_structures/src/span.cairo @@ -0,0 +1,14 @@ +pub mod span_fixed; + +use orion_numbers::FixedTrait; + +pub use span_fixed::FixedSpanMath; + +pub trait SpanMathTrait { + fn arange(n: u32) -> Span; + fn dot(self: Span, other: Span) -> T; + fn max(self: Span) -> T; + fn min(self: Span) -> T; + fn prod(self: Span) -> T; + fn sum(self: Span) -> T; +} diff --git a/packages/algo/src/span_math/span_fixed.cairo b/packages/data_structures/src/span/span_fixed.cairo similarity index 99% rename from packages/algo/src/span_math/span_fixed.cairo rename to packages/data_structures/src/span/span_fixed.cairo index fd533e8b2..c61631c5b 100644 --- a/packages/algo/src/span_math/span_fixed.cairo +++ b/packages/data_structures/src/span/span_fixed.cairo @@ -2,7 +2,7 @@ use core::ops::AddAssign; use orion_numbers::{FixedTrait}; -use orion_algo::span_math::SpanMathTrait; +use super::SpanMathTrait; pub impl FixedSpanMath< diff --git a/packages/ml/.tool-versions b/packages/ml/.tool-versions deleted file mode 100644 index cfbafa68b..000000000 --- a/packages/ml/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -scarb nightly-2024-06-10 \ No newline at end of file diff --git a/packages/numbers/.tool-versions b/packages/numbers/.tool-versions deleted file mode 100644 index 4b769bfe0..000000000 --- a/packages/numbers/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -scarb 2.7.0 \ No newline at end of file