Dataset Viewer
Auto-converted to Parquet Duplicate
function_component
dict
function_name
stringlengths
3
35
focal_code
stringlengths
385
27.9k
file_path
stringlengths
28
76
file_content
stringlengths
869
132k
wrap_class
stringlengths
0
86.6k
class_signature
stringlengths
0
240
struct_class
stringlengths
0
2.87k
package_name
stringclasses
1 value
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}", "pub struct Point {\n pub x: f64,\n pub y: f64,\n}" ], "name": "points", ...
graham_scan
pub fn graham_scan(mut points: Vec<Point>) -> Vec<Point> { if points.len() <= 2 { return vec![]; } let min_point = points.iter().min_by(point_min).unwrap().clone(); points.retain(|p| p != &min_point); if points.is_empty() { // edge case where all the points are the same retu...
Rust-master/src/geometry/graham_scan.rs
use crate::geometry::Point; use std::cmp::Ordering; fn point_min(a: &&Point, b: &&Point) -> Ordering { // Find the bottom-most point. In the case of a tie, find the left-most. if a.y == b.y { a.x.partial_cmp(&b.x).unwrap() } else { a.y.partial_cmp(&b.y).unwrap() } } // Returns a Vec of...
{ "argument_definitions": [ { "definitions": [ "pub struct Point {\n pub x: f64,\n pub y: f64,\n}" ], "name": "points", "type": "&[Point]" } ], "end_line": 27, "name": "ramer_douglas_peucker", "signature": "pub fn ramer_douglas_peucker(points: &[Point], epsilon: f...
ramer_douglas_peucker
pub fn ramer_douglas_peucker(points: &[Point], epsilon: f64) -> Vec<Point> { if points.len() < 3 { return points.to_vec(); } let mut dmax = 0.0; let mut index = 0; let end = points.len() - 1; for i in 1..end { let d = perpendicular_distance(&points[i], &points[0], &points[end]);...
Rust-master/src/geometry/ramer_douglas_peucker.rs
use crate::geometry::Point; pub fn ramer_douglas_peucker(points: &[Point], epsilon: f64) -> Vec<Point> { if points.len() < 3 { return points.to_vec(); } let mut dmax = 0.0; let mut index = 0; let end = points.len() - 1; for i in 1..end { let d = perpendicular_distance(&points[i...
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}" ], "name": "data_points", "type": "Vec<(f64, f64" } ], "end_line": 70, "name...
k_means
pub fn k_means(data_points: Vec<(f64, f64)>, n_clusters: usize, max_iter: i32) -> Option<Vec<u32>> { if data_points.len() < n_clusters { return None; } let mut centroids: Vec<(f64, f64)> = Vec::new(); let mut labels: Vec<u32> = vec![0; data_points.len()]; for _ in 0..n_clusters { l...
Rust-master/src/machine_learning/k_means.rs
use rand::random; fn get_distance(p1: &(f64, f64), p2: &(f64, f64)) -> f64 { let dx: f64 = p1.0 - p2.0; let dy: f64 = p1.1 - p2.1; ((dx * dx) + (dy * dy)).sqrt() } fn find_nearest(data_point: &(f64, f64), centroids: &[(f64, f64)]) -> u32 { let mut cluster: u32 = 0; for (i, c) in centroids.iter()...
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}" ], "name": "mat", "type": "Vec<f64>" } ], "end_line": 31, "name": "cholesky"...
cholesky
pub fn cholesky(mat: Vec<f64>, n: usize) -> Vec<f64> { if (mat.is_empty()) || (n == 0) { return vec![]; } let mut res = vec![0.0; mat.len()]; for i in 0..n { for j in 0..=i { let mut s = 0.0; for k in 0..j { s += res[i * n + k] * res[j * n + k]; ...
Rust-master/src/machine_learning/cholesky.rs
pub fn cholesky(mat: Vec<f64>, n: usize) -> Vec<f64> { if (mat.is_empty()) || (n == 0) { return vec![]; } let mut res = vec![0.0; mat.len()]; for i in 0..n { for j in 0..=i { let mut s = 0.0; for k in 0..j { s += res[i * n + k] * res[j * n + k]; ...
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}", "pub struct Item {\n weight: usize,\n value: usize,\n}" ], "name": "items", ...
knapsack
pub fn knapsack(capacity: usize, items: Vec<Item>) -> KnapsackSolution { let num_items = items.len(); let item_weights: Vec<usize> = items.iter().map(|item| item.weight).collect(); let item_values: Vec<usize> = items.iter().map(|item| item.value).collect(); let knapsack_matrix = generate_knapsack_matri...
Rust-master/src/dynamic_programming/knapsack.rs
//! This module provides functionality to solve the knapsack problem using dynamic programming. //! It includes structures for items and solutions, and functions to compute the optimal solution. use std::cmp::Ordering; /// Represents an item with a weight and a value. #[derive(Debug, PartialEq, Eq)] pub struct Item {...
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}", "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = G...
minimum_cost_path
pub fn minimum_cost_path(matrix: Vec<Vec<usize>>) -> Result<usize, MatrixError> { // Check if the matrix is rectangular if !matrix.iter().all(|row| row.len() == matrix[0].len()) { return Err(MatrixError::NonRectangularMatrix); } // Check if the matrix is empty or contains empty rows if matr...
Rust-master/src/dynamic_programming/minimum_cost_path.rs
use std::cmp::min; /// Represents possible errors that can occur when calculating the minimum cost path in a matrix. #[derive(Debug, PartialEq, Eq)] pub enum MatrixError { /// Error indicating that the matrix is empty or has empty rows. EmptyMatrix, /// Error indicating that the matrix is not rectangular i...
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}" ], "name": "weights", "type": "Vec<f64>" }, { "definitions": [ "...
fractional_knapsack
pub fn fractional_knapsack(mut capacity: f64, weights: Vec<f64>, values: Vec<f64>) -> f64 { // vector of tuple of weights and their value/weight ratio let mut weights: Vec<(f64, f64)> = weights .iter() .zip(values.iter()) .map(|(&w, &v)| (w, v / w)) .collect(); // sort in de...
Rust-master/src/dynamic_programming/fractional_knapsack.rs
pub fn fractional_knapsack(mut capacity: f64, weights: Vec<f64>, values: Vec<f64>) -> f64 { // vector of tuple of weights and their value/weight ratio let mut weights: Vec<(f64, f64)> = weights .iter() .zip(values.iter()) .map(|(&w, &v)| (w, v / w)) .collect(); // sort in de...
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}", "pub enum Colors {\n Red, // \\\n White, // | Define the three colors of the Dutch Fla...
dutch_national_flag_sort
pub fn dutch_national_flag_sort(mut sequence: Vec<Colors>) -> Vec<Colors> { // We take ownership of `sequence` because the original `sequence` will be modified and then returned let length = sequence.len(); if length <= 1 { return sequence; // Arrays of length 0 or 1 are automatically sorted } ...
Rust-master/src/sorting/dutch_national_flag_sort.rs
/* A Rust implementation of the Dutch National Flag sorting algorithm. Reference implementation: https://github.com/TheAlgorithms/Python/blob/master/sorts/dutch_national_flag_sort.py More info: https://en.wikipedia.org/wiki/Dutch_national_flag_problem */ #[derive(PartialOrd, PartialEq, Eq)] pub enum Colors { Red,...
{ "argument_definitions": [ { "definitions": [ ") -> BTreeMap<V, Option<(V, E)>> {\n let mut ans = BTreeMap::new();\n let mut prio = BTreeSet::new();\n\n // start is the special case that doesn't have a predecessor\n ans.insert(start, None);\n\n for (new, weight) in &graph[&start] {\n...
dijkstra
pub fn dijkstra( graph: &Graph<V, E>, start: V, ) -> BTreeMap<V, Option<(V, E)>> { let mut ans = BTreeMap::new(); let mut prio = BTreeSet::new(); // start is the special case that doesn't have a predecessor ans.insert(start, None); for (new, weight) in &graph[&start] { ans.insert(*...
Rust-master/src/graph/dijkstra.rs
use std::collections::{BTreeMap, BTreeSet}; use std::ops::Add; type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>; // performs Dijsktra's algorithm on the given graph from the given start // the graph is a positively-weighted directed graph // // returns a map that for each reachable vertex associates the distance and th...
{ "argument_definitions": [ { "definitions": [ "struct Candidate<V, E> {\n estimated_weight: E,\n real_weight: E,\n state: V,\n}" ], "name": "graph", "type": "&Graph<V, E>" } ], "end_line": 99, "name": "astar", "signature": "pub fn astar(\n graph: &Graph<V, ...
astar
pub fn astar( graph: &Graph<V, E>, start: V, target: V, heuristic: impl Fn(V) -> E, ) -> Option<(E, Vec<V>)> { // traversal front let mut queue = BinaryHeap::new(); // maps each node to its predecessor in the final path let mut previous = BTreeMap::new(); // weights[v] is the accumul...
Rust-master/src/graph/astar.rs
use std::{ collections::{BTreeMap, BinaryHeap}, ops::Add, }; use num_traits::Zero; type Graph<V, E> = BTreeMap<V, BTreeMap<V, E>>; #[derive(Clone, Debug, Eq, PartialEq)] struct Candidate<V, E> { estimated_weight: E, real_weight: E, state: V, } impl<V: Ord + Copy, E: Ord + Copy> PartialOrd for Ca...
{ "argument_definitions": [ { "definitions": [ "pub struct Vec<T, #[unstable(feature = \"allocator_api\", issue = \"32838\")] A: Allocator = Global> {\n buf: RawVec<T, A>,\n len: usize,\n}" ], "name": "graph", "type": "&[Vec<usize>]" } ], "end_line": 140, "name": "f...
ford_fulkerson
pub fn ford_fulkerson( graph: &[Vec<usize>], source: usize, sink: usize, ) -> Result<usize, FordFulkersonError> { validate_ford_fulkerson_input(graph, source, sink)?; let mut residual_graph = graph.to_owned(); let mut parent = vec![usize::MAX; graph.len()]; let mut max_flow = 0; while ...
Rust-master/src/graph/ford_fulkerson.rs
//! The Ford-Fulkerson algorithm is a widely used algorithm to solve the maximum flow problem in a flow network. //! //! The maximum flow problem involves determining the maximum amount of flow that can be sent from a source vertex to a sink vertex //! in a directed weighted graph, subject to capacity constraints on th...
{ "argument_definitions": [ { "definitions": [ "pub struct Graph {\n #[allow(dead_code)]\n nodes: Vec<Node>,\n edges: Vec<Edge>,\n}" ], "name": "graph", "type": "&Graph" }, { "definitions": [ "pub struct Graph {\n #[allow(dead_code)]\n nodes: Ve...
breadth_first_search
pub fn breadth_first_search(graph: &Graph, root: Node, target: Node) -> Option<Vec<u32>> { let mut visited: HashSet<Node> = HashSet::new(); let mut history: Vec<u32> = Vec::new(); let mut queue = VecDeque::new(); visited.insert(root); queue.push_back(root); while let Some(currentnode) = queue.p...
Rust-master/src/graph/breadth_first_search.rs
use std::collections::HashSet; use std::collections::VecDeque; /// Perform a breadth-first search on Graph `graph`. /// /// # Parameters /// /// - `graph`: The graph to search. /// - `root`: The starting node of the graph from which to begin searching. /// - `target`: The target node for the search. /// /// # Returns ...
{ "argument_definitions": [ { "definitions": [ "pub struct Graph {\n #[allow(dead_code)]\n vertices: Vec<Vertex>,\n edges: Vec<Edge>,\n}" ], "name": "graph", "type": "&Graph" }, { "definitions": [ "pub struct Graph {\n #[allow(dead_code)]\n vert...
depth_first_search
pub fn depth_first_search(graph: &Graph, root: Vertex, objective: Vertex) -> Option<Vec<u32>> { let mut visited: HashSet<Vertex> = HashSet::new(); let mut history: Vec<u32> = Vec::new(); let mut queue = VecDeque::new(); queue.push_back(root); // While there is an element in the queue // get the...
Rust-master/src/graph/depth_first_search.rs
use std::collections::HashSet; use std::collections::VecDeque; // Perform a Depth First Search Algorithm to find a element in a graph // // Return a Optional with a vector with history of vertex visiteds // or a None if the element not exists on the graph pub fn depth_first_search(graph: &Graph, root: Vertex, objectiv...
{ "argument_definitions": [ { "definitions": [ "pub struct String {\n vec: Vec<u8>,\n}" ], "name": "s", "type": "String" } ], "end_line": 76, "name": "manacher", "signature": "pub fn manacher(s: String) -> String", "start_line": 1 }
manacher
pub fn manacher(s: String) -> String { let l = s.len(); if l <= 1 { return s; } // MEMO: We need to detect odd palindrome as well, // therefore, inserting dummy string so that // we can find a pair with dummy center character. let mut chars: Vec<char> = Vec::with_capacity(s.len() * ...
Rust-master/src/string/manacher.rs
pub fn manacher(s: String) -> String { let l = s.len(); if l <= 1 { return s; } // MEMO: We need to detect odd palindrome as well, // therefore, inserting dummy string so that // we can find a pair with dummy center character. let mut chars: Vec<char> = Vec::with_capacity(s.len() * ...
{ "argument_definitions": [], "end_line": 52, "name": "kth_smallest_heap", "signature": "pub fn kth_smallest_heap(input: &[T], k: usize) -> Option<T>", "start_line": 13 }
kth_smallest_heap
pub fn kth_smallest_heap(input: &[T], k: usize) -> Option<T> { if input.len() < k { return None; } // heap will maintain the kth smallest elements // seen so far, when new elements, E_new arrives, // it is compared with the largest element of the // current Heap E_large, which is the cu...
Rust-master/src/searching/kth_smallest_heap.rs
use crate::data_structures::Heap; use std::cmp::{Ord, Ordering}; /// Returns k-th smallest element of an array. /// Time complexity is stably O(nlog(k)) in all cases /// Extra space is required to maintain the heap, and it doesn't /// mutate the input list. /// /// It is preferrable to the partition-based algorithm in...
{ "argument_definitions": [], "end_line": 37, "name": "compute_totient", "signature": "pub fn compute_totient(n: i32) -> vec::Vec<i32>", "start_line": 11 }
compute_totient
pub fn compute_totient(n: i32) -> vec::Vec<i32> { let mut phi: Vec<i32> = Vec::new(); // initialize phi[i] = i for i in 0..=n { phi.push(i); } // Compute other Phi values for p in 2..=n { // If phi[p] is not computed already, // then number p is prime if phi[(p)...
Rust-master/src/number_theory/compute_totient.rs
// Totient function for // all numbers smaller than // or equal to n. // Computes and prints // totient of all numbers // smaller than or equal to n use std::vec; pub fn compute_totient(n: i32) -> vec::Vec<i32> { let mut phi: Vec<i32> = Vec::new(); // initialize phi[i] = i for i in 0..=n { phi.p...
{ "argument_definitions": [], "end_line": 60, "name": "fast_factorial", "signature": "pub fn fast_factorial(n: usize) -> BigUint", "start_line": 25 }
fast_factorial
pub fn fast_factorial(n: usize) -> BigUint { if n < 2 { return BigUint::one(); } // get list of primes that will be factors of n! let primes = sieve_of_eratosthenes(n); // Map the primes with their index let p_indices = primes .into_iter() .map(|p| (p, index(p, n))) ...
Rust-master/src/big_integer/fast_factorial.rs
// Algorithm created by Peter Borwein in 1985 // https://doi.org/10.1016/0196-6774(85)90006-9 use crate::math::sieve_of_eratosthenes; use num_bigint::BigUint; use num_traits::One; use std::collections::BTreeMap; /// Calculate the sum of n / p^i with integer division for all values of i fn index(p: usize, n: usize) ->...
{ "argument_definitions": [], "end_line": 59, "name": "transposition", "signature": "pub fn transposition(decrypt_mode: bool, msg: &str, key: &str) -> String", "start_line": 12 }
transposition
pub fn transposition(decrypt_mode: bool, msg: &str, key: &str) -> String { let key_uppercase = key.to_uppercase(); let mut cipher_msg: String = msg.to_string(); let keys: Vec<&str> = if decrypt_mode { key_uppercase.split_whitespace().rev().collect() } else { key_uppercase.split_whitespa...
Rust-master/src/ciphers/transposition.rs
//! Transposition Cipher //! //! The Transposition Cipher is a method of encryption by which a message is shifted //! according to a regular system, so that the ciphertext is a rearrangement of the //! original message. The most commonly referred to Transposition Cipher is the //! COLUMNAR TRANSPOSITION cipher, which i...
{ "argument_definitions": [], "end_line": 206, "name": "blake2b", "signature": "pub fn blake2b(m: &[u8], k: &[u8], nn: u8) -> Vec<u8>", "start_line": 179 }
blake2b
pub fn blake2b(m: &[u8], k: &[u8], nn: u8) -> Vec<u8> { let kk = min(k.len(), KK_MAX); let nn = min(nn, NN_MAX); // Prevent user from giving a key that is too long let k = &k[..kk]; let dd = max(ceil(kk, BB) + ceil(m.len(), BB), 1); let mut blocks: Vec<Block> = vec![blank_block(); dd]; /...
Rust-master/src/ciphers/blake2b.rs
// For specification go to https://www.rfc-editor.org/rfc/rfc7693 use std::cmp::{max, min}; use std::convert::{TryFrom, TryInto}; type Word = u64; const BB: usize = 128; const U64BYTES: usize = (u64::BITS as usize) / 8; type Block = [Word; BB / U64BYTES]; const KK_MAX: usize = 64; const NN_MAX: u8 = 64; // Array...
{ "argument_definitions": [], "end_line": 21, "name": "decimal_to_hexadecimal", "signature": "pub fn decimal_to_hexadecimal(base_num: u64) -> String", "start_line": 1 }
decimal_to_hexadecimal
pub fn decimal_to_hexadecimal(base_num: u64) -> String { let mut num = base_num; let mut hexadecimal_num = String::new(); loop { let remainder = num % 16; let hex_char = if remainder < 10 { (remainder as u8 + b'0') as char } else { (remainder as u8 - 10 + b'A...
Rust-master/src/conversions/decimal_to_hexadecimal.rs
pub fn decimal_to_hexadecimal(base_num: u64) -> String { let mut num = base_num; let mut hexadecimal_num = String::new(); loop { let remainder = num % 16; let hex_char = if remainder < 10 { (remainder as u8 + b'0') as char } else { (remainder as u8 - 10 + b'A...
{ "argument_definitions": [ { "definitions": [ "pub fn area_under_curve(start: f64, end: f64, func: fn(f64) -> f64, step_count: usize) -> f64 {\n assert!(step_count > 0);\n\n let (start, end) = if start > end {\n (end, start)\n } else {\n (start, end)\n }; //swap if bounds ...
area_under_curve
pub fn area_under_curve(start: f64, end: f64, func: fn(f64) -> f64, step_count: usize) -> f64 { assert!(step_count > 0); let (start, end) = if start > end { (end, start) } else { (start, end) }; //swap if bounds reversed let step_length: f64 = (end - start) / step_count as f64; ...
Rust-master/src/math/area_under_curve.rs
pub fn area_under_curve(start: f64, end: f64, func: fn(f64) -> f64, step_count: usize) -> f64 { assert!(step_count > 0); let (start, end) = if start > end { (end, start) } else { (start, end) }; //swap if bounds reversed let step_length: f64 = (end - start) / step_count as f64; ...
{ "argument_definitions": [], "end_line": 65, "name": "miller_rabin", "signature": "pub fn miller_rabin(number: u64, bases: &[u64]) -> u64", "start_line": 38 }
miller_rabin
pub fn miller_rabin(number: u64, bases: &[u64]) -> u64 { // returns zero on a probable prime, and a witness if number is not prime // A base set for deterministic performance on 64 bit numbers is: // [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] // another one for 32 bits: // [2, 3, 5, 7], with small...
Rust-master/src/math/miller_rabin.rs
use num_bigint::BigUint; use num_traits::{One, ToPrimitive, Zero}; use std::cmp::Ordering; fn modulo_power(mut base: u64, mut power: u64, modulo: u64) -> u64 { base %= modulo; if base == 0 { return 0; // return zero if base is divisible by modulo } let mut ans: u128 = 1; let mut bbase: u128...
{ "argument_definitions": [], "end_line": 101, "name": "bell_number", "signature": "pub fn bell_number(n: u32) -> BigUint", "start_line": 69 }
bell_number
pub fn bell_number(n: u32) -> BigUint { let needs_resize; // Check if number is already in lookup table { let lookup_table = LOOKUP_TABLE_LOCK.read().unwrap(); if let Some(entry) = lookup_table.get(n as usize) { return entry; } needs_resize = (n + 1) as usize >...
Rust-master/src/math/bell_numbers.rs
use num_bigint::BigUint; use num_traits::{One, Zero}; use std::sync::RwLock; /// Returns the number of ways you can select r items given n options fn n_choose_r(n: u32, r: u32) -> BigUint { if r == n || r == 0 { return One::one(); } if r > n { return Zero::zero(); } // Any combina...
{ "argument_definitions": [], "end_line": 56, "name": "least_square_approx", "signature": "pub fn least_square_approx(\n points: &[(T, U)],\n degree: i32,\n) -> Option<Vec<f64>>", "start_line": 12 }
least_square_approx
pub fn least_square_approx( points: &[(T, U)], degree: i32, ) -> Option<Vec<f64>> { use nalgebra::{DMatrix, DVector}; /* Used for rounding floating numbers */ fn round_to_decimals(value: f64, decimals: i32) -> f64 { let multiplier = 10f64.powi(decimals); (value * multiplier).round()...
Rust-master/src/math/least_square_approx.rs
/// Least Square Approximation <p> /// Function that returns a polynomial which very closely passes through the given points (in 2D) /// /// The result is made of coeficients, in descending order (from x^degree to free term) /// /// Parameters: /// /// points -> coordinates of given points /// /// degree -> degree of t...
{ "argument_definitions": [], "end_line": 84, "name": "modular_exponential", "signature": "pub fn modular_exponential(base: i64, mut power: i64, modulus: i64) -> i64", "start_line": 60 }
modular_exponential
pub fn modular_exponential(base: i64, mut power: i64, modulus: i64) -> i64 { if modulus == 1 { return 0; // Base case: any number modulo 1 is 0 } // Adjust if the exponent is negative by finding the modular inverse let mut base = if power < 0 { mod_inverse(base, modulus) } else { ...
Rust-master/src/math/modular_exponential.rs
/// Calculate the greatest common divisor (GCD) of two numbers and the /// coefficients of BΓ©zout's identity using the Extended Euclidean Algorithm. /// /// # Arguments /// /// * `a` - One of the numbers to find the GCD of /// * `m` - The other number to find the GCD of /// /// # Returns /// /// A tuple (gcd, x1, x2) s...
{ "argument_definitions": [], "end_line": 22, "name": "prime_factors", "signature": "pub fn prime_factors(n: u64) -> Vec<u64>", "start_line": 3 }
prime_factors
pub fn prime_factors(n: u64) -> Vec<u64> { let mut i = 2; let mut n = n; let mut factors = Vec::new(); while i * i <= n { if n % i != 0 { if i != 2 { i += 1; } i += 1; } else { n /= i; factors.push(i); } ...
Rust-master/src/math/prime_factors.rs
// Finds the prime factors of a number in increasing order, with repetition. pub fn prime_factors(n: u64) -> Vec<u64> { let mut i = 2; let mut n = n; let mut factors = Vec::new(); while i * i <= n { if n % i != 0 { if i != 2 { i += 1; } i += 1...
{ "argument_definitions": [], "end_line": 35, "name": "baby_step_giant_step", "signature": "pub fn baby_step_giant_step(a: usize, b: usize, n: usize) -> Option<usize>", "start_line": 13 }
baby_step_giant_step
pub fn baby_step_giant_step(a: usize, b: usize, n: usize) -> Option<usize> { if greatest_common_divisor::greatest_common_divisor_stein(a as u64, n as u64) != 1 { return None; } let mut h_map = HashMap::new(); let m = (n as f64).sqrt().ceil() as usize; // baby step let mut step = 1; ...
Rust-master/src/math/baby_step_giant_step.rs
use crate::math::greatest_common_divisor; /// Baby-step Giant-step algorithm /// /// Solving discrete logarithm problem: /// a^x = b (mod n) , with respect to gcd(a, n) == 1 /// with O(sqrt(n)) time complexity. /// /// Wikipedia reference: https://en.wikipedia.org/wiki/Baby-step_giant-step /// When a is the primiti...
{ "argument_definitions": [], "end_line": 41, "name": "trial_division", "signature": "pub fn trial_division(mut num: i128) -> Vec<i128>", "start_line": 10 }
trial_division
pub fn trial_division(mut num: i128) -> Vec<i128> { if num < 0 { return trial_division(-num); } let mut result: Vec<i128> = vec![]; if num == 0 { return result; } while num % 2 == 0 { result.push(2); num /= 2; num = double_to_int(floor(num as f64, 0)) ...
Rust-master/src/math/trial_division.rs
fn floor(value: f64, scale: u8) -> f64 { let multiplier = 10i64.pow(scale as u32) as f64; (value * multiplier).floor() } fn double_to_int(amount: f64) -> i128 { amount.round() as i128 } pub fn trial_division(mut num: i128) -> Vec<i128> { if num < 0 { return trial_division(-num); } let ...
{ "argument_definitions": [], "end_line": 27, "name": "zellers_congruence_algorithm", "signature": "pub fn zellers_congruence_algorithm(date: i32, month: i32, year: i32, as_string: bool) -> String", "start_line": 3 }
zellers_congruence_algorithm
pub fn zellers_congruence_algorithm(date: i32, month: i32, year: i32, as_string: bool) -> String { let q = date; let (m, y) = if month < 3 { (month + 12, year - 1) } else { (month, year) }; let day: i32 = (q + (26 * (m + 1) / 10) + (y % 100) + ((y % 100) / 4) + ((y / 100) / 4...
Rust-master/src/math/zellers_congruence_algorithm.rs
// returns the day of the week from the Gregorian Date pub fn zellers_congruence_algorithm(date: i32, month: i32, year: i32, as_string: bool) -> String { let q = date; let (m, y) = if month < 3 { (month + 12, year - 1) } else { (month, year) }; let day: i32 = (q + (26 * (m +...
{ "argument_definitions": [], "end_line": 23, "name": "prime_numbers", "signature": "pub fn prime_numbers(max: usize) -> Vec<usize>", "start_line": 1 }
prime_numbers
pub fn prime_numbers(max: usize) -> Vec<usize> { let mut result: Vec<usize> = Vec::new(); if max >= 2 { result.push(2) } for i in (3..=max).step_by(2) { let stop: usize = (i as f64).sqrt() as usize + 1; let mut status = true; for j in (3..stop).step_by(2) { ...
Rust-master/src/math/prime_numbers.rs
pub fn prime_numbers(max: usize) -> Vec<usize> { let mut result: Vec<usize> = Vec::new(); if max >= 2 { result.push(2) } for i in (3..=max).step_by(2) { let stop: usize = (i as f64).sqrt() as usize + 1; let mut status = true; for j in (3..stop).step_by(2) { ...
End of preview. Expand in Data Studio

πŸ“š Tessera: Exposing the Challenges of LLM-based Test Generation for Low-Resource Programming Languages

Tessera is a validation benchmark designed to measure how well models can generate unit tests for Low-Resource Programming Languages (LRPLs) β€” specifically Rust, Go, and Julia.

πŸ“Œ Purpose

Evaluate how well a model can generate test code, given a focal function's source code and additional context.

πŸ“‚ Dataset Structure

Each sample contains:

  • function_name: Name of the focal function.
  • focal_code: Raw source code of the focal function (used for context).
  • function_component: Detail information about the function like function signature,arguments definition,line range,...
  • file_content: Content of file have the focal function.
  • file_path: Relative path to the file in the repository. Additional fields like package_name, wrap_class, class_signature, or struct_class may depending on the programming language. If the language does not use these concepts, the values will be None or empty.

Dataset Size

The dataset contains ~372–412 samples per language, depending on the source repository.

Usage

from datasets import load_dataset
# Load full dataset
dataset = load_dataset("solis-soict/Tessera")
# Load individual language splits
rust_dataset = load_dataset("solis-soict/Tessera", split="rust")
go_dataset = load_dataset("solis-soict/Tessera", split="go")
julia_dataset = load_dataset("solis-soict/Tessera", split="julia")

Additional Information

Other Resources:

  • Github:
  • Paper:

Licence Information

MIT License

Citation Information

Downloads last month
13