Skip to content

Commit c15f509

Browse files
authored
Merge pull request #40 from NicklasXYZ/main
fix typos & update ci
2 parents 2d90bfc + 9e732ca commit c15f509

File tree

4 files changed

+42
-25
lines changed

4 files changed

+42
-25
lines changed

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313

1414
- uses: erlef/setup-beam@v1
1515
with:
16-
otp-version: "26.2"
17-
gleam-version: "1.4.1"
16+
otp-version: "27.0"
17+
gleam-version: "1.8.0"
1818

1919
- uses: actions/setup-node@v3
2020
with:

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919

2020
- uses: erlef/setup-beam@v1
2121
with:
22-
otp-version: "26.2"
23-
gleam-version: "1.4.1"
22+
otp-version: "27.0"
23+
gleam-version: "1.8.0"
2424

2525
- uses: actions/setup-node@v3
2626
with:

src/gleam_community/maths.gleam

+4-4
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub fn divisors(n: Int) -> List(Int) {
212212
fn find_divisors(n: Int) -> set.Set(Int) {
213213
let nabs = float.absolute_value(int.to_float(n))
214214
// Usage of let assert: 'nabs' is non-negative so no error should occur. The function
215-
// 'float.squre_root' will only return an error in case a non-negative value is given as input.
215+
// 'float.square_root' will only return an error in case a negative value is given as input.
216216
let assert Ok(sqrt_result) = float.square_root(nabs)
217217
let max = float.round(sqrt_result) + 1
218218

@@ -241,7 +241,7 @@ fn do_find_divisors(n: Int, max: Int, acc: set.Set(Int), i: Int) -> set.Set(Int)
241241
/// </div>
242242
///
243243
/// The function returns all the positive divisors of an integer, excluding the
244-
/// number iteself.
244+
/// number itself.
245245
///
246246
/// <details>
247247
/// <summary>Example:</summary>
@@ -735,7 +735,7 @@ pub fn polar_to_cartesian(r: Float, theta: Float) -> #(Float, Float) {
735735
pub fn cartesian_to_polar(x: Float, y: Float) -> #(Float, Float) {
736736
// Calculate 'r' and 'theta'
737737
// Usage of let assert: a sum of squares is always non-negative so no error should occur, i.e.,
738-
// the function 'float.squre_root' will only return an error in case a non-negative value is given
738+
// the function 'float.square_root' will only return an error in case a negative value is given
739739
// as input.
740740
let assert Ok(r) = float.square_root(x *. x +. y *. y)
741741
let theta = atan2(y, x)
@@ -1706,7 +1706,7 @@ pub fn tau() -> Float {
17061706
pub fn golden_ratio() -> Float {
17071707
// Calculate the golden ratio: (1 + sqrt(5)) / 2
17081708
// Usage of let assert: A positive number '5' is given a input so no error should occur, i.e.,
1709-
// the function 'float.squre_root' will only return an error in case a non-negative value is
1709+
// the function 'float.square_root' will only return an error in case a negative value is
17101710
// given as input.
17111711
let assert Ok(sqrt5) = float.square_root(5.0)
17121712
{ 1.0 +. sqrt5 } /. 2.0

test/gleam_community/elementary_test.gleam

+34-17
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,10 @@ pub fn natural_logarithm_test() {
287287
let assert Ok(tol) = float.power(10.0, -6.0)
288288
// Check that the function agrees, at some arbitrary input
289289
// points, with known function values
290-
maths.natural_logarithm(1.0)
291-
|> should.equal(Ok(0.0))
290+
let assert Ok(result) = maths.natural_logarithm(1.0)
291+
result
292+
|> maths.is_close(0.0, 0.0, tol)
293+
|> should.be_true()
292294

293295
let assert Ok(result) = maths.natural_logarithm(0.5)
294296
result
@@ -302,17 +304,24 @@ pub fn natural_logarithm_test() {
302304
}
303305

304306
pub fn logarithm_test() {
307+
let assert Ok(tol) = float.power(10.0, -6.0)
308+
305309
// Check that the function agrees, at some arbitrary input
306310
// points, with known function values
307-
maths.logarithm(10.0, 10.0)
308-
|> should.equal(Ok(1.0))
309-
310-
maths.logarithm(10.0, 100.0)
311-
|> should.equal(Ok(0.5))
311+
let assert Ok(result) = maths.logarithm(10.0, 10.0)
312+
result
313+
|> maths.is_close(1.0, 0.0, tol)
314+
|> should.be_true()
312315

313-
maths.logarithm(1.0, 0.25)
314-
|> should.equal(Ok(0.0))
316+
let assert Ok(result) = maths.logarithm(10.0, 100.0)
317+
result
318+
|> maths.is_close(0.5, 0.0, tol)
319+
|> should.be_true()
315320

321+
let assert Ok(result) = maths.logarithm(1.0, 0.25)
322+
result
323+
|> maths.is_close(0.0, 0.0, tol)
324+
|> should.be_true()
316325
// Check that we get an error when the function is evaluated
317326
// outside its domain
318327
maths.logarithm(1.0, 1.0)
@@ -324,11 +333,15 @@ pub fn logarithm_test() {
324333
maths.logarithm(-1.0, 1.0)
325334
|> should.be_error()
326335

327-
maths.logarithm(1.0, 10.0)
328-
|> should.equal(Ok(0.0))
336+
let assert Ok(result) = maths.logarithm(1.0, 10.0)
337+
result
338+
|> maths.is_close(0.0, 0.0, tol)
339+
|> should.be_true()
329340

330-
maths.logarithm(maths.e(), maths.e())
331-
|> should.equal(Ok(1.0))
341+
let assert Ok(result) = maths.logarithm(maths.e(), maths.e())
342+
result
343+
|> maths.is_close(1.0, 0.0, tol)
344+
|> should.be_true()
332345

333346
maths.logarithm(-1.0, 2.0)
334347
|> should.be_error()
@@ -338,11 +351,15 @@ pub fn logarithm_2_test() {
338351
let assert Ok(tol) = float.power(10.0, -6.0)
339352
// Check that the function agrees, at some arbitrary input
340353
// points, with known function values
341-
maths.logarithm_2(1.0)
342-
|> should.equal(Ok(0.0))
354+
let assert Ok(result) = maths.logarithm_2(1.0)
355+
result
356+
|> maths.is_close(0.0, 0.0, tol)
357+
|> should.be_true()
343358

344-
maths.logarithm_2(2.0)
345-
|> should.equal(Ok(1.0))
359+
let assert Ok(result) = maths.logarithm_2(2.0)
360+
result
361+
|> maths.is_close(1.0, 0.0, tol)
362+
|> should.be_true()
346363

347364
let assert Ok(result) = maths.logarithm_2(5.0)
348365
result

0 commit comments

Comments
 (0)