Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge in latest develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
saraedum committed Aug 23, 2018
2 parents 23a2b10 + aede54d commit a5707a1
Show file tree
Hide file tree
Showing 29 changed files with 179 additions and 206 deletions.
8 changes: 4 additions & 4 deletions build/pkgs/numpy/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=numpy-VERSION.zip
sha1=3d39f6768fa861c6b7000bb33182eb2599954d45
md5=300a6f0528122128ac07c6deb5c95917
cksum=4207303903
tarball=numpy-VERSION.tar.gz
sha1=e4917f6848f4065a70788b954332f1eb87b81989
md5=5cf4daff88042326334266f80ad38884
cksum=3849172272
2 changes: 1 addition & 1 deletion build/pkgs/numpy/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.13.3.p2
1.15.0
39 changes: 0 additions & 39 deletions build/pkgs/numpy/patches/PEP_3141.patch

This file was deleted.

2 changes: 1 addition & 1 deletion src/doc/en/faq/faq-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ ints. For example::
sage: RealNumber = float; Integer = int
sage: from scipy import stats
sage: stats.ttest_ind(list([1,2,3,4,5]),list([2,3,4,5,.6]))
Ttest_indResult(statistic=0.076752955645333687, pvalue=0.94070490247380478)
Ttest_indResult(statistic=0.0767529..., pvalue=0.940704...)
sage: stats.uniform(0,15).ppf([0.5,0.7])
array([ 7.5, 10.5])

Expand Down
12 changes: 7 additions & 5 deletions src/doc/en/thematic_tutorials/numerical_sage/cvxopt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ we could do the following.
sage: B = numpy.array([1.0]*5)
sage: B.shape=(5,1)
sage: print(B)
[[ 1.]
[ 1.]
[ 1.]
[ 1.]
[ 1.]]
[[1.]
[1.]
[1.]
[1.]
[1.]]


sage: print(A)
[ 2.00e+00 3.00e+00 0 0 0 ]
[ 3.00e+00 0 4.00e+00 0 6.00e+00]
Expand Down
67 changes: 34 additions & 33 deletions src/doc/en/thematic_tutorials/numerical_sage/numpy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ well as take slices
sage: l[3]
3.0
sage: l[3:6]
array([ 3., 4., 5.])
array([3., 4., 5.])

You can do basic arithmetic operations

Expand Down Expand Up @@ -147,11 +147,11 @@ also do matrix vector multiplication, and matrix addition
sage: n = numpy.matrix([[1,2],[3,4]],dtype=float)
sage: v = numpy.array([[1],[2]],dtype=float)
sage: n*v
matrix([[ 5.],
[ 11.]])
matrix([[ 5.],
[11.]])
sage: n+n
matrix([[ 2., 4.],
[ 6., 8.]])
matrix([[2., 4.],
[6., 8.]])

If ``n`` was created with :meth:`numpy.array`, then to do matrix vector
multiplication, you would use ``numpy.dot(n,v)``.
Expand All @@ -170,11 +170,11 @@ to manipulate
22., 23., 24.])
sage: n.shape=(5,5)
sage: n
array([[ 0., 1., 2., 3., 4.],
[ 5., 6., 7., 8., 9.],
[ 10., 11., 12., 13., 14.],
[ 15., 16., 17., 18., 19.],
[ 20., 21., 22., 23., 24.]])
array([[ 0., 1., 2., 3., 4.],
[ 5., 6., 7., 8., 9.],
[10., 11., 12., 13., 14.],
[15., 16., 17., 18., 19.],
[20., 21., 22., 23., 24.]])

This changes the one-dimensional array into a `5\times 5` array.

Expand All @@ -187,8 +187,8 @@ NumPy arrays can be sliced as well
sage: n=numpy.array(range(25),dtype=float)
sage: n.shape=(5,5)
sage: n[2:4,1:3]
array([[ 11., 12.],
[ 16., 17.]])
array([[11., 12.],
[16., 17.]])

It is important to note that the sliced matrices are references to
the original
Expand Down Expand Up @@ -224,8 +224,8 @@ Some particularly useful commands are

sage: x=numpy.arange(0,2,.1,dtype=float)
sage: x
array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ,
1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9])
array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. , 1.1, 1.2,
1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9])

