Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions .github/workflows/ci-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,40 @@ jobs:
fail-fast: false
matrix:
# On pushes to tags or branches, test the whole matrix.
os: >-
${{ github.event_name == 'pull_request'
&& fromJson('["ubuntu-latest"]')
|| fromJson('["ubuntu-latest", "macos-latest", "macos-13"]') }}
python: >-
${{ github.event_name == 'pull_request'
&& fromJson('["3.9"]')
|| fromJson('["3.9", "3.10", "3.11"]') }}
os:
- ubuntu-latest
- macos-latest
- macos-13
python:
- 3.9
- 3.10
- 3.11
# Optional environment is disabled for now as its not yet working
# environment: [environment, environment-optional]
# conda-env: [environment, environment-optional]
conda-env: [environment]
use-numpy-2: [true, false]

# On pull requests, only test two jobs:
# Ubuntu with Python 3.9, macOS (arm64) with Python 3.11.
# Build & Test currently uses Python 3.10 (on ubuntu-jammy).
# Together, they cover the supported minor Python versions.
include: >-
${{ github.event_name == 'pull_request'
&& fromJson('[{"os": "macos-latest", "python": "3.11", "conda-env": "environment"}]')
|| fromJson('[]') }}
is-pull-request:
- ${{ github.event_name == 'pull_request' }}
exclude:
- is-pull-request: true # trick from https://github.com/orgs/community/discussions/26253#discussioncomment-6745038
include:
- os: ubuntu-latest
python: 3.9
conda-env: environment
use-numpy-2: false
- os: ubuntu-latest
python: 3.11
conda-env: environment
use-numpy-2: true
- os: macos-latest
python: 3.11
conda-env: environment
use-numpy-2: false

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -72,6 +87,11 @@ jobs:
activate-environment: sage-dev
environment-file: ${{ matrix.conda-env }}-${{ matrix.python }}-${{ startsWith(matrix.os, 'macos') && (startsWith(runner.arch, 'ARM') && 'macos' || 'macos-x86_64') || 'linux' }}.yml

- name: Install Numpy 2
if: ${{ matrix.use-numpy-2 }}
shell: bash -l {0}
run: conda install numpy==2.0.0

- name: Print Conda environment
shell: bash -l {0}
run: |
Expand All @@ -93,12 +113,12 @@ jobs:
SAGE_NUM_THREADS: 5

- name: Verify dependencies
if: success() || failure()
if: '!cancelled()'
shell: bash -l {0}
run: pip check

- name: Test
if: success() || failure()
if: '!cancelled()'
shell: bash -l {0}
run: ./sage -t --all --baseline-stats-path=.github/workflows/ci-conda-known-test-failures.json -p0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ the standard deviation::

sage: import numpy as np
sage: if int(np.version.short_version[0]) > 1:
....: np.set_printoptions(legacy="1.25")
....: _ = np.set_printoptions(legacy="1.25")
sage: np.mean([1, 2, 3, 5])
2.75

Expand Down
2 changes: 1 addition & 1 deletion src/doc/en/thematic_tutorials/numerical_sage/numpy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import it.

sage: import numpy
sage: if int(numpy.version.short_version[0]) > 1:
....: numpy.set_printoptions(legacy="1.25") # to ensure numpy 2.0 compatibility
....: _ = numpy.set_printoptions(legacy="1.25") # to ensure numpy 2.0 compatibility

The basic object of computation in NumPy is an array. It is simple to
create an array.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/fully_packed_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _make_color_list(n, colors=None, color_map=None, randomize=False):

sage: import numpy as np
sage: if int(np.version.short_version[0]) > 1:
....: np.set_printoptions(legacy="1.25")
....: _ = np.set_printoptions(legacy="1.25")
sage: from sage.combinat.fully_packed_loop import _make_color_list
sage: _make_color_list(5)
sage: _make_color_list(5, ['blue', 'red'])
Expand Down
2 changes: 1 addition & 1 deletion src/sage/functions/special.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class SphericalHarmonic(BuiltinFunction):
sage: from scipy.special import sph_harm # NB: arguments x and y are swapped # needs scipy
sage: import numpy as np # needs scipy
sage: if int(np.version.short_version[0]) > 1: # needs scipy
....: np.set_printoptions(legacy="1.25") # needs scipy
....: _ = np.set_printoptions(legacy="1.25") # needs scipy
sage: sph_harm(1, 1, pi.n(), (pi/2).n()) # abs tol 1e-14 # needs scipy sage.symbolic
(0.3454941494713355-4.231083042742082e-17j)

Expand Down
5 changes: 5 additions & 0 deletions src/sage/libs/flint/flint_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#pragma push_macro("ulong")
#undef ulong

/* Reserved in C99, needed for FLINT without https://github.com/flintlib/flint/pull/2027 */
#pragma push_macro("I")
#define I Iv

#include <flint/flint.h>

