File tree Expand file tree Collapse file tree 8 files changed +41
-30
lines changed Expand file tree Collapse file tree 8 files changed +41
-30
lines changed Original file line number Diff line number Diff line change
1
+ from cpython.version cimport PY_MAJOR_VERSION
2
+ from flint.utils.conversion cimport chars_from_str, str_from_chars
3
+
1
4
cdef _str_trunc(s, trunc = 0 ):
2
5
if trunc > 0 and len (s) > 3 * trunc:
3
6
left = right = trunc
Original file line number Diff line number Diff line change @@ -9,5 +9,3 @@ cdef class FlintContext:
9
9
cdef arf_rnd_t rnd
10
10
cdef public bint unicode
11
11
cdef public long _cap
12
-
13
- pass
Original file line number Diff line number Diff line change
1
+ from cpython.version cimport PY_MAJOR_VERSION
2
+ from flint.utils.conversion cimport chars_from_str
3
+
1
4
cdef inline int fmpz_set_pylong(fmpz_t x, obj):
2
5
cdef int overflow
3
6
cdef slong longval
Original file line number Diff line number Diff line change
1
+ from cpython.version cimport PY_MAJOR_VERSION
2
+ from flint.utils.conversion cimport str_from_chars
3
+
1
4
cdef any_as_fmpz_mpoly(x):
2
5
cdef fmpz_mpoly res
3
6
"""
Original file line number Diff line number Diff line change
1
+ from cpython.version cimport PY_MAJOR_VERSION
2
+
1
3
cdef any_as_fmpz_poly(x):
2
4
cdef fmpz_poly res
3
5
if typecheck(x, fmpz_poly):
Original file line number Diff line number Diff line change
1
+ from flint.utils.conversion cimport matrix_to_str
2
+
1
3
cdef any_as_nmod_mat(obj, nmod_t mod):
2
4
cdef nmod_mat r
3
5
cdef mp_limb_t v
Original file line number Diff line number Diff line change @@ -24,33 +24,6 @@ cdef extern from "Python.h":
24
24
double PyComplex_RealAsDouble(PyObject * op)
25
25
double PyComplex_ImagAsDouble(PyObject * op)
26
26
27
- from cpython.version cimport PY_MAJOR_VERSION
28
-
29
- cdef chars_from_str(s):
30
- if PY_MAJOR_VERSION < 3 :
31
- return s
32
- else :
33
- return s.encode(' ascii' )
34
-
35
- cdef str_from_chars(s):
36
- if PY_MAJOR_VERSION < 3 :
37
- return str (s)
38
- else :
39
- return bytes(s).decode(' ascii' )
40
-
41
- cdef matrix_to_str(tab):
42
- if len (tab) == 0 or len (tab[0 ]) == 0 :
43
- return " []"
44
- tab = [[str (c) for c in row] for row in tab]
45
- widths = []
46
- for i in xrange (len (tab[0 ])):
47
- w = max ([len (row[i]) for row in tab])
48
- widths.append(w)
49
- for i in xrange (len (tab)):
50
- tab[i] = [s.rjust(widths[j]) for j, s in enumerate (tab[i])]
51
- tab[i] = " [" + (" , " .join(tab[i])) + " ]"
52
- return " \n " .join(tab)
53
-
54
27
cdef inline bint typecheck(object ob, object tp):
55
28
return PyObject_TypeCheck(ob, < PyTypeObject* > tp)
56
29
Original file line number Diff line number Diff line change
1
+ from cpython.version cimport PY_MAJOR_VERSION
2
+
1
3
cdef inline long prec_to_dps(n):
2
4
return max (1 , int (round (int (n)/ 3.3219280948873626 )- 1 ))
3
5
4
6
cdef inline long dps_to_prec(n):
5
- return max (1 , int (round ((int (n)+ 1 )* 3.3219280948873626 )))
7
+ return max (1 , int (round ((int (n)+ 1 )* 3.3219280948873626 )))
8
+
9
+ cdef inline chars_from_str(s):
10
+ if PY_MAJOR_VERSION < 3 :
11
+ return s
12
+ else :
13
+ return s.encode(' ascii' )
14
+
15
+ cdef inline str_from_chars(s):
16
+ if PY_MAJOR_VERSION < 3 :
17
+ return str (s)
18
+ else :
19
+ return bytes(s).decode(' ascii' )
20
+
21
+ cdef inline matrix_to_str(tab):
22
+ if len (tab) == 0 or len (tab[0 ]) == 0 :
23
+ return " []"
24
+ tab = [[str (c) for c in row] for row in tab]
25
+ widths = []
26
+ for i in xrange (len (tab[0 ])):
27
+ w = max ([len (row[i]) for row in tab])
28
+ widths.append(w)
29
+ for i in xrange (len (tab)):
30
+ tab[i] = [s.rjust(widths[j]) for j, s in enumerate (tab[i])]
31
+ tab[i] = " [" + (" , " .join(tab[i])) + " ]"
32
+ return " \n " .join(tab)
You can’t perform that action at this time.
0 commit comments