Skip to content

Commit

Permalink
sagemathgh-39346: some fixes after cython-lint
Browse files Browse the repository at this point in the history
    
a few fixes in pyx files, according to suggestions of `cython-lint`

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
    
URL: sagemath#39346
Reported by: Frédéric Chapoton
Reviewer(s): Dima Pasechnik, Frédéric Chapoton, Kwankyu Lee
  • Loading branch information
Release Manager committed Jan 26, 2025
2 parents 0037c7c + 335728d commit fbe6d97
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ cpdef _fast_possible_periods(self, return_points=False):
- More space efficient hash/point-table.
"""
cdef int i, k, N
cdef int i, N
cdef int hash_p, hash_q
cdef int index, startindex
cdef list pointslist, points_periods
cdef list points_periods
cdef list P, Q
cdef set periods, lorders, rvalues

Expand All @@ -88,7 +88,7 @@ cpdef _fast_possible_periods(self, return_points=False):
p = PS.base_ring().order()
N = int(PS.dimension_relative())

point_table = [[0,0] for i in range(p**(N + 1))]
point_table = [[0, 0] for i in range(p**(N + 1))]
index = 1
periods = set()
points_periods = []
Expand Down
168 changes: 87 additions & 81 deletions src/sage/dynamics/complex_dynamics/mandel_julia_helper.pyx

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/sage/interacts/library_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ AUTHORS:
- Harald Schilly (2011-01-16): initial version (#9623) partially based on work by Lauri Ruotsalainen
"""
#*****************************************************************************
# ***************************************************************************
# Copyright (C) 2011 Harald Schilly <[email protected]>
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# https://www.gnu.org/licenses/
#*****************************************************************************
# ***************************************************************************


cpdef julia(ff_j, z, int iterations):
Expand Down Expand Up @@ -97,11 +97,11 @@ cpdef cellular(rule, int N):
"""
from numpy import zeros
cdef int j, k, l
M=zeros((N, 2*N+2), dtype=int)
M[0,N]=1
M = zeros((N, 2*N+2), dtype=int)
M[0, N] = 1

for j in range(1, N):
for k in range(0, 2*N):
l = 4 * M[j-1, k-1] + 2 * M[j-1, k] + M[j-1, k+1]
M[j,k] = rule[l]
M[j, k] = rule[l]
return M
6 changes: 3 additions & 3 deletions src/sage/matroids/matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7709,12 +7709,12 @@ cdef class Matroid(SageObject):
# check if edge (u,v) exists in the auxiliary digraph
exist = False
if ((u in Y) and (v in E-Y) and
(self.is_dependent(Y|{v})) and
(self.is_independent((Y|{v}) - {u}))):
self.is_dependent(Y|{v}) and
self.is_independent((Y|{v}) - {u})):
exist = True
if ((u in E-Y) and (v in Y) and
(not other.is_independent(Y|{u})) and
(other.is_independent((Y|{u}) - {v}))):
(other.is_independent((Y|{u}) - {v}))):
exist = True
if exist:
stack.append(v)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/quadratic_forms/ternary.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def _reduced_ternary_form_eisenstein_with_matrix(a1, a2, a3, a23, a13, a12):
[a13, a23] = [a23, a13]

return (a1, a2, a3, a23, a13, a12), \
matrix(ZZ, 3, (m11, m12, m13, m21, m22, m23, m31, m32, m33))
matrix(ZZ, 3, (m11, m12, m13, m21, m22, m23, m31, m32, m33))


def _reduced_ternary_form_eisenstein_without_matrix(a1, a2, a3, a23, a13, a12):
Expand Down
14 changes: 8 additions & 6 deletions src/sage/quivers/algebra_elements.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,10 @@ cdef class PathAlgebraElement(RingElement):
sage: X # indirect doctest
5*e_0 + a + 2*b + 3*c + 3*e_2
"""
parent = self._parent
return repr_lincomb(self._sorted_items_for_printing(), strip_one=True,
scalar_mult=self.parent()._print_options['scalar_mult'],
repr_monomial=self._parent._repr_monomial)
scalar_mult=parent._print_options['scalar_mult'],
repr_monomial=parent._repr_monomial)

