Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Oct 29, 2021
2 parents d5e62da + 6c79ebe commit 0a893cd
Show file tree
Hide file tree
Showing 16 changed files with 2,096 additions and 1,927 deletions.
18 changes: 18 additions & 0 deletions src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/crystals/littelmann_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
21 changes: 1 addition & 20 deletions src/sage/combinat/crystals/tensor_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/crystals/tensor_product_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/sage/combinat/diagram_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -2214,8 +2214,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], {}))

Expand Down Expand Up @@ -2243,8 +2243,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)
Expand Down Expand Up @@ -2351,8 +2351,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], {}))

Expand Down Expand Up @@ -2381,8 +2381,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)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/abc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Polyhedron:
By design, there is a unique direct subclass::
sage: sage.geometry.abc.Polyhedron.__subclasses__() # optional - sage.geometry.polyhedron
[<class 'sage.geometry.polyhedron.base.Polyhedron_base'>]
[<class 'sage.geometry.polyhedron.base0.Polyhedron_base0'>]
sage: len(sage.geometry.abc.Polyhedron.__subclasses__()) <= 1
True
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/polyhedron/backend_normaliz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ def _volume_normaliz(self, measure='euclidean'):
from sage.rings.infinity import infinity
return infinity

from sage.functions.other import factorial
from sage.arith.misc import factorial
return self._volume_normaliz('induced_lattice') / factorial(self.dim())

else:
Expand Down
Loading

0 comments on commit 0a893cd

Please sign in to comment.