Skip to content

Commit 4054c8d

Browse files
committed
Add method signatures to docstrings
1 parent 4072978 commit 4054c8d

File tree

6 files changed

+73
-15
lines changed

6 files changed

+73
-15
lines changed

src/calculus.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ diff(ex::SymbolicType, bs::Tuple, ns::Tuple) =
7272
diff(b1::SymbolicType, x::Union{String,Symbol}) = diff(b1, Basic(x))
7373

7474
"""
75+
series(ex, x, x0=0, n=6)
76+
7577
Series expansion to order `n` about point `x0`
7678
"""
7779
function series(ex::SymbolicType, x::SymbolicType, x0=0, n::Union{Integer, Basic}=6)

src/mathfuns.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ for (meth, libnm) in [(:nextprime,:nextprime)
159159
eval(Expr(:export, meth))
160160
end
161161

162-
"Return coefficient of `x^n` term, `x` a symbol"
162+
"""
163+
coeff!(a, b, x, n)
164+
165+
Return coefficient of `x^n` term, `x` a symbol
166+
"""
163167
function coeff!(a::Basic, b::Basic, x, n)
164168
out = ccall((:basic_coeff, libsymengine), Nothing,
165169
(Ref{Basic},Ref{Basic},Ref{Basic},Ref{Basic}),

src/numerics.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ end
5555
##################################################
5656
# N
5757
"""
58+
N(a)
59+
N(Val(:Type), b::Basic)
5860
5961
Convert a SymEngine numeric value into a Julian number
6062

src/subs.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11

22

33
"""
4-
subs
4+
subs(ex, var, val)
5+
subs(ex, d::AbstractDict)
6+
subs(ex, y::Tuple)
7+
subs(ex)
58
69
Substitute values into a symbolic expression.
710
@@ -126,7 +129,8 @@ end
126129
walk_expression(b) = convert(Expr, b)
127130

128131
"""
129-
lambdify
132+
lambdify(ex, vars=[]; cse=false)
133+
130134
evaluates a symbolless expression or returns a function
131135
"""
132136
function lambdify(ex, vars=[])

src/types.jl

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ const symengine_classes = _get_symengine_classes()
111111
const symengine_classes_val = [Val(c) for c in SymEngine.symengine_classes]
112112
const symengine_classes_val_type = [Val{c} for c in SymEngine.symengine_classes]
113113

114-
"Get SymEngine class of an object (e.g. 1=>:Integer, 1//2 =:Rational, sin(x) => :Sin, ..."
114+
"""
115+
get_symengine_class(s)
116+
117+
Get SymEngine class of an object `s`.
118+
(e.g. `1=>:Integer`, `1//2 =>:Rational`, `sin(x) => :Sin`, ...)
119+
"""
115120
get_symengine_class(s::Basic) = symengine_classes[get_type(s) + 1]
116121
get_symengine_class_val(s::Basic) = symengine_classes_val[get_type(s) + 1]
117122
get_symengine_class_val_type(s::Basic) = symengine_classes_val_type[get_type(s) + 1]
@@ -128,8 +133,9 @@ _symbol(s::Symbol) = _symbol(string(s))
128133

129134
## use SymPy name here, but no assumptions
130135
"""
136+
symbols(::Symbol)
131137
132-
`symbols(::Symbol)` construct symbolic value
138+
Construct symbolic value.
133139
134140
Examples:
135141
```
@@ -255,28 +261,44 @@ BasicTrigFunction = Union{[SymEngine.BasicType{Val{i}} for i in trig_types]...}
255261

256262
###
257263

258-
"Is expression constant"
264+
"""
265+
is_constant(ex)
266+
267+
Is expression constant
268+
"""
259269
function is_constant(ex::Basic)
260270
syms = CSetBasic()
261271
ccall((:basic_free_symbols, libsymengine), Nothing, (Ref{Basic}, Ptr{Cvoid}), ex, syms.ptr)
262272
Base.length(syms) == 0
263273
end
264274

265-
"Is expression a symbol"
275+
"""
276+
is_symbol(x::)
277+
278+
Is expression a symbol
279+
"""
266280
function is_symbol(x::SymbolicType)
267281
res = ccall((:is_a_Symbol, libsymengine), Cuint, (Ref{Basic},), x)
268282
Bool(convert(Int,res))
269283
end
270284

271-
"Does expression contain the symbol"
285+
"""
286+
has_symbol(ex, x)
287+
288+
Does expression `ex` contain the symbol `x`
289+
"""
272290
function has_symbol(ex::SymbolicType, x::SymbolicType)
273291
is_symbol(x) || throw(ArgumentError("Not a symbol"))
274292
res = ccall((:basic_has_symbol, libsymengine), Cuint, (Ref{Basic},Ref{Basic}), ex, x)
275293
Bool(convert(Int, res))
276294
end
277295

278296

279-
" Return free symbols in an expression as a `Set`"
297+
"""
298+
free_symbols(ex)
299+
300+
Return free symbols in an expression `ex` as a `Set`
301+
"""
280302
function free_symbols(ex::Basic)
281303
syms = CSetBasic()
282304
free_symbols!(syms, ex)
@@ -294,7 +316,11 @@ _flat(A) = mapreduce(x->isa(x,Array) ? _flat(x) : x, vcat, A, init=Basic[]) # f
294316
free_symbols(exs::Array{T}) where {T<:SymbolicType} = unique(_flat([free_symbols(ex) for ex in exs]))
295317
free_symbols(exs::Tuple) = unique(_flat([free_symbols(ex) for ex in exs]))
296318

297-
"Return function symbols in an expression as a `Set`"
319+
"""
320+
function_symbols(ex)
321+
322+
Return function symbols in an expression `ex` as a `Set`
323+
"""
298324
function function_symbols(ex::Basic)
299325
syms = CSetBasic()
300326
function_symbols!(syms, ex)
@@ -309,15 +335,23 @@ function_symbols(ex::BasicType) = function_symbols(Basic(ex))
309335
function_symbols(exs::Array{T}) where {T<:SymbolicType} = unique(_flat([function_symbols(ex) for ex in exs]))
310336
function_symbols(exs::Tuple) = unique(_flat([function_symbols(ex) for ex in exs]))
311337

312-
"Return name of function symbol"
338+
"""
339+
get_name(ex)
340+
341+
Return name of function symbol
342+
"""
313343
function get_name(ex::Basic)
314344
a = ccall((:function_symbol_get_name, libsymengine), Cstring, (Ref{Basic}, ), ex)
315345
string = unsafe_string(a)
316346
ccall((:basic_str_free, libsymengine), Nothing, (Cstring, ), a)
317347
return string
318348
end
319349

320-
"Return arguments of a function call as a vector of `Basic` objects"
350+
"""
351+
get_args(ex)
352+
353+
Return arguments of a function call as a vector of `Basic` objects
354+
"""
321355
function get_args(ex::Basic)
322356
args = CVecBasic()
323357
get_args!(args, ex)

src/utils.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
"Helper function to lookup a symbol from libsymengine"
1+
"""
2+
get_symbol(sym)
3+
4+
Helper function to lookup a symbol from libsymengine
5+
"""
26
function get_symbol(sym::Symbol)
37
handle = Libdl.dlopen_e(libsymengine)
48
if handle == C_NULL
@@ -8,7 +12,11 @@ function get_symbol(sym::Symbol)
812
end
913
end
1014

11-
"Get libsymengine version"
15+
"""
16+
get_libversion()
17+
18+
Get libsymengine version
19+
"""
1220
function get_libversion()
1321
func = get_symbol(:symengine_version)
1422
if func != C_NULL
@@ -20,7 +28,11 @@ function get_libversion()
2028
end
2129
end
2230

23-
"Check whether libsymengine was compiled with comp"
31+
"""
32+
have_component(comp::String)
33+
34+
Check whether libsymengine was compiled with component `comp`
35+
"""
2436
function have_component(comp::String)
2537
func = get_symbol(:symengine_have_component)
2638
if func != C_NULL

0 commit comments

Comments
 (0)