Completed
Push — 0.7.dev ( 0c7dff...8e244d )
by Andrei
59s
created

sync_get_size()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
"""!
2
3
@brief CCORE Wrapper for oscillatory neural network based on Kuramoto model.
4
5
@authors Andrei Novikov ([email protected])
6
@date 2014-2017
7
@copyright GNU Public License
8
9
@cond GNU_PUBLIC_LICENSE
10
    PyClustering is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
    
15
    PyClustering is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
    
20
    You should have received a copy of the GNU General Public License
21
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
@endcond
23
24
"""
25
26
27
from pyclustering.core.wrapper import *;
0 ignored issues
show
Unused Code introduced by
c_int was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Structure was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
pointer was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
cast was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_short was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
DllCanUnloadNow was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_ushort was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_int32 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_ulonglong was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
pydll was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_ubyte was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
oledll was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_longdouble was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
PATH_PYCLUSTERING_CCORE_LIBRARY was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_wchar_p was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_wchar was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
resize was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_uint32 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
sys was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_char was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_uint64 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
get_last_error was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
memset was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_ssize_t was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_byte was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
data_representation was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
set_errno was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
OleDLL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
DllGetClassObject was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
ARRAY was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
CFUNCTYPE was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
pythonapi was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_int64 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
sizeof was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
wstring_at was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_int16 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
py_object was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
ArgumentError was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
core was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
WinDLL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
PyDLL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
RTLD_LOCAL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
DEFAULT_MODE was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_int8 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
create_unicode_buffer was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Union was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
GetLastError was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
memmove was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
byref was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
cdll was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
SetPointerType was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_buffer was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
CDLL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_voidp was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
HRESULT was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_uint16 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
RTLD_GLOBAL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
LibraryLoader was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
LittleEndianStructure was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
get_errno was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_uint8 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_char_p was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
FormatError was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
PYFUNCTYPE was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
alignment was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Array was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
kind was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
WinError was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_longlong was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
string_at was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
windll was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
os was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
set_last_error was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
addressof was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
create_string_buffer was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
BigEndianStructure was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_long was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_ulong was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_float was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
WINFUNCTYPE was imported with wildcard, but is not used.
Loading history...
28
from pyclustering.core.pyclustering_package import pyclustering_package, package_extractor;
29
30
31
def sync_create_network(num_osc, weight, frequency, type_conn, initial_phases):
32
    ccore = load_core();
33
    
34
    ccore.sync_create_network.restype = POINTER(c_void_p);
35
    pointer_network = ccore.sync_create_network(c_uint(num_osc), c_double(weight), c_double(frequency), c_uint(type_conn), c_uint(initial_phases));
36
    
37
    return pointer_network;
38
39
40
def sync_get_size(pointer_network):
41
    ccore = load_core();
42
    ccore.sync_get_size.restype = c_size_t;
43
    return ccore.sync_get_size(pointer_network);
44
45
46
def sync_destroy_network(pointer_network):
47
    ccore = load_core();
48
    ccore.sync_destroy_network(pointer_network);
49
50
51
def sync_simulate_static(pointer_network, steps, time, solution, collect_dynamic):
52
    ccore = load_core();
53
    ccore.sync_simulate_static.restype = POINTER(c_void_p);
54
    return ccore.sync_simulate_static(pointer_network, c_uint(steps), c_double(time), c_uint(solution), c_bool(collect_dynamic));
55
56
57
def sync_simulate_dynamic(pointer_network, order, solution, collect_dynamic, step, int_step, threshold_changes):
58
    ccore = load_core();
59
    ccore.sync_simulate_dynamic.restype = POINTER(c_void_p);
60
    return ccore.sync_simulate_dynamic(pointer_network, c_double(order), c_uint(solution), c_bool(collect_dynamic), c_double(step), c_double(int_step), c_double(threshold_changes));
61
62
63
def sync_order(pointer_network):
64
    ccore = load_core();
65
    ccore.sync_order.restype = c_double;
66
    
67
    return ccore.sync_order(pointer_network);
68
    
69
    
70
def sync_local_order(pointer_network):
71
    ccore = load_core();
72
    ccore.sync_local_order.restype = c_double;
73
    
74
    return ccore.sync_local_order(pointer_network);
75
76
77
def sync_connectivity_matrix(pointer_network):
78
    ccore = load_core();
79
    ccore.sync_connectivity_matrix.restype = POINTER(pyclustering_package);
80
    
81
    package = ccore.sync_connectivity_matrix(pointer_network);
82
    
83
    connectivity_matrix = package_extractor(package).extract();
84
    ccore.free_pyclustering_package(package);
85
    
86
    return connectivity_matrix;
87
88
89
def sync_dynamic_get_size(pointer_dynamic):
90
    ccore = load_core();
91
    ccore.sync_dynamic_get_time.restype = c_size_t;
92
    return ccore.sync_dynamic_get_size(pointer_dynamic);
93
94
95
def sync_dynamic_destroy(pointer_dynamic):
96
    ccore = load_core();
97
    ccore.sync_dynamic_destroy(pointer_dynamic);
98
99
100
def sync_dynamic_allocate_sync_ensembles(pointer_dynamic, tolerance, iteration):
101
    if (iteration is None):
102
        iteration = sync_dynamic_get_size(pointer_dynamic) - 1;
103
    
104
    ccore = load_core();
105
    
106
    ccore.sync_dynamic_allocate_sync_ensembles.restype = POINTER(pyclustering_package);
107
    package = ccore.sync_dynamic_allocate_sync_ensembles(pointer_dynamic, c_double(tolerance), c_size_t(iteration));
108
    
109
    result = package_extractor(package).extract();
110
    ccore.free_pyclustering_package(package);
111
    
112
    return result;
113
114
115
def sync_dynamic_allocate_correlation_matrix(pointer_dynamic, iteration):
116
    analyse_iteration = iteration;
117
    if (analyse_iteration is None):
118
        analyse_iteration = sync_dynamic_get_size(pointer_dynamic) - 1;
119
    
120
    ccore = load_core();
121
    
122
    ccore.sync_dynamic_allocate_correlation_matrix.restype = POINTER(pyclustering_package);
123
    package = ccore.sync_dynamic_allocate_correlation_matrix(pointer_dynamic, c_uint(analyse_iteration));
124
    
125
    result = package_extractor(package).extract();
126
    ccore.free_pyclustering_package(package);
127
    
128
    return result;
129
130
131
def sync_dynamic_get_output(pointer_dynamic):
132
    ccore = load_core();
133
    
134
    ccore.sync_dynamic_get_output.restype = POINTER(pyclustering_package);
135
    package = ccore.sync_dynamic_get_output(pointer_dynamic);
136
    
137
    result = package_extractor(package).extract();
138
    ccore.free_pyclustering_package(package);
139
    
140
    return result;
141
142
143
def sync_dynamic_get_time(pointer_dynamic):
144
    ccore = load_core();
145
    
146
    ccore.sync_dynamic_get_time.restype = POINTER(pyclustering_package);
147
    package = ccore.sync_dynamic_get_time(pointer_dynamic);
148
    
149
    result = package_extractor(package).extract();
150
    ccore.free_pyclustering_package(package);
151
    
152
    return result;
153