From a8267aefae6142ad2a745cc9e89851792ca60ded Mon Sep 17 00:00:00 2001 From: Christoph Groth <christoph.groth@cea.fr> Date: Thu, 30 Jul 2015 11:09:10 +0200 Subject: [PATCH] switch to relative cimports This still does not allow to import kwant under other names: http://thread.gmane.org/gmane.comp.python.cython.user/13809 Once we depend on Python 3.5, and "proper" relative cimports are supported by Cython, we could add a test for exclusive use of relative imports. --- kwant/_system.pyx | 4 ++-- kwant/graph/core.pxd | 2 +- kwant/graph/core.pyx | 2 +- kwant/graph/scotch.pyx | 4 ++-- kwant/graph/slicer.pyx | 6 +++--- kwant/graph/utils.pyx | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kwant/_system.pyx b/kwant/_system.pyx index 7e31ed48..d538b09b 100644 --- a/kwant/_system.pyx +++ b/kwant/_system.pyx @@ -12,8 +12,8 @@ import numpy as np from scipy import sparse as sp from itertools import chain -from kwant.graph.core cimport CGraph, gintArraySlice -from kwant.graph.defs cimport gint +from .graph.core cimport CGraph, gintArraySlice +from .graph.defs cimport gint from .graph.defs import gint_dtype msg = ('Hopping from site {0} to site {1} does not match the ' diff --git a/kwant/graph/core.pxd b/kwant/graph/core.pxd index 9922d666..5eb7507d 100644 --- a/kwant/graph/core.pxd +++ b/kwant/graph/core.pxd @@ -7,7 +7,7 @@ # http://kwant-project.org/authors. cimport numpy as np -from kwant.graph.defs cimport gint +from .defs cimport gint cdef struct Edge: gint tail, head diff --git a/kwant/graph/core.pyx b/kwant/graph/core.pyx index 425e4f22..e6557bbd 100644 --- a/kwant/graph/core.pyx +++ b/kwant/graph/core.pyx @@ -30,7 +30,7 @@ from libc.stdlib cimport malloc, realloc, free from libc.string cimport memset import numpy as np cimport numpy as np -from kwant.graph.defs cimport gint +from .defs cimport gint cdef class Graph: """An uncompressed graph. Used to make compressed graphs. (See `CGraph`.) diff --git a/kwant/graph/scotch.pyx b/kwant/graph/scotch.pyx index 0e5dc798..2fe67196 100644 --- a/kwant/graph/scotch.pyx +++ b/kwant/graph/scotch.pyx @@ -13,9 +13,9 @@ __all__ = ['bisect', 'reset'] cimport libc.stdio import numpy as np cimport numpy as np -from kwant.graph cimport core +from . cimport core from . import core, defs -from kwant.graph.c_scotch cimport * +from .c_scotch cimport * DEF SCOTCH_STRATQUALITY = 1 DEF SCOTCH_STRATSPEED = 2 diff --git a/kwant/graph/slicer.pyx b/kwant/graph/slicer.pyx index fbb45f00..14471920 100644 --- a/kwant/graph/slicer.pyx +++ b/kwant/graph/slicer.pyx @@ -10,10 +10,10 @@ import numpy as np cimport numpy as np cimport cython from libc.string cimport memcpy -from kwant.graph.defs cimport gint +from .defs cimport gint from .defs import gint_dtype -from kwant.graph.core cimport CGraph -cimport kwant.graph.c_slicer as c_slicer +from .core cimport CGraph +from . cimport c_slicer __all__ = ['slice'] diff --git a/kwant/graph/utils.pyx b/kwant/graph/utils.pyx index 058916a3..fd64fc66 100644 --- a/kwant/graph/utils.pyx +++ b/kwant/graph/utils.pyx @@ -16,9 +16,9 @@ cimport numpy as np from libc.stdlib cimport malloc, realloc, free from libc.string cimport memset cimport cython -from kwant.graph.defs cimport gint +from .defs cimport gint from .defs import gint_dtype -from kwant.graph.core cimport CGraph, CGraph_malloc +from .core cimport CGraph, CGraph_malloc from .core import CGraph, CGraph_malloc @cython.boundscheck(False) -- GitLab