[go: nahoru, domu]

Skip to content

Commit

Permalink
Remove outdated self-cimports in pyx files and other Cython 3 prep (#179
Browse files Browse the repository at this point in the history
)

* Remove outdated self-cimports in pyx files
* Use absolute cimports only
* Remove a duplicate 'cdef cppclass'
* Do not use cpdef for variables
  • Loading branch information
mkoeppe committed Oct 20, 2023
1 parent 2178e19 commit 615a193
Show file tree
Hide file tree
Showing 24 changed files with 18 additions and 54 deletions.
3 changes: 0 additions & 3 deletions cylp/cy/CyCbcNode.pyx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# cython: embedsignature=True


cimport CyCbcNode

cdef class CyCbcNode:
def __cinit__(self):
self.CppSelf = new CppICbcNode()
Expand Down
4 changes: 0 additions & 4 deletions cylp/cy/CyCglCutGeneratorBase.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ cdef extern from "CglCutGenerator.hpp":
#CppCglCutGenerator* new_CyCglCutGenerator \
# "new ICglCutGenerator" ()

cdef extern from "OsiSolverInterface.hpp":
cdef cppclass CppOsiSolverInterface "OsiSolverInterface":
pass

cdef extern from "ICglCutGeneratorBase.h":
#cdef cppclass CoinIndexedVector:
# pass
Expand Down
3 changes: 0 additions & 3 deletions cylp/cy/CyCglCutGeneratorBase.pyx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# cython: embedsignature=True

cimport CyCglCutGeneratorBase
from cylp.cy.CyCglCutGeneratorBase import CyCglCutGeneratorBase

cdef void RunGenerateCuts(void *ptr, CppOsiSolverInterface *si,
CppOsiCuts *cs,
CppCglTreeInfo info):
Expand Down
3 changes: 0 additions & 3 deletions cylp/cy/CyCglTreeInfo.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

cimport CyCglTreeInfo

cdef class CyCglTreeInfo:
'CyCglTreeInfo documentation'
def __cinit__(self):
Expand Down
4 changes: 2 additions & 2 deletions cylp/cy/CyClpSimplex.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ cdef class CyClpSimplex:
This is the documentation of CyClpSimpelx in the pyx class
'''

cpdef CppIClpSimplex *CppSelf
cpdef vars
cdef CppIClpSimplex *CppSelf
cdef vars
cdef object varSelCriteria
cdef CyCoinModel coinModel
cdef object cyLPModel
Expand Down
9 changes: 4 additions & 5 deletions cylp/cy/CyClpSimplex.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import numpy as np
cimport numpy as np
from scipy import sparse
cimport cpython.ref as cpy_ref
from CyWolfePivot cimport CyWolfePivot
from CyPEPivot cimport CyPEPivot
from CyPivotPythonBase cimport CyPivotPythonBase
from CyDualPivotPythonBase cimport CyDualPivotPythonBase
from cylp.cy cimport CyClpSimplex
from cylp.cy.CyWolfePivot cimport CyWolfePivot
from cylp.cy.CyPEPivot cimport CyPEPivot
from cylp.cy.CyPivotPythonBase cimport CyPivotPythonBase
from cylp.cy.CyDualPivotPythonBase cimport CyDualPivotPythonBase
from cylp.cy cimport CyCoinModel
from cylp.py.utils.sparseUtil import sparseConcat, csc_matrixPlus
from cylp.py.modeling.CyLPModel import CyLPVar, CyLPArray, CyLPSolution
Expand Down
2 changes: 1 addition & 1 deletion cylp/cy/CyCoinIndexedVector.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cdef extern from "ICoinIndexedVector.hpp":


cdef class CyCoinIndexedVector:
cpdef CppCoinIndexedVector *CppSelf
cdef CppCoinIndexedVector *CppSelf
cpdef reserve(self, n)
cpdef assign(self, ind, other)
cdef setCppSelf(self, CppCoinIndexedVector* s)
Expand Down
3 changes: 0 additions & 3 deletions cylp/cy/CyCoinModel.pyx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# cython: embedsignature=True


from cylp.cy cimport CyCoinModel

cdef class CyCoinModel:
'''
Expand Down
2 changes: 1 addition & 1 deletion cylp/cy/CyCoinMpsIO.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cdef extern from "ICoinMpsIO.hpp":

cdef class CyCoinMpsIO:
cdef CppICoinMpsIO *CppSelf
cpdef Hessian
cdef Hessian
# cpdef getColLower(self)
# cpdef getColUpper(self)
# cpdef getRowSense(self)
Expand Down
2 changes: 1 addition & 1 deletion cylp/cy/CyCoinPackedMatrix.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cdef extern from "ICoinPackedMatrix.hpp":


cdef class CyCoinPackedMatrix:
cpdef CppCoinPackedMatrix* CppSelf
cdef CppCoinPackedMatrix* CppSelf
#cpdef getIndices(self)
#cpdef getElements(self)
#cpdef getNumElements(self)
Expand Down
8 changes: 4 additions & 4 deletions cylp/cy/CyCutGeneratorPythonBase.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from CyCglCutGeneratorBase cimport *
from CyOsiSolverInterface cimport CppOsiSolverInterface, CyOsiSolverInterface
from CyOsiCuts cimport CppOsiCuts, CyOsiCuts
from CyCglTreeInfo cimport CppCglTreeInfo, CyCglTreeInfo
from cylp.cy.CyCglCutGeneratorBase cimport *
from cylp.cy.CyOsiSolverInterface cimport CppOsiSolverInterface, CyOsiSolverInterface
from cylp.cy.CyOsiCuts cimport CppOsiCuts, CyOsiCuts
from cylp.cy.CyCglTreeInfo cimport CppCglTreeInfo, CyCglTreeInfo
cimport cython.operator.dereference as deref
from cylp.cy.CyClpSimplex cimport CyClpSimplex, CppIClpSimplex
from cylp.cy.CyCoinIndexedVector cimport CyCoinIndexedVector
Expand Down
4 changes: 0 additions & 4 deletions cylp/cy/CyCutGeneratorPythonBase.pyx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# cython: embedsignature=True


