piegy 2.1.0__cp311-cp311-macosx_11_0_arm64.whl → 2.1.8__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 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
- UNAME_S := $(shell uname -s)
21
+ OS := $(shell uname)
26
22
 
27
- ifeq ($(UNAME_S),Darwin)
28
- # macOS-specific flags
29
- CFLAGS = $(CFLAGS_COMMON) -fPIC -mmacosx-version-min=11.0 -arch arm64 $(DEPFLAGS)
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 ($(UNAME_S),Linux)
32
- # Linux-specific flags
33
- CFLAGS = $(CFLAGS_COMMON) -fPIC $(DEPFLAGS)
27
+ else ifeq ($(OS),Linux)
28
+ # Linux flags
29
+ CFLAGS = $(CFLAGS_COMMON) -fPIC
34
30
  LDFLAGS = $(LDFLAGS_COMMON)
35
- else ifeq ($(UNAME_S),Windows_NT)
36
- # Windows-specific flags
37
- CFLAGS = $(CFLAGS_COMMON) -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 $(DEPFLAGS)
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 $(DEPFLAGS)
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 ($(OS),Windows_NT)
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) $(LDFLAGS) -c $< -o $@
82
+ $(CC) $(CFLAGS) -c $< -o $@
86
83
 
87
84
  # Clean build files
88
85
  clean:
piegy/C_core/piegyc.so ADDED
Binary file
piegy/__init__.py CHANGED
@@ -19,6 +19,7 @@ Last update: May 12, 2025
19
19
  '''
20
20
 
21
21
  from .__version__ import __version__
22
+ from .build_info import build_info
22
23
 
23
24
  from .simulation import model, run, demo_model, UV_expected_val, check_overflow_func
24
25
  from .videos import make_video, SUPPORTED_FIGURES
piegy/__version__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = '2.1.0'
1
+ __version__ = '2.1.8'
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.8: updating 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.8",
8
+ "built from": "local machine",
9
+ "build date": "2025-06-28 01:25:49",
10
+ "python version": "3.11.10",
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:] == '.dll':
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
- lib.mod_free_py.argtypes = [ctypes.POINTER(model_c)]
84
- lib.mod_free_py.restype = None
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
- lib.run.argtypes = [ctypes.POINTER(model_c), ctypes.POINTER(c_char), c_size_t]
87
- lib.run.restype = None
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 = lib.mod_init(ctypes.byref(mod_c),
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
- lib.run(ctypes.byref(mod_c), msg_buffer, msg_len)
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
- lib.mod_free_py(ctypes.byref(mod_c))
433
+ LIB.mod_free_py(ctypes.byref(mod_c))
425
434
  del mod_c
426
435
 
427
436
 
piegy/simulation_py.py CHANGED
@@ -5,8 +5,7 @@ But you can still run them by calling:
5
5
  >>> run_py(mod)
6
6
  '''
7
7
 
8
- from . import simulation
9
- model = simulation.model
8
+ from .simulation import model
10
9
 
11
10
  import math
12
11
  import numpy as np
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: piegy
3
- Version: 2.1.0
3
+ Version: 2.1.8
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.8
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,30 @@
1
- piegy/__init__.py,sha256=RastpPYH3VtnfKLVHfmccKCYH1TUtcZuLQeqhWY6pFI,2082
2
- piegy/__version__.py,sha256=rgltevVSlWt53OTpma9ZGXsUzLcskEhIpjG1QX4DTrs,1546
1
+ piegy/__init__.py,sha256=VQcKA9Eg3hUJci2GV8fZjf9srZu9MPRc_LDVomaxowI,2117
2
+ piegy/__version__.py,sha256=BpBy4N-qGYEU3VnA-wOBHaEl_T8Xd_djXPViwxORZZ0,1615
3
3
  piegy/analysis.py,sha256=2GBsBbi7LdstSEAM0-F2bfL2kHu3MElcrw8bxZ1x6LI,8719
4
+ piegy/build_info.py,sha256=PhQEiMUFJTpnuj6ReYqJGAy2ujueT1VK9Ijcl3NWjyI,288
4
5
  piegy/data_tools.py,sha256=auliVb88qKQmCX7LEDgKQvhBcwFTCXBEWKtjJ4_-rTU,3446
5
6
  piegy/figures.py,sha256=GwixvD3Flaqg4feSvqr42lDR7CwZK0_2qmZg6N6_1uE,17936
