Skip to content

Commit

Permalink
Change module name: tests -> predicates (#6)
Browse files Browse the repository at this point in the history
* Change module name: tests -> predicates

* Fix katex display style math
  • Loading branch information
NicklasXYZ committed Sep 17, 2023
1 parent 1fe5d7c commit 2b4c55e
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 181 deletions.
6 changes: 3 additions & 3 deletions src/gleam_community/maths/arithmetics.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//// // customised options
//// // • auto-render specific keys, e.g.:
//// delimiters: [
//// {left: '$$', right: '$$', display: true},
//// {left: '$', right: '$', display: false},
//// {left: '\\(', right: '\\)', display: false},
//// {left: '$$', right: '$$', display: false},
//// // {left: '$', right: '$', display: false},
//// // {left: '\\(', right: '\\)', display: false},
//// {left: '\\[', right: '\\]', display: true}
//// ],
//// // • rendering keys, e.g.:
Expand Down
6 changes: 3 additions & 3 deletions src/gleam_community/maths/combinatorics.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//// // customised options
//// // • auto-render specific keys, e.g.:
//// delimiters: [
//// {left: '$$', right: '$$', display: true},
//// {left: '$', right: '$', display: false},
//// {left: '\\(', right: '\\)', display: false},
//// {left: '$$', right: '$$', display: false},
//// // {left: '$', right: '$', display: false},
//// // {left: '\\(', right: '\\)', display: false},
//// {left: '\\[', right: '\\]', display: true}
//// ],
//// // • rendering keys, e.g.:
Expand Down
6 changes: 3 additions & 3 deletions src/gleam_community/maths/conversion.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//// // customised options
//// // • auto-render specific keys, e.g.:
//// delimiters: [
//// {left: '$$', right: '$$', display: true},
//// {left: '$', right: '$', display: false},
//// {left: '\\(', right: '\\)', display: false},
//// {left: '$$', right: '$$', display: false},
//// // {left: '$', right: '$', display: false},
//// // {left: '\\(', right: '\\)', display: false},
//// {left: '\\[', right: '\\]', display: true}
//// ],
//// // • rendering keys, e.g.:
Expand Down
6 changes: 3 additions & 3 deletions src/gleam_community/maths/elementary.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//// // customised options
//// // • auto-render specific keys, e.g.:
//// delimiters: [
//// {left: '$$', right: '$$', display: true},
//// {left: '$', right: '$', display: false},
//// {left: '\\(', right: '\\)', display: false},
//// {left: '$$', right: '$$', display: false},
//// // {left: '$', right: '$', display: false},
//// // {left: '\\(', right: '\\)', display: false},
//// {left: '\\[', right: '\\]', display: true}
//// ],
//// // • rendering keys, e.g.:
Expand Down
28 changes: 14 additions & 14 deletions src/gleam_community/maths/metrics.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//// // customised options
//// // • auto-render specific keys, e.g.:
//// delimiters: [
//// {left: '$$', right: '$$', display: true},
//// {left: '$', right: '$', display: false},
//// {left: '\\(', right: '\\)', display: false},
//// {left: '$$', right: '$$', display: false},
//// // {left: '$', right: '$', display: false},
//// // {left: '\\(', right: '\\)', display: false},
//// {left: '\\[', right: '\\]', display: true}
//// ],
//// // • rendering keys, e.g.:
Expand Down Expand Up @@ -40,7 +40,7 @@
import gleam_community/maths/elementary
import gleam_community/maths/piecewise
import gleam_community/maths/arithmetics
import gleam_community/maths/tests
import gleam_community/maths/predicates
import gleam_community/maths/conversion
import gleam/list
import gleam/pair
Expand All @@ -66,19 +66,19 @@ import gleam/float
/// import gleeunit/should
/// import gleam_community/maths/elementary
/// import gleam_community/maths/metrics
/// import gleam_community/maths/tests
/// import gleam_community/maths/predicates
///
/// pub fn example () {
/// let assert Ok(tol) = elementary.power(-10.0, -6.0)
///
/// [1.0, 1.0, 1.0]
/// |> metrics.norm(1.0)
/// |> tests.is_close(3.0, 0.0, tol)
/// |> predicates.is_close(3.0, 0.0, tol)
/// |> should.be_true()
///
/// [1.0, 1.0, 1.0]
/// |> metrics.norm(-1.0)
/// |> tests.is_close(0.3333333333333333, 0.0, tol)
/// |> predicates.is_close(0.3333333333333333, 0.0, tol)
/// |> should.be_true()
/// }
/// </details>
Expand Down Expand Up @@ -129,7 +129,7 @@ pub fn norm(arr: List(Float), p: Float) -> Float {
/// import gleeunit/should
/// import gleam_community/maths/elementary
/// import gleam_community/maths/metrics
/// import gleam_community/maths/tests
/// import gleam_community/maths/predicates
///
/// pub fn example () {
/// let assert Ok(tol) = elementary.power(-10.0, -6.0)
Expand All @@ -144,7 +144,7 @@ pub fn norm(arr: List(Float), p: Float) -> Float {
///
/// let assert Ok(result) = metrics.manhatten_distance([0.0, 0.0], [1.0, 2.0])
/// result
/// |> tests.is_close(3.0, 0.0, tol)
/// |> predicates.is_close(3.0, 0.0, tol)
/// |> should.be_true()
/// }
/// </details>
Expand Down Expand Up @@ -184,7 +184,7 @@ pub fn manhatten_distance(
/// import gleeunit/should
/// import gleam_community/maths/elementary
/// import gleam_community/maths/metrics
/// import gleam_community/maths/tests
/// import gleam_community/maths/predicates
///
/// pub fn example () {
/// let assert Ok(tol) = elementary.power(-10.0, -6.0)
Expand All @@ -203,7 +203,7 @@ pub fn manhatten_distance(
///
/// let assert Ok(result) = metrics.minkowski_distance([0.0, 0.0], [1.0, 2.0], 1.0)
/// result
/// |> tests.is_close(3.0, 0.0, tol)
/// |> predicates.is_close(3.0, 0.0, tol)
/// |> should.be_true()
/// }
/// </details>
Expand Down Expand Up @@ -261,7 +261,7 @@ pub fn minkowski_distance(
/// import gleeunit/should
/// import gleam_community/maths/elementary
/// import gleam_community/maths/metrics
/// import gleam_community/maths/tests
/// import gleam_community/maths/predicates
///
/// pub fn example () {
/// let assert Ok(tol) = elementary.power(-10.0, -6.0)
Expand All @@ -276,7 +276,7 @@ pub fn minkowski_distance(
///
/// let assert Ok(result) = metrics.euclidean_distance([0.0, 0.0], [1.0, 2.0])
/// result
/// |> tests.is_close(2.23606797749979, 0.0, tol)
/// |> predicates.is_close(2.23606797749979, 0.0, tol)
/// |> should.be_true()
/// }
/// </details>
Expand Down Expand Up @@ -395,7 +395,7 @@ pub fn median(arr: List(Float)) -> Result(Float, String) {
let count: Int = list.length(arr)
let mid: Int = list.length(arr) / 2
let sorted: List(Float) = list.sort(arr, float.compare)
case tests.is_odd(count) {
case predicates.is_odd(count) {
// If there is an odd number of elements in the list, then the median
// is just the middle value
True -> {
Expand Down
6 changes: 3 additions & 3 deletions src/gleam_community/maths/piecewise.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//// // customised options
//// // • auto-render specific keys, e.g.:
//// delimiters: [
//// {left: '$$', right: '$$', display: true},
//// {left: '$', right: '$', display: false},
//// {left: '\\(', right: '\\)', display: false},
//// {left: '$$', right: '$$', display: false},
//// // {left: '$', right: '$', display: false},
//// // {left: '\\(', right: '\\)', display: false},
//// {left: '\\[', right: '\\]', display: true}
//// ],
//// // • rendering keys, e.g.:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//// // customised options
//// // • auto-render specific keys, e.g.:
//// delimiters: [
//// {left: '$$', right: '$$', display: true},
//// {left: '$', right: '$', display: false},
//// {left: '\\(', right: '\\)', display: false},
//// {left: '$$', right: '$$', display: false},
//// // {left: '$', right: '$', display: false},
//// // {left: '\\(', right: '\\)', display: false},
//// {left: '\\[', right: '\\]', display: true}
//// ],
//// // • rendering keys, e.g.:
Expand All @@ -23,7 +23,7 @@
////
//// ---
////
//// Tests: A module containing functions for testing various mathematical properties of numbers.
//// Predicates: A module containing functions for testing various mathematical properties of numbers.
////
//// * **Tests**
//// * [`is_close`](#is_close)
Expand Down
18 changes: 9 additions & 9 deletions src/gleam_community/maths/sequences.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//// // customised options
//// // • auto-render specific keys, e.g.:
//// delimiters: [
//// {left: '$$', right: '$$', display: true},
//// {left: '$', right: '$', display: false},
//// {left: '\\(', right: '\\)', display: false},
//// {left: '$$', right: '$$', display: false},
//// // {left: '$', right: '$', display: false},
//// // {left: '\\(', right: '\\)', display: false},
//// {left: '\\[', right: '\\]', display: true}
//// ],
//// // • rendering keys, e.g.:
Expand Down Expand Up @@ -106,13 +106,13 @@ pub fn arange(start: Float, stop: Float, step: Float) -> List(Float) {
/// import gleeunit/should
/// import gleam_community/maths/elementary
/// import gleam_community/maths/sequences
/// import gleam_community/maths/tests
/// import gleam_community/maths/predicates
///
/// pub fn example () {
/// let assert Ok(tol) = elementary.power(-10.0, -6.0)
/// let assert Ok(linspace) = sequences.linear_space(10.0, 50.0, 5, True)
/// let assert Ok(result) =
/// tests.all_close(linspace, [10.0, 20.0, 30.0, 40.0, 50.0], 0.0, tol)
/// predicates.all_close(linspace, [10.0, 20.0, 30.0, 40.0, 50.0], 0.0, tol)
/// result
/// |> list.all(fn(x) { x == True })
/// |> should.be_true()
Expand Down Expand Up @@ -186,13 +186,13 @@ pub fn linear_space(
/// import gleeunit/should
/// import gleam_community/maths/elementary
/// import gleam_community/maths/sequences
/// import gleam_community/maths/tests
/// import gleam_community/maths/predicates
///
/// pub fn example () {
/// let assert Ok(tol) = elementary.power(-10.0, -6.0)
/// let assert Ok(logspace) = sequences.logarithmic_space(1.0, 3.0, 3, True, 10.0)
/// let assert Ok(result) =
/// tests.all_close(logspace, [10.0, 100.0, 1000.0], 0.0, tol)
/// predicates.all_close(logspace, [10.0, 100.0, 1000.0], 0.0, tol)
/// result
/// |> list.all(fn(x) { x == True })
/// |> should.be_true()
Expand Down Expand Up @@ -247,13 +247,13 @@ pub fn logarithmic_space(
/// import gleeunit/should
/// import gleam_community/maths/elementary
/// import gleam_community/maths/sequences
/// import gleam_community/maths/tests
/// import gleam_community/maths/predicates
///
/// pub fn example () {
/// let assert Ok(tol) = elementary.power(-10.0, -6.0)
/// let assert Ok(logspace) = sequences.geometric_space(10.0, 1000.0, 3, True)
/// let assert Ok(result) =
/// tests.all_close(logspace, [10.0, 100.0, 1000.0], 0.0, tol)
/// predicates.all_close(logspace, [10.0, 100.0, 1000.0], 0.0, tol)
/// result
/// |> list.all(fn(x) { x == True })
/// |> should.be_true()
Expand Down
6 changes: 3 additions & 3 deletions src/gleam_community/maths/special.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//// // customised options
//// // • auto-render specific keys, e.g.:
//// delimiters: [
//// {left: '$$', right: '$$', display: true},
//// {left: '$', right: '$', display: false},
//// {left: '\\(', right: '\\)', display: false},
//// {left: '$$', right: '$$', display: false},
//// // {left: '$', right: '$', display: false},
//// // {left: '\\(', right: '\\)', display: false},
//// {left: '\\[', right: '\\]', display: true}
//// ],
//// // • rendering keys, e.g.:
Expand Down
10 changes: 5 additions & 5 deletions test/gleam/gleam_community_maths_conversion.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gleam_community/maths/elementary
import gleam_community/maths/tests
import gleam_community/maths/predicates
import gleam_community/maths/conversion
import gleeunit
import gleeunit/should
Expand All @@ -11,22 +11,22 @@ pub fn main() {
pub fn float_to_degree_test() {
let assert Ok(tol) = elementary.power(-10.0, -6.0)
conversion.radians_to_degrees(0.0)
|> tests.is_close(0.0, 0.0, tol)
|> predicates.is_close(0.0, 0.0, tol)
|> should.be_true()

conversion.radians_to_degrees(2.0 *. elementary.pi())
|> tests.is_close(360.0, 0.0, tol)
|> predicates.is_close(360.0, 0.0, tol)
|> should.be_true()
}

pub fn float_to_radian_test() {
let assert Ok(tol) = elementary.power(-10.0, -6.0)
conversion.degrees_to_radians(0.0)
|> tests.is_close(0.0, 0.0, tol)
|> predicates.is_close(0.0, 0.0, tol)
|> should.be_true()

conversion.degrees_to_radians(360.0)
|> tests.is_close(2.0 *. elementary.pi(), 0.0, tol)
|> predicates.is_close(2.0 *. elementary.pi(), 0.0, tol)
|> should.be_true()
}

Expand Down
Loading

0 comments on commit 2b4c55e

Please sign in to comment.