def _latex_(self):
r"""
Expand All @@ -283,11 +284,12 @@ cdef class PathAlgebraElement(RingElement):
sage: latex(X*X)
10 e_0 + 3 a\cdot c + 5 a + b + 3 c\cdot a + 6 c\cdot b + 9 e_2
"""
parent = self._parent
return repr_lincomb(self._sorted_items_for_printing(),
scalar_mult=self.parent()._print_options['scalar_mult'],
latex_scalar_mult=self.parent()._print_options['latex_scalar_mult'],
repr_monomial=self._parent._latex_monomial,
is_latex=True, strip_one=True)
scalar_mult=parent._print_options['scalar_mult'],
latex_scalar_mult=parent._print_options['latex_scalar_mult'],
repr_monomial=parent._latex_monomial,
is_latex=True, strip_one=True)

# Basic properties

Expand Down
6 changes: 3 additions & 3 deletions src/sage/schemes/elliptic_curves/period_lattice_region.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ AUTHORS:
- John Cremona (2014): added some docstrings and doctests
"""

#*****************************************************************************
# ***************************************************************************
# Copyright (C) 2010 Robert Bradshaw <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
# https://www.gnu.org/licenses/
# ***************************************************************************

import numpy as np
cimport numpy as np
Expand Down
4 changes: 2 additions & 2 deletions src/sage/schemes/toric/divisor_class.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ divisor representing a divisor class::
"""


#*****************************************************************************
# ***************************************************************************
# Copyright (C) 2010 Volker Braun <[email protected]>
# Copyright (C) 2010 Andrey Novoseltsev <[email protected]>
# Copyright (C) 2010 William Stein <[email protected]>
#
# Distributed under the terms of the GNU General Public License (GPL)
#
# https://www.gnu.org/licenses/
#*****************************************************************************
# ***************************************************************************

from sage.libs.gmp.mpq cimport *

Expand Down
9 changes: 5 additions & 4 deletions src/sage/structure/list_clone_demo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ This module demonstrate the usage of the various classes defined in
:mod:`~sage.structure.list_clone`
"""

#*****************************************************************************
# ***************************************************************************
# Copyright (C) 2011 Florent Hivert <[email protected]>
#
# Distributed under the terms of the GNU General Public License (GPL)
# http://www.gnu.org/licenses/
#*****************************************************************************
# https://www.gnu.org/licenses/
# ***************************************************************************

from sage.categories.sets_cat import Sets
from sage.structure.unique_representation import UniqueRepresentation
from sage.structure.list_clone cimport (
ClonableArray, ClonableList, NormalizedClonableList, ClonableIntArray )
ClonableArray, ClonableList, NormalizedClonableList, ClonableIntArray)
from sage.structure.parent import Parent


cdef class IncreasingArray(ClonableArray):
"""
A small extension class for testing
Expand Down
12 changes: 7 additions & 5 deletions src/sage/symbolic/pynac_function_impl.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ cpdef call_registered_function(unsigned serial,
res = g_function_evalv(serial, vec, hold)
elif nargs == 1:
res = g_function_eval1(serial,
(<Expression>args[0])._gobj, hold)
(<Expression>args[0])._gobj, hold)
elif nargs == 2:
res = g_function_eval2(serial, (<Expression>args[0])._gobj,
(<Expression>args[1])._gobj, hold)
res = g_function_eval2(serial,
(<Expression>args[0])._gobj,
(<Expression>args[1])._gobj, hold)
elif nargs == 3:
res = g_function_eval3(serial,
(<Expression>args[0])._gobj, (<Expression>args[1])._gobj,
(<Expression>args[2])._gobj, hold)
(<Expression>args[0])._gobj,
(<Expression>args[1])._gobj,
(<Expression>args[2])._gobj, hold)

if allow_numeric_result and is_a_numeric(res):
return py_object_from_numeric(res)
Expand Down

0 comments on commit fbe6d97

Please sign in to comment.