Skip to content

Commit b1d4592

Browse files
refactor: add is_variable_numeric, is_numeric_symtype
1 parent f51778d commit b1d4592

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/utils.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,27 @@ function is_floatingpoint_symtype(T::Type)
838838
T <: AbstractArray && is_floatingpoint_symtype(eltype(T))
839839
end
840840

841+
"""
842+
$(TYPEDSIGNATURES)
843+
844+
Check if `sym` represents a symbolic number or array of numbers.
845+
"""
846+
function is_variable_numeric(sym)
847+
sym = unwrap(sym)
848+
T = symtype(sym)
849+
is_numeric_symtype(T)
850+
end
851+
852+
"""
853+
$(TYPEDSIGNATURES)
854+
855+
Check if `T` is an appropriate symtype for a symbolic variable representing a number or
856+
array of numbers.
857+
"""
858+
function is_numeric_symtype(T::Type)
859+
return T <: Number || T <: AbstractArray && is_numeric_symtype(eltype(T))
860+
end
861+
841862
"""
842863
$(TYPEDSIGNATURES)
843864

0 commit comments

Comments
 (0)