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

Streamline Vandermonde #49

Merged
merged 7 commits into from
Aug 31, 2021
Merged

Streamline Vandermonde #49

merged 7 commits into from
Aug 31, 2021

Conversation

JeffFessler
Copy link
Member

This PR supports construction with AbstractVector arguments: Vandermonde(1:3) instead of having to use collect.

It also provides more detailed docstring including jldoctests.

It eliminates some (I believe) unnecessary code. For now I have retained the code but enclosed it in block comments in case I have overlooked some reason to retain it.

@codecov
Copy link

codecov bot commented Aug 30, 2021

Codecov Report

Merging #49 (bbe1056) into master (3691275) will decrease coverage by 2.62%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #49      +/-   ##
==========================================
- Coverage   76.85%   74.22%   -2.63%     
==========================================
  Files           8        8              
  Lines         216      194      -22     
==========================================
- Hits          166      144      -22     
  Misses         50       50              
Impacted Files Coverage Δ
src/vandermonde.jl 100.00% <100.00%> (+1.28%) ⬆️
src/strang.jl 69.23% <0.00%> (-7.70%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3691275...bbe1056. Read the comment docs.

@JeffFessler
Copy link
Member Author

@christopher-dG since you were one of the last editors of vandermonde.jl would you mind reviewing this PR?
it passes all the tests but having another pair of eyes is always wise.
Also I am wondering if it should bump the version to 2.0.1?

Copy link
Contributor

@christopher-dG christopher-dG left a comment

Choose a reason for hiding this comment

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

I'm definitely not in a position to review anything domain-specific here, I don't even remember having worked on this package haha.

src/vandermonde.jl Outdated Show resolved Hide resolved
@JeffFessler
Copy link
Member Author

@devmotion you made recent significant contributions here - would you be able to take a look?

Copy link
Contributor

@devmotion devmotion left a comment

Choose a reason for hiding this comment

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

I didn't see any major problems. I added some comments and suggestions. In general, I'd suggest removing the commented code and at most keep comments for the remaining implementations. IMO the code is cleaner this way and the previous implementation can always be recovered from the git history.

src/vandermonde.jl Outdated Show resolved Hide resolved
src/vandermonde.jl Outdated Show resolved Hide resolved
src/vandermonde.jl Outdated Show resolved Hide resolved
src/vandermonde.jl Outdated Show resolved Hide resolved
Comment on lines +3 to +6
using SpecialMatrices: Vandermonde
import SpecialMatrices # dvand!, pvand!
using Test: @test, @testset, @test_throws, @inferred

Copy link
Contributor

Choose a reason for hiding this comment

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

These are not needed since runtests.jl loads SpecialMatrices and Test, and everything is exported.

Suggested change
using SpecialMatrices: Vandermonde
import SpecialMatrices # dvand!, pvand!
using Test: @test, @testset, @test_throws, @inferred

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I know but I like to be able to just include("vandermonde.jl") when developing and have it be a self-contained test. And I feel that Julia code is more readable when you see the dependencies given explicitly at the top of each file. I agree it is not needed, but no real drawback, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, it's not completely uncommon. It's mainly surprising that all imported macros etc. are listed explicitly instead of

Suggested change
using SpecialMatrices: Vandermonde
import SpecialMatrices # dvand!, pvand!
using Test: @test, @testset, @test_throws, @inferred
using SpecialMatrices
using Test

as in runtests.jl. I assumed the intention was to not pollute the namespace which does not work since runtests.jl loads SpecialMatrices and Test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I know - I'll work my way up to runtests.jl eventually.
After literally decades of using Matlab with no namespace control, perhaps I am overly excited about the opportunity to be very explicit 😃

c :: C

function Vandermonde(c::AbstractVector{T}) where T
axes(c,1) isa Base.OneTo || throw(ArgumentError("must be OneTo"))
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to remove this restriction at some point.

Copy link
Member Author

@JeffFessler JeffFessler Aug 30, 2021

Choose a reason for hiding this comment

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

Thanks for all these helpful suggestions. I've accepted (almost) all of them.
But I am unsure what one would do with an OffsetVector input here.

I got into the habit of checking axes after working with @dlfivefifty on some other packages. So just now I checked to see what ToeplitzMatrices does with AbstractVector inputs:

https://github.com/JuliaMatrices/ToeplitzMatrices.jl/blob/edbc8eb37c93df6c752e5313da307445a2e2022c/src/ToeplitzMatrices.jl#L208

At first it looked to me like it had no axes checking, but then I realized that the check is buried inside the convert call there. So if the vector is not something like OneTo then it throws a DimensionMismatch.

I think I will adopt the convert approach of ToeplitzMatrices and if y'all later figure out what would be a meaningful way to handle offsets then perhaps we can do that here too - if there is any use case!

JeffFessler and others added 4 commits August 30, 2021 18:37
@JeffFessler JeffFessler merged commit bb13de9 into master Aug 31, 2021
@JeffFessler JeffFessler deleted the vand branch August 31, 2021 00:27
@coveralls
Copy link

coveralls commented Aug 31, 2021

Pull Request Test Coverage Report for Build 1184082679

  • 20 of 20 (100.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-2.6%) to 74.227%

Files with Coverage Reduction New Missed Lines %
src/strang.jl 1 69.23%
Totals Coverage Status
Change from base Build 1182862414: -2.6%
Covered Lines: 144
Relevant Lines: 194

💛 - Coveralls

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.

4 participants