Data objects¶
Return these from filters to control how outputs are displayed.
Image
¶
Bases: Data
Image payload with save, load and display helpers.
Wraps a float numpy array with values expected in [0, 1], of shape
(H, W) (grayscale) or (H, W, 3) (RGB). Saving and loading go
through Pillow or OpenCV, whichever is installed; pass
backend="pillow" or backend="opencv" to force one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Image array, float values in |
required |
title
|
str
|
Title used when displaying or appended to the file stem when saving. |
''
|
Source code in src/interactive_pipe/data_objects/image.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
save_image
staticmethod
¶
save_image(data: ndarray, path: Path, precision: int = 8, backend: Optional[str] = None) -> None
Save a [0, 1] float image array to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Image array, float values in |
required |
path
|
Path
|
Destination file path (extension picks the format). |
required |
precision
|
int
|
Bit depth of the written file (8 or 16; Pillow supports 8 only). |
8
|
backend
|
Optional[str]
|
|
None
|
Source code in src/interactive_pipe/data_objects/image.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
rescale_dynamic
staticmethod
¶
rescale_dynamic(data: ndarray, precision: int = 8) -> np.ndarray
Scale a [0, 1] float image to integer dynamic ([0, 2^precision - 1]).
Source code in src/interactive_pipe/data_objects/image.py
105 106 107 108 109 110 111 112 113 | |
normalize_dynamic
staticmethod
¶
normalize_dynamic(img: ndarray, precision: int = 8) -> np.ndarray
Scale an integer image ([0, 2^precision - 1]) to [0, 1] floats.
Source code in src/interactive_pipe/data_objects/image.py
115 116 117 118 | |
load_image
staticmethod
¶
load_image(path: Path, precision: int = 8, backend: Optional[str] = None) -> np.ndarray
Load an image file as a [0, 1] float RGB array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Image file path. |
required |
precision
|
int
|
Bit depth of the stored file used for normalization. |
8
|
backend
|
Optional[str]
|
|
None
|
Source code in src/interactive_pipe/data_objects/image.py
153 154 155 156 157 158 159 160 161 162 163 164 165 | |
show
¶
show() -> None
Display the image in a matplotlib figure (title includes the shape).
Source code in src/interactive_pipe/data_objects/image.py
167 168 169 170 171 172 173 | |
Curve
¶
Bases: Data
Attributes
- .grid
- .xlabel
- .ylabel
- .xlim
- .ylim
- .title
- .curves
It is possible to access a curve by simply using the bracket operator
`.curves[index]` is equivalent to `[index]`
Source code in src/interactive_pipe/data_objects/curves.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | |
SingleCurve
¶
Bases: Data
SingleCurve are 2D signals you can plot, defined by x and y numpy arrays Attributes: .x .y .label .alpha .style You'd normally use matplotlib.plot(x, y, label) - .from_file("data.csv") containing x,y columns - save as: - .csv (not style, label or markers exported) - .pkl (dict)
Source code in src/interactive_pipe/data_objects/curves.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
Table
¶
Bases: Data
Tabular data for display in interactive_pipe.
Works without pandas. Pandas features (DataFrame input, csv export) available when pandas is installed.
Supports headerless tables for displaying raw matrices by setting columns=None when using numpy array input.
Attributes:
| Name | Type | Description |
|---|---|---|
columns |
List[str]
|
List of column names (empty strings for headerless). |
values |
List[List]
|
2D list of values (row-major). |
title |
Optional[str]
|
Optional title. |
precision |
int
|
Float formatting precision. |
Source code in src/interactive_pipe/data_objects/table.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
__len__
¶
__len__() -> int
Return the number of rows in the table.
Source code in src/interactive_pipe/data_objects/table.py
182 183 184 | |
__iter__
¶
__iter__()
Iterate over rows as dictionaries.
Source code in src/interactive_pipe/data_objects/table.py
186 187 188 189 | |
__getitem__
¶
__getitem__(key: Union[int, str, slice])
Access data by row index, column name, or slice.
Source code in src/interactive_pipe/data_objects/table.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
as_dataframe
¶
as_dataframe() -> pd.DataFrame
Convert Table to pandas DataFrame.
Returns:
| Type | Description |
|---|---|
DataFrame
|
Table data as a pandas DataFrame |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If pandas is not installed |
Source code in src/interactive_pipe/data_objects/table.py
214 215 216 217 218 219 220 221 222 223 224 | |
create_table
¶
create_table(ax: Optional[Any] = None) -> Any
Create matplotlib table, returns table object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Optional[Any]
|
matplotlib Axes object (optional, will create if None) |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
matplotlib Table object |
Source code in src/interactive_pipe/data_objects/table.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
update_table
¶
update_table(_table_obj: Optional[Any] = None, ax: Optional[Any] = None) -> Any
Update existing matplotlib table.
Note: matplotlib tables don't update well, so we clear and recreate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_table_obj
|
Optional[Any]
|
Previous table object (ignored, kept for API consistency with Curve.update_plot signature) |
None
|
ax
|
Optional[Any]
|
matplotlib Axes object |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
matplotlib Table object |
Source code in src/interactive_pipe/data_objects/table.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |