Skip to content

Commit 0af4a89

Browse files
Merge pull request #4 from SciML/interface
First pass of the interface code
2 parents 6f1bf49 + 3c635e7 commit 0af4a89

File tree

12 files changed

+220
-87
lines changed

12 files changed

+220
-87
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
- Core
2121
version:
2222
- '1'
23-
- '1.6'
2423
steps:
2524
- uses: actions/checkout@v4
2625
- uses: julia-actions/setup-julia@v1

.github/workflows/Downstream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
GROUP: ${{ matrix.package.group }}
1414
strategy:
1515
matrix:
16-
julia-version: [1,1.6]
16+
julia-version: [1]
1717
os: [ubuntu-latest]
1818
package:
1919
- {user: SciML, repo: SciMLBase.jl, group: Core}

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name = "SciMLStructures"
22
uuid = "53ae85a6-f571-4167-b2af-e1d143709226"
33
authors = ["SciML"]
4-
version = "0.1.0"
4+
version = "1.0.0"
55

66
[deps]
77

88
[compat]
9-
julia = "1.6"
9+
julia = "1.10"
1010

1111
[extras]
1212
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ are required to opt-into the interface.
3131
canonicalize(::AbstractPortion, p::T1) -> values::T2, repack, aliases::Bool
3232
repack(new_values::T2) -> p::T1 # with values replaced with new_values
3333
replace(::AbstractPortion, p::T1, new_values) -> p::T1
34-
replace!(p::T1)::Nothing # Requires mutable
34+
replace!(::AbstractPortion, p::T1)::Nothing # Requires mutable
3535
```
3636

3737
### Portion Defintions

docs/Project.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[deps]
2-
MultiScaleArrays = "f9640e96-87f6-5992-9c3b-0743c6a49ffa"
32
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
SciMLStructures = "53ae85a6-f571-4167-b2af-e1d143709226"
44

55
[compat]
6-
Documenter = "0.27"
7-
MultiScaleArrays = "1.10"
6+
Documenter = "1"

docs/make.jl

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
using Documenter, MultiScaleArrays
1+
using Documenter, SciMLStructures
22

33
cp("./docs/Manifest.toml", "./docs/src/assets/Manifest.toml", force = true)
44
cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
55

66
pages = [
77
"Home" => "index.md",
8+
"interface.md",
89
"api.md",
910
]
1011

11-
makedocs(sitename = "FunctionProperties.jl",
12-
authors = "Chris Rackauckas",
13-
modules = [FunctionProperties],
14-
clean = true, doctest = false, linkcheck = true,
15-
strict = [
16-
:doctest,
17-
:linkcheck,
18-
:parse_error,
19-
:example_block,
20-
# Other available options are
21-
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
22-
],
23-
format = Documenter.HTML(analytics = "UA-90474609-3",
24-
assets = ["assets/favicon.ico"],
25-
canonical = "https://docs.sciml.ai/FunctionProperties/stable/"),
26-
pages = pages)
12+
ENV["GKSwstype"] = "100"
2713

28-
deploydocs(repo = "github.com/SciML/MultiScaleArrays.jl.git";
29-
push_preview = true)
14+
makedocs(modules = [SciMLStructures],
15+
sitename = "SciMLStructures.jl",
16+
clean = true,
17+
doctest = false,
18+
linkcheck = true,
19+
warnonly = [:missing_docs, :cross_references, :linkcheck],
20+
format = Documenter.HTML(assets = ["assets/favicon.ico"],
21+
canonical = "https://docs.sciml.ai/SciMLStructures/stable/"),
22+
pages = pages)
23+
24+
deploydocs(repo = "github.com/SciML/SciMLStructures.jl"; push_preview = true)

docs/src/api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# API
22

3-
```@docs
4-
hasbranching
5-
```
3+
```@autodocs
4+
Modules = [SciMLStructures]
5+
```

docs/src/index.md

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,18 @@
1-
# FunctionProperties.jl: Compiler-Based Proofs of Function Properties
1+
# SciMLStructures.jl: Compiler-Based Proofs of Function Properties
22

3-
FunctionProperties.jl is a package which contains utilities for testing the
4-
properties of Julia functions. For example, do you need to know if `f` has
5-
internal branches (if statements) in order to know if a given AD optimization
6-
or symbolic pass is valid? This package's functions allows you to perform
7-
such analyses on functions from a user's code by doing a compiler-based
8-
code inspection.
3+
SciMLStructures.jl defines a generic interface for interacting with solvers, estimation tooling, and more within
4+
the SciML ecosystem and the greater Julia universe. SciMLStructures.jl defines a structured enforcable interface
5+
which allows for solvers to be able to handle custom user types in an efficient and generalized way.
96

107
## Installation
118

12-
To install FunctionProperties.jl, use the Julia package manager:
9+
To install SciMLStructures.jl, use the Julia package manager:
1310

1411
```julia
1512
using Pkg
16-
Pkg.add("FunctionProperties")
13+
Pkg.add("SciMLStructures")
1714
```
1815

19-
## Example
20-
21-
```julia
22-
@test hasbranching(1, 2) do x, y
23-
(x < 0 ? -x : x) + exp(y)
24-
end # true
25-
26-
@test hasbranching(1, 2) do x, y
27-
ifelse(x < 0, -x, x) + exp(y)
28-
end # false
29-
```
30-
31-
## This package uses Cassette internally?
32-
33-
Yes, because this is how it's currently known how to be done. If you have an alternative
34-
implementation which uses the undocumented compiler plugins interface, we would happily
35-
accept the PR!
36-
3716
## Contributing
3817

3918
- Please refer to the
@@ -42,7 +21,7 @@ accept the PR!
4221

4322
- See the [SciML Style Guide](https://github.com/SciML/SciMLStyle) for common coding practices and other style decisions.
4423
- There are a few community forums:
45-
24+
4625
+ The #diffeq-bridged and #sciml-bridged channels in the
4726
[Julia Slack](https://julialang.org/slack/)
4827
+ The #diffeq-bridged and #sciml-bridged channels in the
@@ -91,32 +70,19 @@ Pkg.status(; mode = PKGMODE_MANIFEST) # hide
9170
</details>
9271
```
9372

