Skip to content

Commit 46e3f72

Browse files
committed
u
1 parent b5e0bad commit 46e3f72

5 files changed

Lines changed: 120 additions & 88 deletions

File tree

tutorials/3-advanced-topics/DTAT387_types.ipynb

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
},
5454
{
5555
"cell_type": "code",
56-
"execution_count": null,
56+
"execution_count": 2,
5757
"metadata": {},
5858
"outputs": [],
5959
"source": [
@@ -62,32 +62,43 @@
6262
"def matrix_add(\n",
6363
" input: ArrayLike[float]\n",
6464
") -> ArrayLike[float]:\n",
65-
" \n",
65+
" \"\"\"Function docsting.\"\"\"\n",
6666
" return input + input"
6767
]
6868
},
6969
{
7070
"cell_type": "markdown",
7171
"metadata": {},
7272
"source": [
73-
"And in the context of DeepTrack2, a larger class with several type hints can look something like the following:\n",
74-
"```python\n",
75-
"class Augmentation(Feature):\n",
73+
"And in the context of DeepTrack2, a larger class with several type hints can look something like the following:"
74+
]
75+
},
76+
{
77+
"cell_type": "code",
78+
"execution_count": 3,
79+
"metadata": {},
80+
"outputs": [],
81+
"source": [
82+
"from __future__ import annotations\n",
83+
"import deeptrack as dt\n",
84+
"from deeptrack.types import PropertyLike\n",
85+
"\n",
86+
"class Augmentation(dt.Feature):\n",
87+
"\n",
7688
" def __init__(\n",
77-
" self,\n",
89+
" self: Augmentation,\n",
7890
" time_consistent: bool = False,\n",
7991
" **kwargs\n",
8092
" ) -> None:\n",
8193
" super().__init__(time_consistent=time_consistent, **kwargs)\n",
8294
"\n",
83-
" def _image_wrapped_process_and_get (\n",
84-
" self,\n",
85-
" image_list: List[Image],\n",
95+
" def _image_wrapped_process_and_get(\n",
96+
" self: Augmentation,\n",
97+
" image_list: list[Image],\n",
8698
" time_consistent: PropertyLike[bool],\n",
8799
" **kwargs\n",
88-
" ) -> List[List]:\n",
89-
"\n",
90-
"```"
100+
" ) -> list[Image]:\n",
101+
" pass"
91102
]
92103
},
93104
{
@@ -99,33 +110,59 @@
99110
"We will now declare a new type hint of our own which will represent non-integer numeric datatypes with higher precision than the standard float datatype. We will use `Union` for this, which lets us gather datatypes into a single set."
100111
]
101112
},
113+
{
114+
"cell_type": "markdown",
115+
"metadata": {},
116+
"source": [
117+
"Declare the new type using Union ..."
118+
]
119+
},
102120
{
103121
"cell_type": "code",
104-
"execution_count": null,
122+
"execution_count": 4,
105123
"metadata": {},
106-
"outputs": [],
124+
"outputs": [
125+
{
126+
"name": "stdout",
127+
"output_type": "stream",
128+
"text": [
129+
"typing.Union[numpy.float64, numpy.longdouble, numpy.clongdouble]\n"
130+
]
131+
}
132+
],
107133
"source": [
108-
"from typing import Union\n",
109134
"import numpy as np\n",
135+
"from typing import Union\n",
110136
"\n",
111-
"# Declare type with Union.\n",
112137
"DoubleLike = Union[np.float64, np.longdouble, np.longcomplex]\n",
113-
"print(DoubleLike)\n",
114-
"\n",
115-
"# Declare function with new type hint.\n",
138+
"print(DoubleLike)"
139+
]
140+
},
141+
{
142+
"cell_type": "markdown",
143+
"metadata": {},
144+
"source": [
145+
"... and declare function with new type hint."
146+
]
147+
},
148+
{
149+
"cell_type": "code",
150+
"execution_count": 5,
151+
"metadata": {},
152+
"outputs": [],
153+
"source": [
116154
"def double_add(\n",
117155
" input: ArrayLike[DoubleLike],\n",
118156
" number: DoubleLike\n",
119157
") -> ArrayLike[DoubleLike]:\n",
120-
" \n",
121-
" return input + number\n",
122-
"\n"
158+
" \"\"\"Function docsting.\"\"\"\n",
159+
" return input + number"
123160
]
124161
}
125162
],
126163
"metadata": {
127164
"kernelspec": {
128-
"display_name": "Python 3",
165+
"display_name": "py_env_book",
129166
"language": "python",
130167
"name": "python3"
131168
},
@@ -139,7 +176,7 @@
139176
"name": "python",
140177
"nbconvert_exporter": "python",
141178
"pygments_lexer": "ipython3",
142-
"version": "3.9.13"
179+
"version": "3.10.15"
143180
}
144181
},
145182
"nbformat": 4,

