diff --git a/Project.toml b/Project.toml index 03a3998..57dcb42 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "SymPy" uuid = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" -version = "1.1.12" +version = "1.1.13" [deps] CommonEq = "3709ef60-1bee-4518-9f2f-acd86f176c50" diff --git a/docs/Project.toml b/docs/Project.toml index 3e3ef98..f148933 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -4,4 +4,4 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" [compat] -Documenter = "0.24" +Documenter = "0.24, 1" diff --git a/docs/src/Tutorial/matrices.md b/docs/src/Tutorial/matrices.md index 3fef6d3..99ba034 100644 --- a/docs/src/Tutorial/matrices.md +++ b/docs/src/Tutorial/matrices.md @@ -974,9 +974,9 @@ julia> M = Sym[3 -2 4 -2; 5 3 -3 -2; 5 -2 2 -2; 5 -2 -3 3] julia> M.eigenvals() Dict{Any, Any} with 3 entries: - -2 => 1 3 => 1 5 => 2 + -2 => 1 ``` diff --git a/docs/src/Tutorial/solvers.md b/docs/src/Tutorial/solvers.md index 784fa38..6ac0e6b 100644 --- a/docs/src/Tutorial/solvers.md +++ b/docs/src/Tutorial/solvers.md @@ -519,8 +519,8 @@ julia> solveset(x^3 - 6*x^2 + 9*x, x) ```jldoctest solvers julia> roots(x^3 - 6*x^2 + 9*x, x) |> d -> convert(Dict{Sym, Any}, d) # prettier priting Dict{Sym, Any} with 2 entries: - 3 => 2 0 => 1 + 3 => 2 ``` ---- diff --git a/docs/src/introduction.md b/docs/src/introduction.md index e40e9fa..2da6079 100644 --- a/docs/src/introduction.md +++ b/docs/src/introduction.md @@ -1210,8 +1210,8 @@ julia> v = solveset(x^2 ~ 4, x) julia> collect(Set(v...)) 2-element Vector{Any}: - -2 2 + -2 ``` @@ -1220,8 +1220,8 @@ This composition is done in the `elements` function: ```jldoctest introduction julia> elements(v) 2-element Vector{Sym}: - -2 2 + -2 ``` diff --git a/docs/src/reference.md b/docs/src/reference.md index 4b2110a..11bb480 100644 --- a/docs/src/reference.md +++ b/docs/src/reference.md @@ -13,5 +13,6 @@ end ``` ```@autodocs -Modules = [SymPy] +Modules = [SymPy, SymPy.𝑄, SymPy.Introspection] +Order = [:function, :constant, :macro, :type, :module] ``` diff --git a/src/assumptions.jl b/src/assumptions.jl index db9b55c..e6447bb 100644 --- a/src/assumptions.jl +++ b/src/assumptions.jl @@ -53,7 +53,7 @@ export ask 𝑄 SymPy.Q -Documentation for the `SymPy.Q` module, exported as `𝑄`. +The`SymPy.𝑄` module adds features of the `sympy.Q` module. Also accesible through `SymPy.Q`. SymPy allows for [assumptions](https://docs.sympy.org/latest/modules/assumptions/index.html) @@ -71,7 +71,7 @@ julia> @vars y real=true positive=true (y,) ``` -The `Q` module exposes a means to *q*uery the assumptions on a +The `𝑄` module exposes a means to *q*uery the assumptions on a variable. For example, ```jldoctest 𝑄 @@ -104,12 +104,15 @@ The above use `&` as an infix operation for the binary operator `And`. Values can also be combined with `Or`, `Not`, `Xor`, `Nand`, `Nor`, `Implies`, `Equivalent`, and `satisfiable`. +!!! note "typing `𝑄`" + 𝑄 is entered as [slash]itQ[tab]) or `SymPy.Q.query(value)` *but not* as `sympy.Q.query(value)` + !!! note "Matrix predicates" As `SymPy.jl` converts symbolic matrices into Julia's `Array` type and not as matrices within Python, the predicate functions from SymPy for matrices are not used, though a replacement is given. """ -module Q +module 𝑄 import SymPy import PyCall import LinearAlgebra: det, norm @@ -253,7 +256,7 @@ function positive_definite(M::Array{T,2}) where {T <: SymPy.Sym} no_false = 0 no_nothing = 0 for i in 1:m - a = SymPy.ask(Q.positive(det(M[1:i, 1:i]))) + a = SymPy.ask(𝑄.positive(det(M[1:i, 1:i]))) if a == nothing no_nothing += 1 end if a == false no_false += 1 end end @@ -345,23 +348,20 @@ end end +export 𝑄 ## Issue #354; request to *not* export Q ## export #export Q -const 𝑄 = Q - -""" - 𝑄 - -Exported symbol for [`SymPy.Q`](@ref), a Julia module implementing `sympy.Q`. "Questions" can be asked through the patterns -`𝑄.query(value)` (𝑄 is entered as [slash]itQ[tab]) or `SymPy.Q.query(value)` *but not* as `sympy.Q.query(value)` +# """ +# Q -!!! note - At one time, the symbol `Q` was exported for this. To avoid namespace clutter, the unicode alternative is now used. Legacy code would need a definition like `const Q = SymPy.Q` to work. +# Unexported symbol for [`SymPy.𝑄`](@ref), a Julia module implementing `sympy.Q`. "Questions" can be asked through the patterns +# `𝑄.query(value)` -""" -𝑄 -export 𝑄 +# !!! note +# At one time, the symbol `Q` was exported. To avoid namespace clutter, the unicode alternative is now used. Legacy code would need a definition like `import SymPy: Q` to work. +# """ +const Q = 𝑄 diff --git a/src/types.jl b/src/types.jl index 11b1306..e851694 100644 --- a/src/types.jl +++ b/src/types.jl @@ -61,7 +61,12 @@ export Lambda ## this allows most things to flow though PyCall PyCall.PyObject(x::SymbolicObject) = x.__pyobject__ ## Override this so that using symbols as keys in a dict works -hash(x::SymbolicObject) = hash(PyObject(x)) +function Base.hash(x::SymbolicObject, h::UInt) + o = PyObject(x) + px = ccall((PyCall.@pysym :PyObject_Hash), PyCall.Py_hash_t, (PyCall.PyPtr,), o) # from PyCall.jl + reinterpret(UInt, Int(px)) - 3h # from PythonCall.jl +end +#hash(x::SymbolicObject) = hash(PyObject(x)) ==(x::SymbolicObject, y::SymbolicObject) = PyObject(x) == PyObject(y) ##################################################