itrm 0.2.1__tar.gz → 0.2.2__tar.gz
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.
- {itrm-0.2.1/src/itrm.egg-info → itrm-0.2.2}/PKG-INFO +1 -1
- {itrm-0.2.1 → itrm-0.2.2}/setup.cfg +1 -1
- {itrm-0.2.1 → itrm-0.2.2}/src/itrm/itrm.py +84 -34
- {itrm-0.2.1 → itrm-0.2.2/src/itrm.egg-info}/PKG-INFO +1 -1
- {itrm-0.2.1 → itrm-0.2.2}/LICENSE.txt +0 -0
- {itrm-0.2.1 → itrm-0.2.2}/README.md +0 -0
- {itrm-0.2.1 → itrm-0.2.2}/pyproject.toml +0 -0
- {itrm-0.2.1 → itrm-0.2.2}/src/itrm/__init__.py +0 -0
- {itrm-0.2.1 → itrm-0.2.2}/src/itrm.egg-info/SOURCES.txt +0 -0
- {itrm-0.2.1 → itrm-0.2.2}/src/itrm.egg-info/dependency_links.txt +0 -0
- {itrm-0.2.1 → itrm-0.2.2}/src/itrm.egg-info/requires.txt +0 -0
- {itrm-0.2.1 → itrm-0.2.2}/src/itrm.egg-info/top_level.txt +0 -0
|
@@ -83,14 +83,16 @@ class config: # configuration settings
|
|
|
83
83
|
config.darks = DARK_BLUES
|
|
84
84
|
config.lites = LITE_BLUES
|
|
85
85
|
else:
|
|
86
|
-
raise ValueError(
|
|
87
|
-
+ "
|
|
86
|
+
raise ValueError('cmap must be one of '
|
|
87
|
+
+ '"colors", "viridis", "grays", '
|
|
88
|
+
+ '"reds", "greens", or "blues"')
|
|
88
89
|
|
|
89
90
|
|
|
90
91
|
class persistent: # persistent, run-time values
|
|
91
92
|
t_last = None # last time value
|
|
92
93
|
orig_term_attr = None # original terminal attributes
|
|
93
94
|
rows_last = None # last number of plot rows
|
|
95
|
+
tmp = 0.0
|
|
94
96
|
|
|
95
97
|
|
|
96
98
|
class limits: # x and y data limits
|
|
@@ -103,7 +105,6 @@ class limits: # x and y data limits
|
|
|
103
105
|
self.k_min = k_min # indices of minimum x
|
|
104
106
|
self.k_max = k_max # indices of maximum x
|
|
105
107
|
self.k_xc = k_xc # indices of x near cursor
|
|
106
|
-
self.tmp = 0.0
|
|
107
108
|
|
|
108
109
|
|
|
109
110
|
class term_ws: # terminal window size and sub-character resolution
|
|
@@ -420,8 +421,8 @@ def iplot(x, y=None, label=None, rows=1, cols=1, lg=None, overlay=False):
|
|
|
420
421
|
first = False
|
|
421
422
|
else:
|
|
422
423
|
if report:
|
|
423
|
-
rstr = view_str + f" < t:{tupdate:4f} >"
|
|
424
|
-
|
|
424
|
+
#rstr = view_str + f" < t:{tupdate:4f} >"
|
|
425
|
+
rstr = view_str + f" < {persistent.tmp} >" # FIXME
|
|
425
426
|
redraw_graph(C, D, F, row_zero, rstr, label,
|
|
426
427
|
ccol, cstr, cF, view, lims)
|
|
427
428
|
else:
|
|
@@ -650,7 +651,7 @@ def heat(matrix):
|
|
|
650
651
|
for row in range(0, (rows - rows%2), 2):
|
|
651
652
|
for col in range(cols):
|
|
652
653
|
print("\x1b[38;5;%dm\x1b[48;5;%dm\u2580" %
|
|
653
|
-
(M[row, col], M[row
|
|
654
|
+
(M[row, col], M[row+1, col]), end="", flush=True)
|
|
654
655
|
print("\x1b[0m", flush=True)
|
|
655
656
|
if rows % 2 == 1:
|
|
656
657
|
for col in range(cols):
|
|
@@ -1172,20 +1173,69 @@ def limits_xy(x, y, tws, equal_axes):
|
|
|
1172
1173
|
|
|
1173
1174
|
|
|
1174
1175
|
def get_row_zero(lims, tws):
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1176
|
+
"""
|
|
1177
|
+
Expand the limits to align zero with the nearest row so that the zero marker
|
|
1178
|
+
is true.
|
|
1179
|
+
"""
|
|
1180
|
+
|
|
1181
|
+
# Alias the current min and max y values.
|
|
1182
|
+
a = lims.y_min
|
|
1183
|
+
b = lims.y_max
|
|
1184
|
+
|
|
1185
|
+
if (a < 0) and (b > 0):
|
|
1186
|
+
# Get the real-valued and integer-valued center rows.
|
|
1187
|
+
C = tws.rows*b/(b-a) - 0.5
|
|
1188
|
+
Cl = math.floor(C) # lower value
|
|
1189
|
+
Ch = math.ceil(C) # higher value
|
|
1190
|
+
|
|
1191
|
+
# Get the scaling factors.
|
|
1192
|
+
kl = (Cl + 0.5)/tws.rows
|
|
1193
|
+
kh = (Ch + 0.5)/tws.rows
|
|
1194
|
+
|
|
1195
|
+
# Given the two scaling factors, get the new low values from fixed high
|
|
1196
|
+
# values and the new high values from fixed low values.
|
|
1197
|
+
Al = b*(kl - 1)/kl
|
|
1198
|
+
Ah = b*(kh - 1)/kh
|
|
1199
|
+
Bl = a*kl/(kl - 1)
|
|
1200
|
+
Bh = a*kh/(kh - 1)
|
|
1201
|
+
|
|
1202
|
+
# Between the two new low values, check which is at least as low as the
|
|
1203
|
+
# original.
|
|
1204
|
+
if Al <= a:
|
|
1205
|
+
A = Al
|
|
1206
|
+
CA = Cl
|
|
1207
|
+
elif Ah <= a:
|
|
1208
|
+
A = Ah
|
|
1209
|
+
CA = Ch
|
|
1210
|
+
else:
|
|
1211
|
+
A = -np.inf
|
|
1212
|
+
|
|
1213
|
+
# Between the two new high values, check which is at least as high as
|
|
1214
|
+
# the original.
|
|
1215
|
+
if Bl >= b:
|
|
1216
|
+
B = Bl
|
|
1217
|
+
CB = Cl
|
|
1218
|
+
elif Bh >= b:
|
|
1219
|
+
B = Bh
|
|
1220
|
+
CB = Ch
|
|
1221
|
+
else:
|
|
1222
|
+
B = np.inf
|
|
1223
|
+
|
|
1224
|
+
# Pick the pair which results in the smallest increase in range.
|
|
1225
|
+
if (b - A > 2*(b - a)) and (B - a > 2*(b - a)):
|
|
1226
|
+
row_zero = -1
|
|
1227
|
+
elif (b - A) < (B - a):
|
|
1228
|
+
lims.y_min = A
|
|
1229
|
+
lims.y_max = b
|
|
1230
|
+
row_zero = CA
|
|
1231
|
+
else:
|
|
1232
|
+
lims.y_min = a
|
|
1233
|
+
lims.y_max = B
|
|
1234
|
+
row_zero = CB
|
|
1187
1235
|
else:
|
|
1236
|
+
# Set the zero row to something invalid.
|
|
1188
1237
|
row_zero = -1
|
|
1238
|
+
|
|
1189
1239
|
return row_zero, lims
|
|
1190
1240
|
|
|
1191
1241
|
|
|
@@ -1239,8 +1289,8 @@ def data_to_matrix(x, y, view, tws, j_cursor):
|
|
|
1239
1289
|
# Scale the data to dots. First dot is 0; last dot is Cols - 1.
|
|
1240
1290
|
X = Cols*(x[j, mm] - view.x_min)/x_span - 0.5
|
|
1241
1291
|
Y = Rows*(view.y_max - y[j, mm])/y_span - 0.5
|
|
1242
|
-
X = np.clip(np.round(X).astype(int), 0, Cols
|
|
1243
|
-
Y = np.clip(np.round(Y).astype(int), 0, Rows
|
|
1292
|
+
X = np.clip(np.round(X).astype(int), 0, Cols-1)
|
|
1293
|
+
Y = np.clip(np.round(Y).astype(int), 0, Rows-1)
|
|
1244
1294
|
|
|
1245
1295
|
# Map locations to a large matrix.
|
|
1246
1296
|
M[Y, X] = 1 # Puts a 1 wherever the curve coordinates are.
|
|
@@ -1359,7 +1409,7 @@ def zoom_in_indices(x, view):
|
|
|
1359
1409
|
# Get subset of `x` within the old view.
|
|
1360
1410
|
ka = view.k_min[j]
|
|
1361
1411
|
kb = view.k_max[j]
|
|
1362
|
-
xj_view = x[j, ka:kb
|
|
1412
|
+
xj_view = x[j, ka:kb+1]
|
|
1363
1413
|
|
|
1364
1414
|
# Get the new index of minimum.
|
|
1365
1415
|
mm_min = (xj_view >= view.x_min).nonzero()[0]
|
|
@@ -1379,7 +1429,7 @@ def zoom_out_indices(x, view):
|
|
|
1379
1429
|
# Get subsets of `x` left or right of the old view.
|
|
1380
1430
|
kb = view.k_min[j]
|
|
1381
1431
|
ka = view.k_max[j]
|
|
1382
|
-
xj_left = x[j, :kb
|
|
1432
|
+
xj_left = x[j, :kb+1]
|
|
1383
1433
|
xj_right = x[j, ka:]
|
|
1384
1434
|
|
|
1385
1435
|
# Get the new index of minimum.
|
|
@@ -1401,17 +1451,17 @@ def pan_indices(x, view):
|
|
|
1401
1451
|
ka = view.k_min[j]
|
|
1402
1452
|
kb = view.k_max[j]
|
|
1403
1453
|
if (x[j, ka] >= view.x_min) and (x[j, kb] >= view.x_max): # <--
|
|
1404
|
-
xj_min = x[j, :ka
|
|
1405
|
-
xj_max = x[j, :kb
|
|
1454
|
+
xj_min = x[j, :ka+1]; k_min_ref = 0
|
|
1455
|
+
xj_max = x[j, :kb+1]; k_max_ref = 0
|
|
1406
1456
|
elif (x[j, ka] < view.x_min) and (x[j, kb] < view.x_max): # -->
|
|
1407
1457
|
xj_min = x[j, ka:]; k_min_ref = ka
|
|
1408
1458
|
xj_max = x[j, kb:]; k_max_ref = kb
|
|
1409
1459
|
elif (x[j, ka] >= view.x_min) and (x[j, kb] < view.x_max): # <->
|
|
1410
|
-
xj_min = x[j, :ka
|
|
1460
|
+
xj_min = x[j, :ka+1]; k_min_ref = 0
|
|
1411
1461
|
xj_max = x[j, kb:]; k_max_ref = kb
|
|
1412
1462
|
elif (x[j, ka] < view.x_min) and (x[j, kb] >= view.x_max): # >-<
|
|
1413
|
-
xj_min = x[j, ka:kb
|
|
1414
|
-
xj_max = x[j, ka:kb
|
|
1463
|
+
xj_min = x[j, ka:kb+1]; k_min_ref = ka
|
|
1464
|
+
xj_max = x[j, ka:kb+1]; k_max_ref = ka
|
|
1415
1465
|
|
|
1416
1466
|
# Get the new index of minimum.
|
|
1417
1467
|
mm_min = (xj_min >= view.x_min).nonzero()[0]
|
|
@@ -1432,7 +1482,7 @@ def center_view_x(xc, view):
|
|
|
1432
1482
|
def get_column(xc, view, tws):
|
|
1433
1483
|
x_span = view.x_max - view.x_min
|
|
1434
1484
|
ccol = round(tws.cols*(xc - view.x_min)/x_span - 0.5)
|
|
1435
|
-
ccol = min(max(ccol, 0), tws.cols
|
|
1485
|
+
ccol = min(max(ccol, 0), tws.cols-1)
|
|
1436
1486
|
return ccol
|
|
1437
1487
|
|
|
1438
1488
|
|
|
@@ -1452,8 +1502,8 @@ def get_cursor_y(x, y, view, tws, ccol, j_cursor):
|
|
|
1452
1502
|
for j in jj:
|
|
1453
1503
|
ka = view.k_min[j]
|
|
1454
1504
|
kb = view.k_max[j]
|
|
1455
|
-
xj_view = x[j, ka:kb
|
|
1456
|
-
yj_view = y[j, ka:kb
|
|
1505
|
+
xj_view = x[j, ka:kb+1]
|
|
1506
|
+
yj_view = y[j, ka:kb+1]
|
|
1457
1507
|
is_valid_x = np.isfinite(xj_view)
|
|
1458
1508
|
is_valid_y = np.isfinite(yj_view)
|
|
1459
1509
|
is_in = (xj_view >= xc_a) & (xj_view <= xc_b)
|
|
@@ -1484,8 +1534,8 @@ def get_view_y(x, y, view, j_cursor):
|
|
|
1484
1534
|
for j in jj:
|
|
1485
1535
|
ka = view.k_min[j]
|
|
1486
1536
|
kb = view.k_max[j]
|
|
1487
|
-
xj_view = x[j, ka:kb
|
|
1488
|
-
yj_view = y[j, ka:kb
|
|
1537
|
+
xj_view = x[j, ka:kb+1]
|
|
1538
|
+
yj_view = y[j, ka:kb+1]
|
|
1489
1539
|
is_valid_x = np.isfinite(xj_view)
|
|
1490
1540
|
is_valid_y = np.isfinite(yj_view)
|
|
1491
1541
|
mm = (is_valid_x & is_valid_y).nonzero()[0]
|
|
@@ -1557,7 +1607,7 @@ def matrix_to_ascii(M):
|
|
|
1557
1607
|
|
|
1558
1608
|
def matrix_to_stars(M):
|
|
1559
1609
|
I, J = M.shape
|
|
1560
|
-
C = 0x20*np.ones((I, 2*J
|
|
1610
|
+
C = 0x20*np.ones((I, 2*J+1), dtype=int)
|
|
1561
1611
|
C[:, 1:-1:2] += 0xA*M
|
|
1562
1612
|
return C
|
|
1563
1613
|
|
|
@@ -1728,7 +1778,7 @@ def redraw_graph(C, D, F=None, row_zero=-1, view_str=None, label=None,
|
|
|
1728
1778
|
x_view = (view.x_max + view.x_min)/2
|
|
1729
1779
|
col_center = round(cols*(x_view - lims.x_min)/x_span)
|
|
1730
1780
|
col_a = max(0, round(col_center - bar_width/2))
|
|
1731
|
-
col_b = min(cols
|
|
1781
|
+
col_b = min(cols-1, col_a + bar_width)
|
|
1732
1782
|
# Draw the bar.
|
|
1733
1783
|
print("\x1b[38;5;238m", end="", flush=True)
|
|
1734
1784
|
for col in range(cols):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|