licenses
sequencelengths 1
3
| version
stringclasses 677
values | tree_hash
stringlengths 40
40
| path
stringclasses 1
value | type
stringclasses 2
values | size
stringlengths 2
8
| text
stringlengths 25
67.1M
| package_name
stringlengths 2
41
| repo
stringlengths 33
86
|
---|---|---|---|---|---|---|---|---|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 2534 | using Documenter, SymbolicGA, Literate
const PLOT_DIRECTORY = joinpath(@__DIR__, "src", "plots")
function julia_files(dir)
files = reduce(vcat, [joinpath(root, file) for (root, dirs, files) in walkdir(dir) for file in files])
filter!(endswith(".jl"), files)
filter!(x -> !in(x, readdir(PLOT_DIRECTORY; join = true)), files)
sort!(files)
end
function replace_edit(content)
haskey(ENV, "JULIA_GITHUB_ACTIONS_CI") && return content
# Linking does not work locally, but we can make
# the warning go away with a hard link to the repo.
replace(
content,
r"EditURL = \".*<unknown>/(.*)\"" => s"EditURL = \"https://github.com/JuliaGPU/Vulkan.jl/tree/master/\1\"",
)
end
function generate_markdowns()
dir = joinpath(@__DIR__, "src")
Threads.@threads for file in julia_files(dir)
Literate.markdown(
file,
dirname(file);
postprocess = replace_edit,
documenter = true,
)
end
end
generate_markdowns()
analytics_asset = Documenter.Writers.HTMLWriter.HTMLAsset(
:js,
"https://plausible.io/js/script.js",
false,
Dict(:defer => "", Symbol("data-domain") => "serenity4.github.io"),
)
makedocs(;
modules = [SymbolicGA],
format = Documenter.HTML(
prettyurls = true,
assets = [analytics_asset],
canonical = "https://serenity4.github.io/SymbolicGA.jl/stable/",
),
pages = [
"Home" => "index.md",
"Glossary" => "glossary.md",
"Tutorials" => [
"Getting started" => "tutorial/getting_started.md",
"Euclidean transformations" => "tutorial/euclidean_transformations.md",
"Integration with your own types" => "tutorial/integration.md",
],
"Explanation" => [
"Geometric Algebra" => "explanation/geometric_algebra.md",
"Design" => "explanation/design.md",
],
"How to" => [
"Use macros with custom types" => "howto/integration.md",
"Create user-defined geometric spaces" => "howto/spaces.md",
],
"Reference" => [
"Symbols & operators" => "reference/symbols.md",
"API" => "reference/api.md",
],
],
repo = "https://github.com/serenity4/SymbolicGA.jl/blob/{commit}{path}#L{line}",
sitename = "SymbolicGA.jl",
authors = "serenity4 <[email protected]>",
doctest = false,
checkdocs = :exports,
)
deploydocs(
repo = "github.com/serenity4/SymbolicGA.jl.git",
)
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 1618 | #=
## [Use your own types in geometric algebra expressions](@id howto-integration)
### Inputs
If the type you use supports indexing, e.g. `Vector`, it already works:
=#
using SymbolicGA
x = rand(3)
y = rand(3)
@ga 3 x::1 ∧ y::1
# If your type does not support indexing, and you don't want it to, overload `SymbolicGA.getcomponent(::T, [i::Int, [j::Int]])`:
struct MyInputType{T}
values::Vector{T}
end
SymbolicGA.getcomponent(x::MyInputType, i::Int) = x.values[i]
x = MyInputType(rand(3))
y = MyInputType(rand(3))
@ga 3 x::1 ∧ y::1
#=
For scalars and aggregates of objects with multiple grades, you will need to overload `SymbolicGA.getcomponent(::T)` and `SymbolicGA.getcomponent(::T, j::Int, i::Int)` respectively (see [`SymbolicGA.getcomponent`](@ref)).
### Outputs
If you want to reconstruct a custom type from components, either define a constructor for a single tuple argument, e.g. `T(components::Tuple)`
=#
struct MyOutputType{T}
values::Vector{T}
end
MyOutputType(x::Tuple) = MyOutputType(collect(x))
x = rand(3)
y = rand(3)
@ga 3 MyOutputType dual(x::1 ∧ y::1)
# If you don't want such constructor to be defined, you can overload `SymbolicGA.construct(::Type{T}, ::Tuple)` directly:
struct MyOutputType2{T}
values::Vector{T}
end
SymbolicGA.construct(T::Type{<:MyOutputType2}, x::Tuple) = MyOutputType2(collect(x))
x = rand(3)
y = rand(3)
@ga 3 MyOutputType2 dual(x::1 ∧ y::1)
# Integrations for `Vector`, `Tuple` and `<:Real` have already been defined:
@ga 3 Tuple dual(x::1 ∧ y::1)
#-
@ga 3 Vector dual(x::1 ∧ y::1)
#-
z = rand(3)
@ga 3 Float16 dual(x::1 ∧ y::1 ∧ z::1)
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 787 | #=
# Creating user-defined geometric spaces
## Create a geometric space with default definitions
=#
using SymbolicGA
@geometric_space weird_space (3, 4, 5)
#-
x = rand(12); y = rand(12)
@weird_space x::1 ⟑ dual(y::1)
# ## Create a geometric space with extra definitions.
@geometric_space extra_space 3 quote
>>(x, y) = versor_product(y, x)
*(x, y) = geometric_product(y, x)
I = 1.0::e123
end
#-
x = rand(3); y = rand(3)
@extra_space begin
yᵈ = y::1 * I
yᵈ >> x::1
end
# ## Create a geometric space with non-default bindings.
bindings = Bindings(refs = Dict(:* => :geometric_product))
@geometric_space no_defaults 3 bindings
#-
x = rand(3); y = rand(3)
@no_defaults x::1 * y::1
# Note that you will always have access to the [built-in functions](@ref builtins).
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 1340 | # For the tutorial `euclidean_transformations.jl`.
using SymbolicGA
@geometric_space r3 "+++"
using Makie
using Makie.Colors
using GLMakie
a = (2.0, 0.0, 0.0)
b = (-2.0, 1.0, 0.0)
Π = @r3 a::1 ∧ b::1
rotate_3d(x, Π, α) = rotate_3d(x, @r3 exp(-(0.5α)::0 ⟑ unitize(Π::2)))
rotate_3d(x, Ω) = @r3 Tuple x::1 << Ω::(0, 2)
function rotating_plot()
scene = Scene(backgroundcolor = :black, fxaa = true, resolution = (1920, 1080))
cam3d!(scene; projectiontype = Makie.Perspective)
update_cam!(scene, Vec3f(4.0, 4.0, 2.0), Vec3f(0, 0, 0))
cam = cameracontrols(scene)
lines!(scene, [(0.0, 0.0, 0.0), @ga 3 Tuple dual(Π::2)]; color = "#bbaaff")
arrows!(scene, [Point3f(0.0, 0.0, 0.0)], Vec3f.([a, b]); color = [:lightgreen, :cyan], linewidth = 0.05, arrowsize = 0.15)
poly!(scene, Point3f[(0.0, 0.0, 0.0), a, a .+ b, b], color = "#bbaaff44")
start = (0.0, -1.0, 0.0)
prev = start
record(scene, joinpath(@__DIR__, "color_animation.mp4"), 0:2:360; framerate = 60) do angle
if !isempty(scene.plots)
for plot in scene.plots
isa(plot, Mesh) && delete!(scene, plot)
end
end
location = rotate_3d(start, Π, deg2rad(angle))
mesh!(scene, Sphere(Point3f(location), 0.1), color="#33bbff")
lines!(scene, Point3f[prev, location], color=:cyan)
prev = location
scene
end
end
rotating_plot()
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 9311 | #=
# Euclidean transformations
Geometric algebra being well suited for the representation of orthogonal transformations, we will go through different ways one can apply [Euclidean transformations](https://en.wikipedia.org/wiki/Rigid_transformation), using various geometric spaces of interest. Euclidean transformations are those which preserve the Euclidean distance between two points. They include reflections, rotations and translations expressed in an Euclidean space, as well as any composition of these. Orthogonal transformations only include reflections and rotations, but translations may be represented as orthogonal transformations within special non-Euclidean geometric spaces (quick hint: a translation may be viewed as a rotation following a circle of infinite radius).
## Transformations around the origin
The simplest transformations are defined around the origin. In contrast, take for example rotations around an axis that does not contain the origin, whose expression requires translations. Note that the translational part there is a trick to get back to the origin, apply the rotation, and revert the translation.
We will take $\mathbb{R}^3$ as our base space of interest, and define a geometric space over it:
=#
using SymbolicGA
# Generates a `@r3` macro.
@geometric_space r3 "+++"
#=
Note that we are not defining $\mathbb{R}^3$ itself, but rather $\mathcal{G}(\mathbb{R}^3)$, the geometric space around $\mathbb{R}^3$.
This macro will allow us to use geometric algebra expressions, that will be processed and return Julia code that can be evaluated which implements the operations we aim to perform.
We will not attempt to express a rotation as an action around an axis vector. For example, in 2D space, we will have to construct a rotation without reference to a third axis, which would only exist in 3D space. We will construct our rotation by specifying the plane in which the action should be carried out.
Such a plane may be parametrized by two non-colinear vectors, say `a` and `b`. We form such an object using the outer product, which has the effect of joining vectors `a` and `b` into a geometric entity which contains them both:
=#
a = (2.0, 0.0, 0.0)
b = (-2.0, 1.0, 0.0)
Π = @r3 a::1 ∧ b::1
# You will have noticed that neither `a` or `b` are unit vectors, and `Π` is not a unit plane. `a` and `b` are not orthogonal either. That is not a problem; we will handle that later, for now all we need is the plane in which they are contained, and therefore any choice of non-colinear vectors `a` and `b` will work.
# Next, we compute an object `Ω` which describes a rotation along a plane `Π` with angle `α`; `Π` needs to be a unit plane, so we add a unitization ("renormalization") step to enforce that.
α = π / 15
Ω = @r3 exp(-(0.5α)::0 ⟑ unitize(Π::2))
# `Ω` is a particular kind of object: a versor. Versors are geometric products of invertible vectors, and the exponentiation of a bivector is one way to obtain such a versor. Seeing that we obtain a scalar and a bivector, you could wonder: why not define `Ω = @r3 a::1 ⟑ b::1`? This is because `Ω` would then describe a very specific rotation: a rotation in the plane formed by `a` and `b` - so far so good -, but of twice the angle between `a` and `b` multiplied by `norm(a) * norm(b)`. If we want to apply a rotation with an arbitrary angle, we essentially have to find and join two unit vectors in the plane of rotation such that they form half the desired angle of rotation between them, `α / 2`. This is what the exponential form above parametrizes: for any `α`, the resulting `Ω` is the versor corresponding to two such vectors (in the plane of rotation, with an angle of `α / 2`), describing a rotation in that plane by an angle `α`.
# Say we want to rotate
x = (3.0, 4.0, 5.0)
# How should we apply `Ω` to `x`? The operation we seek to carry out is an orthogonal transformation, using `Ω`. In geometric algebra, orthogonal transformations are obtained by a specific operation on versors, termed the *versor product* (informally named the sandwich product). The versor product on `x` by `Ω` is defined as `Ω ⟑ x ⟑ inverse(Ω)`, which is defined by default with the `x << Ω` operator.
x′ = @r3 x::1 << Ω::(0, 2)
@assert x′ ≈ @r3 Ω::(0, 2) ⟑ x::1 ⟑ inverse(Ω::(0, 2))
using LinearAlgebra: norm # hide
@assert norm(x) ≈ norm(x′) # hide
x′
# The inverse rotation may be applied using the inverse of our versor Ω:
@assert KVector{1,3}(x) ≈ @r3 x′::1 << inv(Ω::(0, 2)) # hide
x′′ = @r3 x′::1 << inv(Ω::(0, 2))
#=
We did get `x` back! But numbers being a bit hard to visualize, we prepared a small animation to see the rotation in action using Makie:

Non-unit vectors `a` and `b` are represented in green and cyan. The bivector formed by `a` and `b` is represented as a purple semi-transparent parallelogram, with its dual - the normal of the plane - represented as a solid purple line.
## Transformations around arbitrary axes
We just performed a rotation around the origin. How can we get rotations around arbitrary points in space?
Although planes arised naturally to describe 3D rotations around the origin, things change a bit when rotating around arbitrary points. It is still valid to define rotations within specific planes, *but that plane must contain the object being rotated*. As we were working with geometries defined around the origin, it was always the case. In fact, the specificity of standard vector spaces such as $\mathcal{G}(\mathbb{R}^2)$ or $\mathcal{G}(\mathbb{R}^3)$ or their "vanilla" geometric spaces such as $\mathcal{G}(\mathbb{R}^2)$ or $\mathcal{G}(\mathbb{R}^3)$ is that geometric entities always contain the origin. A point is always represented by a vector pointing from the origin to a location, and this prevents vectors from being represented as entities invariant by affine transformations (which include translations). If you translate a vector in $\mathbb{R}^3$, only the target location of the vector is translated, but the origin remains the same. For geometric spaces, the situation is the same - they build from the base vector space, and therefore inherit their limitations. For example, bivectors are formed of vectors pointing from the origin, and therefore represent planes parametrized by three points: the point of origin, and the two vector target locations.
This limitation in terms of representation does not prevent translations from being defined, but they do not integrate well with the mathematical model; if you translate the whole space, geometric operations do not represent the same thing before and after the translation. Just like vectors, a translated bivector represents a different plane, and not one that is a translation of the original. The "mathematical" way of saying all this, is that Euclidean space (and Euclidean geometry - geometries represented using Euclidean space) is not invariant with respect to translation.
Coming from another angle, you could ask: "Why, in the first place, do we special-case an origin - aren't all points in 3D space considered the same?". Well, an Euclidean space is one in which angles are defined and points are parametrized by numbers - coordinates -, enabling various measurements; it is the space as seen from a specific location, the origin. No wonder that translating it results in a different space.
We therefore need another space. The spaces that are invariant with respect to translations (and rotations) are called affine spaces. In these spaces, points and vectors are different from each other; adding two points is undefined, while vectors can be added and points translated by vectors. Affine spaces are the intrinsic space we generally compute in - but because we need to represent points with numbers, we identify an origin to allow for a coordinate system, and carry operations in Euclidean space. Forgetting about the origin and staying purely in affine space is tricky; even if we can mathematically describe elements in affine spaces, without an origin we cannot describe them with numerical values.
How can we get out of this situation? We need to find another space, which has an origin so we can numerically represent objects with coordinates, but which also contains an affine space as a subspace. The classical setting is to use a four-dimensional Euclidean space, and use a three-dimensional hyperplane located at `w = 1`; in other terms, Euclidean 3D space is embedded within the four-dimensional Euclidean space with the map $(x, y, z) \rightarrow (x, y, z, 1)$. It works well in removing the 3D origin as a special point - it happens to be `(0, 0, 0, 1)`, but is treated just like any other point on that hyperplane from the persepctive of a four-dimensional space. We will go slightly further however, and trade a tiny bit of intuition by defining a geometric space with signature $(3, 0, 1)$ instead of $(4, 0, 0)$ to obtain more elegant and simpler formulas that describe translations and rotations. A walkthrough of the geometric spaces over $\mathbb{R}^3$ (2D projective space) and $\mathbb{R}^4$ (3D projective space) is provided in the books *Geometric Algebra for Computer Science - An Object-Oriented Approach to Geometry* and *Aspects of Geometric Algebra in Euclidean, Projective and Conformal Space*.
=#
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 5459 | #=
# Getting started
SymbolicGA is a library build upon the metaprogramming capabilities of the language to express and simplify geometric algebra expressions at compile-time. This brings the potential of optimality to its implementation, but may feel a bit odd to use compared to most Julia libraries. Additionally, there were unforeseen advantages to keeping geometric algebra operators as pure notation in a symbolic realm: it allows naming things as you like without worrying about choosing names for Julia functions or structures that satisfy everyone (because, unfortunately, consensus on notation for geometric algebra is pretty far away at the moment).
This package defines two high-level symbols:
- A single macro, [`@ga`](@ref), which allows you to setup your own geometric algebra context and evaluate arbitrary geometric algebra expressions.
- A single structure, [`KVector`](@ref), which simply wraps components with additional information regarding what type of geometric entity it is, and the dimension of the space inside which it was produced.
The [`KVector`](@ref) structure is generally useful to understand what you are getting out of [`@ga`](@ref) and is produced by default. However, the idea of this package is to be able to directly use and generate data from and into your own data structures, provided that a certain interface is fulfilled. For example, if you are designing a computational geometry library, you can define your own types such as `Point`, `Line`, `Circle` etc and use them in `@ga`. No need to juggle with types from another library! After all, geometric algebra defines semantically meaningful transformations, but cares little about how the data has been abstracted over or how it is stored in memory.
A few more advanced features will allow you to seamlessly integrate geometric algebra within your own codebase:
- Utilities for code generation, including [`codegen_expression`](@ref), [`Bindings`](@ref), [`default_bindings`](@ref) will be useful to build macros that automate
- Interface functions [`SymbolicGA.getcomponent`](@ref) and [`SymbolicGA.construct`](@ref) to use your own types within generated expressions, in case the defaults based on indexing and constructors do not fit with the design of your data structures.
We will explain how these features work separately and together, to unlock the expression of geometric algebra within Julia in a performant and non-intrusive way.
## Using [`@ga`](@ref)
The simplest way to define your own geometric space and carry operations on it is to use the [`@ga`](@ref) macro. For example, to construct the geometric space over $\mathbb{R}^2$, noted $\mathcal{G}(\mathbb{R}^2)$, you first specify a signature for this space. Then, you can perform any operations you like, provided that you annotate the type of your values:
=#
using SymbolicGA
x = 1.0
y = 2.0
@ga 2 x::e1 + y::e2
# We simply constructed a simple vector within $\mathcal{G}(\mathbb{R}^2)$ by associating scalar components with basis vectors `e1` and `e2`. Most of the time though, unless you desire to construct a geometric entity with sparse components, you will prefer providing vectors as annotated iterables, such as
@ga 2 (x, y)::Vector
# Note that this `Vector` annotation *does not mean `Base.Vector`*; it means a mathematical vector in the geometric space of interest. Now, let us take the geometric product ⟑ (`\wedgedot`) of two vectors:
a = (x, y)
b = rand(2)
@ga 2 a::Vector ⟑ b::Vector
#=
Here, we obtained a mathematical object composed of both a 0-vector (scalar) and a 2-vector (bivector) part. In $\mathcal{G}(\mathbb{R}^2)$, a bivector has a single component, but with most other spaces bivectors have more; for any embedded space of dimension `n`, the number of elements for an entity with grade `k` is `binomial(n, k)`.
!!! note
If you dislike the use of non-ASCII characters for major operators, you can use standard function names instead of operators, such as `geometric_product(x, y)` (equivalent to `x ⟑ y`) (see [Table of symbols](@ref)).
What if we wanted only the scalar part or the bivector part? We can project the result into either grade 0 or grade 2, respectively:
=#
@ga 2 (a::Vector ⟑ b::Vector)::Scalar
#-
@ga 2 (a::Vector ⟑ b::Vector)::Bivector
# Since it may be a bit tedious to type in these names by hand, when all we really need is to express the grade in these annotations, we can directly use a number on the right-hand side of `::` (see [Type annotations](@ref)).
@ga 2 (a::1 ⟑ b::1)::0
# In this particular case, getting the lowest and highest grade component of a geometric product is what defines the inner and outer products, `⋅` (`\cdot`) and `∧` (`\wedge`). See [Table of symbols](@ref) for a complete list of symbols and operators.
@ga 2 a::1 ⋅ b::1
#-
@ga 2 a::1 ∧ b::1
# You can tweak the signature of the geometric space to your liking, if you want to use other spaces. For example, we can embed a 2D vector into Minkowski space (used to express flat spacetime, also called "Space-time algebra" or STA in works using geometric algebra):
c = rand(4)
#-
@ga (3, 1) c::1 ⋅ c::1
# If you are a bit lazy, you may annotate the `c` once before the expression:
@ga (3, 1) begin
c::1
c ⋅ c
end
#=
These are the very basics, now you know how to evaluate geometric algebra expressions in arbitrary geometric spaces. Feel free to look at other tutorials to learn about meaningful operations to perform!
=#
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 2113 | #=
# Integration with user-defined types
If you want to use values of a custom type in expressions for [`@ga`](@ref) (or any specific geometric space generated by [`@geometric_space`](@ref)), you are totally free to do so. By default, component extraction relies on 1-based indexing via [`SymbolicGA.getcomponent`](@ref), which should be fine most of the time. If that won't work for you for any reason, you can still extend this method with your own types. The choices are therefore the following:
- Extend `Base.getindex(::MyType, ::Int)`
- Extend `SymbolicGA.getcomponent(::MyType, ::Int)`
=#
using SymbolicGA
struct MyType{T}
components::Dict{Symbol, T}
end
index_to_symbol(i) = (:x, :y, :z)[i]
SymbolicGA.getcomponent(x::MyType, i) = x.components[index_to_symbol(i)]
x = MyType(Dict(:x => 1.5, :y => 2.0, :z => 3.0))
y = MyType(Dict(:x => 1.2, :y => -1.4, :z => 0.1))
@ga 3 dual(x::1 ∧ y::1)
#=
Note that we still got a [`KVector`](@ref) out by default; if you want, you may provide `MyType` as output, but you also need to define how to reconstruct a type given a tuple of components. By default, `SymbolicGA.construct` calls the provided type constructor on the tuple of components. You may therefore either:
- Define a `MyType(::Tuple)` constructor
- Extend `SymbolicGA.construct(::Type{MyType}, ::Tuple)`
=#
SymbolicGA.construct(T::Type{<:MyType}, components::Tuple) = T(Dict((:x, :y, :z) .=> components))
@ga 3 MyType dual(x::1 ∧ y::1)
#=
Of course, you can also omit the return type and operate with a [`KVector`](@ref). In fact, that is recommended especially if you don't know what kind of object you'll end up with. For example, would you know what `dual((x::1 ⟑ y::1) ⋅ y::1) + exp(x::1 ∧ y::1)` returns? Well, let's see:
=#
@ga 3 dual((x::1 ⟑ y::1) ⋅ y::1) + exp(x::1 ∧ y::1)
#=
Looks like we got a scalar and a bivector! We could manipulate this `KVector` around, which is a mere allocation-free wrapper over a tuple, but if you already know what type of data structure you want to put your data into, you may find it more convenient to specify it when calling the macro.
=#
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 733 | module SymbolicGA
using Combinatorics
using Graphs
using CompileTraces: @compile_traces
using PrecompileTools: @compile_workload
using Dictionaries
using Logging: with_logger, NullLogger
const Optional{T} = Union{T,Nothing}
include("utils.jl")
include("signatures.jl")
include("expressions.jl")
include("passes.jl")
include("interface.jl")
include("macro.jl")
include("types.jl")
include("optimization.jl")
include("factorization.jl")
include("spaces.jl")
@compile_workload @compile_traces "precompilation_traces.jl"
export Signature,
@ga,
@geometric_space,
@pga2, @pga3, @cga3,
KVector,
Bivector,
Trivector,
Quadvector,
grade,
codegen_expression,
Bindings,
default_bindings,
parse_bindings,
@arg
end
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 35652 | const GradeInfo = Union{Int,Vector{Int}}
@enum Head::UInt8 begin
# Decorations.
COMPONENT = 1
FACTOR = 2
BLADE = 3
KVECTOR = 4
MULTIVECTOR = 5
# Linear operations.
ADDITION
SUBTRACTION
NEGATION # unused
REVERSE
ANTIREVERSE
LEFT_COMPLEMENT
RIGHT_COMPLEMENT
# Products.
GEOMETRIC_PRODUCT
EXTERIOR_PRODUCT
INTERIOR_PRODUCT
COMMUTATOR_PRODUCT
# Nonlinear operations.
INVERSE
EXPONENTIAL
# Scalar operations.
SCALAR_SQRT = 70
SCALAR_ABS = 71
SCALAR_NAN_TO_ZERO = 72
SCALAR_INVERSE = 73
SCALAR_COS = 74
SCALAR_SIN = 75
SCALAR_COSH = 76
SCALAR_SINH = 77
SCALAR_DIVISION = 78
SCALAR_PRODUCT = 79
SCALAR_ADDITION = 80
end
isscalar(head::Head) = head == COMPONENT || UInt8(head) ≥ 70
isaddition(head::Head) = in(head, (ADDITION, SCALAR_ADDITION))
ismultiplication(head::Head) = in(head, (GEOMETRIC_PRODUCT, SCALAR_PRODUCT))
isdecoration(head::Head) = UInt8(head) ≤ 5
isoperation(head::Head) = !isdecoration(head)
function Head(head::Symbol)
head === :factor && return FACTOR
head === :blade && return BLADE
head === :kvector && return KVECTOR
head === :multivector && return MULTIVECTOR
head === :+ && return ADDITION
head === :- && return SUBTRACTION
head === :reverse && return REVERSE
head === :antireverse && return ANTIREVERSE
head === :left_complement && return LEFT_COMPLEMENT
head === :right_complement && return RIGHT_COMPLEMENT
head === :geometric_product && return GEOMETRIC_PRODUCT
head === :exterior_product && return EXTERIOR_PRODUCT
head === :interior_product && return INTERIOR_PRODUCT
head === :commutator_product && return COMMUTATOR_PRODUCT
head === :inverse && return INVERSE
head === :exp && return EXPONENTIAL
head === :abs && return SCALAR_ABS
head === :sqrt && return SCALAR_SQRT
error("Head '$head' is unknown")
end
primitive type ID 64 end
ID(val::UInt64) = reinterpret(ID, val)
ID(val::Integer) = ID(UInt64(val))
Base.isapprox(x::ID, y::ID) = x == y
Base.iterate(id::ID) = nothing
Base.length(id::ID) = 1
mutable struct IDCounter
val::UInt64
end
next!(counter::IDCounter) = ID(counter.val += 1)
IDCounter() = IDCounter(0)
mutable struct Expression
head::Head
grade::GradeInfo
args::Vector{Union{Expression,ID}}
cache
function Expression(head::Head, args::AbstractVector, cache; simplify = true, grade = nothing)
ex = new()
ex.head = head
ex.args = args
ex.cache = cache::ExpressionCache
!isnothing(grade) && (ex.grade = grade)
!simplify && return ex
simplify!(ex)::Expression
end
end
@forward Expression.head (isaddition, ismultiplication)
const Term = Union{Expression, ID}
struct ExpressionSpec
head::Head
args::Vector{Term}
end
Base.:(==)(x::ExpressionSpec, y::ExpressionSpec) = x.head == y.head && x.args == y.args
Base.hash(spec::ExpressionSpec, h::UInt) = hash(hash(spec.head) + hash(spec.args), h)
ExpressionSpec(ex::Expression) = ExpressionSpec(ex.head, ex.args)
Base.isapprox(::Expression, ::ID) = false
Base.isapprox(::ID, ::Expression) = false
function Base.isapprox(x::Expression, y::Expression)
(x.head === y.head && length(x) == length(y)) || return false
(; head) = x
!isunordered(head) && return all(xx ≈ yy for (xx, yy) in zip(x, y))
used = Set{Term}()
for xx in x
i = findfirst(yy -> xx ≈ yy && !in(yy, used), y)
isnothing(i) && return false
push!(used, y[i])
end
true
end
isunordered(head::Head) = head in (ADDITION, SCALAR_ADDITION, SCALAR_PRODUCT)
struct Object
val::Any
end
Base.:(==)(x::Object, y::Object) = typeof(x.val) == typeof(y.val) && x.val == y.val
Base.hash(x::Object, h::UInt) = hash(hash(x.val, hash(typeof(x.val))), h)
struct ExpressionCache
sig::Signature
counter::IDCounter
primitive_ids::Dict{Object,ID}
primitives::Dict{ID,Object}
expressions::Dict{ExpressionSpec,Expression}
substitutions::Dict{ExpressionSpec,Expression}
end
Base.broadcastable(cache::ExpressionCache) = Ref(cache)
ExpressionCache(sig::Signature) = ExpressionCache(sig, IDCounter(), IdDict(), IdDict(), Dict(), Dict())
is_expression_caching_enabled() = true
Base.getproperty(ex::Expression, field::Symbol) = field === :cache ? getfield(ex, field)::ExpressionCache : getfield(ex, field)
ExpressionSpec(cache::ExpressionCache, head::Head, args::AbstractVector) = ExpressionSpec(head, substitute_objects(cache, args))
ExpressionSpec(cache::ExpressionCache, head::Head, args...) = ExpressionSpec(cache, head, collect(Any, args))
unsimplified_expression(cache::ExpressionCache, head::Head, args...) = unsimplified_expression(cache, ExpressionSpec(cache, head, args...))
function unsimplified_expression(cache::ExpressionCache, spec::ExpressionSpec)
ex = get(cache.expressions, spec, nothing)
!isnothing(ex) && return ex
ex = Expression(spec.head, spec.args, cache; simplify = false)
is_expression_caching_enabled() && (cache.expressions[spec] = ex)
ex
end
Expression(head::Head, ex::Expression) = Expression(ex.cache, head, ex)
Expression(cache::ExpressionCache, head::Head, args...) = Expression(cache, ExpressionSpec(cache, head, args...))
function Expression(cache::ExpressionCache, spec::ExpressionSpec)
haskey(cache.substitutions, spec) && is_expression_caching_enabled() && return cache.substitutions[spec]
ex = Expression(spec.head, spec.args, cache)
if is_expression_caching_enabled()
cache.expressions[ExpressionSpec(ex)] = ex
# XXX: there remains a nondeterminism causing this assert to fail.
# @assert !haskey(cache.substitutions, spec) "A result is already cached for $spec" * (cache.substitutions[spec] === ex ? " but is inconsistent with the computed value: $ex !== $(cache.substitutions[spec])" : " and is the computed value.")
ex = get!(cache.substitutions, spec, ex)
end
ex
end
function substitute_objects(cache::ExpressionCache, args::AbstractVector)
terms = Term[]
for arg in args
term = isa(arg, Expression) || isa(arg, ID) ? arg : begin
id = get!(() -> next!(cache.counter), cache.primitive_ids, Object(arg))
cache.primitives[id] = Object(arg)
id
end
push!(terms, term)
end
terms
end
dereference(cache::ExpressionCache, primitive_id::ID) = cache.primitives[primitive_id].val
dereference(cache::ExpressionCache, x) = x
function dereference(ex::Expression)
@assert length(ex) == 1
inner = ex[1]
isa(inner, Expression) && isscalar(inner.head) ? inner : dereference(ex.cache, inner::ID)
end
substitute!(ex::Expression, head::Head, args...) = substitute!(ex, ExpressionSpec(ex.cache, head, args...))
substitute!(ex::Expression, spec::ExpressionSpec) = substitute!(ex, Expression(ex.cache, spec))
function substitute!(ex::Expression, other::Expression)
ex.head = other.head
ex.args = other.args
ex.grade = other.grade
ex
end
function simplify!(ex::Expression)
(; head, args, cache) = ex
(; sig) = cache
# Simplify nested factor expressions.
head === FACTOR && isexpr(args[1], FACTOR) && return args[1]
isscalar(head) && any(isexpr(FACTOR), args) && return substitute!(ex, head, Any[isexpr(x, FACTOR) ? x[1] : x for x in args])
# Apply left and right complements.
if head in (LEFT_COMPLEMENT, RIGHT_COMPLEMENT)
isweightedblade(args[1]) && return substitute!(ex, weighted(Expression(cache, head, args[1][2]), args[1][1]))
args[1] == factor(cache, 0) && return args[1]
end
head === LEFT_COMPLEMENT && isblade(args[1]) && return blade_left_complement(args[1])
head === RIGHT_COMPLEMENT && isblade(args[1]) && return blade_right_complement(args[1])
if head === BLADE
# Sort basis vectors.
if !issorted(args; by = x -> dereference(cache, x))
perm = sortperm(args, by = x -> dereference(cache, x))
fac = isodd(parity(perm)) ? -1 : 1
return substitute!(ex, weighted(Expression(cache, BLADE, args[perm]), fac))
end
# Apply metric.
if !allunique(args)
last = nothing
fac = 1
i = 1
args = copy(args)
while length(args) ≥ 2
i > lastindex(args) && break
new = dereference(cache, args[i])
if !isnothing(last)
if new == last
m = metric(sig, last)
iszero(m) && return substitute!(ex, scalar(cache, 0))
fac *= m
length(args) == 2 && return substitute!(ex, scalar(cache, fac))
deleteat!(args, i)
deleteat!(args, i - 1)
i = max(i - 2, 1)
last = i < firstindex(args) ? nothing : args[i]
else
last = new
end
else
last = new
end
i += 1
end
return substitute!(ex, weighted(Expression(cache, BLADE, args), fac))
end
end
if head === SUBTRACTION
# Simplify unary minus operator to a multiplication with -1.
length(args) == 1 && return substitute!(ex, weighted(args[1], -1))
# Transform binary minus expression into an addition.
@assert length(args) == 2
return substitute!(ex, ADDITION, args[1], -args[2])
end
# Simplify whole expression to zero if a product term is zero.
if head === GEOMETRIC_PRODUCT && any(isexpr(x, FACTOR) && dereference(x) == 0 for x in args)
any(!isexpr(x, FACTOR) && !isexpr(x, BLADE, 0) for x in args) && @debug "Non-factor expression annihilated by a zero multiplication term" args
return substitute!(ex, factor(cache, 0))
end
# Remove unit elements for multiplication and addition.
if in(head, (GEOMETRIC_PRODUCT, ADDITION))
new_args = remove_unit_elements(args, head)
if length(new_args) < length(args)
head === GEOMETRIC_PRODUCT && isempty(new_args) && return substitute!(ex, scalar(cache, 1))
head === ADDITION && isempty(new_args) && return substitute!(ex, scalar(cache, 0))
return substitute!(ex, head, new_args)
end
length(args) == 1 && return substitute!(ex, args[1]::Expression)
# Disassociate ⟑ and +.
any(isexpr(head), args) && return substitute!(ex, disassociate1(cache, args, head))
end
if head === GEOMETRIC_PRODUCT
# Collapse factors into one and put it at the front.
nf = count(isexpr(FACTOR), args)
if nf ≥ 2
# Collapse all factors into one at the front.
factors, nonfactors = filter(isexpr(FACTOR), args), filter(!isexpr(FACTOR), args)
fac = collapse_factors(cache, SCALAR_PRODUCT, factors)
length(args) == nf && return substitute!(ex, fac)
return substitute!(ex, GEOMETRIC_PRODUCT, Term[fac; nonfactors])
elseif nf == 1 && !isexpr(args[1], FACTOR)
# Put the factor at the front.
i = findfirst(isexpr(FACTOR), args)
fac = args[i]::Expression
args = copy(args)
deleteat!(args, i)
pushfirst!(args, fac)
return substitute!(ex, GEOMETRIC_PRODUCT, args)
end
# Collapse all bases and blades into a single blade.
nb = count(isexpr(BLADE), args)
if nb > 1
args = copy(args)
n = length(args)
blade_args = []
for i in reverse(eachindex(args))
x = args[i]
isexpr(x, BLADE) || continue
for arg in reverse(x.args)
pushfirst!(blade_args, dereference(cache, arg)::Int)
end
deleteat!(args, i)
end
blade_ex = blade(cache, blade_args)
# Return the blade if all the terms were collapsed.
nb == n && return substitute!(ex, blade_ex)
return substitute!(ex, GEOMETRIC_PRODUCT, Term[args; blade_ex])
end
end
# Simplify addition of factors.
head === ADDITION && all(isexpr(FACTOR), args) && return substitute!(ex, collapse_factors(cache, SCALAR_ADDITION, args))
# Group blade components over addition.
if head === ADDITION
indices = findall(x -> isblade(x) || isweightedblade(x), args)
if !isempty(indices)
blades = args[indices]
if !allunique(basis_vectors(b) for b in blades)
blade_weights = Dictionary{Vector{Int},Expression}()
for b in blades
vecs = basis_vectors(b)
weight = isweightedblade(b) ? b.args[1] : factor(cache, 1)
if haskey(blade_weights, vecs)
blade_weights[vecs] = factor(cache, Expression(cache, SCALAR_ADDITION, blade_weights[vecs], weight))
else
insert!(blade_weights, vecs, weight)
end
end
for (vecs, weight) in pairs(blade_weights)
if isexpr(weight, ADDITION)
simplified = simplify_addition(weight)
if simplified == factor(cache, 0)
delete!(blade_weights, vecs)
else
blade_weights[vecs] = simplified
end
end
end
new_args = args[setdiff(eachindex(args), indices)]
append!(new_args, Expression(cache, GEOMETRIC_PRODUCT, weight, blade(cache, vecs)) for (vecs, weight) in pairs(blade_weights))
return substitute!(ex, ADDITION, new_args)
end
end
end
head in (SCALAR_PRODUCT, SCALAR_ADDITION) && any(isexpr(head), args) && return substitute!(ex, disassociate1(cache, args, head))
if head === FACTOR
fac = ex[1]
if isexpr(fac, SCALAR_ADDITION)
simplified = simplify_addition(fac)
simplified !== fac && return substitute!(ex, FACTOR, simplified)
end
# Simplify -1 factors.
isexpr(fac, SCALAR_PRODUCT) && count(x -> dereference(cache, x) == -1, args) > 1 && return substitute!(ex, FACTOR, simplify_negations(fac))
end
if isscalar(head)
isempty(args) && isaddition(head) && return substitute!(ex, factor(cache, 0))
isempty(args) && ismultiplication(head) && return substitute!(ex, factor(cache, 1))
length(args) == 1 && head in (SCALAR_PRODUCT, SCALAR_ADDITION) && return substitute!(ex, isa(args[1], Expression) ? args[1] : factor(cache, args[1]))
x = dereference(cache, args[1])
n = expected_nargs(head)
n == 1 && isa(x, Number) && return substitute!(ex, factor(cache, scalar_function(head)(x)))
if n == 2
y = dereference(cache, args[2])
isa(x, Number) && isa(y, Number) && return substitute!(ex, factor(cache, scalar_function(head)(x, y)))
end
if n == -1
all(isa(dereference(cache, x), Number) for x in args) && return substitute!(ex, factor(cache, scalar_function(head)(dereference.(cache, args)...)))
end
end
validate_arguments(cache, head, args)
# Propagate complements over addition.
head in (LEFT_COMPLEMENT, RIGHT_COMPLEMENT) && isexpr(args[1], ADDITION) && return substitute!(ex, ADDITION, Expression.(cache, head, args[1]))
# Distribute products over addition.
head in (GEOMETRIC_PRODUCT, EXTERIOR_PRODUCT, INTERIOR_PRODUCT, COMMUTATOR_PRODUCT) && any(isexpr(arg, ADDITION) for arg in args) && return substitute!(ex, distribute1(cache, args, ADDITION, head))
head === SCALAR_PRODUCT && any(isexpr(arg, SCALAR_ADDITION) for arg in args) && return substitute!(ex, distribute1(cache, args, SCALAR_ADDITION, head))
# Eagerly apply reversions.
head in (REVERSE, ANTIREVERSE) && return substitute!(ex, apply_reverse_operators(ex))
# Expand common operators.
# ========================
# The exterior product is associative, no issues there.
if head === EXTERIOR_PRODUCT
n = sum(x -> grade(x::Expression)::Int, args)
return substitute!(ex, project!(Expression(cache, GEOMETRIC_PRODUCT, args), n))
end
if head === INTERIOR_PRODUCT
# The inner product must have only two operands, as no associativity law is available to derive a canonical binarization.
# Homogeneous vectors are expected, so the grade should be known.
r, s = grade(args[1]::Expression)::Int, grade(args[2]::Expression)::Int
if (iszero(r) || iszero(s))
(!iszero(r) || !iszero(s)) && @debug "Non-scalar expression annihilated in inner product with a scalar"
return scalar(cache, 0)
end
return substitute!(ex, project!(Expression(cache, GEOMETRIC_PRODUCT, args), abs(r - s)))
end
if head === COMMUTATOR_PRODUCT
# The commutator product must have only two operands, as no associativity law is available to derive a canonical binarization.
a, b = args[1]::Expression, args[2]::Expression
return substitute!(ex, weighted(Expression(cache, SUBTRACTION, Expression(cache, GEOMETRIC_PRODUCT, a, b), Expression(cache, GEOMETRIC_PRODUCT, b, a)), 0.5))
end
if head === EXPONENTIAL
# Find a closed form for the exponentiation, if available.
a = args[1]::Expression
(isblade(a) || isweightedblade(a)) && return substitute!(ex, expand_exponential(a))
# return expand_exponential(sig::Signature, a)
isexpr(a, ADDITION) && return substitute!(ex, GEOMETRIC_PRODUCT, Expression.(cache, EXPONENTIAL, a)...)
throw(ArgumentError("Exponentiation is not supported for non-blade elements."))
end
if head === INVERSE
a = args[1]::Expression
isexpr(a, FACTOR) && return substitute!(ex, factor(cache, Expression(cache, SCALAR_INVERSE, dereference(a))))
isweightedblade(a, 0) && return substitute!(ex, scalar(cache, Expression(cache, INVERSE, a[1]::Expression)))
isblade(a, 0) && return a
sc = Expression(cache, GEOMETRIC_PRODUCT, Expression(cache, REVERSE, a), a)
isscalar(sc) || error("`reverse(A) ⟑ A` is not a scalar, suggesting that A is not a versor (i.e., an element of the form `v₁ ⟑ ... ⟑ vₙ` with nonzero (vᵢ)ᵢ). Inversion is only supported for versors at the moment.")
return substitute!(ex, GEOMETRIC_PRODUCT, Expression(cache, REVERSE, a), Expression(cache, INVERSE, sc))
end
ex.grade = infer_grade(cache, head, args)::GradeInfo
ex
end
iscall(ex, f) = Meta.isexpr(ex, :call) && ex.args[1] === f
function remove_unit_elements(args, head)
if head === GEOMETRIC_PRODUCT
filter(x -> !isexpr(x, FACTOR) || dereference(x) != 1, args)
elseif head === ADDITION
filter(x -> !isexpr(x, FACTOR) || dereference(x) != 0, args)
end
end
function collapse_factors(cache, head::Head, args)
unit = ismultiplication(head) ? one : zero
isunit = ismultiplication(head) ? isone : iszero
f = ismultiplication(head) ? (*) : (+)
opaque_factors = Any[]
value = unit(Int64)
for fac in args
if isopaquefactor(fac)
push!(opaque_factors, fac)
else
value = f(value, dereference(fac))
end
end
if !isempty(opaque_factors)
flattened_factors = Any[]
for fac in opaque_factors
if isexpr(fac, head)
append!(flattened_factors, fac)
else
push!(flattened_factors, fac)
end
end
!isunit(value) && pushfirst!(flattened_factors, value)
length(flattened_factors) == 1 && return factor(cache, flattened_factors[1])
return factor(cache, Expression(cache, head, flattened_factors))
end
return factor(cache, value)
end
function disassociate1(args, op::Head)
new_args = Term[]
for arg in args
if isexpr(arg, op)
append!(new_args, arg.args)
else
push!(new_args, arg)
end
end
new_args
end
disassociate1(cache, args, op::Head) = Expression(cache, op, disassociate1(args, op))
function distribute1(cache, args, add_op::Head, mul_op::Head)
x, ys = args[1], @view args[2:end]
base = isexpr(x, add_op) ? x.args : [x]
for y in ys
new_base = Term[]
yterms = isexpr(y, add_op) ? y.args : (y,)
for xterm in base
for yterm in yterms
push!(new_base, Expression(cache, mul_op, xterm, yterm))
end
end
base = new_base
end
Expression(cache, add_op, base)
end
function simplify_negations(ex::Expression)
(; cache) = ex
n = count(x -> dereference(cache, x) == -1, ex)
if n > 1
new_args = filter(x -> dereference(cache, x) ≠ -1, args)
isodd(n) && pushfirst!(args, -1)
return Expression(cache, ex.head, args...)
end
ex
end
function simplify_addition(ex::Expression)
(; cache) = ex
counter = 0
ids = Dict{Any,Int}()
id_counts = Dict{Int,Int}()
new_args = Term[]
for arg in ex
n = 1
obj = arg
if isexpr(arg, SCALAR_PRODUCT)
@assert length(arg) > 1
xs = Term[]
for x in arg
xv = dereference(cache, x)
if isa(xv, Int) || isa(xv, Integer)
n *= xv
else
push!(xs, x)
end
end
# XXX: Sorting by `objectid` will not yield a consistent ordering, causing nondeterministic behavior.
# The alternatives don't look better though; we can't use a set, because arguments are not unique,
# and a string-based representation will result in significant order changes for the resulting expression.
obj = isempty(xs) ? 1 : length(xs) == 1 ? xs[1] : sort!(xs; by = objectid)
end
id = get!(() -> (counter += 1), ids, obj)
id_counts[id] = something(get(id_counts, id, nothing), 0) + n
end
for (x, id) in sort!(collect(ids), by = last)
n = id_counts[id]
n == 0 && continue
isa(x, Vector{Term}) && (x = Expression(cache, SCALAR_PRODUCT, x...))
if n == 1
push!(new_args, x)
else
# XXX: remove the need for manual disassociation.
push!(new_args, Expression(cache, SCALAR_PRODUCT, n, x))
end
end
Expression(cache, SCALAR_ADDITION, new_args)
end
function expected_nargs(head)
in(head, (FACTOR, NEGATION, REVERSE, ANTIREVERSE, LEFT_COMPLEMENT, RIGHT_COMPLEMENT, INVERSE, EXPONENTIAL, SCALAR_SQRT, SCALAR_ABS, SCALAR_COS, SCALAR_COSH, SCALAR_SIN, SCALAR_SINH, SCALAR_INVERSE, SCALAR_NAN_TO_ZERO)) && return 1
in(head, (INTERIOR_PRODUCT, COMMUTATOR_PRODUCT, SUBTRACTION, SCALAR_DIVISION)) && return 2
in(head, (SCALAR_ADDITION, SCALAR_PRODUCT)) && return -1 # variable number of arguments
nothing
end
function validate_arguments(cache, head, args)
n = expected_nargs(head)
!isnothing(n) && n ≥ 0 && @assert length(args) == n "Expected $n arguments for expression $head, $(length(args)) were provided\nArguments: $args"
head !== BLADE && @assert !isempty(args)
head === BLADE && @assert all(isa(dereference(cache, i), Int) for i in args) "Expected integer arguments in BLADE expression, got $(dereference.(cache, ex))"
head === FACTOR && @assert !isa(args[1], Expression) || isscalar(args[1].head) "`Expression` argument detected in FACTOR expression: $(args[1])"
isoperation(head) && !isscalar(head) && !all(isa(x, Expression) for x in args) && throw(ArgumentError("Non-algebraic elements found in operation $head: $(join('`' .* string.(dereference.(cache, filter(x -> !isa(x, Expression), args))) .* '`', ", "))\n\nYou may have forgotten to annotate these inputs, e.g. as `x::1`"))
head === MULTIVECTOR && @assert all(isexpr(x, KVECTOR) for x in args) "Multivector expressions must contain explicit `KVECTOR` arguments"
head === KVECTOR && @assert all(isblade(x) || isweightedblade(x) for x in args) "KVector expressions must contain (weighted) blade arguments"
end
function infer_grade(cache, head::Head, args)
head === FACTOR && return 0
isscalar(head) && return 0
head === BLADE && return count(x -> isodd(dereference(cache, x)), map(x -> count(==(x), args), unique(args)))
if head === GEOMETRIC_PRODUCT
@assert length(args) == 2 && isexpr(args[1], FACTOR)
return grade(args[2]::Expression)
end
if in(head, (ADDITION, MULTIVECTOR))
gs = Int64[]
for arg in args
append!(gs, grade(arg))
end
sort!(unique!(gs))
length(gs) == 1 && return first(gs)
return gs
end
if head === KVECTOR
grades = map(args) do arg
isa(arg, Expression) || error("Expected argument of type $Expression, got $arg")
g = arg.grade
isa(g, Int) || error("Expected grade to be known for argument $arg in $head expression")
g
end
unique!(grades)
length(grades) == 1 || error("Expected unique grade for k-vector expression, got grades $grades")
return first(grades)
end
error("Cannot infer grade for unexpected $head expression with arguments $args")
end
# Empirical formula.
# If anyone has a better one, please let me know.
function blade_right_complement(b::Expression)
(; cache) = b
(; sig) = cache
blade(cache, reverse!(setdiff(1:dimension(sig), basis_vectors(b)))) * factor(cache, (-1)^(
isodd(sum(basis_vectors(b); init = 0)) +
(dimension(sig) ÷ 2) % 2 +
isodd(dimension(sig)) & isodd(length(b))
))
end
# Exact formula derived from the right complement.
blade_left_complement(b::Expression) = factor(b.cache, (-1)^(grade(b) * antigrade(b))) * blade_right_complement(b)
function project!(ex, g, level = 0)
isa(ex, Expression) || return ex
if all(isempty(intersect(g, g′)) for g′ in grade(ex))
iszero(level) && @debug "Non-scalar expression annihilated in projection into grade(s) $g" ex
return factor(ex.cache, 0)
end
if isexpr(ex, ADDITION)
for (i, x) in enumerate(ex)
ex.args[i] = project!(x, g, level + 1)
end
return simplify!(ex)
end
ex
end
function apply_reverse_operators(ex::Expression)
(; cache) = ex
(; sig) = cache
orgex = ex
prewalk(ex) do ex
isexpr(ex, (REVERSE, ANTIREVERSE)) || return ex
reverse_op = ex.head
anti = reverse_op === ANTIREVERSE
ex = ex[1]
@assert isa(ex, Expression) "`Expression` argument expected for `$reverse_op`."
# Distribute over addition.
isexpr(ex, (ADDITION, KVECTOR, MULTIVECTOR)) && return Expression(cache, ex.head, anti ? antireverse.(ex) : reverse.(ex))
!anti && in(ex.grade, (0, 1)) && return ex
anti && in(antigrade(sig, ex.grade), (0, 1)) && return ex
isexpr(ex, GEOMETRIC_PRODUCT) && return propagate_reverse(reverse_op, ex)
@assert isexpr(ex, BLADE) "Unexpected operator $(ex.head) encountered when applying $reverse_op operators."
n = anti ? antigrade(ex)::Int : grade(ex)::Int
fac = (-1)^(n * (n - 1) ÷ 2)
isone(fac) ? ex : -ex
end
end
# grade(x) + antigrade(x) == dimension(sig)
antigrade(sig::Signature, g::Int) = dimension(sig) - g
antigrade(sig::Signature, g::Vector{Int}) = antigrade.(sig, g)
antigrade(ex::Expression) = antigrade(ex.cache.sig, ex.grade)
function propagate_reverse(reverse_op, ex::Expression)
(; cache) = ex
res = Term[]
for arg in ex
arg::Expression
skip = isexpr(arg, FACTOR) || reverse_op === REVERSE ? in(arg.grade, (0, 1)) : in(antigrade(cache.sig, arg.grade), (0, 1))
skip ? push!(res, arg) : push!(res, Expression(cache, reverse_op, arg))
end
Expression(cache, ex.head, res)
end
function expand_exponential(b::Expression)
(; cache) = b
(; sig) = cache
vs = basis_vectors(b)
is_degenerate(sig) && any(iszero(metric(sig, v)) for v in vs) && return Expression(cache, ADDITION, scalar(cache, 1), b)
b² = Expression(cache, GEOMETRIC_PRODUCT, b, b)
@assert isscalar(b²)
α² = isweightedblade(b²) ? b²[1] : factor(cache, 1)
α = Expression(cache, SCALAR_SQRT, Expression(cache, SCALAR_ABS, α²))
# The sign may not be deducible from α² directly, so we compute it manually given metric simplifications and blade permutations.
is_α²_negative = isodd(count(metric(sig, v) == -1 for v in vs)) ⊻ iseven(length(vs))
# Negative square: cos(α) + A * sin(α) / α
# Positive square: cosh(α) + A * sinh(α) / α
(s, c) = is_α²_negative ? (SCALAR_SIN, SCALAR_COS) : (SCALAR_SINH, SCALAR_COSH)
ex = Expression(cache, ADDITION, scalar(cache, Expression(cache, c, α)), Expression(cache, GEOMETRIC_PRODUCT, scalar(cache, Expression(cache, SCALAR_NAN_TO_ZERO, Expression(cache, SCALAR_DIVISION, Expression(cache, s, α), α))), b))
ex
end
# Basic interfaces.
Base.:(==)(x::Expression, y::Expression) = x.head == y.head && (!isdefined(x, :grade) || !isdefined(y, :grade) || x.grade == y.grade) && x.args == y.args
Base.setindex!(x::Expression, args...) = setindex!(x.args, args...)
Base.getindex(x::Expression, args...) = x.args[args...]
Base.firstindex(x::Expression) = firstindex(x.args)
Base.lastindex(x::Expression) = lastindex(x.args)
Base.length(x::Expression) = length(x.args)
Base.iterate(x::Expression, args...) = iterate(x.args, args...)
Base.keys(x::Expression) = keys(x.args)
Base.view(x::Expression, args...) = view(x.args, args...)
# Introspection utilities.
isexpr(ex, head::Head) = isa(ex, Expression) && ex.head === head
isexpr(ex, heads) = isa(ex, Expression) && in(ex.head, heads)
isexpr(ex, head::Head, n::Int) = isa(ex, Expression) && isexpr(ex, head) && length(ex.args) == n
isexpr(heads) = ex -> isexpr(ex, heads)
grade(ex::Expression) = ex.grade::GradeInfo
isblade(ex, n = nothing) = isexpr(ex, BLADE) && (isnothing(n) || n == length(ex))
isscalar(ex::Expression) = isblade(ex, 0) || isweightedblade(ex, 0)
isweighted(ex) = isexpr(ex, GEOMETRIC_PRODUCT, 2) && isexpr(ex[1]::Expression, FACTOR)
isweightedblade(ex, n = nothing) = isweighted(ex) && isblade(ex[2]::Expression, n)
isopaquefactor(ex) = isexpr(ex, FACTOR) && isa(dereference(ex), Union{Symbol, Expr, QuoteNode, Expression})
function basis_vectors(ex::Expression)
isweightedblade(ex) && return basis_vectors(ex[2]::Expression)
isexpr(ex, BLADE) && return [dereference(ex.cache, i)::Int for i in ex]
error("Expected blade or weighted blade expression, got $ex (head: $(ex.head))")
end
function lt_basis_order(xinds, yinds)
nx, ny = length(xinds), length(yinds)
nx ≠ ny && return nx < ny
for (xi, yi) in zip(xinds, yinds)
xi ≠ yi && return xi < yi
end
false
end
# Helper functions.
factor(cache::ExpressionCache, x) = Expression(cache, FACTOR, x)
weighted(x::Expression, fac) = Expression(x.cache, GEOMETRIC_PRODUCT, factor(x.cache, fac), x)
scalar(cache::ExpressionCache, fac) = factor(cache, fac) * blade(cache)
blade(cache::ExpressionCache, xs...) = Expression(cache, BLADE, xs...)
kvector(args::AbstractVector) = Expression((args[1]::Expression).cache, KVECTOR, args)
kvector(xs...) = kvector(collect(Term, xs))
multivector(args::AbstractVector) = Expression((args[1]::Expression).cache, MULTIVECTOR, args)
multivector(xs...) = multivector(collect(Term, xs))
Base.reverse(ex::Expression) = Expression(REVERSE, ex)
antireverse(ex::Expression) = Expression(ANTIREVERSE, ex)
antiscalar(cache::ExpressionCache, fac) = factor(cache, fac) * antiscalar(cache)
antiscalar(cache::ExpressionCache) = blade(cache, 1:dimension(cache.sig))
⟑(x::Expression, args::Expression...) = Expression(x.cache, GEOMETRIC_PRODUCT, x, args...)
Base.:(*)(x::Expression, args::Expression...) = Expression(x.cache, GEOMETRIC_PRODUCT, x, args...)
Base.:(*)(x::Number, y::Expression, args::Expression...) = *(factor(y.cache, x), y, args...)
Base.:(+)(x::Expression, args::Expression...) = Expression(x.cache, ADDITION, x, args...)
Base.:(-)(x::Expression, args::Expression...) = Expression(x.cache, SUBTRACTION, x, args...)
∧(x::Expression, y::Expression) = Expression(x.cache, EXTERIOR_PRODUCT, x, y)
exterior_product(x::Expression, y::Expression) = Expression(x.cache, EXTERIOR_PRODUCT, x, y)
# Traversal/transformation utilities.
walk(ex::Expression, inner::I, outer::O) where {I,O} = outer(Expression(ex.cache, ex.head, Any[inner(x) for x in ex if !isnothing(x)]))
walk(ex, inner::I, outer::O) where {I,O} = outer(ex)
postwalk(f::F, ex) where {F} = walk(ex, x -> postwalk(f, x), f)
prewalk(f::F, ex) where {F} = walk(f(ex), x -> prewalk(f, x), identity)
"""
Retraversal{RT}(should_retraverse, retraversed)
Allow a retraversal to be conditionally done when `traverse(f, ex, T; retraversal)` encounters an element
that is not a `T`.
For any such element, if `should_retraverse` returns true, then a secondary traversal is performed
on `retraversed(ex)::RT` with type `RT` as the traversal type. Upon encountering an object of type `T`,
the initial traversal is continued from this object with `traverse(f, ex, T; retraversal)`.
"""
struct Retraversal{RT,F1<:Function,F2<:Optional{Function}}
should_retraverse::F1 # _ -> Bool
retraversed::F2 # _ -> RT
end
Retraversal{RT}(should_retraverse, retraversed) where {RT} = Retraversal{RT,typeof(should_retraverse),typeof(retraversed)}(should_retraverse, retraversed)
Retraversal(RT::DataType) = Retraversal{RT}(x -> isa(x, RT), nothing)
Retraversal(cache::ExpressionCache, RT::Type{Expr}) = Retraversal{RT}(x -> isa(dereference(cache, x), RT), x -> dereference(cache, x))
traversal_iterator(ex::Expression) = ex.args
traversal_iterator(ex::Expr) = ex.args
traversed(ex, i) = traversal_iterator(ex)[i]
function traverse(f::F, ex, ::Type{T} = Expression; retraversal::Optional{Retraversal{RT}} = nothing) where {F,T,RT}
f(ex) === false && return
if !isa(ex, T)
isnothing(retraversal) && return
retraversal.should_retraverse(ex)::Bool || return
traverse(retraversal.retraversed(ex)::RT, RT) do subex
isa(subex, T) && traverse(f, subex, T; retraversal)
true
end
return
end
for arg in traversal_iterator(ex)
traverse(f, arg, T; retraversal)
end
end
function traverse_indexed(f::F, ex, ::Type{T} = Expression, i = nothing; retraversal::Optional{Retraversal{RT}} = nothing) where {F,T,RT}
f(ex, i) === false && return
!isnothing(i) && (ex = traversed(ex, i))
if !isa(ex, T)
isnothing(retraversal) && return
retraversal.should_retraverse(ex)::Bool || return
traverse_indexed(retraversal.retraversed(ex)::RT, RT) do subex, i
isa(subex, T) && traverse_indexed(f, subex, T, i; retraversal)
!isa(subex, T)
end
return
end
for i in eachindex(traversal_iterator(ex))
traverse_indexed(f, ex, T, i; retraversal)
end
end
# Display.
function Base.show(io::IO, ex::Expression)
isexpr(ex, BLADE) && return print(io, 'e', join(subscript.(dereference.(ex.cache, ex))))
isexpr(ex, FACTOR) && return print_scalar(io, dereference(ex))
isscalar(ex.head) && return print_scalar(io, ex)
if isexpr(ex, GEOMETRIC_PRODUCT) && isexpr(ex[end], BLADE)
if length(ex) == 2 && isexpr(ex[1], FACTOR)
fac = ex[1]
if isexpr(fac, COMPONENT) || !Meta.isexpr(dereference(fac), :call)
return print(io, fac, " ⟑ ", ex[end])
end
else
return print(io, '(', join(ex[1:(end - 1)], " ⟑ "), ") ⟑ ", ex[end])
end
end
isexpr(ex, (GEOMETRIC_PRODUCT, ADDITION, MULTIVECTOR)) && return print(io, '(', Expr(:call, head_symbol(ex.head), ex.args...), ')')
isexpr(ex, KVECTOR) && return print(io, Expr(:call, Symbol("kvector", subscript(ex.grade)), ex.args...))
print(io, Expression, "(:", ex.head, ", ", join(ex.args, ", "), ')')
end
function head_symbol(head::Head)
head === GEOMETRIC_PRODUCT && return :⟑
head === ADDITION && return :+
head === MULTIVECTOR && return :multivector
end
isinfix(head) = head in (SCALAR_ADDITION, SCALAR_PRODUCT)
function print_scalar(io, ex::Expression)
if isexpr(ex, COMPONENT)
# If we got one argument `x`, print `x[]`, unless it is a literal, in which case print e.g. `3`.
# Otherwise, print `x[indices...]`.
x, args... = dereference.(ex.cache, ex)
length(ex) == 1 && return print(io, isa(x, Number) ? x : Expr(:ref, x))
return print(io, Expr(:ref, x, args...))
else
fname = nameof(scalar_function(ex.head))
if isinfix(ex.head)
repr = join((sprint(print_scalar, dereference(ex.cache, arg)) for arg in ex), " $fname ")
return isexpr(ex, SCALAR_ADDITION) ? print(io, '(', repr, ')') : print(io, repr)
end
print(io, fname, '(', join(dereference.(ex.cache, ex), ", "), ')')
end
end
function print_scalar(io, ex)
Meta.isexpr(ex, :call) && in(ex.args[1], (:*, :+)) && return print(io, join((sprint(print_scalar, arg) for arg in @view ex.args[2:end]), " $(ex.args[1]) "))
print(io, ex)
end
"""
Return `val` as a subscript, used for printing `UnitBlade` and `Blade` instances.
"""
function subscript(val)
r = div(val, 10)
subscript_char(x) = Char(8320 + x)
r > 0 ? string(subscript_char(r), subscript_char(mod(val, 10))) : string(subscript_char(val))
end
function show1(io::IO, ex::Expression)
args = map(x -> isa(x, Expression) ? repr(hash(x)) : x, ex.args)
print(io, Expression, '(', join([ex.head; args], ", "), ')')
println(io)
end
show1(ex::Expression) = show1(stdout, ex)
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 3189 | struct Factorization
ex::Expression
terms::Vector{Term}
# Term -> list of products in which the term appears.
factors::Dictionary{Term, Vector{Term}}
end
function Factorization(ex::Expression)
@assert isexpr(ex, SCALAR_ADDITION)
terms = ex.args
Factorization(ex, terms, factor_map(terms))
end
function factor_map(products)
factors = Dictionary{Term, Vector{Term}}()
for product in products
isexpr(product, SCALAR_PRODUCT) || continue
for term in product
term_products = get!(Vector{Term}, factors, term)
!in(product, term_products) && push!(term_products, product)
end
end
factors
end
function remove_single_factor(term::Term, factor::Term)
@assert term !== factor
isexpr(term, SCALAR_PRODUCT) || return term
ex = term::Expression
removed = findfirst(term -> term === factor, ex)
@assert !isnothing(removed)
length(ex) == 2 && return removed == 1 ? ex[2] : ex[1]
unsimplified_expression(ex.cache, SCALAR_PRODUCT, Term[ex[i] for i in eachindex(ex) if i ≠ removed])
end
function factorize(ex::Expression)
!isexpr(ex, SCALAR_ADDITION) && return ex
fact = Factorization(ex)
apply!(fact)
end
function apply!(fact::Factorization)
(; terms, factors, ex) = fact
(; cache) = ex
# Not enough products to factorize anything.
length(factors) < 2 && return ex
n, factor = findmax(length, factors)
@assert n > 0
# There are no terms that we can factorize.
n == 1 && return ex
@debug "Factorizing $n terms for $ex"
products = factors[factor]
factorized_terms = Term[remove_single_factor(term, factor) for term in products]
@assert any(xx !== yy for (xx, yy) in zip(factorized_terms, products))
@assert length(factorized_terms) > 1
addition = unsimplified_expression(cache, SCALAR_ADDITION, factorized_terms)
product = unsimplified_expression(cache, SCALAR_PRODUCT, disassociate1(Term[factor, factorize(addition)], SCALAR_PRODUCT))
unfactorized_terms = filter(term -> all(x -> x !== term, products), terms)
isempty(unfactorized_terms) && return product
unfactorized = length(unfactorized_terms) == 1 ? unfactorized_terms[1] : factorize(unsimplified_expression(cache, SCALAR_ADDITION, unfactorized_terms))
new_ex = unsimplified_expression(cache, SCALAR_ADDITION, disassociate1(Term[product, unfactorized], SCALAR_ADDITION))
factorize(new_ex)
end
function replace_with_factorized!(cache, ex, i)
isnothing(i) && return true
iterator = traversal_iterator(ex)
subex = iterator[i]
isa(subex, ID) && (subex = dereference(cache, subex))
!isexpr(subex, (SCALAR_ADDITION, SCALAR_PRODUCT)) && return true
factorized = factorize(subex)
iterator[i] = factorized
for term in leaf_factorization_terms(factorized)
factorize!(term, cache)
end
false
end
function leaf_factorization_terms(ex::Expression)
leaves = Term[]
traverse(ex) do ex
isexpr(ex, (SCALAR_ADDITION, SCALAR_PRODUCT)) && return true
push!(leaves, ex)
false
end
leaves
end
factorize!(ex::Expression) = factorize!(ex, ex.cache)
function factorize!(ex, cache::ExpressionCache)
traverse_indexed((ex, i) -> replace_with_factorized!(cache, ex, i), ex; retraversal = Retraversal(cache, Expr))
ex
end
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 1801 | """
getcomponent(collection)
getcomponent(collection, i)
getcomponent(collection, j, i)
Retrieve a number from a collection to be interpreted as the component of a geometric entity.
`getcomponent(collection)` which defaults to `collection[]` is used to extract the only component of a scalar or antiscalar.
`getcomponent(collection, j, i)` which defaults to `collection[j][i]` is used to extract the i-th component the j-th geometric entity for a collection of multiple geometric vectors.
`getcomponent(collection, i)` which defaults to `collection[i]` is used to extract the i-th component of a single geometric entity or a set of geometric entities backed by `collection`. In the case of a set of geometric entities, this is semantically equivalent to `getcomponent(collection, j, i)` where a single `i` is computed from the cumulated sum of past indices, i.e. as if components from consecutive entities were concatenated together. See [`@ga`](@ref) for more information regarding which mode is used depending on the syntax for grade extraction.
Most collections will not need to extend this method, but is exposed should the need arise for a tigher control over how input data is accessed.
"""
function getcomponent end
getcomponent(x) = x[]
getcomponent(x, i) = x[i]
getcomponent(x, j, i) = x[j][i]
"""
construct(T, components::Tuple)
Construct an instance of `T` from a tuple of components.
Defaults to `T(components)`.
"""
function construct end
construct(::Type{Tuple}, components) = components
construct(::Type{Vector{T}}, components) where {T} = collect(T, components)
construct(::Type{Vector}, components) = collect(components)
construct(::Type{T}, components) where {T} = T(components)
construct(::Type{T}, components::Tuple) where {T<:Real} = T(only(components))
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 28577 | const DEFAULT_TYPE = nothing
"""
@ga <sig> <T> <ex>
@ga <sig> <ex>
Generate Julia code which implements the computation of geometric elements from `ex` in an algebra defined by a signature `sig` (see [`SymbolicGA.Signature`](@ref)).
Supported syntax:
- `sig`: Integer literal or tuple of 1, 2 or 3 integer literals corresponding to the number of positive, negative and degenerate basis vectors respectively, where unspecified integers default to zero. May also be a string literal of the form `<+++--𝟎>` where the number of `+`, `-` and `𝟎` correspond to the nmuber of positive, negative and degenerate basis vectors respectively.
- `T`: Any arbitrary expression which evaluates to a type or to `nothing`.
- `ex`: Any arbitrary expression that can be parsed algebraically.
See also: [`codegen_expression`](@ref).
`ex` can be a single statement or a block, and uses a domain-specific language to facilitate the construction of algebraic expressions.
`ex` is logically divided into two sections: a definition section, which defines bindings, and a final algebraic expression, which will be the object of the evaluation. It is processed in three phases:
- A definition phase, in which bindings are defined with one or several statements for use in the subsequent phase;
- An expansion phase, where identified bindings in the final algebraic expression are expanded. The defined bindings include the ones priorly defined and a set of default bindings.
- An evaluation phase, in which the core algebraic expression is simplified and translated into a Julia expression.
# Expression parsing
## Binding definitions
All statements prior to the last can define new variables or functions with the following syntax and semantics:
- Variables are either declared with `<lhs::Symbol> = <rhs::Any>` or with `<lhs::Symbol>::<type>`, the latter being expanded to `<lhs> = <lhs>::<type>`.
- Functions are declared with a standard short or long form function definition `<name>(<args...>) = <rhs>` or `function <name>(<args...>) <rhs> end`, and are restricted to simple forms to encode simple semantics. The restrictions are as follows:
- `where` clauses and output type annotations are not supported.
- Function arguments must be untyped, e.g. `f(x, y)` is allowed but not `f(x::Vector, y::Vector)`.
- Function arguments must not be reassigned; it is assumed that any occurence of symbols declared as arguments will reference these arguments. For example, `f(x, y) = x + y` assumes that `x + y` actually means "perform `+` on the first and second function argument". Therefore, `f(x, y) = (x = 2; x) + y` will be likely to cause bugs. To alleviate this restriction, use [`codegen_expression`](@ref) with a suitable [`SymbolicGA.Bindings`] with function entries that contain specific calls to `:(\$(@arg <i>)).
## Binding expansion
References and functions are expanded in a fairly straightforward copy-paste manner, where references are replaced with their right-hand side and function calls with their bodies with their arguments interpolated. Simple checks are put in place to allow for self-referencing bindings for references, such as `x = x::T`, leading to a single expansion of such a pattern in the corresponding expression subtree.
See [`SymbolicGA.Bindings`](@ref) for more information regarding the expansion of such variables and functions.
Function calls will be assumed to be either referencing a binding or a built-in function. If you want to call a function, e.g. `my_func(x)::Vector`, you will have to interpolate the call: `\$(my_func(x))::Vector`.
# Algebraic evaluation
Type annotations may either:
- Specify what type of geometric entity an input should be considered as, where components are then picked off with `getcomponent`.
- Request the projection of an intermediate expression over one or multiple grades.
"""
macro ga(sig_ex, args...)
T, ex = parse_arguments(args)
ex = codegen_expression(sig_ex, ex; T)
propagate_source(__source__, esc(ex))
end
function parse_arguments(args)
length(args) ≤ 2 || throw(MethodError(var"@ga", args))
length(args) == 2 ? args : (DEFAULT_TYPE, args[1])
end
propagate_source(__source__, ex) = Expr(:block, LineNumberNode(__source__.line, __source__.file), ex)
"""
Bindings(; refs = Dict{Symbol,Any}(), funcs = Dict{Symbol,Any}(), warn_override = true)
Structure holding information about bindings which either act as references (simple substitutions) or as functions, which can be called with arguments.
This allows a small domain-specific language to be used when constructing algebraic expressions.
References are `lhs::Symbol => rhs` pairs where the left-hand side simply expands to the right-hand side during parsing. Right-hand sides which include `lhs` are supported, such that references of the form `x = x::Vector` are allowed, but will be expanded only once.
Functions are `name::Symbol => body` pairs where `rhs` must refer to their arguments with `Expr(:argument, <literal::Int>)` expressions. Recursion is not supported and will lead to a `StackOverflowError`. See [`@arg`](@ref).
Most default functions and symbols are implemented using this mechanism. If `warn_override` is set to true, overrides of such default functions will trigger a warning.
"""
struct Bindings
refs::Dict{Symbol,Any}
funcs::Dict{Symbol,Any}
warn_override::Bool
ref_sourcelocs::Dict{Symbol,LineNumberNode}
func_sourcelocs::Dict{Symbol,LineNumberNode}
end
Bindings(; refs = Dict(), funcs = Dict(), warn_override::Bool = true) = Bindings(refs, funcs, warn_override, Dict(), Dict())
function Base.merge!(x::Bindings, y::Bindings)
warn_override = x.warn_override & y.warn_override
for (k, v) in pairs(y.refs)
if haskey(x.refs, k) && warn_override
ln = get(y.ref_sourcelocs, k, nothing)
@warn "Redefinition of variable `$k`$(sourceloc(ln))."
end
x.refs[k] = v
end
for (k, v) in pairs(y.funcs)
if haskey(x.funcs, k) && warn_override
ln = get(y.func_sourcelocs, k, nothing)
@warn "Redefinition of function `$k`$(sourceloc(ln)) (only one method is allowed)."
end
x.funcs[k] = v
end
x
end
"""
@arg <literal::Integer>
Convenience macro to construct expressions of the form `Expr(:argument, i)` used within function definitions for [`SymbolicGA.Bindings`](@ref).
"""
macro arg(i)
i > 0 || error("Argument slots must be positive integers.")
QuoteNode(Expr(:argument, i))
end
"""
[`Bindings`](@ref) included by default in [`@ga`](@ref).
By default, any user-defined symbol overriding a symbol defined here will trigger a warning; set `warn_override = false` to disable this.
"""
function default_bindings(; warn_override::Bool = true)
refs = Dict{Symbol,Any}(
:𝟏 => :(1::e),
:𝟙 => :(1::e̅),
:⟑ => :geometric_product,
:⩒ => :geometric_antiproduct,
:∧ => :exterior_product,
:outer_product => :exterior_product,
:∨ => :exterior_antiproduct,
:regressive_product => :exterior_antiproduct,
:outer_antiproduct => :exterior_antiproduct,
:⬤ => :interior_product,
:● => :interior_product,
:⋅ => :interior_product,
:inner_product => :interior_product,
:○ => :interior_antiproduct,
:inner_antiproduct => :interior_antiproduct,
:⦿ => :scalar_product,
:⊣ => :left_interior_product,
:left_contraction => :left_interior_product,
:⨼ => :left_interior_antiproduct,
:⊢ => :right_interior_product,
:right_contraction => :right_interior_product,
:⨽ => :right_interior_antiproduct,
:× => :commutator_product,
:/ => :division,
:inv => :inverse,
:dual => :right_complement,
:inverse_dual => :left_complement,
:<< => :versor_product,
)
@static if VERSION ≥ v"1.10-DEV"
refs[Symbol("⟇")] = :geometric_antiproduct
end
funcs = Dict{Symbol,Any}(
:bulk_left_complement => :(geometric_product(antireverse($(@arg 1)), 𝟙)),
:bulk_right_complement => :(geometric_product(reverse($(@arg 1)), 𝟙)),
:weight_left_complement => :(geometric_antiproduct(𝟏, antireverse($(@arg 1)))),
:weight_right_complement => :(geometric_antiproduct(𝟏, reverse($(@arg 1)))),
:bulk => :(weight_left_complement(bulk_right_complement($(@arg 1)))),
:weight => :(bulk_left_complement(weight_right_complement($(@arg 1)))),
:left_interior_product => :(exterior_antiproduct(left_complement($(@arg 1)), $(@arg 2))),
:right_interior_product => :(exterior_antiproduct($(@arg 1), right_complement($(@arg 2)))),
:scalar_product => :(geometric_product($(@arg 1), reverse($(@arg 1)))::Scalar),
:left_interior_antiproduct => :(exterior_product($(@arg 1), right_complement($(@arg 2)))),
:right_interior_antiproduct => :(exterior_product(left_complement($(@arg 1)), $(@arg 2))),
:bulk_norm => :($sqrt(interior_product($(@arg 1), reverse($(@arg 1))))::e),
:weight_norm => :($sqrt(interior_antiproduct($(@arg 1), antireverse($(@arg 1))))::e̅),
:geometric_norm => :(bulk_norm($(@arg 1)) + weight_norm($(@arg 1))),
:projected_geometric_norm => :(antidivision(bulk_norm($(@arg 1)), weight_norm($(@arg 1)))),
:unitize => :(antidivision($(@arg 1), weight_norm($(@arg 1)))),
:division => :(geometric_product($(@arg 1), inverse($(@arg 2)))),
:antidivision => :(inverse_dual(division(dual($(@arg 1)), dual($(@arg 2))))),
:geometric_antiproduct => :(inverse_dual(geometric_product(dual($(@arg 1)), dual($(@arg 2))))),
:exterior_antiproduct => :(inverse_dual(exterior_product(dual($(@arg 1)), dual($(@arg 2))))),
:interior_antiproduct => :(inverse_dual(interior_product(dual($(@arg 1)), dual($(@arg 2))))),
:antiscalar_product => :(geometric_antiproduct($(@arg 1), antireverse($(@arg 1)))::e̅),
:antiinverse => :(inverse_dual(inverse(dual($(@arg 1))))),
:versor_product => :(geometric_product($(@arg 2), $(@arg 1), inverse($(@arg 2)))),
)
Bindings(; refs, funcs, warn_override)
end
function generate_expression(sig::Signature, ex, bindings::Bindings = default_bindings(); factorize = true, optimize = true)
ex, flattened = extract_expression(ex, sig, bindings)
ex = restructure(ex)
factorize && factorize!(ex)
optimize && (ex = optimize!(ex))
ex, flattened
end
"""
codegen_expression(sig, ex; T = $DEFAULT_TYPE, bindings::Optional{Bindings} = nothing)
Parse `ex` as an algebraic expression and generate a Julia expression which represents the corresponding computation. `sig` can be a [`SymbolicGA.Signature`](@ref), a signature integer or a signature string, tuple or tuple expression adhering to semantics of [`@ga`](@ref). See [`@ga`](@ref) for more information regarding the parsing and semantics applied to `ex`.
## Parameters
- `T` specifies what type to use when reconstructing geometric entities from tuple components with [`construct`](@ref). If set to `nothing` and the result is in a non-flattened form (i.e. not annotated with an annotation of the type `<ex>::(0 + 2)`), then an appropriate [`KVector`](@ref) will be used depending on which type of geometric entity is returned; if multiple entities are present, a tuple of `KVector`s will be returned. If the result is in a flattened form, `T` will be set to `:Tuple` if unspecified.
- `bindings` is a user-provided [`SymbolicGA.Bindings`](@ref) which controls what expansions are carried out on the raw Julia expression before conversion to an algebraic expression.
"""
function codegen_expression end
codegen_expression(sig_ex, ex; T = DEFAULT_TYPE, bindings::Optional{Bindings} = nothing) =
codegen_expression(extract_signature(sig_ex), ex; T, bindings)
function codegen_expression(sig::Signature, ex; T = DEFAULT_TYPE, bindings::Optional{Bindings} = nothing)
bindings = @something(bindings, default_bindings())
generated, flattened = generate_expression(sig, ex, bindings)
flattened && isnothing(T) && (T = :Tuple)
define_variables(generated, flattened, T)
end
function extract_signature(ex)
(isa(ex, Integer) || isa(ex, AbstractString)) && return Signature(ex)
isa(ex, Tuple) && return Signature(ex...)
Meta.isexpr(ex, :tuple) || error("Expected tuple as signature, got $ex")
all(isa(x, Int) for x in ex.args) || error("Expected literals in signature, got $ex")
s = Signature(ex.args...)
end
const ADJOINT_SYMBOL = Symbol("'")
isreserved(op::Symbol) = in(op, (:+, :-, :geometric_product, :exterior_product, :interior_product, :commutator_product, :inverse, :reverse, :antireverse, :left_complement, :right_complement, :exp))
function extract_blade_from_annotation(cache, t)
isa(t, Symbol) || return nothing
(t === :e || t === :e0) && return blade(cache)
t in (:e̅, :ē) && return antiscalar(cache)
if startswith(string(t), "e_")
indices = parse.(Int, split(string(t), '_')[2:end])
else
m = match(r"^e(\d+)$", string(t))
dimension(cache.sig) < 10 || error("A dimension of less than 10 is required to unambiguously refer to blades.")
isnothing(m) && return nothing
indices = parse.(Int, collect(m[1]))
end
allunique(indices) || error("Index duplicates found in blade annotation $t.")
maximum(indices) ≤ dimension(cache.sig) || error("One or more indices exceeds the dimension of the specified space for blade $t")
blade(cache, indices)
end
function extract_grade_from_annotation(t, sig)
isa(t, Int) && return t
t === :Scalar && return 0
t === :Vector && return 1
t === :Bivector && return 2
t === :Trivector && return 3
t === :Quadvector && return 4
t === :Antiscalar && return dimension(sig)
t === :Multivector && return collect(0:dimension(sig))
Meta.isexpr(t, :annotate_projection) && t.args[1] === :+ && return Int[extract_grade_from_annotation(t, sig) for t in @view t.args[2:end]]
Meta.isexpr(t, :tuple) && return extract_grade_from_annotation.(t.args, sig)
error("Unknown grade projection for algebraic element $t")
end
struct UnknownFunctionError <: Exception
f::Symbol
end
Base.showerror(io::IO, err::UnknownFunctionError) = println(io, "UnknownFunctionError: call to non-built-in function `$(err.f)` detected\n\nIf you want to insert the value of an expression, use the interpolation syntax \$")
function extract_expression(ex, sig::Signature, bindings::Bindings)
# Shield interpolated regions in a `QuoteNode` from expression processing.
ex = prewalk(ex) do ex
Meta.isexpr(ex, :$) && return QuoteNode(ex.args[1])
ex
end
ex2 = expand_variables(ex, bindings)
@debug "After variable expansion: $(stringc(ex2))"
# Make sure calls in annotations are not interpreted as actual operations.
# Also shield interpolated expressions from being processed first in `postwalk`.
ex3 = prewalk(ex2) do ex
if Meta.isexpr(ex, :comparison)
ex = foldr(((arg, op), y) -> :($op($x, $y)), ((ex.args[i], ex.args[i + 1]) for i in 1:(1 - length(ex.args))); init = last(ex.args))
end
if Meta.isexpr(ex, :(::)) && Meta.isexpr(ex.args[2], :call)
ex.args[2] = Expr(:annotate_projection, ex.args[2].args...)
elseif Meta.isexpr(ex, :$)
ex = Some(only(ex.args))
end
ex
end
cache = ExpressionCache(sig)
flattened = Meta.isexpr(ex3, :(::)) && begin
_, T = ex3.args
Meta.isexpr(T, :annotate_projection) && T.args[1] === :+
end
ex4 = postwalk(ex3) do ex
if Meta.isexpr(ex, ADJOINT_SYMBOL)
Expression(cache, REVERSE, ex.args[1]::Expression)
elseif Meta.isexpr(ex, :call) && isa(ex.args[1], Symbol)
op = ex.args[1]::Symbol
if !isreserved(op)
# Allow `*` for juxtaposition, e.g. `0.5α`.
op === :* && return ex
throw(UnknownFunctionError(op))
end
args = ex.args[2:end]
Expression(cache, Head(op), args)
elseif Meta.isexpr(ex, :(::))
ex, T = ex.args
b = extract_blade_from_annotation(cache, T)
if !isnothing(b)
if isa(ex, Expression)
# Allow blade projections only when it is equivalent to projecting on a grade.
isempty(basis_vectors(b)) && return project!(ex, 0)
basis_vectors(b) == collect(1:dimension(sig)) && return project!(ex, dimension(sig))
error("Blade annotations are not supported for specifying projections.")
end
return weighted(b, ex)
end
g = extract_grade_from_annotation(T, sig)
isa(ex, Expression) && return project!(ex, g)
isa(g, Int) && return input_expression(cache, ex, g)::Expression
isa(g, Vector{Int}) && return input_expression(cache, ex, g; flattened = !Meta.isexpr(T, :tuple))::Expression
# Consider the type annotation a regular Julia expression.
:($ex::$T)
elseif isa(ex, QuoteNode) && !isa(ex.value, Symbol)
# Unwrap quoted expressions, except for symbols for which quoting is the only
# way to poss a literal around.
ex.value
else
ex
end
end
final = prewalk(something, ex4)
isa(final, Expression) || error("Could not fully extract expression: $final\n\nOutermost expression has head $(final.head) and arguments $(final.args)\n")
final, flattened
end
sourceloc(ln::Nothing) = ""
sourceloc(ln::LineNumberNode) = string(" around ", ln.file, ':', ln.line)
function parse_bindings(ex::Expr; warn_override::Bool = true)
@assert Meta.isexpr(ex, :block)
parse_bindings(ex.args; warn_override)
end
function parse_bindings(exs; warn_override::Bool = true)
bindings = Bindings(; warn_override)
last_line = nothing
for ex in exs
if isa(ex, LineNumberNode)
last_line = ex
continue
end
if Meta.isexpr(ex, :(=)) && Meta.isexpr(ex.args[1], :call) || Meta.isexpr(ex, :function)
# Extract function definition.
call, body = Meta.isexpr(ex, :(=)) ? ex.args : ex.args
Meta.isexpr(call, :where) && error("`where` clauses are not supported", sourceloc(last_line), '.')
Meta.isexpr(body, :block, 2) && isa(body.args[1], LineNumberNode) && (body = body.args[2])
name::Symbol, args... = call.args
argtypes = extract_type.(args)
all(isnothing, argtypes) || error("Function arguments must not have type annotations", sourceloc(last_line), '.')
argnames = extract_name.(args)
# Create slots so that we don't need to keep the names around; then we can directly place arguments by index.
body = define_argument_slots(body, argnames)
haskey(bindings.funcs, name) && @warn "Redefinition of user-defined function `$name`$(sourceloc(last_line)) (only one method is allowed)."
bindings.funcs[name] = body
!isnothing(last_line) && (bindings.func_sourcelocs[name] = last_line)
continue
end
if Meta.isexpr(ex, :(::)) && isa(ex.args[1], Symbol)
# Type declaration.
var, T = ex.args
ex = :($var = $var::$T)
end
!Meta.isexpr(ex, :(=), 2) && error("Non-final expression parsed without a left-hand side assignment", sourceloc(last_line), '.')
lhs, rhs = ex.args
haskey(bindings.refs, lhs) && @warn "Redefinition of user-defined variable `$lhs`$(sourceloc(last_line))."
bindings.refs[lhs] = rhs
!isnothing(last_line) && (bindings.ref_sourcelocs[lhs] = last_line)
end
bindings
end
"""
Expand variables from a block expression, yielding a final expression where all variables were substitued with their defining expression.
"""
function expand_variables(ex, bindings::Bindings)
!Meta.isexpr(ex, :block) && (ex = Expr(:block, ex))
rhs = nothing
i = findlast(x -> !isa(x, LineNumberNode), eachindex(ex.args))
isnothing(i) && error("No input expression could be parsed.")
parsed_bindings = parse_bindings(ex.args[1:(i - 1)])
bindings = merge!(deepcopy(bindings), parsed_bindings)
last_ex = ex.args[i]
rhs = Meta.isexpr(last_ex, :(=)) ? last_ex.args[2] : last_ex
# Expand references and function calls.
res = postwalk(ex -> expand_subtree(ex, bindings.refs, bindings.funcs, Set{Symbol}()), rhs)
!isa(res, Expr) && error("Expression resulted in a trivial RHS before simplifications: $(repr(res))\n\nThis may be due to not performing any operations related to geometric algebra.")
res
end
function expand_subtree(ex, refs, funcs, used_refs)
expanded_call = expand_function_call(funcs, ex)
!isnothing(expanded_call) && return postwalk(x -> expand_subtree(x, refs, funcs, used_refs), expanded_call)
!isa(ex, Symbol) && return ex
used_refs_subtree = copy(used_refs)
while isa(ex, Symbol) && !in(ex, used_refs_subtree)
expanded_ref = expand_reference(refs, ex)
isnothing(expanded_ref) && break
ref, ex = expanded_ref
push!(used_refs_subtree, ref)
isa(ex, Expr) && return postwalk(x -> expand_subtree(x, refs, funcs, used_refs_subtree), ex)
end
ex
end
extract_type(ex) = Meta.isexpr(ex, :(::), 2) ? ex.args[2] : nothing
extract_name(ex) = Meta.isexpr(ex, :(::), 2) ? ex.args[1] : isa(ex, Symbol) ? ex : error("Expected argument name to be a symbol, got $ex")
function define_argument_slots(ex, argnames)
postwalk(ex) do ex
if isa(ex, Symbol)
i = findfirst(==(ex), argnames)
!isnothing(i) && return Expr(:argument, i)
end
ex
end
end
function expand_function_call(funcs, ex)
Meta.isexpr(ex, :call) && isa(ex.args[1], Symbol) || return nothing
f::Symbol, args... = ex.args
func = get(funcs, f, nothing)
isnothing(func) && return nothing
fill_argument_slots(funcs[f], args, f)
end
function fill_argument_slots(ex, args, f::Symbol)
postwalk(ex) do ex
if Meta.isexpr(ex, :argument)
arg = ex.args[1]::Int
in(arg, eachindex(args)) || throw(ArgumentError("Not enough function arguments were provided to function '$f': expected $(argument_count(ex)) arguments, $(length(args)) were provided."))
return args[arg]
end
ex
end
end
function argument_count(ex)
i = 0
traverse(ex, Expr) do ex
Meta.isexpr(ex, :argument) && (i = max(i, ex.args[1]::Int))
nothing
end
i
end
function expand_reference(refs, ex)
isa(ex, Symbol) || return nothing
ref = get(refs, ex, nothing)
isnothing(ref) && return nothing
ex => ref
end
function extract_weights(cache::ExpressionCache, ex, g::Int; j::Optional{Int} = nothing, offset::Optional{Int} = nothing)
n = nelements(cache.sig, g)
weights = Any[]
for i in 1:n
push!(weights, extract_component(cache, ex, i; j, offset, isscalar = in(g, (0, dimension(cache.sig)))))
end
weights
end
function extract_component(cache::ExpressionCache, ex, i::Int; j::Optional{Int} = nothing, offset::Optional{Int} = nothing, isscalar::Bool = false)
isscalar && isnothing(offset) && isnothing(j) && return Expression(cache, COMPONENT, ex)
!isnothing(j) && return Expression(cache, COMPONENT, ex, j, i)
Expression(cache, COMPONENT, ex, i + something(offset, 0))
end
function input_expression(cache::ExpressionCache, ex, g::Int; j::Optional{Int} = nothing, offset::Optional{Int} = nothing)
blades = map(args -> blade(cache, args), combinations(1:dimension(cache.sig), g))
weights = extract_weights(cache, ex, g; j, offset)
Expression(cache, ADDITION, Term[weighted(blade, w) for (blade, w) in zip(blades, weights)])
end
function input_expression(cache::ExpressionCache, ex, gs::AbstractVector; flattened::Bool = false)
args = Any[]
offset = 0
for (j, g) in enumerate(gs)
if flattened
push!(args, input_expression(cache, ex, g; offset))
offset += nelements(cache.sig, g)
else
push!(args, input_expression(cache, ex, g; j))
end
end
Expression(cache, ADDITION, args)
end
function walk(ex::Expr, inner, outer)
new_ex = Expr(ex.head)
for arg in ex.args
new = inner(arg)
!isnothing(new) && push!(new_ex.args, new)
end
outer(new_ex)
end
function restructure(ex::Expression)
@debug "Before restructuring: $(stringc(ex))"
# Structure the different parts into multivectors and k-vectors.
# All `+` operations are replaced with k-vector or multivector expressions.
ex = restructure_sums(ex)
@debug "After sum restructuring: $(stringc(ex))"
# Add zero-factored components for blades not represented in k-vectors.
ex = fill_kvector_components(ex)
@debug "After k-vector component filling: $(stringc(ex))"
@debug "After restructuring: $(stringc(ex))"
ex
end
function to_final_expr(arg, args...)
final = to_expr(arg, args...)
@assert !isnothing(final) "`nothing` value detected as output element for argument $arg"
@assert !isa(final, Expression) "Expected non-Expression element, got $final"
final
end
reconstructed_type(T::Nothing, sig::Signature, ex) = :($KVector{$(ex.grade::Int), $(dimension(sig))})
reconstructed_type(T, sig::Signature, ex) = T
function to_expr(cache, ex, flatten::Bool, T, variables, stop_early = false)
if isa(ex, Term)
rhs = get(variables, ex, nothing)
!isnothing(rhs) && return rhs
end
isa(ex, ID) && (ex = dereference(cache, ex))
isa(ex, Expression) && isscalar(ex.head) && return Expr(:call, scalar_function(ex.head), to_final_expr.(cache, ex.args, flatten, Ref(T), Ref(variables), true)...)
if isexpr(ex, MULTIVECTOR)
if flatten
@assert !isnothing(T)
args = Expr.(:..., to_final_expr.(cache, ex.args, flatten, Ref(T), Ref(variables), true))
return :($construct($(reconstructed_type(T, ex.cache.sig, ex)), $(Expr(:tuple, args...))))
else
return Expr(:tuple, to_final_expr.(cache, ex, flatten, Ref(T), Ref(variables))...)
end
end
isexpr(ex, FACTOR) && return to_final_expr(cache, ex[1], flatten, T, variables)
if isexpr(ex, KVECTOR)
Tintermediate = flatten ? :Tuple : T
RT = reconstructed_type(Tintermediate, ex.cache.sig, ex)
components = Expr(:tuple)
append!(components.args, [to_final_expr(cache, x, flatten, Tintermediate, variables) for x in ex])
return :($construct($RT, $components))
end
isexpr(ex, BLADE) && return 1
if isexpr(ex, GEOMETRIC_PRODUCT)
@assert isweightedblade(ex)
return to_final_expr(cache, ex[1]::Expression, flatten, T, variables)
end
ex === Zero() && return 0
isa(ex, Expr) && !stop_early && return Expr(ex.head, to_expr.(cache, ex.args, flatten, Ref(T), Ref(variables))...)
ex
end
function scalar_function(head::Head)
head === COMPONENT && return getcomponent
head === SCALAR_SQRT && return sqrt
head === SCALAR_ABS && return abs
head === SCALAR_NAN_TO_ZERO && return nan_to_zero
head === SCALAR_INVERSE && return inv
head === SCALAR_COS && return cos
head === SCALAR_SIN && return sin
head === SCALAR_COSH && return cosh
head === SCALAR_SINH && return sinh
head === SCALAR_DIVISION && return /
head === SCALAR_PRODUCT && return *
head === SCALAR_ADDITION && return +
isscalar(head) && error("Head `$head` does not have a corresponding scalar function")
error("Expected head `$head` to be denoting a scalar expression")
end
nan_to_zero(x) = ifelse(isnan(x), zero(x), x)
struct ExecutionGraph
g::SimpleDiGraph{Int}
exs::Dict{Union{ID,Expression},Int}
exs_inv::Dict{Int,Union{ID,Expression}}
end
ExecutionGraph() = ExecutionGraph(SimpleDiGraph{Int}(), Dict(), Dict())
function ExecutionGraph(ex)
uses = Dict{Term,Int}()
g = ExecutionGraph()
add_node_uses!(uses, g, ex.cache, get_vertex!(g, ex), ex)
rem_edge!(g.g, 1, 1)
g
end
traverse(g::ExecutionGraph) = reverse(topological_sort_by_dfs(g.g))
function get_vertex!(g::ExecutionGraph, ex::Union{ID,Expression})
v = get(g.exs, ex, nothing)
!isnothing(v) && return v
add_vertex!(g.g)
v = nv(g.g)
g.exs[ex] = v
g.exs_inv[v] = ex
v
end
isexpandable(deref) = isa(deref, Expr) || isa(deref, Expression) && isscalar(deref.head)
function add_node_uses!(uses, g::ExecutionGraph, cache, i, ex)
j = 0
deref = dereference(cache, ex)
if (isa(ex, Expression) || isa(ex, ID) && isexpandable(deref))
uses[ex] = 1 + get!(uses, ex, 0)
j = get_vertex!(g, ex)
add_edge!(g.g, i, j)
end
if isa(ex, Expression)
for arg in ex
add_node_uses!(uses, g, cache, j, arg)
end
elseif isa(ex, ID) && isexpandable(deref)
for arg in deref.args
add_node_uses!(uses, g, cache, j, arg)
end
elseif isa(ex, Expr)
for arg in ex.args
if isa(arg, Expr)
add_node_uses!(uses, g, cache, i, arg)
elseif isa(arg, Expression)
add_node_uses!(uses, g, cache, i, arg)
end
end
end
nothing
end
function define_variables(ex::Expression, flatten::Bool, T)
variables = Dict{Term,Symbol}()
g = ExecutionGraph(ex)
definitions = Expr(:block)
# Recursively generate code using the previously defined variables.
for v in traverse(g)
x = g.exs_inv[v]
code = to_final_expr(ex.cache, x, flatten, T, variables)
if isa(code, Expr)
var = gensym()
push!(definitions.args, Expr(:(=), var, code))
variables[x] = var
end
end
definitions
end
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 7067 | mutable struct RefinementMetrics
reused::Int
splits::Int
end
Base.show(io::IO, metrics::RefinementMetrics) = print(io, RefinementMetrics, '(', sprint(show_metrics, metrics), ")")
show_metrics(io::IO, metrics::RefinementMetrics) = print(io, metrics.reused, " reuses, ", metrics.splits, " splits")
struct IterativeRefinement
# Having an vector of `ExpressionSpec` instead of `Expression`s
# would allow lazy substitutions.
# Lazy vs eager is in favor of lazy only if we intend to backtrack.
# For now, we can directly mutate expressions.
available::Dictionary{Int,Vector{Pair{ExpressionSpec,Expression}}}
expressions::Vector{Expression}
metrics::RefinementMetrics
end
function IterativeRefinement(exs::Vector{Expression})
available = Dictionary{Int,Vector{Pair{ExpressionSpec,Expression}}}()
for ex in exs
make_available!(available, ex)
end
IterativeRefinement(available, exs, RefinementMetrics(0, 0))
end
IterativeRefinement(ex::Expression) = IterativeRefinement(gather_scalar_expressions(ex))
gather_scalar_expressions(ex::Expression) = gather_scalar_expressions!(Expression[], ex)
function make_available!(available::Dictionary{Int,Vector{Pair{ExpressionSpec,Expression}}}, ex::Expression)
n = length(ex)
@assert n > 1
available_n = get!(Vector{Pair{ExpressionSpec, Expression}}, available, n)
spec = ExpressionSpec(ex)
!in(available_n, spec => ex) && push!(available_n, spec => ex)
end
make_available!(iter::IterativeRefinement, ex::Expression) = make_available!(iter.available, ex)
function may_reuse(ex::Expression, available::ExpressionSpec)
isexpr(ex, available.head) || return false
may_reuse(ex, available.args)
end
function may_reuse(ex::Expression, available::Vector{<:Term})
length(available) ≥ length(ex) && return false
all(available) do arg
n = count(==(arg), available)
n > 0 && count(==(arg), ex) == n
end
end
function optimize!(ex::Expression)
iter = IterativeRefinement(ex)
apply!(iter)
# @info "Optimization metrics: $(sprint(show_metrics, iter.metrics))"
ex
end
function gather_scalar_expressions!(exs::Vector{Expression}, ex::Expression)
(; cache) = ex
traverse(ex; retraversal = Retraversal(cache, Expr)) do ex
isexpr(ex, (SCALAR_ADDITION, SCALAR_PRODUCT)) && !in(ex, exs) && push!(exs, ex)
true
end
exs
end
function apply!(iter::IterativeRefinement)
@assert allunique(iter.expressions)
@debug "Optimizing over $(length(iter.expressions)) expressions"
exploited = exploit!(iter)
@debug "Exploited: $exploited ($(length(iter.expressions)) remaining)"
explored = -1
while length(iter.expressions) > 0 && (exploited ≠ 0 || explored ≠ 0)
allunique(iter.expressions) || @debug "Expressions are not unique: $(iter.expressions)"
explored = explore!(iter)
exploited = exploit!(iter)
@debug "Explored: $explored, exploited: $exploited ($(length(iter.expressions)) remaining)"
end
end
function exploit!(iter::IterativeRefinement)
exploited = 0
while true
exploited1 = reuse_available!(iter)
exploited1 == 0 && return exploited
exploited += exploited1
end
exploited
end
function reuse_available!(iter::IterativeRefinement)
nreused = iter.metrics.reused
# TODO: maybe do a 50/50 split instead of going for larger reuses first,
# as it might yield more expressions that are split like 90/10 offering
# a lesser potential for reuse.
sortkeys!(iter.available)
for (i, available) in pairs(iter.available)
filter!(iter.expressions) do ex
length(ex) ≤ 2 && return false
length(ex) ≤ i && return true
reuses = findall(x -> may_reuse(ex, x.first), available)
isempty(reuses) && return true
# TODO: use the split information to simulate what other reuses would be unlocked with the new split,
# then choose the reuse with the greater potential among all possible reuses.
(_, reused_ex) = available[first(reuses)]
reused, split = simulate_reuse(ex, reused_ex)
reuse!(ex, reused, iter)
length(ex) > 2
end
end
iter.metrics.reused - nreused
end
function explore!(iter::IterativeRefinement)
nsplits = split_descending!(iter)
filter!(>(2) ∘ length, iter.expressions)
nsplits
end
function split_descending!(iter::IterativeRefinement)
lengths = unique!(length.(iter.expressions))
ref = iter.metrics.splits
for n in sort!(lengths, rev = true)
n ≤ 2 && return 0
for ex in iter.expressions
length(ex) == n || continue
split!(ex, iter)
end
# Stop when at least 1 split has been performed.
# This ensures that splits on large expressions can be
# exploited before smaller expressions are split.
nsplits = iter.metrics.splits - ref
nsplits > 0 && return nsplits
end
0
end
function simulate_reuse(ex::Expression, reused::Expression)
remaining = copy(reused.args)
reused, split = Term[], Term[]
for arg in ex
if in(arg, remaining)
# We may have `x !== x` and `x == x` if `x` comes from an unsimplified expression.
# In such case we choose `x` from `remaining` as the unsimplified form is what we want for codegen.
i = findfirst(==(arg), remaining)::Int
push!(reused, remaining[i])
deleteat!(remaining, i)
else
push!(split, arg)
end
end
reused, split
end
function reuse!(ex::Expression, reused::Vector{Term})
@assert length(reused) > 1
remaining = copy(reused)
filter!(ex.args) do arg
j = findfirst(==(arg), remaining)
isnothing(j) && return true
deleteat!(remaining, j)
false
end
@assert isempty(remaining)
reused_ex = unsimplified_expression(ex.cache, ex.head, reused)
push!(ex.args, reused_ex)
@assert length(ex) > 1
reused_ex
end
function reuse!(ex::Expression, reused::Vector{Term}, iter::IterativeRefinement)
reused_ex = reuse!(ex, reused)
make_available!(iter, ex)
make_available!(iter, reused_ex)
length(reused_ex) > 2 && !in(reused_ex, iter.expressions) && push!(iter.expressions, reused_ex)
iter.metrics.reused += 1
ex
end
function reusability_score(split::Vector{<:Term}, head::Head, iter::IterativeRefinement)
count(ex -> isexpr(ex, head) && may_reuse(ex, split), iter.expressions)
end
select(args, n) = args[1:n]
function find_split(ex::Expression, iter::IterativeRefinement)
best = nothing
best_score = 0
n = length(iter.expressions)
for i in reverse(2:(length(ex) - 1))
possibilities = eachindex(ex.args)
generator = binomial(length(ex), i) ≤ 10 ? combinations(possibilities, i) : (select(possibilities, i) for _ in 1:10)
for indices in generator
set = ex.args[indices]
score = reusability_score(set, ex.head, iter)
score > 0.1n && return set
if isnothing(best)
best, best_score = set, score
elseif best_score < score
best, best_score = set, score
end
end
end
best::Vector{Term}
end
function split!(ex::Expression, iter::IterativeRefinement)
split = find_split(ex, iter)
iter.metrics.splits += 1
reuse!(ex, split, iter)
# Don't record the reuse.
iter.metrics.reused -= 1
end
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 1707 | """
Convert sums between elements of arbitrary grades into either a k-vector or a multivector.
If all elements in the sum had the same grade, a k-vector is returned.
Otherwise, all elements of the same grade are grouped, wrapped in k-vectors
and added to a multivector expression.
"""
function restructure_sums(ex::Expression)
ex == factor(ex.cache, 0) && return kvector(scalar(ex.cache, Zero()))
if isblade(ex) || isweightedblade(ex)
isone(nelements(ex.cache.sig, ex.grade::Int)) && return kvector(ex)
terms = [ex]
else
@assert isexpr(ex, ADDITION) "Expected addition expression, got expression type $(ex.head)"
terms = ex.args
end
# Fast path when all terms have the same grade.
allequal(grade.(terms)) && return kvector(terms)
args = sort(terms, by = grade)
grades = grade.(args)
i = 1
new_args = []
while i ≤ lastindex(grades)
g = grades[i]
j = findfirst(≠(g), @view grades[(i + 1):end])
j = something(j, lastindex(grades) - (i - 1))
j += i
push!(new_args, kvector(args[i:(j - 1)]))
i = j
end
multivector(new_args)
end
"Non-simplifiable zero, for use in factors."
struct Zero end
Base.show(io::IO, ::Zero) = print(io, '𝟎')
function fill_kvector_components(ex::Expression)
postwalk(ex) do ex
isexpr(ex, KVECTOR) || return ex
g = grade(ex)
i = 1
ex = kvector(sort(ex.args, by = basis_vectors, lt = lt_basis_order))
for indices in combinations(1:dimension(ex.cache.sig), g)
next = i ≤ lastindex(ex) ? ex[i]::Expression : nothing
if isnothing(next) || indices ≠ basis_vectors(next)
insert!(ex.args, i, weighted(blade(ex.cache, indices), Zero()))
end
i += 1
end
ex
end
end
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 119442 | precompile(Tuple{Type{SymbolicGA.Signature{P, N, D} where D where N where P}, String})
precompile(Tuple{Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Int64, Int64, Int64})
precompile(Tuple{Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Int64, Int64})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.Signature{3, 0, 0}, SymbolicGA.Signature{3, 0, 0}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.Signature{2, 1, 0}, SymbolicGA.Signature{2, 1, 0}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.Signature{1, 1, 1}, SymbolicGA.Signature{1, 1, 1}})
precompile(Tuple{typeof(SymbolicGA.triplet), SymbolicGA.Signature{1, 2, 3}})
precompile(Tuple{typeof(SymbolicGA.triplet), SymbolicGA.Signature{1, 2, 0}})
precompile(Tuple{Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Int64})
precompile(Tuple{typeof(SymbolicGA.triplet), SymbolicGA.Signature{1, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.is_degenerate), SymbolicGA.Signature{4, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.is_degenerate), SymbolicGA.Signature{1, 3, 0}})
precompile(Tuple{typeof(SymbolicGA.is_degenerate), SymbolicGA.Signature{1, 1, 1}})
precompile(Tuple{typeof(SymbolicGA.dimension), SymbolicGA.Signature{2, 1, 0}})
precompile(Tuple{typeof(SymbolicGA.dimension), SymbolicGA.Signature{1, 1, 4}})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{2, 1, 0}, Base.Val{1}, Base.Val{1}})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{2, 1, 0}, Base.Val{1}, Base.Val{2}})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{2, 1, 0}, Base.Val{3}, Base.Val{3}})
precompile(Tuple{Type{SymbolicGA.ExpressionCache}, SymbolicGA.Signature{3, 1, 0}})
precompile(Tuple{typeof(SymbolicGA.isexpr), SymbolicGA.Head})
precompile(Tuple{typeof(Core.Compiler.eltype), Type{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}}})
precompile(Tuple{typeof(Base._bool), SymbolicGA.var"#69#70"{SymbolicGA.Head}})
precompile(Tuple{typeof(Base.getproperty), Base.MappingRF{Base.var"#320#321"{SymbolicGA.var"#69#70"{SymbolicGA.Head}}, Base.BottomRF{typeof(Base.add_sum)}}, Symbol})
precompile(Tuple{typeof(Base._nt_names), Type{NamedTuple{(:scratch,), Tuple{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}}}}})
precompile(Tuple{typeof(Base.getproperty), Base.MappingRF{SymbolicGA.var"#24#36", typeof(Base.add_sum)}, Symbol})
precompile(Tuple{typeof(Base.reduce_empty), Base.MappingRF{SymbolicGA.var"#24#36", typeof(Base.add_sum)}, Type{Union{SymbolicGA.ID, SymbolicGA.Expression}}})
precompile(Tuple{typeof(Core.Compiler.eltype), Type{Array{SymbolicGA.Expression, 1}}})
precompile(Tuple{typeof(SymbolicGA.simplify!), SymbolicGA.Expression})
precompile(Tuple{Type{SymbolicGA.ExpressionSpec}, SymbolicGA.ExpressionCache, SymbolicGA.Head, SymbolicGA.Expression, Vararg{Any}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.indexed_iterate), Array{SymbolicGA.Expression, 1}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Array{SymbolicGA.Expression, 1}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), typeof(SymbolicGA.blade), SymbolicGA.ExpressionCache, Array{Int64, 1}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.blade), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Array{Int64, 1}}}})
precompile(Tuple{typeof(SymbolicGA.isexpr), SymbolicGA.Expression, SymbolicGA.Head, Int64})
precompile(Tuple{typeof(SymbolicGA.blade), SymbolicGA.ExpressionCache, Int64, Vararg{Int64}})
precompile(Tuple{Type{SymbolicGA.Expression}, SymbolicGA.ExpressionCache, SymbolicGA.Head, Int64, Vararg{Int64}})
precompile(Tuple{Type{SymbolicGA.ExpressionSpec}, SymbolicGA.ExpressionCache, SymbolicGA.Head, Int64, Vararg{Int64}})
precompile(Tuple{typeof(SymbolicGA.isexpr), SymbolicGA.Expression, Tuple{SymbolicGA.Head, SymbolicGA.Head}})
precompile(Tuple{Type{SymbolicGA.Expression}, SymbolicGA.ExpressionCache, SymbolicGA.Head, Symbol, Vararg{Any}})
precompile(Tuple{Type{SymbolicGA.ExpressionSpec}, SymbolicGA.ExpressionCache, SymbolicGA.Head, Symbol, Vararg{Any}})
precompile(Tuple{typeof(SymbolicGA.:(⟑)), SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.Expression, Int64})
precompile(Tuple{typeof(Base.:(!=)), SymbolicGA.Expression, Int64})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), Type{SymbolicGA.Expression}, SymbolicGA.ExpressionCache, SymbolicGA.Head, Symbol, Base.UnitRange{Int64}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), typeof(SymbolicGA.factor), SymbolicGA.ExpressionCache, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, Type{SymbolicGA.Expression}, Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.RefValue{SymbolicGA.Head}, Base.RefValue{Symbol}, Base.UnitRange{Int64}}}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.factor), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, Type{SymbolicGA.Expression}, Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.RefValue{SymbolicGA.Head}, Base.RefValue{Symbol}, Base.UnitRange{Int64}}}}}})
precompile(Tuple{typeof(Base.:(+)), SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.infer_grade), SymbolicGA.ExpressionCache, SymbolicGA.Head, Int64})
precompile(Tuple{typeof(SymbolicGA.infer_grade), SymbolicGA.ExpressionCache, SymbolicGA.Head, Array{Int64, 1}})
precompile(Tuple{typeof(Base.vect), SymbolicGA.Expression, Vararg{SymbolicGA.Expression}})
precompile(Tuple{typeof(SymbolicGA.infer_grade), SymbolicGA.ExpressionCache, SymbolicGA.Head, Array{SymbolicGA.Expression, 1}})
precompile(Tuple{typeof(SymbolicGA.kvector), SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.kvector), SymbolicGA.Expression})
precompile(Tuple{Type{SymbolicGA.ExpressionCache}, SymbolicGA.Signature{3, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.grade), SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{3, 0, 0}, Int64})
precompile(Tuple{typeof(Base.:(+)), SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{3, 0, 0}, Array{Int64, 1}})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{3, 1, 0}, Int64})
precompile(Tuple{typeof(Base.getproperty), SymbolicGA.Expression, Symbol})
precompile(Tuple{typeof(Base.:(==)), Int64, SymbolicGA.ID})
precompile(Tuple{typeof(SymbolicGA.collapse_factors), SymbolicGA.ExpressionCache, SymbolicGA.Head, Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}})
precompile(Tuple{typeof(Base.:(*)), SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.get!), SymbolicGA.var"#45#46", Base.Dict{Any, Int64}, SymbolicGA.ID})
precompile(Tuple{typeof(Base.push!), Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, SymbolicGA.ID})
precompile(Tuple{typeof(Base.:(+)), Vararg{SymbolicGA.Expression, 4}})
precompile(Tuple{Type{SymbolicGA.ExpressionSpec}, SymbolicGA.ExpressionCache, SymbolicGA.Head, Int64, Vararg{Any}})
precompile(Tuple{typeof(SymbolicGA.scalar_function), SymbolicGA.Head})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}}}, Type{Int64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}}}, Type{Real}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Real, 1}, Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}}}, Float64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.:(-)), SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{Int64, SymbolicGA.ID}})
precompile(Tuple{typeof(Base.:(*)), Int64, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.get!), SymbolicGA.var"#45#46", Base.Dict{Any, Int64}, Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}})
precompile(Tuple{typeof(Base.isequal), Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}})
precompile(Tuple{Type{SymbolicGA.Expression}, SymbolicGA.ExpressionCache, SymbolicGA.Head, SymbolicGA.ID, Vararg{Any}})
precompile(Tuple{Type{SymbolicGA.ExpressionSpec}, SymbolicGA.ExpressionCache, SymbolicGA.Head, SymbolicGA.ID, Vararg{Any}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.ID, SymbolicGA.ID}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{Int64, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.:(!=)), SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.:(-)), SymbolicGA.Expression})
precompile(Tuple{typeof(Base.get!), SymbolicGA.var"#45#46", Base.Dict{Any, Int64}, SymbolicGA.Expression})
precompile(Tuple{Type{SymbolicGA.Expression}, SymbolicGA.ExpressionCache, SymbolicGA.Head, SymbolicGA.Expression, Vararg{Any}})
precompile(Tuple{typeof(Base.getindex), SymbolicGA.Expression, Int64})
precompile(Tuple{typeof(SymbolicGA.isexpr), SymbolicGA.Expression, SymbolicGA.Head})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), typeof(SymbolicGA.dereference), SymbolicGA.ExpressionCache, Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}}}})
precompile(Tuple{typeof(Base.Broadcast._broadcast_getindex_evalf), typeof(SymbolicGA.dereference), SymbolicGA.ExpressionCache, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}}}, Type{Any}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}}}, SymbolicGA.Expression, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.push!), Base.Set{Any}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.promote_typeof), Int64, SymbolicGA.Expression, Vararg{SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.promote_typeof), SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.in), SymbolicGA.Expression, Base.Set{Any}})
precompile(Tuple{typeof(Base.:(*)), Int64, SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.project!), SymbolicGA.Expression, Int64})
precompile(Tuple{typeof(Base.reverse), SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.prewalk), SymbolicGA.var"#63#64"{SymbolicGA.Signature{3, 1, 0}, SymbolicGA.ExpressionCache}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(Base.reverse), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}, Type{SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.setindex!), Array{SymbolicGA.Expression, 1}, SymbolicGA.Expression, Int64})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{SymbolicGA.Expression, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(Base.reverse), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{Type{SymbolicGA.Expression}, SymbolicGA.ExpressionCache, SymbolicGA.Head, Array{SymbolicGA.Expression, 1}})
precompile(Tuple{typeof(SymbolicGA.antireverse), SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{3, 1, 0}, Int64})
precompile(Tuple{Type{SymbolicGA.ExpressionCache}, SymbolicGA.Signature{3, 0, 1}})
precompile(Tuple{typeof(SymbolicGA.prewalk), SymbolicGA.var"#63#64"{SymbolicGA.Signature{3, 0, 1}, SymbolicGA.ExpressionCache}, SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{3, 0, 1}, Int64})
precompile(Tuple{typeof(SymbolicGA.exterior_product), SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}}}, Type{Float64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression}})
precompile(Tuple{typeof(SymbolicGA.is_degenerate), SymbolicGA.Signature{3, 0, 1}})
precompile(Tuple{Type{Base.Generator{I, F} where F where I}, SymbolicGA.var"#65#67"{SymbolicGA.Signature{3, 0, 1}}, Array{Int64, 1}})
precompile(Tuple{typeof(Base.any), Base.Generator{Array{Int64, 1}, SymbolicGA.var"#65#67"{SymbolicGA.Signature{3, 0, 1}}}})
precompile(Tuple{typeof(SymbolicGA.is_degenerate), SymbolicGA.Signature{3, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{3, 0, 0}, Int64})
precompile(Tuple{Type{Base.Generator{I, F} where F where I}, SymbolicGA.var"#66#68"{SymbolicGA.Signature{3, 0, 0}}, Array{Int64, 1}})
precompile(Tuple{typeof(Base.getproperty), Base.MappingRF{SymbolicGA.var"#66#68"{SymbolicGA.Signature{3, 0, 0}}, Base.MappingRF{Base.var"#320#321"{typeof(Base.identity)}, Base.BottomRF{typeof(Base.add_sum)}}}, Symbol})
precompile(Tuple{typeof(Base.count), Base.Generator{Array{Int64, 1}, SymbolicGA.var"#66#68"{SymbolicGA.Signature{3, 0, 0}}}})
precompile(Tuple{typeof(SymbolicGA.nan_to_zero), Float64})
precompile(Tuple{typeof(SymbolicGA.scalar), SymbolicGA.ExpressionCache, Float64})
precompile(Tuple{typeof(Base.sprint), Function, SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.show1), Base.GenericIOBuffer{Array{UInt8, 1}}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, SymbolicGA.Head})
precompile(Tuple{typeof(Base.show), Base.GenericIOBuffer{Array{UInt8, 1}}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.show_unquoted), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, SymbolicGA.Expression, Int64, Int64, Int64})
precompile(Tuple{typeof(Base.show), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, SymbolicGA.Expression, String, Vararg{Any}})
precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.join), Base.GenericIOBuffer{Array{UInt8, 1}}, Base.Generator{SymbolicGA.Expression, SymbolicGA.var"#93#94"{SymbolicGA.Expression}}, String})
precompile(Tuple{typeof(SymbolicGA.print_scalar), Base.GenericIOBuffer{Array{UInt8, 1}}, Symbol})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.subscript), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}}}, Type{String}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{String, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.subscript), Tuple{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{Symbol, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, SymbolicGA.ID})
precompile(Tuple{typeof(Base.sizeof), SymbolicGA.ID})
precompile(Tuple{Type{SymbolicGA.Factorization}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.reduce_empty), Base.MappingRF{Base.var"#312#313"{typeof(Base.length)}, Base.BottomRF{typeof(Base._rf_findmax)}}, Type{Pair{Union{SymbolicGA.ID, SymbolicGA.Expression}, Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}}}})
precompile(Tuple{typeof(SymbolicGA.apply!), SymbolicGA.Factorization})
precompile(Tuple{typeof(Base.isapprox), SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.findfirst), SymbolicGA.var"#8#10"{Base.Set{Union{SymbolicGA.ID, SymbolicGA.Expression}}, SymbolicGA.ID}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.push!), Base.Set{Union{SymbolicGA.ID, SymbolicGA.Expression}}, SymbolicGA.ID})
precompile(Tuple{typeof(Base.findfirst), SymbolicGA.var"#8#10"{Base.Set{Union{SymbolicGA.ID, SymbolicGA.Expression}}, SymbolicGA.Expression}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.push!), Base.Set{Union{SymbolicGA.ID, SymbolicGA.Expression}}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression, Symbol}})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{8, SymbolicGA.Expression}})
precompile(Tuple{typeof(SymbolicGA.unsimplified_expression), SymbolicGA.ExpressionCache, SymbolicGA.Head, SymbolicGA.Expression, Vararg{SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.ID, SymbolicGA.ID, SymbolicGA.ID}})
precompile(Tuple{typeof(Base.push!), Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.factorize!), SymbolicGA.Expression})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{SymbolicGA.Retraversal{Expr, SymbolicGA.var"#83#85"{SymbolicGA.ExpressionCache, DataType}, SymbolicGA.var"#84#86"{SymbolicGA.ExpressionCache}}}}, typeof(SymbolicGA.traverse_indexed), SymbolicGA.var"#173#174"{SymbolicGA.ExpressionCache}, SymbolicGA.ID})
precompile(Tuple{typeof(Base.in), SymbolicGA.Expression, Tuple{SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression}})
precompile(Tuple{Type{Base.Pairs{Symbol, V, I, A} where A where I where V}, NamedTuple{(:by,), Tuple{typeof(SymbolicGA.grade)}}, Tuple{Symbol}})
precompile(Tuple{typeof(Base.getproperty), Base.Order.By{typeof(SymbolicGA.grade), Base.Order.ForwardOrdering}, Symbol})
precompile(Tuple{typeof(Base.getproperty), Base.Order.Lt{Base.Sort.var"#26#27"{Base.Order.By{typeof(SymbolicGA.grade), Base.Order.ForwardOrdering}}}, Symbol})
precompile(Tuple{typeof(Base._nt_names), Type{NamedTuple{(:scratch,), Tuple{Array{SymbolicGA.Expression, 1}}}}})
precompile(Tuple{Type{Base.Pairs{Symbol, V, I, A} where A where I where V}, NamedTuple{(:by, :lt), Tuple{typeof(SymbolicGA.basis_vectors), typeof(SymbolicGA.lt_basis_order)}}, Tuple{Symbol, Symbol}})
precompile(Tuple{typeof(Base.getproperty), Base.Order.Lt{Base.Order.var"#1#3"{typeof(SymbolicGA.lt_basis_order), typeof(SymbolicGA.basis_vectors)}}, Symbol})
precompile(Tuple{typeof(Base.getproperty), Base.Order.Lt{Base.Sort.var"#26#27"{Base.Order.Lt{Base.Order.var"#1#3"{typeof(SymbolicGA.lt_basis_order), typeof(SymbolicGA.basis_vectors)}}}}, Symbol})
precompile(Tuple{typeof(Base._nt_names), Type{NamedTuple{(:scratch,), Tuple{Array{Pair{Int64, Array{Pair{SymbolicGA.ExpressionSpec, SymbolicGA.Expression}, 1}}, 1}}}}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:factorize, :optimize), Tuple{Bool, Bool}}, typeof(SymbolicGA.generate_expression), SymbolicGA.Signature{3, 0, 0}, Expr})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#111#114"}, LineNumberNode})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#111#114"}, Expr})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#111#114"}, Symbol})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#111#114"}, Int64})
precompile(Tuple{typeof(SymbolicGA.postwalk), SymbolicGA.var"#120#122"{SymbolicGA.Bindings}, Expr})
precompile(Tuple{typeof(SymbolicGA.walk), Expr, SymbolicGA.var"#77#78"{SymbolicGA.var"#120#122"{SymbolicGA.Bindings}}, SymbolicGA.var"#120#122"{SymbolicGA.Bindings}})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#120#122"{SymbolicGA.Bindings}}, Symbol})
precompile(Tuple{typeof(SymbolicGA.walk), Symbol, SymbolicGA.var"#77#78"{SymbolicGA.var"#120#122"{SymbolicGA.Bindings}}, SymbolicGA.var"#120#122"{SymbolicGA.Bindings}})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#120#122"{SymbolicGA.Bindings}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#120#122"{SymbolicGA.Bindings}}, Int64})
precompile(Tuple{typeof(SymbolicGA.fill_argument_slots), Expr, Array{Any, 1}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#129#130"{Array{Any, 1}, Symbol}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#129#130"{Array{Any, 1}, Symbol}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#129#130"{Array{Any, 1}, Symbol}}, Int64})
precompile(Tuple{typeof(SymbolicGA.postwalk), SymbolicGA.var"#123#125"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#123#125"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#123#125"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#123#125"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}}, Int64})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#124#126"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#124#126"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}}, Expr})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#112#115"}, Symbol})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#112#115"}, Expr})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#112#115"}, Int64})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 0, 0}, SymbolicGA.ExpressionCache}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 0, 0}, SymbolicGA.ExpressionCache}}, Expr})
precompile(Tuple{typeof(SymbolicGA.extract_blade_from_annotation), SymbolicGA.ExpressionCache, Symbol})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Symbol, SymbolicGA.Signature{3, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.input_expression), SymbolicGA.ExpressionCache, Symbol, Int64})
precompile(Tuple{Type{Base.Generator{I, F} where F where I}, SymbolicGA.var"#136#137"{SymbolicGA.ExpressionCache}, Base.Generator{Combinatorics.Combinations, Combinatorics.var"#10#13"{Combinatorics.var"#reorder#11"{Base.UnitRange{Int64}}}}})
precompile(Tuple{typeof(Base.collect), Base.Generator{Base.Generator{Combinatorics.Combinations, Combinatorics.var"#10#13"{Combinatorics.var"#reorder#11"{Base.UnitRange{Int64}}}}, SymbolicGA.var"#136#137"{SymbolicGA.ExpressionCache}}})
precompile(Tuple{typeof(SymbolicGA.nelements), SymbolicGA.Signature{3, 0, 0}, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:j, :offset, :isscalar), Tuple{Nothing, Nothing, Bool}}, typeof(SymbolicGA.extract_component), SymbolicGA.ExpressionCache, Symbol, Int64})
precompile(Tuple{typeof(Base.Iterators.zip), Array{SymbolicGA.Expression, 1}, Array{Any, 1}})
precompile(Tuple{typeof(Base.getindex), Array{SymbolicGA.Expression, 1}, Int64})
precompile(Tuple{typeof(SymbolicGA.weighted), SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 0, 0}, SymbolicGA.ExpressionCache}}, Int64})
precompile(Tuple{typeof(SymbolicGA.input_expression), SymbolicGA.ExpressionCache, Int64, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:j, :offset, :isscalar), Tuple{Nothing, Nothing, Bool}}, typeof(SymbolicGA.extract_component), SymbolicGA.ExpressionCache, Int64, Int64})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{4, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{5, SymbolicGA.Expression}})
precompile(Tuple{typeof(SymbolicGA.substitute!), SymbolicGA.Expression, SymbolicGA.Head, SymbolicGA.Expression, Vararg{SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{6, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{10, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{7, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{11, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.hashindex), Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Int64})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{15, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{12, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{16, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, NTuple{20, SymbolicGA.Expression}})
precompile(Tuple{typeof(SymbolicGA.postwalk), SymbolicGA.var"#100#101", SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.project!), SymbolicGA.Expression, Array{Int64, 1}})
precompile(Tuple{typeof(SymbolicGA.gather_scalar_expressions), SymbolicGA.Expression})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{SymbolicGA.Retraversal{Expr, SymbolicGA.var"#83#85"{SymbolicGA.ExpressionCache, DataType}, SymbolicGA.var"#84#86"{SymbolicGA.ExpressionCache}}}}, typeof(SymbolicGA.traverse), SymbolicGA.var"#147#148"{Array{SymbolicGA.Expression, 1}}, SymbolicGA.ID, Type{SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.all), Function, Array{SymbolicGA.Expression, 1}})
precompile(Tuple{typeof(Base._all), Base.ComposedFunction{Base.Fix2{typeof(Base.:(>)), Int64}, typeof(Base.length)}, Array{SymbolicGA.Expression, 1}, Base.Colon})
precompile(Tuple{Type{SymbolicGA.ExpressionSpec}, SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.may_reuse), SymbolicGA.Expression, SymbolicGA.ExpressionSpec})
precompile(Tuple{typeof(Base.vect), SymbolicGA.Expression})
precompile(Tuple{typeof(Base.:(==)), Array{SymbolicGA.Expression, 1}, Array{SymbolicGA.Expression, 1}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{Nothing}}, typeof(SymbolicGA.traverse), SymbolicGA.var"#88#89"{SymbolicGA.Expression, SymbolicGA.Retraversal{Expr, SymbolicGA.var"#83#85"{SymbolicGA.ExpressionCache, DataType}, SymbolicGA.var"#84#86"{SymbolicGA.ExpressionCache}}, SymbolicGA.var"#147#148"{Array{SymbolicGA.Expression, 1}}}, Symbol, Type{Expr}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{Nothing}}, typeof(SymbolicGA.traverse), SymbolicGA.var"#88#89"{SymbolicGA.Expression, SymbolicGA.Retraversal{Expr, SymbolicGA.var"#83#85"{SymbolicGA.ExpressionCache, DataType}, SymbolicGA.var"#84#86"{SymbolicGA.ExpressionCache}}, SymbolicGA.var"#147#148"{Array{SymbolicGA.Expression, 1}}}, SymbolicGA.Expression, Type{Expr}})
precompile(Tuple{typeof(SymbolicGA.unsimplified_expression), SymbolicGA.ExpressionCache, SymbolicGA.Head, Symbol, Vararg{Any}})
precompile(Tuple{Type{SymbolicGA.IterativeRefinement}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.getproperty), SymbolicGA.IterativeRefinement, Symbol})
precompile(Tuple{typeof(Base.getproperty), SymbolicGA.RefinementMetrics, Symbol})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{Symbol, SymbolicGA.Expression, Expr}})
precompile(Tuple{typeof(Base.in), SymbolicGA.Expression, Array{SymbolicGA.Expression, 1}})
precompile(Tuple{typeof(Base.haskey), Base.Dict{Int64, Array{Pair{SymbolicGA.ExpressionSpec, SymbolicGA.Expression}, 1}}, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:optimize, :factorize), Tuple{Bool, Bool}}, typeof(SymbolicGA.generate_expression), SymbolicGA.Signature{3, 1, 0}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 1, 0}, SymbolicGA.ExpressionCache}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 1, 0}, SymbolicGA.ExpressionCache}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 1, 0}, SymbolicGA.ExpressionCache}}, Int64})
precompile(Tuple{typeof(SymbolicGA.extract_blade_from_annotation), SymbolicGA.ExpressionCache, Int64})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Int64, SymbolicGA.Signature{3, 1, 0}})
precompile(Tuple{typeof(SymbolicGA.nelements), SymbolicGA.Signature{3, 1, 0}, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:optimize, :factorize), Tuple{Bool, Bool}}, typeof(SymbolicGA.generate_expression), SymbolicGA.Signature{3, 0, 0}, Expr})
precompile(Tuple{typeof(Base.allunique), Array{SymbolicGA.Expression, 1}})
precompile(Tuple{typeof(SymbolicGA.optimize!), SymbolicGA.Expression})
precompile(Tuple{typeof(Base.length), Array{SymbolicGA.Expression, 1}})
precompile(Tuple{typeof(Base.in), Array{SymbolicGA.Expression, 1}})
precompile(Tuple{typeof(Base._all), Base.Fix2{typeof(Base.in), Array{SymbolicGA.Expression, 1}}, Array{SymbolicGA.Expression, 1}, Base.Colon})
precompile(Tuple{typeof(SymbolicGA.factor), SymbolicGA.ExpressionCache, Symbol})
precompile(Tuple{typeof(SymbolicGA.multivector), SymbolicGA.Expression, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.repr), SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.print_scalar), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Symbol})
precompile(Tuple{typeof(SymbolicGA.fill_kvector_components), SymbolicGA.Expression})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.Zero, Int64})
precompile(Tuple{typeof(Base.:(!=)), SymbolicGA.Zero, Int64})
precompile(Tuple{typeof(SymbolicGA.kvector), SymbolicGA.Expression, SymbolicGA.Expression, Vararg{SymbolicGA.Expression}})
precompile(Tuple{Type{SymbolicGA.KVector{1, 3, D, N} where N where D}, Tuple{Int64, Int64, Int64}})
precompile(Tuple{typeof(Base.eltype), SymbolicGA.KVector{1, Int64, 3, 3}})
precompile(Tuple{typeof(Base.collect), SymbolicGA.KVector{1, Int64, 3, 3}})
precompile(Tuple{Type{SymbolicGA.KVector{1, 3, D, N} where N where D}, NTuple{4, Int64}})
precompile(Tuple{Type{SymbolicGA.KVector{4, 3, D, N} where N where D}, NTuple{4, Int64}})
precompile(Tuple{Type{SymbolicGA.KVector{0, 3, D, N} where N where D}, Tuple{Int64}})
precompile(Tuple{typeof(Base.collect), SymbolicGA.KVector{0, Int64, 3, 1}})
precompile(Tuple{Type{SymbolicGA.KVector{1, 4, D, N} where N where D}, Int64, Vararg{Int64}})
precompile(Tuple{Type{SymbolicGA.KVector{1, 4, D, N} where N where D}, NTuple{4, Int64}})
precompile(Tuple{typeof(Base.convert), Type{NTuple{4, Int64}}, SymbolicGA.KVector{1, Int64, 4, 4}})
precompile(Tuple{typeof(SymbolicGA.parse_arguments), Tuple{Symbol, Expr}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T), Tuple{Symbol, Symbol}}, typeof(SymbolicGA.codegen_expression), Expr, Expr})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Symbol, Nothing}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{2, 1, 0}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{2, 1, 0}, SymbolicGA.ExpressionCache}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{2, 1, 0}, SymbolicGA.ExpressionCache}}, Expr})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Symbol, SymbolicGA.Signature{2, 1, 0}})
precompile(Tuple{typeof(SymbolicGA.nelements), SymbolicGA.Signature{2, 1, 0}, Int64})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{2, 1, 0}, Int64})
precompile(Tuple{typeof(SymbolicGA.define_variables), SymbolicGA.Expression, Bool, Symbol})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, SymbolicGA.Expression, Bool, Symbol, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(Base.Broadcast._broadcast_getindex), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Int64})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, SymbolicGA.ID, Bool, Symbol, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}, Bool})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Symbol}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Any}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Int64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Int64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Symbol, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Array{Any, 1}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Symbol}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.propagate_source), LineNumberNode, Expr})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T), Tuple{Symbol, Symbol}}, typeof(SymbolicGA.codegen_expression), Int64, Expr})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Symbol, Nothing}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{2, 0, 0}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{2, 0, 0}, SymbolicGA.ExpressionCache}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{2, 0, 0}, SymbolicGA.ExpressionCache}}, Expr})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Symbol, SymbolicGA.Signature{2, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.nelements), SymbolicGA.Signature{2, 0, 0}, Int64})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{2, 0, 0}, Int64})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{2, 0, 0}, SymbolicGA.ExpressionCache}}, Int64})
precompile(Tuple{typeof(SymbolicGA.input_expression), SymbolicGA.ExpressionCache, Expr, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:j, :offset, :isscalar), Tuple{Nothing, Nothing, Bool}}, typeof(SymbolicGA.extract_component), SymbolicGA.ExpressionCache, Expr, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{Nothing}}, typeof(SymbolicGA.traverse_indexed), SymbolicGA.var"#91#92"{SymbolicGA.Expression, SymbolicGA.Retraversal{Expr, SymbolicGA.var"#83#85"{SymbolicGA.ExpressionCache, DataType}, SymbolicGA.var"#84#86"{SymbolicGA.ExpressionCache}}, SymbolicGA.var"#173#174"{SymbolicGA.ExpressionCache}}, Expr, Type{Expr}, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{Nothing}}, typeof(SymbolicGA.traverse), SymbolicGA.var"#88#89"{SymbolicGA.Expression, SymbolicGA.Retraversal{Expr, SymbolicGA.var"#83#85"{SymbolicGA.ExpressionCache, DataType}, SymbolicGA.var"#84#86"{SymbolicGA.ExpressionCache}}, SymbolicGA.var"#147#148"{Array{SymbolicGA.Expression, 1}}}, Int64, Type{Expr}})
precompile(Tuple{typeof(SymbolicGA.add_node_uses!), Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Int64}, SymbolicGA.ExecutionGraph, SymbolicGA.ExpressionCache, Int64, Symbol})
precompile(Tuple{typeof(SymbolicGA.add_node_uses!), Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Int64}, SymbolicGA.ExecutionGraph, SymbolicGA.ExpressionCache, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, SymbolicGA.ID, Bool, Symbol, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, Symbol, Bool, Symbol, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Symbol}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, Int64, Bool, Symbol, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Any}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Int64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.parse_arguments), Tuple{Expr}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T), Tuple{Symbol, Nothing}}, typeof(SymbolicGA.codegen_expression), Int64, Expr})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Nothing, Nothing}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{2, 0, 0}, Expr})
precompile(Tuple{typeof(SymbolicGA.define_variables), SymbolicGA.Expression, Bool, Nothing})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, SymbolicGA.Expression, Bool, Nothing, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(Base.Broadcast._broadcast_getindex), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Int64})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, SymbolicGA.ID, Bool, Nothing, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}, Bool})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Symbol}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Any}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Int64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Int64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Symbol, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.reconstructed_type), Nothing, SymbolicGA.Signature{2, 0, 0}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Array{Any, 1}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Symbol}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.parse_arguments), Tuple{Expr, Expr}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T), Tuple{Symbol, Expr}}, typeof(SymbolicGA.codegen_expression), Int64, Expr})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Expr, Nothing}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{2, 0, 0}, Expr})
precompile(Tuple{typeof(SymbolicGA.define_variables), SymbolicGA.Expression, Bool, Expr})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, SymbolicGA.Expression, Bool, Expr, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(Base.Broadcast._broadcast_getindex), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Int64})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, SymbolicGA.ID, Bool, Expr, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}, Bool})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Symbol}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Any}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Int64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Int64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Symbol, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Array{Any, 1}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Symbol}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Expr}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Nothing, Nothing}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{3, 0, 0}, Expr})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Int64, SymbolicGA.Signature{3, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.extract_blade_from_annotation), SymbolicGA.ExpressionCache, Expr})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Expr, SymbolicGA.Signature{3, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.reconstructed_type), Nothing, SymbolicGA.Signature{3, 0, 0}, SymbolicGA.Expression})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#111#114"}, Float64})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#124#126"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}}, Float64})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#112#115"}, Float64})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 0, 0}, SymbolicGA.ExpressionCache}}, Float64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{Nothing}}, typeof(SymbolicGA.traverse), SymbolicGA.var"#88#89"{SymbolicGA.Expression, SymbolicGA.Retraversal{Expr, SymbolicGA.var"#83#85"{SymbolicGA.ExpressionCache, DataType}, SymbolicGA.var"#84#86"{SymbolicGA.ExpressionCache}}, SymbolicGA.var"#147#148"{Array{SymbolicGA.Expression, 1}}}, Float64, Type{Expr}})
precompile(Tuple{typeof(SymbolicGA.add_node_uses!), Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Int64}, SymbolicGA.ExecutionGraph, SymbolicGA.ExpressionCache, Int64, Float64})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, SymbolicGA.ID, Bool, Nothing, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, Float64, Bool, Nothing, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Float64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.parse_arguments), Tuple{QuoteNode, Expr}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Int64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, Type{Expr}, Tuple{Base.RefValue{Symbol}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}}}, Type{Expr}})
precompile(Tuple{typeof(Base.copyto!), Array{Expr, 1}, Base.Broadcast.Broadcasted{Nothing, Tuple{Base.OneTo{Int64}}, Type{Expr}, Tuple{Base.RefValue{Symbol}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}}}})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#120#122"{SymbolicGA.Bindings}}, Float64})
precompile(Tuple{typeof(SymbolicGA.prewalk), SymbolicGA.var"#63#64"{SymbolicGA.Signature{3, 0, 0}, SymbolicGA.ExpressionCache}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Int64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Symbol, Nothing}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{3, 0, 0}, Expr})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.ID}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Float64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Symbol}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Symbol, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#124#126"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}}, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:offset,), Tuple{Int64}}, typeof(SymbolicGA.input_expression), SymbolicGA.ExpressionCache, Symbol, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:j, :offset, :isscalar), Tuple{Nothing, Int64, Bool}}, typeof(SymbolicGA.extract_component), SymbolicGA.ExpressionCache, Symbol, Int64})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.extract_grade_from_annotation), Tuple{Array{Any, 1}, Base.RefValue{SymbolicGA.Signature{3, 0, 0}}}}})
precompile(Tuple{typeof(Base.getindex), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.extract_grade_from_annotation), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Base.RefValue{SymbolicGA.Signature{3, 0, 0}}}}, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.extract_grade_from_annotation), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Base.RefValue{SymbolicGA.Signature{3, 0, 0}}}}, Type{Int64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.extract_grade_from_annotation), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Base.RefValue{SymbolicGA.Signature{3, 0, 0}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:j, :offset, :isscalar), Tuple{Int64, Nothing, Bool}}, typeof(SymbolicGA.extract_component), SymbolicGA.ExpressionCache, Symbol, Int64})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Expr, SymbolicGA.Signature{2, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Int64, SymbolicGA.Signature{2, 0, 0}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:offset,), Tuple{Int64}}, typeof(SymbolicGA.input_expression), SymbolicGA.ExpressionCache, Expr, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:j, :offset, :isscalar), Tuple{Nothing, Int64, Bool}}, typeof(SymbolicGA.extract_component), SymbolicGA.ExpressionCache, Expr, Int64})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, Int64, Bool, Nothing, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Int64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.extract_grade_from_annotation), Tuple{Array{Any, 1}, Base.RefValue{SymbolicGA.Signature{2, 0, 0}}}}})
precompile(Tuple{typeof(Base.getindex), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.extract_grade_from_annotation), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Base.RefValue{SymbolicGA.Signature{2, 0, 0}}}}, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.extract_grade_from_annotation), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Base.RefValue{SymbolicGA.Signature{2, 0, 0}}}}, Type{Int64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.extract_grade_from_annotation), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Base.RefValue{SymbolicGA.Signature{2, 0, 0}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:j, :offset, :isscalar), Tuple{Int64, Nothing, Bool}}, typeof(SymbolicGA.extract_component), SymbolicGA.ExpressionCache, Expr, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{Nothing}}, typeof(SymbolicGA.traverse), SymbolicGA.var"#88#89"{SymbolicGA.Expression, SymbolicGA.Retraversal{Expr, SymbolicGA.var"#83#85"{SymbolicGA.ExpressionCache, DataType}, SymbolicGA.var"#84#86"{SymbolicGA.ExpressionCache}}, SymbolicGA.var"#147#148"{Array{SymbolicGA.Expression, 1}}}, Expr, Type{Expr}})
precompile(Tuple{typeof(SymbolicGA.add_node_uses!), Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Int64}, SymbolicGA.ExecutionGraph, SymbolicGA.ExpressionCache, Int64, Expr})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, Expr, Bool, Nothing, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Expr}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Expr, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.blade), SymbolicGA.ExpressionCache, Base.UnitRange{Int64}})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#120#122"{SymbolicGA.Bindings}}, QuoteNode})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#112#115"}, QuoteNode})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 0, 0}, SymbolicGA.ExpressionCache}}, QuoteNode})
precompile(Tuple{typeof(SymbolicGA.weighted), SymbolicGA.Expression, Expr})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, Symbol, Bool, Nothing, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Symbol}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Any}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Int64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Expr, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Any}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Int64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.argument_count), Expr})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{Nothing}}, typeof(SymbolicGA.traverse), SymbolicGA.var"#131#132", Symbol, Type{Expr}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{Nothing}}, typeof(SymbolicGA.traverse), SymbolicGA.var"#131#132", Expr, Type{Expr}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{Nothing}}, typeof(SymbolicGA.traverse), SymbolicGA.var"#131#132", Int64, Type{Expr}})
precompile(Tuple{typeof(SymbolicGA.fill_argument_slots), Expr, Array{Symbol, 1}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#129#130"{Array{Symbol, 1}, Symbol}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#129#130"{Array{Symbol, 1}, Symbol}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#129#130"{Array{Symbol, 1}, Symbol}}, Int64})
precompile(Tuple{Type{SymbolicGA.Bindings}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), typeof(SymbolicGA.extract_type), Array{Any, 1}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.extract_type), Tuple{Array{Any, 1}}}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.extract_type), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}, Type{Nothing}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Nothing, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.extract_type), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), typeof(SymbolicGA.extract_name), Array{Any, 1}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(SymbolicGA.extract_name), Tuple{Array{Any, 1}}}})
precompile(Tuple{typeof(SymbolicGA.extract_name), Symbol})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.extract_name), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}, Type{Symbol}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.extract_name), Tuple{Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.define_argument_slots), Expr, Array{Symbol, 1}})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#127#128"{Array{Symbol, 1}}}, Symbol})
precompile(Tuple{typeof(SymbolicGA.postwalk), SymbolicGA.var"#120#122"{SymbolicGA.Bindings}, Symbol})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:refs,), Tuple{Base.Dict{Symbol, Any}}}, Type{SymbolicGA.Bindings}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:refs,), Tuple{Base.Dict{Symbol, Expr}}}, Type{SymbolicGA.Bindings}})
precompile(Tuple{typeof(SymbolicGA.default_bindings)})
precompile(Tuple{typeof(SymbolicGA.expand_variables), Expr, SymbolicGA.Signature{4, 1, 0}, SymbolicGA.Bindings})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#127#128"{Array{Symbol, 1}}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#123#125"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}}, Float64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:funcs,), Tuple{Base.Dict{Symbol, Expr}}}, Type{SymbolicGA.Bindings}})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Bool, Array{Test.LogRecord, 1}, SymbolicGA.Bindings}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Bool, Array{Test.LogRecord, 1}, SymbolicGA.Bindings}, Int64, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:funcs, :warn_override), Tuple{Base.Dict{Symbol, Expr}, Bool}}, Type{SymbolicGA.Bindings}})
precompile(Tuple{typeof(SymbolicGA.define_argument_slots), Symbol, Array{Symbol, 1}})
precompile(Tuple{Type{SymbolicGA.ExpressionCache}, SymbolicGA.Signature{1, 1, 1}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:offset,), Tuple{Int64}}, typeof(SymbolicGA.extract_weights), SymbolicGA.ExpressionCache, Symbol, Int64})
precompile(Tuple{typeof(SymbolicGA.nelements), SymbolicGA.Signature{1, 1, 1}, Int64})
precompile(Tuple{typeof(SymbolicGA.extract_expression), Expr, SymbolicGA.Signature{1, 1, 1}, SymbolicGA.Bindings})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{1, 1, 1}, SymbolicGA.ExpressionCache}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{1, 1, 1}, SymbolicGA.ExpressionCache}}, Symbol})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Symbol, SymbolicGA.Signature{1, 1, 1}})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{1, 1, 1}, Int64})
precompile(Tuple{typeof(SymbolicGA.isweighted), SymbolicGA.Expression})
precompile(Tuple{typeof(Base.string), SymbolicGA.Expression})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}, Type{Symbol}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}, Type{Any}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.dereference), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}}}, Int64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.print_scalar), Base.GenericIOBuffer{Array{UInt8, 1}}, Int64})
precompile(Tuple{typeof(SymbolicGA.getcomponent), Tuple{Int64, Int64, Int64}, Int64})
precompile(Tuple{typeof(SymbolicGA.getcomponent), Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{Tuple}, Tuple{Int64, Int64, Int64}})
precompile(Tuple{typeof(SymbolicGA.getcomponent), Tuple{Int64, Int64}, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{Tuple}, Tuple{Int64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{1, 2, D, N} where N where D}, Tuple{Int64, Int64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{2, 2, D, N} where N where D}, Tuple{Int64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{Array{T, 1} where T}, Tuple{Int64, Int64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{Array{T, 1} where T}, Tuple{Int64}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), typeof(Base.collect), Tuple{SymbolicGA.KVector{1, Int64, 2, 2}, SymbolicGA.KVector{2, Int64, 2, 1}}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.Style{Tuple}, Nothing, typeof(Base.collect), Tuple{Tuple{SymbolicGA.KVector{1, Int64, 2, 2}, SymbolicGA.KVector{2, Int64, 2, 1}}}}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{Array{Float64, 1}}, Tuple{Int64, Int64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{Array{Float64, 1}}, Tuple{Int64}})
precompile(Tuple{typeof(SymbolicGA.getcomponent), Tuple{Float64, Float64, Float64}, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{0, 3, D, N} where N where D}, Tuple{Float64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{2, 3, D, N} where N where D}, Tuple{Float64, Float64, Float64}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), typeof(SymbolicGA.grade), Tuple{SymbolicGA.KVector{0, Float64, 3, 1}, SymbolicGA.KVector{2, Float64, 3, 3}}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.Style{Tuple}, Nothing, typeof(SymbolicGA.grade), Tuple{Tuple{SymbolicGA.KVector{0, Float64, 3, 1}, SymbolicGA.KVector{2, Float64, 3, 3}}}}})
precompile(Tuple{typeof(Base.getindex), SymbolicGA.KVector{0, Float64, 3, 1}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{Tuple}, NTuple{4, Int64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{1, 3, D, N} where N where D}, Tuple{Float64, Float64, Float64}})
precompile(Tuple{Type{SymbolicGA.KVector{1, 3, D, N} where N where D}, Tuple{Float64, Float64, Float64}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{1, Float64, 3, 3}, SymbolicGA.KVector{1, Float64, 3, 3}})
precompile(Tuple{Type{SymbolicGA.KVector{2, 3, D, N} where N where D}, Tuple{Float64, Float64, Float64}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{2, Float64, 3, 3}, SymbolicGA.KVector{2, Float64, 3, 3}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{2, 3, D, N} where N where D}, Tuple{Int64, Int64, Int64}})
precompile(Tuple{typeof(SymbolicGA.grade), SymbolicGA.KVector{2, Int64, 3, 3}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{2, Int64, 3, 3}, SymbolicGA.KVector{2, Int64, 3, 3}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{Tuple}, Tuple{Float64, Float64, Float64}})
precompile(Tuple{typeof(SymbolicGA.getcomponent), NTuple{6, Int64}, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{1, 3, D, N} where N where D}, Tuple{Int64, Int64, Int64}})
precompile(Tuple{typeof(SymbolicGA.getcomponent), Tuple{Tuple{Int64, Int64, Int64}, Tuple{Int64, Int64, Int64}}, Int64, Int64})
precompile(Tuple{typeof(Base.:(==)), Tuple{SymbolicGA.KVector{1, Int64, 3, 3}, SymbolicGA.KVector{2, Int64, 3, 3}}, Tuple{SymbolicGA.KVector{1, Int64, 3, 3}, SymbolicGA.KVector{2, Int64, 3, 3}}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{0, 2, D, N} where N where D}, Tuple{Int64}})
precompile(Tuple{typeof(SymbolicGA.getcomponent), Tuple{Tuple{Int64}, Tuple{Int64, Int64}}, Int64, Int64})
precompile(Tuple{Type{SymbolicGA.KVector{0, 2, D, N} where N where D}, Int64})
precompile(Tuple{Type{SymbolicGA.KVector{1, 2, D, N} where N where D}, Int64, Vararg{Int64}})
precompile(Tuple{Type{SymbolicGA.KVector{1, 2, D, N} where N where D}, Tuple{Int64, Int64}})
precompile(Tuple{typeof(Base.:(==)), Tuple{SymbolicGA.KVector{0, Int64, 2, 1}, SymbolicGA.KVector{1, Int64, 2, 2}}, Tuple{SymbolicGA.KVector{0, Int64, 2, 1}, SymbolicGA.KVector{1, Int64, 2, 2}}})
precompile(Tuple{typeof(SymbolicGA.getcomponent), NTuple{8, Int64}, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{0, 3, D, N} where N where D}, Tuple{Int64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{3, 3, D, N} where N where D}, Tuple{Int64}})
precompile(Tuple{typeof(Base.:(==)), Tuple{SymbolicGA.KVector{0, Int64, 3, 1}, SymbolicGA.KVector{1, Int64, 3, 3}, SymbolicGA.KVector{2, Int64, 3, 3}, SymbolicGA.KVector{3, Int64, 3, 1}}, Tuple{SymbolicGA.KVector{0, Int64, 3, 1}, SymbolicGA.KVector{1, Int64, 3, 3}, SymbolicGA.KVector{2, Int64, 3, 3}, SymbolicGA.KVector{3, Int64, 3, 1}}})
precompile(Tuple{Type{SymbolicGA.KVector{1, 3, D, N} where N where D}, Int64, Vararg{Int64}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Nothing, Nothing}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{4, 0, 0}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{4, 0, 0}, SymbolicGA.ExpressionCache}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{4, 0, 0}, SymbolicGA.ExpressionCache}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{4, 0, 0}, SymbolicGA.ExpressionCache}}, Float64})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{4, 0, 0}, Int64})
precompile(Tuple{typeof(SymbolicGA.reconstructed_type), Nothing, SymbolicGA.Signature{4, 0, 0}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Float64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Real}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Real, 1}, Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Int64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Real, 1}, Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Float64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{Type{SymbolicGA.Expression}, SymbolicGA.ExpressionCache, SymbolicGA.Head, SymbolicGA.ID, Vararg{SymbolicGA.ID}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Nothing, SymbolicGA.Bindings}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{3, 0, 0}, Expr})
precompile(Tuple{typeof(Base.:(==)), Tuple{SymbolicGA.KVector{1, Int64, 3, 3}, SymbolicGA.KVector{3, Int64, 3, 1}}, Tuple{SymbolicGA.KVector{1, Int64, 3, 3}, SymbolicGA.KVector{3, Int64, 3, 1}}})
precompile(Tuple{typeof(Base.:(==)), Tuple{SymbolicGA.KVector{0, Int64, 3, 1}, SymbolicGA.KVector{2, Int64, 3, 3}}, Tuple{SymbolicGA.KVector{0, Int64, 3, 1}, SymbolicGA.KVector{2, Int64, 3, 3}}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{1, 4, D, N} where N where D}, Tuple{Float64, Int64, Int64, Int64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{2, 4, D, N} where N where D}, Tuple{Float64, Float64, Float64, Int64, Int64, Int64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{3, 4, D, N} where N where D}, Tuple{Int64, Int64, Int64, Float64}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), typeof(Base.isapprox), Tuple{SymbolicGA.KVector{1, Float64, 4, 4}, SymbolicGA.KVector{2, Float64, 4, 6}, SymbolicGA.KVector{3, Float64, 4, 4}}, Tuple{SymbolicGA.KVector{1, Float64, 4, 4}, SymbolicGA.KVector{2, Float64, 4, 6}, SymbolicGA.KVector{3, Float64, 4, 4}}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.Style{Tuple}, Nothing, typeof(Base.isapprox), Tuple{Tuple{SymbolicGA.KVector{1, Float64, 4, 4}, SymbolicGA.KVector{2, Float64, 4, 6}, SymbolicGA.KVector{3, Float64, 4, 4}}, Tuple{SymbolicGA.KVector{1, Float64, 4, 4}, SymbolicGA.KVector{2, Float64, 4, 6}, SymbolicGA.KVector{3, Float64, 4, 4}}}}})
precompile(Tuple{typeof(Base.isapprox), SymbolicGA.KVector{1, Float64, 4, 4}, SymbolicGA.KVector{1, Float64, 4, 4}})
precompile(Tuple{typeof(Base.isapprox), SymbolicGA.KVector{2, Float64, 4, 6}, SymbolicGA.KVector{2, Float64, 4, 6}})
precompile(Tuple{typeof(Base.isapprox), SymbolicGA.KVector{3, Float64, 4, 4}, SymbolicGA.KVector{3, Float64, 4, 4}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Base.UnitRange{Int64}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Tuple{Base.UnitRange{Int64}}}})
precompile(Tuple{typeof(Base.promote_typejoin_union), Type{SymbolicGA.Signature{_A, 0, 0} where _A}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Tuple{Base.Broadcast.Extruded{Base.UnitRange{Int64}, Tuple{Bool}, Tuple{Int64}}}}, Type{SymbolicGA.Signature{2, 0, 0}}})
precompile(Tuple{typeof(Base.setindex!), Array{SymbolicGA.Signature{2, 0, 0}, 1}, SymbolicGA.Signature{2, 0, 0}, Int64})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{SymbolicGA.Signature{2, 0, 0}, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Tuple{Base.Broadcast.Extruded{Base.UnitRange{Int64}, Tuple{Bool}, Tuple{Int64}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Tuple{Base.Broadcast.Extruded{Base.UnitRange{Int64}, Tuple{Bool}, Tuple{Int64}}}}, Type{SymbolicGA.Signature{_A, 0, 0} where _A}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, Array{SymbolicGA.Signature{2, 0, 0}, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Tuple{Base.Broadcast.Extruded{Base.UnitRange{Int64}, Tuple{Bool}, Tuple{Int64}}}}, SymbolicGA.Signature{3, 0, 0}, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Tuple{Base.Broadcast.Extruded{Base.UnitRange{Int64}, Tuple{Bool}, Tuple{Int64}}}}, Type{SymbolicGA.Signature{6, 0, 0}}})
precompile(Tuple{typeof(Base.setindex!), Array{SymbolicGA.Signature{6, 0, 0}, 1}, SymbolicGA.Signature{6, 0, 0}, Int64})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{SymbolicGA.Signature{6, 0, 0}, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Tuple{Base.Broadcast.Extruded{Base.UnitRange{Int64}, Tuple{Bool}, Tuple{Int64}}}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, Array{SymbolicGA.Signature{6, 0, 0}, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Tuple{Base.Broadcast.Extruded{Base.UnitRange{Int64}, Tuple{Bool}, Tuple{Int64}}}}, SymbolicGA.Signature{7, 0, 0}, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.vcat), Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, SymbolicGA.Signature{3, 0, 1}, SymbolicGA.Signature{4, 1, 0}, Vararg{Any}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:dims,), Tuple{Base.Val{1}}}, typeof(Base.cat), Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, SymbolicGA.Signature{3, 0, 1}, Vararg{Any}})
precompile(Tuple{Base.var"##cat#159", Base.Val{1}, typeof(Base.cat), Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, Vararg{Any}})
precompile(Tuple{typeof(Base._cat), Base.Val{1}, Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, Vararg{Any}})
precompile(Tuple{typeof(Base.promote_eltypeof), Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, SymbolicGA.Signature{3, 0, 1}, Vararg{Any}})
precompile(Tuple{typeof(Base.promote_eltypeof), SymbolicGA.Signature{3, 0, 1}, SymbolicGA.Signature{4, 1, 0}, Vararg{Any}})
precompile(Tuple{typeof(Base.promote_eltypeof), SymbolicGA.Signature{4, 1, 0}, Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}})
precompile(Tuple{typeof(Base.promote_type), Type{SymbolicGA.Signature{3, 0, 1}}, Type{SymbolicGA.Signature{P, N, 0} where N where P}})
precompile(Tuple{typeof(Base.promote_type), Type{SymbolicGA.Signature{_A, 0, 0} where _A}, Type{SymbolicGA.Signature{P, N, D} where D where N where P}})
precompile(Tuple{typeof(Base._cat_t), Base.Val{1}, Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, Vararg{Any}})
precompile(Tuple{typeof(Base.cat_size_shape), Tuple{Bool}, Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, SymbolicGA.Signature{3, 0, 1}, Vararg{Any}})
precompile(Tuple{typeof(Base._cat_size_shape), Tuple{Bool}, Tuple{Int64}, SymbolicGA.Signature{3, 0, 1}, SymbolicGA.Signature{4, 1, 0}, Vararg{Any}})
precompile(Tuple{typeof(Base._cat_size_shape), Tuple{Bool}, Tuple{Int64}, SymbolicGA.Signature{4, 1, 0}, Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}})
precompile(Tuple{typeof(Base.cat_similar), Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, Type{SymbolicGA.Signature{P, N, D} where D where N where P}, Tuple{Int64}})
precompile(Tuple{typeof(Base.__cat), Array{SymbolicGA.Signature{P, N, D} where D where N where P, 1}, Tuple{Int64}, Tuple{Bool}, Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, Vararg{Any}})
precompile(Tuple{typeof(Base.__cat_offset!), Array{SymbolicGA.Signature{P, N, D} where D where N where P, 1}, Tuple{Int64}, Tuple{Bool}, Tuple{Int64}, Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}, SymbolicGA.Signature{3, 0, 1}, Vararg{Any}})
precompile(Tuple{typeof(Base.__cat_offset!), Array{SymbolicGA.Signature{P, N, D} where D where N where P, 1}, Tuple{Int64}, Tuple{Bool}, Tuple{Int64}, SymbolicGA.Signature{3, 0, 1}, SymbolicGA.Signature{4, 1, 0}, Vararg{Any}})
precompile(Tuple{typeof(Base.__cat_offset!), Array{SymbolicGA.Signature{P, N, D} where D where N where P, 1}, Tuple{Int64}, Tuple{Bool}, Tuple{Int64}, SymbolicGA.Signature{4, 1, 0}, Array{SymbolicGA.Signature{_A, 0, 0} where _A, 1}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), Type{SymbolicGA.ExpressionCache}, Array{SymbolicGA.Signature{P, N, D} where D where N where P, 1}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, Type{SymbolicGA.ExpressionCache}, Tuple{Array{SymbolicGA.Signature{P, N, D} where D where N where P, 1}}}})
precompile(Tuple{Type{SymbolicGA.ExpressionCache}, SymbolicGA.Signature{4, 1, 0}})
precompile(Tuple{Type{SymbolicGA.ExpressionCache}, SymbolicGA.Signature{6, 0, 0}})
precompile(Tuple{Type{SymbolicGA.ExpressionCache}, SymbolicGA.Signature{7, 0, 0}})
precompile(Tuple{Type{SymbolicGA.ExpressionCache}, SymbolicGA.Signature{8, 0, 0}})
precompile(Tuple{Type{SymbolicGA.ExpressionCache}, SymbolicGA.Signature{9, 0, 0}})
precompile(Tuple{Type{SymbolicGA.ExpressionCache}, SymbolicGA.Signature{10, 0, 0}})
precompile(Tuple{typeof(Base.iterate), Array{SymbolicGA.ExpressionCache, 1}})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{2, 0, 0}, Int64})
precompile(Tuple{typeof(Base.iterate), Array{SymbolicGA.ExpressionCache, 1}, Int64})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{4, 1, 0}, Int64})
precompile(Tuple{typeof(SymbolicGA.dimension), SymbolicGA.Signature{6, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{6, 0, 0}, Int64})
precompile(Tuple{typeof(SymbolicGA.dimension), SymbolicGA.Signature{7, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{7, 0, 0}, Int64})
precompile(Tuple{typeof(SymbolicGA.dimension), SymbolicGA.Signature{8, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{8, 0, 0}, Int64})
precompile(Tuple{typeof(SymbolicGA.dimension), SymbolicGA.Signature{9, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{9, 0, 0}, Int64})
precompile(Tuple{typeof(SymbolicGA.dimension), SymbolicGA.Signature{10, 0, 0}})
precompile(Tuple{typeof(SymbolicGA.antigrade), SymbolicGA.Signature{10, 0, 0}, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{3, 3, D, N} where N where D}, Tuple{Float64}})
precompile(Tuple{typeof(Base.getindex), SymbolicGA.KVector{3, Float64, 3, 1}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Nothing, SymbolicGA.Bindings}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{3, 0, 1}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 0, 1}, SymbolicGA.ExpressionCache}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 0, 1}, SymbolicGA.ExpressionCache}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 0, 1}, SymbolicGA.ExpressionCache}}, Int64})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Symbol, SymbolicGA.Signature{3, 0, 1}})
precompile(Tuple{typeof(SymbolicGA.nelements), SymbolicGA.Signature{3, 0, 1}, Int64})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{3, 0, 1}, Int64})
precompile(Tuple{typeof(SymbolicGA.reconstructed_type), Nothing, SymbolicGA.Signature{3, 0, 1}, SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.getcomponent), NTuple{4, Int64}, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{2, 4, D, N} where N where D}, NTuple{6, Int64}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{2, Int64, 4, 6}, SymbolicGA.KVector{2, Int64, 4, 6}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{0, 4, D, N} where N where D}, Tuple{Int64}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{0, Int64, 4, 1}, SymbolicGA.KVector{0, Int64, 4, 1}})
precompile(Tuple{typeof(Base.getindex), SymbolicGA.KVector{0, Int64, 3, 1}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{1, 3, D, N} where N where D}, Tuple{Float64, Int64, Int64}})
precompile(Tuple{Type{SymbolicGA.KVector{1, 3, D, N} where N where D}, Float64, Vararg{Float64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{2, 3, D, N} where N where D}, Tuple{Int64, Int64, Float64}})
precompile(Tuple{Type{SymbolicGA.KVector{2, 3, D, N} where N where D}, Float64, Vararg{Float64}})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 0, 1}, SymbolicGA.ExpressionCache}}, Float64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{0, 4, D, N} where N where D}, Tuple{Float64}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{4, 4, D, N} where N where D}, Tuple{Float64}})
precompile(Tuple{typeof(Base.:(==)), Tuple{SymbolicGA.KVector{0, Float64, 4, 1}, SymbolicGA.KVector{4, Float64, 4, 1}}, Tuple{SymbolicGA.KVector{0, Float64, 4, 1}, SymbolicGA.KVector{4, Float64, 4, 1}}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{1, 4, D, N} where N where D}, NTuple{4, Int64}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{1, Int64, 4, 4}, SymbolicGA.KVector{1, Int64, 4, 4}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{1, 4, D, N} where N where D}, Tuple{Int64, Int64, Int64, Float64}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{1, Int64, 4, 4}, SymbolicGA.KVector{1, Float64, 4, 4}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{0, Float64, 4, 1}, SymbolicGA.KVector{0, Int64, 4, 1}})
precompile(Tuple{Type{SymbolicGA.KVector{0, 4, D, N} where N where D}, Float64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{4, 4, D, N} where N where D}, Tuple{Int64}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{4, Float64, 4, 1}, SymbolicGA.KVector{4, Int64, 4, 1}})
precompile(Tuple{Type{SymbolicGA.KVector{4, 4, D, N} where N where D}, Float64})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Float64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{Type{SymbolicGA.Expression}, SymbolicGA.ExpressionCache, SymbolicGA.Head, Expr})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Float64}})
precompile(Tuple{typeof(Base.Broadcast.copyto_nonleaf!), Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Symbol, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Type{Real}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Real, 1}, Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Float64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{1, 4, D, N} where N where D}, Tuple{Float64, Int64, Int64, Float64}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Nothing, SymbolicGA.Bindings}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{3, 0, 1}, Symbol})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{1, Float64, 4, 4}, SymbolicGA.KVector{1, Float64, 4, 4}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:warn_override,), Tuple{Bool}}, typeof(SymbolicGA.parse_bindings), Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#127#128"{Array{Symbol, 1}}}, Int64})
precompile(Tuple{Type{NamedTuple{(:bindings,), T} where T<:Tuple}, Tuple{SymbolicGA.Bindings}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:bindings,), Tuple{SymbolicGA.Bindings}}, typeof(SymbolicGA.codegen_expression), Tuple{Int64, Int64, Int64}, Expr})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:flattening, :T, :bindings), Tuple{Symbol, Nothing, SymbolicGA.Bindings}}, typeof(SymbolicGA.codegen_expression), SymbolicGA.Signature{4, 1, 0}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{4, 1, 0}, SymbolicGA.ExpressionCache}}, Expr})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{4, 1, 0}, SymbolicGA.ExpressionCache}}, Symbol})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{4, 1, 0}, SymbolicGA.ExpressionCache}}, Int64})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{4, 1, 0}, SymbolicGA.ExpressionCache}}, Float64})
precompile(Tuple{typeof(SymbolicGA.extract_grade_from_annotation), Symbol, SymbolicGA.Signature{4, 1, 0}})
precompile(Tuple{typeof(SymbolicGA.input_expression), SymbolicGA.ExpressionCache, Float64, Int64})
precompile(Tuple{typeof(SymbolicGA.nelements), SymbolicGA.Signature{4, 1, 0}, Int64})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:j, :offset, :isscalar), Tuple{Nothing, Nothing, Bool}}, typeof(SymbolicGA.extract_component), SymbolicGA.ExpressionCache, Float64, Int64})
precompile(Tuple{typeof(SymbolicGA.prewalk), SymbolicGA.var"#63#64"{SymbolicGA.Signature{4, 1, 0}, SymbolicGA.ExpressionCache}, SymbolicGA.Expression})
precompile(Tuple{typeof(SymbolicGA.metric), SymbolicGA.Signature{4, 1, 0}, Int64})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.ID, SymbolicGA.ID}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.ID, SymbolicGA.ID, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Union{SymbolicGA.ID, SymbolicGA.Expression}, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}, Bool}}, Float64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.reconstructed_type), Nothing, SymbolicGA.Signature{4, 1, 0}, SymbolicGA.Expression})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Int64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_final_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Symbol, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{0, 5, D, N} where N where D}, Tuple{Float64}})
precompile(Tuple{Type{SymbolicGA.KVector{0, 5, D, N} where N where D}, Tuple{Float64}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{0, Float64, 5, 1}, SymbolicGA.KVector{0, Float64, 5, 1}})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{0, 5, D, N} where N where D}, Tuple{Int64}})
precompile(Tuple{Type{SymbolicGA.KVector{0, 5, D, N} where N where D}, Tuple{Int64}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{0, Int64, 5, 1}, SymbolicGA.KVector{0, Int64, 5, 1}})
precompile(Tuple{typeof(SymbolicGA.getcomponent), Float64})
precompile(Tuple{typeof(Base.all), Function, NTuple{4, SymbolicGA.KVector{1, Float64, 5, 5}}})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), typeof(Base.:(*)), SymbolicGA.KVector{1, Float64, 5, 5}, Int64})
precompile(Tuple{typeof(SymbolicGA.getcomponent), Array{Float64, 1}, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{1, 5, D, N} where N where D}, NTuple{5, Float64}})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{1, Float64, 5, 5}, SymbolicGA.KVector{1, Float64, 5, 5}})
precompile(Tuple{typeof(SymbolicGA.getcomponent), SymbolicGA.KVector{4, Float64, 5, 5}, Int64})
precompile(Tuple{typeof(SymbolicGA.getcomponent), SymbolicGA.KVector{1, Float64, 5, 5}, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{3, 5, D, N} where N where D}, Tuple{Float64, Float64, Float64, Float64, Float64, Int64, Float64, Float64, Int64, Int64}})
precompile(Tuple{typeof(Base.length), SymbolicGA.KVector{3, Float64, 5, 10}})
precompile(Tuple{typeof(Base.getindex), SymbolicGA.KVector{0, Float64, 5, 1}})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#127#128"{Array{Symbol, 1}}}, Float64})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#129#130"{Array{Any, 1}, Symbol}}, Float64})
precompile(Tuple{SymbolicGA.var"#79#80"{SymbolicGA.var"#111#114"}, QuoteNode})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#124#126"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}}, QuoteNode})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#123#125"{Base.Dict{Symbol, Any}, Base.Dict{Symbol, Any}, Base.Set{Symbol}}}, QuoteNode})
precompile(Tuple{SymbolicGA.var"#77#78"{SymbolicGA.var"#113#116"{SymbolicGA.Signature{3, 0, 1}, SymbolicGA.ExpressionCache}}, QuoteNode})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.ID, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.ID}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.ID, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.ID, SymbolicGA.Expression, SymbolicGA.Expression}})
precompile(Tuple{typeof(Core.kwcall), NamedTuple{(:retraversal,), Tuple{Nothing}}, typeof(SymbolicGA.traverse), SymbolicGA.var"#88#89"{SymbolicGA.Expression, SymbolicGA.Retraversal{Expr, SymbolicGA.var"#83#85"{SymbolicGA.ExpressionCache, DataType}, SymbolicGA.var"#84#86"{SymbolicGA.ExpressionCache}}, SymbolicGA.var"#147#148"{Array{SymbolicGA.Expression, 1}}}, QuoteNode, Type{Expr}})
precompile(Tuple{typeof(SymbolicGA.add_node_uses!), Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Int64}, SymbolicGA.ExecutionGraph, SymbolicGA.ExpressionCache, Int64, QuoteNode})
precompile(Tuple{typeof(SymbolicGA.to_expr), SymbolicGA.ExpressionCache, QuoteNode, Bool, Nothing, Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Symbol, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, QuoteNode, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Expr, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Int64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.ID, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.ID, SymbolicGA.ID}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.ID}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.ID, SymbolicGA.Expression}})
precompile(Tuple{typeof(Base.collect), Type{Any}, Tuple{SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.Expression, SymbolicGA.ID}})
precompile(Tuple{typeof(Base.similar), Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Type{Real}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Real, 1}, Array{Float64, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Int64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.getcomponent), SymbolicGA.KVector{1, Int64, 4, 4}, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{3, 4, D, N} where N where D}, NTuple{4, Int64}})
precompile(Tuple{typeof(SymbolicGA.getcomponent), SymbolicGA.KVector{1, Float64, 4, 4}, Int64})
precompile(Tuple{typeof(SymbolicGA.construct), Type{SymbolicGA.KVector{1, 4, D, N} where N where D}, NTuple{4, Float64}})
precompile(Tuple{Type{SymbolicGA.KVector{1, 4, D, N} where N where D}, Float64, Vararg{Any}})
precompile(Tuple{Type{SymbolicGA.KVector{1, 4, D, N} where N where D}, Tuple{Float64, Int64, Int64, Int64}})
precompile(Tuple{typeof(Base.Broadcast.restart_copyto_nonleaf!), Array{Any, 1}, Array{Expr, 1}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(SymbolicGA.to_expr), Tuple{Base.RefValue{SymbolicGA.ExpressionCache}, Base.Broadcast.Extruded{Array{Any, 1}, Tuple{Bool}, Tuple{Int64}}, Bool, Base.RefValue{Nothing}, Base.RefValue{Base.Dict{Union{SymbolicGA.ID, SymbolicGA.Expression}, Symbol}}}}, Float64, Int64, Base.OneTo{Int64}, Int64, Int64})
precompile(Tuple{typeof(SymbolicGA.getcomponent), SymbolicGA.KVector{2, Float64, 3, 3}, Int64})
precompile(Tuple{typeof(Base.Broadcast.broadcasted), typeof(Base.isapprox), Tuple{SymbolicGA.KVector{0, Float64, 3, 1}, SymbolicGA.KVector{2, Float64, 3, 3}}, Tuple{SymbolicGA.KVector{0, Float64, 3, 1}, SymbolicGA.KVector{2, Float64, 3, 3}}})
precompile(Tuple{typeof(Base.Broadcast.materialize), Base.Broadcast.Broadcasted{Base.Broadcast.Style{Tuple}, Nothing, typeof(Base.isapprox), Tuple{Tuple{SymbolicGA.KVector{0, Float64, 3, 1}, SymbolicGA.KVector{2, Float64, 3, 3}}, Tuple{SymbolicGA.KVector{0, Float64, 3, 1}, SymbolicGA.KVector{2, Float64, 3, 3}}}}})
precompile(Tuple{typeof(SymbolicGA.getcomponent), Tuple{SymbolicGA.KVector{0, Float64, 3, 1}, SymbolicGA.KVector{2, Float64, 3, 3}}, Int64, Int64})
precompile(Tuple{Type{SymbolicGA.KVector{0, 3, D, N} where N where D}, Float64})
precompile(Tuple{typeof(Base.:(==)), SymbolicGA.KVector{0, Float64, 3, 1}, SymbolicGA.KVector{0, Float64, 3, 1}})
precompile(Tuple{typeof(Base.isapprox), SymbolicGA.KVector{1, Float64, 3, 3}, SymbolicGA.KVector{1, Float64, 3, 3}})
precompile(Tuple{typeof(Base.show), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Base.Multimedia.MIME{Symbol("text/plain")}, SymbolicGA.KVector{1, Float64, 3, 3}})
precompile(Tuple{typeof(Base.show), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Base.Multimedia.MIME{Symbol("text/plain")}, SymbolicGA.KVector{2, Float64, 3, 3}})
precompile(Tuple{typeof(Base.show), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Base.Multimedia.MIME{Symbol("text/plain")}, SymbolicGA.KVector{4, Float64, 4, 1}})
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 1525 | """
Signature(positive::Int, negative::Int = 0, degenerate::Int = 0)
Signature(str::AbstractString) # Signature("++-𝟎")
Signature of an Euclidean or pseudo-Euclidean space.
This signature encodes a space with a metric such that the first `P` basis vectors square to 1, the following `N` to -1 and the following `D` to 0.
The metric evaluates to zero between two distinct basis vectors.
"""
struct Signature{P,N,D} end
Base.broadcastable(x::Signature) = Ref(x)
Signature(positive::Int, negative::Int = 0, degenerate::Int = 0) = Signature{positive, negative, degenerate}()
Signature(string::AbstractString) = Signature(count.(["+", "-", "𝟎"], Ref(string))...)
positive(::Signature{P}) where {P} = P
negative(::Signature{P,N}) where {P,N} = N
degenerate(::Signature{P,N,D}) where {P,N,D} = D
dimension(::Signature{P,N,D}) where {P,N,D} = P + N + D
is_degenerate(sig::Signature) = degenerate(sig) ≠ 0
triplet(sig::Signature) = (positive(sig), negative(sig), degenerate(sig))
metric(::Signature{P,N,D}, ::Val{I}) where {P,N,D,I} = I <= P ? 1 : I <= P + N ? -1 : 0
metric(::Signature{P,N,D}, i::Integer) where {P,N,D} = i <= P ? 1 : i <= P + N ? -1 : 0
metric(sig::Signature{P,N,D}, i::Val{I}, j::Val{I}) where {P,N,D,I} = metric(sig, i)
metric(::Signature, ::Val{I}, ::Val{J}) where {I,J} = 0
Base.show(io::IO, sig::Signature) = print(io, Signature, "(\"", sig == Signature(0, 0, 0) ? "Ø" : "<" * join(["+", "-", "𝟎"] .^ triplet(sig)) * ">", "\")")
nelements(s::Signature, k::Int) = binomial(dimension(s), k)
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 4172 | """
@geometric_space name sig quote
n = 1.0::e4 + 1.0::e5
n̄ = (-0.5)::e4 + 0.5::e5
... # other definitions
end [warn_override = true]
Generate a macro `@name` which defines a geometric space with signature `sig` along with optional user-provided definitions.
The resulting macro will have two methods:
- `@name ex`, which acts as a standard `@ga sig ex` (but with potential extra definitions).
- `@name T ex` which wraps the result into type `T`, just like `@ga sig T ex` would (see [`@ga`](@ref)).
If definitions are provided as an `Expr`, they will be parsed into [`Bindings`](@ref) and added to the default bindings. If definitions already are [`Bindings`](@ref), they will be used as is.
`warn_override` can be set to false if you purposefully intend to purposefully override some of the default bindings.
"""
macro geometric_space(name::Symbol, sig_ex, definitions = nothing, warn_override = :(warn_override = true))
warn_override = Meta.isexpr(warn_override, :(=), 2) && warn_override.args[1] == :warn_override ? warn_override.args[2]::Bool : throw(ArgumentError("Expected `warn_override = <true|false>` as last argument, got $(repr(warn_override))"))
if isnothing(definitions)
bindings = nothing
else
ex = Core.eval(__module__, definitions)
if isa(ex, Expr)
bindings = merge!(default_bindings(), parse_bindings(ex; warn_override))
elseif isa(ex, Bindings)
bindings = ex
else
throw(ArgumentError("Expected `definitions` argument to be a Julia expression or a `SymbolciGA.Bindings`, got $(typeof(ex))"))
end
end
docstring = """
@$name(T, ex)
@$name(ex)
Macro generated via `SymbolicGA.@geometric_space` with signature `$sig_ex`
"""
if !isnothing(definitions) && Meta.isexpr(ex, :block)
defs = Expr[]
for line in ex.args
isa(line, LineNumberNode) && continue
if Meta.isexpr(line, :(=)) && Meta.isexpr(line.args[1], :call)
call, body = line.args
body = Meta.isexpr(body, :block, 2) && isa(body.args[1], LineNumberNode) ? body.args[2] : body
line = :($call = $body)
push!(defs, line)
end
end
docstring *= " and the following definitions:\n$(join("\n- ```julia\n " .* string.(defs) .* "\n ```"))"
elseif !isnothing(bindings)
docstring *= " and the following bindings: \n\n$bindings"
end
var = Symbol("@$name")
macros = quote
Core.@__doc__ macro $name end
macro $name(T, ex)
ex = codegen_expression($sig_ex, ex; T, bindings = $bindings)
esc(ex)
end
macro $name(ex)
ex = Expr(:macrocall, $var, __source__, nothing, ex)
esc(ex)
end
$with_logger($NullLogger()) do
Core.@doc $docstring * '\n' * repr(Core.@doc $var) $var
end
$var
end
# Adjust `LineNumberNode`s to include the callsite in stacktraces.
for i in (4, 6)
def = macros.args[i]
@assert Meta.isexpr(def, :macro)
body = def.args[2]
@assert Meta.isexpr(body, :block) body
@assert isa(body.args[2], LineNumberNode)
body.args[2] = __source__
end
esc(macros)
end
@geometric_space pga2 (2, 0, 1) quote
embed(x) = x[1]::e1 + x[2]::e2
magnitude2(x) = x ⦿ x
point(x) = embed(x) + 1.0::e3
end
@geometric_space pga3 (3, 0, 1) quote
embed(x) = x[1]::e1 + x[2]::e2 + x[3]::e3
magnitude2(x) = x ⦿ x
point(x) = embed(x) + 1.0::e4
end
"""
3D Conformal Geometric Algebra.
!!! warning
This functionality is experimental and will likely be subject to change in the future.
It is not recommended for use beyond prototyping and playing around.
"""
@geometric_space cga3 (4, 1) quote
n = 1.0::e4 + 1.0::e5
n̄ = (-0.5)::e4 + 0.5::e5
n̅ = n̄ # n\bar !== n\overbar but they display exactly the same.
embed(x) = x[1]::e1 + x[2]::e2 + x[3]::e3
magnitude2(x) = x ⦿ x
point(x) = (embed(x) + (0.5::Scalar ⟑ magnitude2(embed(x))) ⟑ n + n̄)::Vector
weight(X) = -X ⋅ n
unitize(X) = X / weight(X)
radius2(X) = (magnitude2(X) / magnitude2(X ∧ n))::Scalar
center(X) = X ⟑ n ⟑ X
# For spheres `S` defined as vectors, and points `X` defined as vectors as well.
distance(S, X) = unitize(S) ⋅ unitize(X)
end warn_override = false
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 2596 | """
KVector{K,T,D,N}
Geometric `K`-vector with eltype `T` with `N` elements in a geometric algebra of dimension `D`.
The constructors `KVector{K,D}(elements...)` and `KVector{K,D}(elements::NTuple)` will automatically infer `T` from the arguments and `N` from `K` and `D`.
# Examples
```jldoctest
julia> KVector{1,3}(1.0, 2.0, 3.0)
KVector{1, Float64, 3, 3}(1.0, 2.0, 3.0)
julia> KVector{2,3}(1.0, 2.0, 3.0)
Bivector{Float64, 3, 3}(1.0, 2.0, 3.0)
julia> KVector{4,4}(1.0)
Quadvector{Float64, 4, 1}(1.0)
```
"""
struct KVector{K,T,D,N}
elements::NTuple{N,T}
function KVector{K,D}(elements::NTuple{N,T}) where {K,T,D,N}
(0 ≤ K ≤ D) || error("Cannot construct $K-vector in a geometric algebra of dimension $D")
N === binomial(D, K) || error("Expected ", binomial(D, K), " elements, got $N")
new{K,T,D,N}(elements)
end
KVector{K,D}(elements::Tuple) where {K,D} = KVector{K,D}(promote(elements...))
end
KVector{K,D}(xs...) where {K,D} = KVector{K,D}(xs)
const Scalar{T,D} = KVector{0,T,D,1}
"""
Bivector{T,D,N}
Alias for `KVector{2,T,D,N}`
"""
const Bivector{T,D,N} = KVector{2,T,D,N}
"""
Trivector{T,D,N}
Alias for `KVector{3,T,D,N}`
"""
const Trivector{T,D,N} = KVector{3,T,D,N}
"""
Quadvector{T,D,N}
Alias for `KVector{4,T,D,N}`
"""
const Quadvector{T,D,N} = KVector{4,T,D,N}
@forward KVector.elements (Base.iterate, Base.firstindex, Base.lastindex)
function Base.isapprox(x::KVector, y::KVector; atol::Real = 0, rtol::Real = Base.rtoldefault(eltype(x), eltype(y), atol))
nx, ny = sqrt(sum(x.elements .* x.elements)), sqrt(sum(y.elements .* y.elements))
atol = max(atol, rtol * max(nx, ny))
grade(x) == grade(y) && length(x) == length(y) && all(isapprox(xx, yy; atol, rtol) for (xx, yy) in zip(x, y))
end
Base.:(==)(x::KVector, y::KVector) = grade(x) == grade(y) && all(.==(x, y))
Base.getindex(kvec::KVector) = only(kvec.elements)
Base.getindex(kvec::KVector, indices) = kvec.elements[indices]
Base.eltype(::Type{<:KVector{<:Any,T}}) where {T} = T
Base.length(::Type{<:KVector{K,<:Any,D,N}}) where {K,D,N} = N
Base.length(::Type{<:KVector{K,<:Any,D}}) where {K,D} = binomial(D, K)
Base.zero(T::Type{<:KVector{K,<:Any,D}}) where {K,D} = KVector{K,D}(ntuple(_ -> zero(eltype(T)), length(T)))
grade(::Type{<:KVector{K}}) where {K} = K
for f in (:(Base.eltype), :(Base.length), :grade, :(Base.zero))
@eval $f(kvec::KVector) = $f(typeof(kvec))
end
Base.convert(::Type{NTuple{N,T}}, kvec::KVector{<:Any,T,<:Any,N}) where {T,N} = kvec.elements
Base.show(io::IO, kvec::KVector) = print(io, typeof(kvec), '(', join(kvec.elements, ", "), ')')
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 384 | macro forward(ex, fs)
Meta.isexpr(ex, :., 2) || error("Invalid expression $ex, expected <Type>.<prop>")
T, prop = ex.args[1], ex.args[2].value
fs = Meta.isexpr(fs, :tuple) ? fs.args : [fs]
defs = map(fs) do f
esc(:($f(x::$T, args...; kwargs...) = $f(x.$prop, args...; kwargs...)))
end
Expr(:block, defs...)
end
stringc(x) = sprint(show, x; context=:color => true)
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 165 | using Documenter
@testset "Doctests" begin
DocMeta.setdocmeta!(SymbolicGA, :DocTestSetup, quote
using SymbolicGA
end)
doctest(SymbolicGA)
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 5938 | point(A) = @cga3 point(A)
point_pair(A, B) = @cga3 point(A) ∧ point(B)
circle(A, B, C) = @cga3 point(A) ∧ point(B) ∧ point(C)
line(A, B) = @cga3 point(A) ∧ point(B) ∧ n
sphere(A, B, C, D) = @cga3 point(A) ∧ point(B) ∧ point(C) ∧ point(D)
plane(A, B, C) = @cga3 point(A) ∧ point(B) ∧ point(C) ∧ n
circle_radius(X) = sqrt(@cga3(Float64, radius2(X::Trivector)))
sphere_radius(X) = sqrt(@cga3(Float64, radius2(X::Quadvector)))
@testset "3D Conformal Geometric Algebra" begin
isnullvector(X) = isapprox(@cga3(Float64, magnitude2(X::Vector)), 0; atol = 1e-14)
@test (@cga3 n ⋅ n̄) == (@cga3 n̄ ⋅ n) == KVector{0,5}((-1.0,))
@test (@cga3 magnitude2(n ⦿ n)) == (@cga3 magnitude2(n̄ ⦿ n̄)) == KVector{0,5}((0,))
A = sqrt(2) .* (1, 0, 0)
B = sqrt(2) .* (0, 1, 0)
C = sqrt(2) .* (0, 0, 1)
D = sqrt(2) .* (-1, 0, 0)
@test all(isnullvector, point.((A, B, C, D)))
S1 = sphere(A, B, C, D)
𝒜 = point(A)
@test (@cga3 unitize(($(𝒜 .* 2))::Vector)) == 𝒜
O = (0, 0, 0)
C1 = @cga3 center(S1::Quadvector)
@test @cga3(unitize(C1::Vector)) ≈ point(O)
@test length(@cga3 weight(S1::Quadvector)) == 10
@test @cga3(Float64, radius2(S1::Quadvector)) ≈ sphere_radius(S1)^2 ≈ 2.0
end;
struct Camera{T}
optical_center::KVector{1,T,4,4} # ::Vector
image_plane::KVector{3,T,4,4} # ::Trivector
end
Camera(A₁, A₂, A₃, A₄) = Camera(@pga3(point(A₄)), @pga3 point(A₁) ∧ point(A₂) ∧ point(A₃))
project_point(camera::Camera, x) = @pga3 begin
line = camera.optical_center::Vector ∧ point(x)
line ∨ camera.image_plane::Trivector
end
@testset "3D Projective Geometric Algebra" begin
A = @pga3 point((1, 0, 0))
B = @pga3 point((0, 1, 0))
C = @pga3 point((1, 1, 0))
D = @pga3 point((0, 0, 1))
image_plane = @pga3 A::Vector ∧ B::Vector ∧ C::Vector
optical_center = D
camera = Camera(optical_center, image_plane)
p = project_point(camera, (1.2, 1, 0))
@test (@pga3 unitize(p::Vector)) == KVector{1,4}(-1.2, -1, 0, -1)
p = project_point(camera, (1.2, 1, 2))
@test (@pga3 unitize(p::Vector)) == KVector{1,4}(-1.2, -1, 0, 1)
# The above operation is equivalent to an inversion through the optical center, as the original point is exactly at a distance of one focal length.
@test (@pga3 unitize(−D::Vector ⩒ point((1.2, 1, 2)) ⩒ antireverse(D::Vector))) == KVector{1,4}(1.2, 1, 0, -1)
end
count_expr_nodes(ex) = isa(ex, Expr) ? sum(count_expr_nodes, ex.args) : 1
@testset "3D rotations" begin
function rotate_3d(x, a, b, α)
# Define a unit plane for the rotation.
# The unitization ensures we don't need `a` and `b` to be orthogonal nor to be unit vectors.
Π = @ga 3 unitize(a::1 ∧ b::1)
# Define rotation generator.
Ω = @ga 3 exp(-(0.5α)::0 ⟑ Π::2)
# Apply the rotation with the versor product of x by Ω.
@ga 3 x::1 << Ω::(0, 2)
end
a = (1.0, 0.0, 0.0)
b = (0.0, 1.0, 0.0)
x = (1.0, 1.0, 0.0)
α = π / 4
# Define a plane for the rotation.
Π = @ga 3 a::Vector ∧ b::Vector
# Define rotation bivector.
ϕ = @ga 3 α::Scalar ⟑ Π::Bivector
# Define rotation generator.
Ω = @ga 3 exp(-(ϕ::Bivector) / 2::Scalar)
@test grade.(Ω) == (0, 2)
@test all(Ω .≈ @ga 3 $(cos(0.5α))::Scalar - Π::Bivector ⟑ $(sin(0.5α))::Scalar)
@test (@ga 3 Ω::(Scalar, Bivector) ⟑ inverse(Ω::(Scalar, Bivector))) == KVector{0,3}(1.0)
x′ = @ga 3 x::1 << Ω::(0, 2)
@test x′ ≈ KVector{1,3}(0.0, sqrt(2), 0.0)
@test rotate_3d((1.0, 0.0, 0.0), a, b, π/6) ≈ KVector{1,3}(cos(π/6), sin(π/6), 0.0)
@test rotate_3d((1.0, 0.0, 0.0), a, b, π/3) ≈ KVector{1,3}(cos(π/3), sin(π/3), 0.0)
@test rotate_3d((2.0, 0.0, 0.0), a, b, π/3) ≈ KVector{1,3}(2cos(π/3), 2sin(π/3), 0.0)
@test rotate_3d((2.0, 0.0, 0.0), a, 2 .* b, π/3) ≈ rotate_3d((2.0, 0.0, 0.0), a, b, π/3)
@test rotate_3d((2.0, 0.0, 0.0), a, (1/sqrt(2), 1/sqrt(2), 0.0), π/3) ≈ rotate_3d((2.0, 0.0, 0.0), a, b, π/3)
@test rotate_3d((2.0, 0.0, 0.0), a, (1.0, 1.0, 0.0), π/3) ≈ rotate_3d((2.0, 0.0, 0.0), a, b, π/3)
# Do it more succinctly.
ex = @macroexpand @ga 3 begin
Π = a::1 ⟑ b::1
Ω = exp((-(0.5α)::0) ⟑ Π)
end;
@test_broken count_expr_nodes(ex) < 1000
@test_skip begin
x′′ = @ga 3 begin
# Define unit plane for the rotation.
Π = a::1 ⟑ b::1
# Define rotation generator.
Ω = exp((-(0.5α)::0) ⟑ Π)
# Apply the rotation by sandwiching x with Ω.
Ω ⟑ x::1 ⟑ reverse(Ω)
end
x′′ === x′
end
end;
@testset "Oriented 3D CGA" begin
@testset "Inclusion of a point in a line segment" begin
A = rand(3)
B = rand(3)
L = @cga3 point(A) ∧ point(B) ∧ n
P = A .+ 0.5 .* (B .- A)
function line_tests(P)
t₁ = @cga3 begin
L = point(A) ∧ point(B) ∧ n
(point(A) ∧ point(P) ∧ n) ⟑ L
end
t₂ = @cga3 begin
L = point(A) ∧ point(B) ∧ n
(point(P) ∧ point(B) ∧ n) ⟑ L
end
(t₁, t₂)
end
PRECISION = 1e-15
is_zero(x, y) = isapprox(x, y; atol = PRECISION)
is_positive(x::Number) = x ≥ -PRECISION
is_zero_bivector(x) = is_zero(x, zero(KVector{2,Float64,5}))
is_on_line((t₁, t₂)) = is_zero_bivector(t₁[2]) && is_zero_bivector(t₂[2])
is_within_segment((t₁, t₂)) = is_positive(t₁[1][]) && is_positive(t₂[1][])
ret = line_tests(A)
t₁, t₂ = ret
@test is_on_line(ret)
@test is_within_segment(ret)
@test isapprox(t₁[1][], 0.0; atol = 1e-15) && t₂[1][] ≥ -1e-15
ret = line_tests(B)
t₁, t₂ = ret
@test is_on_line(ret)
@test is_within_segment(ret)
@test t₁[1][] ≥ -1e-15 && isapprox(t₂[1][], 0.0; atol = 1e-15)
ret = line_tests(A .+ 0.5 .* (B .- A))
@test is_on_line(ret)
@test is_within_segment(ret)
ret = line_tests(A .+ -0.1 .* (B .- A))
@test is_on_line(ret)
@test !is_within_segment(ret)
ret = line_tests(A .+ 1.1 .* (B .- A))
@test is_on_line(ret)
@test !is_within_segment(ret)
ret = line_tests((100.0, 100.0, 100.0))
@test !is_on_line(ret)
@test !is_within_segment(ret)
end
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 7623 | using SymbolicGA: infer_grade, project!, dereference
sig = Signature(3, 1)
cache = ExpressionCache(sig)
sc(x) = scalar(cache, x)
fac(x) = factor(cache, x)
bl(args...) = blade(cache, args...)
x, y, z = sc.([:x, :y, :z])
e1, e2, e3, e4 = blade.(cache, [1, 2, 3, 4])
@testset "Expressions" begin
@testset "Expression basics" begin
@test isexpr(fac(0), FACTOR, 1)
@test !isexpr(bl(1, 2), BLADE, 1)
@test isexpr(bl(1, 2), BLADE, 2)
@test isexpr(bl(1, 2), (FACTOR, BLADE))
ex = bl(1, 2)
ex2 = postwalk(x -> isa(dereference(cache, x), Int) ? dereference(cache, x) + 1 : x, ex)
@test ex2 == bl(2, 3)
x1 = factor(cache, Expression(cache, COMPONENT, :x, 1))
@test isexpr(x1 ⟑ e1, GEOMETRIC_PRODUCT, 2)
end
@testset "Expression caching" begin
_cache = ExpressionCache(sig)
@test scalar(_cache, :x) === scalar(_cache, :x)
x1, x2, x3 = factor.(_cache, Expression.(_cache, COMPONENT, :x, 1:3))
e1, e2, e3 = blade.(_cache, [1, 2, 3])
@test x1 ⟑ e1 + x2 ⟑ e2 + x3 ⟑ e3 === x1 ⟑ e1 + x2 ⟑ e2 + x3 ⟑ e3
end
@testset "Grade inference" begin
@test infer_grade(cache, FACTOR, 0) == 0
@test infer_grade(cache, BLADE, [1, 2, 3]) == 3
@test infer_grade(cache, BLADE, [1, 2, 3, 3]) == 2
@test infer_grade(cache, BLADE, [1, 2, 3, 3, 3]) == 3
@test infer_grade(cache, BLADE, [1, 1, 2, 2, 3, 3, 3]) == 1
@test infer_grade(cache, BLADE, [1, 2, 3, 1, 2, 4, 1, 2]) == 4
@test infer_grade(cache, KVECTOR, [bl(1, 2), bl(2, 3)]) == 2
@test infer_grade(cache, MULTIVECTOR, [bl(1, 2), bl(2, 3)]) == 2
@test infer_grade(cache, MULTIVECTOR, [kvector(bl(1, 2), bl(2, 3)), kvector(bl(1))]) == [1, 2]
_cache = ExpressionCache(Signature(3))
ex = blade(_cache, 1, 2)
@test grade(ex) == 2
@test antigrade(ex) == 1
ex = blade(_cache, 1, 2) + blade(_cache, 1)
@test grade(ex) == [1, 2]
@test antigrade(ex) == [2, 1]
end
@testset "Blades and metric simplifications" begin
ex = bl(1, 1)
@test ex.grade == 0
@test ex == sc(1)
ex = bl(1, 2, 3, 1)
@test ex.grade == 2
@test ex == bl(2, 3)
ex = bl(4, 4)
@test ex.grade == 0
@test ex == sc(-1)
ex = bl(1, 2, 1)
@test ex.grade == 1
@test ex == weighted(bl(2), -1)
@test bl(1) * bl(2) == bl(1, 2)
@test bl(1, 2) * bl(3) == bl(1, 2, 3)
end
@testset "Simplification of null elements in addition" begin
@test fac(1) + fac(0) == fac(1)
@test bl(1) + fac(0) == bl(1)
end
@testset "Disassociation of products and sums" begin
@test fac(1) * (fac(:x) * fac(:y)) == fac(:x) * fac(:y)
@test fac(:z) * (fac(:x) * fac(:y)) == fac(:z) * fac(:x) * fac(:y)
@test fac(1) + (fac(:x) + fac(:y)) == fac(:x) + fac(:y) + fac(1)
@test fac(1) + (fac(2) + fac(0)) == fac(3)
end
@testset "Distribution of products" begin
@test (bl(1) + bl(3)) * (bl(2) + bl(4)) == bl(1, 2) + bl(1, 4) + bl(3, 2) + bl(3, 4)
@test (fac(:x) + bl(1)) * (fac(:y) + bl(4)) == fac(:x) * fac(:y) + fac(:x) * bl(4) + bl(1) * fac(:y) + bl(1, 4)
@test (fac(:x) + fac(:y)) * bl(1, 2) == (fac(:x) + fac(:y)) ⟑ bl(1, 2)
end
@testset "Simplification and canonicalization of factors" begin
@test bl(1, 2) * fac(3) == fac(3) ⟑ bl(1, 2)
@test bl(1, 2) * fac(3) * fac(5) == fac(15) ⟑ bl(1, 2)
@test bl(1, 2) * fac(:x) * fac(:(y[1])) == fac(:x) * fac(:(y[1])) ⟑ bl(1, 2)
@test fac(1) * bl(1, 2) * fac(3) == fac(3) ⟑ bl(1, 2)
# @test bl(1, 2) * fac(0) == Expression(GEOMETRIC_PRODUCT, fac(0), bl(1, 2); simplify = false)
@test bl(1, 2) * fac(0) == fac(0)
@test fac(-1) * fac(-1) == fac(1)
@test fac(-1) * fac(-1) * bl(1, 2) == bl(1, 2)
@testset "Simplification of additive factors" begin
@test fac(2) + fac(3) == fac(5)
@test fac(:x) + fac(3) + fac(:y) + fac(2) == fac(:x) + fac(:y) + fac(5)
@test Expression(cache, SCALAR_PRODUCT, 2, 0.5, 1) == fac(1.0)
@test Expression(cache, SCALAR_ADDITION, 2, 0.5, 1) == fac(3.5)
@test x - x == fac(0)
@test x + x == 2x
@test x + x - 2x == fac(0)
@test x * y - x * y == fac(0)
@test x * y + x * y ≠ fac(0)
@test x - 2x == -x
x1 = sc(Expression(cache, COMPONENT, :x, 1))
@test x1 + x1 == 2x1
x2 = sc(Expression(cache, COMPONENT, :x, 2))
@test x1 * x2 - x2 * x1 == sc(0)
ex = x1 * x2 + x2 * x1
@test isexpr(ex[1], FACTOR) && isexpr(ex[1][1], SCALAR_PRODUCT) && Set(dereference.(cache, ex[1][1].args)) == Set([2, x1[1][1], x2[1][1]])
@test x1 * x2 + x2 * x1 - 2 * x1 * x2 == sc(0)
end
end
@testset "Blade grouping over addition" begin
x_e13 = bl(1, 3) * x
ex = x_e13 + x_e13
@test ex == bl(1, 3) * 2x
ex = e1 * x + bl(2, 3) * y + bl(1) * z
@test ex == e1 * (x + z) + bl(2, 3) * y
end
@testset "Projections" begin
@test project!(fac(:x), 1) == fac(0)
@test project!(fac(:x), 0) == fac(:x)
@test project!(bl(1, 2), 1) == fac(0)
@test project!(bl(1, 2) + bl(1), 1) == bl(1)
@test project!(bl(1) + bl(1, 2) + bl(1, 2, 3), 2) == bl(1, 2)
end
@testset "Reversions" begin
@test reverse(bl(1, 2)) == bl(2, 1)
@test reverse(fac(:x) * bl(1, 2)) == fac(:x) * bl(2, 1)
@test reverse(bl(1, 2, 3) + bl(2) + bl(2, 3)) == bl(3, 2, 1) + bl(2) + bl(3, 2)
@test antireverse(bl(1, 2)) == bl(2, 1)
@test antireverse(fac(:x) * bl(1, 2)) == fac(:x) * bl(2, 1)
@test antireverse(bl(1, 2, 3) + bl(2) + bl(2, 3)) == bl(1, 2, 3) - bl(2) + bl(3, 2)
_cache = ExpressionCache(Signature(3, 0, 1))
@test antireverse(weighted(blade(_cache, 4), 1)) == antireverse(blade(_cache, 4)) == -blade(_cache, 4)
end
@testset "Exterior products" begin
x = bl(1, 2)
y = bl(3)
@test exterior_product(bl(1, 2), bl(3)) == bl(1, 2, 3)
@test exterior_product(bl(1, 2), bl(2)) == fac(0)
end
@testset "Common operators" begin
@test Expression(cache, INTERIOR_PRODUCT, bl(1), bl(1, 2)) == bl(2)
@test Expression(cache, COMMUTATOR_PRODUCT, bl(1), bl(2)) == weighted(bl(1, 2), 1.0)
@test Expression(cache, EXTERIOR_PRODUCT, bl(1), bl(2)) == bl(1, 2)
end
@testset "Inversion" begin
@test Expression(cache, INVERSE, fac(2.0)) == fac(0.5)
@test Expression(cache, INVERSE, sc(2.0)) == sc(0.5)
@test Expression(cache, INVERSE, bl(1, 2)) == weighted(bl(1, 2), -1)
@test Expression(cache, INVERSE, weighted(bl(1, 2), 5.0)) == weighted(bl(1, 2), -0.2)
versor = Expression(cache, ADDITION, sc(2.0), weighted(bl(1, 2), 5.0))
@test Expression(cache, GEOMETRIC_PRODUCT, versor, Expression(cache, INVERSE, versor)) == sc(1.0)
mv = Expression(cache, ADDITION, sc(2.0), weighted(bl(3), 1.2), weighted(bl(1, 2), 5.0))
@test_throws "only supported for versors" Expression(cache, GEOMETRIC_PRODUCT, mv, Expression(cache, INVERSE, mv)) == sc(1.0)
end
@testset "Exponentiation" begin
_cache = ExpressionCache(Signature(3, 0, 1))
b = blade(_cache, 1, 2, 4)
ex = Expression(_cache, EXPONENTIAL, b)
@test ex == Expression(_cache, ADDITION, scalar(_cache, 1), b)
_cache = ExpressionCache(Signature(3))
for α in (1, 3.2)
b = weighted(blade(_cache, 1, 2), α)
ex = Expression(_cache, EXPONENTIAL, b)
@test grade(ex) == [0, 2]
@test ex == scalar(_cache, cos(α)) + scalar(_cache, sin(α) / α) ⟑ b
end
end
@testset "Printing" begin
ex = sc(:x) + sc(:y) + bl(1, 2)
@test sprint(show1, ex) isa String && sprint(show, ex) isa String
ex = Expression(cache, SCALAR_ADDITION, :x, Expression(cache, SCALAR_PRODUCT, :y, :z))
@test sprint(show1, ex) isa String && sprint(show, ex) isa String
end
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 1808 | sig = Signature(3, 1)
cache = ExpressionCache(sig)
sc(x) = scalar(cache, x)
fac(x) = factor(cache, x)
bl(args...) = blade(cache, args...)
x, y, z = sc.([:x, :y, :z])
e1, e2, e3, e4 = blade.(cache, [1, 2, 3, 4])
expression(head, args...) = Expression(cache, head, args...)
add(x, ys...) = expression(SCALAR_ADDITION, x, ys...)
mul(x, ys...) = expression(SCALAR_PRODUCT, x, ys...)
uadd(x, ys...) = unsimplified_expression(cache, SCALAR_ADDITION, x, ys...)
umul(x, ys...) = unsimplified_expression(cache, SCALAR_PRODUCT, x, ys...)
@testset "Factorization" begin
a, b, c, d, e, f = (:a, :b, :c, :d, :e, :f)
ex = add(mul(a, b), mul(a, c))
fact = Factorization(ex)
@test apply!(fact) ≈ umul(a, uadd(b, c))
ex = add(mul(a, c), mul(a, d), mul(b, c), mul(b, d), e)
@test factorize(ex) ≈ uadd(umul(add(a, b), add(c, d)), e)
ex = add(mul(a, c, e), mul(a, c, f), mul(a, d, e), mul(a, d, f), mul(b, c, e), mul(b, c, f), mul(b, d, e), mul(b, d, f))
@test factorize(ex) ≈ umul(add(a, b), add(c, d), add(e, f))
ex2 = fac(ex)
factorize!(ex2)
@test factorize(ex) ≈ ex2[1]
ex = add(mul(a, b, c), mul(c, d, e), mul(a, d, f))
@test factorize(ex) in (
uadd(umul(a, add(mul(b, c), mul(d, f))), mul(c, d, e)),
uadd(umul(c, uadd(mul(a, b), mul(d, e))), mul(a, d, f)),
uadd(umul(d, add(mul(c, e), mul(a, f))), mul(a, b, c)),
)
ex, _ = generate_expression(Signature(3), quote
Π = a::Vector ⟑ b::Vector
Ω = exp((-(0.5α)::Scalar) ⟑ Π)
end; factorize = false, optimize = false)
factorize!(ex)
ex, _ = generate_expression(Signature(3), :((x::Vector ⟑ x::Bivector ∧ x::Vector + 2::e12)::Multivector); factorize = false, optimize = false)
@test all(>(1) ∘ length, gather_scalar_expressions(ex))
factorize!(ex)
@test all(>(1) ∘ length, gather_scalar_expressions(ex))
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 7235 | using SymbolicGA: extract_weights, input_expression, extract_expression, restructure, expand_variables, argument_count, fill_argument_slots, UnknownFunctionError
@testset "Macro frontend" begin
@testset "Function definition" begin
f = :($(@arg(1)) + $(@arg(2)))
@test argument_count(f) == 2
@test_throws "Not enough function arguments" fill_argument_slots(f, [:x], :f)
@test fill_argument_slots(f, [:x, :y], :f) == :(x + y)
end
@testset "Function and variable expansion" begin
sig = Signature(3)
# Recursive reference.
ex = quote
x = x::Vector
x ⟑ x
end
@test expand_variables(ex, Bindings()) == :(x::Vector ⟑ x::Vector)
# Interleaved references/function calls.
ex = quote
b1 = 1::e1
g(z) = z + b1
y = (1, 2, 3)
x = g(y::Vector)
x
end
ex2 = expand_variables(ex, Bindings())
@test ex2 == :((1, 2, 3)::Vector + 1::e1)
bindings = Bindings(refs = Dict(
:x => 2.4,
:z => :(x::e),
))
ex = :(z ⦿ z)
ex2 = expand_variables(ex, bindings)
@test ex2 == :(2.4::e ⦿ 2.4::e)
bindings = Bindings(refs = Dict(
:A => :((1, 2, 3)::Vector),
:B => :((10, 2, 30)::Vector),
:C => :((10, 200, 30)::Vector),
:A̅ => :(right_complement(A)),
:B̅ => :(right_complement(B)),
:A̲ => :(left_complement(A)),
:B̲ => :(left_complement(B)),
))
ex = :(A̅ ∧ B̅)
ex2 = expand_variables(ex, merge!(default_bindings(), bindings))
@test ex2 == :(exterior_product(right_complement((1, 2, 3)::Vector), right_complement((10, 2, 30)::Vector)))
sig = Signature(4, 1, 0)
ex = quote
n = 1.0::e4 + 1.0::e5
magnitude2(x) = x ⦿ x
weight(X) = (-X ⋅ n)::Scalar
normalize(X) = X / weight(X)
radius2(X) = (magnitude2(X) / magnitude2(X ∧ n))::Scalar
radius(X) = normalize(radius2(X))::Scalar
radius(S::Quadvector)
end
ex2 = expand_variables(ex, default_bindings(; warn_override = false))
symbols = expression_nodes(ex -> in(ex, (:radius, :radius2, :normalize, :weight, :magnitude2, :n)), ex2, Expr)
@test isempty(symbols)
@testset "Redefinition warnings" begin
bindings = Bindings(funcs = Dict(
:geometric_antiproduct => :(0::e),
))
@test_logs (:warn, r"Redefinition of function") merge!(default_bindings(), bindings)
bindings = Bindings(refs = Dict(
:𝟏 => :(1::e̅),
))
@test_logs (:warn, r"Redefinition of variable") merge!(default_bindings(), bindings)
bindings = Bindings(funcs = Dict(
:geometric_antiproduct => :(0::e),
); warn_override = false)
@test_logs merge!(default_bindings(), bindings)
ex = quote
f(x) = x
f(x, y) = x + y
f(1::e, 2::e1)
end
@test_logs (:warn, r"user-defined function") expand_variables(ex, Bindings())
ex = quote
x = 3
x = 4
x::Scalar
end
@test_logs (:warn, r"user-defined variable") expand_variables(ex, Bindings())
end
end
sig = Signature(1, 1, 1)
cache = ExpressionCache(sig)
ws = extract_weights(cache, :x, 1; offset = 0)
@test length(ws) == 3
@test all(isexpr(w, COMPONENT) && length(w) == 2 && dereference(cache, w[2]) == i for (i, w) in enumerate(ws))
ex = input_expression(cache, :x, 2)
@test isexpr(ex, ADDITION, 3)
@test ex[1] == factor(cache, first(ws)) * blade(cache, 1, 2)
ex, _ = extract_expression(:((x::Vector ⟑ y::Bivector)::Trivector), sig, default_bindings())
ex2 = restructure(ex)
@test isexpr(ex2, KVECTOR, 1)
@test isweighted(ex2[1]) && isexpr(ex2[1][2], BLADE)
@test isa(string(ex2), String)
ex = @macroexpand @ga (2, 1) Tuple x::Vector ∧ y::Vector + x::Vector ⟑ z::Antiscalar
@test isa(ex, Expr)
x = (1, 2, 3)
y = (4, 5, 6)
z = 3
# Yields 1 bivector.
res = @ga (2, 1) Tuple x::Vector ∧ y::Vector + x::Vector ⟑ z::Antiscalar
@test isa(res, NTuple{3,Int})
x = (1, 2)
y = (0, 50)
res = @ga 2 Tuple x::Vector ∧ y::Vector + x[1]::Scalar ⟑ z::Antiscalar
@test res == (1 * 50 + 1 * 3,)
# Yields 1 vector and 1 antiscalar.
res = @ga 2 x::Vector ∧ y::Vector + x::Vector ⟑ z::Antiscalar
@test isa(res, Tuple{<:KVector{1}, <:KVector{2}})
res2 = @ga 2 Vector x::Vector ∧ y::Vector + x::Vector ⟑ z::Antiscalar
@test collect.(res) == res2 && all(isa(x, Vector{Int}) for x in res2)
res3 = @ga 2 Vector{Float64} x::Vector ∧ y::Vector + x::Vector ⟑ z::Antiscalar
@test res2 == res3 && all(isa(x, Vector{Float64}) for x in res3)
x = (1.0, 2.0, 3.0)
y = (50.0, 70.0, 70.0)
# Yields 1 scalar and 1 bivector.
res = @ga 3 x::1 ⟑ y::1
@test grade.(res) == (0, 2)
@test res[1][] == sum(x .* y)
res = @ga 3 begin
x::Vector
x ⟑ x
end
@test grade(res) == 0
res2 = @ga 3 begin
x = (1.0, 2.0, 3.0)::Vector
x ⟑ x
end
@test res === res2
# The `1::e12` gets simplified to `e12`.
res = @ga 3 (1::e1 ⟑ 1::e1 + 1::e12)::(0 + 1 + 2)
@test res == (1, 1, 0, 0)
# Preserve element types.
res = @ga 3 (1::e1 ⟑ 1::e1 + 1.0::e12)::(0 + 1 + 2)
@test res == (1, 1.0, 0, 0)
res = @ga 3 (1::e1 ⟑ 1::e1 + 2::e12)::(0 + 1 + 2)
@test res == (1, 2, 0, 0)
res = @ga 3 ((x::Vector)')
@test res == KVector{1,3}(x)
res = @ga 3 ((x::Bivector)')
@test res == KVector{2,3}((-).(x))
x = (1, 2, 3)
res = (@ga 3 (x::Vector ⟑ x::Bivector ∧ x::Vector + 2::e12)::Multivector)
@test grade(res) == 2
@test (@ga 3 right_complement(1::e2)) == (@ga 3 1::e31)
y = (101, 102, 103)
@test (@ga 3 Tuple (x::1 × y::1)::2) == (@ga 3 Tuple (x::1 ∧ y::1))
z = (x..., y...)
z_nested = (x, y)
@test (@ga 3 𝟏 ∧ z::(1 + 2)) == (@ga 3 𝟏 ∧ z_nested::(1, 2)) == (@ga 3 𝟏 ∧ (x::1 + y::2))
@test (@ga 2 ((1, 2, 3)::(0 + 1))::(0, 1)) == (@ga 2 ((1,), (2, 3))::(0, 1)) == (KVector{0,2}(1), KVector{1,2}(2, 3))
z2 = (3, z..., 2)
@test (@ga 3 𝟏 ∧ z2::Multivector) == (@ga 3 𝟏 ∧ (3::e + x::1 + y::2 + 2::e̅))
@test_throws "Unknown grade projection" @eval @ga 3 x::Unknown
# Ability to interpolate parts of expressions to shield them from processing.
@test (@ga 3 $(x[1] * x[2])::e1) == KVector{1,3}(x[1] * x[2], 0, 0)
@testset "Basis blade annotations with multiple digits" begin
x = @ga 12 (1.0::e_1_2_7_8)::4
@test length(x) == binomial(12, 4)
@test count(!iszero, x) == 1
x = @ga 12 (1.0::e_12_11)::2
@test length(x) == binomial(12, 2)
@test count(!iszero, x) == 1
end
@test_throws "non-built-in" @eval @ga 3 atan(2)::0
@test_throws "non-built-in" @eval @ga 3 sqrt(2)::0
@test_throws "not performing any operations related to geometric algebra" @eval @ga 3 x
@test (@ga 3 Float64 1::0 + $(atan(2))::0) == 1 + atan(2)
@testset "Binarizing comparison expressions" begin
a, b, c, d = rand(2), rand(2), rand(2), rand(2)
@test (@ga 2 a::1 ⊢ b::1 ⊢ c::1) isa KVector
@test (@ga 2 a::1 ⊢ b::1 ⊢ c::1 ⊢ d::1) isa KVector
@test (@ga 2 a::1 ⊣ (a::1 ∧ b::1) ⊢ c::1 ⊣ d::1) isa KVector
end
@testset "Flattening" begin
a, b, c, d = rand(3), rand(3), rand(3), rand(3)
ex = @ga 3 (a::1 ⟑ b::1)::(0 + 2)
@test isa(ex, NTuple{4,Float64})
ex = @ga 3 NTuple{4,Float32} (a::1 ⟑ b::1)::(0 + 2)
@test isa(ex, NTuple{4,Float32})
end
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 4884 | using SymbolicGA: postwalk, traverse, blade_left_complement, blade_right_complement, dimension
using Combinatorics: combinations
all_blades(cache::ExpressionCache) = [blade(cache, indices) for indices in combinations(1:dimension(cache.sig))]
function ga_eval(sig_ex, ex; T = nothing, bindings = nothing)
bindings = merge!(default_bindings(), something(bindings, Bindings()))
eval(codegen_expression(sig_ex, ex; T, bindings))
end
@testset "Operators" begin
sig = 3
bindings = Bindings(refs = Dict(:A => :((1, 2, 3)::Vector), :B => :((10, 2, 30)::Vector), :C => :((10, 200, 3)::Vector)))
generate = ex -> ga_eval(sig, ex; bindings)
@testset "Associativity" begin
@test generate(:(A + (B + C))) == generate(:((A + B) + C))
@test generate(:(A ⟑ (B ⟑ C))) == generate(:((A ⟑ B) ⟑ C))
end
@testset "Distributivity" begin
@test generate(:(A ⟑ (B + C))) == generate(:(A ⟑ B + A ⟑ C))
@test generate(:(A ∧ (B + C))) == generate(:(A ∧ (B + C)))
end
@testset "Jacobi identity" begin
lhs = @ga 4 begin
A = 1.3::e1 + 2.7::e12
B = 0.7::e3 + 1.1::e123 + 3.05::e
C = 0.7::e4 + 0.1::e2 + 1.59::e23 + 1.1::e124 + 3.05::e1234
A × (B × C)
end
rhs = @ga 4 begin
A = 1.3::e1 + 2.7::e12
B = 0.7::e3 + 1.1::e123 + 3.05::e
C = 0.7::e4 + 0.1::e2 + 1.59::e23 + 1.1::e124 + 3.05::e1234
-(B × (C × A) + C × (A × B))
end
@test all(lhs .≈ rhs)
end
@testset "Complements" begin
for cache in ExpressionCache.([Signature.(2:3); Signature(3, 0, 1); Signature(4, 1); Signature.(6:10)])
@test all(all_blades(cache)) do b
(b ∧ blade_right_complement(b) == antiscalar(cache)) &
(blade_left_complement(b) ∧ b == antiscalar(cache))
end
end
end
@testset "Exterior (anti)product" begin
@test (@ga 3 Float64 3.0::e ∧ 4.0::e) == 12.0
@test (@ga 3 Float64 3.0::e̅ ∨ 4.0::e̅) == 12.0
@testset "De Morgan laws" begin
sig = (3, 0, 1)
bindings = Bindings(refs = Dict(
:A => :((1, 2, 3, 4)::Vector),
:B => :((10, 2, 30, 4)::Vector),
:C => :((10, 200, 30, 400)::Vector),
:A̅ => :(right_complement(A)),
:B̅ => :(right_complement(B)),
:A̲ => :(left_complement(A)),
:B̲ => :(left_complement(B)),
))
generate = ex -> ga_eval(sig, ex; bindings)
@test generate(:(right_complement(A ∧ B))) == generate(:(A̅ ∨ B̅))
@test generate(:(right_complement(A ∨ B))) == generate(:(A̅ ∧ B̅))
@test generate(:(left_complement(A ∧ B))) == generate(:(A̲ ∨ B̲))
@test generate(:(left_complement(A ∨ B))) == generate(:(A̲ ∧ B̲))
end
end
@testset "Interior (anti)product" begin
@test (@ga 3 Float64 ●(3.0::e, 1.0::e1)) == 0.
@test (@ga 3 Float64 ●(3.0::e̅, (2.0::e̅)')) == 6.0
@test (@ga 3 ●(3.0::e12, 2.0::e2)) == KVector{1,3}(6., 0., 0.)
@test (@ga 3 Float64 ●(($(√2)::e1 + $(√2)::e2), ($(√2)::e1 + $(√2)::e2)')) ≈ 4.0
@test (@ga 3 Float64 ●(($(sqrt(2))::e1 + $(√2)::e2), ($(√2)::e1 + $(√2)::e2)')) ≈ 4.0
@test (@ga 3 Float64 ○(3.0::e̅, 1.0::e23)) == 0.
@test (@ga 3 Float64 ○(3.0::e, (2.0::e)')) == -6.0
@test (@ga 3 ○(3.0::e12, 2.0::e2)) == KVector{2,3}(0., 0., 6.)
@test (@ga 3 Float64 ○(($(√2)::e23 + $(√2)::e13), antireverse($(√2)::e23 + $(√2)::e13))) ≈ 4.0
end
@testset "Bulk and weight" begin
sig = (3, 0, 1)
bindings = Bindings(refs = Dict(
:x => 2.4,
:y => 3.2,
:z => :(x::e + y::e̅),
:p1 => :(1.2::e1 + 1.56::e2 + 1.65::e3 + 1.0::e4),
:p2 => :((-1.2)::e1 - 1.0::e2 + 0.0::e3 - 1.0::e4),
))
generate = ex -> ga_eval(sig, ex; bindings)
@test generate(:(left_complement(z))) == generate(:(bulk_left_complement(z) + weight_left_complement(z)))
@test generate(:(right_complement(z))) == generate(:(bulk_right_complement(z) + weight_right_complement(z)))
@test generate(:(bulk(z))) == generate(:(x::e))
@test generate(:(weight(z))) == generate(:(y::e̅))
@test generate(:(weight(p1))) == generate(:(1.0::e4))
@test generate(:(weight(p2))) == generate(:((-1.0)::e4))
end
@testset "Norms & unitization" begin
sig = (3, 0, 1)
bindings = Bindings(refs = Dict(
:p => :(8.4::e1 + 4.2::e4),
:punit => :(2.0::e1 + 1.0::e4),
))
generate = ex -> ga_eval(sig, ex; bindings)
@test generate(:(bulk_norm(1::e1))) == generate(:(1.0::e))
# TODO: Make sure generate(:(0.0::e)) results in a KVector whose element type is Float64.
# @test generate(:(bulk_norm(1::e4))) == generate(:(0.0::e))
@test generate(:(bulk_norm(1::e4))) == KVector{0,4}(0.0)
@test generate(:(weight_norm(1::e4))) == generate(:(1.0::e̅))
@test generate(:(weight_norm(1::e1))) == KVector{4,4}(0.0)
@test generate(:(weight_norm(3.2::e1 + 4.0::e4))) == generate(:(4.0::e̅))
@test generate(:(unitize(p))) == generate(:punit)
end
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 2943 | sig = Signature(3, 1)
cache = ExpressionCache(sig)
sc(x) = scalar(cache, x)
fac(x) = factor(cache, x)
bl(args...) = blade(cache, args...)
x, y, z = sc.([:x, :y, :z])
e1, e2, e3, e4 = blade.(cache, [1, 2, 3, 4])
expression(head, args...) = Expression(cache, head, args...)
add(x, ys...) = expression(SCALAR_ADDITION, x, ys...)
mul(x, ys...) = expression(SCALAR_PRODUCT, x, ys...)
uadd(x, ys...) = unsimplified_expression(cache, SCALAR_ADDITION, x, ys...)
umul(x, ys...) = unsimplified_expression(cache, SCALAR_PRODUCT, x, ys...)
is_binarized(ex) = all(==(2) ∘ length, gather_scalar_expressions(ex))
@testset "Optimization" begin
a = add(:x, :y, :z)
@test !may_reuse(a, ExpressionSpec(a))
@test may_reuse(a, ExpressionSpec(add(:x, :y)))
@test !may_reuse(a, ExpressionSpec(mul(:x, :y)))
b = add(:x, :z)
@test !may_reuse(b, ExpressionSpec(add(:x, :y)))
@test !may_reuse(add(:x, :y, :z), ExpressionSpec(add(:x, :x)))
ex = add(:x, :y)
@test gather_scalar_expressions(ex) == [ex]
ex = uadd(:x, uadd(:y, :z))
@test gather_scalar_expressions(ex) == [ex, add(:y, :z)]
ex1 = uadd(:y, :(f($(add(:a, :b)))))
ex = uadd(:x, ex1)
@test gather_scalar_expressions(ex) == [ex, ex1, add(:a, :b)]
ex1 = uadd(:a, :b, :(g($(mul(:c, :d)))))
ex2 = uadd(:y, :(f($ex1)))
ex = uadd(:x, ex2)
@test gather_scalar_expressions(ex) == [ex, ex2, ex1, mul(:c, :d)]
ex1 = umul(:y, expression(SCALAR_DIVISION, add(:a, :b), mul(:c, :d)))
ex = uadd(:x, ex1)
@test gather_scalar_expressions(ex) == [ex, ex1, add(:a, :b), mul(:c, :d)]
ex = uadd(a, b)
iter = IterativeRefinement(ex)
apply!(iter)
@test ex == uadd(uadd(:y, b), b)
@test iter.metrics.reused == 1
@test iter.metrics.splits == 0
@test is_binarized(ex)
a = add(:x, :y, :z)
ex = uadd(a, a, umul(b, uadd(a, a)))
iter = IterativeRefinement(ex)
apply!(iter)
@test a == uadd(:y, uadd(:x, :z))
@test ex == uadd(umul(b, uadd(a, a)), uadd(a, a))
@test iter.metrics.reused == 2
@test iter.metrics.splits == 0
@test is_binarized(ex)
abcd = uadd(:a, :b, :c, :d)
expr = Expr(:call, :f, abcd)
ex = uadd(:x, uadd(:a, :b), expr)
iter = IterativeRefinement(ex)
@test in(abcd, iter.expressions)
@test haskey(iter.available, 4)
apply!(iter)
@test iter.metrics.splits ≤ 2
@test is_binarized(ex)
ex, _ = generate_expression(sig, :(x::1 ⟑ y::2); optimize = true, factorize = false)
@test is_binarized(ex)
ex, _ = generate_expression(Signature(3), quote
Π = a::Vector ⟑ b::Vector
Ω = exp((-(0.5α)::Scalar) ⟑ Π)
end; optimize = false, factorize = false)
exs = gather_scalar_expressions(ex)
@test allunique(exs)
@test !is_binarized(ex)
optimize!(ex)
new_exs = gather_scalar_expressions(ex)
@test length(new_exs) > length(exs)
@test all(in(new_exs), exs)
# TODO: Get a consistent result; the issue probably stems from the non-deterministic sorting of terms in `simplify_addition`.
@test_skip is_binarized(ex)
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 685 | using SymbolicGA: restructure_sums, fill_kvector_components, Zero
@testset "Passes" begin
cache = ExpressionCache(Signature(3))
x, y = factor(cache, :x) * blade(cache, 1, 3), factor(cache, :x) * blade(cache, 1, 2)
z = factor(cache, :x) * blade(cache, 1, 2, 3)
ex = restructure_sums(x + y)
@test ex == kvector(x, y)
ex = restructure_sums(x + y + z)
@test ex == multivector(kvector(x, y), kvector(z))
@test isa(repr(ex), String)
ex = restructure_sums(z)
@test ex == kvector(z)
ex = fill_kvector_components(kvector(blade(cache, 1, 2), blade(cache, 2, 3)))
@test ex == kvector(blade(cache, 1, 2), weighted(blade(cache, 1, 3), Zero()), blade(cache, 2, 3))
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 1151 | using SymbolicGA, Test
using SymbolicGA: Term, Expression, ID, ExpressionCache, ExpressionSpec, isexpr, postwalk, simplify!, isweighted, getcomponent, blade, factor, weighted, scalar, antiscalar, kvector, multivector, antigrade, antireverse, exterior_product, ⟑, ∧, Head, COMPONENT, FACTOR, BLADE, KVECTOR, MULTIVECTOR, ADDITION, SUBTRACTION, NEGATION, REVERSE, ANTIREVERSE, LEFT_COMPLEMENT, RIGHT_COMPLEMENT, GEOMETRIC_PRODUCT, EXTERIOR_PRODUCT, INTERIOR_PRODUCT, COMMUTATOR_PRODUCT, INVERSE, EXPONENTIAL, SCALAR_ADDITION, SCALAR_PRODUCT, SCALAR_DIVISION, may_reuse, unsimplified_expression, IterativeRefinement, apply!, optimize!, dereference, gather_scalar_expressions, generate_expression, show1, Factorization, factorize, factorize!, Scalar, dimension
ENV["JULIA_DEBUG"] = "SymbolicGA"
ENV["JULIA_DEBUG"] = ""
include("utils.jl")
@testset "SymbolicGA.jl" begin
include("signatures.jl")
include("expressions.jl")
include("factorization.jl")
include("optimization.jl")
include("passes.jl")
include("types.jl")
include("macro.jl")
include("operators.jl")
include("examples.jl")
include("doctests.jl")
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 789 | using SymbolicGA: metric, is_degenerate, triplet
@testset "Signature" begin
@test Signature("+++") == Signature(3, 0)
@test Signature("++-") == Signature(2, 1)
@test Signature("+-𝟎") == Signature(1, 1, 1)
@test triplet(Signature(1, 2, 3)) == (1, 2, 3)
@test triplet(Signature(1, 2)) == (1, 2, 0)
@test triplet(Signature(1)) == (1, 0, 0)
@test !is_degenerate(Signature(4, 0, 0))
@test !is_degenerate(Signature(1, 3, 0))
@test is_degenerate(Signature(1, 1, 1))
@test dimension(Signature(2, 1, 0)) == 3
@test dimension(Signature(1, 1, 4)) == 6
s = Signature(2, 1, 0)
@test metric(s, Val(1), Val(1)) == 1
@test metric(s, Val(1), Val(2)) == 0
@test metric(s, Val(3), Val(3)) == -1
@test eval(Meta.parse(repr(s))) == s
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 1023 | using SymbolicUtils
@testset "Symbolic expressions" begin
@syms x₁ x₂ x₃ y₁ y₂ y₃ z₁ z₂ z₃
x = (x₁, x₂, x₃)
y = (y₁, y₂, y₃)
z = (z₁, z₂, z₃)
det = @ga 3 x::1 ∧ y::1 ∧ z::1
@test isequal(det[], x₁*y₂*z₃ + x₂*y₃*z₁ + x₃*y₁*z₂ - x₂*y₁*z₃ - x₁*y₃*z₂ - x₃*y₂*z₁)
@syms cgx cgy cgz cgw cvx cvy cvz cmx cmy cmz
@syms ogx ogy ogz ogw ovx ovy ovz omx omy omz
c = @cga3 (cgx::e423 + cgy::e431 + cgz::e412 + cgw::e321 + cvx::e415 + cvy::e425 + cvz::e435 + cmx::e235 + cmy::e315 + cmz::e125)
o = @cga3 (ogx::e423 + ogy::e431 + ogz::e412 + ogw::e321 + ovx::e415 + ovy::e425 + ovz::e435 + omx::e235 + omy::e315 + omz::e125)
p = @cga3 c::3 ∨ o::3
@test isequal(collect(p)[1:5], [
cgz*omy - cgy*omz + cmy*ogz - cmz*ogy + cvx*ogw + cgw*ovx,
cgx*omz - cgz*omx + cmz*ogx - cmx*ogz + cvy*ogw + cgw*ovy,
cgy*omx - cgx*omy + cmx*ogy - cmy*ogx + cvz*ogw + cgw*ovz,
-(cgx*ovx + cgy*ovy + cgz*ovz + cvx*ogx + cvy*ogy + cvz*ogz),
-(cmx*ovx + cmy*ovy + cmz*ovz + cvx*omx + cvy*omy + cvz*omz),
])
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 415 | @testset "User-facing types" begin
k = KVector{1,3}((1, 2, 3))
@test eltype(k) === Int
@test collect(k) == [1, 2, 3] && isa(collect(k), Vector{Int})
@test length(k) == 3
@test_throws "Expected" KVector{1, 3}((1, 2, 3, 4))
@test_throws "of dimension" KVector{4, 3}((1, 2, 3, 4))
@test collect(KVector{0, 3}((1,))) == [1]
@test convert(NTuple{4,Int64}, KVector{1,4}(1, 2, 3, 4)) === (1, 2, 3, 4)
end;
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | code | 376 | using SymbolicGA: traverse, Retraversal
function expression_nodes(f, x, ::Type{Expr})
res = Expr[]
traverse(x) do y
f(y) === true && push!(res, y)
nothing
end
res
end
function expression_nodes(x::Expression)
res = Expression[]
traverse(x; retraversal = Retraversal(x.cache, Expr)) do y
isa(y, Expression) && push!(res, y)
nothing
end
res
end
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | docs | 1835 | # Changelog
## v0.2
- ![BREAKING][badge-breaking] `*` no longer aliases the geometric product by default `⟑` (`\wedgedot`).
- ![BREAKING][badge-breaking] `VariableInfo` has been renamed `Bindings` for better clarity.
- ![BREAKING][badge-breaking] The `flattening` symbol parameter to `@ga` has been removed, instead using type annotations to express a concatenated or tuple output.
- ![BREAKING][badge-breaking] The `::KVector{$k}` type annotation is no longer supported; instead, prefer using `::$k` or (if `k` is small enough) one of its aliases, e.g. `Bivector` for `KVector{2}`. The `::Multivector{$k, $l, ...}` syntax is also no longer supported; use the `::($k, $l, ...)` syntax instead.
- ![BREAKING][badge-breaking] Default bindings are no longer merged into provided bindings in `codegen_expression`.
- ![feature][badge-feature] A new macro `@geometric_space` has been defined to ease the definition of user macros. See the documentation for more information.
[badge-breaking]: https://img.shields.io/badge/BREAKING-red.svg
[badge-deprecation]: https://img.shields.io/badge/deprecation-orange.svg
[badge-feature]: https://img.shields.io/badge/feature-green.svg
[badge-enhancement]: https://img.shields.io/badge/enhancement-blue.svg
[badge-bugfix]: https://img.shields.io/badge/bugfix-purple.svg
[badge-security]: https://img.shields.io/badge/security-black.svg
[badge-experimental]: https://img.shields.io/badge/experimental-lightgrey.svg
[badge-maintenance]: https://img.shields.io/badge/maintenance-gray.svg
<!--
# Badges (reused from the CHANGELOG.md of Documenter.jl)
![BREAKING][badge-breaking]
![Deprecation][badge-deprecation]
![Feature][badge-feature]
![Enhancement][badge-enhancement]
![Bugfix][badge-bugfix]
![Security][badge-security]
![Experimental][badge-experimental]
![Maintenance][badge-maintenance]
-->
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | docs | 5011 | # SymbolicGA

[](https://codecov.io/gh/serenity4/SymbolicGA.jl)
[](https://serenity4.github.io/SymbolicGA.jl/stable)
[](https://serenity4.github.io/SymbolicGA.jl/dev)
[](https://github.com/SciML/ColPrac)
[](https://www.repostatus.org/#active)
Geometric Algebra (GA) library based on just-in-time symbolic processing to turn algebraic expressions into optimized code.
This package is ready for general use, but it still in active development and bugs may be frequently encountered along with incomplete or unsupported major features. You are welcome to report potential issues or to suggest improvements. When upgrading to a new major version, make sure to consult the [changelog](https://github.com/serenity4/SymbolicGA.jl/blob/main/CHANGELOG.md) to be aware of any major breakages.
## Basic usage
```julia
using SymbolicGA
# Compute the determinant of a 4x4 matrix.
# Let A₁, A₂, A₃ and A₄ be the matrix columns.
A₁, A₂, A₃, A₄ = ntuple(_ -> rand(4), 4)
# The determinant is the four-dimensional "volume" of the subspace spanned by all four column vectors.
# This is trivially generalized to `n`-by-`n` matrices by using a signature of `n` and wedging all `n` column vectors.
Δ = @ga 4 A₁::1 ∧ A₂::1 ∧ A₃::1 ∧ A₄::1
# We got an antiscalar out as a `KVector{4}`.
# Extract the component with `[]`.
Δ[]
# Let's compute the rotation of a vector x by α radians in the plane formed by a and b.
# We do this in 3D, but this works in any dimension with the appropriate signature; 2D but also 4D, 5D, etc.
a = (1.0, 0.0, 0.0)
b = (0.0, 1.0, 0.0)
x = (1.0, 1.0, 0.0)
α = π / 6
# Define a unit plane for the rotation.
# The unitization ensures we don't need `a` and `b` to be orthogonal nor to be unit vectors.
# If these conditions are otherwise met, unitization can be skipped.
Π = @ga 3 unitize(a::1 ∧ b::1)
# Define rotation generator.
Ω = @ga 3 exp(-(0.5α)::0 ⟑ Π::2)
# Apply the rotation with the versor product of x by Ω.
x′ = @ga 3 x::1 << Ω::(0, 2)
@assert collect(x′) ≈ [0.36602540378443876, 1.3660254037844386, 0.0]
```
For advanced usage, tutorials and references, please consult the [official documentation](https://serenity4.github.io/SymbolicGA.jl/stable/).
## Performance
This library applies rules of geometric algebra during macro expansion to generate numerically performant code. The resulting instructions are scalar operations, which should be fast and comparable to hand-written type-stable numerical code.
Here is an example benchmark to compute determinants, compared with LinearAlgebra:
```julia
using StaticArrays: @SVector, SMatrix
using LinearAlgebra: det
using BenchmarkTools: @btime
mydet(A₁, A₂, A₃, A₄) = @ga(4, A₁::1 ∧ A₂::1 ∧ A₃::1 ∧ A₄::1)[]
A₁ = @SVector rand(4)
A₂ = @SVector rand(4)
A₃ = @SVector rand(4)
A₄ = @SVector rand(4)
A = SMatrix([A₁ A₂ A₃ A₄])
@assert mydet(A₁, A₂, A₃, A₄) ≈ det(A)
@btime det($A)
@btime mydet($A₁, $A₂, $A₃, $A₄)
```
```julia
4.845 ns (0 allocations: 0 bytes) # LinearAlgebra
13.485 ns (0 allocations: 0 bytes) # SymbolicGA
```
This snippet performs a 3D vector rotation along an arbitrary plane and angle. Note that part of the timing is only about building the rotation operator Ω, which would correspond to building a rotation matrix in conventional approaches.
```julia
function rotate_3d(x, a, b, α)
Π = @ga 3 unitize(a::1 ∧ b::1)
Ω = @ga 3 exp(-(0.5α)::0 ⟑ Π::2)
rotate_3d(x, Ω)
end
rotate_3d(x, Ω) = @ga 3 x::1 << Ω::(0, 2)
a = (1.0, 0.0, 0.0)
b = (2.0, 2.0, 0.0) # some arbitrary non-unit vector non-orthogonal to `a`.
x = (2.0, 0.0, 0.0)
α = π / 6
x′ = rotate_3d(x, a, b, α)
@assert x′ ≈ KVector{1,3}(2cos(π/6), 2sin(π/6), 0.0)
@btime rotate_3d($a, $b, $x, $α)
Ω = @ga 3 exp(-(0.5α)::0 ⟑ (a::1 ∧ b::1))
@btime rotate_3d($x, $Ω)
```
```julia
# 3D rotation, including both the construction of the rotation operator from a plane and its application.
40.582 ns (0 allocations: 0 bytes)
# Application of rotation operator.
8.310 ns (0 allocations: 0 bytes)
```
It should be noted that in theory any performance gap can be addressed, as we have total control over what code is emitted.
## JuliaCon talk
An introduction to geometric algebra with quick presentation of this library is available on YouTube.
- [Slides](https://docs.google.com/presentation/d/e/2PACX-1vQ9trJBYfvZXCEoArxRQwYhS_tzGBYOfeY-s7aGZhE8_J-VPbztXbPPgW9uNTjUUrNbf9JWIYjLLngW/pub?start=false&loop=false&delayms=3000)
[](https://youtu.be/lD4tNcHVjX4)
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | docs | 773 | # Glossary
**Geometric algebra**: Mathematical framework based around the geometric product, relying on an [exterior algebra](https://en.wikipedia.org/wiki/Exterior_algebra) to construct entities of geometric significance.
**Geometric space**: Mathematical space defined with objects and a geometric product satisfying the axioms of geometric algebra, using a metric defined by a custom signature. Usually described as an algebra in most presentations of geometric algebra, e.g. PGA or CGA, even though different "algebras" are still algebraically very similar, as they use the same rules - just a different base space and metric.
**Signature**: Parameter of a geometric space determining the scalar value of the square of its basis vectors under the geometric product.
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | docs | 444 | # SymbolicGA.jl
## Status
This package is ready for general use, but it still in active development and bugs may be frequently encountered along with incomplete or unsupported major features. You are welcome to report potential issues or to suggest improvements. When upgrading to a new major version, make sure to consult the [changelog](https://github.com/serenity4/SymbolicGA.jl/blob/main/CHANGELOG.md) to be aware of any major breakages.
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | docs | 2481 | # Design choices
There are many ways to implement geometric algebra numerically, and each performs its own trade-offs, depending on the goals it is set to achieve.
In this library, we seek to allow the use of geometric algebra as a language to express logic. In particular, having a concrete representation of the objects and operators of geometric algebra is not a necessity, as long as the relevant operations are easy to express. This is relevant in context of the integration with existing codebases; we chose not to require the use of library-specific types nor, for most cases, to extend specific methods. The interface with this library is based around the way data is to be cast into the semantics of geometric algebra. This should not affect the data structures you choose; be it a tuple, vector or static array, we only need a way to map data to components (see [this how-to](@ref howto-integration)).
Having direct control over the code that is generated was also one motivation for operating at the symbolic level. It is more work to implement a library which has to manipulate symbolic expressions, but we believe that the benefits are largely worth the effort. The performance guaranteed by processing and optimizing algebraic operations at macro expansion time (i.e. right after parsing, before compilation) furthermore allowed us to escape the limitation of supporting a fixed set of signatures, empowering the user to use whatever space they see fit. In a sense, SymbolicGA.jl can be considered a just-in-time library generator, combining the performance of such generators with the flexibility of other, more dynamic approaches.
Another advantage of operating at the symbolic level is that the way syntax is interpreted can also be controlled. We could implement a fairly simple binding-based substitution with references (which expand to an expression) and basic functions (expanding to an expression, but inserting one argument or more), which prevented us from needing to commit to specific function names and aliases to be exported. This flexibility of notation is particularly relevant in the context of geometric algebra as certain operators or variables may have different notations. Examples include the geometric product, most often noted `*` but sometimes noted `⟑` or the pseudoscalar most often noted `I` but sometimes noted `𝟙` ([see the motivations for the latter notations](https://terathon.com/blog/projective-geometric-algebra-done-right/)).
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | docs | 4962 | # Geometric Algebra
This section is dedicated to briefly introducing geometric algebra, and provide resources for further information. Note that geometric algebra is a vast topic, drawing from specialized and advanced branches of geometry in mathematics.
## Introduction
Geometric algebra is an algebraic framework which allows elegant and efficient expressions of geometric entities and transformations. For example, its projective version over $\mathbb{R}^3$ compactly expresses intersections between points, lines and planes without introducing coordinates nor equations; the conformal version additionally expresses circles and spheres, and unifies translations and rotations in a single geometric object, again in a coordinate-free manner. For those familiar with quaternions, these are contained in the geometric algebra over the vector space $\mathbb{R}^3$, and can be better understood intuitively as part of a bigger framework than usually presented. Rotations can furthermore be expressed in the geometric algebra over the vector space $\mathbb{R}^2$ without having to resort to embedding it within $\mathbb{R}^3$, as is the case for a treatment of rotations using the standard cross product. This specific algebra over $\mathbb{R}^2$ contains complex numbers as a subalgebra, in the same way that the geometric algebra over $\mathbb{R}^3$ contains quaternions as a subalgebra.
The major advantages of such a framework resides in:
- Requiring a low symbolic complexity, with clean abstractions that do not require special casings on coordinate systems nor looking up complex formulas to express common geometric operations.
- Providing good intuition about the nature of geometric operations, with clear semantics assigned to many of the operators within geometric algebra and connections to numerous branches of mathematics related to geometry.
The implications to programming are largely tied to the simplicity and consistency over many applications. In certain contexts, it is possible to perform more efficient operations than standard methods by exploiting the sparsity of certain structures; for example, 3D rotations can be expressed by matrices, but with intrinsically fewer degrees of freedom than a general 3x3 matrix. However, the most noticeable improvements reside in lower code complexity, resulting in easier maintenance and understandability of implementations of geometric operations.
Nevertheless, it should be noted that geometric algebra requires a certain mastery before showing its usefulness. In a way, this is a complicated swiss knife which has a steep learning curve and which departs from classic approaches to geometry that one may be more familiar with. Learning about geometric algebra is not an easy task, and is notably recommended for implementers and users of algorithms related to computational geometry and for those that are curious and desiring to gain a deeper insight about the different angles from which geometry can be viewed.
In particular, as an algebraic framework and a highly convenient utility, it very rarely provides new results unknown to other branches of mathematics; but it can easily unlock them to those unused to advanced abstract reasoning, and foster new developments through a unified language and insights that result from its elegance.
## Resources
#### Introductory resources
- [Very approachable introduction](https://arxiv.org/abs/1205.5935v1) by Eric Chisolm (paper)
- [A Swift Introduction to Geometric Algebra](https://www.youtube.com/watch?v=60z_hpEAtD8) (video)
- [Siggraph 2019 talk](https://www.youtube.com/watch?v=tX4H_ctggYo) (video)
- [Cambridge course](http://geometry.mrao.cam.ac.uk/2016/10/geometric-algebra-2016/)
- Introductory book: *Vince, J. (2008). Geometric algebra for computer graphics. Springer Science & Business Media.*
#### Reference resources
- [bivector.net](https://bivector.net)
- [projectivegeometricalgebra.org](https://projectivegeometricalgebra.org/)
- Projective geometric algebra (PGA):
- [PGA wiki](https://rigidgeometricalgebra.org/wiki/index.php?title=Main_Page) (E. Lengyel)
- [3D PGA poster](https://projectivegeometricalgebra.org/projgeomalg.pdf) (E. Lengyel)
- Conformal geometric algebra (CGA):
- [CGA wiki](https://conformalgeometricalgebra.org/wiki/index.php?title=Main_Page) (E. Lengyel)
- [3D CGA poster](https://projectivegeometricalgebra.org/confgeomalg.pdf) (E. Lengyel)
#### Geometric Calculus
Note: this topic is more advanced.
- Reference book (also a great reference book outside geometric calculus): *Hestenes, D., & Sobczyk, G. (2012). Clifford algebra to geometric calculus: a unified language for mathematics and physics (Vol. 5). Springer Science & Business Media.*
- [Advanced tutorial](https://www.youtube.com/watch?v=ItGlUbFBFfc) (video)
- Compact summary (advanced): *Macdonald, A. (2017). A survey of geometric algebra and geometric calculus. Advances in Applied Clifford Algebras, 27(1), 853-891.*
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | docs | 557 | # API Reference
Main symbols:
- [`@ga`](@ref)
- [`@geometric_space`](@ref)
- [`KVector`](@ref)
- [`Bindings`](@ref)
- [`codegen_expression`](@ref)
- [`default_bindings`](@ref)
Aliases:
- [`Bivector`](@ref)
- [`Trivector`](@ref)
- [`Quadvector`](@ref)
## Usage
```@docs
@ga
@pga2
@pga3
@cga3
@geometric_space
KVector
Bivector
Trivector
Quadvector
```
## Expression generation
```@docs
codegen_expression
Bindings
default_bindings
SymbolicGA.Signature
SymbolicGA.@arg
```
## Interface methods
```@docs
SymbolicGA.getcomponent
SymbolicGA.construct
```
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.2.2 | fe44922cacdf82833b9b322a9833fbe10d886577 | docs | 6181 | # Table of symbols
These tables list all the functions, operators and constants that are recognized as geometric operations, e.g. in code evaluated as part of a `@ga` block.
## [Built-in functions](@id builtins)
These functions are always accessible in any context, and cannot be overriden:
- `+(a, b, ...)`
- `-(a)`
- `-(a, b)`
- `reverse(a)`
- `antireverse(a)`
- `left_complement(a)`
- `right_complement(a)`
- `geometric_product(a, b, ...)`
- `exterior_product(a, b, ...)`
- `interior_product(a, b)`
- `commutator_product(a, b)`
- `inverse(a)`
- `exp(a)`
## Default symbols
Although any operation in geometric algebra may be performed using the built-in functions above, it is useful to have access to shorthands and other operators which build on these primitives. Therefore, default functions and operators are provided, as well as a few aliases and constants.
These are obtained with [`default_bindings`](@ref), and may be tweaked or removed if you choose to reimplement your own macro over `@ga` using [Expression generation](@ref) utilities.
### Functions
These functions define secondary operators that are more or less standard in geometric algebra. Many of these operators were extracted from [E. Lengyel's PGA poster](http://projectivegeometricalgebra.org/projgeomalg.pdf).
| Function | Definition |
|---|---|
`antidivision` | `inverse_dual(division(dual(a), dual(b)))`
`antiinverse` | `inverse_dual(inverse(dual(a)))`
`antiscalar_product` | `geometric_antiproduct(a, antireverse(a))::e̅`
`bulk_left_complement` | `geometric_product(antireverse(a), 𝟙)`
`bulk_norm` | `sqrt(interior_product(a, reverse(a)))::e`
`bulk_right_complement` | `geometric_product(reverse(a), 𝟙)`
`bulk` | `weight_left_complement(bulk_right_complement(a))`
`division` | `geometric_product(a, inverse(b))`
`exterior_antiproduct` | `inverse_dual(exterior_product(dual(a), dual(b)))`
`geometric_antiproduct` | `inverse_dual(geometric_product(dual(a), dual(b)))`
`geometric_norm` | `bulk_norm(a) + weight_norm(a)`
`interior_antiproduct` | `inverse_dual(interior_product(dual(a), dual(b)))`
`left_interior_antiproduct` | `exterior_product(a, right_complement(b))`
`left_interior_product` | `exterior_antiproduct(left_complement(a), b)`
`projected_geometric_norm` | `antidivision(bulk_norm(a), weight_norm(a))`
`right_interior_antiproduct` | `exterior_product(left_complement(a), b)`
`right_interior_product` | `exterior_antiproduct(a, right_complement(b))`
`scalar_product` | `geometric_product(a, reverse(a))::Scalar`
`unitize` | `antidivision(a, weight_norm(a))`
`versor_product` | `geometric_product(b, a, inverse(b))`
`weight_left_complement` | `geometric_antiproduct(𝟏, antireverse(a))`
`weight_norm` | `sqrt(interior_antiproduct(a, antireverse(a)))::e̅`
`weight_right_complement` | `geometric_antiproduct(𝟏, reverse(a))`
`weight` | `bulk_left_complement(weight_right_complement(a))`
### Operators
Convenient binary operators are defined by default to allow a more compact language to perform geometric operations. Note that there is no agreed-upon convention for these, and that is why we prefer to allow more advanced users to tweak them at will:
| Function | Unicode input | Expression |
|---|---|---|
| `a ⟑ b` | `\wedgedot` | `geometric_product(a, b)`
| `a ⟇ b` (Julia 1.10 or higher) | `\veedot` | `geometric_antiproduct(a, b)`
| `a ⩒ b` | `\veeodot` | `geometric_antiproduct(a, b)`
| `a ⋅ b` | `\cdot` | `interior_product(a, b)`
| `a ● b` | `\mdlgblkcircle` | `interior_product(a, b)`
| `a ○ b` | `\bigcirc` | `interior_antiproduct(a, b)`
| `a ⦿ b` | `\circledbullet` | `scalar_product(a, b)`
| `a ∧ b` | `\wedge` | `exterior_product(a, b)`
| `a ∨ b` | `\vee` | `exterior_antiproduct(a, b)`
| `a ⊣ b` | `\dashv` | `left_interior_product(a, b)`
| `a ⊢ b` | `\vdash` | `right_interior_product(a, b)`
| `a ⨼ b` | `\intprod` | `left_interior_antiproduct(a, b)`
| `a ⨽ b` | `\intprodr` | `right_interior_antiproduct(a, b)`
| `a << b` | | `versor_product(a, b)`
| `a / b` | | `division(a, b)`
| `a'` | | `reverse(a)`
!!! note
In many materials about geometric algebra, the geometric product uses the same notation as the standard multiplication operator, `*` (or even juxtaposition). However, we prefer to use the `\wedgedot` symbol `⟑` [proposed by E. Lengyel](https://terathon.com/blog/projective-geometric-algebra-done-right/) to visually show its relationship with the inner and outer products, `⋅` and `∧`, and because it allows the use of an "anti-" operator to express the dual operator to the geometric product, the geometric antiproduct `⟇` (`\veedot`, available from Julia 1.10).
There are also programming-related motivations, as `2x` destructures to `2 * x` which would rarely want to be considered as "the geometric product of 2 and `x`".
### Aliases
A few aliases are defined, with a short-hand for the inverse and a specific choice of a dual and dual inverse, along with common names for operators we named differently:
| Symbol | Alias |
|---|---|
| `inv` | `inverse`
| `dual` | `right_complement`
| `inverse_dual` | `left_complement`
| `regressive_product` | `exterior_antiproduct`
| `left_contraction` | `left_interior_product`
| `right_contraction` | `right_interior_product`
### Constants
These constants allow you to complactly express scalar and antiscalar units.
| Symbol | Input | Expression |
|---|---|---|
| `𝟏` | `\bfone` | `1::e`
| `𝟙` | `\bbone` | `1::e̅`
## Type annotations
Considering an $n$-dimensional space, the various ways to annotate a value are as follows:
| Annotation | Alias | Grade or basis blade
|---|---|---|
| `::e1` | | Basis vector $e_1$ (grade 1)
| `::e12` | `::e_1_2` | Basis blade $e_1 \wedge e_2$ (grade 2)
| `::e_11_12` | | Basis blade $e_{11} \wedge e_{12}$ (grade 2, more than one digit per index)
| `::Scalar` | `::0`, `::e` | $0$
| `::Vector` | `::1` | $1$
| `::Bivector` | `::2` | $2$
| `::Trivector` | `::3` | $3$
| `::Quadvector` | `::4` | $4$
| `::Antiscalar` | `::ē` | $n$
| `::(k, l, ...)` | | Tuple of multiple elements of grade $k$, $l$, ...
| `::(k + l + ...)` | | Concatenation of multiple elements of grade $k$, $l$, ...
| `::Multivector` | | Concatenation of all elements with grade $0$ to $n$
| SymbolicGA | https://github.com/serenity4/SymbolicGA.jl.git |
|
[
"MIT"
] | 0.3.6 | 5844ee60d9fd30a891d48bab77ac9e16791a0a57 | code | 7238 | ### A Pluto.jl notebook ###
# v0.16.1
using Markdown
using InteractiveUtils
# ╔═╡ a7288f0e-92c2-11eb-1f09-55b1249cddfc
using ShortCodes
# ╔═╡ b4638c6e-92c2-11eb-3455-297ca53dbf37
md" # ShortCodes
Simple embedding for [Pluto notebooks](https://github.com/fonsp/Pluto.jl)
"
# ╔═╡ bf967628-92c2-11eb-0794-654da6ac5292
md"# Twitter"
# ╔═╡ c4650640-92c2-11eb-2a5b-ed1dc13273ac
Twitter(1314967811626872842)
# ╔═╡ c90a21b6-92c2-11eb-0020-cf0095378602
md"# YouTube
Embed a video and seek to the given point in the video."
# ╔═╡ d5e1705e-92c2-11eb-2369-cba030f80467
YouTube("IAF8DjrQSSk",18,27)
# ╔═╡ db03ba94-92c2-11eb-0d9e-9382dc14f783
md"# Flickr"
# ╔═╡ e02ef00c-92c2-11eb-0036-e9f6a7a34ddc
Flickr(29110717138)
# ╔═╡ e7c836f4-92c2-11eb-3f84-77ffa870187e
md"# Embed Web Page"
# ╔═╡ e9db6308-92c2-11eb-0dda-09b6a1e6bb7e
WebPage("https://julialang.org/downloads/#current_stable_release")
# ╔═╡ f2f0fdd6-92c2-11eb-2e52-c5ea0f9288fc
md"# Vimeo"
# ╔═╡ feb4b4e6-92c2-11eb-0fe8-895a5ee0b084
Vimeo(171764413)
# ╔═╡ 96e66150-c4bb-4c77-b752-d04f8d366bca
md"# DOI
DOI information via [opencitations.net](https://opencitations.net) and [doi.org](https://doi.org)"
# ╔═╡ 8079cb71-95d7-4849-b5a4-abbb43f038f8
DOI("10.1137/141000671")
# ╔═╡ 1cda6524-92c3-11eb-145d-333251ab7498
md"# GraphViz"
# ╔═╡ 23e1b908-92c3-11eb-07c7-79c227f37cd8
GraphViz("digraph G {Hello->World}")
# ╔═╡ f001ad0c-92c3-11eb-15dd-0b6029eba08c
md"# Mermaid"
# ╔═╡ faa2b3f2-92c3-11eb-36a2-b716c6113df4
Mermaid("gantt
section Section
Completed :done, des1, 2014-01-06,2014-01-08
Active :active, des2, 2014-01-07, 3d
Parallel 1 : des3, after des1, 1d
Parallel 2 : des4, after des1, 1d
Parallel 3 : des5, after des3, 1d
Parallel 4 : des6, after des4, 1d")
# ╔═╡ 05880a9e-92c4-11eb-1ca6-25556245f92d
md"# BlockDiag"
# ╔═╡ 0c92c8ea-92c4-11eb-08cd-f9e7d4cbdf24
BlockDiag("""blockdiag {
Kroki -> generates -> "Block diagrams";
Kroki -> is -> "very easy!";
Kroki [color = "greenyellow"];
"Block diagrams" [color = "pink"];
"very easy!" [color = "orange"];
}""")
# ╔═╡ d4dd1922-92c4-11eb-3dff-a71dd1f96782
md"# PlantUML"
# ╔═╡ dcbec424-92c4-11eb-2ce6-d3ac255b3099
PlantUML("@startmindmap
skinparam monochrome true
+ OS
++ Ubuntu
+++ Linux Mint
+++ Kubuntu
+++ Lubuntu
+++ KDE Neon
++ LMDE
++ SolydXK
++ SteamOS
++ Raspbian
-- Windows 95
-- Windows 98
-- Windows NT
--- Windows 8
--- Windows 10
@endmindmap")
# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
ShortCodes = "f62ebe17-55c5-4640-972f-b59c0dd11ccf"
[compat]
ShortCodes = "~0.3.2"
"""
# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised
[[Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
git-tree-sha1 = "ded953804d019afa9a3f98981d99b33e3db7b6da"
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
version = "0.7.0"
[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "Logging", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
git-tree-sha1 = "60ed5f1643927479f845b0135bb369b031b541fa"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.9.14"
[[IniFile]]
deps = ["Test"]
git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8"
uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f"
version = "0.5.0"
[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
[[JSON3]]
deps = ["Dates", "Mmap", "Parsers", "StructTypes", "UUIDs"]
git-tree-sha1 = "b3e5984da3c6c95bcf6931760387ff2e64f508f3"
uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
version = "1.9.1"
[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
[[MacroTools]]
deps = ["Markdown", "Random"]
git-tree-sha1 = "5a5bc6bf062f0f95e62d0fe0a2d99699fed82dd9"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.5.8"
[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[MbedTLS]]
deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"]
git-tree-sha1 = "1c38e51c3d08ef2278062ebceade0e46cefc96fe"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.0.3"
[[MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
[[Memoize]]
deps = ["MacroTools"]
git-tree-sha1 = "2b1dfcba103de714d31c033b5dacc2e4a12c7caa"
uuid = "c03570c3-d221-55d1-a50c-7939bbd78826"
version = "0.4.4"
[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
[[Parsers]]
deps = ["Dates"]
git-tree-sha1 = "9d8c00ef7a8d110787ff6f170579846f776133a9"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.0.4"
[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[ShortCodes]]
deps = ["Base64", "CodecZlib", "HTTP", "JSON3", "Memoize", "UUIDs"]
git-tree-sha1 = "866962b3cc79ad3fee73f67408c649498bad1ac0"
uuid = "f62ebe17-55c5-4640-972f-b59c0dd11ccf"
version = "0.3.2"
[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[StructTypes]]
deps = ["Dates", "UUIDs"]
git-tree-sha1 = "8445bf99a36d703a09c601f9a57e2f83000ef2ae"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.7.3"
[[Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[TranscodingStreams]]
deps = ["Random", "Test"]
git-tree-sha1 = "216b95ea110b5972db65aa90f88d8d89dcb8851c"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.9.6"
[[URIs]]
git-tree-sha1 = "97bbe755a53fe859669cd907f2d96aee8d2c1355"
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
version = "1.3.0"
[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
[[Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
"""
# ╔═╡ Cell order:
# ╠═a7288f0e-92c2-11eb-1f09-55b1249cddfc
# ╟─b4638c6e-92c2-11eb-3455-297ca53dbf37
# ╟─bf967628-92c2-11eb-0794-654da6ac5292
# ╠═c4650640-92c2-11eb-2a5b-ed1dc13273ac
# ╠═c90a21b6-92c2-11eb-0020-cf0095378602
# ╠═d5e1705e-92c2-11eb-2369-cba030f80467
# ╟─db03ba94-92c2-11eb-0d9e-9382dc14f783
# ╠═e02ef00c-92c2-11eb-0036-e9f6a7a34ddc
# ╟─e7c836f4-92c2-11eb-3f84-77ffa870187e
# ╠═e9db6308-92c2-11eb-0dda-09b6a1e6bb7e
# ╟─f2f0fdd6-92c2-11eb-2e52-c5ea0f9288fc
# ╠═feb4b4e6-92c2-11eb-0fe8-895a5ee0b084
# ╟─96e66150-c4bb-4c77-b752-d04f8d366bca
# ╠═8079cb71-95d7-4849-b5a4-abbb43f038f8
# ╟─1cda6524-92c3-11eb-145d-333251ab7498
# ╠═23e1b908-92c3-11eb-07c7-79c227f37cd8
# ╟─f001ad0c-92c3-11eb-15dd-0b6029eba08c
# ╠═faa2b3f2-92c3-11eb-36a2-b716c6113df4
# ╟─05880a9e-92c4-11eb-1ca6-25556245f92d
# ╠═0c92c8ea-92c4-11eb-08cd-f9e7d4cbdf24
# ╟─d4dd1922-92c4-11eb-3dff-a71dd1f96782
# ╠═dcbec424-92c4-11eb-2ce6-d3ac255b3099
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002
| ShortCodes | https://github.com/hellemo/ShortCodes.jl.git |
|
[
"MIT"
] | 0.3.6 | 5844ee60d9fd30a891d48bab77ac9e16791a0a57 | code | 564 | module ShortCodes
using Base64
using CodecZlib
using Downloads
using URIs
using JSON3
using Memoize
using UUIDs
abstract type ShortCode end
function http_get(url; kwargs...)
io = IOBuffer()
Downloads.request(url; output=io, kwargs...)
read(seekstart(io))
end
include("doi.jl")
include("twitter.jl")
include("youtube.jl")
include("misc.jl")
include("kroki.jl")
export ShortCode
export BlockDiag
export DOI, EmDOI, ShortDOI
export Flickr
export GraphViz
export Mermaid
export PlantUML
export Twitter
export Vimeo
export WebPage
export YouTube
end # module
| ShortCodes | https://github.com/hellemo/ShortCodes.jl.git |
|
[
"MIT"
] | 0.3.6 | 5844ee60d9fd30a891d48bab77ac9e16791a0a57 | code | 4686 | abstract type AbstractDOI <: ShortCode end
struct EmDOI{T<:AbstractString} <: AbstractDOI
doi::T
highlight::T # Author to highlight when displaying
end
struct DOI{T<:AbstractString} <: AbstractDOI
doi::T
end
struct ShortDOI{T<:AbstractString} <: AbstractDOI
shortdoi::T
ShortDOI(doi::String) =
length(doi) > 10 ? new{String}(shortdoi(DOI{String}(doi))) : new{String}(doi)
end
DOI(doi::String) = DOI{String}(doi)
EmDOI(doi::String) = EmDOI{String}(doi, "")
EmDOI(doi::AbstractDOI, em::AbstractString) = EmDOI(doi.doi, em)
ShortDOI(doi::AbstractDOI) = ShortDOI(shortdoi(doi))
function Base.getproperty(obj::AbstractDOI, sym::Symbol)
sym == :doi && return getdoi(obj)
sym == :year && return year(obj.pub_date)
sym == :citation_count && return fetch_citation_count(getdoi(obj))
if sym == :journal
return strip(obj.venue)
elseif sym in [:author, :title, :page, :pub_date, :venue] # string types
return fetch_metadata(obj)[sym]
elseif sym in [:volume, :citation_count, :issue] # integer types
return parse(Int, fetch_metadata(obj)[sym])
elseif sym == :reference # DOI type
return split(fetch_metadata(obj)[sym], ";") .|> x -> DOI(replace(x, " " => ""))
else # fallback to getfield
return getfield(obj, sym)
end
end
getdoi(obj::AbstractDOI) = getfield(obj, :doi)
getdoi(obj::ShortDOI) = expand(obj)
function Base.show(io::IO, ::MIME"text/plain", doi::AbstractDOI)
print(io, join((doi.author, doi.title, string(doi.pub_date), shortdoi(doi)), " "))
end
function Base.show(io::IO, ::MIME"text/html", doi::AbstractDOI)
print(
io,
"<div>$(emph_author(doi)) <em>$(doi.title)</em>, $(doi.journal) ($(doi.year))
<a href=https://doi.org/$(shortdoi(doi))>$(shortdoi(doi))</a>, cited by $(fetch_citation_count(getdoi(doi)))</div>",
)
end
function Base.show(io::IO, ::MIME"text/html", dois::Array{T} where {T<:AbstractDOI})
print(io, "<ol>")
for doi in dois
print(
io,
"<li>$(emph_author(doi)) <em>$(doi.title)</em>, $(doi.journal) ($(doi.year))
<a href=https://doi.org/$(shortdoi(doi))>$(shortdoi(doi))</a>, cited by $(fetch_citation_count(getdoi(doi)))</li>",
)
end
print(io, "</ol>")
end
"""
meta-data structure from API: https://w3id.org/oc/meta/api/v1/metadata/
"""
function metadata_template(doi::String)
fields = (:publisher, :pub_date, :page, :venue, :issue, :editor, :author, :id, :volume, :title, :type)
rj = Dict(f => "" for f in fields)
rj[:id] = doi
return rj
end
@memoize function fetch_metadata(doi::AbstractDOI)
fetch_metadata(doi.doi)
end
@memoize function fetch_metadata(doi)
r = http_get("https://w3id.org/oc/meta/api/v1/metadata/doi:$(doi)")
rj = JSON3.read(r)
if isempty(rj)
return metadata_template(doi)
else
return rj[1]
end
end
fetch_citation_count(doi::AbstractDOI) = fetch_citation_count(doi.doi)
@memoize function fetch_citation_count(doi)
rj = JSON3.read(http_get("https://opencitations.net/index/api/v1/citation-count/$(doi)"))
return parse(Int, rj[1][:count])
end
@memoize shortdoi(doi::AbstractDOI) = fetch_shortdoi(doi).ShortDOI
@memoize function fetch_shortdoi(doi::AbstractDOI)
fetch_shortdoi(doi.doi)
end
@memoize function fetch_shortdoi(doi::String)
return JSON3.read(http_get("https://shortdoi.org/$(doi)?format=json"))
end
"""
expand(doi::ShortDOI)
Get full DOI from doi.org
"""
@memoize function expand(doi::ShortDOI)
r = http_get("https://doi.org/api/handles/$(doi.shortdoi)")
return JSON3.read(r)[:values][2][:data][:value]
end
"""
emph_author(authors, author="", em="b")
Add emphasis to selected author display (e.g. for CV use)
"""
function emph_author(doi::AbstractDOI)
emph_author(strip(doi.author))
end
function emph_author(doi::EmDOI)
emph_author(strip(doi.author), doi.highlight)
end
function emph_author(authors, author="", em="b")
orcid = r", \d{4}-\d{4}-\d{4}-\d{4}"
authors = replace(authors, orcid => "")
if length(author) > 2
names = split(author)
lnfirst = names[end] * ", " * names[1]
short = names[end] * ", " * names[1][1] * "."
return replace(
replace(
replace(authors, author => "<$em>" * author * "</$em>"),
short => "<$em>" * short * "</$em>",
),
lnfirst => "<$em>" * lnfirst * "</$em>",
)
else
return authors
end
end
function strip(s)
return replace(s, r" \[(.*?)\]" => "")
end
function year(s)
return !isempty(s) && s != "" ? parse(Int, first(s, 4)) : s
end
| ShortCodes | https://github.com/hellemo/ShortCodes.jl.git |
|
[
"MIT"
] | 0.3.6 | 5844ee60d9fd30a891d48bab77ac9e16791a0a57 | code | 1117 | abstract type Kroki <: ShortCode end
function Base.show(io::IO, ::MIME"text/plain", kroki::Kroki)
print(
io,
kroki.text *
"\n" *
kroki(kroki.text, lowercase(String(nameof(typeof(kroki)))), "svg"),
)
end
function Base.show(io::IO, ::MIME"image/svg+xml", kroki::Kroki)
write(io, fetch_kroki(kroki.text, lowercase(String(nameof(typeof(kroki)))), "svg"))
end
struct GraphViz <: Kroki
text::String
end
struct Mermaid <: Kroki
text::String
end
struct PlantUML <: Kroki
text::String
end
struct BlockDiag <: Kroki
text::String
end
function kroki(krokitext, generator = "graphviz", format = "svg")
encoded = base64urlencode(compress(krokitext))
url = "https://kroki.io/$generator/$format/$encoded"
end
@memoize function fetch_kroki(krokitext, generator = "graphviz", format = "svg")
String(http_get(kroki(krokitext, generator, format)))
end
function base64urlencode(text)
str = base64encode(text)
return replace(replace(str, "/" => "_"), "+" => "-")
end
function compress(text)
return transcode(ZlibCompressor, codeunits(text))
end
| ShortCodes | https://github.com/hellemo/ShortCodes.jl.git |
|
[
"MIT"
] | 0.3.6 | 5844ee60d9fd30a891d48bab77ac9e16791a0a57 | code | 1149 | struct WebPage <: ShortCode
url::String
end
function Base.show(io::IO, ::MIME"text/plain", page::WebPage)
print(io, page.url)
end
function Base.show(io::IO, ::MIME"text/html", page::WebPage)
print(io, webpage(page.url))
end
function webpage(url = "", height = 400, width = 700, title = "")
htm =
"""<iframe src=" """ *
url *
""" " height=" """ *
string(height) *
""" " width=" """ *
string(width) *
""" " title=" """ *
title *
""" "></iframe>"""
return htm
end
struct Vimeo <: ShortCode
id::Integer
end
function Base.show(io::IO, ::MIME"text/plain", video::Vimeo)
print(io, "https://vimeo.com/$(video.id)")
end
function Base.show(io::IO, ::MIME"text/html", video::Vimeo)
write(io, vimeo(video.id))
end
@memoize function vimeo(video_url)
url = "https://vimeo.com/api/oembed.json?url=$(URIs.escapeuri(video_url))&maxheight=500&maxwidth=700&width=680&byline=false&portrait=false&title=false"
json = JSON3.read(http_get(url))
return json[:html]
end
function vimeo(video_id::Integer)
vimeo("https://vimeo.com/$video_id")
end
| ShortCodes | https://github.com/hellemo/ShortCodes.jl.git |
|
[
"MIT"
] | 0.3.6 | 5844ee60d9fd30a891d48bab77ac9e16791a0a57 | code | 585 | function twitter(id)
json = fetch_twitter(id)
return json[:html]
end
@memoize function fetch_twitter(id)
url = "https://publish.twitter.com/oembed?url=https://twitter.com/andypiper/status/$id"
json = JSON3.read(http_get(url))
end
struct Twitter <: ShortCode
id::Int64
end
function Base.show(io::IO, ::MIME"text/plain", tweet::Twitter)
json = fetch_twitter(tweet.id)
tweet_as_text = "$(json[:author_name]): $(json[:url])"
print(io, tweet_as_text)
end
function Base.show(io::IO, ::MIME"text/html", tweet::Twitter)
print(io, twitter(tweet.id))
end
| ShortCodes | https://github.com/hellemo/ShortCodes.jl.git |
|
[
"MIT"
] | 0.3.6 | 5844ee60d9fd30a891d48bab77ac9e16791a0a57 | code | 3967 |
struct YouTube <: ShortCode
id::String
seekto::Int32
end
function Base.show(io::IO, ::MIME"text/plain", video::YouTube)
video_as_text = "https://www.youtube.com/watch?v=$(video.id)&start=$(video.seekto)"
print(io, video_as_text)
end
function Base.show(io::IO, ::MIME"text/html", video::YouTube)
print(io, youtube(video.id, video.seekto))
end
YouTube(id, seektomin, seektosec) = YouTube(id, seektomin * 60 + seektosec)
YouTube(id) = YouTube(id, 0)
"""
Embed youtube video id that seeks seekto seconds into the video and pauses there to
make it possible to show a particular still from the video by default. Note that
the youtube API disallows hiding the annoying "More videos" overlay.
"""
@memoize function youtube(id, seekto)
vid = string(uuid1()) # Assign each video unique id to allow multiple instances.
htm =
"""
<div id=" """ *
vid *
""" "></div>
<script>
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player(' """ *
vid *
""" ', {
height: '390',
width: '640',
rel: '0',
showinfo: '0',
iv_load_policy: '3',
showinfo: '0',
videoId: '""" *
id *
"""',
//modestbranding: 1,
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.mute();
event.target.seekTo(""" *
string(seekto) *
""");
event.target.playVideo();
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 0);
done = true;
}
}
function stopVideo() {
player.pauseVideo();
}
// Check if YT is loaded before trying to start player
function pollYT () {
if (typeof(YT) == 'undefined') {
setTimeout(pollYT, 300); // try again in 300 milliseconds
} else {
onYouTubeIframeAPIReady();
}
}
pollYT();
</script>
"""
return htm
end
"""
Embed youtube video by id, seek to seektomin minutes and seektosek second in
"""
function youtube(id, seektomin, seektosec)
youtube(id, seektomin * 60 + seektosec)
end
"""
Embed youtube video by id, uses default oembed code with reasonable size.
"""
function youtube(id)
url = "https://youtube.com/oembed?url=http://www.youtube.com/watch?v=$id&format=json&maxwidth=600&maxheight=500"
json = JSON3.read(http_get(url))
return HTML(json[:html])
end
struct Flickr <: ShortCode
id::Integer
end
Flickr(url::String) = Flickr(parse(Int, split(url, "/")[6])) # This should be more robust
function Base.show(io::IO, ::MIME"text/plain", img::Flickr)
json = fetch_flickr(img.id)
flickr_as_text = "$(json[:author_name]): $(json[:title])\n$(json[:web_page])"
print(io, flickr_as_text)
end
function Base.show(io::IO, ::MIME"text/html", img::Flickr)
json = fetch_flickr(img.id)
print(io, json[:html])
end
@memoize function fetch_flickr(id)
url = "https://www.flickr.com/services/oembed/?format=json&url=http%3A//www.flickr.com/photos/bees/$id"
json = JSON3.read(http_get(url))
end
| ShortCodes | https://github.com/hellemo/ShortCodes.jl.git |
|
[
"MIT"
] | 0.3.6 | 5844ee60d9fd30a891d48bab77ac9e16791a0a57 | code | 659 | using ShortCodes
using Test
@testset "Kroki tests" begin
@test ShortCodes.kroki("digraph G {Hello->World}") == "https://kroki.io/graphviz/svg/eJxLyUwvSizIUHBXqPZIzcnJ17ULzy_KSakFAGxACMY="
end
@testset "DOI tests" begin
julia = DOI("10.1137/141000671")
@test julia.doi == "10.1137/141000671"
@test ShortDOI(julia).shortdoi == "10/f9wkpj"
@test length(split(julia.author,";")) == 4
@test julia.year == 2017
emjulia = EmDOI(julia, "Stefan Karpinski")
@test emjulia.highlight == "Stefan Karpinski"
io = IOBuffer()
show(io, MIME("text/html"), emjulia)
@test findfirst("<b>", String(take!(io)) ) == 37:39
end | ShortCodes | https://github.com/hellemo/ShortCodes.jl.git |
|
[
"MIT"
] | 0.3.6 | 5844ee60d9fd30a891d48bab77ac9e16791a0a57 | docs | 745 | # ShortCodes Release Notes
## v0.3.2 (2021-04-18)
* Add DOI support via [opencitations](https://opencitations.net) and [doi.org](https://doi.org)
* New types DOI, ShortDOI (using doi.org shortener) and EmDOI to emphasize one author.
## v0.3.1 (2021-04-11)
* Improve loading of YouTube videos
## v0.3.0 (2021-04-01)
* Breaking change: Factored out support for QR codes due to:
- Delays upstreaming fix for julia 1.6.0
- Lighten dependencies
- QR types arguably belongs in the package with the QR code implementation
* Added support for GraphViz, Mermaid, PlantUML and BlockDiags via [Kroki](https://kroki.io) web services.
* Added minimal testing
## v0.2.3 (2021-03-09)
* Registered version
## v0.2.0 (2021-02-21)
* Type based API | ShortCodes | https://github.com/hellemo/ShortCodes.jl.git |
|
[
"MIT"
] | 0.3.6 | 5844ee60d9fd30a891d48bab77ac9e16791a0a57 | docs | 1153 | # ShortCodes
Simply embed content in a [Pluto](https://github.com/fonsp/Pluto.jl) notebook using short codes, inspired by the [Hugo shortcodes](https://gohugo.io/content-management/shortcodes/).
The basic usage is shown below, check out the [example](https://raw.githack.com/hellemo/ShortCodes.jl/main/examples/static-demo.html) to get an impression of the resulting page.
## Usage
```julia
using ShortCodes
# Embed tweet by id
Twitter(1314967811626872842)
# Embed youtube video by id and seek to start
# time and pause to show custom still image
YouTube("IAF8DjrQSSk", 2, 30) # 2 min 30 sec
# Embed Flickr image by id (or by url)
Flickr(29110717138)
# Show DOI info from opencitations.net
DOI("10.1137/141000671")
```
## Note
* YouTube shows an overlay when the video is paused, promoting "more videos", and the API does not allow hiding it. A workaround is to [block the overlay using uBlock](https://www.reddit.com/r/firefox/comments/61y7lf/how_to_removedisable_more_videos_when_pausing_an/).
* Some browsers may block content from social media, e.g. Firefox may block Twitter embeds, check the settings of your browser if it doesn't load. | ShortCodes | https://github.com/hellemo/ShortCodes.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 62 | using Documenter, EasyVega
makedocs(sitename="Documentation") | EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 2065 | # generate values from a distribution
using Distributions, LinearAlgebra
using DataFrames
Σ = let X = randn(2,2); X * X' + I; end
d = MvNormal([1,1], Σ)
draws = rand(d, 100)
df = DataFrame(x = draws[1,:], y=draws[2,:])
# create Data object
dat = Data( values= df )
xscale = LinearScale(range="width", domain=dat.x, padding= 20)
yscale = LinearScale(range="height", domain=dat.y, padding= 20)
# create a Data object derived from 'dat' to calculate the density
density = Data(source=dat,
transform= [(
type= "kde2d",
x_expr = "scale('$xscale', datum.x)", # convert to pixel coordinates
y_expr = "scale('$yscale', datum.y)",
size= [(signal= "width",), (signal= "height",)], # output size
as= "grid"
)]
)
# create a Data object, derived from 'density', that will generate
# the iso contours
contours = Data(source=density,
transform= [( type= "isocontour",
field= "grid",
levels= 6
)]
)
# this mark shows a dot for each sample
pointmark = SymbolMark(
:x => xscale(dat.x),
:y => yscale(dat.y),
:size => 4,
)
# this mark plots an image, based on the density data
# the "heatmap" transform translates the density grid to an image
# (by default, it is the image opacity that varies with density, but
# color can be used as well)
densmark = ImageMark(from_data=density,
:x => 0,
:y => 0,
:width => (signal="width",),
:height => (signal="height",),
:aspect => false,
transform= [
(type="heatmap", field="datum.grid", color= :lightblue)
]
)
# this mark shows the density contours
contourmark = PathMark(from_data=contours,
clip= true,
:strokeWidth => 1,
:strokeOpacity => 0.5,
:stroke => :blue,
transform= [
(type="geopath", field="datum.contour")
]
)
vgspec = VG(width=400, height=400, background=:white, padding=10,
axes=[xscale(orient="bottom"), yscale(orient="left")],
marks= [pointmark, densmark, contourmark]
) | EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 1943 | using DataFrames
using EasyVega
# create dummy data
df = DataFrame(
x=rand([1,2,3,4],200),
y=rand([1,2,3,4],200),
c=rand([:A,:B,:C],200),
)
dat = Data(values = df)
xscale = BandScale(range="width", domain=dat.x, domain_sort=true)
yscale = BandScale(range="height", domain=dat.y, domain_sort=true)
cscale = OrdinalScale(range="category", domain=dat.c)
# Create facetting definition for the group mark
fc = Facet(groupby= [:x, :y], data=dat)
# In each facet,
# - count the number of occurences ('aggregate' transform)
# - calculate angles for the pie ('pie' transform)
fcdata = Data(source=fc,
transform=[
(type="aggregate", groupby=[:c], ops=["count"], as=[:count], fields=[:x])
(type="pie", field=:count)
]
)
# let's add some controls to change the chart appearance
sig1 = Signal(value=15, bind=(input=:range, min=0, max=50, step=1))
sig2 = Signal(value=30, bind=(input=:range, min=0, max=200, step=1))
# pie chart for each facet
rmark = ArcMark(
encode_enter=(
x= Signal("bandwidth('$xscale')/2"),
y= Signal("bandwidth('$xscale')/2"),
startAngle= fcdata.startAngle,
endAngle= fcdata.endAngle,
stroke= :black,
fill = cscale(fcdata.c)),
encode_update=(
innerRadius= sig1,
outerRadius= sig2,
)
)
gm = GroupMark(
encode_enter_x = xscale(fc.x),
encode_enter_y = yscale(fc.y),
marks=[rmark]
)
VG(width=400, height=400, padding=20, background= "#fed",
# force signals to be a root level (because they are linked to a control)
signals=[sig1, sig2],
axes = [
xscale(orient="bottom", grid=true, bandPosition=1, title="x"),
yscale(orient="left", grid=true, bandPosition=1, title="y") ],
marks= [ gm ],
# place a legend for the 'c' field
legends=[ (fill = cscale, title="type", titleFontSize=15) ]
) | EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 1547 | using EasyVega
# use the movies database from Vega examples
# filter out bad data
movies = Data(
url = "https://raw.githubusercontent.com/vega/vega-datasets/next/data/movies.json",
transform= [
(type= "filter",
expr= "datum['Rotten Tomatoes Rating'] != null && datum['IMDB Rating'] != null"
)
]
)
# control to change the bandwidth of the loess interpolation
loessBandwidth = Signal(
value= 0.3,
bind= (input= "range", min= 0.05, max= 1)
)
# create a loess interpolation
trend = Data(
source= movies,
transform= [
(
type= "loess",
# "groupby": [{"signal": "groupby === 'genre' ? 'Major Genre' : 'foo'"}],
bandwidth= (signal= loessBandwidth,),
x= "Rotten Tomatoes Rating",
y= "IMDB Rating",
as= ["u", "v"]
)
]
)
# define the scale (can't use the movies.xyz shortcut here because the field has spaces)
xscale = LinearScale(range="width", domain=(data=movies, field="Rotten Tomatoes Rating"))
yscale = LinearScale(range="height", domain=(data=movies, field="IMDB Rating"))
sma = SymbolMark(
from_data= movies,
:x => (scale= xscale, field="Rotten Tomatoes Rating"),
:y => (scale= yscale, field="IMDB Rating"),
:fillOpacity => 0.5,
:size => 16
)
lma = LineMark(
:x => xscale(trend.u),
:y => yscale(trend.v),
:stroke => :firebrick
)
VG(width=400, height=400, background=:white, padding= 20,
marks=[sma, lma],
axes=[xscale(orient="bottom"), yscale(orient="left")]
)
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 1865 | using EasyVega
# create a Data element with dummy numbers
dat = Data(
values = [
(x= 0, y= 28),
(x= 1, y= 43),
(x= 2, y= 81),
(x= 3, y= 19),
(x= 4, y= 52),
]
)
# group 1
grp1 = begin
xscale = LinearScale(range="width", domain=dat.x)
yscale = LinearScale(range="height", domain=dat.y)
lmark = LineMark( :x => xscale(dat.x), :y => yscale(dat.y))
# note that width and height have to be set in order for the group
# to render correctly
GroupMark(
axes = [ xscale(orient="bottom"), yscale(orient="left") ],
marks= [ lmark ],
:width => (signal="width",),
:height => (signal="height",),
)
end
# group 2
grp2 = begin
xscale = BandScale(range="width", domain=dat.x)
yscale = LinearScale(range="height", domain=dat.y)
lmark = RectMark(
:x => xscale(dat.x), :width => xscale(band=1, offset=-1),
:y => yscale(0), :y2 => yscale(dat.y),
:fill => :orange
)
GroupMark(
axes = [ xscale(orient="bottom"), yscale(orient="left") ],
marks= [ lmark ] ,
:width => (signal="width",),
:height => (signal="height",),
)
end
# group 3
grp3 = begin
# translate y value to angles for the pie chart
fcdata = Data(source=dat,
transform=[ (type="pie", field=:y) ] )
rmark = ArcMark(
:x => (signal="width/2",),
:y => (signal="height/2",),
:startAngle => fcdata.startAngle,
:endAngle => fcdata.endAngle,
:stroke => :black,
:fill => :lightgreen,
:outerRadius => 100,
)
GroupMark(
marks= [ rmark ]
)
end
VG(width=200, height=200, padding=20, background= "white",
layout= (columns=2, padding=20),
marks= [ grp1, grp2, grp3 ],
)
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 2622 | # example adapted from https://vega.github.io/editor/#/examples/vega/packed-bubble-chart
using EasyVega
cx = Signal(update= "width / 2")
cy = Signal(update= "height / 2")
gravityX = Signal(
value= 0.2,
bind= (input="range", min=0, max=1)
)
gravityY = Signal(
value= 0.1,
bind= (input="range", min=0, max=1)
)
table = Data(values=[
(category= "A", amount= 0.28),
(category= "B", amount= 0.55),
(category= "C", amount= 0.43),
(category= "D", amount= 0.91),
(category= "E", amount= 0.81),
(category= "F", amount= 0.53),
(category= "G", amount= 0.19),
(category= "H", amount= 0.87),
(category= "I", amount= 0.28),
(category= "J", amount= 0.55),
(category= "K", amount= 0.43),
(category= "L", amount= 0.91),
(category= "M", amount= 0.81),
(category= "N", amount= 0.53),
(category= "O", amount= 0.19),
(category= "P", amount= 0.87)
])
siz = LinearScale(domain= table.amount, range=[100,3000])
color = OrdinalScale(domain= table.category, range="ramp")
# The bubbles
nodes = SymbolMark(
:fill => color(table.category),
:xfocus => (signal= cx,),
:yfocus => (signal= cy,),
:update_size => siz(signal= "pow(2 * datum.amount, 2)"),
:update_stroke => "white",
:update_strokeWidth => 1,
:update_tooltip => (signal= "datum",),
# apply a force transform (both attrative toward center, and repulsive to avoid collisions)
transform= [
(
type= "force",
iterations= 100,
static= false,
forces= [
(force= "collide", iterations= 2, radius_expr= "sqrt(datum.size) / 2"),
(force= "center", x= (signal= cx,), y= (signal= cy,)),
(force= "x", x= "xfocus", strength= (signal= gravityX,)),
(force= "y", y= "yfocus", strength= (signal= gravityY,))
]
)
]
)
# Textmark to show the category name
# this textmark is not based on a Data but on another Mark : nodes.
# Mark as sources allow to modify / annotate the mark, here we are
# printing a letter at the center of the bubble.
txtmark = TextMark(
# need to be specific here for the from_data field because the source is
# another mark not data.
from_data = nodes,
:align => "center",
:baseline => "middle",
:fontSize => 15,
:fontWeight => "bold",
:fill => "white",
# 'x' and 'y' channels of the mark source appear as fields ,
# 'category' is from the data source of the mark, hence the 'datum.category'
:text => (field= "datum.category",),
:update_x => (field= :x,),
:update_y => (field= :y,),
)
VG( width= 400, height=400,
padding= 20, background= "white",
autosize= "none",
marks= [ nodes, txtmark]
)
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 1324 | using EasyVega
# create dummy data and use the 'stack' transform to generate
# the coordinates (y0, y1) for the stacked objects
dat = Data(
values = [
(x= 0, y= 28, c='A'), (x= 0, y= 20, c='B'),
(x= 1, y= 43, c='A'), (x= 1, y= 35, c='B'),
(x= 2, y= 81, c='A'), (x= 2, y= 10, c='B'),
(x= 3, y= 19, c='A'), (x= 3, y= 15, c='B'),
(x= 4, y= 52, c='A'), (x= 4, y= 48, c='B'),
(x= 5, y= 24, c='A'), (x= 5, y= 28, c='B'),
],
transform=[
(type="stack", groupby=[:x], sort_field=:c, field=:y)
]
)
xscale = BandScale(range="width", domain=dat.x)
yscale = LinearScale(range="height", domain=dat.y1, nice=true, zero=true)
cscale = OrdinalScale(range="category", domain=dat.c)
# Rect mark, with some reactivity on hover
rmark = RectMark(
:x => xscale(dat.x),
:width => xscale(band=1, offset=-1),
:y => yscale(dat.y0),
:y2 => yscale(dat.y1),
:fill => cscale(dat.c),
:update_fillOpacity => 1,
:hover_fillOpacity => 0.5,
)
VG(width=400, height=300, padding=30, background= "#fed",
axes = [
xscale(orient="bottom", offset=10),
yscale(orient="left", offset=10)
],
marks= [ rmark ] )
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 1039 | using EasyVega
# create a Data element with dummy numbers
dat = Data(
values = [
(x= 0, y= 28),
(x= 1, y= 43),
(x= 2, y= 81),
(x= 3, y= 19),
(x= 4, y= 52),
]
)
# create the horizontal scale, mapping the width of the plotting area to
# the extent of the 'x' field values in Data element 'dat'
xscale = LinearScale(range="width", domain=dat.x)
# same for the vertical scale
yscale = LinearScale(range="height", domain=dat.y)
# create the mark, of type 'line', mapping the x of the mark to
# the scaled field 'x' of data and the y to the scaled 'y' field of data
lmark = LineMark(
encode_enter=(
x= xscale(dat.x),
y= yscale(dat.y),
),
)
# wrap up everything and render with the VG() function
VG(
width=300, height=200, background="white",
# add axes at the bottom and left side of the graph
axes = [ xscale(orient="bottom"), yscale(orient="left") ],
# specify the mark to show
marks= [ lmark ]
)
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 1241 | # Adapted from https://vega.github.io/editor/#/examples/vega/sunburst
using EasyVega
tree = Data(
url= "https://raw.githubusercontent.com/vega/vega-datasets/next/data/flare.json",
transform= [
( type= "stratify", key= "id", parentKey= "parent" ),
( type= "partition",
field= "size",
sort= (field= "value",),
size= [(signal= "2 * PI",), (signal= "width / 2",)],
as= ["a0", "r0", "a1", "r1", "depth", "children"]
)
])
color = OrdinalScale(domain = tree.depth, range_scheme= "tableau20")
rma = ArcMark(
:x => (signal= "width / 2",),
:y => (signal= "height / 2",),
:fill => color(tree.depth),
:tooltip => (signal= "datum.name + (datum.size ? ', ' + datum.size + ' bytes' : '')",),
:update_startAngle => tree.a0,
:update_endAngle => tree.a1,
:update_innerRadius => tree.r0,
:update_outerRadius => tree.r1,
:update_stroke => "#222",
:update_strokeWidth => 1,
:update_strokeOpacity => 0.2,
:update_zindex => 0,
# on hover highlight perimeter in red
:hover_stroke => "red",
:hover_strokeWidth => 2,
:hover_zindex => 1
)
VG( width=400, height=400, background= :white,
padding=5, #autosize="none",
maks = [rma]
)
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 2193 | # Adapted from https://vega.github.io/editor/#/examples/vega/tree-layout
using EasyVega
# some controls on the tree appearance
labels = Signal(
value= true,
bind= (input="checkbox",)
)
layout = Signal(
value= "tidy",
bind=(input="radio", options= ["tidy", "cluster"])
)
linkshape = Signal(
value= "diagonal",
bind= (input="radio", options= ["line", "curve", "diagonal", "orthogonal"])
)
separation = Signal(
value= false,
bind= (input="checkbox",)
)
# take the data, stratify it and generate tree
tree = Data(
url= "https://raw.githubusercontent.com/vega/vega-datasets/next/data/flare.json",
transform= [
( type= "stratify", key= "id", parentKey= "parent" ),
( type= "tree",
method= (signal= layout,),
size= [(signal= "height",), (signal= "width - 100",)],
separation= (signal= separation,),
as= ["y", "x", "depth", "children"]
)
])
# create link paths from tree data
links = Data(
source= tree,
transform= [
(type= "treelinks",),
(type= "linkpath", orient= "horizontal", shape= (signal= linkshape,) ),
]
)
color = OrdinalScale(domain = tree.depth,
range_scheme= "magma", zero=true)
# text marks
tma = TextMark(
:text => tree.name,
:fontSize => 9,
:baseline => "middle",
:update_x => tree.x,
:update_y => tree.y,
:update_dx => (signal= "datum.children ? -7 : 7",),
:update_align => (signal= "datum.children ? 'right' : 'left'",),
:update_opacity => (signal= "$labels ? 1 : 0",)
)
# dots for graph vertices
sma = SymbolMark(
:size => 100,
:stroke => "#fff",
:update_x => tree.x,
:update_y => tree.y,
:update_fill => color(tree.depth),
)
# paths for graph edges
pma = PathMark(
:update_path => links.path,
:update_stroke => "#ccc",
)
# EasyVega is not picking up the use of signals in expressions
# (for example the labels signal used in the TextMark to show/hide labels)
# for this reason, they are explicitly mentionned in VG.
VG( width=800, height=1600, background= :white,
padding=10, autosize="none",
signals=[labels, layout, linkshape, separation],
marks = [tma, sma, pma]
)
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 1259 | using DataFrames
using EasyVega
# Data with dummy color categories
dat = Data( values= DataFrame(color= rand("ABCD", 30)) )
cscale = OrdinalScale(range="category",
domain=dat.color, domain_sort= true)
# create points, with forces for collision avoidance, and attracted
# to plot center
pointmark = SymbolMark(
clip=true, zindex=1,
:size => 10, :fill => :black,
:cellColor => cscale(dat.color),
transform=[
(
type= "force",
static= false,
forces= [
(force= "collide", iterations= 2, radius=25),
(force= "center", x= 200, y= 200),
]
)
]
)
# Show voronoi cells based point marks
vormark = PathMark(from_data=pointmark,
clip= true, zindex=0,
:update_strokeWidth => 1,
:update_strokeOpacity => 0.5,
:update_stroke => :black,
:fill => (signal= "datum.cellColor",),
transform= [( type="voronoi",
x= "datum.x", y="datum.y",
size=[(signal= "width",), (signal= "height",)]
)]
)
vgspec = VG(width=400, height=400, background=:white, padding=10,
legends=[ (fill = cscale, title="color", titleFontSize=15) ],
marks= [pointmark, vormark ]
) | EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 1190 | using EasyVega
tx = Signal("width / 2")
ty = Signal("height / 2")
# Projections define how the lat / longitude coordinates should be
# translated 2d coordinates
# see https://vega.github.io/vega/docs/projections/
proj = Projection(
type= "orthographic",
scale= 220,
rotate= [0, 0, 0],
center= [40, 32],
translate= [(signal= tx,), (signal= ty,)]
)
# Graticules are the reference grid for maps
graticule = Data(
transform= [ (type= "graticule", step= [15,15]) ]
)
gratm = ShapeMark(
from_data = graticule,
:strokeWidth => 2,
:stroke => "#ddd",
:fill => nothing,
transform = [ (type="geoshape", projection= proj) ]
)
# pull up a world map from vega example data
world = Data(
url= "https://raw.githubusercontent.com/vega/vega-datasets/next/data/world-110m.json",
format= (
type= "topojson",
feature= "countries"
)
)
worldm = ShapeMark(
from_data = world,
:strokeWidth => 2,
:stroke => "#999",
:fill => "#efd",
transform = [ (type="geoshape", projection= proj) ]
)
VG(width=300, height=300, background=:white, autosize="none",
marks=[gratm, worldm]
)
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 262 |
module EasyVega
using JSON, Dates, Random
using Graphs, MetaGraphsNext
import Tables
include("VGTrie.jl")
include("VGElement.jl")
include("scales.jl")
include("marks.jl")
include("data.jl")
include("misc_named.jl")
include("VG.jl")
include("io.jl")
end
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 4484 | ################# VG ##########################################################
# final Element, collects named VGElements (Signal, Data, Scale, ..) and
# places their definitions at the right place in the trie
export VG
function VG(;nargs...)
f = VGElement{:final}(;nargs...)
deps = depgraph(f)
# skip everything if no dependency (i.e a fully explicit spec is given)
(nv(deps)==0) && return f
# We iteratively update 'positions' which is a vector giving a
# candidate position for the definition of each named element.
# Positions are initialized with their path in the dependency graph between
# the root element VG and the element.
# Positions are updated (by moving up toward the root) to ensure they are at or
# before the definition of the elements depending on it (except if its
# position is fixed)
# We stop when necessary updates are exhausted (i.e the positions are
# consistent)
#### initialize
isfixed = Set( i for i in vertices(deps) if deps[label_for(deps,i)] )
# println(isfixed)
paths = dijkstra_shortest_paths(deps, code_for(deps, f))
positions = enumerate_paths(paths)
# println(positions)
anymoved = true
children = [ inneighbors(deps, i) for i in 1:nv(deps) ]
while anymoved
anymoved = false
for (i, path) in enumerate(positions)
if (length(children) > 0) && (length(path) > 0) && !(i in isfixed)
minpath = mincommonindex(positions[children[i]]...)
if minpath != path
anymoved = true
positions[i] = minpath
# ppath = map(i->label_for(deps,i), path)
# pminp = map(i->label_for(deps,i), minpath)
# println("$(label_for(deps,i)) : $(join(ppath, "/")) => $(join(pminp, "/"))")
end
end
end
end
# find the closest group to the candidate path to put the definition in
defpos = Dict{VGElement, VGElement}()
groups = Set( i for i in 1:nv(deps) if kindof(label_for(deps,i)) in [:final, :Group] )
# println(groups)
for (i,path) in enumerate(positions)
(i == code_for(deps, f)) && continue # skip root
if length(path) < 2
gr = f
else
# groups need to go up 1 level
ppaths = (i in groups) ? path[1:end-1] : path[1:end]
idx = findlast( ip in groups for ip in ppaths )
gr = label_for(deps, path[idx])
end
el = label_for(deps, i)
# println("$el in $gr")
defpos[el] = gr
end
# println(defpos)
#### now we insert the definitions at the indicated place
# arrange by destination group and element type
gtyped = Dict{VGElement, Any}()
for (e, gr) in defpos
haskey(gtyped, gr) || ( gtyped[gr] = Dict{Symbol, Vector}() )
typ = DefName[ kindof(e) ]
if typ !== nothing # skip facets
haskey(gtyped[gr], typ) || ( gtyped[gr][typ] = [] )
push!(gtyped[gr][typ], e)
end
end
# sort within vectors to respect potential dependence (eg between data, between marks)
ord = sortperm(topological_sort(deps))
for (_, d) in gtyped
for (_, v) in d
sort!(v, by= g -> ord[code_for(deps,g)], rev=true)
end
end
# now insert defs
tr = rebuildwithdefs(f, gtyped)
for (k, v) in tr.children
trie(f).children[k] = v
end
f
end
# recursive insertion, without tracking
function rebuildwithdefs(group::VGElement, gtyped)
tr = trie(group)
for (typ, es) in gtyped[group]
for (i, d) in enumerate(es)
# in definitions vectors, remove references, to leave room for the def trie
haskey(tr, [typ, i]) && (subtrie(tr, [typ, i]).is_key = false )
t2 = (kindof(d) == :Group) ? rebuildwithdefs(d, gtyped) : trie(d)
for k in keys(t2)
tr[vcat([typ, i], k)] = t2[k]
end
# for (k, v) in tr.children
# tr[[typ, i]].children[k] = v
# end
tr[[typ, i, :name]] = idof(d) # add their name
end
end
tr
end
# find largest common path
function mincommonindex(vs...)
(length(vs) == 1) && return vs[1]
nk = []
for i in 1:minimum(length, vs)
any( vs[1][i] != vs[j][i] for j in 2:length(vs) ) && break
push!(nk, vs[1][i])
end
nk
end | EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 5209 | ######## VGElements ############################################################
# this is the type for Data, Scale, Signal, (the named elements), other generic
# tree branches and the final graph definition VG
# - they can implement syntax shortcuts (data.x, scale(...), etc.. )
# - they have an id, used for reference in final VG
# - they hold their dependencies to other elements in the tracking field
elements_counter = 1
struct VGElement{T}
__trie::VGTrie
__tracking
__id::Int
function VGElement{T}(trie::VGTrie, tracking) where {T}
global elements_counter
elements_counter += 1
new(trie, tracking, elements_counter)
end
end
function idof(s::VGElement{T}) where T
prefix = String(T)[1:2]
n = s.__id
"$prefix$n"
end
kindof(::VGElement{T}) where T = T
trie(e::VGElement) = e.__trie
depgraph(e::VGElement) = e.__tracking.depgraph
# valid value for tree leaves
const LeafType = Union{
AbstractString,
Symbol,
Char,
Number,
Date, DateTime, Time,
Nothing
}
# general constructor
function VGElement{T}(;nargs...) where T
e = VGElement{T}( VGTrie{LeafType}(Symbol), Tracking() )
for (k,v) in nargs
sk = Symbol.(split(String(k), "_")) # split by symbol separated by "_"
insert!(e, sk, v)
end
e
end
function Base.insert!(e::VGElement, index::Vector, item::LeafType)
trie(e)[index] = item
end
function Base.insert!(e::VGElement, index::Vector, items::NamedTuple)
for (k,v) in pairs(items)
sk = Symbol.(split(String(k), "_")) # split by symbol separated by "_"
insert!(e, vcat(index, sk), v)
end
end
function Base.insert!(e::VGElement, index::Vector, items::Vector)
for (i,v) in enumerate(items)
insert!(e, vcat(index, [i]), v)
end
end
function Base.insert!(e::VGElement, index::Vector, item::VGElement{T}) where {T}
if isnamed(item) # only insert reference to it, not the whole thing
insert!(e, index, idof(item))
else
# add the trie to the trie of e
for k in keys(trie(item))
insert!(e, vcat(index, k), trie(item)[k])
end
end
updateTracking!(e, index, item)
end
# catch remaining types
function Base.insert!(e::VGElement, index::Vector, item::T) where T
if Tables.istable(item)
# do not use insert! here because we don't want to split table field names
# on '_' as insert! does by default
for (i,row) in enumerate(Tables.rowtable(item))
for (k,v) in pairs(row)
insert!(e, [index; i; k], v)
end
end
else
error("type $T not allowed")
end
end
## By default, print the id of the spec
function Base.show(io::IO, t::VGElement)
print(io, idof(t))
end
################ named VGElements ###########################################
# map from named VGElement type to definition field
DefName = Dict(
:Mark => :marks,
:Signal => :signals,
:Scale => :scales,
:Data => :data,
:Facet => nothing, # this one goes in GroupMarks, no def necessary
:Group => :marks,
:Projection => :projections,
:Style => :config, # FIXME: should go in config/styles
)
isnamed(e::VGElement{T}) where {T} = T in keys(DefName)
####### reference and group tracking #########################################
struct Tracking
depgraph::MetaGraph # dependency graph between elements
end
Tracking() = Tracking(
MetaGraph(DiGraph(), label_type= VGElement, vertex_data_type= Bool),
)
function Base.show(io::IO, t::Tracking)
deps = t.depgraph
labs = [ "$(label_for(deps, i))" for i in 1:nv(deps) ]
println(io, "nodes :")
println(io, labs)
println(io, "dependencies :")
println(io, [ "$(labs[e.src]) -> $(labs[e.dst])" for e in edges(deps)])
end
function addDependency(g::MetaGraph, a::VGElement, b::VGElement)
haskey(g, a) || add_vertex!(g, a, false)
haskey(g, b) || add_vertex!(g, b, false)
add_edge!(g, a, b, nothing)
end
function updateTracking!(e::VGElement, index::Vector, item::VGElement)
depg = depgraph(e)
ndepg = depgraph(item)
#### update dependency graph with depgraph of item
for edg in edges(ndepg)
a = label_for(ndepg, edg.src)
b = label_for(ndepg, edg.dst)
if (a == item) && !isnamed(item) # link to e directly
addDependency(depg, e, b)
else
addDependency(depg, a, b)
end
end
# add the item itself to dependencies of e
isnamed(item) && addDependency(depg, e, item)
#### update fixed flag
for iel in vertices(ndepg)
el = label_for(ndepg, iel)
haskey(depg, el) && (depg[el] = ndepg[el])
end
# mark this item as fixed if we are in a definition
if isdef(e, index) && isnamed(item)
depg[item] = true
end
end
function isdef(e::VGElement, index::Vector, allowedtypes=values(DefName))
(length(index) == 2) || return false
isa(index[end], Int) || return false
(index[end-1] in allowedtypes) || return false
# check now that we are in root node or a GroupMark
(kindof(e) == :final) && return true
(kindof(e) == :Group) && return true
return false
end | EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 4171 | # Like a Trie but with indexing that is either a symbol (for named fields)
# or an Int (for vectors)
# -- adapted from DataStructures.jl --
mutable struct VGTrie{T}
value::T
children::Union{ Dict{Symbol,VGTrie{T}}, Dict{Int,VGTrie{T}}}
is_key::Bool
function VGTrie{T}(typ::DataType) where T
self = new{T}()
self.children = Dict{typ,VGTrie{T}}()
self.is_key = false
return self
end
end
keytype(::Dict{A,B}) where {A,B} = A
function Base.setindex!(t::VGTrie{T}, val, key::Vector) where T
value = convert(T, val) # we don't want to iterate before finding out it fails
node = t
for (i, token) in enumerate(key)
# check that token is of the right type (Symbol / Int) for the node
# println(eltype(node.children))
ctyp = keytype(node.children)
if typeof(token) != ctyp
error("invalid key type : $token is not a $ctyp")
end
if !haskey(node.children, token)
nexttyp = (i < length(key)) ? typeof(key[i+1]) : Symbol # FIXME
node.children[token] = VGTrie{T}(nexttyp)
end
node = node.children[token]
end
node.is_key = true
node.value = value
end
function Base.getindex(t::VGTrie, key::Vector)
node = subtrie(t, key)
if (node !== nothing) && node.is_key
return node.value
end
throw(KeyError("key not found: $key"))
end
function subtrie(t::VGTrie, prefix::Vector)
node = t
for sym in prefix
if !haskey(node.children, sym)
return nothing
else
node = node.children[sym]
end
end
return node
end
function Base.haskey(t::VGTrie, key::Vector)
node = subtrie(t, key)
(node !== nothing) && node.is_key
end
function Base.get(t::VGTrie, key::Vector, notfound)
node = subtrie(t, key)
if (node !== nothing) && node.is_key
return node.value
end
return notfound
end
function Base.keys(t::VGTrie, prefix::Vector=[], found=[])
if t.is_key
push!(found, prefix)
end
for (sym,child) in t.children
keys(child, [prefix; sym], found)
end
return found
end
function keys_with_prefix(t::VGTrie, prefix::Vector)
st = subtrie(t, prefix)
(st !== nothing) ? keys(st, prefix) : []
end
##### printing #######################################
## By default, print the tree of the spec
function Base.show(io::IO, t::VGTrie)
# printtrie(io, t)
vs = toStrings(t)
for v in vs
println(io, v)
end
end
# function printtrie(io::IO, t::VGTrie; indent=0)
# spaces = " " ^ indent
# t.is_key && print(io, ": ", t.value)
# if length(t.children) > 0
# print(io, " (")
# for k in keys(t.children)
# print(io, spaces, " ", k)
# printtrie(io, t.children[k], indent=indent+2)
# end
# print(io, " )")
# end
# println(io)
# end
function toStrings(t::VGTrie)::Vector
t.is_key && (length(t.children) > 0) && error("malformed trie")
if t.is_key
io = IOBuffer()
printstyled(IOContext(io, :color => true, :compact => true),
t.value, color=:yellow)
res = [ String(take!(io)) ]
else
ks = sort(collect(keys(t.children)))
if length(ks) > 20 # shorten long arrays
ks = [ ks[1:5] ; nothing ; ks[end-4:end] ]
end
res = AbstractString[]
for k in ks
if (k === nothing) # ellipsis for long arrays
vs = ["..."]
else
vs = toStrings(t.children[k])
if length(vs) > 1 # multiline result
vs = vcat([ "$k: "], [ " ." * v for v in vs ])
else # single line
vs[1] = "$k: " * vs[1]
end
end
append!(res, vs)
end
# if all of res can be squeezed in a single line, do it
if !isempty(res)
if sum(length, res) < 80
res = [ "(" * join(res, ", ") * ")" ]
else
res = [ " " * v for v in res]
end
end
end
res
end
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 1090 | ############# Data & Facets #################################################
# Facets, as Data, define a data source for marks but their definition go into
# the 'from' field of Group marks
export Data, Facet
const Data = VGElement{:Data}
const Facet = VGElement{:Facet}
"""
Data(), Facet()
Create a Data/Facet element. [Vega docs](https://vega.github.io/vega/docs/data/)
Arguments can be named arguments describing the data structure. All Julia objects
thta comply with the Tables interface can be used as values.
# Examples
```julia
using DataFrames
N = 100
tb = DataFrame(x=randn(N), y=randn(N), a=rand("ABC", N))
mydata = Data(values=tb)
```
"""
Data, Facet
# translate data.sym into {data="dataname", field = "sym"}
function Base.getproperty(d::Union{Data,Facet}, sym::Symbol)
# treat VGElement fieldnames as usual
(sym in fieldnames(VGElement)) && return getfield(d, sym)
# TODO : throw error for data colums named "__tracking" or "__trie" or "__id"
f = VGElement{:generic}()
insert!(f, [:field], sym)
insert!(f, [:data], d)
f
end
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 4062 | function toJSON(io::IO, t::VGTrie)
if t.is_key
toJSON(io, t.value)
elseif keytype(t.children) == Symbol
print(io, "{")
sep = false
for k in sort(collect(keys(t.children)))
sep && print(io, ",")
toJSON(io, k)
print(io, ":")
toJSON(io, t.children[k])
sep = true
end
print(io, "}")
else
print(io, "[")
sep = false
for k in sort(collect(keys(t.children)))
sep && print(io, ",")
toJSON(io, t.children[k])
sep = true
end
print(io, "]")
end
end
toJSON(io::IO, v::AbstractString) = print(io, "\"$v\"")
toJSON(io::IO, v::Char) = print(io, "\"$v\"")
toJSON(io::IO, v::Symbol) = print(io, "\"$v\"")
toJSON(io::IO, v::Number) = print(io, "$v")
function toJSON(io::IO, v::DateTime)
dtu = Dates.datetime2unix(v)*1000
dtu = round(Int64, dtu)
print(io, "$dtu")
end
toJSON(io::IO, v::Date) = toJSON(io, DateTime(v))
toJSON(io::IO, v::Time) = print(io, "\"$v\"")
toJSON(io::IO, v::Nothing) = print(io, "null")
function Base.show(io::IO, m::MIME"text/plain", v::VGElement{:final})
show(io, trie(v)) # do not show refs
return
end
# function Base.show(io::IO, v::AbstractVegaSpec)
# if !get(io, :compact, true)
# Vega.printrepr(io, v, include_data=:short)
# else
# print(io, summary(v))
# end
# return
# end
# function convert_vg_to_x(v::VGSpec, script)
# full_script_path = joinpath(vegalite_app_path, "node_modules", "vega-cli", "bin", script)
# p = open(Cmd(`$(nodejs_cmd()) $full_script_path -l error`, dir=vegalite_app_path), "r+")
# writer = @async begin
# our_json_print(p, v)
# close(p.in)
# end
# reader = @async read(p, String)
# wait(p)
# res = fetch(reader)
# if p.exitcode != 0
# throw(ArgumentError("Invalid spec"))
# end
# return res
# end
# function convert_vg_to_svg(v::VGSpec)
# vg2svg_script_path = joinpath(vegalite_app_path, "vg2svg.js")
# p = open(Cmd(`$(nodejs_cmd()) $vg2svg_script_path`, dir=vegalite_app_path), "r+")
# writer = @async begin
# our_json_print(p, v)
# close(p.in)
# end
# reader = @async read(p, String)
# wait(p)
# res = fetch(reader)
# if p.exitcode != 0
# throw(ArgumentError("Invalid spec"))
# end
# return res
# end
Base.Multimedia.istextmime(::MIME{Symbol("application/vnd.vega.v5+json")}) = true
function Base.show(io::IO, m::MIME"application/vnd.vega.v5+json", v::VGElement{:final})
toJSON(io, trie(v))
end
# function Base.show(io::IO, m::MIME"image/svg+xml", v::VGSpec)
# print(io, convert_vg_to_svg(v))
# end
# function Base.show(io::IO, m::MIME"application/vnd.julia.fileio.htmlfile", v::VGSpec)
# writehtml_full(io, v)
# end
# function Base.show(io::IO, m::MIME"application/prs.juno.plotpane+html", v::VGSpec)
# writehtml_full(io, v)
# end
Base.showable(m::MIME"text/html", v::VGElement{:final}) = isdefined(Main, :PlutoRunner)
function Base.show(io::IO, m::MIME"text/html", v::VGElement{:final})
writehtml_partial_script(io, v)
end
"""
Creates a HTML script + div block for showing the plot (typically for Pluto).
VegaLite js files are loaded from the web using script tags.
"""
function writehtml_partial_script(io::IO, v::VGElement{:final})
divid = "vg" * randstring(10)
print(io, """
<style media="screen">
.vega-actions a {
margin-right: 10px;
font-family: sans-serif;
font-size: x-small;
font-style: italic;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
<div id="$divid"></div>
<script>
var spec = """
)
toJSON(io, trie(v))
print(io,"""
;
var opt = {
mode: "vega",
renderer: "svg",
actions: true
};
vegaEmbed("#$divid", spec, opt);
</script>
""")
end
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 7440 | ########### Marks #########################################################""
export ArcMark, AreaMark, GroupMark, ImageMark, LineMark, PathMark, RectMark,
RuleMark, ShapeMark, SymbolMark, TextMark, TrailMark
const Mark = VGElement{:Mark}
const Group = VGElement{:Group}
"""
ArcMark(), AreaMark(), GroupMark(), ImageMark(), LineMark(), PathMark(), RectMark(),
RuleMark(), ShapeMark(), SymbolMark(), TextMark(), TrailMark()
Create a mark of a specific type. [Vega docs](https://vega.github.io/vega/docs/marks/)
Arguments can be named arguments describing the mark structure. Pairs can be passed as
positional arguments to define channel encodings : `:x => scale(data.a)`.
# Examples
```julia
sm = SymbolMark(shape="circle",
:xc => xscale(dat.x),
:yc => dat.y,
:stroke => cscale(dat.a),
)
```
"""
ArcMark, AreaMark, GroupMark, ImageMark, LineMark, PathMark, RectMark, RuleMark, ShapeMark, SymbolMark, TextMark, TrailMark
ArcMark(pargs...;nargs...) = preMark(pargs...;type=:arc, nargs...)
AreaMark(pargs...;nargs...) = preMark(pargs...;type=:area, nargs...)
ImageMark(pargs...;nargs...) = preMark(pargs...;type=:image, nargs...)
LineMark(pargs...;nargs...) = preMark(pargs...;type=:line, nargs...)
PathMark(pargs...;nargs...) = preMark(pargs...;type=:path, nargs...)
RectMark(pargs...;nargs...) = preMark(pargs...;type=:rect, nargs...)
RuleMark(pargs...;nargs...) = preMark(pargs...;type=:rule, nargs...)
ShapeMark(pargs...;nargs...) = preMark(pargs...;type=:shape, nargs...)
SymbolMark(pargs...;nargs...) = preMark(pargs...;type=:symbol, nargs...)
TextMark(pargs...;nargs...) = preMark(pargs...;type=:text, nargs...)
TrailMark(pargs...;nargs...) = preMark(pargs...;type=:trail, nargs...)
### specialized inserts for Marks
# translates encodings to valid Vega spec
function Base.insert!(e::Union{Mark,Group}, index::Vector, item::VGElement)
# println(index, " -- ", item)
if (index[1] == :encode) && (length(index) == 3)
if kindof(item) == :Signal
insert!( e, index, (signal= idof(item),) )
else
# check if there is a :data field and remove it
if haskey(trie(item), [:data])
dat = pop!(trie(item).children, :data)
# println("removed $dat")
end
# add the trie to the trie of e
for k in keys(trie(item))
insert!(e, vcat(index, k), trie(item)[k])
end
end
else
if isnamed(item) # only insert reference to it, not the whole thing
trie(e)[index] = idof(item)
else
# add the trie to the trie of e
for k in keys(trie(item))
insert!(e, vcat(index, k), trie(item)[k])
end
end
end
updateTracking!(e, index, item)
end
function Base.insert!(e::Union{Mark,Group}, index::Vector, item::LeafType)
# println(index, " - ", item)
if (index[1] == :encode) && (length(index) == 3)
trie(e)[[index; :value]] = item
else
trie(e)[index] = item
end
end
### translate positional args to named arguments
# (e.g pairs for channel encodings )
function convertposargs(pargs...)
is = []
if !isempty(pargs)
# check positional args
all( p isa Pair for p in pargs ) ||
error("positional arguments in marks should be pairs : channel => value / field / signal")
for p in pargs
ne = 1 + count( c -> c == '_', String(p.first) )
if ne == 1 # add the default "enter" encoding set when none is specified
k = Symbol("encode_enter_" * String(p.first))
elseif ne == 2
k = Symbol("encode_" * String(p.first))
elseif ne > 2
error("invalid channel spec : $(p.first)")
end
push!(is, k => p.second )
end
end
is
end
function preMark(pargs...;nargs...)
is = convertposargs(pargs...) # process positional args to convert to named arguments
### create VGElement
e = VGElement{:Mark}(; nargs..., is...)
# if no "from/data" is specified, create it
if ! haskey(trie(e), [:from, :data])
# look for facets or data
# TODO: improve search to only take data/facet that are used for encode (and skip used those in scales for example)
deps = depgraph(e)
dorf = [ label_for(deps,i) for i in outneighbors(deps, code_for(deps, e)) ]
filter!(e -> kindof(e) in [:Facet, :Data], dorf)
if length(dorf) > 1
error("multiple data/facets used in this mark : $dorf")
elseif length(dorf) == 1
insert!(e, [:from, :data], idof(dorf[1]))
end
end
e
end
### group mark ###############################################################
"""
GroupMark([ Pairs[] ]; [ named arguments ])
Create a group mark.
Group marks are higher level marks that can contain other marks. They can also
contain all the definitions that the root Vega spec can contain (definitions for
axes, legends, title, etc.).
# Example
```julia
gm = GroupMark(
signals=[sig1, sig2],
axes = [ xscale(orient="bottom"), yscale(orient="left") ],
legends=[ (fill = cscale, title="type", titleFontSize=15) ],
marks= [ linemark, pointmark ],
)
```
"""
function GroupMark(pargs...; nargs...)
is = convertposargs(pargs...) # process positional args to convert to named arguments
### create VGElement
e = VGElement{:Group}(type=:group; nargs..., is...)
# handle the "from" field
# - if set by user => use that, do not touch
# - if facets present, use first, throw warning if several
# - if no facet, use data
if subtrie(trie(e), [:from]) === nothing
deps = depgraph(e)
dorf = [ label_for(deps,i) for i in outneighbors(deps, code_for(deps, e)) ]
filter!(e -> kindof(e) in [:Facet, :Data], dorf)
if length(dorf) > 0
# use facets over data in priority
is = findfirst( kindof.(dorf) .== :Facet )
(is === nothing) && ( is = findfirst( kindof.(dorf) .== :Data ) )
cfd = dorf[is]
(length(dorf)>1) && warning("multiple data/facets in this group, using $cfd, explicitly set it if not correct")
if kindof(cfd) == :Facet
# insert definition of this facet in the 'from' field
insert!(e, [:from, :facet, :name], idof(cfd)) # add facet name
for k in keys(trie(cfd))
# correct some misplaced fields in facets (TODO: improve this)
if k == [:groupby, :data]
insert!(e, [:from, :facet, :data], trie(cfd)[k])
elseif k == [:groupby, :field]
insert!(e, [:from, :facet, :groupby], trie(cfd)[k])
else
insert!(e, vcat([:from, :facet], k), trie(cfd)[k])
end
end
# add new link between this group and this facet
addDependency(deps, e, cfd)
# mark this definition as fixed
deps[cfd] = true
else # Data, insert ref only
insert!(e, [:from, :data], idof(cfd))
addDependency(deps, e, cfd)
end
end
end
e
end
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 860 | ### other named elements #####################################################
########### Signals ###
export Signal
"""
Signal()
Create a signal. [Vega docs](https://vega.github.io/vega/docs/signals/)
# Example
```julia
# create a signal linked to a control
sig1 = Signal(value=15, bind=(input=:range, min=0, max=50, step=1))
# create a signal based on an expression
sig2 = Signal(update="[0,0.9*bandwidth('\$xscale')]")
```
"""
const Signal = VGElement{:Signal}
# TODO : signals with bindings should be at root level, enforce that
# special constructor for simple expressions String => (update= "expression")
VGElement{:Signal}(expr::AbstractString) = VGElement{:Signal}(;update=expr)
########### Projection ##
export Projection
const Projection = VGElement{:Projection}
########### Style ##
export Style
const Style = VGElement{:Style}
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 2137 | ########### Scale #############################################################
export LinearScale, LogScale, PowScale, SqrtScale, SymlogScale, TimeScale, UtcScale,
SequentialScale, OrdinalScale, BandScale, PointScale, QuantileScale, QuantizeScale,
ThresholdScale, BinordinalScale
const Scale = VGElement{:Scale}
# make scale(...) expand to (scale= scaleid, ...)
function (s::Scale)(e::VGElement)
f = VGElement{:generic}()
insert!(f, [], e)
insert!(f, [:scale], s)
f
end
(s::Scale)(; nargs...) = s( VGElement{:generic}(;nargs...) )
(s::Scale)(x::LeafType) = s( VGElement{:generic}(;value=x) )
"""
LinearScale(), LogScale(), PowScale(), SqrtScale(), SymlogScale(), TimeScale(), UtcScale(),
SequentialScale(), OrdinalScale(), BandScale(), PointScale(), QuantileScale(), QuantizeScale(),
ThresholdScale(), BinordinalScale()
Create a scale of a specific type. [Vega docs](https://vega.github.io/vega/docs/scales/)
# Examples
```julia
yscale = BandScale(range="height", domain=dat.y, domain_sort=true)
cscale = OrdinalScale(range="category", domain=dat.c)
```
"""
LinearScale, LogScale, PowScale, SqrtScale, SymlogScale, TimeScale, UtcScale, SequentialScale, OrdinalScale, BandScale, PointScale, QuantileScale, QuantizeScale, ThresholdScale, BinordinalScale
LinearScale(;nargs...) = Scale(type=:linear; nargs...)
LogScale(;nargs...) = Scale(type=:log; nargs...)
PowScale(;nargs...) = Scale(type=:pow; nargs...)
SqrtScale(;nargs...) = Scale(type=:sqrt; nargs...)
SymlogScale(;nargs...) = Scale(type=:symlog; nargs...)
TimeScale(;nargs...) = Scale(type=:time; nargs...)
UtcScale(;nargs...) = Scale(type=:utc; nargs...)
SequentialScale(;nargs...) = Scale(type=:sequential; nargs...)
OrdinalScale(;nargs...) = Scale(type=:ordinal; nargs...)
BandScale(;nargs...) = Scale(type=:band; nargs...)
PointScale(;nargs...) = Scale(type=:point; nargs...)
QuantileScale(;nargs...) = Scale(type=:quantile; nargs...)
QuantizeScale(;nargs...) = Scale(type=:quantize; nargs...)
ThresholdScale(;nargs...) = Scale(type=:threshold; nargs...)
BinordinalScale(;nargs...) = Scale(type="bin-ordinal"; nargs...)
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 1738 | using Test
using EasyVega
import EasyVega: VGTrie, insert!, VGElement, kindof, idof, depgraph, trie
import EasyVega: code_for, label_for, outneighbors, inneighbors
import EasyVega: nv, ne, isdef, isnamed
@testset "VGTrie" begin
t = VGTrie{String}(Symbol)
t[[:abc,3]] = "xyx"
@test t[[:abc,3]] == "xyx"
@test_throws KeyError t[[:abc]]
@test t.is_key == false
@test t.children[:abc].is_key == false
@test t.children[:abc].children[3].is_key == true
@test EasyVega.subtrie(t, [:abc]) isa EasyVega.VGTrie
@test haskey(t, [:abc]) == false
@test haskey(t, [:abc,3]) == true
@test keys(t) == [[:abc, 3]]
end
@testset "VGElement" begin
e = VGElement{:test}()
@test kindof(e) == :test
@test match(r"^te\d*$", idof(e)) !== nothing
insert!(e, [:abcd, 3, :xyz], 456)
@test trie(e)[[:abcd, 3, :xyz]] == 456
insert!(e, [:abcd, 3], (i=4, j=:sym))
@test trie(e)[[:abcd, 3, :i]] == 4
@test trie(e)[[:abcd, 3, :j]] == :sym
@test_throws ErrorException("type DataType not allowed") insert!(e, [:abcd, 3], Int)
@test_throws ErrorException("invalid key type : xy is not a Int64") insert!(e, [:abcd, :xy], 1.5)
m = Data(values=[(a=4,b="a"), (a=5,b="b")])
n = GroupMark(:x => m.a, marks = [ 456, :abcd])
deps = depgraph(n)
@test nv(deps) == 2
@test ne(deps) == 1
deps2 = depgraph(m)
@test nv(deps2) == 0
@test outneighbors(deps, code_for(deps, n)) == [ code_for(deps, m) ]
@test inneighbors(deps, code_for(deps, n)) == Int64[]
@test isdef(n, [:encode]) == false
@test isdef(n, [:marks, 1]) == true
@test isnamed(m) == true
@test isnamed(n) == true
@test isnamed(e) == false
end
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | code | 2019 | using DataFrames
N = 200
tb = DataFrame(x=randn(N), y=randn(N), a=rand("ABC", N))
using EasyVega
###############
using CSV, Glob
flist = readdir("/home/fred/logs/temtop")
flist = flist[ match.(r"^\d{8}\.csv$", flist) .!= nothing ]
histo = DataFrame()
for fn in flist
tmp = CSV.File(joinpath("/home/fred/logs/temtop",fn),
dateformat="yyyy-mm-dd HH:MM:SS", normalizenames=true
) |> DataFrame
append!(histo, tmp)
end
histo
describe(histo)
histdat = Data(values=sort!(histo, :DATE))
tscale = TimeScale(range="width", domain=histdat.DATE)
yscale = LinearScale(range="height", domain=histdat.PM2_5, nice=true, zero=true)
y2scale = LinearScale(range="height", domain=histdat.CO2, nice=true, zero=true)
lmark = LineMark(encode_enter=(
x=tscale(histdat.DATE),
y=yscale(histdat.PM2_5),
stroke_value="#d666")
)
lmark2 = LineMark(encode_enter=(
x=tscale(histdat.DATE),
y=y2scale(histdat.CO2),
stroke_value="#66d")
)
######
function mkMark(var)
tsc = TimeScale(range="width", domain=histdat.DATE)
ysc = LinearScale(range="height", domain=var, nice=true)
lmark = LineMark(encode_enter=(
x=tsc(histdat.DATE),
y=ysc(var)
))
GroupMark(
axes = [ tsc(orient="top", grid=true),
ysc(orient="left", grid=true)],
marks = [lmark]
)
end
VG(width=800, height=300, padding=20, background= "#fed",
layout=(columns=1,padding=20),
marks= [
mkMark(histdat.TEMP),
mkMark(histdat.CO2)
]
)
VG(width=800, height=300, padding=20, background= "#fed",
layout=(columns=1,padding=20),
marks= [
mkMark(histdat.TEMP),
mkMark(histdat.PM2_5)
]
)
################
using InteractiveUtils
################
io = IOBuffer()
EasyVega.toJSON(io,ttt.trie)
String(take!(io))
using PkgTemplates
t = Template(plugins=[GitHubActions()])
t("EasyVega2")
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MIT"
] | 0.1.0 | cc94cfcc2bacca3252dbccb07268e47b11e626b1 | docs | 10967 | # EasyVega
[](https://github.com/fredo-dedup/EasyVega.jl/actions/workflows/ci.yml)
[](https://codecov.io/gh/fredo-dedup/EasyVega.jl)
[](https://github.com/fredo-dedup/EasyVega.jl/actions/workflows/CompatHelper.yml)
[](https://github.com/fredo-dedup/EasyVega.jl/actions/workflows/TagBot.yml)
Julia bindings for the Vega plotting library.
Vega [(link)](https://vega.github.io/vega/) is a grammar for visualization using the JSON format. It provides all the building blocks to generate simple or complex visuals with interactive features.
> Note that Vega is a lower level language than VegaLite which is built upon it. If you want to build simple graphs quickly and with an easier learning curve, EasyVega is probably not the recommended path. You can check VegaLite [(link)](https://vega.github.io/vega-lite/) and its Julia binding [https://github.com/queryverse/VegaLite.jl](https://github.com/queryverse/VegaLite.jl) or most other Julia plotting packages.
This being said, Vega provides a variety of visuals and interactivity features that may be what you are looking for, and this Julia package brings a few syntax shortcuts that will make it easier to use.
[ <img src="./examples/simpleline.png" width="200" height="200" /> ](examples/simpleline.jl)
[ <img src="./examples/simplebars.png" width="200" height="200" /> ](examples/simplebars.jl)
[ <img src="./examples/facetpie.png" width="200" height="200" /> ](examples/facetpie.jl)
[ <img src="./examples/multipleplots.svg" width="200" height="200" /> ](examples/multipleplots.jl)
[ <img src="./examples/worldmap.svg" width="200" height="200" /> ](examples/worldmap.jl)
[ <img src="./examples/packedbubbles.svg" width="200" height="200" /> ](examples/packedbubbles.jl)
[ <img src="./examples/sunburst.svg" width="200" height="200" /> ](examples/sunburst.jl)
[ <img src="./examples/treelayout.svg" style="width:200px; height:200px; object-fit:none; object-position: 50% 0" /> ](examples/treelayout.jl)
[ <img src="./examples/density_and_contours.svg" width="200" height="200" /> ](examples/density_and_contours.jl)
[ <img src="./examples/voronoi.svg" width="200" height="200" /> ](examples/voronoi.jl)
[ <img src="./examples/loess.svg" width="200" height="200" /> ](examples/loess.jl)
## Direct Vega specification creation
This is not the recommended way to use EasyVega but this will help understand some aspects of the EasyVega syntax.
The function `VG()` can render a Vega plot by passing it all at once all the elements. For example to generate the minimal JSON spec below (showing a single dot) :
```JSON
{
"width": 100,
"height": 100,
"marks": [
{
"encode": {
"enter": {
"x": {"value": 50},
"y": {"value": 50},
"size": {"value": 100}
}
},
"type": "symbol"
}
]
}
```
You can call the `VG()` function with each structure of the JSON translated in a named argument or a `Vector`/ `NamedTuple` :
```julia
VG(
width= 100,
height= 100,
marks= [(
encode= (
enter= (
x= (value= 50,),
y= (value= 50,),
size= (value= 100,)
,)
,),
type= "symbol"
)
]
)
```
You can also use a syntax shortcut for nested structures by appending fields with an underscore character.
For example you can replace `x= (value= 50,)` with `x_value= 50`. This can help limit the number of nested parentheses.
By appending several levels you can rewrite the preceding example as :
```julia
VG(
width= 100,
height= 100,
marks= [(
encode_enter_x_value= 50,
encode_enter_y_value= 50,
encode_enter_size_value= 100,
type= "symbol"
)
]
)
```
Currently, the allowed values (on the right hand side of the '=' sign) can be a `Number`, a `Date` / `DateTime`, an `AbstractString` / `Symbol` / `Char` (all passed as strings in the JSON) and `nothing` as the JSON equivalent for `null`.
## Define named spec elements as separate variables
The recommended way to use EasyVega is to build the plot step by step.
This syntax idea starts from the observation that Vega specs have many element types that are named : data, marks, group marks, scales,... These are defined once and often used elsewhere by referring to their name. For example a mark can be defined with a data source and one or more scales; a mark can have another mark as a source, or a scale can use a data field to define its domain.
With EasyVega you can break down the full spec into separate definitions for each of these named elements, assign them to a variable and then use this variable in the following elements that depend on it.
This makes the creation of the full spec look more like a small regular Julia program where variables are set one after the other and making more explicit the dependency structure.
```julia
# create a Data element with dummy numbers
dat = Data(
values = [
(x= 0, y= 28),
(x= 1, y= 43),
(x= 2, y= 81),
(x= 3, y= 19),
(x= 4, y= 52),
]
)
# create the horizontal scale, mapping the width of the plotting area to
# the extent of the 'x' field values in Data element 'dat'
xscale = LinearScale(range="width", domain=dat.x)
# same for the vertical scale
yscale = LinearScale(range="height", domain=dat.y)
# create the mark, of type 'line', mapping the x of the mark to
# the scaled field 'x' of data and the y to the scaled 'y' field of data
lmark = LineMark(
encode_enter=(
x= xscale(dat.x),
y= yscale(dat.y),
),
)
# wrap up everything and render with the VG() function
VG(
width=300, height=200, background="white",
# add axes at the bottom and left side of the graph
axes = [ xscale(orient="bottom"), yscale(orient="left") ],
# specify the mark to show
marks= [ lmark ]
)
```
There are several things going on in this short example :
- the Data element creation `dat = Data(...)` allows to later refer to individual data fields with `dat.x` / `dat.y` (used in the subsequent scale and mark definitions).
- The scale creation `xscale = LinearScale(...)` provides a function `xscale(..)` indicating that the scale should be applied to the arguments, or more precisely generating an element with the scale annotation (used in the mark and axes definitions).
- The mark creation `lmark = LineMark(...)` does not need to specify the data source with a `from_data= dat`, EasyVega infers this dependance from the encodings of the 'x' and 'y' channels.
- In the final function `VG(..)`, you only need to mention the `lmark` variable for EasyVega to pull together the scales and data definitions into the final Vega spec, they do not need to be explicitly mentionned.
Currently the named elements that can be created this way are `Data()`, `Facet()` for facetting group marks, *`type`*`Mark()`, *`type`*`Scale()`, `GroupMark()`, `Projection()` and `Signal()`.
**All the other Vega spec elements (config, axes, legends, layout, triggers, ..) are not named and should be defined explicitly in GroupMarks or the final VG()**
## Pairs for channel encodings
EasyVega has a further syntax shortcuts for describing the channel encodings in marks (including group marks).
1. the right hand side defining the channel can be simplified :
- for simple values : `.. = (value= x,)` can be replaced with `.. = x`
- for data fields : `.. = (field= x,)` can be replaced with `.. = dat.x` (with `dat` used by EasyVega to fill in the `from_data` field of the mark if it is not specified explictily)
- for scaled data fields : `.. = (field= x, scale= myscale)` can be replaced with `.. = myscale(dat.x)`
- for all other cases, follow the Vega syntax.
2. the mapping between channels and values / fields can be specified as a `Pair` in a positional argument of the mark function. The left hand side of the Pair can be either a single symbol which will be added to the `enter` encoding set by default, or two symbols associated by an underscore, in which case the first symbol will be interpreted as the encoding set (e.g. `update` / `hover` / `exit` / etc.) and the second one as the channel name.
For example, using both shortcuts above, this mark specification :
```julia
SymbolMark(
shape="circle",
from_data = dat,
encode_enter=(
xc = (field= :x, scale= xscale),
yc = (field= :y,),
fill = (value= :black,),
size = (value= 100, scale= sscale),
)
encode_update=(
fillOpacity = (value= 0.2,),
)
)
```
can be replaced by the shorter equivalent :
```julia
SymbolMark(
shape="circle",
:xc => xscale(dat.x),
:yc => dat.y,
:fill => :black,
:size => sscale(100),
:update_fillOpacity => 0.2,
)
```
## Rendering
Rendering should work in Pluto and Visual Studio Code without issues. Other front end clients need to be implemented.
## Debugging plots
Since the rendering of the JSON Vega specs occurs in a javascript runtime, EasyVega (or Vega.jl/VegaLite.jl for that matter) cannot surface easily the error messages to help debugging. This is a fundamental disadvantage compared to full Julia plotting packages.
Additionally, EasyVega will throw errors or warnings for some structural inconsistencies but will not check for the full compliance of the generated spec.
There are however some ways to work through issues :
- The (unexported) function `trie()` will print the interpreted structure of the element provided as argument. This can help spotting typos or interpretation errors by EasyVega (you can file an issue in this case) :
```julia-repl
julia> EasyVega.trie( LineMark( :x => 12, :x => yscale(dat.y) ) )
encode: (enter: (x: (field: y, scale: Sc94)))
from: (data: Da90)
type: line
```
- The generated JSON can be copy/pasted in the online [Vega editor](https://vega.github.io/editor/#/) that provides several debugging tools (log, data viewer).
- In Pluto, click on "Open in Vega Editor" in the top right menu next to the plot (provided the plot appears at all)
- In Julia run the code below and paste in the editor (and right-click + 'format document' to have a readable JSON) :
```julia
vgspec = VG(...) # plot to debug
using InteractiveUtils
io = IOBuffer()
EasyVega.toJSON(io, EasyVega.trie(vgspec))
clipboard(String(take!(io)))
```
## Limitations / Future work
- Limited number of IDEs supported
- No SVG / PNG file export yet
- No Vega schema compliance checking for the generated Vega JSON produced
- Vega runtime errors not reported
| EasyVega | https://github.com/fredo-dedup/EasyVega.jl.git |
|
[
"MPL-2.0"
] | 1.1.0 | 22788e73371af8b8dd4aa1105bfb37f4fe278a33 | code | 2175 | module FastGraphletTransform
using SparseArrays, FGlT_jll
export fglt
"""
FastGraphletTransform.workers()
Get the number of workers available to the FGLT implementation.
"""
workers() = ccall((:getWorkers, libfglt), Cint, ())
"""
fglt(A::SparseMatrixCSC{F, I})
Perform the Fast Graphlet Transform (FGLT) on a graph described by the given adjacency
matrix `A` and return a tuple with the raw and net frequency matrices (`f` and `fnet` of size `n` by 16),
where `n` is the number of nodes in the graph.
The computed frequencies correspond to the following graphlets:
| sigma | Description |
|:---:|:---|
| 0 | singleton |
| 1 | 1-path, at an end |
| 2 | 2-path, at an end |
| 3 | bi-fork, at the root |
| 4 | 3-clique, at any node |
| 5 | 3-path, at an end |
| 6 | 3-path, at an interior node |
| 7 | claw, at a leaf |
| 8 | claw, at the root |
| 9 | dipper, at the handle tip |
| 10 | dipper, at a base node |
| 11 | dipper, at the center |
| 12 | 4-cycle, at any node |
| 13 | diamond, at an off-cord node |
| 14 | diamond, at an on-cord node 14 |
| 15 | 4-clique, at any node |
"""
function fglt(A::SparseMatrixCSC)
(A.n == A.m) || error("The adjacency matrix A must be square.")
n = A.n
f = zeros(Cdouble, n, 16)
fn = zeros(Cdouble, n, 16)
ii = A.rowval .- 1
jStart = A.colptr .- 1
# The number of edges is the number of non-zero entries
m = nnz(A)
np = workers()
GC.@preserve f fn ii jStart begin
ccall((:compute, libfglt), Cvoid,
(Ptr{Ptr{Cdouble}},
Ptr{Ptr{Cdouble}},
Ptr{Csize_t},
Ptr{Csize_t},
Csize_t,
Csize_t,
Csize_t),
f, fn, ii, jStart, n, m, np)
end
# Frequencies can only be integers.
# Will throw an InexactError if we somehow get a decimal.
(convert.(Int, f), convert.(Int, fn))
end
# See: https://stackoverflow.com/questions/33003174/calling-a-c-function-from-julia-and-passing-a-2d-array-as-a-pointer-of-pointers
Base.cconvert(::Type{Ptr{Ptr{Cdouble}}},xx2::Matrix{Cdouble})=Ref{Ptr{Cdouble}}([Ref(xx2,i) for i=1:size(xx2,1):length(xx2)])
end # module
| FastGraphletTransform | https://github.com/nsailor/FastGraphletTransform.jl.git |
|
[
"MPL-2.0"
] | 1.1.0 | 22788e73371af8b8dd4aa1105bfb37f4fe278a33 | code | 3444 | using FastGraphletTransform
using Test
using Match
using Graphs
using SparseArrays
function claw()
g = SimpleGraph(4);
add_edge!(g, 1, 2)
add_edge!(g, 1, 3)
add_edge!(g, 1, 4)
return g
end
function paw()
g = SimpleGraph(4);
add_edge!(g, 1, 2)
add_edge!(g, 1, 3)
add_edge!(g, 1, 4)
add_edge!(g, 2, 3)
return g
end
function buildU3(U3, f)
for x in eachrow(f)
r = findlast(x .== 1) - 2
U3[:,r] = x[3:5]
end
return U3
end
function buildU4(U4, f)
for x in eachrow(f)
r = findlast(x .== 1) - 5
U4[:,r] = x[6:end]
end
return U4
end
function graphlet(name)
@match name begin
"node" => Graph(1,0)
"edge" => Graph(2,1)
"bifork" => path_graph(3)
"triangle" => cycle_graph(3)
"gate" => path_graph(4)
"claw" => claw()
"paw" => paw()
"c4" => cycle_graph(4)
"diamond" => smallgraph("diamond")
"k4" => complete_graph(4)
end
end
@testset "FastGraphletTransform.jl" begin
# === 1-node graph
U1 = ones(Int32, 1, 1);
f, fn = fglt( adjacency_matrix( graphlet("node") ) )
@testset "1-node graph" begin
@test all( f .== fn )
@test all( f .== [1 zeros(1,15)])
end
# === 2-node graphs
U2 = ones(Int32, 1, 1);
f, fn = fglt( adjacency_matrix( graphlet("edge") ) )
@testset "2-node graph" begin
@test all( f .== fn )
@test all( f .== [1 1 zeros(1,14); 1 1 zeros(1,14)])
end
# === 3-node graphs
U3 = zeros(Int32, 3, 3);
@testset "3-node graphs" begin
# bi-fork/path-2
f, fn = fglt( adjacency_matrix( graphlet("bifork") ) )
@test all( fn .== [1 1 1 0 zeros(1,12);
1 2 0 1 zeros(1,12);
1 1 1 0 zeros(1,12)])
U3 = buildU3(U3, f)
# triangle
f, fn = fglt( adjacency_matrix(graphlet("triangle")) )
@test all( fn .== repeat( [1 2 0 0 1 zeros(1,11)], outer = [3 1] ) )
U3 = buildU3(U3, f)
end
# === 4-node graphs
U4 = zeros(Int32, 11, 11);
f, fn = fglt( adjacency_matrix(graphlet("gate")) )
U4 = buildU4(U4, f)
f, fn = fglt( adjacency_matrix( graphlet("claw") ) )
U4 = buildU4(U4, f)
f, fn = fglt( adjacency_matrix(graphlet("paw")) )
U4 = buildU4(U4, f)
f, fn = fglt( adjacency_matrix( graphlet("c4") ) )
U4 = buildU4(U4, f)
f, fn = fglt( adjacency_matrix(graphlet("diamond")) )
U4 = buildU4(U4, f)
f, fn = fglt( adjacency_matrix( graphlet("k4") ) )
U4 = buildU4(U4, f)
# === build U16 conversion
U16 = cat(U1, U2, U3, U4, dims=(1,2));
U16_gold =
[ 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 2 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 2 1 0 2 4 2 6
0 0 0 0 0 0 1 0 0 0 1 2 2 2 4 6
0 0 0 0 0 0 0 1 0 1 1 0 0 2 1 3
0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 1
0 0 0 0 0 0 0 0 0 1 0 0 0 2 0 3
0 0 0 0 0 0 0 0 0 0 1 0 0 2 2 6
0 0 0 0 0 0 0 0 0 0 0 1 0 0 2 3
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 3
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1];
@testset "net-2-raw conversion" begin
@test all( U16_gold .== U16 )
end
end
| FastGraphletTransform | https://github.com/nsailor/FastGraphletTransform.jl.git |
|
[
"MPL-2.0"
] | 1.1.0 | 22788e73371af8b8dd4aa1105bfb37f4fe278a33 | docs | 1957 | # FastGraphletTransform.jl
Julia wrapper for the [Fast Graphlet Transform](https://github.com/fcdimitr/fglt) C++/Cilk implementation.
[](https://github.com/nsailor/FastGraphletTransform.jl/actions)
[](https://codecov.io/gh/nsailor/FastGraphletTransform.jl)
[](https://www.mozilla.org/en-US/MPL/)
## Installation
To add the package to your Julia environment, open a Julia prompt, enter the `pkg` mode by pressing `]`, and type:
```julia
add FastGraphletTransform
```
## Usage
To perform a fast graphlet transform, call the `fglt` function with the graph's adjacency matrix, for instance:
```julia
julia> using FastGraphletTransform
julia> using SparseArrays
julia> A = sparse([0 1 0 0 1 0; 1 0 1 1 1 0; 0 1 0 1 1 0; 0 1 1 0 1 1; 1 1 1 1 0 0; 0 0 0 1 0 0])
6×6 SparseMatrixCSC{Int64,Int64} with 18 stored entries:
⋅ 1 ⋅ ⋅ 1 ⋅
1 ⋅ 1 1 1 ⋅
⋅ 1 ⋅ 1 1 ⋅
⋅ 1 1 ⋅ 1 1
1 1 1 1 ⋅ ⋅
⋅ ⋅ ⋅ 1 ⋅ ⋅
julia> (f, fn) = fglt(A);
Total elapsed time: 0.0000 sec
julia> f # Raw frequencies (n x 16)
6×16 Matrix{Int64}:
1 2 6 1 1 14 4 6 0 6 4 0 2 2 0 0
1 4 9 6 4 12 19 7 4 3 12 8 5 3 5 1
1 3 9 3 3 14 12 9 1 5 12 3 4 4 3 1
1 4 8 6 3 12 18 7 4 5 10 6 4 4 3 1
1 4 9 6 4 12 19 7 4 3 12 8 5 3 5 1
1 1 3 0 0 8 0 3 0 3 0 0 0 0 0 0
julia> fn # Net frequencies (n x 16)
6×16 Matrix{Int64}:
1 2 4 0 1 2 0 0 0 2 0 0 0 2 0 0
1 4 1 2 4 0 1 0 0 0 2 1 0 0 2 1
1 3 3 0 3 0 0 0 0 0 4 0 0 1 0 1
1 4 2 3 3 0 2 0 0 0 2 3 0 1 0 1
1 4 1 2 4 0 1 0 0 0 2 1 0 0 2 1
1 1 3 0 0 2 0 0 0 3 0 0 0 0 0 0
```
| FastGraphletTransform | https://github.com/nsailor/FastGraphletTransform.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 1226 | using Documenter:
DocMeta,
HTML,
MathJax3,
asset,
deploydocs,
makedocs
using PlutoStaticHTML
const NOTEBOOK_DIR = joinpath(@__DIR__, "src", "notebooks")
"""
build()
Run all Pluto notebooks (".jl" files) in `NOTEBOOK_DIR`.
"""
function build()
println("Building notebooks in $NOTEBOOK_DIR")
oopts = OutputOptions(; append_build_context=true)
output_format = documenter_output
bopts = BuildOptions(NOTEBOOK_DIR; output_format)
build_notebooks(bopts, oopts)
return nothing
end
# Build the notebooks; defaults to true.
if get(ENV, "BUILD_DOCS_NOTEBOOKS", "true") == "true"
build()
end
sitename = "PlutoStaticHTML.jl"
pages = [
"PlutoStaticHTML" => "index.md",
"Example notebook" => "notebooks/example.md",
"`with_terminal`" => "with_terminal.md"
]
# Using MathJax3 since Pluto uses that engine too.
mathengine = MathJax3()
prettyurls = get(ENV, "CI", nothing) == "true"
format = HTML(; mathengine, prettyurls)
modules = [PlutoStaticHTML]
checkdocs = :none
makedocs(; sitename, pages, format, modules, checkdocs)
deploydocs(;
branch="docs-output",
devbranch="main",
repo="github.com/rikhuijzer/PlutoStaticHTML.jl.git",
push_preview=false
)
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 57952 | ### A Pluto.jl notebook ###
# v0.19.42
using Markdown
using InteractiveUtils
# ╔═╡ 3dd303b0-373e-11ec-18e4-69bfc20b5e29
using CairoMakie, DataFrames
# ╔═╡ 751853f6-626f-4040-86b2-088339ef9a3c
md"""
The web page that you're looking is generated from a Pluto notebook.
"""
# ╔═╡ 058a7f63-7058-4229-b40c-2e98264bd77f
1 + 1
# ╔═╡ ee8c85f0-6612-4515-89a8-af04298c48bc
(; title="a namedtuple", values=[1, 2, 3])
# ╔═╡ 7ca85dab-6066-4b2a-b61c-9d9607b8756c
lines(1:10, 1:10)
# ╔═╡ 4ca09326-c8d8-44fb-8582-8dcc071bc76a
DataFrame(A = [1, 2], B = [3, 4], C = ["some", "text"])
# ╔═╡ d06ba72d-a89f-4bc8-98e1-fae8962e70aa
md"""
## Math
Using inline and display math is possible too.
For example, $x = 3\pi$ and
```math
y = \frac{a \cdot b}{c^2}
```
"""
# ╔═╡ 3207c229-6a6b-4219-9960-f08ebdff245a
md"""
## Admonitons
Admonitons are styled by default in the Documenter output.
For example:
!!! note
This is a note.
!!! warning
This is a warning.
See the [Documenter documentation](https://juliadocs.github.io/Documenter.jl/stable/showcase/#Admonitions) for the full list of admoniton types.
See the `convert_admonitions` option for `HTMLOptions` for more information about how it works and how to disable it.
"""
# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
[compat]
CairoMakie = "~0.10.11"
DataFrames = "~1.6.1"
"""
# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised
julia_version = "1.10.4"
manifest_format = "2.0"
project_hash = "c0130941acb94849fd135523260f350f5e51bac6"
[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "d92ad398961a3ed262d8bf04a1a2b8340f915fef"
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
version = "1.5.0"
weakdeps = ["ChainRulesCore", "Test"]
[deps.AbstractFFTs.extensions]
AbstractFFTsChainRulesCoreExt = "ChainRulesCore"
AbstractFFTsTestExt = "Test"
[[deps.AbstractLattices]]
git-tree-sha1 = "222ee9e50b98f51b5d78feb93dd928880df35f06"
uuid = "398f06c4-4d28-53ec-89ca-5b2656b7603d"
version = "0.3.0"
[[deps.AbstractTrees]]
git-tree-sha1 = "2d9c9a55f9c93e8887ad391fbae72f8ef55e1177"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.4.5"
[[deps.Adapt]]
deps = ["LinearAlgebra", "Requires"]
git-tree-sha1 = "6a55b747d1812e699320963ffde36f1ebdda4099"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "4.0.4"
weakdeps = ["StaticArrays"]
[deps.Adapt.extensions]
AdaptStaticArraysExt = "StaticArrays"
[[deps.AliasTables]]
deps = ["PtrArrays", "Random"]
git-tree-sha1 = "9876e1e164b144ca45e9e3198d0b689cadfed9ff"
uuid = "66dad0bd-aa9a-41b7-9441-69ab47430ed8"
version = "1.1.3"
[[deps.Animations]]
deps = ["Colors"]
git-tree-sha1 = "e81c509d2c8e49592413bfb0bb3b08150056c79d"
uuid = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
version = "0.4.1"
[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
version = "1.1.1"
[[deps.ArrayInterface]]
deps = ["Adapt", "LinearAlgebra", "SparseArrays", "SuiteSparse"]
git-tree-sha1 = "ed2ec3c9b483842ae59cd273834e5b46206d6dda"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "7.11.0"
[deps.ArrayInterface.extensions]
ArrayInterfaceBandedMatricesExt = "BandedMatrices"
ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices"
ArrayInterfaceCUDAExt = "CUDA"
ArrayInterfaceCUDSSExt = "CUDSS"
ArrayInterfaceChainRulesExt = "ChainRules"
ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore"
ArrayInterfaceReverseDiffExt = "ReverseDiff"
ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore"
ArrayInterfaceTrackerExt = "Tracker"
[deps.ArrayInterface.weakdeps]
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CUDSS = "45b445bb-4962-46a0-9369-b4df9d0f772e"
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
[[deps.Automa]]
deps = ["PrecompileTools", "TranscodingStreams"]
git-tree-sha1 = "588e0d680ad1d7201d4c6a804dcb1cd9cba79fbb"
uuid = "67c07d97-cdcb-5c2c-af73-a7f9c32a568b"
version = "1.0.3"
[[deps.AxisAlgorithms]]
deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"]
git-tree-sha1 = "01b8ccb13d68535d73d2b0c23e39bd23155fb712"
uuid = "13072b0f-2c55-5437-9ae7-d433b7a33950"
version = "1.1.0"
[[deps.AxisArrays]]
deps = ["Dates", "IntervalSets", "IterTools", "RangeArrays"]
git-tree-sha1 = "16351be62963a67ac4083f748fdb3cca58bfd52f"
uuid = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
version = "0.4.7"
[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[deps.Bzip2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "9e2a6b69137e6969bab0152632dcb3bc108c8bdd"
uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
version = "1.0.8+1"
[[deps.CEnum]]
git-tree-sha1 = "389ad5c84de1ae7cf0e28e381131c98ea87d54fc"
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
version = "0.5.0"
[[deps.CRC32c]]
uuid = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
[[deps.CRlibm_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "e329286945d0cfc04456972ea732551869af1cfc"
uuid = "4e9b3aee-d8a1-5a3d-ad8b-7d824db253f0"
version = "1.0.1+0"
[[deps.Cairo]]
deps = ["Cairo_jll", "Colors", "Glib_jll", "Graphics", "Libdl", "Pango_jll"]
git-tree-sha1 = "d0b3f8b4ad16cb0a2988c6788646a5e6a17b6b1b"
uuid = "159f3aea-2a34-519c-b102-8c37f9878175"
version = "1.0.5"
[[deps.CairoMakie]]
deps = ["Base64", "Cairo", "Colors", "FFTW", "FileIO", "FreeType", "GeometryBasics", "LinearAlgebra", "Makie", "PrecompileTools", "SHA"]
git-tree-sha1 = "5e21a254d82c64b1a4ed9dbdc7e87c5d9cf4a686"
uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
version = "0.10.12"
[[deps.Cairo_jll]]
deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"]
git-tree-sha1 = "a2f1c8c668c8e3cb4cca4e57a8efdb09067bb3fd"
uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a"
version = "1.18.0+2"
[[deps.Calculus]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "f641eb0a4f00c343bbc32346e1217b86f3ce9dad"
uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9"
version = "0.5.1"
[[deps.ChainRulesCore]]
deps = ["Compat", "LinearAlgebra"]
git-tree-sha1 = "71acdbf594aab5bbb2cec89b208c41b4c411e49f"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.24.0"
weakdeps = ["SparseArrays"]
[deps.ChainRulesCore.extensions]
ChainRulesCoreSparseArraysExt = "SparseArrays"
[[deps.ColorBrewer]]
deps = ["Colors", "JSON", "Test"]
git-tree-sha1 = "61c5334f33d91e570e1d0c3eb5465835242582c4"
uuid = "a2cac450-b92f-5266-8821-25eda20663c8"
version = "0.4.0"
[[deps.ColorSchemes]]
deps = ["ColorTypes", "ColorVectorSpace", "Colors", "FixedPointNumbers", "PrecompileTools", "Random"]
git-tree-sha1 = "4b270d6465eb21ae89b732182c20dc165f8bf9f2"
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
version = "3.25.0"
[[deps.ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
git-tree-sha1 = "b10d0b65641d57b8b4d5e234446582de5047050d"
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
version = "0.11.5"
[[deps.ColorVectorSpace]]
deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "Requires", "Statistics", "TensorCore"]
git-tree-sha1 = "a1f44953f2382ebb937d60dafbe2deea4bd23249"
uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4"
version = "0.10.0"
weakdeps = ["SpecialFunctions"]
[deps.ColorVectorSpace.extensions]
SpecialFunctionsExt = "SpecialFunctions"
[[deps.Colors]]
deps = ["ColorTypes", "FixedPointNumbers", "Reexport"]
git-tree-sha1 = "362a287c3aa50601b0bc359053d5c2468f0e7ce0"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.12.11"
[[deps.Combinatorics]]
git-tree-sha1 = "08c8b6831dc00bfea825826be0bc8336fc369860"
uuid = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
version = "1.0.2"
[[deps.CommonSubexpressions]]
deps = ["MacroTools", "Test"]
git-tree-sha1 = "7b8a93dba8af7e3b42fecabf646260105ac373f7"
uuid = "bbf7d656-a473-5ed7-a52c-81e309532950"
version = "0.3.0"
[[deps.Compat]]
deps = ["TOML", "UUIDs"]
git-tree-sha1 = "b1c55339b7c6c350ee89f2c1604299660525b248"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "4.15.0"
weakdeps = ["Dates", "LinearAlgebra"]
[deps.Compat.extensions]
CompatLinearAlgebraExt = "LinearAlgebra"
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.1.1+0"
[[deps.ConstructionBase]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "260fd2400ed2dab602a7c15cf10c1933c59930a2"
uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
version = "1.5.5"
weakdeps = ["IntervalSets", "StaticArrays"]
[deps.ConstructionBase.extensions]
ConstructionBaseIntervalSetsExt = "IntervalSets"
ConstructionBaseStaticArraysExt = "StaticArrays"
[[deps.Contour]]
git-tree-sha1 = "439e35b0b36e2e5881738abc8857bd92ad6ff9a8"
uuid = "d38c429a-6771-53c6-b99e-75d170b6e991"
version = "0.6.3"
[[deps.Crayons]]
git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "4.1.1"
[[deps.DataAPI]]
git-tree-sha1 = "abe83f3a2f1b857aac70ef8b269080af17764bbe"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.16.0"
[[deps.DataFrames]]
deps = ["Compat", "DataAPI", "DataStructures", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "REPL", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "04c738083f29f86e62c8afc341f0967d8717bdb8"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "1.6.1"
[[deps.DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
git-tree-sha1 = "1d0a14036acb104d9e89698bd408f63ab58cdc82"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.18.20"
[[deps.DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"
[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
[[deps.DelaunayTriangulation]]
deps = ["DataStructures", "EnumX", "ExactPredicates", "Random", "SimpleGraphs"]
git-tree-sha1 = "d4e9dc4c6106b8d44e40cd4faf8261a678552c7c"
uuid = "927a84f5-c5f4-47a5-9785-b46e178433df"
version = "0.8.12"
[[deps.DiffResults]]
deps = ["StaticArraysCore"]
git-tree-sha1 = "782dd5f4561f5d267313f23853baaaa4c52ea621"
uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"
version = "1.1.0"
[[deps.DiffRules]]
deps = ["IrrationalConstants", "LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"]
git-tree-sha1 = "23163d55f885173722d1e4cf0f6110cdbaf7e272"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "1.15.1"
[[deps.Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[deps.Distributions]]
deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"]
git-tree-sha1 = "9c405847cc7ecda2dc921ccf18b47ca150d7317e"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.25.109"
[deps.Distributions.extensions]
DistributionsChainRulesCoreExt = "ChainRulesCore"
DistributionsDensityInterfaceExt = "DensityInterface"
DistributionsTestExt = "Test"
[deps.Distributions.weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
DensityInterface = "b429d917-457f-4dbc-8f4c-0cc954292b1d"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[deps.DocStringExtensions]]
deps = ["LibGit2"]
git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.9.3"
[[deps.Downloads]]
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
version = "1.6.0"
[[deps.DualNumbers]]
deps = ["Calculus", "NaNMath", "SpecialFunctions"]
git-tree-sha1 = "5837a837389fccf076445fce071c8ddaea35a566"
uuid = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74"
version = "0.6.8"
[[deps.EarCut_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "e3290f2d49e661fbd94046d7e3726ffcb2d41053"
uuid = "5ae413db-bbd1-5e63-b57d-d24a61df00f5"
version = "2.2.4+0"
[[deps.EnumX]]
git-tree-sha1 = "bdb1942cd4c45e3c678fd11569d5cccd80976237"
uuid = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
version = "1.0.4"
[[deps.ExactPredicates]]
deps = ["IntervalArithmetic", "Random", "StaticArrays"]
git-tree-sha1 = "b3f2ff58735b5f024c392fde763f29b057e4b025"
uuid = "429591f6-91af-11e9-00e2-59fbe8cec110"
version = "2.2.8"
[[deps.Expat_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "1c6317308b9dc757616f0b5cb379db10494443a7"
uuid = "2e619515-83b5-522b-bb60-26c02a35a201"
version = "2.6.2+0"
[[deps.Extents]]
git-tree-sha1 = "94997910aca72897524d2237c41eb852153b0f65"
uuid = "411431e0-e8b7-467b-b5e0-f676ba4f2910"
version = "0.1.3"
[[deps.FFMPEG_jll]]
deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "JLLWrappers", "LAME_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "PCRE2_jll", "Zlib_jll", "libaom_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"]
git-tree-sha1 = "ab3f7e1819dba9434a3a5126510c8fda3a4e7000"
uuid = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5"
version = "6.1.1+0"
[[deps.FFTW]]
deps = ["AbstractFFTs", "FFTW_jll", "LinearAlgebra", "MKL_jll", "Preferences", "Reexport"]
git-tree-sha1 = "4820348781ae578893311153d69049a93d05f39d"
uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
version = "1.8.0"
[[deps.FFTW_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "c6033cc3892d0ef5bb9cd29b7f2f0331ea5184ea"
uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a"
version = "3.3.10+0"
[[deps.FileIO]]
deps = ["Pkg", "Requires", "UUIDs"]
git-tree-sha1 = "82d8afa92ecf4b52d78d869f038ebfb881267322"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.16.3"
[[deps.FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
[[deps.FillArrays]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "0653c0a2396a6da5bc4766c43041ef5fd3efbe57"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "1.11.0"
weakdeps = ["PDMats", "SparseArrays", "Statistics"]
[deps.FillArrays.extensions]
FillArraysPDMatsExt = "PDMats"
FillArraysSparseArraysExt = "SparseArrays"
FillArraysStatisticsExt = "Statistics"
[[deps.FiniteDiff]]
deps = ["ArrayInterface", "LinearAlgebra", "Requires", "Setfield", "SparseArrays"]
git-tree-sha1 = "2de436b72c3422940cbe1367611d137008af7ec3"
uuid = "6a86dc24-6348-571c-b903-95158fe2bd41"
version = "2.23.1"
[deps.FiniteDiff.extensions]
FiniteDiffBandedMatricesExt = "BandedMatrices"
FiniteDiffBlockBandedMatricesExt = "BlockBandedMatrices"
FiniteDiffStaticArraysExt = "StaticArrays"
[deps.FiniteDiff.weakdeps]
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
[[deps.FixedPointNumbers]]
deps = ["Statistics"]
git-tree-sha1 = "05882d6995ae5c12bb5f36dd2ed3f61c98cbb172"
uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
version = "0.8.5"
[[deps.Fontconfig_jll]]
deps = ["Artifacts", "Bzip2_jll", "Expat_jll", "FreeType2_jll", "JLLWrappers", "Libdl", "Libuuid_jll", "Zlib_jll"]
git-tree-sha1 = "db16beca600632c95fc8aca29890d83788dd8b23"
uuid = "a3f928ae-7b40-5064-980b-68af3947d34b"
version = "2.13.96+0"
[[deps.Formatting]]
deps = ["Logging", "Printf"]
git-tree-sha1 = "fb409abab2caf118986fc597ba84b50cbaf00b87"
uuid = "59287772-0a20-5a39-b81b-1366585eb4c0"
version = "0.4.3"
[[deps.ForwardDiff]]
deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions"]
git-tree-sha1 = "cf0fe81336da9fb90944683b8c41984b08793dad"
uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.36"
weakdeps = ["StaticArrays"]
[deps.ForwardDiff.extensions]
ForwardDiffStaticArraysExt = "StaticArrays"
[[deps.FreeType]]
deps = ["CEnum", "FreeType2_jll"]
git-tree-sha1 = "907369da0f8e80728ab49c1c7e09327bf0d6d999"
uuid = "b38be410-82b0-50bf-ab77-7b57e271db43"
version = "4.1.1"
[[deps.FreeType2_jll]]
deps = ["Artifacts", "Bzip2_jll", "JLLWrappers", "Libdl", "Zlib_jll"]
git-tree-sha1 = "5c1d8ae0efc6c2e7b1fc502cbe25def8f661b7bc"
uuid = "d7e528f0-a631-5988-bf34-fe36492bcfd7"
version = "2.13.2+0"
[[deps.FreeTypeAbstraction]]
deps = ["ColorVectorSpace", "Colors", "FreeType", "GeometryBasics"]
git-tree-sha1 = "2493cdfd0740015955a8e46de4ef28f49460d8bc"
uuid = "663a7486-cb36-511b-a19d-713bb74d65c9"
version = "0.10.3"
[[deps.FriBidi_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "1ed150b39aebcc805c26b93a8d0122c940f64ce2"
uuid = "559328eb-81f9-559d-9380-de523a88c83c"
version = "1.0.14+0"
[[deps.Future]]
deps = ["Random"]
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"
[[deps.GeoInterface]]
deps = ["Extents"]
git-tree-sha1 = "801aef8228f7f04972e596b09d4dba481807c913"
uuid = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
version = "1.3.4"
[[deps.GeometryBasics]]
deps = ["EarCut_jll", "Extents", "GeoInterface", "IterTools", "LinearAlgebra", "StaticArrays", "StructArrays", "Tables"]
git-tree-sha1 = "b62f2b2d76cee0d61a2ef2b3118cd2a3215d3134"
uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
version = "0.4.11"
[[deps.Gettext_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "XML2_jll"]
git-tree-sha1 = "9b02998aba7bf074d14de89f9d37ca24a1a0b046"
uuid = "78b55507-aeef-58d4-861c-77aaff3498b1"
version = "0.21.0+0"
[[deps.Glib_jll]]
deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE2_jll", "Zlib_jll"]
git-tree-sha1 = "7c82e6a6cd34e9d935e9aa4051b66c6ff3af59ba"
uuid = "7746bdde-850d-59dc-9ae8-88ece973131d"
version = "2.80.2+0"
[[deps.Graphics]]
deps = ["Colors", "LinearAlgebra", "NaNMath"]
git-tree-sha1 = "d61890399bc535850c4bf08e4e0d3a7ad0f21cbd"
uuid = "a2bd30eb-e257-5431-a919-1863eab51364"
version = "1.1.2"
[[deps.Graphite2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "344bf40dcab1073aca04aa0df4fb092f920e4011"
uuid = "3b182d85-2403-5c21-9c21-1e1f0cc25472"
version = "1.3.14+0"
[[deps.GridLayoutBase]]
deps = ["GeometryBasics", "InteractiveUtils", "Observables"]
git-tree-sha1 = "f57a64794b336d4990d90f80b147474b869b1bc4"
uuid = "3955a311-db13-416c-9275-1d80ed98e5e9"
version = "0.9.2"
[[deps.Grisu]]
git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2"
uuid = "42e2da0e-8278-4e71-bc24-59509adca0fe"
version = "1.0.2"
[[deps.HarfBuzz_jll]]
deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "Graphite2_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Pkg"]
git-tree-sha1 = "129acf094d168394e80ee1dc4bc06ec835e510a3"
uuid = "2e76f6c2-a576-52d4-95c1-20adfe4de566"
version = "2.8.1+1"
[[deps.HypergeometricFunctions]]
deps = ["DualNumbers", "LinearAlgebra", "OpenLibm_jll", "SpecialFunctions"]
git-tree-sha1 = "f218fe3736ddf977e0e772bc9a586b2383da2685"
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
version = "0.3.23"
[[deps.ImageAxes]]
deps = ["AxisArrays", "ImageBase", "ImageCore", "Reexport", "SimpleTraits"]
git-tree-sha1 = "2e4520d67b0cef90865b3ef727594d2a58e0e1f8"
uuid = "2803e5a7-5153-5ecf-9a86-9b4c37f5f5ac"
version = "0.6.11"
[[deps.ImageBase]]
deps = ["ImageCore", "Reexport"]
git-tree-sha1 = "eb49b82c172811fd2c86759fa0553a2221feb909"
uuid = "c817782e-172a-44cc-b673-b171935fbb9e"
version = "0.1.7"
[[deps.ImageCore]]
deps = ["ColorVectorSpace", "Colors", "FixedPointNumbers", "MappedArrays", "MosaicViews", "OffsetArrays", "PaddedViews", "PrecompileTools", "Reexport"]
git-tree-sha1 = "b2a7eaa169c13f5bcae8131a83bc30eff8f71be0"
uuid = "a09fc81d-aa75-5fe9-8630-4744c3626534"
version = "0.10.2"
[[deps.ImageIO]]
deps = ["FileIO", "IndirectArrays", "JpegTurbo", "LazyModules", "Netpbm", "OpenEXR", "PNGFiles", "QOI", "Sixel", "TiffImages", "UUIDs"]
git-tree-sha1 = "437abb322a41d527c197fa800455f79d414f0a3c"
uuid = "82e4d734-157c-48bb-816b-45c225c6df19"
version = "0.6.8"
[[deps.ImageMetadata]]
deps = ["AxisArrays", "ImageAxes", "ImageBase", "ImageCore"]
git-tree-sha1 = "355e2b974f2e3212a75dfb60519de21361ad3cb7"
uuid = "bc367c6b-8a6b-528e-b4bd-a4b897500b49"
version = "0.9.9"
[[deps.Imath_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "0936ba688c6d201805a83da835b55c61a180db52"
uuid = "905a6f67-0a94-5f89-b386-d35d92009cd1"
version = "3.1.11+0"
[[deps.IndirectArrays]]
git-tree-sha1 = "012e604e1c7458645cb8b436f8fba789a51b257f"
uuid = "9b13fd28-a010-5f03-acff-a1bbcff69959"
version = "1.0.0"
[[deps.Inflate]]
git-tree-sha1 = "d1b1b796e47d94588b3757fe84fbf65a5ec4a80d"
uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
version = "0.1.5"
[[deps.InlineStrings]]
deps = ["Parsers"]
git-tree-sha1 = "9cc2baf75c6d09f9da536ddf58eb2f29dedaf461"
uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
version = "1.4.0"
[[deps.IntegerMathUtils]]
git-tree-sha1 = "b8ffb903da9f7b8cf695a8bead8e01814aa24b30"
uuid = "18e54dd8-cb9d-406c-a71d-865a43cbb235"
version = "0.1.2"
[[deps.IntelOpenMP_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "be50fe8df3acbffa0274a744f1a99d29c45a57f4"
uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0"
version = "2024.1.0+0"
[[deps.InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
[[deps.Interpolations]]
deps = ["Adapt", "AxisAlgorithms", "ChainRulesCore", "LinearAlgebra", "OffsetArrays", "Random", "Ratios", "Requires", "SharedArrays", "SparseArrays", "StaticArrays", "WoodburyMatrices"]
git-tree-sha1 = "88a101217d7cb38a7b481ccd50d21876e1d1b0e0"
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
version = "0.15.1"
[deps.Interpolations.extensions]
InterpolationsUnitfulExt = "Unitful"
[deps.Interpolations.weakdeps]
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
[[deps.IntervalArithmetic]]
deps = ["CRlibm_jll", "MacroTools", "RoundingEmulator"]
git-tree-sha1 = "433b0bb201cd76cb087b017e49244f10394ebe9c"
uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
version = "0.22.14"
weakdeps = ["DiffRules", "ForwardDiff", "RecipesBase"]
[deps.IntervalArithmetic.extensions]
IntervalArithmeticDiffRulesExt = "DiffRules"
IntervalArithmeticForwardDiffExt = "ForwardDiff"
IntervalArithmeticRecipesBaseExt = "RecipesBase"
[[deps.IntervalSets]]
git-tree-sha1 = "dba9ddf07f77f60450fe5d2e2beb9854d9a49bd0"
uuid = "8197267c-284f-5f27-9208-e0e47529a953"
version = "0.7.10"
weakdeps = ["Random", "RecipesBase", "Statistics"]
[deps.IntervalSets.extensions]
IntervalSetsRandomExt = "Random"
IntervalSetsRecipesBaseExt = "RecipesBase"
IntervalSetsStatisticsExt = "Statistics"
[[deps.InvertedIndices]]
git-tree-sha1 = "0dc7b50b8d436461be01300fd8cd45aa0274b038"
uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f"
version = "1.3.0"
[[deps.IrrationalConstants]]
git-tree-sha1 = "630b497eafcc20001bba38a4651b327dcfc491d2"
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
version = "0.2.2"
[[deps.Isoband]]
deps = ["isoband_jll"]
git-tree-sha1 = "f9b6d97355599074dc867318950adaa6f9946137"
uuid = "f1662d9f-8043-43de-a69a-05efc1cc6ff4"
version = "0.1.1"
[[deps.IterTools]]
git-tree-sha1 = "42d5f897009e7ff2cf88db414a389e5ed1bdd023"
uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
version = "1.10.0"
[[deps.IteratorInterfaceExtensions]]
git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"
[[deps.JLLWrappers]]
deps = ["Artifacts", "Preferences"]
git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.5.0"
[[deps.JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.4"
[[deps.JpegTurbo]]
deps = ["CEnum", "FileIO", "ImageCore", "JpegTurbo_jll", "TOML"]
git-tree-sha1 = "fa6d0bcff8583bac20f1ffa708c3913ca605c611"
uuid = "b835a17e-a41a-41e7-81f0-2f016b05efe0"
version = "0.1.5"
[[deps.JpegTurbo_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "c84a835e1a09b289ffcd2271bf2a337bbdda6637"
uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8"
version = "3.0.3+0"
[[deps.KernelDensity]]
deps = ["Distributions", "DocStringExtensions", "FFTW", "Interpolations", "StatsBase"]
git-tree-sha1 = "7d703202e65efa1369de1279c162b915e245eed1"
uuid = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b"
version = "0.6.9"
[[deps.LAME_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "170b660facf5df5de098d866564877e119141cbd"
uuid = "c1c5ebd0-6772-5130-a774-d5fcae4a789d"
version = "3.100.2+0"
[[deps.LLVMOpenMP_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "d986ce2d884d49126836ea94ed5bfb0f12679713"
uuid = "1d63c593-3942-5779-bab2-d838dc0a180e"
version = "15.0.7+0"
[[deps.LZO_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "70c5da094887fd2cae843b8db33920bac4b6f07d"
uuid = "dd4b983a-f0e5-5f8d-a1b7-129d4a5fb1ac"
version = "2.10.2+0"
[[deps.LaTeXStrings]]
git-tree-sha1 = "50901ebc375ed41dbf8058da26f9de442febbbec"
uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
version = "1.3.1"
[[deps.LazyArtifacts]]
deps = ["Artifacts", "Pkg"]
uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
[[deps.LazyModules]]
git-tree-sha1 = "a560dd966b386ac9ae60bdd3a3d3a326062d3c3e"
uuid = "8cdb02fc-e678-4876-92c5-9defec4f444e"
version = "0.3.1"
[[deps.LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
version = "0.6.4"
[[deps.LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
version = "8.4.0+0"
[[deps.LibGit2]]
deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
[[deps.LibGit2_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"]
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
version = "1.6.4+0"
[[deps.LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
version = "1.11.0+1"
[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
[[deps.Libffi_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "0b4a5d71f3e5200a7dff793393e09dfc2d874290"
uuid = "e9f186c6-92d2-5b65-8a66-fee21dc1b490"
version = "3.2.2+1"
[[deps.Libgcrypt_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgpg_error_jll"]
git-tree-sha1 = "9fd170c4bbfd8b935fdc5f8b7aa33532c991a673"
uuid = "d4300ac3-e22c-5743-9152-c294e39db1e4"
version = "1.8.11+0"
[[deps.Libgpg_error_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "fbb1f2bef882392312feb1ede3615ddc1e9b99ed"
uuid = "7add5ba3-2f88-524e-9cd5-f83b8a55f7b8"
version = "1.49.0+0"
[[deps.Libiconv_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "f9557a255370125b405568f9767d6d195822a175"
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
version = "1.17.0+0"
[[deps.Libmount_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "0c4f9c4f1a50d8f35048fa0532dabbadf702f81e"
uuid = "4b2f31a3-9ecc-558c-b454-b3730dcb73e9"
version = "2.40.1+0"
[[deps.Libuuid_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "5ee6203157c120d79034c748a2acba45b82b8807"
uuid = "38a345b3-de98-5d2b-a5d3-14cd9215e700"
version = "2.40.1+0"
[[deps.LightXML]]
deps = ["Libdl", "XML2_jll"]
git-tree-sha1 = "3a994404d3f6709610701c7dabfc03fed87a81f8"
uuid = "9c8b4983-aa76-5018-a973-4c85ecc9e179"
version = "0.9.1"
[[deps.LineSearches]]
deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf"]
git-tree-sha1 = "7bbea35cec17305fc70a0e5b4641477dc0789d9d"
uuid = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
version = "7.2.0"
[[deps.LinearAlgebra]]
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[[deps.LinearAlgebraX]]
deps = ["LinearAlgebra", "Mods", "Primes", "SimplePolynomials"]
git-tree-sha1 = "d76cec8007ec123c2b681269d40f94b053473fcf"
uuid = "9b3f67b0-2d00-526e-9884-9e4938f8fb88"
version = "0.2.7"
[[deps.LogExpFunctions]]
deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
git-tree-sha1 = "a2d09619db4e765091ee5c6ffe8872849de0feea"
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
version = "0.3.28"
[deps.LogExpFunctions.extensions]
LogExpFunctionsChainRulesCoreExt = "ChainRulesCore"
LogExpFunctionsChangesOfVariablesExt = "ChangesOfVariables"
LogExpFunctionsInverseFunctionsExt = "InverseFunctions"
[deps.LogExpFunctions.weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
[[deps.MKL_jll]]
deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "oneTBB_jll"]
git-tree-sha1 = "80b2833b56d466b3858d565adcd16a4a05f2089b"
uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
version = "2024.1.0+0"
[[deps.MacroTools]]
deps = ["Markdown", "Random"]
git-tree-sha1 = "2fa9ee3e63fd3a4f7a9a4f4744a52f4856de82df"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
version = "0.5.13"
[[deps.Makie]]
deps = ["Animations", "Base64", "CRC32c", "ColorBrewer", "ColorSchemes", "ColorTypes", "Colors", "Contour", "DelaunayTriangulation", "Distributions", "DocStringExtensions", "Downloads", "FFMPEG_jll", "FileIO", "FixedPointNumbers", "Formatting", "FreeType", "FreeTypeAbstraction", "GeometryBasics", "GridLayoutBase", "ImageIO", "InteractiveUtils", "IntervalSets", "Isoband", "KernelDensity", "LaTeXStrings", "LinearAlgebra", "MacroTools", "MakieCore", "Markdown", "MathTeXEngine", "Observables", "OffsetArrays", "Packing", "PlotUtils", "PolygonOps", "PrecompileTools", "Printf", "REPL", "Random", "RelocatableFolders", "Setfield", "ShaderAbstractions", "Showoff", "SignedDistanceFields", "SparseArrays", "StableHashTraits", "Statistics", "StatsBase", "StatsFuns", "StructArrays", "TriplotBase", "UnicodeFun"]
git-tree-sha1 = "35fa3c150cd96fd77417a23965b7037b90d6ffc9"
uuid = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
version = "0.19.12"
[[deps.MakieCore]]
deps = ["Observables", "REPL"]
git-tree-sha1 = "9b11acd07f21c4d035bd4156e789532e8ee2cc70"
uuid = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
version = "0.6.9"
[[deps.MappedArrays]]
git-tree-sha1 = "2dab0221fe2b0f2cb6754eaa743cc266339f527e"
uuid = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
version = "0.4.2"
[[deps.Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[deps.MathTeXEngine]]
deps = ["AbstractTrees", "Automa", "DataStructures", "FreeTypeAbstraction", "GeometryBasics", "LaTeXStrings", "REPL", "RelocatableFolders", "UnicodeFun"]
git-tree-sha1 = "96ca8a313eb6437db5ffe946c457a401bbb8ce1d"
uuid = "0a4f8689-d25c-4efe-a92b-7142dfc1aa53"
version = "0.5.7"
[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.2+1"
[[deps.Missings]]
deps = ["DataAPI"]
git-tree-sha1 = "ec4f7fbeab05d7747bdf98eb74d130a2a2ed298d"
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
version = "1.2.0"
[[deps.Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[deps.Mods]]
git-tree-sha1 = "924f962b524a71eef7a21dae1e6853817f9b658f"
uuid = "7475f97c-0381-53b1-977b-4c60186c8d62"
version = "2.2.4"
[[deps.MosaicViews]]
deps = ["MappedArrays", "OffsetArrays", "PaddedViews", "StackViews"]
git-tree-sha1 = "7b86a5d4d70a9f5cdf2dacb3cbe6d251d1a61dbe"
uuid = "e94cdb99-869f-56ef-bcf0-1ae2bcbe0389"
version = "0.3.4"
[[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2023.1.10"
[[deps.Multisets]]
git-tree-sha1 = "8d852646862c96e226367ad10c8af56099b4047e"
uuid = "3b2b4ff1-bcff-5658-a3ee-dbcf1ce5ac09"
version = "0.4.4"
[[deps.NLSolversBase]]
deps = ["DiffResults", "Distributed", "FiniteDiff", "ForwardDiff"]
git-tree-sha1 = "a0b464d183da839699f4c79e7606d9d186ec172c"
uuid = "d41bc354-129a-5804-8e4c-c37616107c6c"
version = "7.8.3"
[[deps.NaNMath]]
deps = ["OpenLibm_jll"]
git-tree-sha1 = "0877504529a3e5c3343c6f8b4c0381e57e4387e4"
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
version = "1.0.2"
[[deps.Netpbm]]
deps = ["FileIO", "ImageCore", "ImageMetadata"]
git-tree-sha1 = "d92b107dbb887293622df7697a2223f9f8176fcd"
uuid = "f09324ee-3d7c-5217-9330-fc30815ba969"
version = "1.1.1"
[[deps.NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
version = "1.2.0"
[[deps.Observables]]
git-tree-sha1 = "7438a59546cf62428fc9d1bc94729146d37a7225"
uuid = "510215fc-4207-5dde-b226-833fc4488ee2"
version = "0.5.5"
[[deps.OffsetArrays]]
git-tree-sha1 = "e64b4f5ea6b7389f6f046d13d4896a8f9c1ba71e"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.14.0"
weakdeps = ["Adapt"]
[deps.OffsetArrays.extensions]
OffsetArraysAdaptExt = "Adapt"
[[deps.Ogg_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "887579a3eb005446d514ab7aeac5d1d027658b8f"
uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051"
version = "1.3.5+1"
[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.23+4"
[[deps.OpenEXR]]
deps = ["Colors", "FileIO", "OpenEXR_jll"]
git-tree-sha1 = "327f53360fdb54df7ecd01e96ef1983536d1e633"
uuid = "52e1d378-f018-4a11-a4be-720524705ac7"
version = "0.3.2"
[[deps.OpenEXR_jll]]
deps = ["Artifacts", "Imath_jll", "JLLWrappers", "Libdl", "Zlib_jll"]
git-tree-sha1 = "8292dd5c8a38257111ada2174000a33745b06d4e"
uuid = "18a262bb-aa17-5467-a713-aee519bc75cb"
version = "3.2.4+0"
[[deps.OpenLibm_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
version = "0.8.1+2"
[[deps.OpenSSL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "a028ee3cb5641cccc4c24e90c36b0a4f7707bdf5"
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "3.0.14+0"
[[deps.OpenSpecFun_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1"
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
version = "0.5.5+0"
[[deps.Optim]]
deps = ["Compat", "FillArrays", "ForwardDiff", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "SparseArrays", "StatsBase"]
git-tree-sha1 = "d9b79c4eed437421ac4285148fcadf42e0700e89"
uuid = "429524aa-4258-5aef-a3af-852621145aeb"
version = "1.9.4"
[deps.Optim.extensions]
OptimMOIExt = "MathOptInterface"
[deps.Optim.weakdeps]
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
[[deps.Opus_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "51a08fb14ec28da2ec7a927c4337e4332c2a4720"
uuid = "91d4177d-7536-5919-b921-800302f37372"
version = "1.3.2+0"
[[deps.OrderedCollections]]
git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.6.3"
[[deps.PCRE2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "efcefdf7-47ab-520b-bdef-62a2eaa19f15"
version = "10.42.0+1"
[[deps.PDMats]]
deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"]
git-tree-sha1 = "949347156c25054de2db3b166c52ac4728cbad65"
uuid = "90014a1f-27ba-587c-ab20-58faa44d9150"
version = "0.11.31"
[[deps.PNGFiles]]
deps = ["Base64", "CEnum", "ImageCore", "IndirectArrays", "OffsetArrays", "libpng_jll"]
git-tree-sha1 = "67186a2bc9a90f9f85ff3cc8277868961fb57cbd"
uuid = "f57f5aa1-a3ce-4bc8-8ab9-96f992907883"
version = "0.4.3"
[[deps.Packing]]
deps = ["GeometryBasics"]
git-tree-sha1 = "ec3edfe723df33528e085e632414499f26650501"
uuid = "19eb6ba3-879d-56ad-ad62-d5c202156566"
version = "0.5.0"
[[deps.PaddedViews]]
deps = ["OffsetArrays"]
git-tree-sha1 = "0fac6313486baae819364c52b4f483450a9d793f"
uuid = "5432bcbf-9aad-5242-b902-cca2824c8663"
version = "0.5.12"
[[deps.Pango_jll]]
deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "FriBidi_jll", "Glib_jll", "HarfBuzz_jll", "JLLWrappers", "Libdl"]
git-tree-sha1 = "cb5a2ab6763464ae0f19c86c56c63d4a2b0f5bda"
uuid = "36c8627f-9965-5494-a995-c6b170f724f3"
version = "1.52.2+0"
[[deps.Parameters]]
deps = ["OrderedCollections", "UnPack"]
git-tree-sha1 = "34c0e9ad262e5f7fc75b10a9952ca7692cfc5fbe"
uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a"
version = "0.12.3"
[[deps.Parsers]]
deps = ["Dates", "PrecompileTools", "UUIDs"]
git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.8.1"
[[deps.Permutations]]
deps = ["Combinatorics", "LinearAlgebra", "Random"]
git-tree-sha1 = "4ca430561cf37c75964c8478eddae2d79e96ca9b"
uuid = "2ae35dd2-176d-5d53-8349-f30d82d94d4f"
version = "0.4.21"
[[deps.PikaParser]]
deps = ["DocStringExtensions"]
git-tree-sha1 = "d6ff87de27ff3082131f31a714d25ab6d0a88abf"
uuid = "3bbf5609-3e7b-44cd-8549-7c69f321e792"
version = "0.6.1"
[[deps.Pixman_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LLVMOpenMP_jll", "Libdl"]
git-tree-sha1 = "35621f10a7531bc8fa58f74610b1bfb70a3cfc6b"
uuid = "30392449-352a-5448-841d-b1acce4e97dc"
version = "0.43.4+0"
[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.10.0"
[[deps.PkgVersion]]
deps = ["Pkg"]
git-tree-sha1 = "f9501cc0430a26bc3d156ae1b5b0c1b47af4d6da"
uuid = "eebad327-c553-4316-9ea0-9fa01ccd7688"
version = "0.3.3"
[[deps.PlotUtils]]
deps = ["ColorSchemes", "Colors", "Dates", "PrecompileTools", "Printf", "Random", "Reexport", "Statistics"]
git-tree-sha1 = "7b1a9df27f072ac4c9c7cbe5efb198489258d1f5"
uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043"
version = "1.4.1"
[[deps.PolygonOps]]
git-tree-sha1 = "77b3d3605fc1cd0b42d95eba87dfcd2bf67d5ff6"
uuid = "647866c9-e3ac-4575-94e7-e3d426903924"
version = "0.1.2"
[[deps.Polynomials]]
deps = ["LinearAlgebra", "RecipesBase", "Setfield", "SparseArrays"]
git-tree-sha1 = "25e7f73d679e5214971620886d3416c1f5991ecc"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
version = "4.0.9"
[deps.Polynomials.extensions]
PolynomialsChainRulesCoreExt = "ChainRulesCore"
PolynomialsFFTWExt = "FFTW"
PolynomialsMakieCoreExt = "MakieCore"
PolynomialsMutableArithmeticsExt = "MutableArithmetics"
[deps.Polynomials.weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
MakieCore = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
[[deps.PooledArrays]]
deps = ["DataAPI", "Future"]
git-tree-sha1 = "36d8b4b899628fb92c2749eb488d884a926614d3"
uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720"
version = "1.4.3"
[[deps.PositiveFactorizations]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "17275485f373e6673f7e7f97051f703ed5b15b20"
uuid = "85a6dd25-e78a-55b7-8502-1745935b8125"
version = "0.2.4"
[[deps.PrecompileTools]]
deps = ["Preferences"]
git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f"
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
version = "1.2.1"
[[deps.Preferences]]
deps = ["TOML"]
git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.4.3"
[[deps.PrettyTables]]
deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "Reexport", "StringManipulation", "Tables"]
git-tree-sha1 = "66b20dd35966a748321d3b2537c4584cf40387c7"
uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
version = "2.3.2"
[[deps.Primes]]
deps = ["IntegerMathUtils"]
git-tree-sha1 = "cb420f77dc474d23ee47ca8d14c90810cafe69e7"
uuid = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
version = "0.5.6"
[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
[[deps.ProgressMeter]]
deps = ["Distributed", "Printf"]
git-tree-sha1 = "763a8ceb07833dd51bb9e3bbca372de32c0605ad"
uuid = "92933f4c-e287-5a05-a399-4b506db050ca"
version = "1.10.0"
[[deps.PtrArrays]]
git-tree-sha1 = "f011fbb92c4d401059b2212c05c0601b70f8b759"
uuid = "43287f4e-b6f4-7ad1-bb20-aadabca52c3d"
version = "1.2.0"
[[deps.QOI]]
deps = ["ColorTypes", "FileIO", "FixedPointNumbers"]
git-tree-sha1 = "18e8f4d1426e965c7b532ddd260599e1510d26ce"
uuid = "4b34888f-f399-49d4-9bb3-47ed5cae4e65"
version = "1.0.0"
[[deps.QuadGK]]
deps = ["DataStructures", "LinearAlgebra"]
git-tree-sha1 = "9b23c31e76e333e6fb4c1595ae6afa74966a729e"
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
version = "2.9.4"
[[deps.REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
[[deps.Random]]
deps = ["SHA"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[deps.RangeArrays]]
git-tree-sha1 = "b9039e93773ddcfc828f12aadf7115b4b4d225f5"
uuid = "b3c3ace0-ae52-54e7-9d0b-2c1406fd6b9d"
version = "0.3.2"
[[deps.Ratios]]
deps = ["Requires"]
git-tree-sha1 = "1342a47bf3260ee108163042310d26f2be5ec90b"
uuid = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439"
version = "0.4.5"
weakdeps = ["FixedPointNumbers"]
[deps.Ratios.extensions]
RatiosFixedPointNumbersExt = "FixedPointNumbers"
[[deps.RecipesBase]]
deps = ["PrecompileTools"]
git-tree-sha1 = "5c3d09cc4f31f5fc6af001c250bf1278733100ff"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "1.3.4"
[[deps.Reexport]]
git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "1.2.2"
[[deps.RelocatableFolders]]
deps = ["SHA", "Scratch"]
git-tree-sha1 = "ffdaf70d81cf6ff22c2b6e733c900c3321cab864"
uuid = "05181044-ff0b-4ac5-8273-598c1e38db00"
version = "1.0.1"
[[deps.Requires]]
deps = ["UUIDs"]
git-tree-sha1 = "838a3a4188e2ded87a4f9f184b4b0d78a1e91cb7"
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
version = "1.3.0"
[[deps.RingLists]]
deps = ["Random"]
git-tree-sha1 = "f39da63aa6d2d88e0c1bd20ed6a3ff9ea7171ada"
uuid = "286e9d63-9694-5540-9e3c-4e6708fa07b2"
version = "0.2.8"
[[deps.Rmath]]
deps = ["Random", "Rmath_jll"]
git-tree-sha1 = "f65dcb5fa46aee0cf9ed6274ccbd597adc49aa7b"
uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
version = "0.7.1"
[[deps.Rmath_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "d483cd324ce5cf5d61b77930f0bbd6cb61927d21"
uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
version = "0.4.2+0"
[[deps.RoundingEmulator]]
git-tree-sha1 = "40b9edad2e5287e05bd413a38f61a8ff55b9557b"
uuid = "5eaf0fd0-dfba-4ccb-bf02-d820a40db705"
version = "0.2.1"
[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "0.7.0"
[[deps.SIMD]]
deps = ["PrecompileTools"]
git-tree-sha1 = "2803cab51702db743f3fda07dd1745aadfbf43bd"
uuid = "fdea26ae-647d-5447-a871-4b548cad5224"
version = "3.5.0"
[[deps.Scratch]]
deps = ["Dates"]
git-tree-sha1 = "3bac05bc7e74a75fd9cba4295cde4045d9fe2386"
uuid = "6c6a2e73-6563-6170-7368-637461726353"
version = "1.2.1"
[[deps.SentinelArrays]]
deps = ["Dates", "Random"]
git-tree-sha1 = "90b4f68892337554d31cdcdbe19e48989f26c7e6"
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
version = "1.4.3"
[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[deps.Setfield]]
deps = ["ConstructionBase", "Future", "MacroTools", "StaticArraysCore"]
git-tree-sha1 = "e2cc6d8c88613c05e1defb55170bf5ff211fbeac"
uuid = "efcf1570-3423-57d1-acb7-fd33fddbac46"
version = "1.1.1"
[[deps.ShaderAbstractions]]
deps = ["ColorTypes", "FixedPointNumbers", "GeometryBasics", "LinearAlgebra", "Observables", "StaticArrays", "StructArrays", "Tables"]
git-tree-sha1 = "79123bc60c5507f035e6d1d9e563bb2971954ec8"
uuid = "65257c39-d410-5151-9873-9b3e5be5013e"
version = "0.4.1"
[[deps.SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
[[deps.Showoff]]
deps = ["Dates", "Grisu"]
git-tree-sha1 = "91eddf657aca81df9ae6ceb20b959ae5653ad1de"
uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f"
version = "1.0.3"
[[deps.SignedDistanceFields]]
deps = ["Random", "Statistics", "Test"]
git-tree-sha1 = "d263a08ec505853a5ff1c1ebde2070419e3f28e9"
uuid = "73760f76-fbc4-59ce-8f25-708e95d2df96"
version = "0.4.0"
[[deps.SimpleGraphs]]
deps = ["AbstractLattices", "Combinatorics", "DataStructures", "IterTools", "LightXML", "LinearAlgebra", "LinearAlgebraX", "Optim", "Primes", "Random", "RingLists", "SimplePartitions", "SimplePolynomials", "SimpleRandom", "SparseArrays", "Statistics"]
git-tree-sha1 = "f65caa24a622f985cc341de81d3f9744435d0d0f"
uuid = "55797a34-41de-5266-9ec1-32ac4eb504d3"
version = "0.8.6"
[[deps.SimplePartitions]]
deps = ["AbstractLattices", "DataStructures", "Permutations"]
git-tree-sha1 = "e182b9e5afb194142d4668536345a365ea19363a"
uuid = "ec83eff0-a5b5-5643-ae32-5cbf6eedec9d"
version = "0.3.2"
[[deps.SimplePolynomials]]
deps = ["Mods", "Multisets", "Polynomials", "Primes"]
git-tree-sha1 = "7063828369cafa93f3187b3d0159f05582011405"
uuid = "cc47b68c-3164-5771-a705-2bc0097375a0"
version = "0.2.17"
[[deps.SimpleRandom]]
deps = ["Distributions", "LinearAlgebra", "Random"]
git-tree-sha1 = "3a6fb395e37afab81aeea85bae48a4db5cd7244a"
uuid = "a6525b86-64cd-54fa-8f65-62fc48bdc0e8"
version = "0.3.1"
[[deps.SimpleTraits]]
deps = ["InteractiveUtils", "MacroTools"]
git-tree-sha1 = "5d7e3f4e11935503d3ecaf7186eac40602e7d231"
uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
version = "0.9.4"
[[deps.Sixel]]
deps = ["Dates", "FileIO", "ImageCore", "IndirectArrays", "OffsetArrays", "REPL", "libsixel_jll"]
git-tree-sha1 = "2da10356e31327c7096832eb9cd86307a50b1eb6"
uuid = "45858cf5-a6b0-47a3-bbea-62219f50df47"
version = "0.1.3"
[[deps.Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[deps.SortingAlgorithms]]
deps = ["DataStructures"]
git-tree-sha1 = "66e0a8e672a0bdfca2c3f5937efb8538b9ddc085"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "1.2.1"
[[deps.SparseArrays]]
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
version = "1.10.0"
[[deps.SpecialFunctions]]
deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"]
git-tree-sha1 = "2f5d4697f21388cbe1ff299430dd169ef97d7e14"
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "2.4.0"
weakdeps = ["ChainRulesCore"]
[deps.SpecialFunctions.extensions]
SpecialFunctionsChainRulesCoreExt = "ChainRulesCore"
[[deps.StableHashTraits]]
deps = ["Compat", "PikaParser", "SHA", "Tables", "TupleTools"]
git-tree-sha1 = "a58e0d86783226378a6857f2de26d3314107e3ac"
uuid = "c5dd0088-6c3f-4803-b00e-f31a60c170fa"
version = "1.2.0"
[[deps.StackViews]]
deps = ["OffsetArrays"]
git-tree-sha1 = "46e589465204cd0c08b4bd97385e4fa79a0c770c"
uuid = "cae243ae-269e-4f55-b966-ac2d0dc13c15"
version = "0.1.1"
[[deps.StaticArrays]]
deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"]
git-tree-sha1 = "6e00379a24597be4ae1ee6b2d882e15392040132"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.9.5"
weakdeps = ["ChainRulesCore", "Statistics"]
[deps.StaticArrays.extensions]
StaticArraysChainRulesCoreExt = "ChainRulesCore"
StaticArraysStatisticsExt = "Statistics"
[[deps.StaticArraysCore]]
git-tree-sha1 = "192954ef1208c7019899fbf8049e717f92959682"
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
version = "1.4.3"
[[deps.Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
version = "1.10.0"
[[deps.StatsAPI]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "1ff449ad350c9c4cbc756624d6f8a8c3ef56d3ed"
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
version = "1.7.0"
[[deps.StatsBase]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
git-tree-sha1 = "5cf7606d6cef84b543b483848d4ae08ad9832b21"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.34.3"
[[deps.StatsFuns]]
deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
git-tree-sha1 = "cef0472124fab0695b58ca35a77c6fb942fdab8a"
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
version = "1.3.1"
[deps.StatsFuns.extensions]
StatsFunsChainRulesCoreExt = "ChainRulesCore"
StatsFunsInverseFunctionsExt = "InverseFunctions"
[deps.StatsFuns.weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
[[deps.StringManipulation]]
deps = ["PrecompileTools"]
git-tree-sha1 = "a04cabe79c5f01f4d723cc6704070ada0b9d46d5"
uuid = "892a3eda-7b42-436c-8928-eab12a02cf0e"
version = "0.3.4"
[[deps.StructArrays]]
deps = ["ConstructionBase", "DataAPI", "Tables"]
git-tree-sha1 = "f4dc295e983502292c4c3f951dbb4e985e35b3be"
uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
version = "0.6.18"
[deps.StructArrays.extensions]
StructArraysAdaptExt = "Adapt"
StructArraysGPUArraysCoreExt = "GPUArraysCore"
StructArraysSparseArraysExt = "SparseArrays"
StructArraysStaticArraysExt = "StaticArrays"
[deps.StructArrays.weakdeps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
[[deps.SuiteSparse]]
deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"]
uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
[[deps.SuiteSparse_jll]]
deps = ["Artifacts", "Libdl", "libblastrampoline_jll"]
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
version = "7.2.1+1"
[[deps.TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "1.0.3"
[[deps.TableTraits]]
deps = ["IteratorInterfaceExtensions"]
git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39"
uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
version = "1.0.1"
[[deps.Tables]]
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits"]
git-tree-sha1 = "cb76cf677714c095e535e3501ac7954732aeea2d"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "1.11.1"
[[deps.Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
version = "1.10.0"
[[deps.TensorCore]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "1feb45f88d133a655e001435632f019a9a1bcdb6"
uuid = "62fd8b95-f654-4bbd-a8a5-9c27f68ccd50"
version = "0.1.1"
[[deps.Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[deps.TiffImages]]
deps = ["ColorTypes", "DataStructures", "DocStringExtensions", "FileIO", "FixedPointNumbers", "IndirectArrays", "Inflate", "Mmap", "OffsetArrays", "PkgVersion", "ProgressMeter", "SIMD", "UUIDs"]
git-tree-sha1 = "bc7fd5c91041f44636b2c134041f7e5263ce58ae"
uuid = "731e570b-9d59-4bfa-96dc-6df516fadf69"
version = "0.10.0"
[[deps.TranscodingStreams]]
git-tree-sha1 = "a947ea21087caba0a798c5e494d0bb78e3a1a3a0"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.10.9"
weakdeps = ["Random", "Test"]
[deps.TranscodingStreams.extensions]
TestExt = ["Test", "Random"]
[[deps.TriplotBase]]
git-tree-sha1 = "4d4ed7f294cda19382ff7de4c137d24d16adc89b"
uuid = "981d1d27-644d-49a2-9326-4793e63143c3"
version = "0.1.0"
[[deps.TupleTools]]
git-tree-sha1 = "41d61b1c545b06279871ef1a4b5fcb2cac2191cd"
uuid = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
version = "1.5.0"
[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[[deps.UnPack]]
git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b"
uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
version = "1.0.2"
[[deps.Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
[[deps.UnicodeFun]]
deps = ["REPL"]
git-tree-sha1 = "53915e50200959667e78a92a418594b428dffddf"
uuid = "1cfade01-22cf-5700-b092-accc4b62d6e1"
version = "0.4.1"
[[deps.WoodburyMatrices]]
deps = ["LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "c1a7aa6219628fcd757dede0ca95e245c5cd9511"
uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6"
version = "1.0.0"
[[deps.XML2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"]
git-tree-sha1 = "52ff2af32e591541550bd753c0da8b9bc92bb9d9"
uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a"
version = "2.12.7+0"
[[deps.XSLT_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgcrypt_jll", "Libgpg_error_jll", "Libiconv_jll", "Pkg", "XML2_jll", "Zlib_jll"]
git-tree-sha1 = "91844873c4085240b95e795f692c4cec4d805f8a"
uuid = "aed1982a-8fda-507f-9586-7b0439959a61"
version = "1.1.34+0"
[[deps.Xorg_libX11_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libxcb_jll", "Xorg_xtrans_jll"]
git-tree-sha1 = "afead5aba5aa507ad5a3bf01f58f82c8d1403495"
uuid = "4f6342f7-b3d2-589e-9d20-edeb45f2b2bc"
version = "1.8.6+0"
[[deps.Xorg_libXau_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "6035850dcc70518ca32f012e46015b9beeda49d8"
uuid = "0c0b7dd1-d40b-584c-a123-a41640f87eec"
version = "1.0.11+0"
[[deps.Xorg_libXdmcp_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "34d526d318358a859d7de23da945578e8e8727b7"
uuid = "a3789734-cfe1-5b06-b2d0-1dd0d9d62d05"
version = "1.1.4+0"
[[deps.Xorg_libXext_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libX11_jll"]
git-tree-sha1 = "d2d1a5c49fae4ba39983f63de6afcbea47194e85"
uuid = "1082639a-0dae-5f34-9b06-72781eeb8cb3"
version = "1.3.6+0"
[[deps.Xorg_libXrender_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libX11_jll"]
git-tree-sha1 = "47e45cd78224c53109495b3e324df0c37bb61fbe"
uuid = "ea2f1a96-1ddc-540d-b46f-429655e07cfa"
version = "0.9.11+0"
[[deps.Xorg_libpthread_stubs_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "8fdda4c692503d44d04a0603d9ac0982054635f9"
uuid = "14d82f49-176c-5ed1-bb49-ad3f5cbd8c74"
version = "0.1.1+0"
[[deps.Xorg_libxcb_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "XSLT_jll", "Xorg_libXau_jll", "Xorg_libXdmcp_jll", "Xorg_libpthread_stubs_jll"]
git-tree-sha1 = "b4bfde5d5b652e22b9c790ad00af08b6d042b97d"
uuid = "c7cfdc94-dc32-55de-ac96-5a1b8d977c5b"
version = "1.15.0+0"
[[deps.Xorg_xtrans_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "e92a1a012a10506618f10b7047e478403a046c77"
uuid = "c5fb5394-a638-5e4d-96e5-b29de1b5cf10"
version = "1.5.0+0"
[[deps.Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
version = "1.2.13+1"
[[deps.isoband_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "51b5eeb3f98367157a7a12a1fb0aa5328946c03c"
uuid = "9a68df92-36a6-505f-a73e-abb412b6bfb4"
version = "0.2.3+0"
[[deps.libaom_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "1827acba325fdcdf1d2647fc8d5301dd9ba43a9d"
uuid = "a4ae2306-e953-59d6-aa16-d00cac43593b"
version = "3.9.0+0"
[[deps.libass_jll]]
deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "HarfBuzz_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "5982a94fcba20f02f42ace44b9894ee2b140fe47"
uuid = "0ac62f75-1d6f-5e53-bd7c-93b484bb37c0"
version = "0.15.1+0"
[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.8.0+1"
[[deps.libfdk_aac_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "daacc84a041563f965be61859a36e17c4e4fcd55"
uuid = "f638f0a6-7fb0-5443-88ba-1cc74229b280"
version = "2.0.2+0"
[[deps.libpng_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Zlib_jll"]
git-tree-sha1 = "d7015d2e18a5fd9a4f47de711837e980519781a4"
uuid = "b53b4c65-9356-5827-b1ea-8c7a1a84506f"
version = "1.6.43+1"
[[deps.libsixel_jll]]
deps = ["Artifacts", "JLLWrappers", "JpegTurbo_jll", "Libdl", "Pkg", "libpng_jll"]
git-tree-sha1 = "d4f63314c8aa1e48cd22aa0c17ed76cd1ae48c3c"
uuid = "075b6546-f08a-558a-be8f-8157d0f608a5"
version = "1.10.3+0"
[[deps.libvorbis_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg"]
git-tree-sha1 = "b910cb81ef3fe6e78bf6acee440bda86fd6ae00c"
uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a"
version = "1.3.7+1"
[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
version = "1.52.0+1"
[[deps.oneTBB_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "7d0ea0f4895ef2f5cb83645fa689e52cb55cf493"
uuid = "1317d2d5-d96f-522e-a858-c73665f53c3e"
version = "2021.12.0+0"
[[deps.p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
version = "17.4.0+2"
[[deps.x264_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4fea590b89e6ec504593146bf8b988b2c00922b2"
uuid = "1270edf5-f2f9-52d2-97e9-ab00b5d0237a"
version = "2021.5.5+0"
[[deps.x265_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "ee567a171cce03570d77ad3a43e90218e38937a9"
uuid = "dfaa095f-4041-5dcd-9319-2fabd8486b76"
version = "3.5.0+0"
"""
# ╔═╡ Cell order:
# ╠═751853f6-626f-4040-86b2-088339ef9a3c
# ╠═058a7f63-7058-4229-b40c-2e98264bd77f
# ╠═ee8c85f0-6612-4515-89a8-af04298c48bc
# ╠═3dd303b0-373e-11ec-18e4-69bfc20b5e29
# ╠═7ca85dab-6066-4b2a-b61c-9d9607b8756c
# ╠═4ca09326-c8d8-44fb-8582-8dcc071bc76a
# ╠═d06ba72d-a89f-4bc8-98e1-fae8962e70aa
# ╠═3207c229-6a6b-4219-9960-f08ebdff245a
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 1402 | module PlutoStaticHTML
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@max_methods"))
@eval Base.Experimental.@max_methods 1
end
import Base:
show,
string
import Pluto:
PlutoRunner,
WorkspaceManager
using Base64: base64encode
using Dates
using Gumbo: Gumbo, HTMLDocument, HTMLElement, parsehtml
using LazyArtifacts
using Pkg:
Types.Context,
Types.UUID,
Operations
using Pluto:
BondValue,
Cell,
CellOutput,
Configuration.CompilerOptions,
Notebook,
PkgCompat.dependencies,
Pluto,
PlutoRunner,
ServerSession,
SessionActions,
WorkspaceManager,
generate_html,
load_notebook_nobackup,
update_dependency_cache!,
update_run!,
update_save_run!
using RelocatableFolders: @path
using SHA: sha256
using TOML: parse as parsetoml
using tectonic_jll: tectonic
const PKGDIR = @path string(pkgdir(PlutoStaticHTML))::String
const JULIAMONO_VERSION = "0.045"
include("module_doc.jl")
include("context.jl")
include("cache.jl")
include("mimeoverride.jl")
include("with_terminal.jl")
include("output.jl")
include("style.jl")
include("html.jl")
include("html2tex.jl")
include("pdf.jl")
include("build.jl")
include("documenter.jl")
export OutputOptions
export documenter_output, franklin_output, html_output, pdf_output
export BuildOptions, build_notebooks
include("precompile.jl")
end # module
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 17460 | function _is_cell_done(cell)
if cell.metadata["disabled"]
return true
else
return !cell.queued && !cell.running
end
end
function nothingstring(x::Union{Nothing,AbstractString})::Union{Nothing,String}
return x isa Nothing ? x : string(x)::String
end
@enum OutputFormat begin
documenter_output
franklin_output
html_output
pdf_output
end
const WRITE_FILES_DEFAULT = true
const PREVIOUS_DIR_DEFAULT = nothing
const OUTPUT_FORMAT_DEFAULT = html_output
const ADD_DOCUMENTER_CSS_DEFAULT = true
const USE_DISTRIBUTED_DEFAULT = true
const MAX_CONCURRENT_RUNS_DEFAULT = 4
"""
BuildOptions(
dir::AbstractString;
write_files::Bool=$WRITE_FILES_DEFAULT,
previous_dir::Union{Nothing,AbstractString}=$PREVIOUS_DIR_DEFAULT,
output_format::Union{OutputFormat,Vector{OutputFormat}}=$OUTPUT_FORMAT_DEFAULT,
add_documenter_css::Bool=$ADD_DOCUMENTER_CSS_DEFAULT,
use_distributed::Bool=$USE_DISTRIBUTED_DEFAULT,
compiler_options::Union{Nothing,CompilerOptions}=$COMPILER_OPTIONS_DEFAULT,
max_concurrent_runs::Int=$MAX_CONCURRENT_RUNS_DEFAULT
)
Arguments:
- `dir`:
Directory in which the Pluto notebooks are stored.
- `write_files`:
Write files to `joinpath(dir, "\$file.html")`.
- `previous_dir::Union{Nothing,AbstractString}=Nothing`:
Use the output from the previous run as a cache to speed up running time.
To use the cache, specify a directory `previous_dir::AbstractString` which contains HTML or Markdown files from a previous run.
Specifically, files are expected to be at `joinpath(previous_dir, "\$file.html")`.
The output from the previous run may be embedded in a larger HTML or Markdown file.
This package will extract the original output from the full file contents.
By default, caching is disabled.
- `output_format`:
What file to write the output to.
By default this is `html_output::OutputFormat` meaning that the output of the HTML method is pure HTML.
To generate Franklin, Documenter or PDF files, use respectively `franklin_output`, `documenter_output` or `pdf_output`.
When `BuildOptions.write_files == true` and `output_format == franklin_output` or `output_format == documenter_output`, the output file has a ".md" extension instead of ".html".
When `BuildOptions.write_files == true` and `output_format == pdf_output`, two output files are created with ".tex" and ".pdf" extensions.
- `add_documenter_css` whether to add a CSS style to the HTML when `documenter_output=true`.
- `use_distributed`:
Whether to build the notebooks in different processes.
By default, this is enabled just like in Pluto and the notebooks are build in parallel.
The benefit of different processes is that things are more independent of each other.
Unfortunately, the drawback is that compilation has to happen for each process.
By setting this option to `false`, all notebooks are built sequentially in the same process which avoids recompilation.
This is likely quicker in situations where there are few threads available such as GitHub Runners depending on the notebook contents.
Beware that `use_distributed=false` will **not** work with Pluto's built-in package manager.
- `compiler_options`:
`Pluto.Configuration.CompilerOptions` to be passed to Pluto.
This can, for example, be useful to pass custom system images from `PackageCompiler.jl`.
- `max_concurrent_runs`:
Maximum number of notebooks to evaluate concurrently when `use_distributed=true`.
Note that each notebook starts in a different process and can start multiple threads, so don't set this number too high or the CPU might be busy switching tasks and not do any productive work.
"""
struct BuildOptions
dir::String
write_files::Bool
previous_dir::Union{Nothing,String}
output_format::Vector{OutputFormat}
add_documenter_css::Bool
use_distributed::Bool
compiler_options::Union{Nothing,CompilerOptions}
max_concurrent_runs::Int
function BuildOptions(
dir::AbstractString;
write_files::Bool=WRITE_FILES_DEFAULT,
previous_dir::Union{Nothing,AbstractString}=PREVIOUS_DIR_DEFAULT,
output_format::Union{OutputFormat,Vector{OutputFormat}}=OUTPUT_FORMAT_DEFAULT,
add_documenter_css::Bool=ADD_DOCUMENTER_CSS_DEFAULT,
use_distributed::Bool=USE_DISTRIBUTED_DEFAULT,
compiler_options::Union{Nothing,CompilerOptions}=COMPILER_OPTIONS_DEFAULT,
max_concurrent_runs::Int=MAX_CONCURRENT_RUNS_DEFAULT
)
if !(output_format isa Vector)
output_format = OutputFormat[output_format]
end
return new(
string(dir)::String,
write_files,
nothingstring(previous_dir),
output_format,
add_documenter_css,
use_distributed,
compiler_options,
max_concurrent_runs
)
end
end
"""
_is_notebook_done(notebook::Notebook)
Return whether all cells in the `notebook` have executed.
This method is more reliable than using `notebook.executetoken` because Pluto.jl drops that lock also after installing packages.
"""
function _notebook_done(notebook::Notebook)
cells = [last(elem) for elem in notebook.cells_dict]
return all(_is_cell_done, cells)
end
function _wait_for_notebook_done(nb::Notebook)
while !_notebook_done(nb)
sleep(1)
end
end
function extract_previous_output(html::AbstractString)::String
start_range = findfirst(BEGIN_IDENTIFIER, html)
@assert !isnothing(start_range)
start = first(start_range)
stop_range = findfirst(END_IDENTIFIER, html)
@assert !isnothing(stop_range)
stop = last(stop_range)
return html[start:stop]
end
"""
Previous(state::State, html::String)
- `state`: Previous state.
- `text`: Either
- HTML starting with "$BEGIN_IDENTIFIER" and ending with "$END_IDENTIFIER" or
- Contents of a Franklin/Documenter Markdown file.
"""
struct Previous
state::Union{State,Nothing}
text::String
end
function Previous(text::String)
state = contains(text, STATE_IDENTIFIER) ?
extract_state(text) :
nothing
text = contains(text, BEGIN_IDENTIFIER) ?
extract_previous_output(text) :
""
return Previous(state, text)
end
function Previous(previous_dir, output_format::OutputFormat, in_file)
prev_dir = previous_dir
if isnothing(prev_dir)
return Previous(nothing, "")
end
name, _ = splitext(in_file)
ext = output_format == html_output ? ".html" : ".md"
prev_path = joinpath(prev_dir, "$name$ext")
if !isfile(prev_path)
@info "Could not find cache for \"$in_file\" at \"$prev_path\""
return Previous(nothing, "")
end
text = read(prev_path, String)
return Previous(text)
end
function reuse_previous(previous::Previous, dir, in_file)::Bool
in_path = joinpath(dir, in_file)
curr = path2state(in_path)
prev = previous.state
if isnothing(prev)
return false
end
sha_match = prev.input_sha == curr.input_sha
if !sha_match
@info "SHA of previous file did not match the SHA of the current file. Ignoring cache for \"$in_file\""
end
julia_match = prev.julia_version == curr.julia_version
if !julia_match
@info "Julia version of previous file did not match the current version. Ignoring cache for \"$in_file\""
end
reuse = sha_match && julia_match
return reuse
end
"""
Write to a ".html" or ".md" file depending on `OutputOptions.output_format`.
The output file is always a sibling to the file at `in_path`.
"""
function _write_main_output(
in_path::String,
text::String,
bopts::BuildOptions,
output_format::OutputFormat,
oopts::OutputOptions
)
ext = output_format == html_output ? ".html" :
output_format == pdf_output ? ".pdf" : ".md"
if bopts.write_files
dir = dirname(in_path)
in_file = basename(in_path)
without_extension, _ = splitext(in_file)
out_file = "$(without_extension)$(ext)"
out_path = joinpath(dir, out_file)
@info "Writing output to \"$out_path\""
write(out_path, text)
end
return nothing
end
"Used when creating the page for the first time and to restore the cache."
function _wrap_franklin_output(html)
return "~~~\n$(html)\n~~~"
end
"Used when creating the page for the first time and when restoring the cache."
function _wrap_documenter_output(html::String, bopts::BuildOptions, in_path::String)
if bopts.add_documenter_css
html = _add_documenter_css(html)
end
editurl = _editurl_text(bopts, in_path)
return """
```@raw html
$(_fix_header_links(html))
```
$editurl
"""
end
function _outcome2text(session, prevs::Vector{Previous}, in_path::String, bopts, oopts)::Vector{String}
texts = map(zip(prevs, bopts.output_format)) do (prev, output_format)
text = prev.text
if output_format == franklin_output
text = _wrap_franklin_output(text)
end
if output_format == documenter_output
text = _wrap_documenter_output(text, bopts, in_path)
end
_write_main_output(in_path, text, bopts, output_format, oopts)
return text
end
return texts
end
function _inject_script(html, script)
l = length(END_IDENTIFIER)
without_end = html[1:end-l]
return string(without_end, '\n', script, '\n', END_IDENTIFIER)
end
function _outcome2pdf(
nb::Notebook,
in_path::String,
bopts::BuildOptions,
output_format::OutputFormat,
oopts::OutputOptions
)
@assert output_format == pdf_output
tex = notebook2tex(nb, in_path, oopts)
# _write_main_output(...)
return tex
end
function _outcome2html(
nb::Notebook,
in_path::String,
bopts::BuildOptions,
output_format::OutputFormat,
oopts::OutputOptions
)
html = notebook2html(nb, in_path, oopts)
if output_format == franklin_output
html = _wrap_franklin_output(html)
end
if output_format == documenter_output
html = _wrap_documenter_output(html, bopts, in_path)
end
_write_main_output(in_path, html, bopts, output_format, oopts)
return string(html)::String
end
function _outcome2text(session, nb::Notebook, in_path::String, bopts, oopts)::Vector{String}
_throw_if_error(session, nb)
texts = map(bopts.output_format) do output_format
if output_format == pdf_output
return _outcome2pdf(nb, in_path, bopts, output_format, oopts)
else
return _outcome2html(nb, in_path, bopts, output_format, oopts)
end
end
# The sleep avoids `AssertionError: will_run_code(notebook)`
@async begin
sleep(5)
SessionActions.shutdown(session, nb; verbose=false)
end
return texts
end
const TimeState = Dict{String,DateTime}
_time_init!(time_state::TimeState, in_file::String) = setindex!(time_state, now(), in_file)
_time_elapsed(time_state::TimeState, in_file::String) = now() - time_state[in_file]
"Return `... minutes and ... seconds`."
function _pretty_elapsed(t::Millisecond)
value = t.value
seconds = Float64(value) / 1000
min, sec = divrem(seconds, 60)
rmin = round(Int, min)
min_text = rmin == 0 ? "" :
rmin == 1 ? "$rmin minute and " :
"$rmin minutes and "
rsec = round(Int, sec)
sec_text = rsec == 1 ? "$rsec second" : "$rsec seconds"
return string(min_text, sec_text)
end
"Return multiple previous files (caches) or nothing when a new evaluation is needed."
function _prevs(bopts::BuildOptions, dir, in_file)::Union{Vector{Previous},Nothing}
prevs = Previous[]
for output_format in bopts.output_format
prev = Previous(bopts.previous_dir, output_format, in_file)
if !reuse_previous(prev, dir, in_file)
return nothing
end
push!(prevs, prev)
end
return prevs
end
function run_notebook!(
path::AbstractString,
session::ServerSession;
compiler_options::Union{Nothing,CompilerOptions}=nothing,
run_async::Bool=false
)
# Avoid changing pwd.
previous_dir = pwd()
session.options.server.disable_writing_notebook_files = true
nb = SessionActions.open(session, path; compiler_options, run_async)
if !run_async
_throw_if_error(session, nb)
end
cd(previous_dir)
return nb
end
function _add_extra_preamble!(session::ServerSession)
current = session.options.evaluation.workspace_custom_startup_expr
config = string(CONFIG_PLUTORUNNER)::String
# Avoids warning message to show up multiple every time
# https://github.com/rikhuijzer/PlutoStaticHTML.jl/pull/172.
if current !== nothing
@assert typeof(current) == typeof(config) "$(typeof(current)) != $(typeof(config))"
end
if current !== nothing && current != config
@warn "Expected the `workspace_custom_startup_expr` setting to not be set by someone else; overriding it."
end
session.options.evaluation.workspace_custom_startup_expr = config
return session
end
"""
_evaluate_file(bopts, oopts, session, in_file, time_state)
Return either
- `Vector{Previous}` if the cache was a hit for all `output_format`s, or
- `Notebook` if there was a cache miss for one or more `output_format`s.
"""
function _evaluate_file(bopts::BuildOptions, oopts::OutputOptions, session, in_file, time_state)
dir = bopts.dir
in_path = joinpath(dir, in_file)::String
@assert isfile(in_path) "File not found at \"$in_path\""
@assert (string(splitext(in_file)[2]) == ".jl") "File doesn't have a `.jl` extension at \"$in_path\""
_add_extra_preamble!(session)
prevs = _prevs(bopts, dir, in_file)
if !isnothing(prevs)
@info "Using cache for Pluto notebook at \"$in_file\""
return prevs
else
@info "Starting evaluation of Pluto notebook \"$in_file\""
if bopts.use_distributed
run_async = true
else
run_async = false
# `use_distributed` means mostly "whether to run in a new process".
session.options.evaluation.workspace_use_distributed = false
end
nb = run_notebook!(in_path, session; bopts.compiler_options, run_async)
if bopts.use_distributed
# The notebook is running in a distributed process, but we still need to wait to
# avoid spawning too many processes in `_evaluate_parallel`.
_wait_for_notebook_done(nb)
end
elapsed = _time_elapsed(time_state, in_file)
pretty_elapsed = _pretty_elapsed(elapsed)
@info "Finished evaluation of Pluto notebook \"$in_file\" in $pretty_elapsed"
return nb
end
end
"""
Evaluate `files` in parallel.
Using asynchronous tasks instead of multi-threading since Downloads is not thread-safe on Julia 1.6/1.7.
https://github.com/JuliaLang/Downloads.jl/issues/110.
"""
function _evaluate_parallel(bopts, oopts, session, files, time_state)
ntasks = bopts.max_concurrent_runs
X = asyncmap(files; ntasks) do in_file
_time_init!(time_state, in_file)
_evaluate_file(bopts, oopts, session, in_file, time_state)
end
return X
end
function _evaluate_sequential(bopts, oopts, session, files, time_state)
X = map(files) do in_file
_time_init!(time_state, in_file)
_evaluate_file(bopts, oopts, session, in_file, time_state)
end
return X
end
"""
build_notebooks(
bopts::BuildOptions,
[files,]
oopts::OutputOptions=OutputOptions();
session=ServerSession()
)
Build Pluto notebook `files` in `dir`.
Here, `files` is optional.
When not passing `files`, then all Pluto notebooks in `dir` will be built.
# Example
```
julia> dir = joinpath(homedir(), "my_project", "notebooks");
julia> bopts = BuildOptions(dir);
julia> oopts = OutputOptions(; append_build_context=true);
julia> files = ["pi.jl", "math.jl"];
julia> build_notebooks(bopts, files, oopts);
```
"""
function build_notebooks(
bopts::BuildOptions,
files,
oopts::OutputOptions=OutputOptions();
session=ServerSession()
)::Dict{String,Vector{String}}
time_state = TimeState()
func = bopts.use_distributed ? _evaluate_parallel : _evaluate_sequential
# Vector containing Notebooks and or Previous.
X = func(bopts, oopts, session, files, time_state)::Vector
# One `String` for every build_output.
outputs = Dict{String,Vector{String}}()
for (in_file, x::Union{Vector{Previous},Notebook}) in zip(files, X)
in_path = joinpath(bopts.dir, in_file)
text = _outcome2text(session, x, in_path, bopts, oopts)
outputs[in_file] = text
end
return outputs
end
function _is_pluto_file(path::AbstractString)::Bool
first(eachline(string(path))) == "### A Pluto.jl notebook ###"
end
function build_notebooks(
bopts::BuildOptions,
oopts::OutputOptions=OutputOptions()
)::Dict{String,Vector{String}}
dir = bopts.dir
files = filter(readdir(dir)) do file
path = joinpath(dir, file)
endswith(file, ".jl") && _is_pluto_file(path) && !startswith(file, TMP_COPY_PREFIX)
end
return build_notebooks(bopts, files, oopts)
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 1614 | sha(s) = bytes2hex(sha256(s))
path2sha(path::AbstractString) = sha(read(path))
"""
State(input_sha::String, julia_version::String)
State obtained from a Pluto notebook file (".jl") where
- `input_sha`: SHA checksum calculated over the file
- `julia_version`: \\\$VERSION
"""
struct State
input_sha::String
julia_version::String
end
"""
State(text::AbstractString)
Create a new State from a Pluto notebook file (".jl").
"""
State(text::AbstractString) = State(sha(text), string(VERSION))
function n_cache_lines()
# Determine length by using `string(state::State)`.
state = State("a", "b")
lines = split(string(state), '\n')
return length(lines)
end
const STATE_IDENTIFIER = "[PlutoStaticHTML.State]"
function string(state::State)::String
return """
<!--
# This information is used for caching.
$STATE_IDENTIFIER
input_sha = "$(state.input_sha)"
julia_version = "$(state.julia_version)"
-->
"""
end
"Extract State from a HTML file which contains a State as string somewhere."
function extract_state(html::AbstractString)::State
sep = '\n'
lines = split(html, sep)
start = findfirst(contains(STATE_IDENTIFIER), lines)::Int
stop = start + 2
info = join(lines[start:stop], sep)
entries = parsetoml(info)["PlutoStaticHTML"]["State"]
return State(entries["input_sha"], entries["julia_version"])
end
"Convert a notebook at `path` to a State."
function path2state(path::AbstractString)::State
@assert endswith(path, ".jl")
code = read(path, String)
State(code)
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 1237 | """
_direct_dependencies(notebook::Notebook) -> String
Return the direct dependencies for a `notebook`.
"""
function _direct_dependencies(notebook::Notebook)::String
ctx = notebook.nbpkg_ctx
if isnothing(ctx)
error("""
Failed to determine the notebook dependencies from the state of Pluto's built-in package manager
This can be fixed by setting `append_build_context=false`.
See https://github.com/rikhuijzer/PlutoStaticHTML.jl/issues/74 for more information and open an issue if the problem persists.
""")
end
deps = [last(pair) for pair in dependencies(ctx)]
filter!(p -> p.is_direct_dep, deps)
# Ignore stdlib modules.
filter!(p -> !isnothing(p.version), deps)
list = ["$(p.name) $(p.version)" for p in deps]
sort!(list)
return join(list, "<br>\n")::String
end
"""
_context(notebook::Notebook) -> String
Return build context, such as the Julia version and package versions, for `notebook`.
"""
function _context(notebook::Notebook)::String
deps = _direct_dependencies(notebook)
return """
<div class='manifest-versions'>
<p>Built with Julia $VERSION and</p>
$deps
</div>
"""
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 2281 | """
Return path to the notebook starting with "/docs/src/".
The "/docs/src/" assumption is required since we don't know the module.
"""
function _relative_notebook_path(bopts::BuildOptions, in_path::String)::Union{String,Nothing}
absolute_path = joinpath(bopts.dir, in_path)
pos = findfirst("/docs/src/", absolute_path)
if !isnothing(pos)
relative_path = absolute_path[first(pos) + 1:end]
return string(relative_path)
else
return nothing
end
end
function _editurl_text(
bopts::BuildOptions,
github_repo::String,
branch::String,
in_path::String
)
path = _relative_notebook_path(bopts, in_path)
url = "https://github.com/$github_repo/blob/$branch/$path"
return """
```@meta
EditURL = "$url"
```
"""
end
function _editurl_text(bopts::BuildOptions, in_path::String)::String
github_repo = get(ENV, "GITHUB_REPOSITORY", "")
if github_repo != ""
# Only when we're in GitHub's CI, it is possible to figure out the path to the file.
# "refs/heads/$(branchname)" for branch, "refs/tags/$(tagname)" for tags.
# Thanks to Documenter for this comment.
github_ref = get(ENV, "GITHUB_REF", "")
if github_ref != ""
prefix = "refs/heads/"
if contains(github_ref, prefix)
branch = github_ref[length(prefix) + 1:end]
return _editurl_text(bopts, github_repo, branch, in_path)
else
# We're on a tag so maybe that's a triggered deploy for stable docs?
branch = "main"
return _editurl_text(bopts, github_repo, branch, in_path)
end
else
@warn "github_ref was empty which is unexpected"
return ""
end
else
return ""
end
end
"""
Return raw_html where Markdown headers hidden in the HTML are converted back to Markdown so that Documenter parses them.
"""
function _fix_header_links(html::String)
rx = r"""<div class="markdown"><h2>([^<]*)<\/h2>"""
substitution_string = s"""
```
## \1
```@raw html
<div class="markdown">
"""
return replace(html, rx => substitution_string)
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 6129 | """
_escape_html(s::AbstractString)
Escape HTML.
Useful for showing HTML inside code blocks, see
https://github.com/rikhuijzer/PlutoStaticHTML.jl/issues/9.
"""
function _escape_html(s::AbstractString)
s = replace(s, '<' => "<")
s = replace(s, '>' => ">")
return s
end
function code_block(code; pre_class="language-julia", code_class="")
if code == ""
return ""
end
code = _escape_html(code)
return "<pre class='$pre_class'><code class='$code_class'>$code</code></pre>"
end
function output_block(s; output_pre_class="pre-class", var="")
if s == ""
return ""
end
id = var == "" ? "" : "id='var-$var'"
return "<pre $id class='$output_pre_class'>$s</pre>"
end
function _code2html(cell::Cell, oopts::OutputOptions)
if oopts.hide_code || cell.code_folded
return ""
end
code = cell.code
if oopts.hide_md_code && startswith(code, "md\"")
return ""
end
if oopts.hide_md_def_code
lstripped = lstrip(code, ['\"', ' ', '\n', '\r'])
if startswith(lstripped, "+++")
return ""
end
end
if oopts.replace_code_tabs
code = _replace_code_tabs(code)
end
if contains(code, "# hideall")
return ""
end
sep = '\n'
lines = split(code, sep)
filter!(!endswith("# hide"), lines)
code = join(lines, sep)
return code_block(code; oopts.code_class)
end
function _output2html(cell::Cell, T::IMAGEMIME, oopts)
encoded = base64encode(cell.output.body)
uri = "data:$T;base64,$encoded"
return """<img src="$uri">"""
end
function _tr_wrap(elements::Vector)
joined = join(elements, '\n')
return "<tr>\n$joined\n</tr>"
end
_tr_wrap(::Array{String, 0}) = "<tr>\n<td>...</td>\n</tr>"
function _output2html(cell::Cell, ::MIME"application/vnd.pluto.table+object", oopts)
body = cell.output.body::Dict{Symbol,Any}
rows = body[:rows]
nms = body[:schema][:names]
wide_truncated = false
if rows[1][end][end] == "more"
# Replace "more" by "..." in the last column of wide tables.
nms[end] = "..."
wide_truncated = true
end
headers = _tr_wrap(["<th>$colname</th>" for colname in [""; nms]])
contents = map(rows) do row
index = row[1]
row = row[2:end]
# Unpack the type and throw away mime info.
elements = try
first.(only(row))
catch
first.(first.(row))
end
if eltype(elements) != Char && wide_truncated
elements[end] = ""
end
eltype(index) != Char ? pushfirst!(elements, string(index)::String) : ""
elements = ["<td>$e</td>" for e in elements]
return _tr_wrap(elements)
end
content = join(contents, '\n')
return """
<table>
$headers
$content
</table>
"""
end
"""
_var(cell::Cell)::Symbol
Return the variable which is set by `cell`.
This method requires that the notebook to be executed be able to give the right results.
"""
function _var(cell::Cell)::Symbol
ra = cell.output.rootassignee
if isnothing(ra)
mapping = cell.cell_dependencies.downstream_cells_map
K = keys(mapping)
if isempty(K)
h = hash(cell.code)
# This is used when storing binds to give it reproducible name.
return Symbol(first(string("hash", h), 10))
end
# `only` cannot be used because loading packages can give multiple keys.
return first(K)
else
return ra
end
end
function _output2html(cell::Cell, ::MIME"text/plain", oopts)
var = _var(cell)
body = string(cell.output.body)::String
# `+++` means that it is a cell with Franklin definitions.
if oopts.hide_md_def_code && startswith(body, "+++")
# Go back into Markdown mode instead of HTML
return string("~~~\n", body, "\n~~~")
end
output_block(body; oopts.output_pre_class, var)
end
function _patch_inline_math(body::String)::String
body = replace(body, raw"""<span class="tex">$""" => raw"""<span class="tex">\(""")
body = replace(body, raw"""$</span>""" => raw"""\)</span>""")
body
end
function _output2html(cell::Cell, ::MIME"text/html", oopts)
body = string(cell.output.body)::String
body = _patch_inline_math(body)
if contains(body, """<script type="text/javascript" id="plutouiterminal">""")
return _patch_with_terminal(body)
end
# The docstring is already visible in Markdown and shouldn't be shown below the code.
if startswith(body, """<div class="pluto-docs-binding">""")
return ""
end
return body
end
function _output2html(cell::Cell, ::MIME"application/vnd.pluto.stacktrace+object", oopts)
return error(string(cell.output.body)::String)
end
_output2html(cell::Cell, T::MIME, oopts) = error("Unknown type: $T")
function _cell2html(cell::Cell, oopts::OutputOptions)
if cell.metadata["disabled"]
return ""
end
code = _code2html(cell, oopts)
output = _output2html(cell, cell.output.mime, oopts)
if oopts.convert_admonitions
output = _convert_admonitions(output)
end
if oopts.show_output_above_code
return """
$output
$code
"""
else
return """
$code
$output
"""
end
end
"""
notebook2html(nb::Notebook, path, opts::OutputOptions=OutputOptions())::String
Return the code and output as HTML for `nb`.
Assumes that the notebook has already been executed.
"""
function notebook2html(nb::Notebook, path, oopts::OutputOptions=OutputOptions())::String
@assert isready(nb)
order = nb.cell_order
outputs = map(order) do cell_uuid
cell = nb.cells_dict[cell_uuid]
_cell2html(cell, oopts)
end
html = join(outputs, '\n')
if oopts.add_state && !isnothing(path)
html = string(path2state(path)) * html
end
if oopts.append_build_context
html = html * _context(nb)
end
html = string(BEGIN_IDENTIFIER, '\n', html, '\n', END_IDENTIFIER)::String
return html
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 857 | using AbstractTrees: AbstractTrees
using Gumbo: Gumbo, parsehtml
_strip_div(s::String) = replace(s, r"<\/?div[^>]*>" => "")
function _handle_p(s::String)
s = replace(s, "<p>" => "\\par{")
s = replace(s, "</p>" => "}")
return s
end
function map!(f::Function, doc::Gumbo.HTMLDocument)
for elem in AbstractTrees.PreOrderDFS(doc.root)
if elem isa Gumbo.HTMLElement
# Changing elem directly doesn't work, so we loop direct children.
children = elem.children
for i in 1:length(children)
elem.children[i] = f(elem.children[i])
end
end
# else (isa Gumbo.HTMLText) is handled by the fact that we loop direct children.
end
return doc
end
function _html2tex(s::String)
doc = parsehtml(s)
# map!(println, doc)
return string(doc)::String
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 315 | # Keep this a quote because it's used in `eval` below.
const CONFIG_PLUTORUNNER = quote
PlutoRunner.is_mime_enabled(::MIME"application/vnd.pluto.tree+object") = false
PlutoRunner.PRETTY_STACKTRACES[] = false
end
# These overrides are used when `use_distributed=false`.
eval(CONFIG_PLUTORUNNER)
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 603 | let
text = raw"""
# PlutoStaticHTML.jl
To quickly build two notebooks (evaluate all the code and convert the output to HTML), use:
```
julia> dir = joinpath("posts", "notebooks");
julia> files = ["notebook1.jl", "notebook2.jl"];
julia> build_notebooks(BuildOptions(dir), files)
```
and to build all notebooks, use:
```
julia> build_notebooks(BuildOptions(dir))
```
See https://rikhuijzer.github.io/PlutoStaticHTML.jl/dev/ for the full documentation.
"""
@doc text PlutoStaticHTML
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 6946 | """
IMAGEMIME
Union of MIME image types.
Based on Pluto.PlutoRunner.imagemimes.
"""
const IMAGEMIME = Union{
MIME"image/svg+xml",
MIME"image/png",
MIME"image/jpg",
MIME"image/jpeg",
MIME"image/bmp",
MIME"image/gif"
}
const CODE_CLASS_DEFAULT = "language-julia"
const OUTPUT_PRE_CLASS_DEFAULT = "code-output documenter-example-output"
const HIDE_CODE_DEFAULT = false
const HIDE_MD_CODE_DEFAULT = true
const HIDE_MD_DEF_CODE_DEFAULT = true
const ADD_STATE_DEFAULT = true
const APPEND_BUILD_CONTEXT_DEFAULT = false
const COMPILER_OPTIONS_DEFAULT = nothing
const SHOW_OUTPUT_ABOVE_CODE_DEFAULT = false
const REPLACE_CODE_TABS_DEFAULT = true
const CONVERT_ADMONITIONS_DEFAULT = true
"""
OutputOptions(;
code_class::AbstractString="$CODE_CLASS_DEFAULT",
output_pre_class::AbstractString="$OUTPUT_PRE_CLASS_DEFAULT",
hide_code::Bool=$HIDE_CODE_DEFAULT,
hide_md_code::Bool=$HIDE_MD_CODE_DEFAULT,
hide_md_def_code::Bool=$HIDE_MD_DEF_CODE_DEFAULT,
add_state::Bool=$ADD_STATE_DEFAULT,
append_build_context::Bool=$APPEND_BUILD_CONTEXT_DEFAULT,
show_output_above_code::Bool=$SHOW_OUTPUT_ABOVE_CODE_DEFAULT,
replace_code_tabs::Bool=$REPLACE_CODE_TABS_DEFAULT,
convert_admonitions::Bool=$CONVERT_ADMONITIONS_DEFAULT
)
Arguments:
- `code_class`:
HTML class for code.
This is used by CSS and/or the syntax highlighter.
- `output_pre_class`:
HTML class for `<pre>`.
- `output_class`:
HTML class for output.
This is used by CSS and/or the syntax highlighter.
- `hide_code`:
Whether to omit all code blocks.
Can be useful when readers are not interested in code at all.
- `hide_md_code`:
Whether to omit all Markdown code blocks.
- `hide_md_def_code`:
Whether to omit Franklin Markdown definition code blocks (blocks surrounded by +++).
- `add_state`:
Whether to add a comment in HTML with the state of the input notebook.
This state can be used for caching.
Specifically, this state stores a checksum of the input notebook and the Julia version.
- `append_build_context`:
Whether to append build context.
When set to `true`, this adds information about the dependencies and Julia version.
This is not executed via Pluto.jl's evaluation to avoid having to add extra dependencies to existing notebooks.
Instead, this reads the manifest from the notebook file.
- `show_output_above_code`:
Whether to show the output from the code above the code.
Pluto.jl shows the output above the code by default; this package shows the output below the code by default.
To show the output above the code, set `show_output_above_code=true`.
- `replace_code_tabs`:
Replace tabs at the start of lines inside code blocks with spaces.
This avoids inconsistent appearance of code blocks on web pages.
- `convert_admonitions`:
Convert admonitions such as
```
!!! note
This is a note.
```
from Pluto's HTML to Documenter's HTML.
When this is enabled, the `documenter_output` has proper styling by default.
"""
struct OutputOptions
code_class::String
output_pre_class::String
hide_code::Bool
hide_md_code::Bool
hide_md_def_code::Bool
add_state::Bool
append_build_context::Bool
show_output_above_code::Bool
replace_code_tabs::Bool
convert_admonitions::Bool
function OutputOptions(;
code_class::AbstractString=CODE_CLASS_DEFAULT,
output_pre_class::AbstractString=OUTPUT_PRE_CLASS_DEFAULT,
hide_code::Bool=HIDE_CODE_DEFAULT,
hide_md_code::Bool=HIDE_MD_CODE_DEFAULT,
hide_md_def_code::Bool=HIDE_MD_DEF_CODE_DEFAULT,
add_state::Bool=ADD_STATE_DEFAULT,
append_build_context::Bool=APPEND_BUILD_CONTEXT_DEFAULT,
show_output_above_code::Bool=SHOW_OUTPUT_ABOVE_CODE_DEFAULT,
replace_code_tabs::Bool=REPLACE_CODE_TABS_DEFAULT,
convert_admonitions::Bool=CONVERT_ADMONITIONS_DEFAULT
)
return new(
string(code_class)::String,
string(output_pre_class)::String,
hide_code,
hide_md_code,
hide_md_def_code,
add_state,
append_build_context,
show_output_above_code,
replace_code_tabs,
convert_admonitions
)
end
end
function _code_tabs_replacer(x::SubString{String})
replace(x, '\t' => " ")
end
"Replace tabs by spaces in code blocks."
function _replace_code_tabs(code)
# Match all tabs at start of line or start of newline.
rx = r"(^|\r|\n)([\t]*)"
replace(code, rx => _code_tabs_replacer)
end
abstract type Struct end
function symbol2type(s::Symbol)
if s == :Tuple
return Tuple
elseif s == :Array
return Array
elseif s == :struct
return Struct
else
@warn "Missing type: $s"
return Missing
end
end
const BEGIN_IDENTIFIER = "<!-- PlutoStaticHTML.Begin -->"
const END_IDENTIFIER = "<!-- PlutoStaticHTML.End -->"
isready(nb::Notebook) = nb.process_status == "ready"
const TMP_COPY_PREFIX = "_tmp_"
function _retry_run(session, nb, cell::Cell)
Pluto.update_save_run!(session, nb, [cell])
end
"Indent each line by two spaces."
function _indent(s::AbstractString)::String
return replace(s, '\n' => "\n ")::String
end
function _throw_if_error(session::ServerSession, nb::Notebook)
cells = [nb.cells_dict[cell_uuid] for cell_uuid in nb.cell_order]
for cell in cells
if cell.errored
# Re-try running macro cells.
# Hack for Pluto.jl/issues/1664.
if startswith(cell.code, '@')
_retry_run(session, nb, cell)
if !cell.errored
continue
end
end
filename = _indent(nb.path)
code = _indent(cell.code)
body = cell.output.body::Dict{Symbol,Any}
error_text::String = if haskey(body, :stacktrace)
if body[:stacktrace] isa CapturedException
val = body[:stacktrace]::CapturedException
io = IOBuffer()
ioc = IOContext(io, :color => Base.get_have_color())
showerror(ioc, val)
_indent(String(take!(io)))
else
_indent(string(body[:stacktrace])::String)
end
else
# Fallback.
string(body)::String
end
msg = """
Execution of notebook failed.
Does the notebook show any errors when opening it in Pluto?
Notebook:
$filename
Code:
$code
Error:
$error_text
"""
error(msg)
end
end
return nothing
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 4097 | function run_tectonic(args::Vector)
return read(`$(tectonic()) $args`, String)
end
tectonic_version() = strip(run_tectonic(["--version"]))
function _code2tex(code::String, oopts::OutputOptions)
if oopts.hide_code
return ""
end
if oopts.hide_md_code && startswith(code, "md\"")
return ""
end
return """
\\begin{lstlisting}[language=Julia]
$code
\\end{lstlisting}
"""
end
function _verbatim(text::String, language::String)
return """
\\begin{lstlisting}[language=$language]
$text
\\end{lstlisting}
"""
end
function tex_code_block(code)
if code == ""
return ""
end
return _verbatim(code, "Julia")
end
function tex_output_block(text::String)
text == "" && return ""
return _verbatim(text, "Output")
end
function _output2tex(cell::Cell, ::MIME"text/plain", oopts::OutputOptions)
body = string(cell.output.body)::String
# `+++` means that it is a cell with Franklin definitions.
if oopts.hide_md_def_code && startswith(body, "+++")
return ""
end
return tex_output_block(body)
end
function _output2tex(cell::Cell, ::MIME"text/html", oopts::OutputOptions)
body = cell.output.body
return _html2tex(body)
end
function _output2tex(cell::Cell, T, oopts::OutputOptions)
return "<output>"
end
function _cell2tex(cell::Cell, oopts::OutputOptions)
code = _code2tex(cell.code, oopts)
output = _output2tex(cell, cell.output.mime, oopts)
if oopts.show_output_above_code
return """
$output
$code
"""
else
return """
$code
$output
"""
end
end
"Return the directory of JuliaMono with a trailing slash to please fontspec."
function _juliamono_dir()
artifact = LazyArtifacts.artifact"JuliaMono"
dir = joinpath(artifact, string("juliamono-", JULIAMONO_VERSION))
return string(dir, '/')
end
function _tex_header()
juliamono_dir = _juliamono_dir()
listings = joinpath(PKGDIR, "src", "listings", "julia_listings.tex")
unicode = joinpath(PKGDIR, "src", "listings", "julia_listings_unicode.tex")
return """
\\documentclass{article}
\\usepackage[left=3cm,top=1.5cm,right=3cm,bottom=2cm]{geometry}
\\usepackage{fontspec}
\\setmonofont{JuliaMono-Regular.ttf}[
Path = $(juliamono_dir)/,
Contextuals = Alternate,
Ligatures = NoCommon
]
\\newfontfamily{\\juliabold}{JuliaMono-Bold.ttf}[
Path = $(juliamono_dir)/,
Contextuals = Alternate,
Ligatures = NoCommon
]
\\input{$listings}
\\input{$unicode}
\\usepackage{lastpage}
\\usepackage{fancyhdr}
\\pagestyle{fancy}
\\cfoot{Page \\thepage\\ of \\pageref{LastPage}}
\\begin{document}
"""
end
function notebook2tex(nb::Notebook, in_path::String, oopts::OutputOptions)
@assert isready(nb)
order = nb.cell_order
outputs = map(order) do cell_uuid
cell = nb.cells_dict[cell_uuid]
_cell2tex(cell, oopts)
end
header = _tex_header()
body = join(outputs, '\n')
tex = """
$header
$body
\\end{document}
"""
return tex
end
function _tectonic(args::Vector{String})
tectonic() do bin
run(`$bin $args`)
end
end
function _tex2pdf(tex_path::String)
dir = dirname(tex_path)
args = [
tex_path,
"--outdir=$dir",
"--print"
]
_tectonic(args)
return nothing
end
function notebook2pdf(nb::Notebook, in_path::String, oopts::OutputOptions)
tex = notebook2tex(nb, in_path, oopts)
dir = dirname(in_path)
filename, _ = splitext(basename(in_path))
tex_path = joinpath(dir, string(filename, ".tex"))
@debug "Writing tex file for debugging purposes to $tex_path"
write(tex_path, tex)
pdf_path = joinpath(dir, string(filename, ".pdf"))
@debug "Writing pdf file to $pdf_path"
_tex2pdf(tex_path)
return pdf_path
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 351 | using PrecompileTools: @setup_workload, @compile_workload
@setup_workload begin
@compile_workload begin
n_cache_lines()
state = State("hi")
string(state)
PlutoStaticHTML._patch_with_terminal("let txt = ")
PlutoStaticHTML._replace_code_tabs("")
PlutoStaticHTML._add_documenter_css("")
end
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 3258 | "Add some style overrides to make things a bit prettier and more consistent with Pluto."
function _add_documenter_css(html)
style = """
<style>
#documenter-page table {
display: table !important;
margin: 2rem auto !important;
border-top: 2pt solid rgba(0,0,0,0.2);
border-bottom: 2pt solid rgba(0,0,0,0.2);
}
#documenter-page pre, #documenter-page div {
margin-top: 1.4rem !important;
margin-bottom: 1.4rem !important;
}
.code-output {
padding: 0.7rem 0.5rem !important;
}
.admonition-body {
padding: 0em 1.25em !important;
}
</style>
"""
return string(style, '\n', html)
end
function _convert_admonition_class!(el::HTMLElement{:div})
@assert el.children[1].attributes["class"] == "admonition-title"
attributes = el.attributes
class = attributes["class"]
updated_class = replace(class, "admonition " => "admonition is-")
attributes["class"] = updated_class
return nothing
end
function _convert_p_to_header!(el::HTMLElement{:div})
p = el.children[1]
new = let
children = p.children
parent = el
attributes = Dict("class" => "admonition-header")
HTMLElement{:header}(children, parent, attributes)
end
el.children[1] = new
return nothing
end
function _convert_siblings_to_admonition_body!(el)
siblings = el.children[2:end]
new = let
children = siblings
parent = el
attributes = Dict("class" => "admonition-body")
HTMLElement{:div}(children, parent, attributes)
end
el.children[2] = new
return nothing
end
"Convert a single admonition from Pluto to Documenter."
function _convert_admonition!(el::HTMLElement{:div})
_convert_admonition_class!(el)
_convert_p_to_header!(el)
_convert_siblings_to_admonition_body!(el)
return nothing
end
function _convert_admonitions!(el::HTMLElement{:div})
if haskey(el.attributes, "class")
if startswith(el.attributes["class"], "admonition")
first_child = el.children[1]
if first_child isa HTMLElement{:p}
if haskey(first_child.attributes, "class")
if first_child.attributes["class"] == "admonition-title"
return _convert_admonition!(el)
end
end
end
end
end
for child in el.children
_convert_admonitions!(child)
end
return nothing
end
# Fallback for HTMLText and such.
_convert_admonitions!(el) = nothing
function _convert_admonitions!(el::HTMLElement)
for child in el.children
_convert_admonitions!(child)
end
return nothing
end
"""
Convert Pluto's admonitions HTML to Documenter's admonitions HTML.
This ensures that admonitions are properly styled in `documenter_output`.
"""
function _convert_admonitions(html::AbstractString)
parsed = parsehtml(html)
body = parsed.root.children[2]
_convert_admonitions!(body)
body_content = join(string.(body.children)::Vector{String}, '\n')
return body_content
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 509 | function _extract_txt(body)
sep = '\n'
lines = split(body, sep)
index = findfirst(contains("let txt = "), lines)
txt_line = strip(lines[index])
txt = txt_line[12:end-1]
with_newlines = replace(txt, "\\n" => '\n')
without_extraneous_newlines = strip(with_newlines, '\n')
return without_extraneous_newlines
end
function _patch_with_terminal(body::String)
txt = _extract_txt(body)
return """
<pre id="plutouiterminal">
$txt
</pre>
"""
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 4775 | @testset "build" begin
mktempdir() do dir
files = map(1:2) do i
without_extension = "file$i"
file = "$(without_extension).jl"
content = pluto_notebook_content("""
x = begin
sleep(3)
x = 3000 + $i
end
""")
path = joinpath(dir, file)
write(path, content)
return file
end
build_notebooks(BuildOptions(dir, use_distributed=false))
html_file = joinpath(dir, "file1.html")
@test contains(read(html_file, String), "3001")
html_file = joinpath(dir, "file2.html")
@test contains(read(html_file, String), "3002")
end
end
@testset "is_pluto_file" begin
cd(mktempdir()) do
nb_text = """
### A Pluto.jl notebook ###
# v0.14.0
"""
write("true.jl", nb_text)
@test PlutoStaticHTML._is_pluto_file("true.jl")
jl_text = """
module Foo
end # module
"""
write("false.jl", jl_text)
@test !PlutoStaticHTML._is_pluto_file("false.jl")
end
end
@testset "invalid_notebook" begin
try
mktempdir() do dir
content = pluto_notebook_content("@assert false")
file = "file.jl"
path = joinpath(dir, file)
write(path, content)
build_notebooks(BuildOptions(dir), [file], use_distributed=false)
end
error("Test should have failed")
catch AssertionError
@test true # Success.
end
end
@testset "extract_previous_output" begin
# function extract_previous_output(html::AbstractString)::String
html = """
lorem
$(PlutoStaticHTML.BEGIN_IDENTIFIER)
ipsum
$(PlutoStaticHTML.END_IDENTIFIER)
dolar
"""
actual = PlutoStaticHTML.extract_previous_output(html)
expected = """
$(PlutoStaticHTML.BEGIN_IDENTIFIER)
ipsum
$(PlutoStaticHTML.END_IDENTIFIER)
"""
@test strip(actual) == strip(expected)
end
@testset "add_documenter_css" begin
for add_documenter_css in (true, false)
dir = mktempdir()
cd(dir) do
path = joinpath(dir, "notebook.jl")
code = pluto_notebook_content("""
x = 1
""")
write(path, code)
use_distributed = false
output_format = documenter_output
bo = BuildOptions(dir; use_distributed, output_format, add_documenter_css)
build_notebooks(bo)
output_path = joinpath(dir, "notebook.md")
lines = readlines(output_path)
if add_documenter_css
@test lines[2] == "<style>"
else
@test lines[2] != "<style>"
end
end
end
end
@testset "EditURL" begin
dir = joinpath(pkgdir(PlutoStaticHTML), "docs", "src", "notebooks")
bopts = BuildOptions(dir)
in_path = "example.jl"
kv = [
"GITHUB_REPOSITORY" => "",
"GITHUB_REF" => ""
]
withenv(kv...) do
@test PlutoStaticHTML._editurl_text(bopts, in_path) == ""
end
kv = [
"GITHUB_REPOSITORY" => "rikhuijzer/PlutoStaticHTML.jl",
"GITHUB_REF" => "refs/heads/main"
]
withenv(kv...) do
url = "https://github.com/rikhuijzer/PlutoStaticHTML.jl/blob/main/docs/src/notebooks/example.jl"
@test strip(PlutoStaticHTML._editurl_text(bopts, in_path)) == strip("""
```@meta
EditURL = "$url"
```
""")
end
end
@testset "Fix header links" begin
expected = """
```
## Admonitons
```@raw html
<div class="markdown">
"""
@test PlutoStaticHTML._fix_header_links("""<div class="markdown"><h2>Admonitons</h2>""") == expected
@test PlutoStaticHTML._fix_header_links("") == ""
mktempdir() do dir
cd(dir) do
path = joinpath(dir, "notebook.jl")
code = pluto_notebook_content("""
md"## Some header"
""")
write(path, code)
use_distributed = false
output_format = documenter_output
bo = BuildOptions(dir; use_distributed, output_format)
build_notebooks(bo)
output_path = joinpath(dir, "notebook.md")
output = read(output_path, String)
@test contains(output, "## Some header")
end
end
end
@testset "Elapsed time" begin
n = now()
sleep(1)
n2 = now()
@test PlutoStaticHTML._pretty_elapsed(n2 - n) == "1 second"
sleep(1)
n2 = now()
@test PlutoStaticHTML._pretty_elapsed(n2 - n) == "2 seconds"
end
nothing
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 5581 | @testset "prefix" begin
version = VERSION
text = repeat("foobar\n", 100)
html = string(PlutoStaticHTML.State(text)) * text
state = PlutoStaticHTML.State(html)
@test state.input_sha == PlutoStaticHTML.sha(html)
@test state.julia_version == string(VERSION)
end
exception_text(ex) = sprint(Base.showerror, ex)
function try_read(file)::String
for i in 1:30
try
return read(file, String)
catch
sleep(0.2)
end
end
try
return read(file, String)
catch ex
error("try_read was unable to read file: $(exception_text(ex))")
end
end
function try_rm(file)
for i in 1:30
try
return rm(file)
catch
sleep(0.2)
end
end
try
return rm(file)
catch ex
error("try_rm was unable to remove file: $(exception_text(ex))")
end
end
@testset "caching" begin
dir = mktempdir()
use_distributed = false
cd(dir) do
@info "Evaluating notebooks in \"$dir\" without caching"
path(name) = joinpath(dir, "$name.txt")
code = pluto_notebook_content("""
begin
path = "$(path('a'))"
@info "Writing to \$path"
write(path, "a")
end
""")
write("a.jl", code)
code = pluto_notebook_content("""write("$(path('b'))", "b")""")
write("b.jl", code)
bo = BuildOptions(dir; use_distributed)
build_notebooks(bo)
# Without try_read, Pluto in another process may still have a lock on a txt file.
@test try_read("a.txt") == "a"
try_read("a.html")
@test try_read("b.txt") == "b"
try_read("b.html")
try_rm("a.html")
try_rm("a.txt")
try_rm("b.txt")
previous_dir = dir
dir = mktempdir()
cd(dir) do
@info "Evaluating notebooks in \"$dir\" with caching"
cp(joinpath(previous_dir, "a.jl"), joinpath(dir, "a.jl"))
cp(joinpath(previous_dir, "b.jl"), joinpath(dir, "b.jl"))
bo = BuildOptions(dir; use_distributed, previous_dir)
build_notebooks(bo)
# a was evaluated because "a.html" was removed.
# note that Pluto always writes txt files to the first dir.
@test try_read(joinpath(previous_dir, "a.txt")) == "a"
try_read("a.html")
# b was not evaluated because "b.html" was used from the cache.
@test !isfile(joinpath(previous_dir, "b.txt"))
try_read("b.html")
end
end
end
@testset "extract_previous" begin
text = """
prefix
<!-- PlutoStaticHTML.Begin -->
<!-- PlutoStaticHTML.End -->
suffix
"""
prev = PlutoStaticHTML.Previous(text::String)
@test startswith(prev.text, PlutoStaticHTML.BEGIN_IDENTIFIER)
@test endswith(prev.text, PlutoStaticHTML.END_IDENTIFIER)
end
@testset "html_cache_output" begin
# Test whether the HTML copied from the cache doesn't contain anything outside PlutoStaticHTML.Begin and End.
dir = mktempdir()
cd(dir) do
path = joinpath(dir, "notebook.jl")
code = pluto_notebook_content("x = 1")
write(path, code)
output_format = html_output
use_distributed = false
bo = BuildOptions(dir; output_format, use_distributed)
build_notebooks(bo)
output_path = joinpath(dir, "notebook.html")
output = read(output_path, String)
# This is similar to how Franklin, for example, adds a prefix and suffix.
write(output_path, "prefix\n" * output * "\nsuffix")
previous_dir = dir
bo = BuildOptions(dir; output_format, use_distributed, previous_dir)
build_notebooks(bo)
output2 = read(output_path, String)
@test output == output2
end
end
@testset "franklin_markdown_cache_output" begin
# Test whether the Franklin Markdown copied from the cache is correct.
dir = mktempdir()
cd(dir) do
path = joinpath(dir, "notebook.jl")
code = pluto_notebook_content("""
md\"\"\"
+++
title = \"foo\"
+++
\"\"\"
""")
write(path, code)
use_distributed = false
output_format = franklin_output
bo = BuildOptions(dir; use_distributed, output_format)
build_notebooks(bo)
output_path = joinpath(dir, "notebook.md")
output = read(output_path, String)
previous_dir = dir
bo = BuildOptions(dir; output_format, use_distributed, previous_dir)
build_notebooks(bo)
output2 = read(output_path, String)
@test output == output2
end
end
@testset "documenter_cache_output" begin
# Test whether the Documenter HTML + Markdown copied from the cache is correct.
dir = mktempdir()
cd(dir) do
path = joinpath(dir, "notebook.jl")
code = pluto_notebook_content("""
x = 1
""")
write(path, code)
use_distributed = false
output_format = documenter_output
bo = BuildOptions(dir; use_distributed, output_format)
build_notebooks(bo)
output_path = joinpath(dir, "notebook.md")
output = read(output_path, String)
previous_dir = dir
bo = BuildOptions(dir; output_format, use_distributed, previous_dir)
build_notebooks(bo)
output2 = read(output_path, String)
@test output == output2
end
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 445 | tmpdir = mktempdir()
in_file = "notebook.jl"
content = pluto_notebook_content("""
# Very small package.
using PrecompileMacro
""")
write(joinpath(tmpdir, in_file), content)
hopts = OutputOptions(; append_build_context=true)
bopts = BuildOptions(tmpdir; use_distributed=true)
outputs = build_notebooks(bopts, hopts)
html = only(outputs[in_file])
@test contains(html, r"Built with Julia 1.*")
@test contains(html, "PrecompileMacro")
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 7525 | @testset "mimeoverride" begin
nb = Notebook([
Cell("""PlutoRunner.is_mime_enabled(MIME"application/vnd.pluto.tree+object"()) ? "enabled" : "disabled" """)
])
html, nb = notebook2html_helper(nb)
@test contains(html, "disabled")
end
@testset "contains" begin
html = "<b>foo</b>"
block = PlutoStaticHTML.code_block(html)
@test contains(block, "<b>foo</b>")
notebook = Notebook([
Cell("x = 1 + 1"),
Cell("using Images: load"),
Cell("PKGDIR = \"$PKGDIR\""),
Cell("""im_file(ext) = joinpath(PKGDIR, "test", "im", "im.\$ext")"""),
Cell("""load(im_file("png"))""")
])
html, nb = notebook2html_helper(notebook)
lines = split(html, '\n')
@test contains(lines[1], "1 + 1")
@test contains(lines[2], "2")
@test contains(lines[2], "class=\"$(PlutoStaticHTML.OUTPUT_PRE_CLASS_DEFAULT)\"")
@test contains(lines[end-1], """src=\"data:image/png;base64,""")
@test contains(lines[end-1], "<img")
notebook = Notebook([
Cell("struct A end"),
Cell("""
struct B
x::Int
a::A
end
"""
),
Cell("B(1, A())")
])
use_distributed = false
html, nb = notebook2html_helper(notebook; use_distributed)
lines = split(html, '\n')
@test contains(lines[end-1], "B(1, A())")
notebook = Notebook([
Cell("md\"my text\"")
])
html, nb = notebook2html_helper(notebook, OutputOptions(; hide_md_code=true); use_distributed)
lines = split(html, '\n')
@test lines[1] == ""
html, nb = notebook2html_helper(notebook, OutputOptions(; hide_md_code=false); use_distributed)
lines = split(html, '\n')
@test lines[1] != ""
opts = OutputOptions(; hide_md_code=false, hide_code=true)
html, nb = notebook2html_helper(notebook, opts; use_distributed)
lines = split(html, '\n')
@test lines[1] == ""
end
@testset "use_distributed=false and pwd" begin
dir = pwd()
nb = Notebook([Cell("1 + 1")])
_, _ = notebook2html_helper(nb, OutputOptions(; hide_md_code=true); use_distributed=false)
@test pwd() == dir
end
@testset "hide" begin
nb = Notebook([
Cell("x = 1 + 1 # hide"),
Cell("""
# hideall
y = 3 + 3
""")
])
html, nb = notebook2html_helper(nb; use_distributed=false)
@test contains(html, ">2<")
@test !contains(html, "1 + 1")
@test contains(html, ">6<")
@test !contains(html, "3 + 3")
end
@testset "from_file" begin
mktempdir() do dir
file = joinpath(dir, "tmp.jl")
content = pluto_notebook_content("x = 1 + 2")
write(file, content)
html = notebook2html(file)
@test contains(html, "3")
end
end
@testset "run_notebook!_errors" begin
# To avoid changing the current working directory; I don't know what causes it to change
# exactly.
cd(pwd()) do
mktempdir() do dir
text = pluto_notebook_content("sum(1, :b)")
path = joinpath(dir, "notebook.jl")
write(path, text)
session = ServerSession()
session.options.evaluation.workspace_use_distributed = false
err = nothing
try
nb = PlutoStaticHTML.run_notebook!(path, session)
catch err
end
@test err isa Exception
msg = sprint(showerror, err)
@test contains(msg, "notebook failed")
@test contains(msg, "notebook.jl")
@test contains(msg, "sum(1, :b)")
@test contains(msg, "Closest candidates are")
@test contains(msg, "_foldl_impl")
end
end
end
@testset "pluto-docs-binding" begin
text = """
"This is a docstring"
foo(x) = x
"""
nb = Notebook([
Cell(text),
])
html, nb = notebook2html_helper(nb; use_distributed=false)
@test !contains(html, "pluto-docs-binding")
end
@testset "benchmark-hack" begin
# Related to https://github.com/fonsp/Pluto.jl/issues/1664
nb = Notebook([
Cell("using BenchmarkTools"),
Cell("@benchmark sum(x)"),
Cell("x = [1, 2]")
])
html, nb = notebook2html_helper(nb; use_distributed=true)
@test contains(html, "BenchmarkTools.Trial")
end
@testset "show_output_above_code" begin
nb = Notebook([
Cell("x = 1 + 1020"),
])
oopts = OutputOptions(; show_output_above_code=true)
html, _ = notebook2html_helper(nb, oopts; use_distributed=false)
lines = split(html, '\n')
@test contains(lines[1], "1021")
@test contains(lines[2], "1 + 1020")
end
@testset "with_terminal" begin
nb = Notebook([
Cell("using PlutoUI"),
Cell("f(x) = Base.inferencebarrier(x);"),
Cell("""
with_terminal() do
@code_warntype f(1)
end
""")
])
html, _ = notebook2html_helper(nb)
# Basically, this only tests whether `_patch_with_terminal` is applied.
@test contains(html, """<pre id="plutouiterminal">""")
end
@testset "replace_code_tabs" begin
code = """
1
2
"""
@test PlutoStaticHTML._replace_code_tabs(code) == """
1
2
"""
nb = Notebook([
Cell(" a = 1 + 1021;"),
Cell(" b = 1 + 1021;"),
])
oopts = OutputOptions()
html, _ = notebook2html_helper(nb, oopts; use_distributed=false)
lines = split(html, '\n')
filter!(!isempty, lines)
@test contains(lines[1], " a = 1 + 1021")
@test contains(lines[2], " b = 1 + 1021")
end
@testset "big-table" begin
# Using DataFrames here instead of Tables to get the number of rows for long tables.
nb = Notebook([
Cell("using DataFrames: DataFrame"),
Cell("DataFrame(rand(120, 20), :auto)")
])
oopts = OutputOptions()
html, _ = notebook2html_helper(nb, oopts; use_distributed=false)
# Use write(tmp.html, html) to look at this.
# First column is empty in the header (because of indexes).
# The tbody is added by Gumbo.
@test contains(html, """<table><tbody><tr><th></th>""")
# At least one of the rows contains three dots.
@test contains(html, "<th>...</th></tr>")
# The number of rows is shown.
@test contains(html, "<td>120</td>")
# If not being careful, the first element of the last column is taken, so "more" becomes "m".
@test !contains(html, "<td>m</td>")
end
@testset "handle cell metadata" begin
nb = Notebook([
Cell("a = 1000 + 1"),
Cell("b = 2000 + 1"),
Cell("c = 3000 + 1")
])
nb.cells[1].code_folded = true
nb.cells[2].metadata["disabled"] = true
html, _ = notebook2html_helper(nb; use_distributed=false)
@test !contains(html, "1000 + 1")
@test contains(html, "1001")
@test !contains(html, "2000 + 1")
@test !contains(html, "2001")
end
@testset "pluto tree data" begin
nb = Notebook([
Cell("nt = (; A = [1, 2], B = [3, 4])")
])
html, _ = notebook2html_helper(nb; use_distributed=false)
end
@testset "patch inline math" begin
nb = Notebook([
Cell(raw"""
md"Some inline math with $x$."
""")
])
html, _ = notebook2html_helper(nb; use_distributed=false)
# Verify that Pluto.jl's inline math as `<span class="tex">$x$</span>` is replaced.
@test contains(html, raw"""Some inline math with <span class="tex">\(x\)</span>.""")
end
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 194 |
url = raw"""
<div class="markdown">
<p>
link:
<a href="https://example.com">
https://example.com
</a>
</p>
</div>
"""
PS._html2tex(url)
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 766 | notebook = Notebook([
Cell("md\"This is **markdown**\"")
])
html, nb = notebook2html_helper(notebook; use_distributed=false)
lines = split(html, '\n')
@test contains(lines[2], "<strong>")
notebook = Notebook([
Cell("""("pluto", "tree", "object")"""),
Cell("""["pluto", "tree", "object"]"""),
Cell("""[1, (2, (3, 4))]"""),
Cell("(; a=(1, 2), b=(3, 4))")
])
html, nb = notebook2html_helper(notebook; use_distributed=false);
lines = split(html, '\n')
@test contains(lines[2], "(\"pluto\", \"tree\", \"object\")")
@test contains(lines[2], "<pre")
@test contains(lines[6], "pluto")
@test contains(lines[7], "tree")
@test contains(lines[8], "object")
@test contains(lines[11], "2-element Vector")
@test contains(lines[16], "(a = (1, 2), b = (3, 4))")
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
|
[
"MIT"
] | 6.0.28 | f82ff5b9e85ef972634d3312f52bbf7653dc8459 | code | 584 | @test contains(PS.tectonic_version(), "Tectonic")
nb = Notebook([
Cell("x = 1 + 1"),
])
tex, nb = notebook2tex_helper(nb; use_distributed=false)
@test contains(tex, "x = 1 + 1")
tmpdir = joinpath(PS.PKGDIR, "test", "tmp")
mkpath(tmpdir)
in_path = joinpath(tmpdir, "test.jl")
pdf_path = PS.notebook2pdf(nb, in_path, OutputOptions())
@test isfile(joinpath(tmpdir, "test.pdf"))
nb = Notebook([
Cell("""md"link: <https://example.com>" """)
])
in_path = joinpath(tmpdir, "url.jl")
pdf_path, nb = notebook2pdf_helper(nb, in_path; use_distributed=false)
nothing
| PlutoStaticHTML | https://github.com/rikhuijzer/PlutoStaticHTML.jl.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.