tutorials/3-advanced-topics/DTAT389_elementwise.ipynb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"source": [
3232
"## 1. What is elementwise?\n",
3333
"\n",
34-
"The elementwise module introduces utility functions which lets the user apply Numpy functions to `Feature` objects elementwise.\n",
34+
"The elementwise module introduces utility functions which lets the user apply Numpy functions to `Feature` objects elementwise, that is element by element.\n",
35+
"\n",
3536
"Some functions included in elementwise are:\n",
3637
"\n",
3738
"- Trigonometric\n",
@@ -45,14 +46,14 @@
4546
"cell_type": "markdown",
4647
"metadata": {},
4748
"source": [
48-
"## 2. Initialize a `Feature`\n",
49+
"## 2. Use example\n",
4950
"\n",
50-
"We create a feature that subtracts values from an image."
51+
"Create a feature that subtracts values from an image ..."
5152
]
5253
},
5354
{
5455
"cell_type": "code",
55-
"execution_count": null,
56+
"execution_count": 2,
5657
"metadata": {},
5758
"outputs": [
5859
{
@@ -67,7 +68,6 @@
6768
"import numpy as np\n",
6869
"from deeptrack.features import Feature\n",
6970
"\n",
70-
"\n",
7171
"class Subtract(Feature):\n",
7272
" def get(self, image, value, **kwargs):\n",
7373
" return image - value\n",
@@ -83,12 +83,12 @@
8383
"cell_type": "markdown",
8484
"metadata": {},
8585
"source": [
86-
"## 3. Compute the Absolute value of the feature (In sequence)\n"
86+
"... and compute the absolute value of the feature (in sequence)."
8787
]
8888
},
8989
{
9090
"cell_type": "code",
91-
"execution_count": null,
91+
"execution_count": 3,
9292
"metadata": {},
9393
"outputs": [
9494
{
@@ -103,7 +103,6 @@
103103
"source": [
104104
"from deeptrack.elementwise import Abs\n",
105105
"\n",
106-
"\n",
107106
"# Sequentially take the absolute value after subtraction.\n",
108107
"pipeline = Abs(subtract_10)\n",
109108
"output_image = pipeline(input_image)\n",
@@ -118,7 +117,7 @@
118117
],
119118
"metadata": {
120119
"kernelspec": {
121-
"display_name": "Python 3",
120+
"display_name": "py_env_book",
122121
"language": "python",
123122
"name": "python3"
124123
},
@@ -132,7 +131,7 @@
132131
"name": "python",
133132
"nbconvert_exporter": "python",
134133
"pygments_lexer": "ipython3",
135-
"version": "3.9.13"
134+
"version": "3.10.15"
136135
}
137136
},
138137
"nbformat": 4,

tutorials/3-advanced-topics/DTAT391A_sources.base.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"child_b = node.b\n",
6666
"\n",
6767
"# Call child nodes.\n",
68-
"print (child_a() + child_b())"
68+
"print(child_a() + child_b())"
6969
]
7070
},
7171
{
@@ -77,7 +77,7 @@
7777
},
7878
{
7979
"cell_type": "code",
80-
"execution_count": null,
80+
"execution_count": 3,
8181
"metadata": {},
8282
"outputs": [
8383
{
@@ -114,7 +114,7 @@
114114
},
115115
{
116116
"cell_type": "code",
117-
"execution_count": null,
117+
"execution_count": 4,
118118
"metadata": {},
119119
"outputs": [
120120
{
@@ -153,7 +153,7 @@
153153
},
154154
{
155155
"cell_type": "code",
156-
"execution_count": null,
156+
"execution_count": 5,
157157
"metadata": {},
158158
"outputs": [
159159
{
@@ -190,7 +190,7 @@
190190
},
191191
{
192192
"cell_type": "code",
193-
"execution_count": null,
193+
"execution_count": 6,
194194
"metadata": {},
195195
"outputs": [
196196
{
@@ -231,7 +231,7 @@
231231
},
232232
{
233233
"cell_type": "code",
234-
"execution_count": null,
234+
"execution_count": 7,
235235
"metadata": {},
236236
"outputs": [
237237
{
@@ -279,7 +279,7 @@
279279
],
280280
"metadata": {
281281
"kernelspec": {
282-
"display_name": "Python 3",
282+
"display_name": "py_env_book",
283283
"language": "python",
284284
"name": "python3"
285285
},
@@ -293,7 +293,7 @@
293293
"name": "python",
294294
"nbconvert_exporter": "python",
295295
"pygments_lexer": "ipython3",
296-
"version": "3.9.13"
296+
"version": "3.10.15"
297297
}
298298
},
299299
"nbformat": 4,

tutorials/3-advanced-topics/DTAT391C_sources.rng.ipynb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
{
4646
"cell_type": "code",
47-
"execution_count": null,
47+
"execution_count": 2,
4848
"metadata": {
4949
"execution": {
5050
"iopub.execute_input": "2022-06-29T20:33:47.187180Z",
@@ -58,12 +58,12 @@
5858
"name": "stdout",
5959
"output_type": "stream",
6060
"text": [
61-
"Python rng #0 yields a Random Number -> 36\n",
62-
"Python rng #1 yields a Random Number -> 83\n",
63-
"Python rng #2 yields a Random Number -> 28\n",
64-
"Python rng #0 yields a Random Number -> 36\n",
65-
"Python rng #1 yields a Random Number -> 83\n",
66-
"Python rng #2 yields a Random Number -> 28\n"
61+
"Python rng #0 yields a Random Number: 36\n",
62+
"Python rng #1 yields a Random Number: 83\n",
63+
"Python rng #2 yields a Random Number: 28\n",
64+
"Python rng #0 yields a Random Number: 36\n",
65+
"Python rng #1 yields a Random Number: 83\n",
66+
"Python rng #2 yields a Random Number: 28\n"
6767
]
6868
}
6969
],
@@ -95,19 +95,19 @@
9595
},
9696
{
9797
"cell_type": "code",
98-
"execution_count": null,
98+
"execution_count": 3,
9999
"metadata": {},
100100
"outputs": [
101101
{
102102
"name": "stdout",
103103
"output_type": "stream",
104104
"text": [
105-
"Numpy rng #0 yields a Random Number -> 4\n",
106-
"Numpy rng #1 yields a Random Number -> 88\n",
107-
"Numpy rng #2 yields a Random Number -> 55\n",
108-
"Numpy rng #0 yields a Random Number -> 4\n",
109-
"Numpy rng #1 yields a Random Number -> 88\n",
110-
"Numpy rng #2 yields a Random Number -> 55\n"
105+
"Numpy rng #0 yields a Random Number: 4\n",
106+
"Numpy rng #1 yields a Random Number: 88\n",
107+
"Numpy rng #2 yields a Random Number: 55\n",
108+
"Numpy rng #0 yields a Random Number: 4\n",
109+
"Numpy rng #1 yields a Random Number: 88\n",
110+
"Numpy rng #2 yields a Random Number: 55\n"
111111
]
112112
}
113113
],
@@ -132,7 +132,7 @@
132132
],
133133
"metadata": {
134134
"kernelspec": {
135-
"display_name": "Python 3",
135+
"display_name": "py_env_book",
136136
"language": "python",
137137
"name": "python3"
138138
},
@@ -146,7 +146,7 @@
146146
"name": "python",
147147
"nbconvert_exporter": "python",
148148
"pygments_lexer": "ipython3",
149-
"version": "3.9.13"
149+
"version": "3.10.15"
150150
}
151151
},
152152
"nbformat": 4,

0 commit comments

Comments
 (0)