You can see that :meth:`numpy.arange` creates an array of floats increasing by 0.1
from 0 to 2. There is a useful command :meth:`numpy.r_` that is best explained by example
Expand All @@ -240,10 +240,11 @@ from 0 to 2. There is a useful command :meth:`numpy.r_` that is best explained b
sage: Integer=int
sage: n=r_[0.0:5.0]
sage: n
array([ 0., 1., 2., 3., 4.])
array([0., 1., 2., 3., 4.])
sage: n=r_[0.0:5.0, [0.0]*5]
sage: n
array([ 0., 1., 2., 3., 4., 0., 0., 0., 0., 0.])
array([0., 1., 2., 3., 4., 0., 0., 0., 0., 0.])


:meth:`numpy.r_` provides a shorthand for constructing NumPy arrays efficiently.
Note in the above ``0.0:5.0`` was shorthand for ``0.0, 1.0, 2.0, 3.0, 4.0``.
Expand All @@ -255,7 +256,7 @@ intervals. We can do this as follows
::

sage: r_[0.0:5.0:11*j]
array([ 0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. ])
array([0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. ])

The notation ``0.0:5.0:11*j`` expands to a list of 11 equally space
points between 0 and 5 including both endpoints. Note that ``j`` is the
Expand Down Expand Up @@ -287,23 +288,23 @@ an equally spaced grid with `\Delta x = \Delta y = .25` for
sage: y=numpy.r_[0.0:1.0:5*j]
sage: xx,yy= meshgrid(x,y)
sage: xx
array([[ 0. , 0.25, 0.5 , 0.75, 1. ],
[ 0. , 0.25, 0.5 , 0.75, 1. ],
[ 0. , 0.25, 0.5 , 0.75, 1. ],
[ 0. , 0.25, 0.5 , 0.75, 1. ],
[ 0. , 0.25, 0.5 , 0.75, 1. ]])
array([[0. , 0.25, 0.5 , 0.75, 1. ],
[0. , 0.25, 0.5 , 0.75, 1. ],
[0. , 0.25, 0.5 , 0.75, 1. ],
[0. , 0.25, 0.5 , 0.75, 1. ],
[0. , 0.25, 0.5 , 0.75, 1. ]])
sage: yy
array([[ 0. , 0. , 0. , 0. , 0. ],
[ 0.25, 0.25, 0.25, 0.25, 0.25],
[ 0.5 , 0.5 , 0.5 , 0.5 , 0.5 ],
[ 0.75, 0.75, 0.75, 0.75, 0.75],
[ 1. , 1. , 1. , 1. , 1. ]])
array([[0. , 0. , 0. , 0. , 0. ],
[0.25, 0.25, 0.25, 0.25, 0.25],
[0.5 , 0.5 , 0.5 , 0.5 , 0.5 ],
[0.75, 0.75, 0.75, 0.75, 0.75],
[1. , 1. , 1. , 1. , 1. ]])
sage: f(xx,yy)
array([[ 0. , 0.0625, 0.25 , 0.5625, 1. ],
[ 0.0625, 0.125 , 0.3125, 0.625 , 1.0625],
[ 0.25 , 0.3125, 0.5 , 0.8125, 1.25 ],
[ 0.5625, 0.625 , 0.8125, 1.125 , 1.5625],
[ 1. , 1.0625, 1.25 , 1.5625, 2. ]])
array([[0. , 0.0625, 0.25 , 0.5625, 1. ],
[0.0625, 0.125 , 0.3125, 0.625 , 1.0625],
[0.25 , 0.3125, 0.5 , 0.8125, 1.25 ],
[0.5625, 0.625 , 0.8125, 1.125 , 1.5625],
[1. , 1.0625, 1.25 , 1.5625, 2. ]])

You can see that :meth:`numpy.meshgrid` produces a pair of matrices, here denoted
`xx` and `yy`, such that `(xx[i,j],yy[i,j])` has coordinates
Expand All @@ -324,7 +325,7 @@ equation `Ax=b` do
sage: b=numpy.array(range(1,6))
sage: x=linalg.solve(A,b)
sage: numpy.dot(A,x)
array([ 1., 2., 3., 4., 5.])
array([1., 2., 3., 4., 5.])

