-
Couldn't load subscription status.
- Fork 25
**BREAKING** improve structs & constructors #306
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
base: main
Are you sure you want to change the base?
Conversation
This would be good. We should be it in an |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #306 +/- ##
==========================================
- Coverage 96.21% 0.25% -95.96%
==========================================
Files 12 13 +1
Lines 396 387 -9
==========================================
- Hits 381 1 -380
- Misses 15 386 +371 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the type restriction but I still think it should go into a breaking release since it is not only theoretically breaking. Copied from #236 (comment)_:
This is not correct. Code written for the
FiniteGPtype does not supportUniformScalingscalars / vectors as the observation noise covariance. If such types are passed, outer constructors are used to convert them into appropriateAbstractMatrixobjects. The lack of a type constraint is an omission, and therefore a bug. For example, if you take a look through this code, you'll see that there are a lot of things that are done that are only safe to do withAbstractMatrixs. For example this.
I just checked and UniformScaling is supported and can be used at least with some methods (mean_and_var errors since diagind is not defined):
julia> using AbstractGPs, LinearAlgebra
julia> fx = GP(GaussianKernel())(rand(10), 2.0*I)
AbstractGPs.FiniteGP{GP{AbstractGPs.ZeroMean{Float64}, SqExponentialKernel{Distances.Euclidean}}, Vector{Float64}, UniformScaling{Float64}}(
f: GP{AbstractGPs.ZeroMean{Float64}, SqExponentialKernel{Distances.Euclidean}}(AbstractGPs.ZeroMean{Float64}(), Squared Exponential Kernel (metric = Distances.Euclidean(0.0)))
x: [0.9001122128843618, 0.5014532689115688, 0.9068485710635356, 0.8671710704251859, 0.1593165289491113, 0.033849226130907684, 0.6012613832007633, 0.6792056597108606, 0.6291170664768985, 0.4586633196418336]
Σy: UniformScaling{Float64}(2.0)
)
julia> mean(fx)
10-element Vector{Float64}:
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
julia> mean_and_cov(fx)
([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [3.0 0.9236108289936744 … 0.9639467883634513 0.9071580732113963; 0.9236108289936744 3.0 … 0.9918840906723075 0.9990849290537535; … ; 0.9639467883634513 0.9918840906723075 … 3.0 0.9855777713218073; 0.9071580732113963 0.9990849290537535 … 0.9855777713218073 3.0])
julia> rand(fx)
10-element Vector{Float64}:
3.7182207380247623
1.0497036329028469
0.9905553822300871
-0.44238892519088857
-1.0465937939874175
-0.8895511203455914
1.0418168460349009
-0.20439667340116374
1.2400217065941217
0.12529989634261757
Could we not make that non-breaking by also having a constructor that converts the UniformScaling into an appropriately-sized ScalMat? |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
@devmotion I'm still not entirely convinced by the The docstring for although it should probably be tightened up, and docstrings added for the other outer constructors. In short, our official documentation, to some degree the docstring for |
Looks like we can, @devmotion I added the example you gave as another test case and it's passing |
|
A constructor won't prevent breakage of downstream dispatches on |
|
@willtebbutt I can definitely see your point. IMO it's an edge case and one could argue one way or the other. I don't think the use of In general, I think the discussion just shows that it would be safer to make a breaking release. Not all matrix-like structures are of type |
|
Okay. Let's try and tie this down in the next release though (more precise testing and documentation). |
|
See JuliaGaussianProcesses/ApproximateGPs.jl#126 for the required AD fix |
Happy for others to contribute to this branch.
Things that came to my mind:
e.g.
FiniteGPshould check whetherlength(x) == size(Sigma, 1) == size(Sigma, 2).