cimport CyCutGeneratorPythonBase


cdef class CyCutGeneratorPythonBase(CyCglCutGeneratorBase):
def __init__(self, cutGeneratorObject, cyLPModel=None):
CyCglCutGeneratorBase.__init__(self)
Expand Down
2 changes: 1 addition & 1 deletion cylp/cy/CyDantzigPivot.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from CyClpPrimalColumnPivotBase cimport *
from cylp.cy.CyClpPrimalColumnPivotBase cimport *
from cylp.cy cimport CyClpSimplex
from cylp.cy.CyCoinIndexedVector cimport CyCoinIndexedVector

Expand Down
2 changes: 0 additions & 2 deletions cylp/cy/CyDantzigPivot.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import numpy as np
cimport numpy as np
cimport CyDantzigPivot
#cimport CyClpSimplex

# varStatus defined to mimic 'enum ClpSimplex::Status'.
# But is too slow obviously
Expand Down
2 changes: 1 addition & 1 deletion cylp/cy/CyDualPivotPythonBase.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
cimport numpy as np
from CyClpDualRowPivotBase cimport *
from cylp.cy.CyClpDualRowPivotBase cimport *
cimport cython.operator.dereference as deref
from cylp.cy cimport CyClpSimplex
from cylp.cy.CyCoinIndexedVector cimport CyCoinIndexedVector
Expand Down
3 changes: 0 additions & 3 deletions cylp/cy/CyDualPivotPythonBase.pyx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# cython: embedsignature=True


cimport CyDualPivotPythonBase

cdef class CyDualPivotPythonBase(CyClpDualRowPivotBase):
def __init__(self, dualPivotMethodObject):
CyClpDualRowPivotBase.__init__(self)
Expand Down
1 change: 0 additions & 1 deletion cylp/cy/CyOsiCuts.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import scipy
from scipy.sparse import csr_matrix
cimport CyOsiCuts
from cylp.py.modeling.CyLPModel import CyLPModel
cimport numpy as np
import numpy as np
Expand Down
4 changes: 0 additions & 4 deletions cylp/cy/CyOsiSolverInterface.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

cimport CyOsiSolverInterface


cdef extern from *:
CppOsiClpSolverInterface* dynamic_cast_osi_2_clp "dynamic_cast<OsiClpSolverInterface*>" (CppOsiSolverInterface*)
CppIClpSimplex* static_cast_clp_2_iclp "static_cast<IClpSimplex*>" (CppClpSimplex*)
Expand Down
2 changes: 1 addition & 1 deletion cylp/cy/CyPEPivot.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cimport cython.operator.dereference as deref
from CyClpPrimalColumnPivotBase cimport *
from cylp.cy.CyClpPrimalColumnPivotBase cimport *
from cylp.cy cimport CyClpSimplex
from cylp.cy.CyCoinIndexedVector cimport CyCoinIndexedVector

Expand Down
2 changes: 1 addition & 1 deletion cylp/cy/CyPivotPythonBase.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from CyClpPrimalColumnPivotBase cimport *
from cylp.cy.CyClpPrimalColumnPivotBase cimport *
cimport cython.operator.dereference as deref
from cylp.cy.CyClpSimplex cimport CyClpSimplex, CppIClpSimplex
from cylp.cy.CyCoinIndexedVector cimport CyCoinIndexedVector
Expand Down
2 changes: 0 additions & 2 deletions cylp/cy/CyPivotPythonBase.pyx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# cython: embedsignature=True


cimport CyPivotPythonBase

cdef class CyPivotPythonBase(CyClpPrimalColumnPivotBase):
def __init__(self, pivotMethodObject):
CyClpPrimalColumnPivotBase.__init__(self)
Expand Down
2 changes: 1 addition & 1 deletion cylp/cy/CyWolfePivot.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from CyClpPrimalColumnPivotBase cimport *
from cylp.cy.CyClpPrimalColumnPivotBase cimport *
from cylp.cy cimport CyClpSimplex
from cylp.cy.CyCoinIndexedVector cimport CyCoinIndexedVector

Expand Down
2 changes: 0 additions & 2 deletions cylp/cy/CyWolfePivot.pyx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# cython: embedsignature=True


from cylp.cy cimport CyWolfePivot

cdef class CyWolfePivot(CyClpPrimalColumnPivotBase):

cdef pivotColumn(self, CppCoinIndexedVector* cppupdates, CppCoinIndexedVector* cppspareRow1,
Expand Down
1 change: 0 additions & 1 deletion cylp/cy/createCythonInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

#Create the pyx file
pyxContent = '''
cimport Cy%s
cdef class Cy%s:
'Cy%s documentation'
Expand Down

0 comments on commit 615a193

Please sign in to comment.