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

Should datasets/spectra also work with non numpy array. #43

Open
ajasja opened this issue Apr 26, 2014 · 3 comments
Open

Should datasets/spectra also work with non numpy array. #43

ajasja opened this issue Apr 26, 2014 · 3 comments
Labels

Comments

@ajasja
Copy link
Member

ajasja commented Apr 26, 2014

Right now if a non- np.ndarray somehow gets into a Dataset an exception is raised when doing addition/subtraction.

this is because

a = [1,2,3]
a == a

returns True, but

anp = np.array(a)
anp == anp

returns array([ True, True, True], dtype=bool)

I temporarily solved this by writing a make_numpy_array function that returns a np.ndarray.
Perhaps we should solve this also in another way, by replacing the code any(x == y) with something that can handle both array and ndarray.

@ajasja
Copy link
Member Author

ajasja commented Apr 26, 2014

Ahh, there is
http://docs.scipy.org/doc/numpy/reference/generated/numpy.array_equal.html, which should work for both arrays and numpy arrays

@ajasja
Copy link
Member Author

ajasja commented Apr 26, 2014

In the test all(x == y) should be replaced with np.array_equal and we're good to go.

@ajasja
Copy link
Member Author

ajasja commented Apr 26, 2014

Hmm another difference between array and ndarray.

a = np.array([1, 2, 3])
b = 2*a
>>> [2, 4, 6]

a = [1, 2, 3]
>>>[1, 2, 3, 1, 2, 3]

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

No branches or pull requests

1 participant