piegy 1.1.1__py3-none-any.whl → 1.1.2__py3-none-any.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/__version__.py +2 -1
- piegy/figures.py +5 -6
- piegy/model.py +7 -14
- piegy/test_var.py +12 -12
- piegy/tools/figure_tools.py +5 -5
- piegy/videos.py +3 -3
- {piegy-1.1.1.dist-info → piegy-1.1.2.dist-info}/METADATA +1 -1
- piegy-1.1.2.dist-info/RECORD +16 -0
- piegy-1.1.1.dist-info/RECORD +0 -16
- {piegy-1.1.1.dist-info → piegy-1.1.2.dist-info}/WHEEL +0 -0
- {piegy-1.1.1.dist-info → piegy-1.1.2.dist-info}/licenses/LICENSE.txt +0 -0
- {piegy-1.1.1.dist-info → piegy-1.1.2.dist-info}/top_level.txt +0 -0
piegy/__version__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
__version__ = '1.
|
1
|
+
__version__ = '1.1.2'
|
2
2
|
|
3
3
|
'''
|
4
4
|
version history:
|
@@ -15,5 +15,6 @@ version history:
|
|
15
15
|
1.0.0: first version in PyPI
|
16
16
|
1.1.0: debugging. Updated a range of functions, in the following modules: figures, videos, test_var, model, figure_tools
|
17
17
|
1.1.1: minor debugging in model module.
|
18
|
+
1.1.2: fix text bad location in figure_tools, update labeling and titling in figures and test_var. Add dpi param to make_video in videos. Remove reset_data function in model.
|
18
19
|
|
19
20
|
'''
|
piegy/figures.py
CHANGED
@@ -72,9 +72,9 @@ def UV_heatmap(sim, ax_U = None, ax_V = None, U_color = 'Purples', V_color = 'Gr
|
|
72
72
|
|
73
73
|
#### plot ####
|
74
74
|
|
75
|
-
U_title = figure_t.gen_title('U', start, end)
|
75
|
+
U_title = figure_t.gen_title('Popu U', start, end)
|
76
76
|
U_text = figure_t.gen_text(np.mean(U_ave), np.std(U_ave))
|
77
|
-
V_title = figure_t.gen_title('V', start, end)
|
77
|
+
V_title = figure_t.gen_title('Popu V', start, end)
|
78
78
|
V_text = figure_t.gen_text(np.mean(V_ave), np.std(V_ave))
|
79
79
|
|
80
80
|
ax_U = figure_t.heatmap(U_ave, ax_U, U_color, annot, fmt, U_title, U_text)
|
@@ -110,9 +110,9 @@ def UV_bar(sim, ax_U = None, ax_V = None, U_color = 'purple', V_color = 'green',
|
|
110
110
|
|
111
111
|
#### plot ####
|
112
112
|
|
113
|
-
U_title = figure_t.gen_title('U', start, end)
|
113
|
+
U_title = figure_t.gen_title('Population U', start, end)
|
114
114
|
U_text = figure_t.gen_text(np.mean(U_ave), np.std(U_ave))
|
115
|
-
V_title = figure_t.gen_title('V', start, end)
|
115
|
+
V_title = figure_t.gen_title('Population V', start, end)
|
116
116
|
V_text = figure_t.gen_text(np.mean(V_ave), np.std(V_ave))
|
117
117
|
|
118
118
|
ax_U = figure_t.bar(U_ave, ax = ax_U, color = U_color, xlabel = 'patches', ylabel = 'U', title = U_title, text = U_text)
|
@@ -405,7 +405,6 @@ def pi_dyna(sim, ax = None, interval = 20, grid = True):
|
|
405
405
|
ax.plot(xaxis, U_curve, CURVE_TYPE, label = r'$p_U$')
|
406
406
|
ax.plot(xaxis, V_curve, CURVE_TYPE, label = r'$p_V$')
|
407
407
|
ax.plot(xaxis, total_curve, CURVE_TYPE, label = 'total')
|
408
|
-
ax.set_xlim(0, sim.maxtime)
|
409
408
|
ax.set_xlabel('Time')
|
410
409
|
ax.set_ylabel('Payoff')
|
411
410
|
ax.set_title('Payoff ' + r'$p_U$' + ' & ' + r'$p_V$' + ' over time')
|
@@ -492,7 +491,7 @@ def pi_std(sim, ax = None, interval = 20, grid = True):
|
|
492
491
|
|
493
492
|
|
494
493
|
|
495
|
-
def UV_pi(sim, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellowgreen', alpha = 0.
|
494
|
+
def UV_pi(sim, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellowgreen', alpha = 0.5, start = 0.95, end = 1.0):
|
496
495
|
'''
|
497
496
|
Make two scatter plots: x-axes are population and y-axes are payoff in a specified time interval.
|
498
497
|
Reveals relationship between population and payoff.
|
piegy/model.py
CHANGED
@@ -33,7 +33,7 @@ from timeit import default_timer as timer
|
|
33
33
|
|
34
34
|
|
35
35
|
# data type used by simulation.U and simulation.V
|
36
|
-
UV_DTYPE = '
|
36
|
+
UV_DTYPE = 'float64'
|
37
37
|
|
38
38
|
# data type used by simulation.U_pi and V_pi
|
39
39
|
PI_DTYPE = 'float64'
|
@@ -282,7 +282,7 @@ class simulation:
|
|
282
282
|
|
283
283
|
def __init__(self, N, M, maxtime, record_itv, sim_time, boundary, I, X, P, print_pct = 25, seed = None, UV_dtype = UV_DTYPE, pi_dtype = PI_DTYPE):
|
284
284
|
|
285
|
-
self.check_valid_input(N, M, maxtime, record_itv, sim_time, boundary, I, X, P, print_pct
|
285
|
+
self.check_valid_input(N, M, maxtime, record_itv, sim_time, boundary, I, X, P, print_pct)
|
286
286
|
|
287
287
|
self.N = N # int, N x M is spatial dimension
|
288
288
|
self.M = M # int, can't be 1. If want to make 1D space, use N = 1. And this model doesn't work for 1x1 space (causes NaN)
|
@@ -318,7 +318,7 @@ class simulation:
|
|
318
318
|
self.V_pi = np.zeros((self.N, self.M, self.max_record), dtype = self.pi_dtype)
|
319
319
|
|
320
320
|
|
321
|
-
def check_valid_input(self, N, M, maxtime, record_itv, sim_time, boundary, I, X, P, print_pct
|
321
|
+
def check_valid_input(self, N, M, maxtime, record_itv, sim_time, boundary, I, X, P, print_pct):
|
322
322
|
# check whether the inputs are valid
|
323
323
|
# seed, UV_dtype, pi_dtype is handled by numpy
|
324
324
|
|
@@ -355,10 +355,8 @@ class simulation:
|
|
355
355
|
if print_pct <= 0:
|
356
356
|
raise ValueError('Please use an int > 0 for print_pct or None for not printing progress.')
|
357
357
|
|
358
|
-
# seed is checked by number
|
359
|
-
|
360
358
|
|
361
|
-
def check_valid_data(self, data_empty, max_record, compress_itv
|
359
|
+
def check_valid_data(self, data_empty, max_record, compress_itv):
|
362
360
|
# check whether a set of data is valid, used when reading a saved model
|
363
361
|
if type(data_empty) != bool:
|
364
362
|
raise TypeError('data_empty not a bool')
|
@@ -482,21 +480,16 @@ class simulation:
|
|
482
480
|
# set seed
|
483
481
|
self.seed = seed
|
484
482
|
|
485
|
-
|
486
|
-
def reset_data(self):
|
487
|
-
# clear all data stored, set all to 0
|
488
|
-
self.init_storage()
|
489
|
-
|
490
483
|
|
491
484
|
def clear(self):
|
492
|
-
# clear data
|
493
|
-
self.
|
485
|
+
# clear all data stored, set all to 0
|
486
|
+
self.init_storage()
|
494
487
|
|
495
488
|
|
496
489
|
def set_data(self, data_empty, max_record, compress_itv, U, V, U_pi, V_pi):
|
497
490
|
# set data to the given data values
|
498
491
|
# copies are made
|
499
|
-
self.check_valid_data(data_empty, max_record, compress_itv
|
492
|
+
self.check_valid_data(data_empty, max_record, compress_itv)
|
500
493
|
|
501
494
|
self.data_empty = data_empty
|
502
495
|
self.max_record = max_record
|
piegy/test_var.py
CHANGED
@@ -193,12 +193,12 @@ def var_UV1(var, values, var_dirs, ax_U = None, ax_V = None, start = 0.95, end =
|
|
193
193
|
var_disp = PATCH_VAR_DISP[var]
|
194
194
|
|
195
195
|
ax_U.set_xlabel(var_disp)
|
196
|
-
ax_U.set_ylabel(r'$U$')
|
196
|
+
ax_U.set_ylabel('Population ' + r'$U$')
|
197
197
|
ax_U.plot(values, U_ave, DOTTED_CURVE_TYPE, color = U_color)
|
198
198
|
ax_U.set_title(figure_t.gen_title(var_disp + r'$\,-\,U$', start, end))
|
199
199
|
|
200
200
|
ax_V.set_xlabel(var_disp)
|
201
|
-
ax_V.set_ylabel(r'$V$')
|
201
|
+
ax_V.set_ylabel('Population ' + r'$V$')
|
202
202
|
ax_V.plot(values, V_ave, DOTTED_CURVE_TYPE, color = V_color)
|
203
203
|
ax_V.set_title(figure_t.gen_title(var_disp + r'$\,-\,V$', start, end))
|
204
204
|
|
@@ -277,7 +277,7 @@ def var_UV2(var1, var2, values1, values2, var_dirs, ax_U = None, ax_V = None, va
|
|
277
277
|
color_k = cmap_U(k / len(values1))[:3] + (rgb_alpha,)
|
278
278
|
ax_U.plot(values2, U_ave[k], DOTTED_CURVE_TYPE, label = label, color = color_k)
|
279
279
|
ax_U.set_xlabel(var2_disp)
|
280
|
-
ax_U.set_ylabel(r'$U$')
|
280
|
+
ax_U.set_ylabel('Population ' + r'$U$')
|
281
281
|
ax_U.set_title(figure_t.gen_title(var1_disp + ',' + var2_disp + r'$\,-\,U$', start, end))
|
282
282
|
ax_U.legend()
|
283
283
|
|
@@ -294,7 +294,7 @@ def var_UV2(var1, var2, values1, values2, var_dirs, ax_U = None, ax_V = None, va
|
|
294
294
|
color_k = cmap_V(k / len(values1))[:3] + (rgb_alpha,)
|
295
295
|
ax_V.plot(values2, V_ave[k], DOTTED_CURVE_TYPE, label = label, color = color_k)
|
296
296
|
ax_V.set_xlabel(var2_disp)
|
297
|
-
ax_V.set_ylabel(r'$V$')
|
297
|
+
ax_V.set_ylabel('Population ' + r'$V$')
|
298
298
|
ax_V.set_title(figure_t.gen_title(var1_disp + ',' + var2_disp + r'$\,-\,V$', start, end))
|
299
299
|
ax_V.legend()
|
300
300
|
|
@@ -347,14 +347,14 @@ def var_pi1(var, values, var_dirs, ax_U = None, ax_V = None, start = 0.95, end =
|
|
347
347
|
var_disp = PATCH_VAR_DISP[var]
|
348
348
|
|
349
349
|
ax_U.set_xlabel(var_disp)
|
350
|
-
ax_U.set_ylabel(r'
|
350
|
+
ax_U.set_ylabel('Payoff ' + r'$p_U$')
|
351
351
|
ax_U.plot(values, U_ave, DOTTED_CURVE_TYPE, color = U_color)
|
352
|
-
ax_U.set_title(figure_t.gen_title(var_disp + r'
|
352
|
+
ax_U.set_title(figure_t.gen_title(var_disp + r'$\,-\,p_U$', start, end))
|
353
353
|
|
354
354
|
ax_V.set_xlabel(var_disp)
|
355
|
-
ax_V.set_ylabel(r'
|
355
|
+
ax_V.set_ylabel('Payoff ' + r'$p_V$')
|
356
356
|
ax_V.plot(values, V_ave, DOTTED_CURVE_TYPE, color = V_color)
|
357
|
-
ax_V.set_title(figure_t.gen_title(var_disp + r'
|
357
|
+
ax_V.set_title(figure_t.gen_title(var_disp + r'$\,-\,p_V$', start, end))
|
358
358
|
|
359
359
|
return ax_U, ax_V
|
360
360
|
|
@@ -428,8 +428,8 @@ def var_pi2(var1, var2, values1, values2, var_dirs, ax_U = None, ax_V = None, va
|
|
428
428
|
color_k = cmap_U(k / len(values1))[:3] + (rgb_alpha,)
|
429
429
|
ax_U.plot(values2, U_ave[k], DOTTED_CURVE_TYPE, label = label, color = color_k)
|
430
430
|
ax_U.set_xlabel(var2_disp)
|
431
|
-
ax_U.set_ylabel(r'
|
432
|
-
ax_U.set_title(figure_t.gen_title(var1_disp + ',' + var2_disp + r'
|
431
|
+
ax_U.set_ylabel('Payoff ' + r'$p_{V}$')
|
432
|
+
ax_U.set_title(figure_t.gen_title(var1_disp + ',' + var2_disp + r'$\,-\,p_U$', start, end))
|
433
433
|
ax_U.legend()
|
434
434
|
|
435
435
|
cmap_V = plt.get_cmap(V_color)
|
@@ -445,8 +445,8 @@ def var_pi2(var1, var2, values1, values2, var_dirs, ax_U = None, ax_V = None, va
|
|
445
445
|
color_k = cmap_V(k / len(values1))[:3] + (rgb_alpha,)
|
446
446
|
ax_V.plot(values2, V_ave[k], DOTTED_CURVE_TYPE, label = label, color = color_k)
|
447
447
|
ax_V.set_xlabel(var2_disp)
|
448
|
-
ax_V.set_ylabel(r'
|
449
|
-
ax_V.set_title(figure_t.gen_title(var1_disp + ',' + var2_disp + r'
|
448
|
+
ax_V.set_ylabel('Payoff ' + r'$p_{U}$')
|
449
|
+
ax_V.set_title(figure_t.gen_title(var1_disp + ',' + var2_disp + r'$\,-\,p_V$', start, end))
|
450
450
|
ax_V.legend()
|
451
451
|
|
452
452
|
return ax_U, ax_V
|
piegy/tools/figure_tools.py
CHANGED
@@ -43,10 +43,10 @@ def heatmap(data, ax = None, cmap = "Greens", annot = False, fmt = '.3g', title
|
|
43
43
|
_, ax = plt.subplots()
|
44
44
|
|
45
45
|
if text != None:
|
46
|
-
ax.text(0.
|
46
|
+
ax.text(0.8, 1.025, text, size = 10, linespacing = 1.5, transform = ax.transAxes)
|
47
47
|
|
48
48
|
ax = sns.heatmap(data, ax = ax, cmap = cmap, annot = annot, fmt = fmt)
|
49
|
-
ax.set_title(title)
|
49
|
+
ax.set_title(title, x = 0.5, y = 1)
|
50
50
|
|
51
51
|
return ax
|
52
52
|
|
@@ -80,12 +80,12 @@ def bar(data, ax = None, color = "green", xlabel = None, ylabel = None, title =
|
|
80
80
|
_, ax = plt.subplots()
|
81
81
|
|
82
82
|
if text != None:
|
83
|
-
ax.text(0.
|
83
|
+
ax.text(0.7, 1.025, text, size = 10, linespacing = 1.5, transform = ax.transAxes)
|
84
84
|
|
85
85
|
ax.bar(x = xaxis, height = data, color = color)
|
86
86
|
ax.set_xlabel(xlabel)
|
87
87
|
ax.set_ylabel(ylabel)
|
88
|
-
ax.set_title(title)
|
88
|
+
ax.set_title(title, x = 0.5, y = 1)
|
89
89
|
|
90
90
|
return ax
|
91
91
|
|
@@ -121,7 +121,7 @@ def gen_title(title, start, end):
|
|
121
121
|
'''
|
122
122
|
Generate a title for plot when it's about an interval of time.
|
123
123
|
'''
|
124
|
-
title += ", " + str(round(start * 100, 1)) + "
|
124
|
+
title += ", " + str(round(start * 100, 1)) + "~" + str(round(end * 100, 1)) + "%"
|
125
125
|
return title
|
126
126
|
|
127
127
|
|
piegy/videos.py
CHANGED
@@ -201,7 +201,7 @@ def make_mp4(video_dir, frame_dir, fps):
|
|
201
201
|
|
202
202
|
|
203
203
|
|
204
|
-
def make_video(sim, func_name = 'UV_heatmap', frames = 100, fps = 30, U_color = 'Greens', V_color = 'Purples', annot = False, fmt = '.3g', del_frames = False, dirs = 'videos'):
|
204
|
+
def make_video(sim, func_name = 'UV_heatmap', frames = 100, dpi = 200, fps = 30, U_color = 'Greens', V_color = 'Purples', annot = False, fmt = '.3g', del_frames = False, dirs = 'videos'):
|
205
205
|
'''
|
206
206
|
Make a mp4 video based on simulation results.
|
207
207
|
|
@@ -274,8 +274,8 @@ def make_video(sim, func_name = 'UV_heatmap', frames = 100, fps = 30, U_color =
|
|
274
274
|
ax_V.set_xlim(U_xlim)
|
275
275
|
ax_V.set_xlim(V_xlim)
|
276
276
|
|
277
|
-
fig_U.savefig(U_frame_dirs + '/' + 'U_frame_' + str(i) + '.png', pad_inches = 0.25)
|
278
|
-
fig_V.savefig(V_frame_dirs + '/' + 'V_frame_' + str(i) + '.png', pad_inches = 0.25)
|
277
|
+
fig_U.savefig(U_frame_dirs + '/' + 'U_frame_' + str(i) + '.png', pad_inches = 0.25, dpi = dpi)
|
278
|
+
fig_V.savefig(V_frame_dirs + '/' + 'V_frame_' + str(i) + '.png', pad_inches = 0.25, dpi = dpi)
|
279
279
|
|
280
280
|
plt.close(fig_U)
|
281
281
|
plt.close(fig_V)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
piegy/__init__.py,sha256=Lrh6NegSvo6LOCXg_tBTu804eicnHpQY2zmE0FchjKE,3241
|
2
|
+
piegy/__version__.py,sha256=Trj_0I_674hSVhRFZKrxgEPKLEDrFFGr_p7rby3iR5w,701
|
3
|
+
piegy/analysis.py,sha256=1cF06igQMGJGVjLiyhtgepGk8fYhzvL0orI48tOK1qY,8713
|
4
|
+
piegy/data_tools.py,sha256=lNFOX4H0o_WfRSNQoC9QGCK66-IdrZ0zCnz12N-Ael4,3599
|
5
|
+
piegy/figures.py,sha256=xXvr9LcGGhpeVibWTnIiDQlc_kBPibT8qYU5ALKS-zw,19063
|
6
|
+
piegy/model.py,sha256=iTC0Ybp4qtrCcX_NcmEEk4bbqIXqUh470eF0CPbeEK0,45311
|
7
|
+
piegy/test_var.py,sha256=HpdJf8i90iWteoJaVnYt37NJo1it2cf9srCsuYtwc7k,23628
|
8
|
+
piegy/videos.py,sha256=yzZPMvU2wTrBQLnqoQGHuxOWVu-Dxyes7w4UuEB_N6c,10176
|
9
|
+
piegy/tools/__init__.py,sha256=eYOl_HJHDonYexfrmKh3koOlxvtSo46vH6jHvCEEB4k,300
|
10
|
+
piegy/tools/figure_tools.py,sha256=IWxMF_Yali37l2knzKLAcvrE8ndAQhCixfUu1_sWEf0,6975
|
11
|
+
piegy/tools/file_tools.py,sha256=ncxFWeHfIE-GYLQlOrahFlhBgqPyuY3R5_93fpQeCEs,630
|
12
|
+
piegy-1.1.2.dist-info/licenses/LICENSE.txt,sha256=wfzEht_CxOcfGGmg3f3at4mWJb9rTBjA51mXLl_3O3g,1498
|
13
|
+
piegy-1.1.2.dist-info/METADATA,sha256=VCEwbAo25BkpLu_-b8nmsbisD-cFPy7lwovmG5PKNa0,5097
|
14
|
+
piegy-1.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
+
piegy-1.1.2.dist-info/top_level.txt,sha256=k4QLYL8PqdqDuy95-4NZD_FVLqJDsmq67tpKkBn4vMw,6
|
16
|
+
piegy-1.1.2.dist-info/RECORD,,
|
piegy-1.1.1.dist-info/RECORD
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
piegy/__init__.py,sha256=Lrh6NegSvo6LOCXg_tBTu804eicnHpQY2zmE0FchjKE,3241
|
2
|
-
piegy/__version__.py,sha256=8IfclnXlmVE5p-odcoFI_9v7RIOmz2Cxd8Dvx1dMjNc,526
|
3
|
-
piegy/analysis.py,sha256=1cF06igQMGJGVjLiyhtgepGk8fYhzvL0orI48tOK1qY,8713
|
4
|
-
piegy/data_tools.py,sha256=lNFOX4H0o_WfRSNQoC9QGCK66-IdrZ0zCnz12N-Ael4,3599
|
5
|
-
piegy/figures.py,sha256=xR4NKuHc-7E3ld6NjyAAVcJG8CtIoKoM4mqd8qPOXsg,19063
|
6
|
-
piegy/model.py,sha256=NkP_Apnun3MhATSihR4_irnA-8p4FW879xQjCXVEPMA,45502
|
7
|
-
piegy/test_var.py,sha256=PDtCCou-kFXumEe2EdAQNKJohwHH58ifLSsp5xQraVI,23532
|
8
|
-
piegy/videos.py,sha256=vPl1aTIOaWxIUsxX5yL3JPiuf-Um0bPo7qYIHZP0bo0,10143
|
9
|
-
piegy/tools/__init__.py,sha256=eYOl_HJHDonYexfrmKh3koOlxvtSo46vH6jHvCEEB4k,300
|
10
|
-
piegy/tools/figure_tools.py,sha256=tAI5sBMsxN_1BN5_G_3UoMcDeYTj2DXr8l4HpPl9FSs,6961
|
11
|
-
piegy/tools/file_tools.py,sha256=ncxFWeHfIE-GYLQlOrahFlhBgqPyuY3R5_93fpQeCEs,630
|
12
|
-
piegy-1.1.1.dist-info/licenses/LICENSE.txt,sha256=wfzEht_CxOcfGGmg3f3at4mWJb9rTBjA51mXLl_3O3g,1498
|
13
|
-
piegy-1.1.1.dist-info/METADATA,sha256=qawzMEDrKZITzujlqMf_9WJoEklAGFYcOw3I2u8plbQ,5097
|
14
|
-
piegy-1.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
-
piegy-1.1.1.dist-info/top_level.txt,sha256=k4QLYL8PqdqDuy95-4NZD_FVLqJDsmq67tpKkBn4vMw,6
|
16
|
-
piegy-1.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|