Skip to content

Aqua + typos CI #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Downgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'docs/**'
push:
branches:
- master
- main
paths-ignore:
- 'docs/**'
jobs:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Spell Check

on: [pull_request]

jobs:
typos-check:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3
- name: Check spelling
uses: crate-ci/typos@v1.16.23
2 changes: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[default.extend-words]
numer = "numer"
11 changes: 7 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"

[compat]
Aqua = "0.8"
DataDrivenDiffEq = "1.3"
DataDrivenSparse = "0.1.2"
DataStructures = "0.18.13"
LinearAlgebra = "1.10"
SpecialFunctions = "2"
Statistics = "1.9"
Statistics = "1.10"
SymbolicUtils = "1.4"
Symbolics = "5.12"
julia = "1.9"
LinearAlgebra = "<0.0.1, 1"
Test = "1"
julia = "1.10"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["Aqua", "Test"]
2 changes: 0 additions & 2 deletions src/integral.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using LinearAlgebra
using Statistics: mean, std

Base.signbit(z::Complex{T}) where {T <: Number} = signbit(real(z))
Base.signbit(x::SymbolicUtils.Sym{Number}) = false

"""
integrate(eq, x; kwargs...)
Expand Down
10 changes: 5 additions & 5 deletions src/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ function prune_basis(eq, x, basis; plan = default_plan())
return basis[l]
end

# init_basis_matrix tranforms the integration problem into a linear system
#
# It returns A, X, V, where
# init_basis_matrix transforms the integration problem into a linear system
#
# It returns A, X, V, where
#
# A: the normalized training matrix, we seek a vector q such that A * q = 1
# X: a vector of complex test points
Expand Down Expand Up @@ -217,14 +217,14 @@ function hints(eq, x, basis; plan = default_plan())

return h, ε
catch e
# println("Error from hints: ", e)
# println("Error from hints: ", e)
end

return 0, Inf
end

# best_hints works is the link between numerical and symbolic integration.
# It convers a symbolic integrad eq into a univariate expression, performs
# It converts a symbolic integrad eq into a univariate expression, performs
# symbolic-numeric integration, and the returns a list of symbolic ansatzes
# corresponding to the solution
function best_hints(eq, x, basis; plan = default_plan(), num_trials = 10)
Expand Down
46 changes: 23 additions & 23 deletions src/symbolic.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
########################### Utility functions #########################

# beautify convers floats to integers/rational numbers with small
# beautify converts floats to integers/rational numbers with small
# denominators if possible
function beautify(eq)
if is_add(eq)
Expand Down Expand Up @@ -47,22 +47,22 @@ function split_terms(eq, x)
end
end

# is_holonomic checks whether y is a holonomic function, i.e.,
# is_holonomic checks whether y is a holonomic function, i.e.,
# is closed under differentiation w.r.t. x
#
#
# For our purpose, we define a holonomic function as one composed
# of the positive powers of x, sin, cos, exp, sinh, and cosh
#
#
# Args:
# y: the expression to check for holonomy
# x: independent variable
#
#
# Returns:
# true if y is holonomic
function is_holonomic(y, x)
y = value(y)

# technically, polynomials are not holonomic, but
# technically, polynomials are not holonomic, but
# practically we can include them
if is_polynomial(y, x)
return true
Expand Down Expand Up @@ -90,8 +90,8 @@ function is_holonomic(y, x)
return false
end

# blender generates a list of ansatzes based on repetative
# differentiation. It works for holonomic functions, which
# blender generates a list of ansatzes based on repetitive
# differentiation. It works for holonomic functions, which
# are closed under differentiation.
function blender(y, x; n = 3)
basis = value(y)
Expand All @@ -111,7 +111,7 @@ function blender(y, x; n = 3)
return split_terms(basis, x)
end

# subs_symbols returns a dictionary of the symbolic constants
# subs_symbols returns a dictionary of the symbolic constants
# in the expression and random real value assignments.
#
# Args:
Expand All @@ -138,8 +138,8 @@ function subs_symbols(eq, x; include_x = false, radius = 5.0, as_complex = true)
return S
end

# atomize splits terms into a part dependent on x and a part
# constant w.r.t. variables in xs.
# atomize splits terms into a part dependent on x and a part
# constant w.r.t. variables in xs.
#
# For example, `atomize(a*sin(b*x), x)` is `(a, sin(b*x))`)
function atomize(eq, xs...)
Expand All @@ -165,7 +165,7 @@ function atomize(eq, xs...)
end
end

# apply_coefs generates the final integral based on the list
# apply_coefs generates the final integral based on the list
# of coefficients (q) and a list of ansatzes (ker).
function apply_coefs(q, ker)
s = 0
Expand Down Expand Up @@ -201,11 +201,11 @@ complex_from_num(x) = Complex(value(real(x)), value(imag(x)))
########################### Symbolic Integration #############################

# integrate_symbolic is the main entry point for symbolic integration.
#
#
# Argu:
# eq: the expression to integrate
# x: independent variable
#
#
# Returns:
# the integral or nothing if no solution
function integrate_symbolic(eq, x; plan = default_plan())
Expand All @@ -226,10 +226,10 @@ struct Problem
x::Expression # independent variable
coef::Expression # coefficient of the integrand
ker::Array{Expression} # the pruned list of the basis expressions (kernel)
plan::NumericalPlan # the numerial plan, containing various parameters
plan::NumericalPlan # the numerical plan, containing various parameters
end

# Constructor to create a Problem for integrand eq
# Constructor to create a Problem for integrand eq
function Problem(eq, x; plan = default_plan())
eq = expand(eq)
coef, eq = atomize(eq, x)
Expand Down Expand Up @@ -314,14 +314,14 @@ subs_symbols(prob::Problem) = subs_symbols(prob.eq, prob.x)
abstract type IntegrationAlgorithm end

struct SymbolicIntegrator <: IntegrationAlgorithm
eqs::Vector{Equation} # list of equations of the form Σ θ[i]*frag[i] ~ 0
eqs::Vector{Equation} # list of equations of the form Σ θ[i]*frag[i] ~ 0
vars::Vector{Expression} # list of dummy variables (θ[1], θ[2], ...)
frags::Dict # Dict of fragments of form frag => expression in θs
end

@variables θ[1:30]

# Constructor creating a SymbolicIntegrator algorithm
# Constructor creating a SymbolicIntegrator algorithm
# from an integration Problem
function SymbolicIntegrator(prob::Problem)
frags = Dict()
Expand Down Expand Up @@ -355,16 +355,16 @@ function solver(prob::Problem, alg::SymbolicIntegrator)
sol = apply_coefs(q, prob.ker)
return sol
catch e
# println(e)
# println(e)
end

return nothing
end

# If the linear system generated by the SymbolicIntegrator solver is
# under-determined, make_square uses semi-numerical methods to
# under-determined, make_square uses semi-numerical methods to
# generate a full-rank linear system.
#
#
# The output is another SymbolicIntegrator or nothing if unsuccessful.
function make_square(prob::Problem, alg::SymbolicIntegrator)
n = length(alg.vars)
Expand All @@ -390,10 +390,10 @@ function make_square(prob::Problem, alg::SymbolicIntegrator)
end

struct NumericIntegrator
A::AbstractMatrix # training dataset as a normalized linear system
A::AbstractMatrix # training dataset as a normalized linear system
X::AbstractVector # vector of test points
V::AbstractMatrix # verification dataset
basis::Vector{Expression} # expand basis
basis::Vector{Expression} # expand basis
end

# Constructor to create a NumericIntegrator algorithm from prob
Expand Down
11 changes: 11 additions & 0 deletions test/qa.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using SymbolicNumericIntegration, Aqua
@testset "Aqua" begin
Aqua.find_persistent_tasks_deps(SymbolicNumericIntegration)
Aqua.test_ambiguities(SymbolicNumericIntegration, recursive = false)
Aqua.test_deps_compat(SymbolicNumericIntegration)
Aqua.test_piracies(SymbolicNumericIntegration, broken = true)
Aqua.test_project_extras(SymbolicNumericIntegration)
Aqua.test_stale_deps(SymbolicNumericIntegration)
Aqua.test_unbound_args(SymbolicNumericIntegration)
Aqua.test_undefined_exports(SymbolicNumericIntegration)
end
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ using SymbolicUtils.Rewriters

using Test

@testset "Quality Assurance" begin include("qa.jl") end

include("axiom.jl")

##############################################################################
Expand Down