94-
```@raw html
95-
You can also download the
96-
<a href="
97-
```
98-
9973
```@eval
10074
using TOML
75+
using Markdown
10176
version = TOML.parse(read("../../Project.toml", String))["version"]
10277
name = TOML.parse(read("../../Project.toml", String))["name"]
103-
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
104-
"/assets/Manifest.toml"
105-
```
106-
107-
```@raw html
108-
">manifest</a> file and the
109-
<a href="
110-
```
111-
112-
```@eval
113-
using TOML
114-
version = TOML.parse(read("../../Project.toml", String))["version"]
115-
name = TOML.parse(read("../../Project.toml", String))["name"]
116-
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
117-
"/assets/Project.toml"
118-
```
119-
120-
```@raw html
121-
">project</a> file.
78+
link_manifest = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
79+
"/assets/Manifest.toml"
80+
link_project = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
81+
"/assets/Project.toml"
82+
Markdown.parse("""You can also download the
83+
[manifest]($link_manifest)
84+
file and the
85+
[project]($link_project)
86+
file.
87+
""")
12288
```

docs/src/interface.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# The SciMLStructure Interface
2+
3+
## Core Interface Definitions
4+
5+
### `isscimlstructure` Definition
6+
7+
```julia
8+
isscimlstructure(p)::Bool
9+
ismutablescimlstructure(p)::Bool
10+
```
11+
12+
Returns whether the object satisfies the SciMLStructure interface. Defaults to `false` and types
13+
are required to opt-into the interface.
14+
15+
### `canonicalize` Definition
16+
17+
```julia
18+
canonicalize(::AbstractPortion, p::T1) -> values::T2, repack, aliases::Bool
19+
repack(new_values::T2) -> p::T1 # with values replaced with new_values
20+
replace(::AbstractPortion, p::T1, new_values) -> p::T1
21+
replace!(::AbstractPortion, p::T1)::Nothing # Requires mutable
22+
```
23+
24+
### Portion Defintions
25+
26+
The core function of the interface is the `canonicalize` function. `canonicalize` allows the user to define
27+
to the solver how to represent the given "portion" in a standard `AbstractVector` type which allows for
28+
interfacing with standard tools like linear algebra in an efficient manner. The type of portions which
29+
are defined are:
30+
31+
* Tunable: the tunable values/parameters, i.e. the values of the structure which are supposed to be considered
32+
non-constant when used in the context of an inverse problem solve. For example, this is the set of
33+
parameters to be optimized during a parameter estimation of an ODE.
34+
* Tunable parameters are expected to return an `AbstractVector` of unitless values.
35+
* Constants: the values which are to be considered constant by the solver, i.e. values which are not estimated
36+
in an inverse problem and which are unchanged in any operation by the user as part of the solver's usage.
37+
* Caches: the stored cache values of the struct, i.e. the values of the structure which are used as intermediates
38+
within other computations in order to avoid extra allocations.
39+
* Discrete: the discrete portions of the state captured inside of the structure. For example, discrete values
40+
stored outside of the `u` in the parameters to be modified in the callbacks of an ODE.
41+
42+
## Definitions for Base Objects
43+
44+
* `Vector`: returns an aliased version of itself as `Tunable`, and an empty vector matching type for `Constants`,
45+
`Caches`, and `Discrete`.
46+
* `Array`: returns the `vec(p)` aliased version of itself as `Tunable`, and an empty vector matching type for `Constants`,
47+
`Caches`, and `Discrete`.

src/SciMLStructures.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module SciMLStructures
22

3-
function isscimlstructure end
3+
include("interface.jl")
4+
include("array.jl")
45

5-
function canonicalize end
6+
# public isscimlstructure, ismutablescimlstructure, hasportion, canonicalize,
7+
# replace, replace!, Tunable, Constants, Caches, Discrete
68

7-
8-
9-
end
9+
end

0 commit comments

Comments
 (0)