triples 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {triples-0.2.0 → triples-0.3.0}/PKG-INFO +1 -1
- {triples-0.2.0 → triples-0.3.0}/pyproject.toml +42 -1
- {triples-0.2.0 → triples-0.3.0}/triples/__init__.py +1 -1
- {triples-0.2.0 → triples-0.3.0}/triples/benchmarks/problems/books/vasile.py +1 -21
- {triples-0.2.0 → triples-0.3.0}/triples/core/dispatch.py +59 -27
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/basis.py +102 -133
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/correction.py +28 -7
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/lift.py +38 -19
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/linsos.py +42 -10
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/solution.py +7 -6
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/tangents.py +149 -80
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/tests/test_linsos.py +12 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/node.py +15 -8
- {triples-0.2.0 → triples-0.3.0}/triples/core/preprocess/algebraic.py +3 -0
- triples-0.3.0/triples/core/preprocess/elimination.py +758 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/preprocess/modeling.py +172 -59
- triples-0.3.0/triples/core/preprocess/noncommutative.py +115 -0
- triples-0.3.0/triples/core/preprocess/polynomial.py +127 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/preprocess/reparam.py +1 -1
- triples-0.3.0/triples/core/preprocess/signs.py +989 -0
- triples-0.3.0/triples/core/preprocess/tests/test_elimination.py +156 -0
- triples-0.3.0/triples/core/preprocess/tests/test_noncommutative.py +19 -0
- triples-0.3.0/triples/core/preprocess/tests/test_signs.py +407 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/problem.py +258 -105
- triples-0.3.0/triples/core/progsos/__init__.py +7 -0
- triples-0.3.0/triples/core/progsos/cauchy.py +986 -0
- triples-0.3.0/triples/core/progsos/progsos.py +28 -0
- triples-0.3.0/triples/core/progsos/qcqp.py +334 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/abstract.py +7 -4
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/algebra/__init__.py +2 -2
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/algebra/basis.py +16 -8
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/algebra/moment_algebra.py +20 -5
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/algebra/nc_poly_ring.py +25 -9
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/algebra/poly_ring.py +11 -7
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/algebra/pseudo_poly.py +88 -39
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/algebra/state_algebra.py +9 -1
- triples-0.3.0/triples/core/sdpsos/algebra/tests/test_moment_algebra.py +50 -0
- triples-0.3.0/triples/core/sdpsos/algebra/tests/test_pseudo_poly.py +359 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/manifold.py +12 -6
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/sdpsos.py +72 -15
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/sohs.py +4 -3
- triples-0.3.0/triples/core/sdpsos/solution.py +362 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/sos.py +4 -3
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/sos_moment.py +4 -3
- triples-0.3.0/triples/core/sdpsos/tests/test_sdpsos.py +55 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/shared.py +1 -1
- {triples-0.2.0 → triples-0.3.0}/triples/core/solution.py +16 -14
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/__init__.py +1 -2
- triples-0.3.0/triples/core/structsos/nvars/__init__.py +9 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/nvars/linear.py +4 -3
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/nvars/quadratic.py +39 -12
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/nvars/quartic.py +10 -7
- triples-0.3.0/triples/core/structsos/nvars/solver.py +97 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/nvars/tests/test_nvars.py +6 -3
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/pivoting/bivariate.py +31 -18
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/quaternary/__init__.py +0 -1
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/quaternary/cubic.py +154 -7
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/quaternary/dense_symmetric.py +63 -21
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/quaternary/quartic.py +9 -8
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/quaternary/quartic_symmetric.py +54 -8
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/quaternary/quintic.py +4 -3
- triples-0.3.0/triples/core/structsos/quaternary/solver.py +236 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/quaternary/tests/test_quaternary.py +5 -3
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/structsos.py +62 -23
- triples-0.3.0/triples/core/structsos/ternary/__init__.py +39 -0
- {triples-0.2.0/triples/core/structsos/constrained → triples-0.3.0/triples/core/structsos/ternary}/acute.py +33 -30
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/acyclic.py +1 -1
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/cubic.py +56 -38
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/dense_symmetric.py +219 -86
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/nonic.py +25 -25
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/octic.py +5 -5
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/octic_symmetric.py +496 -293
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/quadratic.py +5 -4
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/quartic.py +520 -262
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/quintic.py +59 -69
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/quintic_symmetric.py +95 -105
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/septic.py +44 -48
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/septic_symmetric.py +20 -25
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/sextic.py +176 -134
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/sextic_symmetric.py +627 -518
- triples-0.3.0/triples/core/structsos/ternary/solver.py +305 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/sparse.py +21 -19
- triples-0.3.0/triples/core/structsos/ternary/tests/test_ternary.py +51 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/ternary/utils.py +31 -51
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/tests/test_univariate.py +3 -2
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/univariate.py +6 -5
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/utils.py +200 -94
- {triples-0.2.0 → triples-0.3.0}/triples/core/sum_of_squares.py +31 -6
- {triples-0.2.0 → triples-0.3.0}/triples/core/symsos/basic.py +1 -1
- {triples-0.2.0 → triples-0.3.0}/triples/core/symsos/representation.py +1 -1
- {triples-0.2.0 → triples-0.3.0}/triples/core/tests/test_dispatch.py +17 -1
- {triples-0.2.0 → triples-0.3.0}/triples/core/tests/test_problem.py +10 -1
- {triples-0.2.0 → triples-0.3.0}/triples/gui/grid.py +1 -1
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/__init__.py +3 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/abstract.py +13 -4
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/arithmetic/__init__.py +7 -3
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/arithmetic/matmul.py +231 -128
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/arithmetic/matop.py +147 -93
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/arithmetic/tests/test_matmul.py +143 -3
- triples-0.3.0/triples/sdp/arithmetic/tests/test_matop.py +79 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/backend.py +63 -13
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/caller.py +118 -38
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/clarabel_sdp.py +4 -1
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/tests/test_backends.py +91 -0
- triples-0.3.0/triples/sdp/cone.py +199 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/dual.py +23 -7
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/primal.py +6 -3
- triples-0.3.0/triples/sdp/tests/test_cone.py +29 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/transforms/linear.py +4 -3
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/transforms/transform.py +2 -1
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/transforms/transformable.py +2 -1
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/utils.py +64 -46
- {triples-0.2.0 → triples-0.3.0}/triples/testing/doctest_parser.py +14 -2
- triples-0.3.0/triples/testing/tests/test_code_quality.py +56 -0
- triples-0.3.0/triples/testing/tests/test_syntax.py +407 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/__init__.py +5 -4
- {triples-0.2.0 → triples-0.3.0}/triples/utils/expressions/coeff.py +31 -14
- {triples-0.2.0 → triples-0.3.0}/triples/utils/expressions/cyclic.py +5 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/monomials.py +378 -158
- {triples-0.2.0 → triples-0.3.0}/triples/utils/normalforms.py +5 -4
- {triples-0.2.0 → triples-0.3.0}/triples/utils/polytools.py +274 -12
- {triples-0.2.0 → triples-0.3.0}/triples/utils/pqr.py +10 -8
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/__init__.py +2 -3
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/monotonic_opt.py +3 -2
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/polysolve.py +27 -5
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/rationalize.py +20 -8
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/root_list.py +17 -11
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/roots.py +165 -64
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/tests/test_roots.py +12 -1
- triples-0.3.0/triples/utils/tests/__init__.py +0 -0
- triples-0.3.0/triples/utils/tests/test_monomials.py +107 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/tests/test_polytools.py +34 -2
- {triples-0.2.0 → triples-0.3.0}/triples/utils/tree_predictor.py +59 -36
- {triples-0.2.0 → triples-0.3.0}/triples.egg-info/PKG-INFO +1 -1
- {triples-0.2.0 → triples-0.3.0}/triples.egg-info/SOURCES.txt +17 -11
- triples-0.2.0/triples/core/linsos/updegree.py +0 -7
- triples-0.2.0/triples/core/preprocess/elimination.py +0 -310
- triples-0.2.0/triples/core/preprocess/polynomial.py +0 -344
- triples-0.2.0/triples/core/preprocess/signs.py +0 -663
- triples-0.2.0/triples/core/preprocess/tests/test_elimination.py +0 -57
- triples-0.2.0/triples/core/preprocess/tests/test_signs.py +0 -179
- triples-0.2.0/triples/core/sdpsos/solution.py +0 -204
- triples-0.2.0/triples/core/structsos/constrained/__init__.py +0 -3
- triples-0.2.0/triples/core/structsos/constrained/linear.py +0 -139
- triples-0.2.0/triples/core/structsos/constrained/solver.py +0 -40
- triples-0.2.0/triples/core/structsos/constrained/tests/test_constrained.py +0 -28
- triples-0.2.0/triples/core/structsos/nvars/__init__.py +0 -9
- triples-0.2.0/triples/core/structsos/nvars/solver.py +0 -89
- triples-0.2.0/triples/core/structsos/quaternary/solver.py +0 -191
- triples-0.2.0/triples/core/structsos/quaternary/utils.py +0 -20
- triples-0.2.0/triples/core/structsos/solution.py +0 -96
- triples-0.2.0/triples/core/structsos/sparse.py +0 -104
- triples-0.2.0/triples/core/structsos/ternary/__init__.py +0 -36
- triples-0.2.0/triples/core/structsos/ternary/solver.py +0 -132
- triples-0.2.0/triples/core/structsos/ternary/tests/test_ternary.py +0 -27
- triples-0.2.0/triples/sdp/arithmetic/tests/test_matop.py +0 -24
- triples-0.2.0/triples/testing/tests/test_dependency.py +0 -66
- {triples-0.2.0 → triples-0.3.0}/LICENSE +0 -0
- {triples-0.2.0 → triples-0.3.0}/README.md +0 -0
- {triples-0.2.0 → triples-0.3.0}/notebooks/README_pypi.md +0 -0
- {triples-0.2.0 → triples-0.3.0}/setup.cfg +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/benchmarks/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/benchmarks/problems/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/benchmarks/problems/books/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/benchmarks/problems/books/nice_and_hard567.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/benchmarks/problems/contests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/benchmarks/problems/contests/chn.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/benchmarks/problems/contests/imo.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/benchmarks/problems/problem_set.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/benchmarks/run_benchmark.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/complexity.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/models/linearsossolver_length_model.npz +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/models/linearsossolver_prob_model.npz +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/models/linearsossolver_time_model.npz +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/linsos/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/pivoting/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/pivoting/pivoting.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/pivoting/quadratic.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/pivoting/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/pivoting/tests/test_pivoting.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/preprocess/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/preprocess/features.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/preprocess/tests/__init__.py +0 -0
- {triples-0.2.0/triples/core/sdpsos → triples-0.3.0/triples/core/progsos}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/__init__.py +0 -0
- {triples-0.2.0/triples/core/structsos/constrained → triples-0.3.0/triples/core/sdpsos/algebra}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/models/sdpsossolver_length_model.npz +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/models/sdpsossolver_prob_model.npz +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/models/sdpsossolver_time_model.npz +0 -0
- {triples-0.2.0/triples/core/structsos/nvars → triples-0.3.0/triples/core/sdpsos}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/sdpsos/tests/test_sos_obj.py +0 -0
- {triples-0.2.0/triples/core/structsos/quaternary → triples-0.3.0/triples/core/structsos/nvars}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/structsos/pivoting/__init__.py +0 -0
- {triples-0.2.0/triples/core/structsos/ternary → triples-0.3.0/triples/core/structsos/quaternary}/tests/__init__.py +0 -0
- {triples-0.2.0/triples/core/structsos → triples-0.3.0/triples/core/structsos/ternary}/tests/__init__.py +0 -0
- {triples-0.2.0/triples/core/symsos → triples-0.3.0/triples/core/structsos}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/symsos/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/symsos/symmetric.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/symsos/symsos.py +0 -0
- {triples-0.2.0/triples/core → triples-0.3.0/triples/core/symsos}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/core/symsos/tests/test_symsos.py +0 -0
- {triples-0.2.0/triples/sdp/arithmetic → triples-0.3.0/triples/core}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/gui/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/gui/linebreak.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/gui/sos_manager.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/gui/visualize.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/arithmetic/eigens.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/arithmetic/linsolve.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/arithmetic/lll.py +0 -0
- {triples-0.2.0/triples/sdp/backends → triples-0.3.0/triples/sdp/arithmetic}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/arithmetic/tests/test_eigens.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/arithmetic/tests/test_linsolve.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/cvxopt_sdp.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/cvxpy_sdp.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/mosek_sdp.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/picos_sdp.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/qics_sdp.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/sdpap_sdp.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/backends/settings.py +0 -0
- {triples-0.2.0/triples/sdp → triples-0.3.0/triples/sdp/backends}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/ipm.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/rationalize.py +0 -0
- {triples-0.2.0/triples/sdp/transforms → triples-0.3.0/triples/sdp}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/tests/test_dual.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/tests/test_primal.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/transforms/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/transforms/diagonalize.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/transforms/parametric.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/transforms/polytope.py +0 -0
- {triples-0.2.0/triples/sdp/wedderburn → triples-0.3.0/triples/sdp/transforms}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/transforms/tests/test_diagonalize.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/transforms/tests/test_linear.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/transforms/tests/test_polytope.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/wedderburn/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/wedderburn/character_table.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/wedderburn/decomposition.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/wedderburn/dixon.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/wedderburn/symmetric.py +0 -0
- {triples-0.2.0/triples/testing → triples-0.3.0/triples/sdp/wedderburn/tests}/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/wedderburn/tests/test_dixon.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/sdp/wedderburn/tests/test_symmetric.py +0 -0
- {triples-0.2.0/triples/testing/tests → triples-0.3.0/triples/testing}/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/testing/fix_code_quality.py +0 -0
- {triples-0.2.0/triples/utils/expressions → triples-0.3.0/triples/testing}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/expressions/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/expressions/exraw.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/expressions/psatz.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/expressions/soscone.py +0 -0
- {triples-0.2.0/triples/utils/roots → triples-0.3.0/triples/utils/expressions}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/expressions/tests/test_coeff.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/expressions/tests/test_cyclic.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/extrema.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/num_extrema.py +0 -0
- {triples-0.2.0/triples/utils → triples-0.3.0/triples/utils/roots}/tests/__init__.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/tests/test_extrema.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/tests/test_num_extrema.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/roots/tests/test_polysolve.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/tests/test_text_process.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples/utils/text_process.py +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples.egg-info/dependency_links.txt +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples.egg-info/requires.txt +0 -0
- {triples-0.2.0 → triples-0.3.0}/triples.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "triples"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Automatic sum-of-squares proofs for algebraic inequalities"
|
|
9
9
|
readme = "notebooks/README_pypi.md"
|
|
10
10
|
license = {file = "LICENSE"}
|
|
@@ -46,6 +46,44 @@ include = ["triples*"]
|
|
|
46
46
|
[tool.setuptools.package-data]
|
|
47
47
|
triples = ["**/*.npz"]
|
|
48
48
|
|
|
49
|
+
[tool.mypy]
|
|
50
|
+
# mypy 2.3 no longer supports Python 3.6 as a checking target. Keep the
|
|
51
|
+
# source annotations Python 3.6-compatible while using the oldest target
|
|
52
|
+
# supported by the installed checker.
|
|
53
|
+
python_version = "3.10"
|
|
54
|
+
files = ["triples/core", "triples/utils", "triples/sdp"]
|
|
55
|
+
exclude = "(^|/)(benchmarks|gui|testing|tests)(/|$)"
|
|
56
|
+
show_error_codes = true
|
|
57
|
+
warn_unused_ignores = true
|
|
58
|
+
check_untyped_defs = true
|
|
59
|
+
|
|
60
|
+
[[tool.mypy.overrides]]
|
|
61
|
+
module = [
|
|
62
|
+
"scipy",
|
|
63
|
+
"scipy.*",
|
|
64
|
+
"mpmath",
|
|
65
|
+
"mpmath.*",
|
|
66
|
+
"pandas",
|
|
67
|
+
"pandas.*",
|
|
68
|
+
"tqdm",
|
|
69
|
+
"tqdm.*",
|
|
70
|
+
"clarabel",
|
|
71
|
+
"clarabel.*",
|
|
72
|
+
"cvxopt",
|
|
73
|
+
"cvxopt.*",
|
|
74
|
+
"cvxpy",
|
|
75
|
+
"cvxpy.*",
|
|
76
|
+
"mosek",
|
|
77
|
+
"mosek.*",
|
|
78
|
+
"picos",
|
|
79
|
+
"picos.*",
|
|
80
|
+
"qics",
|
|
81
|
+
"qics.*",
|
|
82
|
+
"sdpap",
|
|
83
|
+
"sdpap.*",
|
|
84
|
+
]
|
|
85
|
+
ignore_missing_imports = true
|
|
86
|
+
|
|
49
87
|
[tool.ruff]
|
|
50
88
|
# from SymPy
|
|
51
89
|
lint.select = [
|
|
@@ -100,3 +138,6 @@ exclude = ["triples/benchmarks/run_benchmark.py"]
|
|
|
100
138
|
[tool.ruff.lint.flake8-type-checking]
|
|
101
139
|
quote-annotations = true
|
|
102
140
|
strict = true
|
|
141
|
+
|
|
142
|
+
# [tool.ruff.lint.isort]
|
|
143
|
+
# relative-imports-order = "closest-to-furthest"
|
|
@@ -739,7 +739,6 @@ class MathematicalInequalitiesVol1(MathematicalInequalities):
|
|
|
739
739
|
def problem_vasile_p13098(self):
|
|
740
740
|
return c4p(a-1) - (x-1)**4, [a,b,c,d], [c4s(1/a**2) - 4/x**2]
|
|
741
741
|
|
|
742
|
-
@mark(mark.skip)
|
|
743
742
|
def problem_vasile_p13099(self):
|
|
744
743
|
return c4p((1+a**3)/(1+a**2)) - (1+c4p(a))/2, [a,b,c,d], []
|
|
745
744
|
|
|
@@ -806,15 +805,12 @@ class MathematicalInequalitiesVol1(MathematicalInequalities):
|
|
|
806
805
|
def problem_vasile_p13115(self):
|
|
807
806
|
return 31*c5s(a**2)-150-c5s(a**4), [a,b,c,d,e], [c5s(a)-5]
|
|
808
807
|
|
|
809
|
-
@mark(mark.skip)
|
|
810
808
|
def problem_vasile_p13116(self):
|
|
811
809
|
return 5 - c5p(a)*c5s(a**4), [a,b,c,d,e], [c5s(a**2)-5]
|
|
812
810
|
|
|
813
|
-
@mark(mark.skip)
|
|
814
811
|
def problem_vasile_p13117(self):
|
|
815
812
|
return c5s(1/a) + 20/c5s(a**2) - 9, [a,b,c,d,e], [c5s(a)-5]
|
|
816
813
|
|
|
817
|
-
@mark(mark.skip)
|
|
818
814
|
def problem_vasile_p13118(self):
|
|
819
815
|
return c5p(a+1/a) + 68 - 4*c5s(a)*c5s(1/a), [a-1,b-1,c-1,d-1,e-1], []
|
|
820
816
|
|
|
@@ -1005,11 +1001,9 @@ class MathematicalInequalitiesVol2(MathematicalInequalities):
|
|
|
1005
1001
|
def problem_vasile_p21042_p1(self):
|
|
1006
1002
|
return Rational(3,2) - c3s(1/(3-a*b)), [a,b,c], [c3s(a**2)-3]
|
|
1007
1003
|
|
|
1008
|
-
@mark(mark.skip)
|
|
1009
1004
|
def problem_vasile_p21042_p2(self):
|
|
1010
1005
|
return 3/(sqrt(6)-1) - c3s(1/(sqrt(6)-a*b)), [a,b,c], [c3s(a**2)-3]
|
|
1011
1006
|
|
|
1012
|
-
@mark(mark.skip)
|
|
1013
1007
|
def problem_vasile_p21043(self):
|
|
1014
1008
|
return c3s(1/(1+a**5)) - Rational(3,2), [a,b,c], [c3s(a**2)-3]
|
|
1015
1009
|
|
|
@@ -1122,7 +1116,6 @@ class MathematicalInequalitiesVol2(MathematicalInequalities):
|
|
|
1122
1116
|
def problem_vasile_p21071(self):
|
|
1123
1117
|
return c3s((a*b+(k-1)*b*c+c*a)/(b**2+k*b*c+c**2)) - 3*(k+1)/(k+2), [a,b,c,k+2], []
|
|
1124
1118
|
|
|
1125
|
-
@mark(mark.skip)
|
|
1126
1119
|
def problem_vasile_p21072(self):
|
|
1127
1120
|
return 3/(k+2) - c3s((3*b*c-a*(b+c))/(b**2+k*b*c+c**2)), [a,b,c,k+2], []
|
|
1128
1121
|
|
|
@@ -1153,11 +1146,9 @@ class MathematicalInequalitiesVol2(MathematicalInequalities):
|
|
|
1153
1146
|
def problem_vasile_p21081(self):
|
|
1154
1147
|
return c3s((2*a**2+5*b*c)/(b+c)**2) - Rational(21,4), [a,b,c], []
|
|
1155
1148
|
|
|
1156
|
-
@mark(mark.skip)
|
|
1157
1149
|
def problem_vasile_p21082(self):
|
|
1158
1150
|
return c3s((2*a**2+(2*k+1)*b*c)/(b**2+k*b*c+c**2)) - 3*(2*k+3)/(k+2), [a,b,c,k+2], []
|
|
1159
1151
|
|
|
1160
|
-
@mark(mark.skip)
|
|
1161
1152
|
def problem_vasile_p21083(self):
|
|
1162
1153
|
return 3/(k+2) - c3s((3*b*c-2*a**2)/(b**2+k*b*c+c**2)), [a,b,c,k+2], []
|
|
1163
1154
|
|
|
@@ -1170,11 +1161,9 @@ class MathematicalInequalitiesVol2(MathematicalInequalities):
|
|
|
1170
1161
|
def problem_vasile_p21086(self):
|
|
1171
1162
|
return c3s((a**2+64*b*c)/(b+c)**2) - 18, [a,b,c], []
|
|
1172
1163
|
|
|
1173
|
-
@mark(mark.skip)
|
|
1174
1164
|
def problem_vasile_p21087(self):
|
|
1175
1165
|
return c3s((a**2*(b+c)+k*a*b*c)/(b**2+k*b*c+c**2)) - c3s(a), [a,b,c,k+1], []
|
|
1176
1166
|
|
|
1177
|
-
@mark(mark.skip)
|
|
1178
1167
|
def problem_vasile_p21088(self):
|
|
1179
1168
|
return c3s((a**3+(k+1)*a*b*c)/(b**2+k*b*c+c**2)) - c3s(a), [a,b,c,k+Rational(3,2)], []
|
|
1180
1169
|
|
|
@@ -1194,15 +1183,12 @@ class MathematicalInequalitiesVol2(MathematicalInequalities):
|
|
|
1194
1183
|
def problem_vasile_p21092(self):
|
|
1195
1184
|
return c3s((b**2+c**2-a**2)/(2*a**2+(b+c)**2)) - Rational(1,2), [a,b,c], []
|
|
1196
1185
|
|
|
1197
|
-
@mark(mark.skip)
|
|
1198
1186
|
def problem_vasile_p21093(self):
|
|
1199
1187
|
return 3/k - c3s((3*a**2-2*b*c)/(k*a**2+(b-c)**2)), [a,b,c,k], []
|
|
1200
1188
|
|
|
1201
|
-
@mark(mark.skip)
|
|
1202
1189
|
def problem_vasile_p21094_p1(self):
|
|
1203
1190
|
return c3s(a/(a**2+k*b*c)) - 9/c3s(a)/(1+k), [a,b,c,k-3-sqrt(7)], []
|
|
1204
1191
|
|
|
1205
|
-
@mark(mark.skip)
|
|
1206
1192
|
def problem_vasile_p21094_p2(self):
|
|
1207
1193
|
return c3s(a/(k*a**2+b*c)) - 9/c3s(a)/(1+k), [a,b,c,k-3-sqrt(7)], []
|
|
1208
1194
|
|
|
@@ -1281,11 +1267,9 @@ class MathematicalInequalitiesVol2(MathematicalInequalities):
|
|
|
1281
1267
|
def problem_vasile_p21114(self):
|
|
1282
1268
|
return 9/c3s(a*b)/2 - c3s(1/(b**2+c**2)), [b+c-a,c+a-b,a+b-c], []
|
|
1283
1269
|
|
|
1284
|
-
@mark(mark.skip)
|
|
1285
1270
|
def problem_vasile_p21115_p1(self):
|
|
1286
1271
|
return Abs(c3s((a+b)/(a-b))) - 5, [b+c-a,c+a-b,a+b-c], []
|
|
1287
1272
|
|
|
1288
|
-
@mark(mark.skip)
|
|
1289
1273
|
def problem_vasile_p21115_p2(self):
|
|
1290
1274
|
return Abs(c3s((a**2+b**2)/(a**2-b**2))) - 3, [b+c-a,c+a-b,a+b-c], []
|
|
1291
1275
|
|
|
@@ -1298,7 +1282,6 @@ class MathematicalInequalitiesVol2(MathematicalInequalities):
|
|
|
1298
1282
|
def problem_vasile_p21118(self):
|
|
1299
1283
|
return c3s((a*(b+c)-2*b*c)/((b+c)*(3*a+b+c))), [a,b,c], []
|
|
1300
1284
|
|
|
1301
|
-
@mark(mark.skip)
|
|
1302
1285
|
def problem_vasile_p21119(self):
|
|
1303
1286
|
return c3s((a**5-a**2)/(a**5+b**2+c**2)), [a,b,c,c3s(a**2)-3], []
|
|
1304
1287
|
|
|
@@ -2335,7 +2318,6 @@ class MathematicalInequalitiesVol3(MathematicalInequalities):
|
|
|
2335
2318
|
def problem_vasile_p31087_p2(self):
|
|
2336
2319
|
return c3s(1/a/sqrt(a+8*b)) - sqrt(1/c3p(a)), [a,b,c], []
|
|
2337
2320
|
|
|
2338
|
-
@mark(mark.skip)
|
|
2339
2321
|
def problem_vasile_p31088(self):
|
|
2340
2322
|
return sqrt(c3s(a)/3) - c3s(a/sqrt(5*a+4*b)), [a,b,c], []
|
|
2341
2323
|
|
|
@@ -2613,7 +2595,6 @@ class MathematicalInequalitiesVol3(MathematicalInequalities):
|
|
|
2613
2595
|
def problem_vasile_p31160(self):
|
|
2614
2596
|
return c4p(1+2*a/(b+c)) - 9, [a,b,c,d] ,[]
|
|
2615
2597
|
|
|
2616
|
-
@mark(mark.skip)
|
|
2617
2598
|
def problem_vasile_p31161(self):
|
|
2618
2599
|
return c4p(1+k*a/(b+c)) - (1+k)**2, [a,b,c,d,k], []
|
|
2619
2600
|
|
|
@@ -2651,7 +2632,7 @@ class MathematicalInequalitiesVol3(MathematicalInequalities):
|
|
|
2651
2632
|
def problem_vasile_p31172_p1(self):
|
|
2652
2633
|
return (sqrt(5)-1)/4 - c5s(a*b)/c5s(a**2), [], [c5s(a)]
|
|
2653
2634
|
|
|
2654
|
-
def
|
|
2635
|
+
def problem_vasile_p31172_p2(self):
|
|
2655
2636
|
return (sqrt(5)+1)/4 + c5s(a*b)/c5s(a**2), [], [c5s(a)]
|
|
2656
2637
|
|
|
2657
2638
|
def problem_vasile_p31173(self):
|
|
@@ -3033,7 +3014,6 @@ class MathematicalInequalitiesVol3(MathematicalInequalities):
|
|
|
3033
3014
|
return x + y + z - sqrt(4*(a + b + c + sqrt(a*b) + sqrt(b*c) + sqrt(c*a)) + 3*(a*b*c)**Rational(1,3)), [a,b,c,x,y,z],\
|
|
3034
3015
|
[a/(y*z) + b/(z*x) + c/(x*y) - 1]
|
|
3035
3016
|
|
|
3036
|
-
@mark(mark.skip)
|
|
3037
3017
|
def problem_vasile_p32080_p2(self):
|
|
3038
3018
|
return x + y + z - (sqrt(a + b) + sqrt(b + c) + sqrt(c + a)), [a,b,c,x,y,z], [a/(y*z) + b/(z*x) + c/(x*y) - 1]
|
|
3039
3019
|
|
|
@@ -10,11 +10,11 @@ To control the behaviour of `InequalityProblem` on new types, you can either:
|
|
|
10
10
|
from functools import singledispatch
|
|
11
11
|
from typing import (
|
|
12
12
|
List, Tuple, Set, Optional, Callable,
|
|
13
|
-
Any,
|
|
13
|
+
Any, TYPE_CHECKING, cast
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
from sympy import (
|
|
17
|
-
Expr, Dummy, Poly, Integer, Add, Mul,
|
|
17
|
+
Expr, Dummy, Poly, Integer, Add, Mul, Pow,
|
|
18
18
|
sympify, signsimp
|
|
19
19
|
)
|
|
20
20
|
from sympy import __version__ as SYMPY_VERSION
|
|
@@ -35,15 +35,17 @@ else:
|
|
|
35
35
|
_sqf_list = lambda p: p.factor_list() # it would be slower, but correct
|
|
36
36
|
|
|
37
37
|
if SYMPY_VERSION_TUPLE >= (1, 14):
|
|
38
|
-
_polyelement_init = PolyElement
|
|
39
|
-
_fracelement_init = FracElement
|
|
38
|
+
_polyelement_init = cast(Callable[..., Any], PolyElement)
|
|
39
|
+
_fracelement_init = cast(Callable[..., Any], FracElement)
|
|
40
40
|
else:
|
|
41
|
-
def
|
|
41
|
+
def _polyelement_init_legacy(ring, init):
|
|
42
42
|
return ring.zero.new(init)
|
|
43
|
-
def
|
|
43
|
+
def _fracelement_init_legacy(field, numer, denom):
|
|
44
44
|
obj = object.__new__(FracElement)
|
|
45
45
|
obj.field, obj.numer, obj.denom = field, numer, denom
|
|
46
46
|
return obj
|
|
47
|
+
_polyelement_init = _polyelement_init_legacy
|
|
48
|
+
_fracelement_init = _fracelement_init_legacy
|
|
47
49
|
|
|
48
50
|
from ..utils.expressions.exraw import HAS_EXRAW
|
|
49
51
|
|
|
@@ -53,39 +55,51 @@ if TYPE_CHECKING:
|
|
|
53
55
|
)
|
|
54
56
|
from sympy.combinatorics import Permutation
|
|
55
57
|
|
|
56
|
-
T = TypeVar('T')
|
|
57
|
-
|
|
58
58
|
@singledispatch
|
|
59
|
-
def _dtype_free_symbols(x:
|
|
59
|
+
def _dtype_free_symbols(x: Any) -> Set['Symbol']:
|
|
60
60
|
return x.free_symbols
|
|
61
61
|
|
|
62
62
|
@singledispatch
|
|
63
|
-
def _dtype_gens(x:
|
|
63
|
+
def _dtype_gens(x: Any) -> Tuple['Symbol', ...]:
|
|
64
64
|
return x.gens
|
|
65
65
|
|
|
66
66
|
@singledispatch
|
|
67
|
-
def _dtype_is_zero(x:
|
|
67
|
+
def _dtype_is_zero(x: Any) -> Optional[bool]:
|
|
68
68
|
return x.is_zero
|
|
69
69
|
|
|
70
70
|
@singledispatch
|
|
71
|
-
def _dtype_convert(x:
|
|
71
|
+
def _dtype_convert(x: Any, y: Any) -> Any:
|
|
72
72
|
return x.convert(y)
|
|
73
73
|
|
|
74
74
|
@singledispatch
|
|
75
|
-
def _dtype_homogenize(x:
|
|
75
|
+
def _dtype_homogenize(x: Any, s: 'Symbol') -> Any:
|
|
76
76
|
return x.homogenize(s)
|
|
77
77
|
|
|
78
78
|
@singledispatch
|
|
79
|
-
def _dtype_is_homogeneous(x:
|
|
79
|
+
def _dtype_is_homogeneous(x: Any) -> Optional[bool]:
|
|
80
80
|
return x.is_homogeneous
|
|
81
81
|
|
|
82
82
|
@singledispatch
|
|
83
|
-
def _dtype_sqf_list(x:
|
|
83
|
+
def _dtype_sqf_list(x: Any) -> Tuple[Expr, List[Tuple[Any, int]]]:
|
|
84
84
|
return x.sqf_list()
|
|
85
85
|
|
|
86
86
|
@singledispatch
|
|
87
|
-
def _dtype_make_reorder_func(x:
|
|
88
|
-
"""
|
|
87
|
+
def _dtype_make_reorder_func(x: Any, gens: Tuple['Symbol', ...]) -> Callable[['Permutation'], Any]:
|
|
88
|
+
"""
|
|
89
|
+
Return a callable `f` such that `f(perm) == x.xreplace(dict(zip(gens, perm(gens))))`.
|
|
90
|
+
|
|
91
|
+
Unlike `Poly.reorder`, this function changes the value of `x`.
|
|
92
|
+
|
|
93
|
+
Examples
|
|
94
|
+
--------
|
|
95
|
+
>>> from sympy.abc import a, b, c
|
|
96
|
+
>>> from sympy.combinatorics import Permutation
|
|
97
|
+
>>> x = (a+2*b+3*c).as_poly(a,b,c)
|
|
98
|
+
>>> x.reorder(b,c,a)
|
|
99
|
+
Poly(2*b + 3*c + a, b, c, a, domain='ZZ')
|
|
100
|
+
>>> _dtype_make_reorder_func(x, (a,b,c))(Permutation([1,2,0]))
|
|
101
|
+
Poly(3*a + b + 2*c, a, b, c, domain='ZZ')
|
|
102
|
+
"""
|
|
89
103
|
return lambda perm: x.xreplace(dict(zip(gens, perm(gens))))
|
|
90
104
|
|
|
91
105
|
|
|
@@ -114,14 +128,14 @@ def _expr_homogenize(x: Expr, s: 'Symbol') -> Expr:
|
|
|
114
128
|
for a in xargs:
|
|
115
129
|
if a == s:
|
|
116
130
|
power += 1
|
|
117
|
-
elif a
|
|
131
|
+
elif isinstance(a, Pow) and a.base == s:
|
|
118
132
|
power += a.exp
|
|
119
133
|
else:
|
|
120
134
|
other_args.append(a)
|
|
121
135
|
return (power, Mul(*other_args))
|
|
122
136
|
return (0, x)
|
|
123
137
|
|
|
124
|
-
def extract(x: Add) ->
|
|
138
|
+
def extract(x: Add) -> Expr:
|
|
125
139
|
"""Collect all terms of an Add expression by the power of s."""
|
|
126
140
|
args = Add.make_args(x)
|
|
127
141
|
ex = [extract_mul(a) for a in args]
|
|
@@ -144,15 +158,21 @@ def _expr_is_homogeneous(x: Expr) -> Optional[bool]:
|
|
|
144
158
|
@_dtype_sqf_list.register(Expr)
|
|
145
159
|
def _expr_sqf_list(x: Expr) -> Tuple[Expr, List[Tuple[Expr, int]]]:
|
|
146
160
|
if x.is_Mul:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
factors = []
|
|
162
|
+
for arg in x.args:
|
|
163
|
+
a = cast(Expr, arg)
|
|
164
|
+
if isinstance(a, Pow) and a.exp.is_Rational:
|
|
165
|
+
factors.append((a.base**(Integer(1)/a.exp.q), int(a.exp.p)))
|
|
166
|
+
else:
|
|
167
|
+
factors.append((a, 1))
|
|
168
|
+
return Integer(1), factors
|
|
169
|
+
if isinstance(x, Pow) and x.exp.is_Rational:
|
|
150
170
|
return (Integer(1), [(x.base**(Integer(1)/x.exp.q), int(x.exp.p))])
|
|
151
171
|
return (Integer(1), [(x, 1)])
|
|
152
172
|
|
|
153
173
|
@_dtype_make_reorder_func.register(Expr)
|
|
154
|
-
def _expr_make_reorder_func(x: Expr, gens: Tuple['Symbol', ...]) -> Callable[['Permutation'],
|
|
155
|
-
return lambda perm: signsimp(x.xreplace(dict(zip(gens, perm(gens)))))
|
|
174
|
+
def _expr_make_reorder_func(x: Expr, gens: Tuple['Symbol', ...]) -> Callable[['Permutation'], Expr]:
|
|
175
|
+
return lambda perm: cast(Expr, signsimp(x.xreplace(dict(zip(gens, perm(gens))))))
|
|
156
176
|
|
|
157
177
|
|
|
158
178
|
|
|
@@ -170,7 +190,7 @@ def _poly_sqf_list(x: Poly) -> Tuple[Expr, List[Tuple[Poly, int]]]:
|
|
|
170
190
|
return _sqf_list(x)
|
|
171
191
|
|
|
172
192
|
@_dtype_make_reorder_func.register(Poly)
|
|
173
|
-
def _poly_make_reorder_func(x: Poly, gens: Tuple['Symbol', ...]) -> Callable[['Permutation'],
|
|
193
|
+
def _poly_make_reorder_func(x: Poly, gens: Tuple['Symbol', ...]) -> Callable[['Permutation'], Poly]:
|
|
174
194
|
if x.gens == gens:
|
|
175
195
|
return lambda perm: Poly.new(x.reorder(*perm.__invert__()(gens)).rep, *gens)
|
|
176
196
|
return lambda perm: Poly(x.as_expr().xreplace(dict(zip(gens, perm(gens)))), *gens)
|
|
@@ -195,7 +215,7 @@ def _polyelement_free_symbols(x: PolyElement) -> Set['Symbol']:
|
|
|
195
215
|
symbols = {g for g, d in zip(x.ring.gens, x.degrees()) if d > 0}
|
|
196
216
|
domain = x.ring.domain
|
|
197
217
|
if domain.is_Composite:
|
|
198
|
-
for gen in domain.symbols:
|
|
218
|
+
for gen in domain.symbols: # type: ignore
|
|
199
219
|
symbols |= gen.free_symbols
|
|
200
220
|
elif domain.is_EX:
|
|
201
221
|
for coeff in x.coeffs():
|
|
@@ -203,7 +223,7 @@ def _polyelement_free_symbols(x: PolyElement) -> Set['Symbol']:
|
|
|
203
223
|
elif HAS_EXRAW and domain.is_EXRAW:
|
|
204
224
|
for coeff in x.coeffs():
|
|
205
225
|
symbols |= coeff.free_symbols
|
|
206
|
-
return symbols
|
|
226
|
+
return cast(Set['Symbol'], symbols)
|
|
207
227
|
|
|
208
228
|
|
|
209
229
|
@_dtype_homogenize.register(PolyElement)
|
|
@@ -223,6 +243,12 @@ def _polyelement_is_homogeneous(x: PolyElement) -> bool:
|
|
|
223
243
|
d = sum(monoms[0])
|
|
224
244
|
return all(sum(m) == d for m in monoms)
|
|
225
245
|
|
|
246
|
+
@_dtype_make_reorder_func.register(PolyElement)
|
|
247
|
+
def _polyelement_make_reorder_func(x: PolyElement, gens: Tuple['Symbol', ...]) -> Callable[['Permutation'], PolyElement]:
|
|
248
|
+
def reorder(perm):
|
|
249
|
+
inv = perm.__invert__()._array_form
|
|
250
|
+
return x.new({tuple(m[i] for i in inv): v for m, v in x.items()})
|
|
251
|
+
return reorder
|
|
226
252
|
|
|
227
253
|
|
|
228
254
|
@_dtype_free_symbols.register(FracElement)
|
|
@@ -242,3 +268,9 @@ def _fracelement_is_homogeneous(x: FracElement) -> bool:
|
|
|
242
268
|
def _fracelement_homogenize(x: FracElement, s: 'Symbol') -> FracElement:
|
|
243
269
|
numer, denom = _polyelement_homogenize(x.numer, s), _polyelement_homogenize(x.denom, s)
|
|
244
270
|
return _fracelement_init(numer.ring.to_field(), *numer.cancel(denom))
|
|
271
|
+
|
|
272
|
+
@_dtype_make_reorder_func.register(FracElement)
|
|
273
|
+
def _fracelement_make_reorder_func(x: FracElement, gens: Tuple['Symbol', ...]) -> Callable[['Permutation'], FracElement]:
|
|
274
|
+
rn = _polyelement_make_reorder_func(x.numer, gens)
|
|
275
|
+
rd = _polyelement_make_reorder_func(x.denom, gens)
|
|
276
|
+
return lambda perm: _fracelement_init(x.numer.ring.to_field(), *rn(perm).cancel(rd(perm)))
|