diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 256801c893b..2c6d4b85c85 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -5031,6 +5031,24 @@ def integer_floor(x): raise NotImplementedError("computation of floor of %s not implemented"%x) +def integer_trunc(i): + """ + Truncate to the integer closer to zero + + EXAMPLES:: + + sage: from sage.arith.misc import integer_trunc as trunc + sage: trunc(-3/2), trunc(-1), trunc(-1/2), trunc(0), trunc(1/2), trunc(1), trunc(3/2) + (-1, -1, 0, 0, 0, 1, 1) + sage: isinstance(trunc(3/2), Integer) + True + """ + if i >= 0: + return integer_floor(i) + else: + return integer_ceil(i) + + def two_squares(n): """ Write the integer `n` as a sum of two integer squares if possible; diff --git a/src/sage/combinat/crystals/littelmann_path.py b/src/sage/combinat/crystals/littelmann_path.py index 4efbef4a0c3..04cddcf7278 100644 --- a/src/sage/combinat/crystals/littelmann_path.py +++ b/src/sage/combinat/crystals/littelmann_path.py @@ -40,7 +40,7 @@ from sage.rings.integer import Integer from sage.rings.rational_field import QQ from sage.combinat.root_system.root_system import RootSystem -from sage.functions.other import floor +from sage.arith.misc import integer_floor as floor from sage.misc.latex import latex diff --git a/src/sage/combinat/crystals/tensor_product.py b/src/sage/combinat/crystals/tensor_product.py index 9df369573f8..4b8ee8480d8 100644 --- a/src/sage/combinat/crystals/tensor_product.py +++ b/src/sage/combinat/crystals/tensor_product.py @@ -52,27 +52,8 @@ from sage.misc.flatten import flatten from sage.structure.element import get_coercion_model from sage.rings.semirings.non_negative_integer_semiring import NN +from sage.arith.misc import integer_trunc as trunc -############################################################################## -# Until trunc gets implemented in sage.function.other - -from sage.functions.other import floor, ceil -def trunc(i): - """ - Truncates to the integer closer to zero - - EXAMPLES:: - - sage: from sage.combinat.crystals.tensor_product import trunc - sage: trunc(-3/2), trunc(-1), trunc(-1/2), trunc(0), trunc(1/2), trunc(1), trunc(3/2) - (-1, -1, 0, 0, 0, 1, 1) - sage: isinstance(trunc(3/2), Integer) - True - """ - if i>= 0: - return floor(i) - else: - return ceil(i) ############################################################################## # Support classes diff --git a/src/sage/combinat/crystals/tensor_product_element.pyx b/src/sage/combinat/crystals/tensor_product_element.pyx index ed3e688ee56..8a6f7043491 100644 --- a/src/sage/combinat/crystals/tensor_product_element.pyx +++ b/src/sage/combinat/crystals/tensor_product_element.pyx @@ -34,7 +34,6 @@ from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from sage.structure.parent cimport Parent from sage.misc.cachefunc import cached_method, cached_in_parent_method -from sage.functions.other import ceil from sage.combinat.tableau import Tableau from sage.rings.integer_ring import ZZ diff --git a/src/sage/combinat/diagram_algebras.py b/src/sage/combinat/diagram_algebras.py index 17a9f85bc5f..ea5303bf1bc 100644 --- a/src/sage/combinat/diagram_algebras.py +++ b/src/sage/combinat/diagram_algebras.py @@ -43,7 +43,8 @@ from sage.misc.misc_c import prod from sage.rings.integer_ring import ZZ from sage.rings.rational_field import QQ -from sage.functions.other import floor, ceil +from sage.arith.misc import integer_floor as floor +from sage.arith.misc import integer_ceil as ceil import itertools diff --git a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py index 14ae3029a87..583ca582d43 100644 --- a/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py +++ b/src/sage/dynamics/arithmetic_dynamics/endPN_automorphism_group.py @@ -39,7 +39,7 @@ from sage.sets.set import Set from sage.combinat.permutation import Arrangements from sage.parallel.use_fork import p_iter_fork -from sage.functions.other import floor + def automorphism_group_QQ_fixedpoints(rational_function, return_functions=False, iso_type=False): r""" @@ -2213,8 +2213,8 @@ def find_conjugations_arrangement(tuples): # and check linear independence in parallel if len(all_subsets) > num_cpus: for i in range(num_cpus): - start = floor(len(all_subsets)*i/num_cpus) - end = floor(len(all_subsets)*(i+1)/num_cpus) + start = (len(all_subsets) * i) // num_cpus + end = (len(all_subsets) * (i+1)) // num_cpus tuples = all_subsets[start:end] parallel_data.append(([tuples], {})) @@ -2242,8 +2242,8 @@ def find_conjugations_arrangement(tuples): all_arrangements += list(product(*subset_arrangements)) parallel_data = [] for i in range(num_cpus): - start = floor(len(all_arrangements)*i/num_cpus) - end = floor(len(all_arrangements)*(i+1)/num_cpus) + start = (len(all_arrangements) * i) // num_cpus + end = (len(all_arrangements) * (i+1)) // num_cpus tuples = all_arrangements[start:end] parallel_data.append(([tuples], {})) X = p_iter_fork(num_cpus) @@ -2350,8 +2350,8 @@ def find_conjugations_arrangement(tuples): # and check linear independence in parallel if len(all_subsets) > num_cpus: for i in range(num_cpus): - start = floor(len(all_subsets)*i/num_cpus) - end = floor(len(all_subsets)*(i+1)/num_cpus) + start = (len(all_subsets) * i) // num_cpus + end = (len(all_subsets) * (i+1)) // num_cpus tuples = all_subsets[start:end] parallel_data.append(([tuples], {})) @@ -2380,8 +2380,8 @@ def find_conjugations_arrangement(tuples): all_arrangements += list(product(*subset_arrangements)) parallel_data = [] for i in range(num_cpus): - start = floor(len(all_arrangements)*i/num_cpus) - end = floor(len(all_arrangements)*(i+1)/num_cpus) + start = (len(all_arrangements) * i) // num_cpus + end = (len(all_arrangements) * (i+1)) // num_cpus tuples = all_arrangements[start:end] parallel_data.append(([tuples], {})) X = p_iter_fork(num_cpus) diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index 33f06c06dda..1a1ff3f292d 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -9272,7 +9272,7 @@ def _ford_fulkerson(self, s, t, use_edge_labels=False, integer=False, value_only 0 """ from sage.graphs.digraph import DiGraph - from sage.functions.other import floor + from sage.arith.misc import integer_floor as floor # Whether we should consider the edges labeled if use_edge_labels: diff --git a/src/sage/graphs/hyperbolicity.pyx b/src/sage/graphs/hyperbolicity.pyx index 1f479774b7e..44e33930181 100644 --- a/src/sage/graphs/hyperbolicity.pyx +++ b/src/sage/graphs/hyperbolicity.pyx @@ -158,7 +158,6 @@ from sage.graphs.distances_all_pairs cimport c_distances_all_pairs from sage.arith.all import binomial from sage.rings.integer_ring import ZZ from sage.rings.real_mpfr import RR -from sage.functions.other import floor from sage.data_structures.bitset import Bitset from sage.graphs.base.static_sparse_graph cimport short_digraph from sage.graphs.base.static_sparse_graph cimport init_short_digraph diff --git a/src/sage/modular/pollack_stevens/dist.pyx b/src/sage/modular/pollack_stevens/dist.pyx index 65942454937..b9165153621 100644 --- a/src/sage/modular/pollack_stevens/dist.pyx +++ b/src/sage/modular/pollack_stevens/dist.pyx @@ -39,7 +39,6 @@ from sage.matrix.matrix cimport Matrix from sage.matrix.matrix_space import MatrixSpace from sage.matrix.constructor import matrix from sage.misc.prandom import random -from sage.functions.other import floor from sage.structure.element cimport RingElement, Element import operator from sage.rings.padics.padic_generic import pAdicGeneric diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx index 63b59b82525..80405d61158 100644 --- a/src/sage/quadratic_forms/ternary.pyx +++ b/src/sage/quadratic_forms/ternary.pyx @@ -19,7 +19,6 @@ from sage.arith.all import inverse_mod, xgcd, gcd from sage.quadratic_forms.extras import extend_to_primitive from sage.rings.finite_rings.integer_mod import mod from sage.misc.prandom import randint -from sage.functions.other import ceil, floor def red_mfact(a,b):