scikit-network 0.33.0__cp39-cp39-win_amd64.whl → 0.33.3__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of scikit-network might be problematic. Click here for more details.
- scikit_network-0.33.3.dist-info/METADATA +122 -0
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.3.dist-info}/RECORD +44 -44
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.3.dist-info}/WHEEL +1 -1
- sknetwork/classification/diffusion.py +1 -1
- sknetwork/classification/knn.py +1 -1
- sknetwork/classification/metrics.py +3 -3
- sknetwork/classification/pagerank.py +1 -1
- sknetwork/classification/propagation.py +1 -1
- sknetwork/classification/vote.cp39-win_amd64.pyd +0 -0
- sknetwork/classification/vote.cpp +686 -679
- sknetwork/clustering/leiden_core.cp39-win_amd64.pyd +0 -0
- sknetwork/clustering/leiden_core.cpp +715 -704
- sknetwork/clustering/louvain.py +3 -3
- sknetwork/clustering/louvain_core.cp39-win_amd64.pyd +0 -0
- sknetwork/clustering/louvain_core.cpp +715 -704
- sknetwork/clustering/metrics.py +1 -1
- sknetwork/clustering/tests/test_louvain.py +6 -0
- sknetwork/gnn/base_activation.py +1 -0
- sknetwork/gnn/gnn_classifier.py +1 -1
- sknetwork/hierarchy/metrics.py +3 -3
- sknetwork/hierarchy/paris.cp39-win_amd64.pyd +0 -0
- sknetwork/hierarchy/paris.cpp +1777 -1155
- sknetwork/linalg/diteration.cp39-win_amd64.pyd +0 -0
- sknetwork/linalg/diteration.cpp +686 -679
- sknetwork/linalg/push.cp39-win_amd64.pyd +0 -0
- sknetwork/linalg/push.cpp +1771 -1155
- sknetwork/linalg/sparse_lowrank.py +1 -1
- sknetwork/ranking/betweenness.cp39-win_amd64.pyd +0 -0
- sknetwork/ranking/betweenness.cpp +565 -559
- sknetwork/topology/cliques.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/cliques.cpp +1731 -1112
- sknetwork/topology/core.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/core.cpp +1757 -1141
- sknetwork/topology/cycles.py +2 -2
- sknetwork/topology/minheap.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/minheap.cpp +689 -679
- sknetwork/topology/triangles.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/triangles.cpp +439 -434
- sknetwork/topology/weisfeiler_lehman_core.cp39-win_amd64.pyd +0 -0
- sknetwork/topology/weisfeiler_lehman_core.cpp +686 -679
- sknetwork/visualization/graphs.py +1 -1
- scikit_network-0.33.0.dist-info/METADATA +0 -517
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.3.dist-info/licenses}/AUTHORS.rst +0 -0
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.3.dist-info/licenses}/LICENSE +0 -0
- {scikit_network-0.33.0.dist-info → scikit_network-0.33.3.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated by Cython 3.0.
|
|
1
|
+
/* Generated by Cython 3.0.12 */
|
|
2
2
|
|
|
3
3
|
/* BEGIN: Cython Metadata
|
|
4
4
|
{
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"/d2FH4-"
|
|
9
9
|
],
|
|
10
10
|
"include_dirs": [
|
|
11
|
-
"C:\\Users\\runneradmin\\AppData\\Local\\Temp\\
|
|
11
|
+
"C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pip-build-env-ji5gyl3u\\overlay\\Lib\\site-packages\\numpy\\_core\\include"
|
|
12
12
|
],
|
|
13
13
|
"language": "c++",
|
|
14
14
|
"name": "sknetwork.ranking.betweenness",
|
|
@@ -44,10 +44,10 @@ END: Cython Metadata */
|
|
|
44
44
|
#else
|
|
45
45
|
#define __PYX_EXTRA_ABI_MODULE_NAME ""
|
|
46
46
|
#endif
|
|
47
|
-
#define CYTHON_ABI "
|
|
47
|
+
#define CYTHON_ABI "3_0_12" __PYX_EXTRA_ABI_MODULE_NAME
|
|
48
48
|
#define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
|
|
49
49
|
#define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
|
|
50
|
-
#define CYTHON_HEX_VERSION
|
|
50
|
+
#define CYTHON_HEX_VERSION 0x03000CF0
|
|
51
51
|
#define CYTHON_FUTURE_DIVISION 1
|
|
52
52
|
#include <stddef.h>
|
|
53
53
|
#ifndef offsetof
|
|
@@ -1811,7 +1811,7 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args,
|
|
|
1811
1811
|
#if !CYTHON_VECTORCALL
|
|
1812
1812
|
#if PY_VERSION_HEX >= 0x03080000
|
|
1813
1813
|
#include "frameobject.h"
|
|
1814
|
-
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
1814
|
+
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
|
|
1815
1815
|
#ifndef Py_BUILD_CORE
|
|
1816
1816
|
#define Py_BUILD_CORE 1
|
|
1817
1817
|
#endif
|
|
@@ -3451,7 +3451,7 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness___init
|
|
|
3451
3451
|
PyObject *__pyx_t_1 = NULL;
|
|
3452
3452
|
PyObject *__pyx_t_2 = NULL;
|
|
3453
3453
|
PyObject *__pyx_t_3 = NULL;
|
|
3454
|
-
int __pyx_t_4;
|
|
3454
|
+
unsigned int __pyx_t_4;
|
|
3455
3455
|
int __pyx_lineno = 0;
|
|
3456
3456
|
const char *__pyx_filename = NULL;
|
|
3457
3457
|
int __pyx_clineno = 0;
|
|
@@ -3673,22 +3673,23 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
3673
3673
|
PyObject *__pyx_t_1 = NULL;
|
|
3674
3674
|
PyObject *__pyx_t_2 = NULL;
|
|
3675
3675
|
PyObject *__pyx_t_3 = NULL;
|
|
3676
|
-
int __pyx_t_4;
|
|
3677
|
-
|
|
3678
|
-
|
|
3676
|
+
unsigned int __pyx_t_4;
|
|
3677
|
+
int __pyx_t_5;
|
|
3678
|
+
PyObject *__pyx_t_6 = NULL;
|
|
3679
3679
|
int __pyx_t_7;
|
|
3680
3680
|
int __pyx_t_8;
|
|
3681
3681
|
int __pyx_t_9;
|
|
3682
3682
|
int __pyx_t_10;
|
|
3683
|
-
|
|
3684
|
-
std::vector<int> __pyx_t_12;
|
|
3685
|
-
int
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
std::vector<
|
|
3691
|
-
std::vector<int>
|
|
3683
|
+
int __pyx_t_11;
|
|
3684
|
+
std::vector<std::vector<int> > __pyx_t_12;
|
|
3685
|
+
std::vector<int> __pyx_t_13;
|
|
3686
|
+
int __pyx_t_14;
|
|
3687
|
+
long __pyx_t_15;
|
|
3688
|
+
Py_ssize_t __pyx_t_16;
|
|
3689
|
+
PyObject *(*__pyx_t_17)(PyObject *);
|
|
3690
|
+
std::vector<float> __pyx_t_18;
|
|
3691
|
+
std::vector<int> ::iterator __pyx_t_19;
|
|
3692
|
+
std::vector<int> *__pyx_t_20;
|
|
3692
3693
|
int __pyx_lineno = 0;
|
|
3693
3694
|
const char *__pyx_filename = NULL;
|
|
3694
3695
|
int __pyx_clineno = 0;
|
|
@@ -3807,9 +3808,9 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
3807
3808
|
__pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 57, __pyx_L1_error)
|
|
3808
3809
|
__Pyx_GOTREF(__pyx_t_2);
|
|
3809
3810
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
3810
|
-
|
|
3811
|
+
__pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 57, __pyx_L1_error)
|
|
3811
3812
|
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
|
3812
|
-
__pyx_v_n =
|
|
3813
|
+
__pyx_v_n = __pyx_t_5;
|
|
3813
3814
|
|
|
3814
3815
|
/* "sknetwork/ranking/betweenness.pyx":58
|
|
3815
3816
|
*
|
|
@@ -3825,14 +3826,14 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
3825
3826
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
3826
3827
|
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error)
|
|
3827
3828
|
__Pyx_GOTREF(__pyx_t_1);
|
|
3828
|
-
|
|
3829
|
+
__pyx_t_6 = NULL;
|
|
3829
3830
|
__pyx_t_4 = 0;
|
|
3830
3831
|
#if CYTHON_UNPACK_METHODS
|
|
3831
3832
|
if (unlikely(PyMethod_Check(__pyx_t_3))) {
|
|
3832
|
-
|
|
3833
|
-
if (likely(
|
|
3833
|
+
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
|
|
3834
|
+
if (likely(__pyx_t_6)) {
|
|
3834
3835
|
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
|
|
3835
|
-
__Pyx_INCREF(
|
|
3836
|
+
__Pyx_INCREF(__pyx_t_6);
|
|
3836
3837
|
__Pyx_INCREF(function);
|
|
3837
3838
|
__Pyx_DECREF_SET(__pyx_t_3, function);
|
|
3838
3839
|
__pyx_t_4 = 1;
|
|
@@ -3840,9 +3841,9 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
3840
3841
|
}
|
|
3841
3842
|
#endif
|
|
3842
3843
|
{
|
|
3843
|
-
PyObject *__pyx_callargs[2] = {
|
|
3844
|
+
PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_1};
|
|
3844
3845
|
__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4);
|
|
3845
|
-
__Pyx_XDECREF(
|
|
3846
|
+
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
3846
3847
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
3847
3848
|
if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
|
|
3848
3849
|
__Pyx_GOTREF(__pyx_t_2);
|
|
@@ -3858,10 +3859,10 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
3858
3859
|
* preds = [[] for _ in range(n)]
|
|
3859
3860
|
* sigma = np.zeros(n)
|
|
3860
3861
|
*/
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
for (
|
|
3864
|
-
__pyx_v_source =
|
|
3862
|
+
__pyx_t_5 = __pyx_v_n;
|
|
3863
|
+
__pyx_t_7 = __pyx_t_5;
|
|
3864
|
+
for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
|
|
3865
|
+
__pyx_v_source = __pyx_t_8;
|
|
3865
3866
|
|
|
3866
3867
|
/* "sknetwork/ranking/betweenness.pyx":63
|
|
3867
3868
|
*
|
|
@@ -3873,19 +3874,19 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
3873
3874
|
{ /* enter inner scope */
|
|
3874
3875
|
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
|
|
3875
3876
|
__Pyx_GOTREF(__pyx_t_2);
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
for (
|
|
3879
|
-
__pyx_7genexpr__pyx_v__ =
|
|
3877
|
+
__pyx_t_9 = __pyx_v_n;
|
|
3878
|
+
__pyx_t_10 = __pyx_t_9;
|
|
3879
|
+
for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
|
|
3880
|
+
__pyx_7genexpr__pyx_v__ = __pyx_t_11;
|
|
3880
3881
|
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error)
|
|
3881
3882
|
__Pyx_GOTREF(__pyx_t_3);
|
|
3882
3883
|
if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 63, __pyx_L1_error)
|
|
3883
3884
|
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
|
3884
3885
|
}
|
|
3885
3886
|
} /* exit inner scope */
|
|
3886
|
-
|
|
3887
|
+
__pyx_t_12 = __pyx_convert_vector_from_py_std_3a__3a_vector_3c_int_3e___(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 63, __pyx_L1_error)
|
|
3887
3888
|
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
|
3888
|
-
__pyx_v_preds = __PYX_STD_MOVE_IF_SUPPORTED(
|
|
3889
|
+
__pyx_v_preds = __PYX_STD_MOVE_IF_SUPPORTED(__pyx_t_12);
|
|
3889
3890
|
|
|
3890
3891
|
/* "sknetwork/ranking/betweenness.pyx":64
|
|
3891
3892
|
* for source in range(n):
|
|
@@ -3901,32 +3902,32 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
3901
3902
|
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
|
3902
3903
|
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 64, __pyx_L1_error)
|
|
3903
3904
|
__Pyx_GOTREF(__pyx_t_3);
|
|
3904
|
-
|
|
3905
|
-
|
|
3905
|
+
__pyx_t_6 = NULL;
|
|
3906
|
+
__pyx_t_4 = 0;
|
|
3906
3907
|
#if CYTHON_UNPACK_METHODS
|
|
3907
3908
|
if (unlikely(PyMethod_Check(__pyx_t_1))) {
|
|
3908
|
-
|
|
3909
|
-
if (likely(
|
|
3909
|
+
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
|
|
3910
|
+
if (likely(__pyx_t_6)) {
|
|
3910
3911
|
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
|
|
3911
|
-
__Pyx_INCREF(
|
|
3912
|
+
__Pyx_INCREF(__pyx_t_6);
|
|
3912
3913
|
__Pyx_INCREF(function);
|
|
3913
3914
|
__Pyx_DECREF_SET(__pyx_t_1, function);
|
|
3914
|
-
|
|
3915
|
+
__pyx_t_4 = 1;
|
|
3915
3916
|
}
|
|
3916
3917
|
}
|
|
3917
3918
|
#endif
|
|
3918
3919
|
{
|
|
3919
|
-
PyObject *__pyx_callargs[2] = {
|
|
3920
|
-
__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-
|
|
3921
|
-
__Pyx_XDECREF(
|
|
3920
|
+
PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_3};
|
|
3921
|
+
__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4);
|
|
3922
|
+
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
3922
3923
|
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
|
3923
3924
|
if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error)
|
|
3924
3925
|
__Pyx_GOTREF(__pyx_t_2);
|
|
3925
3926
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
3926
3927
|
}
|
|
3927
|
-
|
|
3928
|
+
__pyx_t_13 = __pyx_convert_vector_from_py_int(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 64, __pyx_L1_error)
|
|
3928
3929
|
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
|
3929
|
-
__pyx_v_sigma = __PYX_STD_MOVE_IF_SUPPORTED(
|
|
3930
|
+
__pyx_v_sigma = __PYX_STD_MOVE_IF_SUPPORTED(__pyx_t_13);
|
|
3930
3931
|
|
|
3931
3932
|
/* "sknetwork/ranking/betweenness.pyx":65
|
|
3932
3933
|
* preds = [[] for _ in range(n)]
|
|
@@ -3959,17 +3960,17 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
3959
3960
|
__pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
|
|
3960
3961
|
__Pyx_GOTREF(__pyx_t_2);
|
|
3961
3962
|
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 66, __pyx_L1_error)
|
|
3962
|
-
|
|
3963
|
-
__Pyx_GOTREF(
|
|
3963
|
+
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 66, __pyx_L1_error)
|
|
3964
|
+
__Pyx_GOTREF(__pyx_t_6);
|
|
3964
3965
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
3965
3966
|
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
|
3966
3967
|
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
|
3967
|
-
__pyx_t_2 = PyNumber_Negative(
|
|
3968
|
+
__pyx_t_2 = PyNumber_Negative(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
|
|
3968
3969
|
__Pyx_GOTREF(__pyx_t_2);
|
|
3969
|
-
__Pyx_DECREF(
|
|
3970
|
-
|
|
3970
|
+
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
3971
|
+
__pyx_t_13 = __pyx_convert_vector_from_py_int(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L1_error)
|
|
3971
3972
|
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
|
3972
|
-
__pyx_v_dists = __PYX_STD_MOVE_IF_SUPPORTED(
|
|
3973
|
+
__pyx_v_dists = __PYX_STD_MOVE_IF_SUPPORTED(__pyx_t_13);
|
|
3973
3974
|
|
|
3974
3975
|
/* "sknetwork/ranking/betweenness.pyx":67
|
|
3975
3976
|
* sigma[source] = 1
|
|
@@ -3997,8 +3998,8 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
3997
3998
|
* bfs_queue.pop()
|
|
3998
3999
|
*/
|
|
3999
4000
|
while (1) {
|
|
4000
|
-
|
|
4001
|
-
if (!
|
|
4001
|
+
__pyx_t_14 = (__pyx_v_bfs_queue.size() != 0);
|
|
4002
|
+
if (!__pyx_t_14) break;
|
|
4002
4003
|
|
|
4003
4004
|
/* "sknetwork/ranking/betweenness.pyx":71
|
|
4004
4005
|
*
|
|
@@ -4041,24 +4042,24 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4041
4042
|
*/
|
|
4042
4043
|
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_adjacency, __pyx_n_s_indices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
|
|
4043
4044
|
__Pyx_GOTREF(__pyx_t_2);
|
|
4044
|
-
|
|
4045
|
-
__Pyx_GOTREF(
|
|
4046
|
-
__pyx_t_3 = __Pyx_GetItemInt(
|
|
4045
|
+
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_adjacency, __pyx_n_s_indptr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 75, __pyx_L1_error)
|
|
4046
|
+
__Pyx_GOTREF(__pyx_t_6);
|
|
4047
|
+
__pyx_t_3 = __Pyx_GetItemInt(__pyx_t_6, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 75, __pyx_L1_error)
|
|
4047
4048
|
__Pyx_GOTREF(__pyx_t_3);
|
|
4048
|
-
__Pyx_DECREF(
|
|
4049
|
-
|
|
4050
|
-
__Pyx_GOTREF(
|
|
4051
|
-
|
|
4052
|
-
__pyx_t_1 = __Pyx_GetItemInt(
|
|
4049
|
+
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
4050
|
+
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_adjacency, __pyx_n_s_indptr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 75, __pyx_L1_error)
|
|
4051
|
+
__Pyx_GOTREF(__pyx_t_6);
|
|
4052
|
+
__pyx_t_15 = (__pyx_v_i + 1);
|
|
4053
|
+
__pyx_t_1 = __Pyx_GetItemInt(__pyx_t_6, __pyx_t_15, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error)
|
|
4053
4054
|
__Pyx_GOTREF(__pyx_t_1);
|
|
4054
|
-
__Pyx_DECREF(
|
|
4055
|
-
|
|
4056
|
-
__Pyx_GOTREF(
|
|
4055
|
+
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
4056
|
+
__pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, 0, &__pyx_t_3, &__pyx_t_1, NULL, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 75, __pyx_L1_error)
|
|
4057
|
+
__Pyx_GOTREF(__pyx_t_6);
|
|
4057
4058
|
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
|
4058
4059
|
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
|
4059
4060
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
4060
|
-
__Pyx_XDECREF_SET(__pyx_v_neighbors,
|
|
4061
|
-
|
|
4061
|
+
__Pyx_XDECREF_SET(__pyx_v_neighbors, __pyx_t_6);
|
|
4062
|
+
__pyx_t_6 = 0;
|
|
4062
4063
|
|
|
4063
4064
|
/* "sknetwork/ranking/betweenness.pyx":76
|
|
4064
4065
|
* seen.push_back(i)
|
|
@@ -4068,47 +4069,47 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4068
4069
|
* dists[j] = dists[i] + 1
|
|
4069
4070
|
*/
|
|
4070
4071
|
if (likely(PyList_CheckExact(__pyx_v_neighbors)) || PyTuple_CheckExact(__pyx_v_neighbors)) {
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4072
|
+
__pyx_t_6 = __pyx_v_neighbors; __Pyx_INCREF(__pyx_t_6);
|
|
4073
|
+
__pyx_t_16 = 0;
|
|
4074
|
+
__pyx_t_17 = NULL;
|
|
4074
4075
|
} else {
|
|
4075
|
-
|
|
4076
|
-
__Pyx_GOTREF(
|
|
4077
|
-
|
|
4076
|
+
__pyx_t_16 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_neighbors); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 76, __pyx_L1_error)
|
|
4077
|
+
__Pyx_GOTREF(__pyx_t_6);
|
|
4078
|
+
__pyx_t_17 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 76, __pyx_L1_error)
|
|
4078
4079
|
}
|
|
4079
4080
|
for (;;) {
|
|
4080
|
-
if (likely(!
|
|
4081
|
-
if (likely(PyList_CheckExact(
|
|
4081
|
+
if (likely(!__pyx_t_17)) {
|
|
4082
|
+
if (likely(PyList_CheckExact(__pyx_t_6))) {
|
|
4082
4083
|
{
|
|
4083
|
-
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(
|
|
4084
|
+
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
|
|
4084
4085
|
#if !CYTHON_ASSUME_SAFE_MACROS
|
|
4085
4086
|
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 76, __pyx_L1_error)
|
|
4086
4087
|
#endif
|
|
4087
|
-
if (
|
|
4088
|
+
if (__pyx_t_16 >= __pyx_temp) break;
|
|
4088
4089
|
}
|
|
4089
4090
|
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
|
|
4090
|
-
__pyx_t_1 = PyList_GET_ITEM(
|
|
4091
|
+
__pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_16); __Pyx_INCREF(__pyx_t_1); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 76, __pyx_L1_error)
|
|
4091
4092
|
#else
|
|
4092
|
-
__pyx_t_1 = __Pyx_PySequence_ITEM(
|
|
4093
|
+
__pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
|
|
4093
4094
|
__Pyx_GOTREF(__pyx_t_1);
|
|
4094
4095
|
#endif
|
|
4095
4096
|
} else {
|
|
4096
4097
|
{
|
|
4097
|
-
Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(
|
|
4098
|
+
Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
|
|
4098
4099
|
#if !CYTHON_ASSUME_SAFE_MACROS
|
|
4099
4100
|
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 76, __pyx_L1_error)
|
|
4100
4101
|
#endif
|
|
4101
|
-
if (
|
|
4102
|
+
if (__pyx_t_16 >= __pyx_temp) break;
|
|
4102
4103
|
}
|
|
4103
4104
|
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
|
|
4104
|
-
__pyx_t_1 = PyTuple_GET_ITEM(
|
|
4105
|
+
__pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_16); __Pyx_INCREF(__pyx_t_1); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 76, __pyx_L1_error)
|
|
4105
4106
|
#else
|
|
4106
|
-
__pyx_t_1 = __Pyx_PySequence_ITEM(
|
|
4107
|
+
__pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
|
|
4107
4108
|
__Pyx_GOTREF(__pyx_t_1);
|
|
4108
4109
|
#endif
|
|
4109
4110
|
}
|
|
4110
4111
|
} else {
|
|
4111
|
-
__pyx_t_1 =
|
|
4112
|
+
__pyx_t_1 = __pyx_t_17(__pyx_t_6);
|
|
4112
4113
|
if (unlikely(!__pyx_t_1)) {
|
|
4113
4114
|
PyObject* exc_type = PyErr_Occurred();
|
|
4114
4115
|
if (exc_type) {
|
|
@@ -4119,9 +4120,9 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4119
4120
|
}
|
|
4120
4121
|
__Pyx_GOTREF(__pyx_t_1);
|
|
4121
4122
|
}
|
|
4122
|
-
|
|
4123
|
+
__pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 76, __pyx_L1_error)
|
|
4123
4124
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
4124
|
-
__pyx_v_j =
|
|
4125
|
+
__pyx_v_j = __pyx_t_9;
|
|
4125
4126
|
|
|
4126
4127
|
/* "sknetwork/ranking/betweenness.pyx":77
|
|
4127
4128
|
* neighbors = adjacency.indices[adjacency.indptr[i]:adjacency.indptr[i + 1]]
|
|
@@ -4130,8 +4131,8 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4130
4131
|
* dists[j] = dists[i] + 1
|
|
4131
4132
|
* bfs_queue.push(j)
|
|
4132
4133
|
*/
|
|
4133
|
-
|
|
4134
|
-
if (
|
|
4134
|
+
__pyx_t_14 = ((__pyx_v_dists[__pyx_v_j]) < 0);
|
|
4135
|
+
if (__pyx_t_14) {
|
|
4135
4136
|
|
|
4136
4137
|
/* "sknetwork/ranking/betweenness.pyx":78
|
|
4137
4138
|
* for j in neighbors:
|
|
@@ -4167,8 +4168,8 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4167
4168
|
* sigma[j] += sigma[i]
|
|
4168
4169
|
* preds[j].push_back(i)
|
|
4169
4170
|
*/
|
|
4170
|
-
|
|
4171
|
-
if (
|
|
4171
|
+
__pyx_t_14 = ((__pyx_v_dists[__pyx_v_j]) == ((__pyx_v_dists[__pyx_v_i]) + 1));
|
|
4172
|
+
if (__pyx_t_14) {
|
|
4172
4173
|
|
|
4173
4174
|
/* "sknetwork/ranking/betweenness.pyx":81
|
|
4174
4175
|
* bfs_queue.push(j)
|
|
@@ -4177,8 +4178,8 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4177
4178
|
* preds[j].push_back(i)
|
|
4178
4179
|
*
|
|
4179
4180
|
*/
|
|
4180
|
-
|
|
4181
|
-
(__pyx_v_sigma[
|
|
4181
|
+
__pyx_t_9 = __pyx_v_j;
|
|
4182
|
+
(__pyx_v_sigma[__pyx_t_9]) = ((__pyx_v_sigma[__pyx_t_9]) + (__pyx_v_sigma[__pyx_v_i]));
|
|
4182
4183
|
|
|
4183
4184
|
/* "sknetwork/ranking/betweenness.pyx":82
|
|
4184
4185
|
* if dists[j] == dists[i] + 1: # shortest path to j via i?
|
|
@@ -4211,7 +4212,7 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4211
4212
|
* dists[j] = dists[i] + 1
|
|
4212
4213
|
*/
|
|
4213
4214
|
}
|
|
4214
|
-
__Pyx_DECREF(
|
|
4215
|
+
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
4215
4216
|
}
|
|
4216
4217
|
|
|
4217
4218
|
/* "sknetwork/ranking/betweenness.pyx":85
|
|
@@ -4229,7 +4230,7 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4229
4230
|
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
|
|
4230
4231
|
__Pyx_GOTREF(__pyx_t_1);
|
|
4231
4232
|
__pyx_t_2 = NULL;
|
|
4232
|
-
|
|
4233
|
+
__pyx_t_4 = 0;
|
|
4233
4234
|
#if CYTHON_UNPACK_METHODS
|
|
4234
4235
|
if (unlikely(PyMethod_Check(__pyx_t_3))) {
|
|
4235
4236
|
__pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
|
|
@@ -4238,22 +4239,22 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4238
4239
|
__Pyx_INCREF(__pyx_t_2);
|
|
4239
4240
|
__Pyx_INCREF(function);
|
|
4240
4241
|
__Pyx_DECREF_SET(__pyx_t_3, function);
|
|
4241
|
-
|
|
4242
|
+
__pyx_t_4 = 1;
|
|
4242
4243
|
}
|
|
4243
4244
|
}
|
|
4244
4245
|
#endif
|
|
4245
4246
|
{
|
|
4246
4247
|
PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_1};
|
|
4247
|
-
|
|
4248
|
+
__pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4);
|
|
4248
4249
|
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
|
|
4249
4250
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
4250
|
-
if (unlikely(!
|
|
4251
|
-
__Pyx_GOTREF(
|
|
4251
|
+
if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error)
|
|
4252
|
+
__Pyx_GOTREF(__pyx_t_6);
|
|
4252
4253
|
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
|
4253
4254
|
}
|
|
4254
|
-
|
|
4255
|
-
__Pyx_DECREF(
|
|
4256
|
-
__pyx_v_delta = __PYX_STD_MOVE_IF_SUPPORTED(
|
|
4255
|
+
__pyx_t_18 = __pyx_convert_vector_from_py_float(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error)
|
|
4256
|
+
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
4257
|
+
__pyx_v_delta = __PYX_STD_MOVE_IF_SUPPORTED(__pyx_t_18);
|
|
4257
4258
|
|
|
4258
4259
|
/* "sknetwork/ranking/betweenness.pyx":86
|
|
4259
4260
|
* # Now backtrack to compute betweenness scores
|
|
@@ -4263,12 +4264,12 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4263
4264
|
* seen.pop_back()
|
|
4264
4265
|
*/
|
|
4265
4266
|
while (1) {
|
|
4266
|
-
|
|
4267
|
-
__Pyx_GOTREF(
|
|
4268
|
-
|
|
4269
|
-
__Pyx_DECREF(
|
|
4270
|
-
|
|
4271
|
-
if (!
|
|
4267
|
+
__pyx_t_6 = __pyx_convert_vector_to_py_int(__pyx_v_seen); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 86, __pyx_L1_error)
|
|
4268
|
+
__Pyx_GOTREF(__pyx_t_6);
|
|
4269
|
+
__pyx_t_16 = PyObject_Length(__pyx_t_6); if (unlikely(__pyx_t_16 == ((Py_ssize_t)-1))) __PYX_ERR(0, 86, __pyx_L1_error)
|
|
4270
|
+
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
4271
|
+
__pyx_t_14 = (__pyx_t_16 != 0);
|
|
4272
|
+
if (!__pyx_t_14) break;
|
|
4272
4273
|
|
|
4273
4274
|
/* "sknetwork/ranking/betweenness.pyx":87
|
|
4274
4275
|
* delta = np.zeros(n)
|
|
@@ -4295,13 +4296,13 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4295
4296
|
* delta[i] += sigma[i] / sigma[j] * (1 + delta[j])
|
|
4296
4297
|
* if j != source:
|
|
4297
4298
|
*/
|
|
4298
|
-
|
|
4299
|
-
|
|
4299
|
+
__pyx_t_20 = &(__pyx_v_preds[__pyx_v_j]);
|
|
4300
|
+
__pyx_t_19 = __pyx_t_20->begin();
|
|
4300
4301
|
for (;;) {
|
|
4301
|
-
if (!(
|
|
4302
|
-
|
|
4303
|
-
++
|
|
4304
|
-
__pyx_v_i =
|
|
4302
|
+
if (!(__pyx_t_19 != __pyx_t_20->end())) break;
|
|
4303
|
+
__pyx_t_9 = *__pyx_t_19;
|
|
4304
|
+
++__pyx_t_19;
|
|
4305
|
+
__pyx_v_i = __pyx_t_9;
|
|
4305
4306
|
|
|
4306
4307
|
/* "sknetwork/ranking/betweenness.pyx":90
|
|
4307
4308
|
* seen.pop_back()
|
|
@@ -4310,14 +4311,14 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4310
4311
|
* if j != source:
|
|
4311
4312
|
* self.scores_[j] += delta[j]
|
|
4312
4313
|
*/
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
if (unlikely(
|
|
4314
|
+
__pyx_t_9 = __pyx_v_i;
|
|
4315
|
+
__pyx_t_10 = (__pyx_v_sigma[__pyx_v_i]);
|
|
4316
|
+
__pyx_t_11 = (__pyx_v_sigma[__pyx_v_j]);
|
|
4317
|
+
if (unlikely(__pyx_t_11 == 0)) {
|
|
4317
4318
|
PyErr_SetString(PyExc_ZeroDivisionError, "float division");
|
|
4318
4319
|
__PYX_ERR(0, 90, __pyx_L1_error)
|
|
4319
4320
|
}
|
|
4320
|
-
(__pyx_v_delta[
|
|
4321
|
+
(__pyx_v_delta[__pyx_t_9]) = ((__pyx_v_delta[__pyx_t_9]) + ((((double)__pyx_t_10) / ((double)__pyx_t_11)) * (1.0 + (__pyx_v_delta[__pyx_v_j]))));
|
|
4321
4322
|
|
|
4322
4323
|
/* "sknetwork/ranking/betweenness.pyx":89
|
|
4323
4324
|
* j = seen.back()
|
|
@@ -4335,8 +4336,8 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4335
4336
|
* self.scores_[j] += delta[j]
|
|
4336
4337
|
*
|
|
4337
4338
|
*/
|
|
4338
|
-
|
|
4339
|
-
if (
|
|
4339
|
+
__pyx_t_14 = (__pyx_v_j != __pyx_v_source);
|
|
4340
|
+
if (__pyx_t_14) {
|
|
4340
4341
|
|
|
4341
4342
|
/* "sknetwork/ranking/betweenness.pyx":92
|
|
4342
4343
|
* delta[i] += sigma[i] / sigma[j] * (1 + delta[j])
|
|
@@ -4345,10 +4346,10 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4345
4346
|
*
|
|
4346
4347
|
* # Undirected graph, divide all values by two
|
|
4347
4348
|
*/
|
|
4348
|
-
|
|
4349
|
-
__Pyx_GOTREF(
|
|
4350
|
-
|
|
4351
|
-
__pyx_t_3 = __Pyx_GetItemInt(
|
|
4349
|
+
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scores); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 92, __pyx_L1_error)
|
|
4350
|
+
__Pyx_GOTREF(__pyx_t_6);
|
|
4351
|
+
__pyx_t_9 = __pyx_v_j;
|
|
4352
|
+
__pyx_t_3 = __Pyx_GetItemInt(__pyx_t_6, __pyx_t_9, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error)
|
|
4352
4353
|
__Pyx_GOTREF(__pyx_t_3);
|
|
4353
4354
|
__pyx_t_1 = PyFloat_FromDouble((__pyx_v_delta[__pyx_v_j])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
|
|
4354
4355
|
__Pyx_GOTREF(__pyx_t_1);
|
|
@@ -4356,9 +4357,9 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4356
4357
|
__Pyx_GOTREF(__pyx_t_2);
|
|
4357
4358
|
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
|
|
4358
4359
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
4359
|
-
if (unlikely((__Pyx_SetItemInt(
|
|
4360
|
+
if (unlikely((__Pyx_SetItemInt(__pyx_t_6, __pyx_t_9, __pyx_t_2, int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0))) __PYX_ERR(0, 92, __pyx_L1_error)
|
|
4360
4361
|
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
|
4361
|
-
__Pyx_DECREF(
|
|
4362
|
+
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
4362
4363
|
|
|
4363
4364
|
/* "sknetwork/ranking/betweenness.pyx":91
|
|
4364
4365
|
* for i in preds[j]:
|
|
@@ -4378,13 +4379,13 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4378
4379
|
*
|
|
4379
4380
|
* return self
|
|
4380
4381
|
*/
|
|
4381
|
-
|
|
4382
|
-
__Pyx_GOTREF(
|
|
4382
|
+
__pyx_t_6 = PyFloat_FromDouble((1.0 / 2.0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 95, __pyx_L1_error)
|
|
4383
|
+
__Pyx_GOTREF(__pyx_t_6);
|
|
4383
4384
|
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scores); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
|
|
4384
4385
|
__Pyx_GOTREF(__pyx_t_2);
|
|
4385
|
-
__pyx_t_1 = PyNumber_Multiply(
|
|
4386
|
+
__pyx_t_1 = PyNumber_Multiply(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
|
|
4386
4387
|
__Pyx_GOTREF(__pyx_t_1);
|
|
4387
|
-
__Pyx_DECREF(
|
|
4388
|
+
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
|
4388
4389
|
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
|
4389
4390
|
if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_scores, __pyx_t_1) < 0) __PYX_ERR(0, 95, __pyx_L1_error)
|
|
4390
4391
|
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
|
@@ -4412,7 +4413,7 @@ static PyObject *__pyx_pf_9sknetwork_7ranking_11betweenness_11Betweenness_2fit(C
|
|
|
4412
4413
|
__Pyx_XDECREF(__pyx_t_1);
|
|
4413
4414
|
__Pyx_XDECREF(__pyx_t_2);
|
|
4414
4415
|
__Pyx_XDECREF(__pyx_t_3);
|
|
4415
|
-
__Pyx_XDECREF(
|
|
4416
|
+
__Pyx_XDECREF(__pyx_t_6);
|
|
4416
4417
|
__Pyx_AddTraceback("sknetwork.ranking.betweenness.Betweenness.fit", __pyx_clineno, __pyx_lineno, __pyx_filename);
|
|
4417
4418
|
__pyx_r = NULL;
|
|
4418
4419
|
__pyx_L0:;
|
|
@@ -7904,6 +7905,9 @@ static PyTypeObject __pyx_CyFunctionType_type = {
|
|
|
7904
7905
|
#if PY_VERSION_HEX >= 0x030C0000
|
|
7905
7906
|
0,
|
|
7906
7907
|
#endif
|
|
7908
|
+
#if PY_VERSION_HEX >= 0x030d00A4
|
|
7909
|
+
0,
|
|
7910
|
+
#endif
|
|
7907
7911
|
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
|
|
7908
7912
|
0,
|
|
7909
7913
|
#endif
|
|
@@ -8326,7 +8330,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
|
|
|
8326
8330
|
#include "compile.h"
|
|
8327
8331
|
#include "frameobject.h"
|
|
8328
8332
|
#include "traceback.h"
|
|
8329
|
-
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
8333
|
+
#if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
|
|
8330
8334
|
#ifndef Py_BUILD_CORE
|
|
8331
8335
|
#define Py_BUILD_CORE 1
|
|
8332
8336
|
#endif
|
|
@@ -8567,12 +8571,19 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
|
|
|
8567
8571
|
}
|
|
8568
8572
|
}
|
|
8569
8573
|
{
|
|
8570
|
-
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
8571
8574
|
unsigned char *bytes = (unsigned char *)&value;
|
|
8572
|
-
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX
|
|
8575
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
|
|
8576
|
+
if (is_unsigned) {
|
|
8577
|
+
return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
|
|
8578
|
+
} else {
|
|
8579
|
+
return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
|
|
8580
|
+
}
|
|
8581
|
+
#elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
|
|
8582
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
8573
8583
|
return _PyLong_FromByteArray(bytes, sizeof(long),
|
|
8574
8584
|
little, !is_unsigned);
|
|
8575
8585
|
#else
|
|
8586
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
8576
8587
|
PyObject *from_bytes, *result = NULL;
|
|
8577
8588
|
PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
|
|
8578
8589
|
from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
|
|
@@ -8622,245 +8633,239 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
|
|
|
8622
8633
|
}
|
|
8623
8634
|
return (int) val;
|
|
8624
8635
|
}
|
|
8625
|
-
}
|
|
8636
|
+
}
|
|
8626
8637
|
#endif
|
|
8627
|
-
if (
|
|
8628
|
-
|
|
8638
|
+
if (unlikely(!PyLong_Check(x))) {
|
|
8639
|
+
int val;
|
|
8640
|
+
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
|
|
8641
|
+
if (!tmp) return (int) -1;
|
|
8642
|
+
val = __Pyx_PyInt_As_int(tmp);
|
|
8643
|
+
Py_DECREF(tmp);
|
|
8644
|
+
return val;
|
|
8645
|
+
}
|
|
8646
|
+
if (is_unsigned) {
|
|
8629
8647
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
}
|
|
8648
|
+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
|
|
8649
|
+
goto raise_neg_overflow;
|
|
8650
|
+
} else if (__Pyx_PyLong_IsCompact(x)) {
|
|
8651
|
+
__PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
|
|
8652
|
+
} else {
|
|
8653
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
8654
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
8655
|
+
switch (__Pyx_PyLong_DigitCount(x)) {
|
|
8656
|
+
case 2:
|
|
8657
|
+
if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
|
|
8658
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
8659
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8660
|
+
} else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
|
|
8661
|
+
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
8645
8662
|
}
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8663
|
+
}
|
|
8664
|
+
break;
|
|
8665
|
+
case 3:
|
|
8666
|
+
if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
|
|
8667
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
8668
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8669
|
+
} else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
|
|
8670
|
+
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
8654
8671
|
}
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8672
|
+
}
|
|
8673
|
+
break;
|
|
8674
|
+
case 4:
|
|
8675
|
+
if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
|
|
8676
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
8677
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8678
|
+
} else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
|
|
8679
|
+
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
|
|
8663
8680
|
}
|
|
8664
|
-
|
|
8665
|
-
|
|
8681
|
+
}
|
|
8682
|
+
break;
|
|
8666
8683
|
}
|
|
8684
|
+
}
|
|
8667
8685
|
#endif
|
|
8668
8686
|
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8687
|
+
if (unlikely(Py_SIZE(x) < 0)) {
|
|
8688
|
+
goto raise_neg_overflow;
|
|
8689
|
+
}
|
|
8672
8690
|
#else
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8691
|
+
{
|
|
8692
|
+
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
8693
|
+
if (unlikely(result < 0))
|
|
8694
|
+
return (int) -1;
|
|
8695
|
+
if (unlikely(result == 1))
|
|
8696
|
+
goto raise_neg_overflow;
|
|
8697
|
+
}
|
|
8680
8698
|
#endif
|
|
8681
|
-
|
|
8682
|
-
|
|
8699
|
+
if ((sizeof(int) <= sizeof(unsigned long))) {
|
|
8700
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
|
|
8683
8701
|
#ifdef HAVE_LONG_LONG
|
|
8684
|
-
|
|
8685
|
-
|
|
8702
|
+
} else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
|
|
8703
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
|
|
8686
8704
|
#endif
|
|
8687
|
-
|
|
8688
|
-
|
|
8705
|
+
}
|
|
8706
|
+
} else {
|
|
8689
8707
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
}
|
|
8708
|
+
if (__Pyx_PyLong_IsCompact(x)) {
|
|
8709
|
+
__PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
|
|
8710
|
+
} else {
|
|
8711
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
8712
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
8713
|
+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
|
|
8714
|
+
case -2:
|
|
8715
|
+
if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
|
|
8716
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
8717
|
+
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8718
|
+
} else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
8719
|
+
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
8703
8720
|
}
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8721
|
+
}
|
|
8722
|
+
break;
|
|
8723
|
+
case 2:
|
|
8724
|
+
if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
|
|
8725
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
8726
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8727
|
+
} else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
8728
|
+
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
8712
8729
|
}
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8730
|
+
}
|
|
8731
|
+
break;
|
|
8732
|
+
case -3:
|
|
8733
|
+
if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
|
|
8734
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
8735
|
+
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8736
|
+
} else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
8737
|
+
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
8721
8738
|
}
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8739
|
+
}
|
|
8740
|
+
break;
|
|
8741
|
+
case 3:
|
|
8742
|
+
if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
|
|
8743
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
8744
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8745
|
+
} else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
8746
|
+
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
8730
8747
|
}
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8748
|
+
}
|
|
8749
|
+
break;
|
|
8750
|
+
case -4:
|
|
8751
|
+
if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
|
|
8752
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
8753
|
+
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8754
|
+
} else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
|
|
8755
|
+
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
8739
8756
|
}
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8757
|
+
}
|
|
8758
|
+
break;
|
|
8759
|
+
case 4:
|
|
8760
|
+
if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
|
|
8761
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
8762
|
+
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
8763
|
+
} else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
|
|
8764
|
+
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
|
|
8748
8765
|
}
|
|
8749
|
-
|
|
8750
|
-
|
|
8766
|
+
}
|
|
8767
|
+
break;
|
|
8751
8768
|
}
|
|
8769
|
+
}
|
|
8752
8770
|
#endif
|
|
8753
|
-
|
|
8754
|
-
|
|
8771
|
+
if ((sizeof(int) <= sizeof(long))) {
|
|
8772
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
|
|
8755
8773
|
#ifdef HAVE_LONG_LONG
|
|
8756
|
-
|
|
8757
|
-
|
|
8774
|
+
} else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
|
|
8775
|
+
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
|
|
8758
8776
|
#endif
|
|
8759
|
-
|
|
8777
|
+
}
|
|
8778
|
+
}
|
|
8779
|
+
{
|
|
8780
|
+
int val;
|
|
8781
|
+
int ret = -1;
|
|
8782
|
+
#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
8783
|
+
Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
|
|
8784
|
+
x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
|
|
8785
|
+
if (unlikely(bytes_copied == -1)) {
|
|
8786
|
+
} else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
|
|
8787
|
+
goto raise_overflow;
|
|
8788
|
+
} else {
|
|
8789
|
+
ret = 0;
|
|
8790
|
+
}
|
|
8791
|
+
#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
8792
|
+
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
8793
|
+
unsigned char *bytes = (unsigned char *)&val;
|
|
8794
|
+
ret = _PyLong_AsByteArray((PyLongObject *)x,
|
|
8795
|
+
bytes, sizeof(val),
|
|
8796
|
+
is_little, !is_unsigned);
|
|
8797
|
+
#else
|
|
8798
|
+
PyObject *v;
|
|
8799
|
+
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
8800
|
+
int bits, remaining_bits, is_negative = 0;
|
|
8801
|
+
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
8802
|
+
if (likely(PyLong_CheckExact(x))) {
|
|
8803
|
+
v = __Pyx_NewRef(x);
|
|
8804
|
+
} else {
|
|
8805
|
+
v = PyNumber_Long(x);
|
|
8806
|
+
if (unlikely(!v)) return (int) -1;
|
|
8807
|
+
assert(PyLong_CheckExact(v));
|
|
8760
8808
|
}
|
|
8761
8809
|
{
|
|
8762
|
-
int
|
|
8763
|
-
|
|
8764
|
-
#if PY_MAJOR_VERSION < 3
|
|
8765
|
-
if (likely(v) && !PyLong_Check(v)) {
|
|
8766
|
-
PyObject *tmp = v;
|
|
8767
|
-
v = PyNumber_Long(tmp);
|
|
8768
|
-
Py_DECREF(tmp);
|
|
8769
|
-
}
|
|
8770
|
-
#endif
|
|
8771
|
-
if (likely(v)) {
|
|
8772
|
-
int ret = -1;
|
|
8773
|
-
#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
8774
|
-
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
8775
|
-
unsigned char *bytes = (unsigned char *)&val;
|
|
8776
|
-
ret = _PyLong_AsByteArray((PyLongObject *)v,
|
|
8777
|
-
bytes, sizeof(val),
|
|
8778
|
-
is_little, !is_unsigned);
|
|
8779
|
-
#else
|
|
8780
|
-
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
8781
|
-
int bits, remaining_bits, is_negative = 0;
|
|
8782
|
-
long idigit;
|
|
8783
|
-
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
8784
|
-
if (unlikely(!PyLong_CheckExact(v))) {
|
|
8785
|
-
PyObject *tmp = v;
|
|
8786
|
-
v = PyNumber_Long(v);
|
|
8787
|
-
assert(PyLong_CheckExact(v));
|
|
8788
|
-
Py_DECREF(tmp);
|
|
8789
|
-
if (unlikely(!v)) return (int) -1;
|
|
8790
|
-
}
|
|
8791
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
8792
|
-
if (Py_SIZE(x) == 0)
|
|
8793
|
-
return (int) 0;
|
|
8794
|
-
is_negative = Py_SIZE(x) < 0;
|
|
8795
|
-
#else
|
|
8796
|
-
{
|
|
8797
|
-
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
8798
|
-
if (unlikely(result < 0))
|
|
8799
|
-
return (int) -1;
|
|
8800
|
-
is_negative = result == 1;
|
|
8801
|
-
}
|
|
8802
|
-
#endif
|
|
8803
|
-
if (is_unsigned && unlikely(is_negative)) {
|
|
8804
|
-
goto raise_neg_overflow;
|
|
8805
|
-
} else if (is_negative) {
|
|
8806
|
-
stepval = PyNumber_Invert(v);
|
|
8807
|
-
if (unlikely(!stepval))
|
|
8808
|
-
return (int) -1;
|
|
8809
|
-
} else {
|
|
8810
|
-
stepval = __Pyx_NewRef(v);
|
|
8811
|
-
}
|
|
8812
|
-
val = (int) 0;
|
|
8813
|
-
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
8814
|
-
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
8815
|
-
for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
|
|
8816
|
-
PyObject *tmp, *digit;
|
|
8817
|
-
digit = PyNumber_And(stepval, mask);
|
|
8818
|
-
if (unlikely(!digit)) goto done;
|
|
8819
|
-
idigit = PyLong_AsLong(digit);
|
|
8820
|
-
Py_DECREF(digit);
|
|
8821
|
-
if (unlikely(idigit < 0)) goto done;
|
|
8822
|
-
tmp = PyNumber_Rshift(stepval, shift);
|
|
8823
|
-
if (unlikely(!tmp)) goto done;
|
|
8824
|
-
Py_DECREF(stepval); stepval = tmp;
|
|
8825
|
-
val |= ((int) idigit) << bits;
|
|
8826
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
8827
|
-
if (Py_SIZE(stepval) == 0)
|
|
8828
|
-
goto unpacking_done;
|
|
8829
|
-
#endif
|
|
8830
|
-
}
|
|
8831
|
-
idigit = PyLong_AsLong(stepval);
|
|
8832
|
-
if (unlikely(idigit < 0)) goto done;
|
|
8833
|
-
remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
8834
|
-
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
8835
|
-
goto raise_overflow;
|
|
8836
|
-
val |= ((int) idigit) << bits;
|
|
8837
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
8838
|
-
unpacking_done:
|
|
8839
|
-
#endif
|
|
8840
|
-
if (!is_unsigned) {
|
|
8841
|
-
if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
|
|
8842
|
-
goto raise_overflow;
|
|
8843
|
-
if (is_negative)
|
|
8844
|
-
val = ~val;
|
|
8845
|
-
}
|
|
8846
|
-
ret = 0;
|
|
8847
|
-
done:
|
|
8848
|
-
Py_XDECREF(shift);
|
|
8849
|
-
Py_XDECREF(mask);
|
|
8850
|
-
Py_XDECREF(stepval);
|
|
8851
|
-
#endif
|
|
8810
|
+
int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
|
|
8811
|
+
if (unlikely(result < 0)) {
|
|
8852
8812
|
Py_DECREF(v);
|
|
8853
|
-
|
|
8854
|
-
return val;
|
|
8813
|
+
return (int) -1;
|
|
8855
8814
|
}
|
|
8856
|
-
|
|
8815
|
+
is_negative = result == 1;
|
|
8857
8816
|
}
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8817
|
+
if (is_unsigned && unlikely(is_negative)) {
|
|
8818
|
+
Py_DECREF(v);
|
|
8819
|
+
goto raise_neg_overflow;
|
|
8820
|
+
} else if (is_negative) {
|
|
8821
|
+
stepval = PyNumber_Invert(v);
|
|
8822
|
+
Py_DECREF(v);
|
|
8823
|
+
if (unlikely(!stepval))
|
|
8824
|
+
return (int) -1;
|
|
8825
|
+
} else {
|
|
8826
|
+
stepval = v;
|
|
8827
|
+
}
|
|
8828
|
+
v = NULL;
|
|
8829
|
+
val = (int) 0;
|
|
8830
|
+
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
8831
|
+
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
8832
|
+
for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
|
|
8833
|
+
PyObject *tmp, *digit;
|
|
8834
|
+
long idigit;
|
|
8835
|
+
digit = PyNumber_And(stepval, mask);
|
|
8836
|
+
if (unlikely(!digit)) goto done;
|
|
8837
|
+
idigit = PyLong_AsLong(digit);
|
|
8838
|
+
Py_DECREF(digit);
|
|
8839
|
+
if (unlikely(idigit < 0)) goto done;
|
|
8840
|
+
val |= ((int) idigit) << bits;
|
|
8841
|
+
tmp = PyNumber_Rshift(stepval, shift);
|
|
8842
|
+
if (unlikely(!tmp)) goto done;
|
|
8843
|
+
Py_DECREF(stepval); stepval = tmp;
|
|
8844
|
+
}
|
|
8845
|
+
Py_DECREF(shift); shift = NULL;
|
|
8846
|
+
Py_DECREF(mask); mask = NULL;
|
|
8847
|
+
{
|
|
8848
|
+
long idigit = PyLong_AsLong(stepval);
|
|
8849
|
+
if (unlikely(idigit < 0)) goto done;
|
|
8850
|
+
remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
8851
|
+
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
8852
|
+
goto raise_overflow;
|
|
8853
|
+
val |= ((int) idigit) << bits;
|
|
8854
|
+
}
|
|
8855
|
+
if (!is_unsigned) {
|
|
8856
|
+
if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
|
|
8857
|
+
goto raise_overflow;
|
|
8858
|
+
if (is_negative)
|
|
8859
|
+
val = ~val;
|
|
8860
|
+
}
|
|
8861
|
+
ret = 0;
|
|
8862
|
+
done:
|
|
8863
|
+
Py_XDECREF(shift);
|
|
8864
|
+
Py_XDECREF(mask);
|
|
8865
|
+
Py_XDECREF(stepval);
|
|
8866
|
+
#endif
|
|
8867
|
+
if (unlikely(ret))
|
|
8868
|
+
return (int) -1;
|
|
8864
8869
|
return val;
|
|
8865
8870
|
}
|
|
8866
8871
|
raise_overflow:
|
|
@@ -8904,12 +8909,19 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
|
|
|
8904
8909
|
}
|
|
8905
8910
|
}
|
|
8906
8911
|
{
|
|
8907
|
-
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
8908
8912
|
unsigned char *bytes = (unsigned char *)&value;
|
|
8909
|
-
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX
|
|
8913
|
+
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
|
|
8914
|
+
if (is_unsigned) {
|
|
8915
|
+
return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
|
|
8916
|
+
} else {
|
|
8917
|
+
return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
|
|
8918
|
+
}
|
|
8919
|
+
#elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
|
|
8920
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
8910
8921
|
return _PyLong_FromByteArray(bytes, sizeof(int),
|
|
8911
8922
|
little, !is_unsigned);
|
|
8912
8923
|
#else
|
|
8924
|
+
int one = 1; int little = (int)*(unsigned char *)&one;
|
|
8913
8925
|
PyObject *from_bytes, *result = NULL;
|
|
8914
8926
|
PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL;
|
|
8915
8927
|
from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
|
|
@@ -8975,245 +8987,239 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
|
|
|
8975
8987
|
}
|
|
8976
8988
|
return (long) val;
|
|
8977
8989
|
}
|
|
8978
|
-
}
|
|
8990
|
+
}
|
|
8979
8991
|
#endif
|
|
8980
|
-
if (
|
|
8981
|
-
|
|
8992
|
+
if (unlikely(!PyLong_Check(x))) {
|
|
8993
|
+
long val;
|
|
8994
|
+
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
|
|
8995
|
+
if (!tmp) return (long) -1;
|
|
8996
|
+
val = __Pyx_PyInt_As_long(tmp);
|
|
8997
|
+
Py_DECREF(tmp);
|
|
8998
|
+
return val;
|
|
8999
|
+
}
|
|
9000
|
+
if (is_unsigned) {
|
|
8982
9001
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
}
|
|
9002
|
+
if (unlikely(__Pyx_PyLong_IsNeg(x))) {
|
|
9003
|
+
goto raise_neg_overflow;
|
|
9004
|
+
} else if (__Pyx_PyLong_IsCompact(x)) {
|
|
9005
|
+
__PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
|
|
9006
|
+
} else {
|
|
9007
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
9008
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
9009
|
+
switch (__Pyx_PyLong_DigitCount(x)) {
|
|
9010
|
+
case 2:
|
|
9011
|
+
if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
|
|
9012
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
9013
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
9014
|
+
} else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
|
|
9015
|
+
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
8998
9016
|
}
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9017
|
+
}
|
|
9018
|
+
break;
|
|
9019
|
+
case 3:
|
|
9020
|
+
if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
|
|
9021
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
9022
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
9023
|
+
} else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
|
|
9024
|
+
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
9007
9025
|
}
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9026
|
+
}
|
|
9027
|
+
break;
|
|
9028
|
+
case 4:
|
|
9029
|
+
if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
|
|
9030
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
9031
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
9032
|
+
} else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
|
|
9033
|
+
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
|
|
9016
9034
|
}
|
|
9017
|
-
|
|
9018
|
-
|
|
9035
|
+
}
|
|
9036
|
+
break;
|
|
9019
9037
|
}
|
|
9038
|
+
}
|
|
9020
9039
|
#endif
|
|
9021
9040
|
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9041
|
+
if (unlikely(Py_SIZE(x) < 0)) {
|
|
9042
|
+
goto raise_neg_overflow;
|
|
9043
|
+
}
|
|
9025
9044
|
#else
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9045
|
+
{
|
|
9046
|
+
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
9047
|
+
if (unlikely(result < 0))
|
|
9048
|
+
return (long) -1;
|
|
9049
|
+
if (unlikely(result == 1))
|
|
9050
|
+
goto raise_neg_overflow;
|
|
9051
|
+
}
|
|
9033
9052
|
#endif
|
|
9034
|
-
|
|
9035
|
-
|
|
9053
|
+
if ((sizeof(long) <= sizeof(unsigned long))) {
|
|
9054
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
|
|
9036
9055
|
#ifdef HAVE_LONG_LONG
|
|
9037
|
-
|
|
9038
|
-
|
|
9056
|
+
} else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
|
|
9057
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
|
|
9039
9058
|
#endif
|
|
9040
|
-
|
|
9041
|
-
|
|
9059
|
+
}
|
|
9060
|
+
} else {
|
|
9042
9061
|
#if CYTHON_USE_PYLONG_INTERNALS
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
}
|
|
9062
|
+
if (__Pyx_PyLong_IsCompact(x)) {
|
|
9063
|
+
__PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
|
|
9064
|
+
} else {
|
|
9065
|
+
const digit* digits = __Pyx_PyLong_Digits(x);
|
|
9066
|
+
assert(__Pyx_PyLong_DigitCount(x) > 1);
|
|
9067
|
+
switch (__Pyx_PyLong_SignedDigitCount(x)) {
|
|
9068
|
+
case -2:
|
|
9069
|
+
if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
|
|
9070
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
9071
|
+
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
9072
|
+
} else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
9073
|
+
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
9056
9074
|
}
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9075
|
+
}
|
|
9076
|
+
break;
|
|
9077
|
+
case 2:
|
|
9078
|
+
if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
|
|
9079
|
+
if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
|
|
9080
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
9081
|
+
} else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
9082
|
+
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
9065
9083
|
}
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9084
|
+
}
|
|
9085
|
+
break;
|
|
9086
|
+
case -3:
|
|
9087
|
+
if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
|
|
9088
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
9089
|
+
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
9090
|
+
} else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
9091
|
+
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
9074
9092
|
}
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9093
|
+
}
|
|
9094
|
+
break;
|
|
9095
|
+
case 3:
|
|
9096
|
+
if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
|
|
9097
|
+
if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
|
|
9098
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
9099
|
+
} else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
9100
|
+
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
9083
9101
|
}
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9102
|
+
}
|
|
9103
|
+
break;
|
|
9104
|
+
case -4:
|
|
9105
|
+
if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
|
|
9106
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
9107
|
+
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
9108
|
+
} else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
|
|
9109
|
+
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
9092
9110
|
}
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9111
|
+
}
|
|
9112
|
+
break;
|
|
9113
|
+
case 4:
|
|
9114
|
+
if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
|
|
9115
|
+
if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
|
|
9116
|
+
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
|
|
9117
|
+
} else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
|
|
9118
|
+
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
|
|
9101
9119
|
}
|
|
9102
|
-
|
|
9103
|
-
|
|
9120
|
+
}
|
|
9121
|
+
break;
|
|
9104
9122
|
}
|
|
9123
|
+
}
|
|
9105
9124
|
#endif
|
|
9106
|
-
|
|
9107
|
-
|
|
9125
|
+
if ((sizeof(long) <= sizeof(long))) {
|
|
9126
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
|
|
9108
9127
|
#ifdef HAVE_LONG_LONG
|
|
9109
|
-
|
|
9110
|
-
|
|
9128
|
+
} else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
|
|
9129
|
+
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
|
|
9111
9130
|
#endif
|
|
9112
|
-
|
|
9131
|
+
}
|
|
9132
|
+
}
|
|
9133
|
+
{
|
|
9134
|
+
long val;
|
|
9135
|
+
int ret = -1;
|
|
9136
|
+
#if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
|
|
9137
|
+
Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
|
|
9138
|
+
x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
|
|
9139
|
+
if (unlikely(bytes_copied == -1)) {
|
|
9140
|
+
} else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
|
|
9141
|
+
goto raise_overflow;
|
|
9142
|
+
} else {
|
|
9143
|
+
ret = 0;
|
|
9144
|
+
}
|
|
9145
|
+
#elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
9146
|
+
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
9147
|
+
unsigned char *bytes = (unsigned char *)&val;
|
|
9148
|
+
ret = _PyLong_AsByteArray((PyLongObject *)x,
|
|
9149
|
+
bytes, sizeof(val),
|
|
9150
|
+
is_little, !is_unsigned);
|
|
9151
|
+
#else
|
|
9152
|
+
PyObject *v;
|
|
9153
|
+
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
9154
|
+
int bits, remaining_bits, is_negative = 0;
|
|
9155
|
+
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
9156
|
+
if (likely(PyLong_CheckExact(x))) {
|
|
9157
|
+
v = __Pyx_NewRef(x);
|
|
9158
|
+
} else {
|
|
9159
|
+
v = PyNumber_Long(x);
|
|
9160
|
+
if (unlikely(!v)) return (long) -1;
|
|
9161
|
+
assert(PyLong_CheckExact(v));
|
|
9113
9162
|
}
|
|
9114
9163
|
{
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
#if PY_MAJOR_VERSION < 3
|
|
9118
|
-
if (likely(v) && !PyLong_Check(v)) {
|
|
9119
|
-
PyObject *tmp = v;
|
|
9120
|
-
v = PyNumber_Long(tmp);
|
|
9121
|
-
Py_DECREF(tmp);
|
|
9122
|
-
}
|
|
9123
|
-
#endif
|
|
9124
|
-
if (likely(v)) {
|
|
9125
|
-
int ret = -1;
|
|
9126
|
-
#if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
|
|
9127
|
-
int one = 1; int is_little = (int)*(unsigned char *)&one;
|
|
9128
|
-
unsigned char *bytes = (unsigned char *)&val;
|
|
9129
|
-
ret = _PyLong_AsByteArray((PyLongObject *)v,
|
|
9130
|
-
bytes, sizeof(val),
|
|
9131
|
-
is_little, !is_unsigned);
|
|
9132
|
-
#else
|
|
9133
|
-
PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
|
|
9134
|
-
int bits, remaining_bits, is_negative = 0;
|
|
9135
|
-
long idigit;
|
|
9136
|
-
int chunk_size = (sizeof(long) < 8) ? 30 : 62;
|
|
9137
|
-
if (unlikely(!PyLong_CheckExact(v))) {
|
|
9138
|
-
PyObject *tmp = v;
|
|
9139
|
-
v = PyNumber_Long(v);
|
|
9140
|
-
assert(PyLong_CheckExact(v));
|
|
9141
|
-
Py_DECREF(tmp);
|
|
9142
|
-
if (unlikely(!v)) return (long) -1;
|
|
9143
|
-
}
|
|
9144
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
9145
|
-
if (Py_SIZE(x) == 0)
|
|
9146
|
-
return (long) 0;
|
|
9147
|
-
is_negative = Py_SIZE(x) < 0;
|
|
9148
|
-
#else
|
|
9149
|
-
{
|
|
9150
|
-
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
|
|
9151
|
-
if (unlikely(result < 0))
|
|
9152
|
-
return (long) -1;
|
|
9153
|
-
is_negative = result == 1;
|
|
9154
|
-
}
|
|
9155
|
-
#endif
|
|
9156
|
-
if (is_unsigned && unlikely(is_negative)) {
|
|
9157
|
-
goto raise_neg_overflow;
|
|
9158
|
-
} else if (is_negative) {
|
|
9159
|
-
stepval = PyNumber_Invert(v);
|
|
9160
|
-
if (unlikely(!stepval))
|
|
9161
|
-
return (long) -1;
|
|
9162
|
-
} else {
|
|
9163
|
-
stepval = __Pyx_NewRef(v);
|
|
9164
|
-
}
|
|
9165
|
-
val = (long) 0;
|
|
9166
|
-
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
9167
|
-
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
9168
|
-
for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
|
|
9169
|
-
PyObject *tmp, *digit;
|
|
9170
|
-
digit = PyNumber_And(stepval, mask);
|
|
9171
|
-
if (unlikely(!digit)) goto done;
|
|
9172
|
-
idigit = PyLong_AsLong(digit);
|
|
9173
|
-
Py_DECREF(digit);
|
|
9174
|
-
if (unlikely(idigit < 0)) goto done;
|
|
9175
|
-
tmp = PyNumber_Rshift(stepval, shift);
|
|
9176
|
-
if (unlikely(!tmp)) goto done;
|
|
9177
|
-
Py_DECREF(stepval); stepval = tmp;
|
|
9178
|
-
val |= ((long) idigit) << bits;
|
|
9179
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
9180
|
-
if (Py_SIZE(stepval) == 0)
|
|
9181
|
-
goto unpacking_done;
|
|
9182
|
-
#endif
|
|
9183
|
-
}
|
|
9184
|
-
idigit = PyLong_AsLong(stepval);
|
|
9185
|
-
if (unlikely(idigit < 0)) goto done;
|
|
9186
|
-
remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
9187
|
-
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
9188
|
-
goto raise_overflow;
|
|
9189
|
-
val |= ((long) idigit) << bits;
|
|
9190
|
-
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000
|
|
9191
|
-
unpacking_done:
|
|
9192
|
-
#endif
|
|
9193
|
-
if (!is_unsigned) {
|
|
9194
|
-
if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
|
|
9195
|
-
goto raise_overflow;
|
|
9196
|
-
if (is_negative)
|
|
9197
|
-
val = ~val;
|
|
9198
|
-
}
|
|
9199
|
-
ret = 0;
|
|
9200
|
-
done:
|
|
9201
|
-
Py_XDECREF(shift);
|
|
9202
|
-
Py_XDECREF(mask);
|
|
9203
|
-
Py_XDECREF(stepval);
|
|
9204
|
-
#endif
|
|
9164
|
+
int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
|
|
9165
|
+
if (unlikely(result < 0)) {
|
|
9205
9166
|
Py_DECREF(v);
|
|
9206
|
-
|
|
9207
|
-
return val;
|
|
9167
|
+
return (long) -1;
|
|
9208
9168
|
}
|
|
9209
|
-
|
|
9169
|
+
is_negative = result == 1;
|
|
9210
9170
|
}
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9171
|
+
if (is_unsigned && unlikely(is_negative)) {
|
|
9172
|
+
Py_DECREF(v);
|
|
9173
|
+
goto raise_neg_overflow;
|
|
9174
|
+
} else if (is_negative) {
|
|
9175
|
+
stepval = PyNumber_Invert(v);
|
|
9176
|
+
Py_DECREF(v);
|
|
9177
|
+
if (unlikely(!stepval))
|
|
9178
|
+
return (long) -1;
|
|
9179
|
+
} else {
|
|
9180
|
+
stepval = v;
|
|
9181
|
+
}
|
|
9182
|
+
v = NULL;
|
|
9183
|
+
val = (long) 0;
|
|
9184
|
+
mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
|
|
9185
|
+
shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
|
|
9186
|
+
for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
|
|
9187
|
+
PyObject *tmp, *digit;
|
|
9188
|
+
long idigit;
|
|
9189
|
+
digit = PyNumber_And(stepval, mask);
|
|
9190
|
+
if (unlikely(!digit)) goto done;
|
|
9191
|
+
idigit = PyLong_AsLong(digit);
|
|
9192
|
+
Py_DECREF(digit);
|
|
9193
|
+
if (unlikely(idigit < 0)) goto done;
|
|
9194
|
+
val |= ((long) idigit) << bits;
|
|
9195
|
+
tmp = PyNumber_Rshift(stepval, shift);
|
|
9196
|
+
if (unlikely(!tmp)) goto done;
|
|
9197
|
+
Py_DECREF(stepval); stepval = tmp;
|
|
9198
|
+
}
|
|
9199
|
+
Py_DECREF(shift); shift = NULL;
|
|
9200
|
+
Py_DECREF(mask); mask = NULL;
|
|
9201
|
+
{
|
|
9202
|
+
long idigit = PyLong_AsLong(stepval);
|
|
9203
|
+
if (unlikely(idigit < 0)) goto done;
|
|
9204
|
+
remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
|
|
9205
|
+
if (unlikely(idigit >= (1L << remaining_bits)))
|
|
9206
|
+
goto raise_overflow;
|
|
9207
|
+
val |= ((long) idigit) << bits;
|
|
9208
|
+
}
|
|
9209
|
+
if (!is_unsigned) {
|
|
9210
|
+
if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
|
|
9211
|
+
goto raise_overflow;
|
|
9212
|
+
if (is_negative)
|
|
9213
|
+
val = ~val;
|
|
9214
|
+
}
|
|
9215
|
+
ret = 0;
|
|
9216
|
+
done:
|
|
9217
|
+
Py_XDECREF(shift);
|
|
9218
|
+
Py_XDECREF(mask);
|
|
9219
|
+
Py_XDECREF(stepval);
|
|
9220
|
+
#endif
|
|
9221
|
+
if (unlikely(ret))
|
|
9222
|
+
return (long) -1;
|
|
9217
9223
|
return val;
|
|
9218
9224
|
}
|
|
9219
9225
|
raise_overflow:
|