-
Notifications
You must be signed in to change notification settings - Fork 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
Add conversions from nalgebra types #554
base: master
Are you sure you want to change the base?
Conversation
7c6ecdf
to
9640dcd
Compare
This makes nalgebra a public dependency, optional or not. Then we'll have to be careful. Nice feature for ndarray users but we need to think about release management. |
It turns out that Rust 1.31 will fix this for us, because 1.31 stabilizes the With this approach, if |
edae6d0
to
2961c5f
Compare
Not bad, that's very interesting. Great to have that stable in cargo 🙂 |
Is it viable for nalgebra to implement conversions to our types? Does the dependency cycle work out if one includes both crates? |
From impls should in general not fail or panic, so we need a rationale |
2961c5f
to
ceaa1ef
Compare
Do you mean conversions from our types? Not all conversions are possible without copying the data because
I assume so, but I need to check this.
The implementations panic only in very unusual cases (overflowing isize or aliasing mutable elements). @sebcrozet said that it's a bug that So, panics should be rare. That said, maybe we should use |
This works only on Rust 1.31 and later because it requires the `rename-dependency` feature.
faba4eb
to
94608e3
Compare
I know this is a pretty old open PR, but I just published a crate that has conversions from nalgebra to ndarray types in it: https://crates.io/crates/nshare (currently the only conversions it supports). I just wanted to note that this functionality can be added using a third party library so this doesn't have to be constantly updated to match the current nalgebra version. |
Yeah IMO I think it should be fine to close it and do a docs PR to mention nshare. That seems like the path of least resistance and if we want to add direct support for this in ndarray can revisit this later. |
This is a good idea only if @vadixidav updates his
but nalgebra is now at version 0.23.1 |
I have not been using the crate recently, but feel free to create an issue on the repo, and I can bump the version. I would also like to add that nshare needs some work because it only supports some conversions. Between image, ndarray, and nalgebea there are several modes of conversion that aren't currently supported. I am definitely open to taking PRs on any of that as well. |
@nilgoyette I've seen vadixidav be pretty responsive when users have asked for a bump. Also I think I might have write access to nshare as well so if needs be I can step in as well as other members of the rust-cv org 🙂 |
Not only can other people step in, but perhaps we need to move it to be maintained by someone else that is actually making use of it. Right now we aren't using it that actively. It probably will have to be updated before a future release of the cv crate. Just as a note, that crate was created mostly in response to a lack of interoperability between the many n-dimensional crates. If the desire is to upstream this kind of behavior, I am totally on board with that too. I just want to make sure the tools are out there. nshare is not even complete anyways, and still needs several different conversions added. It mostly only has things added as they are needed for Rust CV, but I could easily just make those PRs upstream in nalgebea or ndarray. I think the question is which one should they be in, or if they should be separate then who maintains that? Anyways, please let me know if you want ownership over nshare. It lives in the Rust CV org, but it isn't computer vision specific, so anyone that wants to maintain it can do that. |
I did just go ahead and bump the versions in |
Can I ask what is the status of this? I'm trying to figure out how to take an |
So far the situation is the same. We are still maintaining |
Thanks for doing it too, interoperability is quite important, but figuring out how to handle the cargo deps for it is tricky IMO. |
This isn't ready to merge yet because building the docs for
nalgebra
results in an internal compiler error (dimforge/nalgebra#482). I'd like to wait until this is fixed because I don't want to breakndarray
's docs. [Edit: This is now fixed.]The primary motivation for this is to enable
ndarray-linalg
to usenalgebra
as a backend for linear algebra operations when BLAS/LAPACK aren't available (rust-ndarray/ndarray-linalg#121).Other notes:
n_rows.saturating_sub(1) * n_cols.saturating_sub(1) == 0
, buttypenum
doesn't appear to have a type-levelsaturating_sub
operation. Maybe @sebcrozet has an idea how to express the constraint?ndarray
->nalgebra
). Those should be placed in thenalgebra
crate.array-convert
crate for inter-crate conversions instead of using features for conditional compilation. However, that would prevent the conversions from using theFrom
trait.nalgebra
requiresrepr(transparent)
, which isn't available in Rust 1.27.