From bc209ac864c1407cdcbd157a2c8aa352fad033f7 Mon Sep 17 00:00:00 2001 From: Ricardo Rosa Date: Sat, 22 Jul 2023 08:35:34 -0300 Subject: [PATCH 1/2] support math functions on NeuralNumbers --- Project.toml | 2 +- src/NeuralNumbers.jl | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index d5c3e7f..cbe0fa7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ChainPlots" uuid = "43761bbe-b505-42c3-b8bd-5d4ae40fd227" authors = ["Ricardo Rosa "] -version = "0.1.2" +version = "0.1.3" [deps] Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" diff --git a/src/NeuralNumbers.jl b/src/NeuralNumbers.jl index 21bc298..e8d7db3 100644 --- a/src/NeuralNumbers.jl +++ b/src/NeuralNumbers.jl @@ -98,17 +98,22 @@ Base.promote_rule(::Type{NeuralNumber}, ::Type{<:Number}) = NeuralNumber Random.rand(::Random.AbstractRNG, ::Random.Sampler{NeuralNumber}) = cold -for f in [:+, :-, :abs, :abs2, :inv, :tanh, :sqrt, - :exp, :log, :log1p, :log2, :log10, - :conj, :transpose, :adjoint, :angle] +for f in (:log, :exp, :sin, :cos, :tan, :sinh, :cosh, :tanh, :asin, + :acos, :atan, :asinh, :acosh, :atanh, :cbrt, :sqrt, :log2, :log10, + :max, :min, :exp2, :exp10, :expm1, :log1p, :sinpi, :cospi, :mod2pi, + ) @eval Base.$f(x::NeuralNumber) = x end -for f in [:+, :-, :*, :/, :^, :mod, :div, :rem, :widemul] +for f in (:+, :-, :abs, :abs2, :inv, :conj, :transpose, :adjoint, :angle) + @eval Base.$f(x::NeuralNumber) = x +end + +for f in (:+, :-, :*, :/, :^, :mod, :div, :rem, :widemul) @eval Base.$f(x::NeuralNumber, y::NeuralNumber) = max(x, y) end -for f in [:+, :-, :*, :/, :^, :mod, :div, :rem, :widemul] +for f in (:+, :-, :*, :/, :^, :mod, :div, :rem, :widemul) # specialize to avoid conflict with Base #= @eval Base.$f(x::NeuralNumber, ::Bool) = x @eval Base.$f(::Bool, y::NeuralNumber) = y =# From 987ccd6d982c1d804471a8b25311fe651ca9c0b0 Mon Sep 17 00:00:00 2001 From: Ricardo Rosa Date: Sat, 22 Jul 2023 08:39:52 -0300 Subject: [PATCH 2/2] fix PR branch for CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f31999d..25b909c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ on: - main pull_request: branches: - - master + - main jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}