Allow ops on arrays with elems of different types#588
Allow ops on arrays with elems of different types#588jturner314 merged 2 commits intorust-ndarray:masterfrom
Conversation
The implementations of operations for `&'a ArrayBase<S, D>` are still unnecessarily restrictive in the `Output` element type, but the implementations are now more general than they were before this commit.
|
It looks good to me, but it would be nice to have a way to check if it introduces type inference ambiguities that might cause a project using |
Yeah, that would be nice. It might be possible to do this using crates on crates.io that depend on the latest version of
I have a (non-public) project with ~1.3e4 lines of code that uses This is one (simplified) example: extern crate ndarray;
use ndarray::prelude::*;
fn main() {
let n = 5;
let a = Array2::<f64>::zeros((n, n));
let b = a + Array2::eye(n);
println!("{}", b);
}(The compiler can no longer infer the element type for Here's another similar example: extern crate ndarray;
use ndarray::prelude::*;
fn main() {
let n = 5;
let a = Array1::<f64>::zeros(n);
let b = Array2::zeros((n, n)) + a;
println!("{}", b);
}(The compiler can no longer infer the element type for I've added the "breaking-change" label. I don't see any way around this since Rust doesn't let us specify a default type for If everything looks good, let's go ahead and merge this. (We've already started merged some breaking changes for the 0.13 release.) |
|
I had somehow lost track of this conversation. |
eba4321 to
9b51170
Compare
This generalizes the right operand element type. The implementations of operations for
&'a ArrayBase<S, D>are still unnecessarily restrictive in theOutputelement type, but the implementations are now more general than they were before this commit.As far as I can tell, this change is backwards compatible except for possibly causing ambiguities in type inference that weren't present before.