Skip to content

Define JetSpace equality#418

Open
PerezHz wants to merge 2 commits into
JuliaDiff:masterfrom
PerezHz:jp/jetspace-equality
Open

Define JetSpace equality#418
PerezHz wants to merge 2 commits into
JuliaDiff:masterfrom
PerezHz:jp/jetspace-equality

Conversation

@PerezHz

@PerezHz PerezHz commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This PR is an attempt to fix #417:

  • Adds structural JetSpace == and matching hash. By structural I mean comparing order, number of variables, variable names, and symbols, not caches/locks.
  • Updates TaylorN and HomogeneousPolynomial equality to use space(a) == space(b).
  • Leaves arithmetic checks identity-based via _check_same_space, so mixed-space operations still throw.
  • Updates set_default_space! to keep and return the existing default object when the incoming space is structurally equal.
  • Updates variables! to reuse the existing default space instead of constructing/replacing an equivalent one.
  • Adds tests for equality, hashing, no-warning reuse, and continued arithmetic rejection across distinct space identities.

cc: @lbenet @schillic

@coveralls

coveralls commented Jun 18, 2026

Copy link
Copy Markdown

Coverage Status

Coverage is 89.357%PerezHz:jp/jetspace-equality into JuliaDiff:master. No base build found for JuliaDiff:master.

@PerezHz PerezHz changed the title Define JetSpace equality Define JetSpace equality Jun 18, 2026

@schillic schillic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, in my later comments of #417 I did not mean to change the definition of == anymore. But if you think it makes sense, I will also not complain 🙂

Comment thread src/hash_tables.jl
"""
function set_default_space!(space::JetSpace; nowarn::Bool=false)
old_space = default_space[]
old_space === space && return space

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
old_space === space && return space

This line is now redundant.

Comment thread Project.toml
name = "TaylorSeries"
uuid = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea"
version = "0.22.1"
version = "0.22.2"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this qualifies as a patch version. It changes the behavior.

@schillic

Copy link
Copy Markdown
Contributor

Sorry, while this is helpful, it is not solving all of my issues.
Is there a reason why HomogeneousPolynomials need to have the same space? In particular, it could be sufficient that the relevant variables are the same. Consider the extreme case below where both polynomials are constants but created for different spaces.

julia> cp
 33.0

julia> cq
 33.0

julia> cp.space
JetSpace
    Expansion order:        3
    Number of variables:    3
    Variable names:         ["x₁", "x₂", "x₃"]
    Variable symbols:       [:x₁, :x₂, :x₃]

julia> cq.space
JetSpace
    Expansion order:        3
    Number of variables:    5
    Variable names:         ["x₁", "x₂", "x₃", "x₄", "x₅"]
    Variable symbols:       [:x₁, :x₂, :x₃, :x₄, :x₅]

julia> cp == cq
false

I understand that this is much more intricate to implement. So would it be possible to provide a function (again, it does not have to be ==) to check equality of polynomials while ignoring the space?

@lbenet

lbenet commented Jun 30, 2026

Copy link
Copy Markdown
Member

Is there a reason why HomogeneousPolynomials need to have the same space?

My naive guess to answer this question is that HomogeneousPolynomials are the basic consitituents of TaylorN, and in that sense they need to be related to a JetSpace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define == for JetSpace

4 participants