/* If flint was already previously included via another header (e.g.
Expand Down Expand Up @@ -169,6 +173,7 @@
#undef mp_bitcnt_t

#pragma pop_macro("ulong")
#pragma pop_macro("I")

/* CPU_SIZE_1 and SIZE_RED_FAILURE_THRESH are defined as macros in flint/fmpz_lll.h
* and as variables in fplll/defs.h, which breaks build if linbox is compiled with fplll */
Expand Down
12 changes: 6 additions & 6 deletions src/sage/numerical/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
import scipy.optimize
import numpy
if int(numpy.version.short_version[0]) > 1:
numpy.set_printoptions(legacy="1.25")
_ = numpy.set_printoptions(legacy="1.25")

Check warning on line 158 in src/sage/numerical/optimize.py

View check run for this annotation

Codecov / codecov/patch

src/sage/numerical/optimize.py#L158

Added line #L158 was not covered by tests

g = lambda x: float(f(x))
brentqRes = scipy.optimize.brentq(g, a, b,
Expand Down Expand Up @@ -290,7 +290,7 @@
import scipy.optimize
import numpy
if int(numpy.version.short_version[0]) > 1:
numpy.set_printoptions(legacy="1.25")
_ = numpy.set_printoptions(legacy="1.25")

Check warning on line 293 in src/sage/numerical/optimize.py

View check run for this annotation

Codecov / codecov/patch

src/sage/numerical/optimize.py#L293

Added line #L293 was not covered by tests

xmin, fval, iter, funcalls = scipy.optimize.fminbound(f, a, b, full_output=1, xtol=tol, maxfun=maxfun)
return fval, xmin
Expand Down Expand Up @@ -381,7 +381,7 @@
....: return sum(100.0r*(x[1r:]-x[:-1r]**2.0r)**2.0r + (1r-x[:-1r])**2.0r)
sage: import numpy
sage: if int(numpy.version.short_version[0]) > 1:
....: numpy.set_printoptions(legacy="1.25")
....: _ = numpy.set_printoptions(legacy="1.25")
sage: from numpy import zeros
sage: def rosen_der(x):
....: xm = x[1r:-1r]
Expand All @@ -400,7 +400,7 @@
from sage.ext.fast_callable import fast_callable
import numpy
if int(numpy.version.short_version[0]) > 1:
numpy.set_printoptions(legacy="1.25")
_ = numpy.set_printoptions(legacy="1.25")

Check warning on line 403 in src/sage/numerical/optimize.py

View check run for this annotation

Codecov / codecov/patch

src/sage/numerical/optimize.py#L403

Added line #L403 was not covered by tests

from scipy import optimize
if isinstance(func, Expression):
Expand Down Expand Up @@ -539,7 +539,7 @@
from sage.ext.fast_callable import fast_callable
import numpy
if int(numpy.version.short_version[0]) > 1:
numpy.set_printoptions(legacy="1.25")
_ = numpy.set_printoptions(legacy="1.25")

Check warning on line 542 in src/sage/numerical/optimize.py

View check run for this annotation

Codecov / codecov/patch

src/sage/numerical/optimize.py#L542

Added line #L542 was not covered by tests
from scipy import optimize
function_type = type(lambda x,y: x+y)

Expand Down Expand Up @@ -662,7 +662,7 @@
"""
import numpy
if int(numpy.version.short_version[0]) > 1:
numpy.set_printoptions(legacy="1.25")
_ = numpy.set_printoptions(legacy="1.25")

Check warning on line 665 in src/sage/numerical/optimize.py

View check run for this annotation

Codecov / codecov/patch

src/sage/numerical/optimize.py#L665

Added line #L665 was not covered by tests

if not isinstance(data, numpy.ndarray):
try:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/plot/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_minmax_data(self):

sage: import numpy # to ensure numpy 2.0 compatibility
sage: if int(numpy.version.short_version[0]) > 1:
....: numpy.set_printoptions(legacy="1.25")
....: _ = numpy.set_printoptions(legacy="1.25")
sage: from sage.plot.arrow import CurveArrow
sage: b = CurveArrow(path=[[(0,0),(.5,.5),(1,0)],[(.5,1),(0,0)]],
....: options={})
Expand Down
4 changes: 2 additions & 2 deletions src/sage/plot/multigraphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ def _add_subplot(self, figure, index, **options):
(0.2, 0.3, 0.4, 0.1)
sage: import numpy # to ensure numpy 2.0 compatibility
sage: if int(numpy.version.short_version[0]) > 1:
....: numpy.set_printoptions(legacy="1.25")
....: _ = numpy.set_printoptions(legacy="1.25")
sage: ax1.get_position().bounds # tol 1.0e-13
(0.2, 0.3, 0.4000000000000001, 0.10000000000000003)
"""
Expand Down Expand Up @@ -1269,7 +1269,7 @@ def position(self, index):
sage: G = graphics_array([g1, g2])
sage: import numpy # to ensure numpy 2.0 compatibility
sage: if int(numpy.version.short_version[0]) > 1:
....: numpy.set_printoptions(legacy="1.25")
....: _ = numpy.set_printoptions(legacy="1.25")
sage: G.position(0) # tol 5.0e-3
(0.025045451349937315,
0.03415488992713045,
Expand Down
2 changes: 1 addition & 1 deletion src/sage/plot/streamline_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_minmax_data(self):
sage: x, y = var('x y')
sage: import numpy # to ensure numpy 2.0 compatibility
sage: if int(numpy.version.short_version[0]) > 1:
....: numpy.set_printoptions(legacy="1.25")
....: _ = numpy.set_printoptions(legacy="1.25")
sage: d = streamline_plot((.01*x, x+y), (x,10,20), (y,10,20))[0].get_minmax_data()
sage: d['xmin']
10.0
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/integer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
sage: # needs numpy
sage: import numpy
sage: if int(numpy.version.short_version[0]) > 1:
....: numpy.set_printoptions(legacy="1.25")
....: _ = numpy.set_printoptions(legacy="1.25")
sage: numpy.int8('12') == 12
True
sage: 12 == numpy.int8('12')
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/real_mpfi.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ TESTS::

sage: import numpy # needs numpy
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
....: numpy.set_printoptions(legacy="1.25") # needs numpy
....: _ = numpy.set_printoptions(legacy="1.25") # needs numpy
sage: RIF(2) == numpy.int8('2') # needs numpy
True
sage: numpy.int8('2') == RIF(2) # needs numpy
Expand Down
10 changes: 5 additions & 5 deletions src/sage/schemes/elliptic_curves/period_lattice_region.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ cdef class PeriodicRegion:

sage: import numpy as np
sage: if int(np.version.short_version[0]) > 1:
....: np.set_printoptions(legacy="1.25")
....: _ = np.set_printoptions(legacy="1.25")
sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion
sage: data = np.zeros((4, 4))
sage: PeriodicRegion(CDF(2), CDF(2*I), data).is_empty()
Expand Down Expand Up @@ -296,7 +296,7 @@ cdef class PeriodicRegion:

sage: import numpy as np
sage: if int(np.version.short_version[0]) > 1:
....: np.set_printoptions(legacy="1.25")
....: _ = np.set_printoptions(legacy="1.25")
sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion
sage: data = np.zeros((10, 10))
sage: data[1:4,1:4] = True
Expand All @@ -320,7 +320,7 @@ cdef class PeriodicRegion:

sage: import numpy as np
sage: if int(np.version.short_version[0]) > 1:
....: np.set_printoptions(legacy="1.25")
....: _ = np.set_printoptions(legacy="1.25")
sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion
sage: data = np.zeros((4, 4))
sage: data[1,1] = True
Expand Down Expand Up @@ -375,7 +375,7 @@ cdef class PeriodicRegion:

sage: import numpy as np
sage: if int(np.version.short_version[0]) > 1:
....: np.set_printoptions(legacy="1.25")
....: _ = np.set_printoptions(legacy="1.25")
sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion

sage: data = np.zeros((20, 20))
Expand Down Expand Up @@ -528,7 +528,7 @@ cdef class PeriodicRegion:

sage: import numpy as np
sage: if int(np.version.short_version[0]) > 1:
....: np.set_printoptions(legacy="1.25")
....: _ = np.set_printoptions(legacy="1.25")
sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion
sage: data = np.zeros((4, 4))
sage: data[1, 1] = True
Expand Down
4 changes: 2 additions & 2 deletions src/sage/stats/basic_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def std(v, bias=False):
sage: # needs numpy
sage: import numpy
sage: if int(numpy.version.short_version[0]) > 1:
....: numpy.set_printoptions(legacy="1.25")
....: _ = numpy.set_printoptions(legacy="1.25")
sage: x = numpy.array([1,2,3,4,5])
sage: std(x, bias=False)
1.5811388300841898
Expand Down Expand Up @@ -299,7 +299,7 @@ def variance(v, bias=False):
0.4897530450000000?
sage: import numpy # needs numpy
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
....: numpy.set_printoptions(legacy="1.25") # needs numpy
....: _ = numpy.set_printoptions(legacy="1.25") # needs numpy
sage: x = numpy.array([1,2,3,4,5]) # needs numpy
sage: variance(x, bias=False) # needs numpy
2.5
Expand Down
2 changes: 1 addition & 1 deletion src/sage/structure/coerce.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ cdef class CoercionModel:

sage: import numpy # needs numpy
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
....: numpy.set_printoptions(legacy="1.25") # needs numpy
....: __ = numpy.set_printoptions(legacy="1.25") # needs numpy

sage: # needs sage.rings.real_mpfr
sage: x = polygen(RR)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/symbolic/function.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ cdef class BuiltinFunction(Function):

sage: import numpy # needs numpy
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
....: numpy.set_printoptions(legacy="1.25") # needs numpy
....: __ = numpy.set_printoptions(legacy="1.25") # needs numpy

sage: sin(numpy.int32(0)) # needs numpy
0.0
Expand Down
2 changes: 1 addition & 1 deletion src/sage/symbolic/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ cdef class NumpyToSRMorphism(Morphism):

sage: import numpy # needs numpy
sage: if int(numpy.version.short_version[0]) > 1: # needs numpy
....: numpy.set_printoptions(legacy="1.25") # needs numpy
....: _ = numpy.set_printoptions(legacy="1.25") # needs numpy
sage: f(x) = x^2
sage: f(numpy.int8('2')) # needs numpy
4
Expand Down
Loading