This creates a random 5x5 matrix ``A``, and solves `Ax=b` where
``b=[0.0,1.0,2.0,3.0,4.0]``. There are many other routines in the :mod:`numpy.linalg`
Expand Down
48 changes: 24 additions & 24 deletions src/sage/calculus/riemann.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1191,30 +1191,30 @@ cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values,
sage: zval = numpy.array([[0, 1, 1000],[.2+.3j,1,-.3j],[0,0,0]],dtype = numpy.complex128)
sage: deriv = numpy.array([[.1]],dtype = numpy.float64)
sage: complex_to_spiderweb(zval, deriv,deriv, 4,4,[0,0,0],1,False,0.001)
array([[[ 1., 1., 1.],
[ 1., 1., 1.],
[ 1., 1., 1.]],
array([[[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]],
<BLANKLINE>
[[ 1., 1., 1.],
[ 0., 0., 0.],
[ 1., 1., 1.]],
[[1., 1., 1.],
[0., 0., 0.],
[1., 1., 1.]],
<BLANKLINE>
[[ 1., 1., 1.],
[ 1., 1., 1.],
[ 1., 1., 1.]]])
[[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]]])
sage: complex_to_spiderweb(zval, deriv,deriv, 4,4,[0,0,0],1,True,0.001)
array([[[ 1. , 1. , 1. ],
[ 1. , 0.05558355, 0.05558355],
[ 0.17301243, 0. , 0. ]],
array([[[1. , 1. , 1. ],
[1. , 0.05558355, 0.05558355],
[0.17301243, 0. , 0. ]],
<BLANKLINE>
[[ 1. , 0.96804683, 0.48044583],
[ 0. , 0. , 0. ],
[ 0.77351965, 0.5470393 , 1. ]],
[[1. , 0.96804683, 0.48044583],
[0. , 0. , 0. ],
[0.77351965, 0.5470393 , 1. ]],
<BLANKLINE>
[[ 1. , 1. , 1. ],
[ 1. , 1. , 1. ],
[ 1. , 1. , 1. ]]])
[[1. , 1. , 1. ],
[1. , 1. , 1. ],
[1. , 1. , 1. ]]])
"""
cdef Py_ssize_t i, j, imax, jmax
cdef FLOAT_T x, y, mag, arg, width, target, precision, dmag, darg
Expand Down Expand Up @@ -1279,14 +1279,14 @@ cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim = 2] z_values):
sage: from sage.calculus.riemann import complex_to_rgb
sage: import numpy
sage: complex_to_rgb(numpy.array([[0, 1, 1000]], dtype = numpy.complex128))
array([[[ 1. , 1. , 1. ],
[ 1. , 0.05558355, 0.05558355],
[ 0.17301243, 0. , 0. ]]])
array([[[1. , 1. , 1. ],
[1. , 0.05558355, 0.05558355],
[0.17301243, 0. , 0. ]]])
sage: complex_to_rgb(numpy.array([[0, 1j, 1000j]], dtype = numpy.complex128))
array([[[ 1. , 1. , 1. ],
[ 0.52779177, 1. , 0.05558355],
[ 0.08650622, 0.17301243, 0. ]]])
array([[[1. , 1. , 1. ],
[0.52779177, 1. , 0.05558355],
[0.08650622, 0.17301243, 0. ]]])
TESTS::
Expand Down
10 changes: 5 additions & 5 deletions src/sage/combinat/fully_packed_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ def _make_color_list(n, colors=None, color_map=None, randomize=False):
sage: _make_color_list(5, ['blue', 'red'])
['blue', 'red', 'blue', 'red', 'blue']
sage: _make_color_list(5, color_map='summer')
[(0.0, 0.5, 0.40000000000000002),
(0.25098039215686274, 0.62549019607843137, 0.40000000000000002),
(0.50196078431372548, 0.75098039215686274, 0.40000000000000002),
(0.75294117647058822, 0.87647058823529411, 0.40000000000000002),
(1.0, 1.0, 0.40000000000000002)]
[(0.0, 0.5, 0.4),
(0.25098039215686274, 0.6254901960784314, 0.4),
(0.5019607843137255, 0.7509803921568627, 0.4),
(0.7529411764705882, 0.8764705882352941, 0.4),
(1.0, 1.0, 0.4)]
sage: _make_color_list(8, ['blue', 'red'], randomize=True)
['blue', 'blue', 'red', 'blue', 'red', 'red', 'red', 'blue']
"""
Expand Down
8 changes: 4 additions & 4 deletions src/sage/finance/time_series.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ cdef class TimeSeries:
sage: import numpy
sage: v = numpy.array([[1,2], [3,4]], dtype=float); v
array([[ 1., 2.],
[ 3., 4.]])
array([[1., 2.],
[3., 4.]])
sage: finance.TimeSeries(v)
[1.0000, 2.0000, 3.0000, 4.0000]
sage: finance.TimeSeries(v[:,0])
Expand Down Expand Up @@ -2100,14 +2100,14 @@ cdef class TimeSeries:
sage: w[0] = 20
sage: w
array([ 20. , -3. , 4.5, -2. ])
array([20. , -3. , 4.5, -2. ])
sage: v
[20.0000, -3.0000, 4.5000, -2.0000]
If you want a separate copy do not give the ``copy=False`` option. ::
sage: z = v.numpy(); z
array([ 20. , -3. , 4.5, -2. ])
array([20. , -3. , 4.5, -2. ])
sage: z[0] = -10
sage: v
[20.0000, -3.0000, 4.5000, -2.0000]
Expand Down
8 changes: 4 additions & 4 deletions src/sage/functions/hyperbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _eval_numpy_(self, x):
sage: import numpy
sage: a = numpy.arange(2, 5)
sage: coth(a)
array([ 1.03731472, 1.00496982, 1.00067115])
array([1.03731472, 1.00496982, 1.00067115])
"""
return 1.0 / tanh(x)

Expand Down Expand Up @@ -267,7 +267,7 @@ def _eval_numpy_(self, x):
sage: import numpy
sage: a = numpy.arange(2, 5)
sage: sech(a)
array([ 0.26580223, 0.09932793, 0.03661899])
array([0.26580223, 0.09932793, 0.03661899])
"""
return 1.0 / cosh(x)

Expand Down Expand Up @@ -318,7 +318,7 @@ def _eval_numpy_(self, x):
sage: import numpy
sage: a = numpy.arange(2, 5)
sage: csch(a)
array([ 0.27572056, 0.09982157, 0.03664357])
array([0.27572056, 0.09982157, 0.03664357])
"""
return 1.0 / sinh(x)

Expand Down Expand Up @@ -586,7 +586,7 @@ def _eval_numpy_(self, x):
sage: import numpy
sage: a = numpy.arange(2,5)
sage: acoth(a)
array([ 0.54930614, 0.34657359, 0.25541281])
array([0.54930614, 0.34657359, 0.25541281])
"""
return arctanh(1.0 / x)

Expand Down
16 changes: 8 additions & 8 deletions src/sage/functions/orthogonal_polys.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,12 +810,12 @@ def _eval_numpy_(self, n, x):
sage: z2 = numpy.array([[1,2],[1,2]])
sage: z3 = numpy.array([1,2,3.])
sage: chebyshev_T(1,z)
array([ 1., 2.])
array([1., 2.])
sage: chebyshev_T(1,z2)
array([[ 1., 2.],
[ 1., 2.]])
array([[1., 2.],
[1., 2.]])
sage: chebyshev_T(1,z3)
array([ 1., 2., 3.])
array([1., 2., 3.])
sage: chebyshev_T(z,0.1)
array([ 0.1 , -0.98])
"""
Expand Down Expand Up @@ -1095,12 +1095,12 @@ def _eval_numpy_(self, n, x):
sage: z2 = numpy.array([[1,2],[1,2]])
sage: z3 = numpy.array([1,2,3.])
sage: chebyshev_U(1,z)
array([ 2., 4.])
array([2., 4.])
sage: chebyshev_U(1,z2)
array([[ 2., 4.],
[ 2., 4.]])
array([[2., 4.],
[2., 4.]])
sage: chebyshev_U(1,z3)
array([ 2., 4., 6.])
array([2., 4., 6.])
sage: chebyshev_U(z,0.1)
array([ 0.2 , -0.96])
"""
Expand Down

0 comments on commit a5707a1

Please sign in to comment.