Ticket #12173: 12173_script-v2.sh

File 12173_script-v2.sh, 3.6 KB (added by jpflori, 9 years ago)

Update script to cleanup fmpz_poly.pyx

Line 
1#!/usr/bin/env bash
2
3# Execute in $SAGE_ROOT/devel/sage
4
5
6# Start from a clean repo
7hg revert --all -r qparent
8
9# Move files
10hg mv sage/libs/flint/zmod_poly_linkage.pxi sage/libs/flint/nmod_poly_linkage.pxi
11hg mv sage/libs/flint/zmod_poly.pxd sage/libs/flint/nmod_poly.pxd
12
13# Delete files integrated upstream
14hg rm -f sage/libs/flint/fmpq_poly.c sage/libs/flint/fmpq_poly.h
15hg rm -f sage/libs/flint/long_extras.pxd
16
17# Create new file
18touch sage/libs/flint/ulong_extras.pxd
19hg add sage/libs/flint/ulong_extras.pxd
20
21
22# Automatic renaming of functions
23for file in `find sage \( -name "*.pxi" -o -name "*.pxd" -o -name "*.pyx" -o -name "*.py" \)`; do
24
25echo $file
26
27sed -i $file -f /dev/stdin <<EOF
28
29# function names
30s|/FLINT|/flint|g
31s|FLINT/|flint/|g
32s|\(flint.\)long_extras|\1ulong_extras|g
33
34s|ZZX_to_fmpz_poly|fmpz_poly_set_ZZX|g
35s|fmpz_poly_to_ZZX|fmpz_poly_get_ZZX|g
36s|fmpz_to_mpz|fmpz_get_mpz|g
37s|ZZ_to_fmpz|fmpz_set_ZZ|g
38
39s|mpz_to_fmpz|fmpz_set_mpz|g
40
41s| z_isprime| n_is_prime|g
42s| z_gcd| n_gcd|g
43s| z_factor| n_factor|g
44s| factor_t | n_factor_t |g
45
46s|fmpz_poly_scalar_div_exact_ui|fmpz_poly_scalar_divexact_ui|g
47s|fmpz_poly_scalar_div_exact_si|fmpz_poly_scalar_divexact_si|g
48s|fmpz_poly_scalar_div_exact_fmpz|fmpz_poly_scalar_divexact_fmpz|g
49s|fmpz_poly_from_string|fmpz_poly_set_str|g
50s|fmpz_poly_to_string|fmpz_poly_get_str|g
51s|fmpz_poly_power_trunc_n|fmpz_poly_pow_trunc|g
52s|fmpz_poly_power|fmpz_poly_pow|g
53s|fmpz_poly_left_shift|fmpz_poly_shift_left|g
54s|fmpz_poly_right_shift|fmpz_poly_shift_right|g
55s|fmpz_poly_evaluate|fmpz_poly_evaluate_fmpz|g
56s|fmpz_poly_scalar_div_mpz|fmpz_poly_scalar_fdiv_mpz|g
57s|fmpz_poly_scalar_div_ui|fmpz_poly_scalar_fdiv_ui|g
58
59s|zmod_poly|nmod_poly|g
60s|__nmod_poly_normalise|_nmod_poly_normalise|g
61s|nmod_poly_init_precomp|nmod_poly_init_preinv|g
62s|nmod_poly_init2_precomp|nmod_poly_init2_preinv|g
63s|nmod_poly_scalar_mul(|nmod_poly_scalar_mul_nmod(|g
64s|nmod_poly_evaluate(|nmod_poly_evaluate_nmod(|g
65s|nmod_poly_compose_horner|nmod_poly_compose|g
66s|nmod_poly_mul_trunc_n|nmod_poly_mullow|g
67s|nmod_poly_mul_trunc_left_n|nmod_poly_mulhigh|g
68s|nmod_poly_isirreducible|nmod_poly_is_irreducible|g
69s|nmod_poly_factor_square_free|nmod_poly_factor_squarefree|g
70
71s|numer[.]p_inv|numer.mod.ninv|g
72s|denom[.]p_inv|denom.mod.ninv|g
73
74s|_fmpq_poly_from_list|fmpq_poly_set_array_mpq|g
75s|fmpq_poly_getslice|fmpq_poly_get_slice|g
76s|fmpq_poly_left_shift|fmpq_poly_shift_left|g
77s|fmpq_poly_right_shift|fmpq_poly_shift_right|g
78s|fmpq_poly_power|fmpq_poly_pow|g
79s|fmpq_poly_floordiv|fmpq_poly_div|g
80s|fmpq_poly_mod|fmpq_poly_rem|g
81
82# Remove trailing whitespace on changed lines
83T;
84s/ *$//
85
86EOF
87
88done
89
90
91# Reformat some doctests
92for file in sage/schemes/elliptic_curves/ell_padic_field.py sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py sage/libs/flint/fmpz_poly.pyx; do
93
94sed -i $file -f /dev/stdin <<EOF
95
96/EXAMPLES: *$/ {
97    s/EXAMPLES:[: ]*/EXAMPLES::/
98    h  # Store this in hold space
99    s/EXAMPLES.*//
100    x  # Hold space now contains only leading spaces
101    b doctestblock
102}
103
104/TESTS: *$/ {
105    s/TESTS:[: ]*/TESTS::/
106    h  # Store this in hold space
107    s/TESTS.*//
108    x  # Hold space now contains only leading spaces
109    b doctestblock
110}
111
112# Skip this
113b
114
115:doctestblock
116# Next line should be empty
117n
118/[^ ]/ {
119i\
120\
121
122}
123
124:doctestloop
125    /^ *$/ { s/.*//; n; b doctestloop }
126    /[a-z0-9]/ {
127        # Delete all trailing whitespace
128        s/ *$//
129        # Delete leading whitespace in multiples of four
130        s/^\(    \)*//
131        # Append whitespace (as new line)
132        G
133        # Move whitespace to the right place
134        s/^\(.*\)\n\( *\)$/\2    \1/
135
136        # Loop
137        n
138        b doctestloop
139    }
140
141
142EOF
143
144done