Skip to content

Commit

Permalink
Merge pull request #7 from SciML/smc/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
SebastianM-C authored Apr 7, 2024
2 parents 092469d + e76c4b5 commit 858f3d1
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 56 deletions.
2 changes: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[default.extend-words]
nin = "nin"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# UDEComponents

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://SebastianM-C.github.io/UDEComponents.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://SebastianM-C.github.io/UDEComponents.jl/dev/)
[![Build Status](https://github.com/SebastianM-C/UDEComponents.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/SebastianM-C/UDEComponents.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/SebastianM-C/UDEComponents.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/SebastianM-C/UDEComponents.jl)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://SciML.github.io/UDEComponents.jl/stable/)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://SciML.github.io/UDEComponents.jl/dev/)
[![Build Status](https://github.com/SciML/UDEComponents.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/SciML/UDEComponents.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/SciML/UDEComponents.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/SciML/UDEComponents.jl)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

Expand Down
26 changes: 13 additions & 13 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
using UDEComponents
using Documenter

DocMeta.setdocmeta!(UDEComponents, :DocTestSetup, :(using UDEComponents); recursive=true)
DocMeta.setdocmeta!(UDEComponents, :DocTestSetup, :(using UDEComponents); recursive = true)

makedocs(;
modules=[UDEComponents],
authors="Sebastian Micluța-Câmpeanu <[email protected]> and contributors",
sitename="UDEComponents.jl",
format=Documenter.HTML(;
canonical="https://SebastianM-C.github.io/UDEComponents.jl",
edit_link="main",
assets=String[],
modules = [UDEComponents],
authors = "Sebastian Micluța-Câmpeanu <[email protected]> and contributors",
sitename = "UDEComponents.jl",
format = Documenter.HTML(;
canonical = "https://SciML.github.io/UDEComponents.jl",
edit_link = "main",
assets = String[]
),
pages=[
"Home" => "index.md",
],
pages = [
"Home" => "index.md"
]
)

deploydocs(;
repo="github.com/SebastianM-C/UDEComponents.jl",
devbranch="main",
repo = "github.com/SciML/UDEComponents.jl",
devbranch = "main"
)
1 change: 0 additions & 1 deletion src/UDEComponents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ include("utils.jl")
include("hacks.jl") # this should be removed / upstreamed

"""
create_ude_component(n_input = 1, n_output = 1;
chain = multi_layer_feed_forward(n_input, n_output),
rng = Xoshiro(0))
Expand Down
23 changes: 2 additions & 21 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
function multi_layer_feed_forward(input_length, output_length; width::Int = 5,
depth::Int = 1, activation = softplus)
depth::Int = 1, activation = softplus, disable_optimizations = false)
Lux.Chain(Lux.Dense(input_length, width, activation),
[Lux.Dense(width, width, activation) for _ in 1:(depth)]...,
Lux.Dense(width, output_length); disable_optimizations = true)
Lux.Dense(width, output_length); disable_optimizations)
end

# Symbolics.@register_array_symbolic print_input(x) begin
# size = size(x)
# eltype = eltype(x)
# end

# function print_input(x)
# @info x
# x
# end

# function debug_component(n_input, n_output)
# @named input = RealInput(nin = n_input)
# @named output = RealOutput(nout = n_output)

# eqs = [output.u ~ print_input(input.u)]

# @named dbg_comp = ODESystem(eqs, t_nounits, [], [], systems = [input, output])
# end
26 changes: 11 additions & 15 deletions test/lotka_volterra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ end
model = lotka_ude()
nn = create_ude_component(2, 2)

eqs = [
connect(model.nn_in, nn.output)
connect(model.nn_out, nn.input)
]
eqs = [connect(model.nn_in, nn.output)
connect(model.nn_out, nn.input)]

ude_sys = complete(ODESystem(
eqs, ModelingToolkit.t_nounits, systems = [model, nn], name = :ude_sys))
Expand Down Expand Up @@ -83,7 +81,6 @@ function loss(x, (prob, sol_ref, get_vars, get_refs))
end
end


of = OptimizationFunction{true}(loss, AutoForwardDiff())

ps = (prob, sol_ref, get_vars, get_refs);
Expand All @@ -95,20 +92,19 @@ ps = (prob, sol_ref, get_vars, get_refs);

op = OptimizationProblem(of, x0, (prob, sol_ref, get_vars, get_refs))


# using Plots

# oh = []

plot_cb = (opt_state, loss) -> begin
@info "step $(opt_state.iter), loss: $loss"
# push!(oh, opt_state)
# new_p = SciMLStructures.replace(Tunable(), prob.p, opt_state.u)
# new_prob = remake(prob, p = new_p)
# sol = solve(new_prob, Rodas4())
# display(plot(sol))
false
end
# plot_cb = (opt_state, loss) -> begin
# @info "step $(opt_state.iter), loss: $loss"
# push!(oh, opt_state)
# new_p = SciMLStructures.replace(Tunable(), prob.p, opt_state.u)
# new_prob = remake(prob, p = new_p)
# sol = solve(new_prob, Rodas4())
# display(plot(sol))
# false
# end

res = solve(op, Adam(), maxiters = 2000)#, callback = plot_cb)

Expand Down
4 changes: 2 additions & 2 deletions test/qa.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ using UDEComponents
using Aqua
using JET

@testset verbose = true "Code quality (Aqua.jl)" begin
@testset verbose=true "Code quality (Aqua.jl)" begin
Aqua.find_persistent_tasks_deps(UDEComponents)
Aqua.test_ambiguities(UDEComponents, recursive = false)
Aqua.test_deps_compat(UDEComponents)
# TODO: fix type piracy in propagate_ndims and propagate_shape
Aqua.test_piracies(UDEComponents, broken=true)
Aqua.test_piracies(UDEComponents, broken = true)
Aqua.test_project_extras(UDEComponents)
Aqua.test_stale_deps(UDEComponents, ignore = Symbol[])
Aqua.test_unbound_args(UDEComponents)
Expand Down

0 comments on commit 858f3d1

Please sign in to comment.