6
- piegy/simulation.py,sha256=K11zY5i2WJlWwx-vDJ1f9sKwLe1ZqrF7d-rYOotJwPc,19905
7
- piegy/simulation_py.py,sha256=WtWhpHCosKQ457gZ-iJ-7v0N3NtyPqDfgXv4DL3aBKs,29523
7
+ piegy/find_C.py,sha256=CoET9YkWqhvcHxdby6hVaZyPePBUm-fEWm2fo6ishYU,496
8
+ piegy/simulation.py,sha256=5hKtwQGXeMWdZLTSco83CYR5phP6jrOkNcrcfbe7-Z0,20035
9
+ piegy/simulation_py.py,sha256=vVQbb76ui8Dw1msdk_GaNDNYVkMEUG-Q3lMsCx-8KNs,29503
8
10
  piegy/test_var.py,sha256=EfItIK-FEApJTAW8rs15kdMs5xlv-8Bx6CtfpSoi8ys,23562
9
11
  piegy/videos.py,sha256=QfSpOdwfaDsrQYRoiHmZ6gowzRQHom3m8kx1P65_8sM,10218
10
- piegy/C_core/Makefile,sha256=oZOBh7LAIXaHRcTkTin4BZHqae3WEcgM24iqFR-3a18,2198
12
+ piegy/C_core/Makefile,sha256=kVNaxlGxxvcODyaEKQkDoXnU68NueKxksxqXSrTnPcM,2069
11
13
  piegy/C_core/model.c,sha256=lAIQ2-r6GDBZNQUnxaj6EWiMLNI52-1vnYC6CPY8KyY,2854
12
14
  piegy/C_core/model.h,sha256=hmIqOwznkB8rhG-JeEUmn7JBDiWHkNrR9qfy1wN7X1E,1180
13
15
  piegy/C_core/patch.c,sha256=OVG4qyTpRs0hDa5eMRdPyNUmZk2G-FogBVq7Li381PQ,1032
14
16
  piegy/C_core/patch.h,sha256=c3MXJweW4cogRnacaoY-aoUsf98jhJ_Hs-hp9AH6gwY,963
15
17
  piegy/C_core/piegyc.cpython-311-darwin.so,sha256=X09xSi_scV7wr4wzE_BBjeN-a5R26cR2T3mnGCeo_4g,67656
16
18
  piegy/C_core/piegyc.h,sha256=INS97GRoOI01TQkzWHOa0KGKCBeg0L0pPFlb6Ei3faI,1078
19
+ piegy/C_core/piegyc.so,sha256=X09xSi_scV7wr4wzE_BBjeN-a5R26cR2T3mnGCeo_4g,67656
17
20
  piegy/C_core/runner.c,sha256=WU2jfJUqwv0Xxp3g4cewVYsyDyvG4wkPFcu2VJ_sKNk,1576
18
21
  piegy/C_core/sim_funcs.c,sha256=TJp-u_bEMtjiJySY4LrjnFRK_wpUeC-tHk4BURkec_4,18830
19
22
  piegy/C_core/sim_funcs.h,sha256=w53jaLVf49h_OxEr3xbMT3p_v6KTmduf0ORsoSqFhTI,15144
20
23
  piegy/tools/__init__.py,sha256=eYOl_HJHDonYexfrmKh3koOlxvtSo46vH6jHvCEEB4k,300
21
24
  piegy/tools/figure_tools.py,sha256=54vJSJMReXidFnSPE_xFvedtgnJU3d55zQDPNBLGs98,6975
22
25
  piegy/tools/file_tools.py,sha256=ncxFWeHfIE-GYLQlOrahFlhBgqPyuY3R5_93fpQeCEs,630
23
- piegy-2.1.0.dist-info/licenses/LICENSE.txt,sha256=wfzEht_CxOcfGGmg3f3at4mWJb9rTBjA51mXLl_3O3g,1498
24
- piegy-2.1.0.dist-info/METADATA,sha256=SkhrNr5fXsPVv2y9txMuTfqyWAJyNljESI3co7uAlHs,5435
25
- piegy-2.1.0.dist-info/WHEEL,sha256=qxQkdhERtGxJzqnVOBnucx1aUmU2n3HmuzYdln_LyOw,109
26
- piegy-2.1.0.dist-info/top_level.txt,sha256=k4QLYL8PqdqDuy95-4NZD_FVLqJDsmq67tpKkBn4vMw,6
27
- piegy-2.1.0.dist-info/RECORD,,
26
+ piegy-2.1.8.dist-info/licenses/LICENSE.txt,sha256=wfzEht_CxOcfGGmg3f3at4mWJb9rTBjA51mXLl_3O3g,1498
27
+ piegy-2.1.8.dist-info/METADATA,sha256=0etGMI932tEbHgoft3Nq9ikZpKwIK4peEB8meiKABX8,5435
28
+ piegy-2.1.8.dist-info/WHEEL,sha256=qxQkdhERtGxJzqnVOBnucx1aUmU2n3HmuzYdln_LyOw,109
29
+ piegy-2.1.8.dist-info/top_level.txt,sha256=k4QLYL8PqdqDuy95-4NZD_FVLqJDsmq67tpKkBn4vMw,6
30
+ piegy-2.1.8.dist-info/RECORD,,
File without changes