Re: [Numpy-discussion] Characteristic of a Matrix.
On 06/01/2015 8:38 PM, Alexander Belopolsky wrote: On Tue, Jan 6, 2015 at 8:20 PM, Nathaniel Smith n...@pobox.com mailto:n...@pobox.com wrote: Since matrices are now part of some high school curricula, I urge that they be treated appropriately in Numpy. Further, I suggest that consideration be given to establishing V and VT sub-classes, to cover vectors and transposed vectors. The numpy devs don't really have the interest or the skills to create a great library for pedagogical use in high schools. If you're interested in an interface like this, then I'd suggest creating a new package focused specifically on that (which might use numpy internally). There's really no advantage in glomming this into numpy proper. Sorry for taking this further off-topic, but I recently discovered an excellent SAGE package, http://www.sagemath.org/. While it's targeted audience includes math graduate students and research mathematicians, parts of it are accessible to schoolchildren. SAGE is written in Python and integrates a number of packages including numpy. My remark about high school was intended to emphasise that matrix algebra is an essential part of linear algebra. Numpy has not fully developed this part. I feel that Guido may not have fully understood the availability of the Matrix class when he approved the reliance on dot(). I would highly recommend to anyone interested in using Python for education to take a look at SAGE. Thanks Alexander, I'll do that. It looks excellent, but it seems that the University of Washington has funding problems and does not appear to have the crew of volunteers that Python has. Regards, Colin W. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On 08/01/2015 1:19 PM, Ryan Nelson wrote: Colin, I'll second the endorsement of Sage; however, for teaching purposes, I would suggest Sage Math Cloud. It is a free, web-based version of Sage, and it does not require you or the students to install any software (besides a new-ish web browser). It also make sharing/collaborative work quite easy as well. I've used this a bit for demos, and it's great. The author William Stein is good at correcting bugs/issues very quickly. Sage implements it's own Matrix and Vector classes, and the Vector class has a column method that returns a column vector (transpose). http://www.sagemath.org/doc/tutorial/tour_linalg.html For what it's worth, I agree with others about the benefits of avoiding a Matrix class in Numpy. In my experience, it certainly makes things cleaner in larger projects when I always use NDArray and just call the appropriate linear algebra functions (e.g. np.dot, etc) when that is context I need. Anyway, just my two cents. Ryan Ryan, Thanks. I agree that Sage Math Cloud seems the better way to go for students. However your preference for the dot() world may be because the Numpy Matrix Class is inadequately developed. I'm not suggesting that development, at this time, but proposing that the errors I referenced be considered as bugs. Colin W. On Wed, Jan 7, 2015 at 2:44 PM, cjw c...@ncf.ca mailto:c...@ncf.ca wrote: Thanks Alexander, I'll look at Sage. Colin W. On 06-Jan-15 8:38 PM, Alexander Belopolsky wrote: On Tue, Jan 6, 2015 at 8:20 PM, Nathaniel Smithn...@pobox.com mailto:n...@pobox.com wrote: Since matrices are now part of some high school curricula, I urge that they be treated appropriately in Numpy. Further, I suggest that consideration be given to establishing V and VT sub-classes, to cover vectors and transposed vectors. The numpy devs don't really have the interest or the skills to create a great library for pedagogical use in high schools. If you're interested in an interface like this, then I'd suggest creating a new package focused specifically on that (which might use numpy internally). There's really no advantage in glomming this into numpy proper. Sorry for taking this further off-topic, but I recently discovered an excellent SAGE package,http://www.sagemath.org/ http://www.sagemath.org/. While it's targeted audience includes math graduate students and research mathematicians, parts of it are accessible to schoolchildren. SAGE is written in Python and integrates a number of packages including numpy. I would highly recommend to anyone interested in using Python for education to take a look at SAGE. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org mailto:NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org mailto:NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
Colin, I'll second the endorsement of Sage; however, for teaching purposes, I would suggest Sage Math Cloud. It is a free, web-based version of Sage, and it does not require you or the students to install any software (besides a new-ish web browser). It also make sharing/collaborative work quite easy as well. I've used this a bit for demos, and it's great. The author William Stein is good at correcting bugs/issues very quickly. Sage implements it's own Matrix and Vector classes, and the Vector class has a column method that returns a column vector (transpose). http://www.sagemath.org/doc/tutorial/tour_linalg.html For what it's worth, I agree with others about the benefits of avoiding a Matrix class in Numpy. In my experience, it certainly makes things cleaner in larger projects when I always use NDArray and just call the appropriate linear algebra functions (e.g. np.dot, etc) when that is context I need. Anyway, just my two cents. Ryan On Wed, Jan 7, 2015 at 2:44 PM, cjw c...@ncf.ca wrote: Thanks Alexander, I'll look at Sage. Colin W. On 06-Jan-15 8:38 PM, Alexander Belopolsky wrote: On Tue, Jan 6, 2015 at 8:20 PM, Nathaniel Smith n...@pobox.com n...@pobox.com wrote: Since matrices are now part of some high school curricula, I urge that they be treated appropriately in Numpy. Further, I suggest that consideration be given to establishing V and VT sub-classes, to cover vectors and transposed vectors. The numpy devs don't really have the interest or the skills to create a great library for pedagogical use in high schools. If you're interested in an interface like this, then I'd suggest creating a new package focused specifically on that (which might use numpy internally). There's really no advantage in glomming this into numpy proper. Sorry for taking this further off-topic, but I recently discovered an excellent SAGE package, http://www.sagemath.org/ http://www.sagemath.org/. While it's targeted audience includes math graduate students and research mathematicians, parts of it are accessible to schoolchildren. SAGE is written in Python and integrates a number of packages including numpy. I would highly recommend to anyone interested in using Python for education to take a look at SAGE. ___ NumPy-Discussion mailing listNumPy-Discussion@scipy.orghttp://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On Wed, Jan 7, 2015 at 7:35 PM, cjw c...@ncf.ca wrote: Nathaniel, Of the two characteristics to which I pointed, I feel that the rectangularity check is the more important. I gave an example of a typo which demonstrated this problem. The numpy matrix class does require rectangularity; the issue you ran into is more weird than that. It's legal to make a matrix of arbitrary python objects, e.g. np.matrix([[hello, None]]) (this can be useful e.g. if you want to work with extremely large integers using Python's long integer objects). In your case, b/c the lists were not the same length, the matrix constructor guessed that you wanted a matrix containing two Python list objects. This is pretty confusing, and fixing it is bug #5303. But it doesn't indicate any deeper problem with the matrix object. Notice: In [5]: A2 = np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) In [6]: A2.shape Out[6]: (1, 3) In [7]: A2[0, 0] Out[7]: [1, 2, -2] The error message reported that pinv does not have a conjugate function which, I suggest, is a totally misleading error message. When working with arrays/matrices of objects, functions like 'pinv' will try to call special methods on the objects. This is a little weird and arguably a bug itself, but it does mean that it's at least possible in theory to have an array of arbitrary python objects and have pinv() work. Of course this requires objects that will cooperate. In this case, though, pinv() has no idea what to do with a matrix whose elements are themselves lists, so it gives an error. -n -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
Nathaniel, Of the two characteristics to which I pointed, I feel that the rectangularity check is the more important. I gave an example of a typo which demonstrated this problem. The error message reported that pinv does not have a conjugate function which, I suggest, is a totally misleading error message. In these circumstances, I hope that the Development Team will wish to treat this as a bug. Regards, Colin W. On 06-Jan-15 8:20 PM, Nathaniel Smith wrote: Hi Colin, On Wed, Jan 7, 2015 at 12:58 AM, cjw c...@ncf.ca wrote: My recollection, from discussions, at the time of the introduction of the @ operator, was that there was no intention to disturb the existing Matrix class. Yeah, we're not going to be making any major changes to the numpy.matrix class -- e.g. we certainly aren't going to disallow non-numeric data types at this point. I see the matrix as a long recognized mathematical entity. On the other hand, the array is a very useful computational construct, used in a number of computer languages. Since matrices are now part of some high school curricula, I urge that they be treated appropriately in Numpy. Further, I suggest that consideration be given to establishing V and VT sub-classes, to cover vectors and transposed vectors. The numpy devs don't really have the interest or the skills to create a great library for pedagogical use in high schools. If you're interested in an interface like this, then I'd suggest creating a new package focused specifically on that (which might use numpy internally). There's really no advantage in glomming this into numpy proper. -n ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
Thanks Alexander, I'll look at Sage. Colin W. On 06-Jan-15 8:38 PM, Alexander Belopolsky wrote: On Tue, Jan 6, 2015 at 8:20 PM, Nathaniel Smith n...@pobox.com wrote: Since matrices are now part of some high school curricula, I urge that they be treated appropriately in Numpy. Further, I suggest that consideration be given to establishing V and VT sub-classes, to cover vectors and transposed vectors. The numpy devs don't really have the interest or the skills to create a great library for pedagogical use in high schools. If you're interested in an interface like this, then I'd suggest creating a new package focused specifically on that (which might use numpy internally). There's really no advantage in glomming this into numpy proper. Sorry for taking this further off-topic, but I recently discovered an excellent SAGE package, http://www.sagemath.org/. While it's targeted audience includes math graduate students and research mathematicians, parts of it are accessible to schoolchildren. SAGE is written in Python and integrates a number of packages including numpy. I would highly recommend to anyone interested in using Python for education to take a look at SAGE. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On 06/01/15 02:08, cjw wrote: This is not a comment on any present matrix support, but deals with the matrix class, which existed back when Todd Miller of the Space Telescope Group supported numpy. Matrix is a sub-class of ndarray. Since this Matrix class is (more or less) deprecated and its use discouraged, I think it should just be left as it is. Sturla ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On 06-Jan-15 7:31 AM, Sturla Molden wrote: On 06/01/15 02:08, cjw wrote: This is not a comment on any present matrix support, but deals with the matrix class, which existed back when Todd Miller of the Space Telescope Group supported numpy. Matrix is a sub-class of ndarray. Since this Matrix class is (more or less) deprecated and its use discouraged, I think it should just be left as it is. Sturla Sturla, My recollection, from discussions, at the time of the introduction of the @ operator, was that there was no intention to disturb the existing Matrix class. I see the matrix as a long recognized mathematical entity. On the other hand, the array is a very useful computational construct, used in a number of computer languages. Since matrices are now part of some high school curricula, I urge that they be treated appropriately in Numpy. Further, I suggest that consideration be given to establishing V and VT sub-classes, to cover vectors and transposed vectors. Regards, Colin W. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
Hi Colin, On Wed, Jan 7, 2015 at 12:58 AM, cjw c...@ncf.ca wrote: My recollection, from discussions, at the time of the introduction of the @ operator, was that there was no intention to disturb the existing Matrix class. Yeah, we're not going to be making any major changes to the numpy.matrix class -- e.g. we certainly aren't going to disallow non-numeric data types at this point. I see the matrix as a long recognized mathematical entity. On the other hand, the array is a very useful computational construct, used in a number of computer languages. Since matrices are now part of some high school curricula, I urge that they be treated appropriately in Numpy. Further, I suggest that consideration be given to establishing V and VT sub-classes, to cover vectors and transposed vectors. The numpy devs don't really have the interest or the skills to create a great library for pedagogical use in high schools. If you're interested in an interface like this, then I'd suggest creating a new package focused specifically on that (which might use numpy internally). There's really no advantage in glomming this into numpy proper. -n -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On Tue, Jan 6, 2015 at 8:20 PM, Nathaniel Smith n...@pobox.com wrote: Since matrices are now part of some high school curricula, I urge that they be treated appropriately in Numpy. Further, I suggest that consideration be given to establishing V and VT sub-classes, to cover vectors and transposed vectors. The numpy devs don't really have the interest or the skills to create a great library for pedagogical use in high schools. If you're interested in an interface like this, then I'd suggest creating a new package focused specifically on that (which might use numpy internally). There's really no advantage in glomming this into numpy proper. Sorry for taking this further off-topic, but I recently discovered an excellent SAGE package, http://www.sagemath.org/. While it's targeted audience includes math graduate students and research mathematicians, parts of it are accessible to schoolchildren. SAGE is written in Python and integrates a number of packages including numpy. I would highly recommend to anyone interested in using Python for education to take a look at SAGE. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On 05-Jan-15 1:56 PM, Davidid wrote: On 5 January 2015 at 20:40, Colin J. Williams cjwilliam...@gmail.com wrote: This illustrates a failure, which is reported later in the calculation: A2= np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) Here 2 - 6 is treated as an expression. There should be a comma between 2 and -6. The rectangularity is checked, and in this case, it is not fulfilled. As such, NumPy creates a square matrix of size 1x1 of dtype object. If you want to make sure what you have manually inputed is correct, you should include a couple of assertions afterwards. /David. David, Thanks. My suggestion was that numpy should do that checking, Colin W. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
Nathaniel, This is not a comment on any present matrix support, but deals with the matrix class, which existed back when Todd Miller of the Space Telescope Group supported numpy. Matrix is a sub-class of ndarray. I'm suggesting that anything which is produced by this class should be checked for the Characteristics of a Matrix. These characteristics include: a rectangular array; and all numeric values. Others might suggest other characteristics. I suggest that any matrix which is returned should check the characteristics and reject any incompatible cases. An example of a failure was given: A1= np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) A comma was missing Subsequent statements might have been shown: print('A1=', A1) print ('Identity: A1 * A1.I: ', A1 * A1.I) ## Grief here numpy # Reported in a misleading way: # Traceback (most recent call last): # File "string", line 254, in run_nodebug # File "C:\Users\cjw_2\Documents \stephanie.py", line 31, in module # print ('Identity: A1 * A1.I: ', A1 * A1.I) ## Grief here numpy # File "C:\Python27\lib\site-packages\numpy\matrixlib\defmatrix.py", line 870, in getI # return asmatrix(func(self)) # File "C:\Python27\lib\site-packages\numpy\linalg\linalg.py", line 1584, in pinv # a = a.conjugate() # AttributeError: 'list' object has no attribute 'conjugate' # A check up front would have been more helpful, especially for a user who is not familiar with Numpy. I hope that this is clearer. Colin W. On 05-Jan-15 1:58 PM, Nathaniel Smith wrote: I'm afraid that I really don't understand what you're trying to say. Is there something that you think numpy should be doing differently? On Mon, Jan 5, 2015 at 6:40 PM, Colin J. Williams cjwilliam...@gmail.com wrote: One of the essential characteristics of a matrix is that it be rectangular. This is neither spelt out or checked currently. The Doc description refers to a class: - *class *numpy.matrix[source] http://github.com/numpy/numpy/blob/v1.9.1/numpy/matrixlib/defmatrix.py#L206 Returns a matrix from an array-like object, or from a string of data. A matrix is aspecialized 2-D array that retains its 2-D nature through operations. It has certain special operators, such as * (matrix multiplication) and ** (matrix power). This illustrates a failure, which is reported later in the calculation: A2= np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) Here 2 - 6 is treated as an _expression_. Wikipedia offers: In mathematics http://en.wikipedia.org/wiki/Mathematics, a *matrix* (plural *matrices*) is a rectangular http://en.wikipedia.org/wiki/Rectangle *array http://en.wiktionary.org/wiki/array*[1] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-1 of numbers http://en.wikipedia.org/wiki/Number, symbols http://en.wikipedia.org/wiki/Symbol_%28formal%29, or expressions http://en.wikipedia.org/wiki/Expression_%28mathematics%29, arranged in *rows http://en.wiktionary.org/wiki/row* and *columns http://en.wiktionary.org/wiki/column*.[2] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-2[3] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-3 The individual items in a matrix are called its *elements* or *entries*. An example of a matrix with 2 rows and 3 columns is [image: \begin{bmatrix}1 9 -13 \\20 5 -6 \end{bmatrix}.]In the Numpy context, the symbols or expressions need to be evaluable. Colin W. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Characteristic of a Matrix.
One of the essential characteristics of a matrix is that it be rectangular. This is neither spelt out or checked currently. The Doc description refers to a class: - *class *numpy.matrix[source] http://github.com/numpy/numpy/blob/v1.9.1/numpy/matrixlib/defmatrix.py#L206 Returns a matrix from an array-like object, or from a string of data. A matrix is aspecialized 2-D array that retains its 2-D nature through operations. It has certain special operators, such as * (matrix multiplication) and ** (matrix power). This illustrates a failure, which is reported later in the calculation: A2= np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) Here 2 - 6 is treated as an expression. Wikipedia offers: In mathematics http://en.wikipedia.org/wiki/Mathematics, a *matrix* (plural *matrices*) is a rectangular http://en.wikipedia.org/wiki/Rectangle *array http://en.wiktionary.org/wiki/array*[1] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-1 of numbers http://en.wikipedia.org/wiki/Number, symbols http://en.wikipedia.org/wiki/Symbol_%28formal%29, or expressions http://en.wikipedia.org/wiki/Expression_%28mathematics%29, arranged in *rows http://en.wiktionary.org/wiki/row* and *columns http://en.wiktionary.org/wiki/column*.[2] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-2[3] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-3 The individual items in a matrix are called its *elements* or *entries*. An example of a matrix with 2 rows and 3 columns is [image: \begin{bmatrix}1 9 -13 \\20 5 -6 \end{bmatrix}.]In the Numpy context, the symbols or expressions need to be evaluable. Colin W. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On 5 January 2015 at 20:40, Colin J. Williams cjwilliam...@gmail.com wrote: This illustrates a failure, which is reported later in the calculation: A2= np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) Here 2 - 6 is treated as an expression. There should be a comma between 2 and -6. The rectangularity is checked, and in this case, it is not fulfilled. As such, NumPy creates a square matrix of size 1x1 of dtype object. If you want to make sure what you have manually inputed is correct, you should include a couple of assertions afterwards. /David. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
Hi, On Mon, Jan 5, 2015 at 8:40 PM, Colin J. Williams cjwilliam...@gmail.com wrote: One of the essential characteristics of a matrix is that it be rectangular. This is neither spelt out or checked currently. The Doc description refers to a class: - *class *numpy.matrix[source] http://github.com/numpy/numpy/blob/v1.9.1/numpy/matrixlib/defmatrix.py#L206 Returns a matrix from an array-like object, or from a string of data. A matrix is aspecialized 2-D array that retains its 2-D nature through operations. It has certain special operators, such as * (matrix multiplication) and ** (matrix power). This illustrates a failure, which is reported later in the calculation: A2= np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) Here 2 - 6 is treated as an expression. FWIW, here A2 is definitely rectangular, with shape== (1, 3) and dtype== object, i.e elements are just python lists. Wikipedia offers: In mathematics http://en.wikipedia.org/wiki/Mathematics, a *matrix* (plural *matrices*) is a rectangular http://en.wikipedia.org/wiki/Rectangle *array http://en.wiktionary.org/wiki/array*[1] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-1 of numbers http://en.wikipedia.org/wiki/Number, symbols http://en.wikipedia.org/wiki/Symbol_%28formal%29, or expressions http://en.wikipedia.org/wiki/Expression_%28mathematics%29, arranged in *rows http://en.wiktionary.org/wiki/row* and *columns http://en.wiktionary.org/wiki/column*.[2] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-2[3] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-3 (and in this context also python objects). -eat The individual items in a matrix are called its *elements* or *entries*. An example of a matrix with 2 rows and 3 columns is [image: \begin{bmatrix}1 9 -13 \\20 5 -6 \end{bmatrix}.]In the Numpy context, the symbols or expressions need to be evaluable. Colin W. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
I'm afraid that I really don't understand what you're trying to say. Is there something that you think numpy should be doing differently? On Mon, Jan 5, 2015 at 6:40 PM, Colin J. Williams cjwilliam...@gmail.com wrote: One of the essential characteristics of a matrix is that it be rectangular. This is neither spelt out or checked currently. The Doc description refers to a class: - *class *numpy.matrix[source] http://github.com/numpy/numpy/blob/v1.9.1/numpy/matrixlib/defmatrix.py#L206 Returns a matrix from an array-like object, or from a string of data. A matrix is aspecialized 2-D array that retains its 2-D nature through operations. It has certain special operators, such as * (matrix multiplication) and ** (matrix power). This illustrates a failure, which is reported later in the calculation: A2= np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) Here 2 - 6 is treated as an expression. Wikipedia offers: In mathematics http://en.wikipedia.org/wiki/Mathematics, a *matrix* (plural *matrices*) is a rectangular http://en.wikipedia.org/wiki/Rectangle *array http://en.wiktionary.org/wiki/array*[1] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-1 of numbers http://en.wikipedia.org/wiki/Number, symbols http://en.wikipedia.org/wiki/Symbol_%28formal%29, or expressions http://en.wikipedia.org/wiki/Expression_%28mathematics%29, arranged in *rows http://en.wiktionary.org/wiki/row* and *columns http://en.wiktionary.org/wiki/column*.[2] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-2[3] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-3 The individual items in a matrix are called its *elements* or *entries*. An example of a matrix with 2 rows and 3 columns is [image: \begin{bmatrix}1 9 -13 \\20 5 -6 \end{bmatrix}.]In the Numpy context, the symbols or expressions need to be evaluable. Colin W. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On Mon, Jan 5, 2015 at 1:58 PM, Nathaniel Smith n...@pobox.com wrote: I'm afraid that I really don't understand what you're trying to say. Is there something that you think numpy should be doing differently? This is a case similar to the issue discussed in https://github.com/numpy/numpy/issues/5303. Instead of getting an error (because the arguments don't create the expected 2-d matrix), a matrix with dtype object and shape (1, 3) is created. Warren On Mon, Jan 5, 2015 at 6:40 PM, Colin J. Williams cjwilliam...@gmail.com wrote: One of the essential characteristics of a matrix is that it be rectangular. This is neither spelt out or checked currently. The Doc description refers to a class: - *class *numpy.matrix[source] http://github.com/numpy/numpy/blob/v1.9.1/numpy/matrixlib/defmatrix.py#L206 Returns a matrix from an array-like object, or from a string of data. A matrix is aspecialized 2-D array that retains its 2-D nature through operations. It has certain special operators, such as * (matrix multiplication) and ** (matrix power). This illustrates a failure, which is reported later in the calculation: A2= np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) Here 2 - 6 is treated as an expression. Wikipedia offers: In mathematics http://en.wikipedia.org/wiki/Mathematics, a *matrix* (plural *matrices*) is a rectangular http://en.wikipedia.org/wiki/Rectangle *array http://en.wiktionary.org/wiki/array*[1] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-1 of numbers http://en.wikipedia.org/wiki/Number, symbols http://en.wikipedia.org/wiki/Symbol_%28formal%29, or expressions http://en.wikipedia.org/wiki/Expression_%28mathematics%29, arranged in *rows http://en.wiktionary.org/wiki/row* and *columns http://en.wiktionary.org/wiki/column*.[2] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-2[3] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-3 The individual items in a matrix are called its *elements* or *entries*. An example of a matrix with 2 rows and 3 columns is [image: \begin{bmatrix}1 9 -13 \\20 5 -6 \end{bmatrix}.]In the Numpy context, the symbols or expressions need to be evaluable. Colin W. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On Mon, Jan 5, 2015 at 1:58 PM, Nathaniel Smith n...@pobox.com wrote: I'm afraid that I really don't understand what you're trying to say. Is there something that you think numpy should be doing differently? I liked it better when this raised an exception, instead of creating a rectangular object array. Josef On Mon, Jan 5, 2015 at 6:40 PM, Colin J. Williams cjwilliam...@gmail.com wrote: One of the essential characteristics of a matrix is that it be rectangular. This is neither spelt out or checked currently. The Doc description refers to a class: - *class *numpy.matrix[source] http://github.com/numpy/numpy/blob/v1.9.1/numpy/matrixlib/defmatrix.py#L206 Returns a matrix from an array-like object, or from a string of data. A matrix is aspecialized 2-D array that retains its 2-D nature through operations. It has certain special operators, such as * (matrix multiplication) and ** (matrix power). This illustrates a failure, which is reported later in the calculation: A2= np.matrix([[1, 2, -2], [-3, -1, 4], [4, 2 -6]]) Here 2 - 6 is treated as an expression. Wikipedia offers: In mathematics http://en.wikipedia.org/wiki/Mathematics, a *matrix* (plural *matrices*) is a rectangular http://en.wikipedia.org/wiki/Rectangle *array http://en.wiktionary.org/wiki/array*[1] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-1 of numbers http://en.wikipedia.org/wiki/Number, symbols http://en.wikipedia.org/wiki/Symbol_%28formal%29, or expressions http://en.wikipedia.org/wiki/Expression_%28mathematics%29, arranged in *rows http://en.wiktionary.org/wiki/row* and *columns http://en.wiktionary.org/wiki/column*.[2] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-2[3] http://en.wikipedia.org/wiki/Matrix_%28mathematics%29#cite_note-3 The individual items in a matrix are called its *elements* or *entries*. An example of a matrix with 2 rows and 3 columns is [image: \begin{bmatrix}1 9 -13 \\20 5 -6 \end{bmatrix}.]In the Numpy context, the symbols or expressions need to be evaluable. Colin W. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On Mon, Jan 5, 2015 at 7:18 PM, josef.p...@gmail.com wrote: On Mon, Jan 5, 2015 at 1:58 PM, Nathaniel Smith n...@pobox.com wrote: I'm afraid that I really don't understand what you're trying to say. Is there something that you think numpy should be doing differently? I liked it better when this raised an exception, instead of creating a rectangular object array. Did it really used to raise an exception? Patches accepted :-) (#5303 is the relevant bug, like Warren points out. From the discussion there it doesn't look like np.array's handling of non-conformable lists has any defenders.) -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On Mon, Jan 5, 2015 at 2:36 PM, Nathaniel Smith n...@pobox.com wrote: On Mon, Jan 5, 2015 at 7:18 PM, josef.p...@gmail.com wrote: On Mon, Jan 5, 2015 at 1:58 PM, Nathaniel Smith n...@pobox.com wrote: I'm afraid that I really don't understand what you're trying to say. Is there something that you think numpy should be doing differently? I liked it better when this raised an exception, instead of creating a rectangular object array. Did it really used to raise an exception? Patches accepted :-) (#5303 is the relevant bug, like Warren points out. From the discussion there it doesn't look like np.array's handling of non-conformable lists has any defenders.) Since I'm usually late in updating numpy, I was for a long time very familiar with the frequent occurence of `ValueError: setting an array element with a sequence.` based on this, it was up to numpy 1.5 https://github.com/scipy/scipy/pull/2631#issuecomment-20898809 ugly but backwards compatible :) Josef -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Characteristic of a Matrix.
On Mon, Jan 5, 2015 at 9:36 PM, Nathaniel Smith n...@pobox.com wrote: On Mon, Jan 5, 2015 at 7:18 PM, josef.p...@gmail.com wrote: On Mon, Jan 5, 2015 at 1:58 PM, Nathaniel Smith n...@pobox.com wrote: I'm afraid that I really don't understand what you're trying to say. Is there something that you think numpy should be doing differently? I liked it better when this raised an exception, instead of creating a rectangular object array. Did it really used to raise an exception? Patches accepted :-) (#5303 is the relevant bug, like Warren points out. From the discussion there it doesn't look like np.array's handling of non-conformable lists has any defenders.) +1 for 'object array [and matrix] construction should require explicitly specifying dtype= object' -eat -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion