Skip to content

Commit

Permalink
update to 2.2.0 (keep-starknet-strange#171)
Browse files Browse the repository at this point in the history
Ref title.

Please make sure to perform a release for the previous version
also performed a formatting as it changed
  • Loading branch information
gaetbout authored Sep 6, 2023
1 parent 7814854 commit a3052ff
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scarb 0.6.2
scarb 0.7.0
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@

Alexandria is a community maintained standard library for Cairo 1.0.
It is a collection of useful algorithms and data structures implemented in Cairo.
Current version: [v2.0.1](https://github.com/starkware-libs/cairo/releases/tag/v2.0.1)
Current version can be found in the [toml file](./Scarb.toml)

## Features

This repository is divided in 8 modules:
This repository is composed of multiple crates:

- [ASCII](./src/ascii/README.md)
- [Data Structures](./src/data_structures/README.md)
- [Encoding](./src/encoding/README.md)
- [Linalg](./src/linalg/README.md)
Expand Down
2 changes: 1 addition & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ description = "Community maintained Cairo and Starknet libraries"
homepage = "https://github.com/keep-starknet-strange/alexandria/"

[workspace.dependencies]
starknet = ">=2.1.1"
starknet = ">=2.2.0"

[scripts]
all = "scarb build && scarb test"
2 changes: 1 addition & 1 deletion src/data_structures/src/queue.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use array::ArrayTrait;
const ZERO_USIZE: usize = 0;

struct Queue<T> {
elements: Array<T>,
elements: Array<T>,
}

trait QueueTrait<T> {
Expand Down
4 changes: 2 additions & 2 deletions src/data_structures/src/stack.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl DestructFeltStack<
}

impl Felt252StackImpl<
T, impl TCopy: Copy<T>, impl TDrop: Drop<T>, impl TFelt252DictValue: Felt252DictValue<T>,
T, impl TCopy: Copy<T>, impl TDrop: Drop<T>, impl TFelt252DictValue: Felt252DictValue<T>,
> of StackTrait<Felt252Stack<T>, T> {
#[inline(always)]
/// Creates a new Stack instance.
Expand Down Expand Up @@ -123,7 +123,7 @@ impl DestructNullableStack<T, impl TDrop: Drop<T>> of Destruct<NullableStack<T>>
}

impl NullableStackImpl<
T, impl TCopy: Copy<T>, impl TDrop: Drop<T>,
T, impl TCopy: Copy<T>, impl TDrop: Drop<T>,
> of StackTrait<NullableStack<T>, T> {
#[inline(always)]
fn new() -> NullableStack<T> {
Expand Down
12 changes: 6 additions & 6 deletions src/data_structures/src/tests/vec_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fn felt252_vec_at_test() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Index out of bounds', ))]
#[should_panic(expected: ('Index out of bounds',))]
fn felt252_vec_at_out_of_bounds_test() {
let mut vec = VecTrait::<Felt252Vec, u128>::new();
vec_at_out_of_bounds_test(ref vec);
Expand All @@ -204,7 +204,7 @@ fn felt252_vec_set_test() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Index out of bounds', ))]
#[should_panic(expected: ('Index out of bounds',))]
fn felt252_vec_set_test_expect_error() {
let mut vec = VecTrait::<Felt252Vec, u128>::new();
vec_set_test_expect_error(ref vec, 1, 2);
Expand All @@ -219,7 +219,7 @@ fn felt252_vec_index_trait_test() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Index out of bounds', ))]
#[should_panic(expected: ('Index out of bounds',))]
fn felt252_vec_index_trait_out_of_bounds_test() {
let mut vec = VecTrait::<Felt252Vec, u128>::new();
vec_index_trait_out_of_bounds_test(ref vec, 1);
Expand Down Expand Up @@ -254,7 +254,7 @@ fn nullable_vec_at_test() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Index out of bounds', ))]
#[should_panic(expected: ('Index out of bounds',))]
fn nullable_vec_at_out_of_bounds_test() {
let mut vec = VecTrait::<NullableVec, u128>::new();
vec_at_out_of_bounds_test(ref vec);
Expand All @@ -276,7 +276,7 @@ fn nullable_vec_set_test() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Index out of bounds', ))]
#[should_panic(expected: ('Index out of bounds',))]
fn nullable_vec_set_test_expect_error() {
let mut vec = VecTrait::<NullableVec, u128>::new();
vec_set_test_expect_error(ref vec, 1, 2);
Expand All @@ -291,7 +291,7 @@ fn nullable_vec_index_trait_test() {

#[test]
#[available_gas(2000000)]
#[should_panic(expected: ('Index out of bounds', ))]
#[should_panic(expected: ('Index out of bounds',))]
fn nullable_vec_index_trait_out_of_bounds_test() {
let mut vec = VecTrait::<NullableVec, u128>::new();
vec_index_trait_out_of_bounds_test(ref vec, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/linalg/src/tests/dot_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn dot_product_test() {
}

#[test]
#[should_panic(expected: ('Arrays must have the same len', ))]
#[should_panic(expected: ('Arrays must have the same len',))]
#[available_gas(2000000)]
fn dot_product_test_check_len() {
let mut xs: Array<u64> = array![1];
Expand Down
2 changes: 1 addition & 1 deletion src/math/src/sha512.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const U64_BIT_NUM: u64 = 64;

#[derive(Drop, Copy)]
struct Word64 {
data: u64,
data: u64,
}

impl WordBitAnd of BitAnd<Word64> {
Expand Down
2 changes: 1 addition & 1 deletion src/math/src/tests/gcd_of_n_numbers_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn gcd_single_test() {

#[test]
#[available_gas(1000000000)]
#[should_panic(expected: ('EI', ))]
#[should_panic(expected: ('EI',))]
fn gcd_empty_input_test() {
let mut arr = array![];
gcd(arr.span());
Expand Down
4 changes: 2 additions & 2 deletions src/math/src/tests/karatsuba_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use alexandria_math::karatsuba::multiply;
// TODO All the out of gas have got lazily fixed. Maybe there is a way to fix those.
#[test]
#[available_gas(10000000)]
#[should_panic(expected: ('Out of gas', ))]
#[should_panic(expected: ('Out of gas',))]
fn multiply_same_size_positive_number() {
let n1 = 31415;
let n2 = 31415;
Expand All @@ -23,7 +23,7 @@ fn multiply_distinct_size_positive_number() {

#[test]
#[available_gas(20000000)]
#[should_panic(expected: ('Out of gas', ))]
#[should_panic(expected: ('Out of gas',))]
fn multiply_by_zero() {
let n1 = 10296;
let n2 = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/numeric/src/cumsum.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use option::OptionTrait;
/// * `sequence` - The sequence to operate.
/// # Returns
/// * `Array<T>` - The cumulative sum of sequence.
fn cumsum<T, impl TAdd: Add<T>, impl TCopy: Copy<T>, impl TDrop: Drop<T>, >(
fn cumsum<T, impl TAdd: Add<T>, impl TCopy: Copy<T>, impl TDrop: Drop<T>,>(
mut sequence: Span<T>
) -> Array<T> {
// [Check] Inputs
Expand Down
2 changes: 1 addition & 1 deletion src/numeric/src/tests/cumsum_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn cumsum_test() {
}

#[test]
#[should_panic(expected: ('Array must have at least 1 elt', ))]
#[should_panic(expected: ('Array must have at least 1 elt',))]
#[available_gas(2000000)]
fn cumsum_test_revert_empty() {
let xs: Array<u64> = array![];
Expand Down
4 changes: 2 additions & 2 deletions src/numeric/src/tests/diff_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ fn diff_test() {
}

#[test]
#[should_panic(expected: ('Sequence must be sorted', ))]
#[should_panic(expected: ('Sequence must be sorted',))]
#[available_gas(2000000)]
fn diff_test_revert_not_sorted() {
let xs: Array<u128> = array![3, 2];
let ys = diff(xs.span());
}

#[test]
#[should_panic(expected: ('Array must have at least 1 elt', ))]
#[should_panic(expected: ('Array must have at least 1 elt',))]
#[available_gas(2000000)]
fn diff_test_revert_empty() {
let xs: Array<u128> = array![];
Expand Down
4 changes: 2 additions & 2 deletions src/numeric/src/tests/interpolate_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn interp_constant_right_test() {
}

#[test]
#[should_panic(expected: ('Arrays must have the same len', ))]
#[should_panic(expected: ('Arrays must have the same len',))]
#[available_gas(2000000)]
fn interp_revert_len_mismatch() {
let xs: Array::<u64> = array![3, 5];
Expand All @@ -136,7 +136,7 @@ fn interp_revert_len_mismatch() {
}

#[test]
#[should_panic(expected: ('Array must have at least 2 elts', ))]
#[should_panic(expected: ('Array must have at least 2 elts',))]
#[available_gas(2000000)]
fn interp_revert_len_too_short() {
let xs: Array::<u64> = array![3];
Expand Down
6 changes: 3 additions & 3 deletions src/numeric/src/tests/trapezoidal_rule_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn trapezoidal_rule_test() {
}

#[test]
#[should_panic(expected: ('Arrays must have the same len', ))]
#[should_panic(expected: ('Arrays must have the same len',))]
#[available_gas(2000000)]
fn trapezoidal_rule_test_revert_len_mismatch() {
let xs: Array::<u64> = array![3];
Expand All @@ -19,7 +19,7 @@ fn trapezoidal_rule_test_revert_len_mismatch() {
}

#[test]
#[should_panic(expected: ('Array must have at least 2 elts', ))]
#[should_panic(expected: ('Array must have at least 2 elts',))]
#[available_gas(2000000)]
fn trapezoidal_rule_test_revert_len_too_short() {
let xs: Array::<u64> = array![3];
Expand All @@ -28,7 +28,7 @@ fn trapezoidal_rule_test_revert_len_too_short() {
}

#[test]
#[should_panic(expected: ('Abscissa must be sorted', ))]
#[should_panic(expected: ('Abscissa must be sorted',))]
#[available_gas(2000000)]
fn trapezoidal_rule_test_revert_not_sorted() {
let xs: Array::<u64> = array![5, 3];
Expand Down

0 comments on commit a3052ff

Please sign in to comment.