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

Inconsistent return type of domain? #456

Closed
singularitti opened this issue Jan 29, 2023 · 11 comments
Closed

Inconsistent return type of domain? #456

singularitti opened this issue Jan 29, 2023 · 11 comments

Comments

@singularitti
Copy link
Contributor

singularitti commented Jan 29, 2023

I am trying two examples and using domain on them. But one returns a Tuple, the other returns a Vector. Could it be unified?

julia> p = Polynomial([1, 2, 3, 4])
Polynomial(1 + 2*x + 3*x^2 + 4*x^3)

julia> domain(p)
(-Inf, Inf)

julia> p = ChebyshevT([1, 0, 3, 4])
ChebyshevT(1T_0(x) + 3T_2(x) + 4T_3(x))

julia> domain(p)
[-1, 1]
@jverzani
Copy link
Member

Yes, that seems like a bug. No reason not to return a tuple in each.

@jverzani
Copy link
Member

Oops, not a but. That is an artifact of show. The domain method returns an Interval.

@singularitti
Copy link
Contributor Author

OK, I get it. Could it be Interval(-Inf, Inf) and Interval[-1, 1]?

@singularitti
Copy link
Contributor Author

Another hint: Intervals.jl use a..b to represent intervals:

lcfWzyIz_000009

@jverzani
Copy link
Member

Yeah, I didn't want to take on that dependency, but it is useful syntax. I wish .. were in base and not a package.

@singularitti
Copy link
Contributor Author

singularitti commented Jan 30, 2023

Maybe we could take inspiration from both. How about this?

(-Inf..Inf)
[-1..1]

They are clearly neither vectors nor tuples.

@jverzani
Copy link
Member

That is a show method. Would be nice, though better would be Polynomials.Interval[-1,1], as it isnt' an exported thing. Want to put in a PR? Let me know, o/w I can add it.

@singularitti
Copy link
Contributor Author

singularitti commented Jan 30, 2023

I can make a PR. Which one do you like?

Polynomials.Interval[-1,1]

or [-1..1]?

@jverzani
Copy link
Member

I like the latter with ( or ) for infinite values.

@singularitti
Copy link
Contributor Author

It should work now: #460

julia> using Polynomials: domain

julia> p = Polynomial([1, 2, 3, 4])
Polynomial(1 + 2*x + 3*x^2 + 4*x^3)

julia> domain(p)
(-Inf..Inf)

julia> p = ChebyshevT([1, 0, 3, 4])
ChebyshevT(1T_0(x) + 3T_2(x) + 4T_3(x))

julia> domain(p)
[-1..1]

@singularitti
Copy link
Contributor Author

Closed by #460

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

No branches or pull requests

2 participants