Conversation
src/mathfuns.jl
Outdated
| Base.Symbol(s::SymFunction) = Symbol(s.name) | ||
| Base.nameof(s::SymFunction) = Symbol(s) |
There was a problem hiding this comment.
I got cute? They could both resolve to Symbol(s.name). (I was looking for a generic that would give the symbol and not the general symbol for SymFunction and wasn't sure which should be preferred for generic programming.)
|
Is this good to go? I'm happy to merge but might need your help again with juliaregistrator. |
src/mathops.jl
Outdated
|
|
||
| ## Logical operators | ||
| Base.:<(x::SymbolicType, y::SymbolicType) = N(x) < N(y) | ||
| Base.:<(x::SymbolicType, y::SymbolicType) = is_constant(x) && is_constant(y) && N(x) < N(y) |
There was a problem hiding this comment.
x < y where x, y are Symbols would now give False silently?
There was a problem hiding this comment.
That's the idea, as the comparison isn't true. But I think I have this incorrect. There is now:
isless-- Non-numeric types with a total order should implement this function (then<would fall back toisless. (But is there a natural total order?)<-- New types with a canonical partial order should implement this function for two arguments of the new type.isunordered-- Return true if x is a value that is not orderable according to <,
We have defined isless and < but it seems in a manner that is not quite right. (isless and < had the same redundant definition.)
I'll roll this back and open an issue so it can be through through.
src/numerics.jl
Outdated
|
|
||
|
|
||
| ## julia predicates we can mirror | ||
| Base.iseven(x::Basic) = is_a_Integer(x) && iseven(convert(Integer, x)) |
There was a problem hiding this comment.
We should implement it for BasicType{:Integer} only.
There was a problem hiding this comment.
This is a good question. For floating point values iseven is defined and it checks for the value being an integer (2.0 is considered an integer) and then checks. Perhaps it should be a test with is_constant: Base.iseven(x::Basic) = is_constant(x) && iseven(N(x)) which is more general and doesn't seem to allocate any more
There was a problem hiding this comment.
Even then for a symbolic x we say it is not even, when we should be erroring out for symbolic values that are not integers.
There was a problem hiding this comment.
Okay, let's be consistent. (I just rolled back the < defintion and will roll back this one)
A few small adjustments
added
constto several constant variablesallow
TermInterface.operationto work withSymFunctionobjectsadd
nameofmethod forSymFunctionobjectsConversion of :ℯ (\euler) (Fixes bug)
add
unwrap_constto mirror SymbolicUtils behaviour (no error)add
isevenandisodd; add tests (allocate due to conversion to Integer)adjust behavior of _convert for expressions (Really want to avoid this, but somehow writing
convert(Expr, x)and getting a symbol seems wrong. Add test for behaviour.