|
25 | 25 | from __future__ import annotations |
26 | 26 |
|
27 | 27 | import abc |
28 | | -from collections.abc import Callable |
29 | 28 | from contextlib import contextmanager |
30 | 29 | from typing import TYPE_CHECKING, Generator |
31 | 30 |
|
@@ -148,9 +147,9 @@ def context_no_refresh(self) -> Generator[None, None, None]: |
148 | 147 |
|
149 | 148 | >>> with proxy.context_no_refresh(): |
150 | 149 | ... proxy.add_image("image1", data1) |
151 | | - ... proxy.compute_fft() |
152 | | - ... proxy.compute_wiener() |
153 | | - ... proxy.compute_ifft() |
| 150 | + ... proxy.calc("fft") |
| 151 | + ... proxy.calc("wiener") |
| 152 | + ... proxy.calc("ifft") |
154 | 153 | ... # Auto refresh is disabled during the above operations |
155 | 154 | """ |
156 | 155 | self.toggle_auto_refresh(False) |
@@ -495,44 +494,23 @@ def import_macro_from_file(self, filename: str) -> None: |
495 | 494 |
|
496 | 495 | @abc.abstractmethod |
497 | 496 | def calc(self, name: str, param: gds.DataSet | None = None) -> gds.DataSet: |
498 | | - """Call compute function ``name`` in current panel's processor. |
| 497 | + """Call computation feature ``name`` |
499 | 498 |
|
500 | | - Args: |
501 | | - name: Compute function name |
502 | | - param: Compute function parameter. Defaults to None. |
503 | | -
|
504 | | - Raises: |
505 | | - ValueError: unknown function |
506 | | - """ |
| 499 | + .. note:: |
507 | 500 |
|
508 | | - def __getattr__(self, name: str) -> Callable: |
509 | | - """Return compute function ``name`` in current panel's processor. |
| 501 | + This calls either the processor's ``compute_<name>`` method (if it exists), |
| 502 | + or the processor's ``<name>`` computation feature (if it is registered, |
| 503 | + using the ``run_feature`` method). |
| 504 | + It looks for the function in all panels, starting with the current one. |
510 | 505 |
|
511 | 506 | Args: |
512 | 507 | name: Compute function name |
513 | | -
|
514 | | - Returns: |
515 | | - Callable: Compute function |
| 508 | + param: Compute function parameter. Defaults to None. |
516 | 509 |
|
517 | 510 | Raises: |
518 | | - AttributeError: If compute function ``name`` does not exist |
| 511 | + ValueError: unknown function |
519 | 512 | """ |
520 | 513 |
|
521 | | - def compute_func(param: gds.DataSet | None = None) -> gds.DataSet: |
522 | | - """Compute function. |
523 | | -
|
524 | | - Args: |
525 | | - param: Compute function parameter. Defaults to None. |
526 | | -
|
527 | | - Returns: |
528 | | - Compute function result |
529 | | - """ |
530 | | - return self.calc(name, param) |
531 | | - |
532 | | - if name.startswith("compute_"): |
533 | | - return compute_func |
534 | | - raise AttributeError(f"DataLab has no compute function '{name}'") |
535 | | - |
536 | 514 |
|
537 | 515 | class BaseProxy(AbstractDLControl, metaclass=abc.ABCMeta): |
538 | 516 | """Common base class for DataLab proxies |
|
0 commit comments