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

Towards #12251 part 2, replace all full(X) calls with convert(Array, X) and migrate tests #17079

Merged
merged 6 commits into from
Jul 21, 2016

Conversation

Sacha0
Copy link
Member

@Sacha0 Sacha0 commented Jun 23, 2016

Second step towards JuliaLang/LinearAlgebra.jl#231 (for a description of the overall objective and plan, see #17066 (comment)). This pull request replaces all full(X) calls with convert(Array, X) and accordingly migrates tests and documentation. Thanks and best!

@@ -811,7 +811,7 @@ reference.
+----------------------------------------+----------------------------------+--------------------------------------------+
| :func:`speye(n) <speye>` | :func:`eye(n) <eye>` | Creates a *n*-by-*n* identity matrix. |
+----------------------------------------+----------------------------------+--------------------------------------------+
| :func:`full(S) <full>` | :func:`sparse(A) <sparse>` | Interconverts between dense |
| :func:`convert(Array, S) <convert>` | :func:`sparse(A) <sparse>` | Interconverts between dense |
Copy link
Contributor

Choose a reason for hiding this comment

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

table alignment needs fixing

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Thanks!

@Sacha0 Sacha0 force-pushed the repfull branch 2 times, most recently from b928fa2 to a937904 Compare June 27, 2016 21:34
@andreasnoack andreasnoack added the linear algebra Linear algebra label Jul 10, 2016
@andreasnoack
Copy link
Member

@Sacha0 Thanks for all the work on this. With #17066 merged, I guess it's time for a rebase here.

@tkelman
Copy link
Contributor

tkelman commented Jul 16, 2016

@nanosoldier runbenchmarks(ALL, vs = ":master")

@test full(ss116[i,[end-3:-2:1;]]) == aa116[i,[end-3:-2:1;]]
@test full(ss116[[end-3:-2:1;],j]) == aa116[[end-3:-2:1;],j]
@test convert(Array, ss116[i,[3:2:end-3;]]) == aa116[i,[3:2:end-3;]]
@test convert(Array, ss116[[3:2:end-3;],j]) == aa116[[3:2:end-3;],j]
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a bad sign when your diffs get long enough that github gives up on coloring words any more. I should probably have looked at this commit-by-commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Apologies. How should I improve this? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

no action needed, what you did with splitting to multiple commits was good, I just should have reviewed in the same way. or we can complain to github to highlight more of long diffs

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

@Sacha0
Copy link
Member Author

Sacha0 commented Jul 21, 2016

Travis i686 timeout unrelated?

@tkelman tkelman merged commit b82d923 into JuliaLang:master Jul 21, 2016
@Sacha0 Sacha0 deleted the repfull branch July 21, 2016 13:59
@Sacha0
Copy link
Member Author

Sacha0 commented Jul 21, 2016

Thanks for the review and merge!

@tkelman
Copy link
Contributor

tkelman commented Jul 22, 2016

This looks like it had some unintended consequences, ref JuliaStats/DataArrays.jl#208 - not sure what that was doing before, I guess specializing full to return something other than Array ?

@tkelman
Copy link
Contributor

tkelman commented Jul 22, 2016

Since this isn't really critical and wasn't supposed to have visible consequences, I think we may want to revert it for now and revisit after branching 0.5?

@Sacha0
Copy link
Member Author

Sacha0 commented Jul 22, 2016

Since this isn't really critical and wasn't supposed to have visible consequences, I think we may want to revert it for now and revisit after branching 0.5?

Sounds good! Prior to merger I assumed this was 0.6-dev material. Taking a look now at the base/abstractarray.jl code @andreasnoack identified (independent of reversion) and will report back. Thanks!

@Sacha0
Copy link
Member Author

Sacha0 commented Jul 22, 2016

As @andreasnoack noted above, full in the generic concatenation methods' similar(full(X), T, dims) calls seems intended to handle annotation and special matrix types such as Diagonal and LowerTriangular and otherwise be a no-op. Specifically, when X is such an annotation or special matrix type, the full call returns a form of X that enables similar(full(X), T, dims) to return something concatenable yet, if possible, more similar to X than Array. On the other hand, the presence of full seems to make the generic concatenation methods inapplicable to sparse matrices/vectors and perhaps similar types.

One path forward would be to introduce backingtype and change the identified calls to similar(convert(backingtype(X), X), T, dims). But backingtype would need to exist for a broad swathe of types, practically requiring introduction of a no-op backingtype fallback. And that no-op backingtype fallback would essentially be a reintroduction of full's no-op fallback with a different name and slightly clearer definition, though still fraught with issues. (E.g., what should backingtype return for special matrix types? Need you abstract backingtype to something that provides the closest type that can have arbitrary shape and is fully writeable to make similar(convert(backingtype(X), X), T, dims) work as needed here? That sounds like a more principled replacement for full, but also sounds suspiciously like one conception of similar.) Moreover, in some sense this path would couple the logic of annotation and special matrix types with many unrelated things, whereas reducing that coupling was part of the appeal of deprecating full.

Another path forward would be removing full from the identified similar(full(X), T, dims) calls. This approach has the appeal of decoupling annotation and special matrix types' logic from the rest of the codebase. In the near term this approach would reduce the degree to which the generic concatenation methods preserve structure. But writing specialized similar methods could restore much of that ability, and specialized concatenation methods (as presently exist for e.g. sparse matrices/vectors due to the fulls in question) could take care of the rest. This approach would make clarifying the meaning of similar (and consequently convert etc) more urgent, but that might be a good thing.

Thoughts? Did the full calls serve any other purpose? Best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants