piegy 2.1.0__cp311-cp311-macosx_11_0_arm64.whl → 2.1.9__cp311-cp311-macosx_11_0_arm64.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.
- piegy/C_core/Makefile +17 -20
- piegy/C_core/piegyc.cpython-311-darwin.so +0 -0
- piegy/__init__.py +1 -0
- piegy/__version__.py +3 -1
- piegy/build_info.py +12 -0
- piegy/find_C.py +17 -0
- piegy/simulation.py +29 -20
- piegy/simulation_py.py +1 -2
- {piegy-2.1.0.dist-info → piegy-2.1.9.dist-info}/METADATA +2 -2
- {piegy-2.1.0.dist-info → piegy-2.1.9.dist-info}/RECORD +29 -27
- {piegy-2.1.0.dist-info → piegy-2.1.9.dist-info}/WHEEL +1 -0
- {piegy-2.1.0.dist-info → piegy-2.1.9.dist-info}/licenses/LICENSE.txt +0 -0
- {piegy-2.1.0.dist-info → piegy-2.1.9.dist-info}/top_level.txt +0 -0
piegy/C_core/Makefile
CHANGED
@@ -5,40 +5,36 @@ CC = gcc
|
|
5
5
|
|
6
6
|
## Flags for Max Speed ##
|
7
7
|
# standard
|
8
|
-
CFLAGS_COMMON = -O3 -flto -std=c99 -DNDEBUG -ffp-contract=fast
|
8
|
+
CFLAGS_COMMON = -O3 -flto -std=c99 -DNDEBUG -ffp-contract=fast -MMD -MP
|
9
9
|
LDFLAGS_COMMON = -flto
|
10
10
|
|
11
11
|
## Flags for Debugging ##
|
12
12
|
# slower, debuggable with lldb, with Address Sanitizer. Don't use in python
|
13
|
-
#CFLAGS = -g -std=c99 -Wall -Wextra -fsanitize=address,undefined -fno-omit-frame-pointer
|
13
|
+
#CFLAGS = -g -std=c99 -Wall -Wextra -MMD -MP -fsanitize=address,undefined -fno-omit-frame-pointer
|
14
14
|
#LDFLAGS = -fsanitize=address,undefined
|
15
15
|
# slower, regular build, allow lldb
|
16
|
-
#CFLAGS = -g -std=c99 -Wall -Wextra
|
16
|
+
#CFLAGS = -g -std=c99 -Wall -Wextra -MMD -MP
|
17
17
|
#LDFLAGS =
|
18
18
|
|
19
|
-
# Enable auto header dependency tracking
|
20
|
-
DEPFLAGS = -MMD -MP
|
21
|
-
CFLAGS += $(DEPFLAGS)
|
22
|
-
|
23
19
|
|
24
20
|
#### OS specific ####
|
25
|
-
|
21
|
+
OS := $(shell uname)
|
26
22
|
|
27
|
-
ifeq ($(
|
28
|
-
# macOS
|
29
|
-
CFLAGS = $(CFLAGS_COMMON) -fPIC -mmacosx-version-min=11.0 -arch arm64
|
23
|
+
ifeq ($(OS),Darwin)
|
24
|
+
# macOS flags
|
25
|
+
CFLAGS = $(CFLAGS_COMMON) -fPIC -mmacosx-version-min=11.0 -arch arm64
|
30
26
|
LDFLAGS = $(LDFLAGS_COMMON)
|
31
|
-
else ifeq ($(
|
32
|
-
# Linux
|
33
|
-
CFLAGS = $(CFLAGS_COMMON) -fPIC
|
27
|
+
else ifeq ($(OS),Linux)
|
28
|
+
# Linux flags
|
29
|
+
CFLAGS = $(CFLAGS_COMMON) -fPIC
|
34
30
|
LDFLAGS = $(LDFLAGS_COMMON)
|
35
|
-
else ifeq
|
36
|
-
#
|
37
|
-
CFLAGS = $(CFLAGS_COMMON) -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00
|
31
|
+
else ifeq '$(findstring ;,$(PATH))' ';'
|
32
|
+
# windows flags
|
33
|
+
CFLAGS = $(CFLAGS_COMMON) -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00
|
38
34
|
LDFLAGS = $(LDFLAGS_COMMON)
|
39
35
|
else
|
40
36
|
# Default fallback
|
41
|
-
CFLAGS = $(CFLAGS_COMMON) -fPIC
|
37
|
+
CFLAGS = $(CFLAGS_COMMON) -fPIC
|
42
38
|
LDFLAGS = $(LDFLAGS_COMMON)
|
43
39
|
endif
|
44
40
|
|
@@ -56,7 +52,8 @@ DEPS = $(OBJ:.o=.d) $(RUNNER_DEPS)
|
|
56
52
|
|
57
53
|
# Executable name
|
58
54
|
TEST = runner
|
59
|
-
ifeq
|
55
|
+
ifeq '$(findstring ;,$(PATH))' ';'
|
56
|
+
# windows
|
60
57
|
SHARED_LIB = piegyc.dll
|
61
58
|
else
|
62
59
|
SHARED_LIB = piegyc.so
|
@@ -82,7 +79,7 @@ $(SHARED_LIB): $(OBJ)
|
|
82
79
|
|
83
80
|
# Compile source files to object files
|
84
81
|
%.o: %.c
|
85
|
-
$(CC) $(CFLAGS)
|
82
|
+
$(CC) $(CFLAGS) -c $< -o $@
|
86
83
|
|
87
84
|
# Clean build files
|
88
85
|
clean:
|
Binary file
|
piegy/__init__.py
CHANGED
piegy/__version__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
__version__ = '2.1.
|
1
|
+
__version__ = '2.1.9'
|
2
2
|
|
3
3
|
'''
|
4
4
|
version history:
|
@@ -28,4 +28,6 @@ version history:
|
|
28
28
|
2.0.4: minor debuggings.
|
29
29
|
2.0.5: fix error in random number generator.
|
30
30
|
2.1.0: redo random number generator. Update package upload so that more compatible across platforms.
|
31
|
+
2.1.1: fix import bug for the C core.
|
32
|
+
2.1.2 ~ 2.1.9: updating & fixing wheel.
|
31
33
|
'''
|
piegy/build_info.py
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
"""
|
2
|
+
Contains build info, whether it's local built, or a pre-compiled wheel.
|
3
|
+
Auto-generated at compile time.
|
4
|
+
"""
|
5
|
+
|
6
|
+
build_info = {
|
7
|
+
"version": "2.1.9",
|
8
|
+
"built from": "local machine",
|
9
|
+
"build date": "2025-06-28 08:59:55",
|
10
|
+
"python version": "3.11.9",
|
11
|
+
"platform": "darwin"
|
12
|
+
}
|
piegy/find_C.py
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
'''
|
2
|
+
This module is used to find the C core
|
3
|
+
'''
|
4
|
+
|
5
|
+
import os
|
6
|
+
|
7
|
+
|
8
|
+
def find_C():
|
9
|
+
C_core_path = os.path.join(os.path.dirname(__file__), 'C_core')
|
10
|
+
C_list = os.listdir(C_core_path)
|
11
|
+
for file in C_list:
|
12
|
+
if file[-3:] == '.so':
|
13
|
+
return C_core_path + '/' + file
|
14
|
+
if file[-4:] == '.pyd':
|
15
|
+
return C_core_path + '/' + file
|
16
|
+
|
17
|
+
raise FileNotFoundError('C computation core not found. You can either compile manully or use the Python core instead. Please see docs.')
|
piegy/simulation.py
CHANGED
@@ -12,6 +12,7 @@ Class & Functions:
|
|
12
12
|
- check_overflow_func: check whether an overflow might happen in simulation. This is usually done automatically when init-ing a model.
|
13
13
|
'''
|
14
14
|
|
15
|
+
from . import find_C
|
15
16
|
|
16
17
|
import numpy as np
|
17
18
|
import os
|
@@ -21,14 +22,15 @@ import numpy as np
|
|
21
22
|
from numpy.ctypeslib import ndpointer
|
22
23
|
|
23
24
|
|
24
|
-
# path to the C shared libary
|
25
|
-
C_LIB_PATH = os.path.join(os.path.dirname(__file__), 'C_core', 'piegyc.so')
|
26
|
-
|
27
25
|
# check whether overflow / too large values might be encountered
|
28
26
|
# these values are considered as exponents in exp()
|
29
27
|
EXP_OVERFLOW_BOUND = 709 # where exp(x) reaches overflow bound
|
30
28
|
EXP_TOO_LARGE_BOUND = 88 # where exp(x) reaches 1e20
|
31
29
|
|
30
|
+
# read the C core into LIB
|
31
|
+
# initialized upon first run
|
32
|
+
LIB = None
|
33
|
+
|
32
34
|
|
33
35
|
'''
|
34
36
|
The C core
|
@@ -69,23 +71,28 @@ class model_c(ctypes.Structure):
|
|
69
71
|
ptr = getattr(self, name)
|
70
72
|
return np.ctypeslib.as_array(ptr, shape=(self.arr_size,))
|
71
73
|
|
72
|
-
lib = ctypes.CDLL(C_LIB_PATH, winmode = 0)
|
73
|
-
lib.mod_init.argtypes = [
|
74
|
-
ctypes.POINTER(model_c), c_size_t, c_size_t,
|
75
|
-
c_double, c_double, c_size_t, c_bool,
|
76
|
-
ndpointer(dtype=np.uint32, flags="C_CONTIGUOUS"),
|
77
|
-
ndpointer(dtype=np.float64, flags="C_CONTIGUOUS"),
|
78
|
-
ndpointer(dtype=np.float64, flags="C_CONTIGUOUS"),
|
79
|
-
c_int32, c_int32
|
80
|
-
]
|
81
|
-
lib.mod_init.restype = c_bool
|
82
74
|
|
83
|
-
|
84
|
-
|
75
|
+
def read_lib():
|
76
|
+
global LIB
|
77
|
+
if LIB != None:
|
78
|
+
return
|
79
|
+
|
80
|
+
LIB = ctypes.CDLL(find_C.find_C(), winmode = 0)
|
81
|
+
LIB.mod_init.argtypes = [
|
82
|
+
ctypes.POINTER(model_c), c_size_t, c_size_t,
|
83
|
+
c_double, c_double, c_size_t, c_bool,
|
84
|
+
ndpointer(dtype=np.uint32, flags="C_CONTIGUOUS"),
|
85
|
+
ndpointer(dtype=np.float64, flags="C_CONTIGUOUS"),
|
86
|
+
ndpointer(dtype=np.float64, flags="C_CONTIGUOUS"),
|
87
|
+
c_int32, c_int32
|
88
|
+
]
|
89
|
+
LIB.mod_init.restype = c_bool
|
85
90
|
|
86
|
-
|
87
|
-
|
91
|
+
LIB.mod_free_py.argtypes = [ctypes.POINTER(model_c)]
|
92
|
+
LIB.mod_free_py.restype = None
|
88
93
|
|
94
|
+
LIB.run.argtypes = [ctypes.POINTER(model_c), ctypes.POINTER(c_char), c_size_t]
|
95
|
+
LIB.run.restype = None
|
89
96
|
|
90
97
|
|
91
98
|
|
@@ -396,6 +403,8 @@ def run(mod, message = ""):
|
|
396
403
|
C-cored simulation
|
397
404
|
'''
|
398
405
|
|
406
|
+
read_lib()
|
407
|
+
|
399
408
|
if not mod.data_empty:
|
400
409
|
raise ValueError('mod has non-empty data.')
|
401
410
|
|
@@ -408,20 +417,20 @@ def run(mod, message = ""):
|
|
408
417
|
P = np.ascontiguousarray(mod.P.flatten(), dtype = np.float64)
|
409
418
|
|
410
419
|
mod_c = model_c()
|
411
|
-
success =
|
420
|
+
success = LIB.mod_init(ctypes.byref(mod_c),
|
412
421
|
mod.N, mod.M, mod.maxtime, mod.record_itv, mod.sim_time, mod.boundary,
|
413
422
|
I, X, P, mod.print_pct, mod.seed)
|
414
423
|
if not success:
|
415
424
|
raise RuntimeError('mod_init failed')
|
416
425
|
|
417
|
-
|
426
|
+
LIB.run(ctypes.byref(mod_c), msg_buffer, msg_len)
|
418
427
|
|
419
428
|
mod.set_data(False, mod.max_record, 1, mod_c.get_array('U1d').reshape(mod.N, mod.M, mod.max_record),
|
420
429
|
mod_c.get_array('V1d').reshape(mod.N, mod.M, mod.max_record),
|
421
430
|
mod_c.get_array('Upi_1d').reshape(mod.N, mod.M, mod.max_record),
|
422
431
|
mod_c.get_array('Vpi_1d').reshape(mod.N, mod.M, mod.max_record))
|
423
432
|
|
424
|
-
|
433
|
+
LIB.mod_free_py(ctypes.byref(mod_c))
|
425
434
|
del mod_c
|
426
435
|
|
427
436
|
|
piegy/simulation_py.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: piegy
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.9
|
4
4
|
Summary: Payoff-Driven Stochastic Spatial Model for Evolutionary Game Theory
|
5
5
|
Author-email: Chenning Xu <cxu7@caltech.edu>
|
6
6
|
License: BSD 3-Clause License
|
@@ -44,7 +44,7 @@ Classifier: Programming Language :: Python :: 3
|
|
44
44
|
Classifier: Programming Language :: Python :: 3.10
|
45
45
|
Classifier: Programming Language :: Python :: 3.11
|
46
46
|
Classifier: Operating System :: OS Independent
|
47
|
-
Requires-Python: >=3.
|
47
|
+
Requires-Python: >=3.7
|
48
48
|
Description-Content-Type: text/markdown
|
49
49
|
License-File: LICENSE.txt
|
50
50
|
Requires-Dist: numpy
|
@@ -1,27 +1,29 @@
|
|
1
|
-
piegy/
|
2
|
-
piegy/
|
3
|
-
piegy/analysis.py,sha256=2GBsBbi7LdstSEAM0-F2bfL2kHu3MElcrw8bxZ1x6LI,8719
|
4
|
-
piegy/data_tools.py,sha256=auliVb88qKQmCX7LEDgKQvhBcwFTCXBEWKtjJ4_-rTU,3446
|
5
|
-
piegy/
|
6
|
-
piegy/
|
7
|
-
piegy/
|
8
|
-
piegy/test_var.py,sha256=EfItIK-FEApJTAW8rs15kdMs5xlv-8Bx6CtfpSoi8ys,23562
|
9
|
-
piegy/
|
10
|
-
piegy/
|
11
|
-
piegy/
|
12
|
-
piegy/C_core/
|
13
|
-
piegy/C_core/
|
14
|
-
piegy/C_core/
|
15
|
-
piegy/C_core/
|
16
|
-
piegy/C_core/
|
17
|
-
piegy/C_core/
|
18
|
-
piegy/C_core/
|
19
|
-
piegy/C_core/
|
20
|
-
piegy/
|
21
|
-
piegy/
|
22
|
-
piegy/tools/
|
23
|
-
piegy
|
24
|
-
piegy
|
25
|
-
piegy-2.1.
|
26
|
-
piegy-2.1.
|
27
|
-
piegy-2.1.
|
1
|
+
piegy/simulation.py,sha256=5hKtwQGXeMWdZLTSco83CYR5phP6jrOkNcrcfbe7-Z0,20035
|
2
|
+
piegy/find_C.py,sha256=sbPQ2oTDCoBb00woDZ9ppRJstUmJwLguh7TOpQpvBfY,496
|
3
|
+
piegy/analysis.py,sha256=2GBsBbi7LdstSEAM0-F2bfL2kHu3MElcrw8bxZ1x6LI,8719
|
4
|
+
piegy/data_tools.py,sha256=auliVb88qKQmCX7LEDgKQvhBcwFTCXBEWKtjJ4_-rTU,3446
|
5
|
+
piegy/__init__.py,sha256=VQcKA9Eg3hUJci2GV8fZjf9srZu9MPRc_LDVomaxowI,2117
|
6
|
+
piegy/__version__.py,sha256=LkXXuVOkNPwLDSdwo_RFSdJR9SxYMQMqy1subSveOMo,1624
|
7
|
+
piegy/figures.py,sha256=GwixvD3Flaqg4feSvqr42lDR7CwZK0_2qmZg6N6_1uE,17936
|
8
|
+
piegy/test_var.py,sha256=EfItIK-FEApJTAW8rs15kdMs5xlv-8Bx6CtfpSoi8ys,23562
|
9
|
+
piegy/simulation_py.py,sha256=vVQbb76ui8Dw1msdk_GaNDNYVkMEUG-Q3lMsCx-8KNs,29503
|
10
|
+
piegy/build_info.py,sha256=tsLg_G9TV_g_D3sri3ZdANTE3lpLFjl01uG5TW4L1EY,287
|
11
|
+
piegy/videos.py,sha256=QfSpOdwfaDsrQYRoiHmZ6gowzRQHom3m8kx1P65_8sM,10218
|
12
|
+
piegy/C_core/patch.c,sha256=OVG4qyTpRs0hDa5eMRdPyNUmZk2G-FogBVq7Li381PQ,1032
|
13
|
+
piegy/C_core/model.c,sha256=lAIQ2-r6GDBZNQUnxaj6EWiMLNI52-1vnYC6CPY8KyY,2854
|
14
|
+
piegy/C_core/piegyc.h,sha256=INS97GRoOI01TQkzWHOa0KGKCBeg0L0pPFlb6Ei3faI,1078
|
15
|
+
piegy/C_core/runner.c,sha256=WU2jfJUqwv0Xxp3g4cewVYsyDyvG4wkPFcu2VJ_sKNk,1576
|
16
|
+
piegy/C_core/Makefile,sha256=kVNaxlGxxvcODyaEKQkDoXnU68NueKxksxqXSrTnPcM,2069
|
17
|
+
piegy/C_core/sim_funcs.c,sha256=TJp-u_bEMtjiJySY4LrjnFRK_wpUeC-tHk4BURkec_4,18830
|
18
|
+
piegy/C_core/model.h,sha256=hmIqOwznkB8rhG-JeEUmn7JBDiWHkNrR9qfy1wN7X1E,1180
|
19
|
+
piegy/C_core/patch.h,sha256=c3MXJweW4cogRnacaoY-aoUsf98jhJ_Hs-hp9AH6gwY,963
|
20
|
+
piegy/C_core/piegyc.cpython-311-darwin.so,sha256=LM9JHvMbgNhgaurflfN9dUKb0TQTQlFbUKeOY2Xn_1s,67656
|
21
|
+
piegy/C_core/sim_funcs.h,sha256=w53jaLVf49h_OxEr3xbMT3p_v6KTmduf0ORsoSqFhTI,15144
|
22
|
+
piegy/tools/__init__.py,sha256=eYOl_HJHDonYexfrmKh3koOlxvtSo46vH6jHvCEEB4k,300
|
23
|
+
piegy/tools/file_tools.py,sha256=ncxFWeHfIE-GYLQlOrahFlhBgqPyuY3R5_93fpQeCEs,630
|
24
|
+
piegy/tools/figure_tools.py,sha256=54vJSJMReXidFnSPE_xFvedtgnJU3d55zQDPNBLGs98,6975
|
25
|
+
piegy-2.1.9.dist-info/RECORD,,
|
26
|
+
piegy-2.1.9.dist-info/WHEEL,sha256=sunMa2yiYbrNLGeMVDqEA0ayyJbHlex7SCn1TZrEq60,136
|
27
|
+
piegy-2.1.9.dist-info/top_level.txt,sha256=k4QLYL8PqdqDuy95-4NZD_FVLqJDsmq67tpKkBn4vMw,6
|
28
|
+
piegy-2.1.9.dist-info/METADATA,sha256=nOg1krDYxs1lGiESkE4OJD1SMfQAX1Pb12Tm4be9qZw,5435
|
29
|
+
piegy-2.1.9.dist-info/licenses/LICENSE.txt,sha256=wfzEht_CxOcfGGmg3f3at4mWJb9rTBjA51mXLl_3O3g,1498
|
File without changes
|
File without changes
|