Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce VarName #1291

Merged
merged 6 commits into from
Mar 25, 2023
Merged

Introduce VarName #1291

merged 6 commits into from
Mar 25, 2023

Conversation

mgkurtz
Copy link
Contributor

@mgkurtz mgkurtz commented Mar 21, 2023

As discussed in #1282 (comment), this introduces

const VarName = Union{Symbol, AbstractString, Char}

Hopefully I found all places, where this should be used. In some places I use VarNameNonSymbol instead to prohibit infinite recursion.

In a separate PR, we can care for different ways to provide lists of variable names. For now, they are changed to AbstractVector{<:VarName}.

@mgkurtz mgkurtz marked this pull request as draft March 21, 2023 00:56
@mgkurtz
Copy link
Contributor Author

mgkurtz commented Mar 21, 2023

It seems, like where I now wrote foo(s::VarName) = Generic.foo(Symbol(s)), I need to provide foo(s::VarNameNonSymbol) = foo(Symbol(s)) as to allow other implementations to implement only foo(::Symbol). So, I actually removed to much. On the other hand, I am once more inclined to use some metaprogramming and write

@add_var_name_method foo Generic.foo (a, s::VarName=var(a), b)

to provide

foo(a, s::Symbol, b) = Generic.foo(a, s, b)
foo(a, s::VarName=var(a), b) = foo(a, Symbol(s), b)

With a similar interface for lists of variable names. That way, I could remove some more noise from the files. In the case of variable name lists, this approach could further help, if we later decide on adding more flexibility there.

@codecov
Copy link

codecov bot commented Mar 21, 2023

Codecov Report

Merging #1291 (4cd578a) into master (8aefeec) will increase coverage by 0.26%.
The diff coverage is 84.61%.

@@            Coverage Diff             @@
##           master    #1291      +/-   ##
==========================================
+ Coverage   85.51%   85.77%   +0.26%     
==========================================
  Files         102      102              
  Lines       27987    27855     -132     
==========================================
- Hits        23932    23893      -39     
+ Misses       4055     3962      -93     
Impacted Files Coverage Δ
src/FreeAssAlgebra.jl 98.93% <ø> (ø)
src/Rings.jl 51.78% <0.00%> (-2.94%) ⬇️
src/fundamental_interface.jl 100.00% <ø> (ø)
src/generic/MPoly.jl 95.08% <ø> (+0.16%) ⬆️
src/generic/NCPoly.jl 61.00% <ø> (-0.96%) ⬇️
src/generic/Poly.jl 98.75% <ø> (-0.03%) ⬇️
src/AbsSeries.jl 93.36% <60.00%> (+2.54%) ⬆️
src/RelSeries.jl 93.52% <60.00%> (+1.72%) ⬆️
src/NCRings.jl 89.13% <66.66%> (-1.78%) ⬇️
src/MPoly.jl 78.13% <90.00%> (+0.65%) ⬆️
... and 13 more

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@mgkurtz
Copy link
Contributor Author

mgkurtz commented Mar 21, 2023

The missing test coverage is unrelated to this issue. We could improve the coverage by factoring out parts of the code instead of having it copied all around. But, as said, this is unrelated.

@fingolfin
Copy link
Member

I like it. OscarCI is failing, though? Seems to be related to some Singular stuff?

Meta question: do we really want/need that Char in there? Is anyone really using 'x' instead of "x"? And even if they are, do we want to encourage that? It seems to just complicate things further.

Regarding AbstractString: if we want to support general strings, there should be test cases testing those. There is Test.GenericString for that purpose.

@thofma
Copy link
Member

thofma commented Mar 22, 2023

Yes, people are using Char. I remember various complaints. It should be kept.

@@ -1155,27 +1156,11 @@ function YoungTableau(part::Generic.Partition, fill::Vector{Int}=collect(1:part.
Generic.YoungTableau(part, fill)
end

function number_field(a::Generic.Poly{Rational{BigInt}}, s::AbstractString, t = "\$"; cached = true)
function number_field(a::Generic.Poly{Rational{BigInt}}, s::VarName, t = "\$"; cached = true)
Copy link
Member

Choose a reason for hiding this comment

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

Stupid question, but: what is t here? Is this another "symbol"?

The documentation says:

The string fields are currently ignored, but are reserved for future use.

But what's the point of that?! The arguments are completely unspecified, after all. Maybe they are matching something in Nemo or Hecke? But I don't see an argument t in the OSCAR docstrings for these functions either?

(This is of course not a blocker for this PR, I just noticed it while reviewing the PR)

Copy link
Member

Choose a reason for hiding this comment

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

This function will never be called in OSCAR/Nemo/Hecke :)

@mgkurtz
Copy link
Contributor Author

mgkurtz commented Mar 22, 2023

The test failure seems unrelated. Here is a new issue for that #1293.

@mgkurtz mgkurtz marked this pull request as ready for review March 22, 2023 10:59
@thofma thofma merged commit 63e8f9c into Nemocas:master Mar 25, 2023
julien-schanz pushed a commit to julien-schanz/AbstractAlgebra.jl that referenced this pull request Mar 28, 2023
@mgkurtz mgkurtz deleted the mgk/varname branch August 27, 2024 12:18
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.

3 participants