Repository navigation
Use compact aliases when displaying polynomial basis types - #418
Merged
Merged
Conversation
FullBasis and SubBasis are aliases for StarAlgebras types. Julia's default
type display expands their internal mapping, iterator, and storage types,
including inside SOS sets and certificates. Add explicit show methods
using the existing MP aliases and preserve the basis family, variables,
and exponent types. Support partial families, upper bounds, unions, and
nested types; defer lower-bounded families to the default display.
Validation: 27 standalone MP display assertions pass using the environment
from test/Project.toml; temporary line markers exercise every new display
branch. The existing DP (50) and TP (165) display assertions and six frontend
integration assertions pass. Format the repository with JuliaFormatter 2.
Ellipsoid benchmark: four relaxations (degrees 2, 4, 6, 8), 11 warmed runs,
medians, Julia 1.13.3, one Julia and one BLAS thread, matched feasibility
and absolute/relative optimality tolerances of 1e-7. MP 0.6.4 with this
change, DP 0.7.0, released Dualization 0.7.7, Hypatia 0.11.0, Clarabel 0.11.1.
An in-memory switch compares the released and compact type displays in
the same process. Dualization is unmodified. Every measured run has zero
compilation/recompilation time and passes all eight tutorial assertions.
| Configuration | Build + solve (ms) | Solver (ms) | Other time (ms) | Allocated (MB) |
| --- | ---: | ---: | ---: | ---: |
| Clarabel | 486.3 | 456.9 | 29.5 | 51.7 |
| Dual Hypatia released display | 1007.8 | 97.7 | 910.4 | 319.0 |
| Dual Hypatia compact display | 413.0 | 97.2 | 315.7 | 125.0 |
These display methods remove most of the error-formatting overhead but
do not eliminate it. Generic alias lookup for the retained vector types
remains expensive. A separate warmed REPL measurement of 200 displays per
type (also with zero compilation time) illustrates that residual cost:
| Type displayed | Time per display (ms) | Allocated per display (bytes) |
| --- | ---: | ---: |
| Compact FullBasis | 0.576 | 182496 |
| Compact SubBasis | 0.582 | 182496 |
| Vector of DP variables | 0.306 | 109584 |
| Vector{Int} | 0.234 | 72848 |
Track type display invalidations separately while retaining the existing arithmetic invalidation limit. Handle SnoopCompile entries without an associated method and exercise that case explicitly.
Use one show method for both basis families to avoid ambiguity at Union{} on Julia 1.14. Defer bottom types and union families to the default type printer, including UnionAll wrappers.
Validation: the standalone invalidation tests (2 assertions) and type display tests (31 assertions) pass on Julia 1.10.13, 1.13.4, and 1.14.0-beta1 using test/Project.toml environments and the CI dependency exclusions on 1.14. Temporary line markers confirm coverage of the changed branches. JuliaFormatter 2 checks pass for src and test.
blegat
force-pushed
the
bl/basis_type_display
branch
from
November 17, 2026 16:27
5ab1271 to
f5d33e3
Compare
Use explicit Int64 and Int32 exponent types so the union remains distinct on both architectures. Int aliases Int32 on 32-bit Julia, causing the union to collapse. Validation: test/type_display.jl passes all 31 assertions on Julia 1.13.4 x64; temporary line markers confirm both basis families execute the changed line. Ran JuliaFormatter 2 on src and test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FullBasis and SubBasis are aliases for StarAlgebras types. Julia's default type display expands their internal mapping, iterator, and storage types, including inside SOS sets and certificates. Add explicit show methods using the existing MP aliases and preserve the basis family, variables, and exponent types. Support partial families, upper bounds, unions, and nested types; defer lower-bounded families to the default display.
For typeof(FullBasis{Monomial}([x, y])) with default DP variables, before printing expanded the implementation:
After:
These display methods remove most of the error-formatting overhead but do not eliminate it. Generic alias lookup for the retained vector types remains expensive. A separate warmed REPL measurement of 200 displays per type (also with zero compilation time) illustrates that residual cost: