Skip to content

Commit 2597192

Browse files
committed
Moved cdl.core.computation to cdl.computation
1 parent 6979507 commit 2597192

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2337
-2322
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ for future and past milestones.
337337
parameters for a new signal
338338
* Added `edit_new_image_parameters` method for showing a dialog box to edit
339339
parameters for a new image (updated the *cdl_testdata.py* plugin accordingly)
340-
* Signal and image computations API (`cdl.core.computations`):
340+
* Signal and image computations API (`cdl.computations`):
341341
* Added wrappers for signal and image 1 -> 1 computations
342342
* These wrappers aim at simplifying the creation of a basic computation function
343343
operating on DataLab's native objects (`SignalObj` and `ImageObj`) from a

cdl/algorithms/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
.. seealso::
1010
1111
The :mod:`cdl.algorithms` package is the main entry point for the DataLab
12-
algorithms when manipulating NumPy arrays. See the :mod:`cdl.core.computation`
12+
algorithms when manipulating NumPy arrays. See the :mod:`cdl.computation`
1313
package for algorithms that operate directly on DataLab objects (i.e.
1414
:class:`cdl.obj.SignalObj` and :class:`cdl.obj.ImageObj`).
1515
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Computation (:mod:`cdl.core.computation`)
2+
Computation (:mod:`cdl.computation`)
33
-----------------------------------------
44
55
This package contains the computation functions used by the DataLab project.
@@ -9,7 +9,7 @@
99
1010
.. seealso::
1111
12-
The :mod:`cdl.core.computation` package is the main entry point for the DataLab
12+
The :mod:`cdl.computation` package is the main entry point for the DataLab
1313
computation functions when manipulating DataLab objects.
1414
See the :mod:`cdl.algorithms` package for algorithms that operate directly on
1515
NumPy arrays.
@@ -31,20 +31,20 @@
3131
The computation modules are organized in subpackages according to their purpose.
3232
The following subpackages are available:
3333
34-
- :mod:`cdl.core.computation.base`: Common processing features
35-
- :mod:`cdl.core.computation.signal`: Signal processing features
36-
- :mod:`cdl.core.computation.image`: Image processing features
34+
- :mod:`cdl.computation.base`: Common processing features
35+
- :mod:`cdl.computation.signal`: Signal processing features
36+
- :mod:`cdl.computation.image`: Image processing features
3737
3838
Common processing features
3939
^^^^^^^^^^^^^^^^^^^^^^^^^^
4040
41-
.. automodule:: cdl.core.computation.base
41+
.. automodule:: cdl.computation.base
4242
:members:
4343
4444
Signal processing features
4545
^^^^^^^^^^^^^^^^^^^^^^^^^^
4646
47-
.. automodule:: cdl.core.computation.signal
47+
.. automodule:: cdl.computation.signal
4848
:members:
4949
5050
Image processing features
@@ -53,35 +53,35 @@
5353
Base image processing features
5454
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5555
56-
.. automodule:: cdl.core.computation.image
56+
.. automodule:: cdl.computation.image
5757
:members:
5858
5959
Exposure correction features
6060
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6161
62-
.. automodule:: cdl.core.computation.image.exposure
62+
.. automodule:: cdl.computation.image.exposure
6363
:members:
6464
6565
Restoration features
6666
~~~~~~~~~~~~~~~~~~~~
6767
68-
.. automodule:: cdl.core.computation.image.restoration
68+
.. automodule:: cdl.computation.image.restoration
6969
:members:
7070
7171
Morphological features
7272
~~~~~~~~~~~~~~~~~~~~~~
7373
74-
.. automodule:: cdl.core.computation.image.morphology
74+
.. automodule:: cdl.computation.image.morphology
7575
:members:
7676
7777
Edge detection features
7878
~~~~~~~~~~~~~~~~~~~~~~~
7979
80-
.. automodule:: cdl.core.computation.image.edges
80+
.. automodule:: cdl.computation.image.edges
8181
8282
Detection features
8383
~~~~~~~~~~~~~~~~~~
8484
85-
.. automodule:: cdl.core.computation.image.detection
85+
.. automodule:: cdl.computation.image.detection
8686
:members:
8787
"""
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Copyright (c) DataLab Platform Developers, BSD 3-Clause license, see LICENSE file.
22

33
"""
4-
.. Common computation objects (see parent package :mod:`cdl.core.computation`)
4+
.. Common computation objects (see parent package :mod:`cdl.computation`)
55
"""
66

77
# pylint: disable=invalid-name # Allows short reference names like x, y, ...
88

99
# Note:
1010
# ----
11-
# All dataset classes must also be imported in the cdl.core.computation.param module.
11+
# All dataset classes must also be imported in the cdl.computation.param module.
1212

1313
from __future__ import annotations
1414

@@ -18,14 +18,12 @@
1818
import numpy as np
1919

2020
from cdl.config import _
21-
from cdl.core.model.base import ResultProperties
22-
from cdl.core.model.signal import create_signal
21+
from cdl.obj import ResultProperties, create_signal
2322

2423
if TYPE_CHECKING:
2524
from typing import Callable
2625

27-
from cdl.core.model.image import ImageObj
28-
from cdl.core.model.signal import SignalObj
26+
from cdl.obj import ImageObj, SignalObj
2927

3028

3129
class GaussianParam(gds.DataSet):
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) DataLab Platform Developers, BSD 3-Clause license, see LICENSE file.
22

33
"""
4-
.. Image computation objects (see parent package :mod:`cdl.core.computation`)
4+
.. Image computation objects (see parent package :mod:`cdl.computation`)
55
"""
66

77
# pylint: disable=invalid-name # Allows short reference names like x, y, ...
@@ -25,8 +25,7 @@
2525
from skimage import filters
2626

2727
import cdl.algorithms.image as alg
28-
from cdl.config import _
29-
from cdl.core.computation.base import (
28+
from cdl.computation.base import (
3029
ClipParam,
3130
ConstantOperationParam,
3231
FFTParam,
@@ -41,9 +40,17 @@
4140
dst_n1n,
4241
new_signal_result,
4342
)
44-
from cdl.core.model.base import BaseProcParam, ResultProperties, ResultShape
45-
from cdl.core.model.image import ImageObj, ROI2DParam, RoiDataGeometries, RoiDataItem
46-
from cdl.core.model.signal import SignalObj
43+
from cdl.config import _
44+
from cdl.obj import (
45+
BaseProcParam,
46+
ImageObj,
47+
ImageRoiDataItem,
48+
ResultProperties,
49+
ResultShape,
50+
ROI2DParam,
51+
RoiDataGeometries,
52+
SignalObj,
53+
)
4754

4855
VALID_DTYPES_STRLIST = ImageObj.get_valid_dtypenames()
4956

@@ -62,7 +69,7 @@ class Wrap11Func:
6269
Example:
6370
6471
>>> import numpy as np
65-
>>> from cdl.core.computation.signal import Wrap11Func
72+
>>> from cdl.computation.signal import Wrap11Func
6673
>>> import cdl.obj
6774
>>> def add_noise(data):
6875
... return data + np.random.random(data.shape)
@@ -1191,7 +1198,7 @@ def compute_magnitude_spectrum(
11911198
Output image object
11921199
"""
11931200
dst = dst_11(src, "magnitude_spectrum")
1194-
log_scale = True if p is not None and p.log else False
1201+
log_scale = p is not None and p.log
11951202
dst.data = alg.magnitude_spectrum(src.data, log_scale=log_scale)
11961203
dst.xunit = dst.yunit = dst.zunit = ""
11971204
dst.xlabel = dst.ylabel = _("Frequency")
@@ -1224,7 +1231,7 @@ def compute_psd(src: ImageObj, p: SpectrumParam | None = None) -> ImageObj:
12241231
Output image object
12251232
"""
12261233
dst = dst_11(src, "psd")
1227-
log_scale = True if p is not None and p.log else False
1234+
log_scale = p is not None and p.log
12281235
dst.data = alg.psd(src.data, log_scale=log_scale)
12291236
dst.xunit = dst.yunit = dst.zunit = ""
12301237
dst.xlabel = dst.ylabel = _("Frequency")
@@ -1351,7 +1358,7 @@ def calc_resultshape(
13511358
# Circle [x0, y0, r] or ellipse coordinates [x0, y0, a, b, theta]
13521359
colx, coly = 0, 1
13531360
if obj.roi is not None:
1354-
x0, y0, _x1, _y1 = RoiDataItem(obj.roi[i_roi]).get_rect()
1361+
x0, y0, _x1, _y1 = ImageRoiDataItem(obj.roi[i_roi]).get_rect()
13551362
coords[:, colx] += x0
13561363
coords[:, coly] += y0
13571364
coords[:, colx] = obj.dx * coords[:, colx] + obj.x0
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# Note:
1212
# ----
13-
# All dataset classes must also be imported in the cdl.core.computation.param module.
13+
# All dataset classes must also be imported in the cdl.computation.param module.
1414

1515
from __future__ import annotations
1616

@@ -24,10 +24,9 @@
2424
get_2d_peaks_coords,
2525
get_contour_shapes,
2626
)
27+
from cdl.computation.image import calc_resultshape
2728
from cdl.config import _
28-
from cdl.core.computation.image import calc_resultshape
29-
from cdl.core.model.base import ResultShape, ShapeTypes
30-
from cdl.core.model.image import ImageObj
29+
from cdl.obj import ImageObj, ResultShape, ShapeTypes
3130

3231

3332
class GenericDetectionParam(gds.DataSet):
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010

1111
# Note:
1212
# ----
13-
# All dataset classes must also be imported in the cdl.core.computation.param module.
13+
# All dataset classes must also be imported in the cdl.computation.param module.
1414

1515
from __future__ import annotations
1616

1717
import guidata.dataset as gds
1818
import numpy as np
1919
from skimage import feature, filters
2020

21+
from cdl.computation.image import Wrap11Func, dst_11
2122
from cdl.config import _
22-
from cdl.core.computation.image import Wrap11Func, dst_11
23-
from cdl.core.model.image import ImageObj
23+
from cdl.obj import ImageObj
2424

2525

2626
class CannyParam(gds.DataSet):
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
# Note:
1212
# ----
13-
# All dataset classes must also be imported in the cdl.core.computation.param module.
13+
# All dataset classes must also be imported in the cdl.computation.param module.
1414

1515
from __future__ import annotations
1616

1717
import guidata.dataset as gds
1818
from skimage import exposure
1919

20+
from cdl.computation.image import VALID_DTYPES_STRLIST, dst_11
2021
from cdl.config import _
21-
from cdl.core.computation.image import VALID_DTYPES_STRLIST, dst_11
22-
from cdl.core.model.image import ImageObj
22+
from cdl.obj import ImageObj
2323

2424

2525
class AdjustGammaParam(gds.DataSet):
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
# Note:
1212
# ----
13-
# All dataset classes must also be imported in the cdl.core.computation.param module.
13+
# All dataset classes must also be imported in the cdl.computation.param module.
1414

1515
from __future__ import annotations
1616

1717
import guidata.dataset as gds
1818
from skimage import morphology
1919

20+
from cdl.computation.image import dst_11
2021
from cdl.config import _
21-
from cdl.core.computation.image import dst_11
22-
from cdl.core.model.image import ImageObj
22+
from cdl.obj import ImageObj
2323

2424

2525
class MorphologyParam(gds.DataSet):
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# Note:
1212
# ----
13-
# All dataset classes must also be imported in the cdl.core.computation.param module.
13+
# All dataset classes must also be imported in the cdl.computation.param module.
1414

1515
from __future__ import annotations
1616

@@ -19,10 +19,10 @@
1919
from skimage import morphology
2020
from skimage.restoration import denoise_bilateral, denoise_tv_chambolle, denoise_wavelet
2121

22+
from cdl.computation.image import dst_11
23+
from cdl.computation.image.morphology import MorphologyParam
2224
from cdl.config import _
23-
from cdl.core.computation.image import dst_11
24-
from cdl.core.computation.image.morphology import MorphologyParam
25-
from cdl.core.model.image import ImageObj
25+
from cdl.obj import ImageObj
2626

2727

2828
class DenoiseTVParam(gds.DataSet):

0 commit comments

Comments
 (0)