Skip to content

Commit c6f6e57

Browse files
Merge pull request #3 from devmotion/dw/statsfuns
Initial list of constants copied from StatsFuns
2 parents 615dc8c + c3e23f4 commit c6f6e57

File tree

8 files changed

+213
-1
lines changed

8 files changed

+213
-1
lines changed

.github/workflows/CI.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
version:
17+
- '1.0'
18+
- '1'
19+
- 'nightly'
20+
os:
21+
- ubuntu-latest
22+
arch:
23+
- x64
24+
include:
25+
- version: '1'
26+
os: ubuntu-latest
27+
arch: x64
28+
coverage: true
29+
steps:
30+
- uses: actions/checkout@v2
31+
- uses: julia-actions/setup-julia@v1
32+
with:
33+
version: ${{ matrix.version }}
34+
arch: ${{ matrix.arch }}
35+
- uses: actions/cache@v1
36+
env:
37+
cache-name: cache-artifacts
38+
with:
39+
path: ~/.julia/artifacts
40+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
41+
restore-keys: |
42+
${{ runner.os }}-test-${{ env.cache-name }}-
43+
${{ runner.os }}-test-
44+
${{ runner.os }}-
45+
- uses: julia-actions/julia-buildpkg@v1
46+
- uses: julia-actions/julia-runtest@v1
47+
with:
48+
coverage: ${{ matrix.coverage || false }}
49+
- uses: julia-actions/julia-processcoverage@v1
50+
if: matrix.coverage
51+
- uses: codecov/codecov-action@v1
52+
if: matrix.coverage
53+
with:
54+
file: lcov.info
55+
- uses: coverallsapp/github-action@master
56+
if: matrix.coverage
57+
with:
58+
github-token: ${{ secrets.GITHUB_TOKEN }}
59+
path-to-lcov: ./lcov.info

.github/workflows/CompatHelper.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CompatHelper
2+
3+
on:
4+
schedule:
5+
- cron: 0 0 * * *
6+
workflow_dispatch:
7+
8+
jobs:
9+
CompatHelper:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: "Install CompatHelper"
13+
run: |
14+
import Pkg
15+
name = "CompatHelper"
16+
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
17+
version = "2"
18+
Pkg.add(; name, uuid, version)
19+
shell: julia --color=yes {0}
20+
- name: "Run CompatHelper"
21+
run: |
22+
import CompatHelper
23+
CompatHelper.main()
24+
shell: julia --color=yes {0}
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}

.github/workflows/TagBot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: TagBot
2+
3+
on:
4+
issue_comment:
5+
types:
6+
- created
7+
workflow_dispatch:
8+
9+
jobs:
10+
TagBot:
11+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: JuliaRegistries/TagBot@v1
15+
with:
16+
token: ${{ secrets.GITHUB_TOKEN }}
17+
ssh: ${{ secrets.DOCUMENTER_KEY }}

Project.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name = "IrrationalConstants"
2+
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
3+
authors = ["JuliaMath"]
4+
version = "0.1.0"
5+
6+
[compat]
7+
julia = "1"
8+
9+
[extras]
10+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
11+
12+
[targets]
13+
test = ["Test"]

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
11
# IrrationalConstants.jl
2-
defines additional mathematical constants
2+
3+
[![Build Status](https://github.com/JuliaMath/IrrationalConstants.jl/workflows/CI/badge.svg?branch=main)](https://github.com/JuliaMath/IrrationalConstants.jl/actions/workflows/CI.yml?query=branch%3Amain)
4+
[![Coverage](https://codecov.io/gh/JuliaMath/IrrationalConstants.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaMath/IrrationalConstants.jl)
5+
[![Coverage](https://coveralls.io/repos/github/JuliaMath/IrrationalConstants.jl/badge.svg?branch=main)](https://coveralls.io/github/JuliaMath/IrrationalConstants.jl?branch=main)
6+
7+
This package defines the following irrational constants:
8+
9+
```julia
10+
twoπ #
11+
fourπ #
12+
halfπ # π / 2
13+
quartπ # π / 4
14+
invπ # 1 / π
15+
twoinvπ # 2 / π
16+
fourinvπ # 4 / π
17+
inv2π # 1 / (2π)
18+
inv4π # 1 / (4π)
19+
sqrt2 # √2
20+
sqrt3 # √3
21+
sqrtπ # √π
22+
sqrt2π # √2π
23+
sqrt4π # √4π
24+
sqrthalfπ # √(π / 2)
25+
invsqrt2 # 1 / √2
26+
invsqrt2π # 1 / √2π
27+
loghalf # log(1 / 2)
28+
logtwo # log(2)
29+
logπ # log(π)
30+
log2π # log(2π)
31+
log4π # log(4π)
32+
```
33+

src/IrrationalConstants.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module IrrationalConstants
2+
3+
using Base: @irrational
4+
5+
export
6+
twoπ, #
7+
fourπ, #
8+
halfπ, # π / 2
9+
quartπ, # π / 4
10+
invπ, # 1 / π
11+
twoinvπ, # 2 / π
12+
fourinvπ, # 4 / π
13+
inv2π, # 1 / (2π)
14+
inv4π, # 1 / (4π)
15+
sqrt2, # √2
16+
sqrt3, # √3
17+
sqrtπ, # √π
18+
sqrt2π, # √2π
19+
sqrt4π, # √4π
20+
sqrthalfπ, # √(π / 2)
21+
invsqrt2, # 1 / √2
22+
invsqrt2π, # 1 / √2π
23+
loghalf, # log(1 / 2)
24+
logtwo, # log(2)
25+
logπ, # log(π)
26+
log2π, # log(2π)
27+
log4π # log(4π)
28+
29+
include("stats.jl")
30+
31+
end # module

src/stats.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# mathematical constants related to statistics
2+
3+
@irrational twoπ 6.2831853071795864769 2 * big(π)
4+
@irrational fourπ 12.566370614359172954 4 * big(π)
5+
@irrational halfπ 1.5707963267948966192 big(π) / 2
6+
@irrational quartπ 0.7853981633974483096 big(π) / 4
7+
8+
@irrational invπ 0.31830988618379067154 inv(big(π))
9+
@irrational twoinvπ 0.63661977236758134308 2 / big(π)
10+
@irrational fourinvπ 1.27323954473516268615 4 / big(π)
11+
@irrational inv2π 0.159154943091895335769 inv(2 * big(π))
12+
@irrational inv4π 0.079577471545947667884 inv(4 * big(π))
13+
14+
@irrational sqrt2 1.4142135623730950488 sqrt(big(2))
15+
@irrational sqrt3 1.7320508075688772935 sqrt(big(3))
16+
@irrational sqrtπ 1.7724538509055160273 sqrt(big(π))
17+
@irrational sqrt2π 2.5066282746310005024 sqrt(2 * big(π))
18+
@irrational sqrt4π 3.5449077018110320546 sqrt(4 * big(π))
19+
@irrational sqrthalfπ 1.2533141373155002512 sqrt(big(π) / 2)
20+
21+
@irrational invsqrt2 0.7071067811865475244 inv(sqrt(big(2)))
22+
@irrational invsqrt2π 0.3989422804014326779 inv(sqrt(2 * big(π)))
23+
24+
@irrational loghalf -0.6931471805599453094 log(inv(big(2)))
25+
@irrational logtwo 0.6931471805599453094 log(big(2))
26+
@irrational logπ 1.1447298858494001741 log(big(π))
27+
@irrational log2π 1.8378770664093454836 log(2 * big(π))
28+
@irrational log4π 2.5310242469692907930 log(4 * big(π))

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using IrrationalConstants
2+
using Test
3+
4+
@testset "IrrationalConstants.jl" begin
5+
# Write your tests here.
6+
end

0 commit comments

Comments
 (0)