* **Parent logger can be specified by naming the child logger `'<parent>.<name>'`.**
* **If logger doesn't have a set level it inherits it from the first ancestor that does.**
* **Formatter also accepts: pathname, filename, funcName, lineno, thread and process.**
* **A `'log.handlers.RotatingFileHandler'` creates and deletes log files based on 'maxBytes' and 'backupCount' arguments.**
* **RotatingFileHandler creates and deletes files based on 'maxBytes' and 'backupCount' args.**
* **An object with `'filter(<LogRecord>)'` method (or the method itself) can be added to loggers and handlers via addFilter(). Message is dropped if filter() returns a false value.**
#### Creates a logger that writes all messages to file and sends them to the root's handler that prints warnings or higher:
<dict> = <Sig>.parameters # Dict of Parameters. Also <Sig>.return_annotation.
<memb> = <Param>.kind # Member of ParamKind enum (Parameter.KEYWORD_ONLY, …).
<obj> = <Param>.default # Returns parameter's default value or Parameter.empty.
<type> = <Param>.annotation # Returns parameter's type hint or Parameter.empty.
<obj> = <Param>.default # Parameter.empty if missing. Also <Param>.annotation.
```
@ -2707,32 +2707,33 @@ import numpy as np
```
* **`':'` returns a slice of all dimension's indices. Omitted dimensions default to `':'`.**
* **Indices should not be tuples because Python converts `'obj[i, j]'` to `'obj[(i, j)]'`!**
* **`'ix_()'` returns two 2d arrays. Indices of different shapes get unified with broadcasting.**
* **Indexing with a slice and 1d array works the same as when using two slices (lines 4, 6, 7).**
* **`'ix_([1, 2], [3, 4])'` returns `'[[1], [2]]'` and `'[[3, 4]]'`. Due to broadcasting rules, this is the same as using `'[[1, 1], [2, 2]]'` and `'[[3, 4], [3, 4]]'`.**
* **Any value that is broadcastable to the indexed shape can be assigned to the selection.**
### Broadcasting
**Set of rules by which NumPy functions operate on arrays of different sizes and/or dimensions.**
```python
left = [[0.1], [0.6], [0.8]] # Shape: (3, 1)
right = [ 0.1 , 0.6 , 0.8 ] # Shape: (3,)
left = [ 0.1 , 0.6 , 0.8 ] # Shape: (3,)
right = [[0.1], [0.6], [0.8]] # Shape: (3, 1)
```
#### 1. If array shapes differ in length, left-pad the shorter shape with ones:
```python
left = [[0.1], [0.6], [0.8]] # Shape: (3, 1)
right = [[0.1 , 0.6 , 0.8]] # Shape: (1, 3) <-!
left = [[0.1 , 0.6 , 0.8]] # Shape: (1, 3) <-!
right = [[0.1], [0.6], [0.8]] # Shape: (3, 1)
```
#### 2. If any dimensions differ in size, expand the ones that have size 1 by duplicating their elements:
<li><strong>Parent logger can be specified by naming the child logger <codeclass="python hljs"><spanclass="hljs-string">'<parent>.<name>'</span></code>.</strong></li>
<li><strong>If logger doesn't have a set level it inherits it from the first ancestor that does.</strong></li>
<li><strong>Formatter also accepts: pathname, filename, funcName, lineno, thread and process.</strong></li>
<li><strong>A <codeclass="python hljs"><spanclass="hljs-string">'log.handlers.RotatingFileHandler'</span></code> creates and deletes log files based on 'maxBytes' and 'backupCount' arguments.</strong></li>
<li><strong>RotatingFileHandler creates and deletes files based on 'maxBytes' and 'backupCount' args.</strong></li>
<li><strong>An object with <codeclass="python hljs"><spanclass="hljs-string">'filter(<LogRecord>)'</span></code> method (or the method itself) can be added to loggers and handlers via addFilter(). Message is dropped if filter() returns a false value.</strong></li>
</ul>
<div><h4id="createsaloggerthatwritesallmessagestofileandsendsthemtotherootshandlerthatprintswarningsorhigher">Creates a logger that writes all messages to file and sends them to the root's handler that prints warnings or higher:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>logger = log.getLogger(<spanclass="hljs-string">'my_module'</span>)
<spanclass="hljs-number">2023</span><spanclass="hljs-number">-02</span><spanclass="hljs-number">-07</span><spanclass="hljs-number">23</span>:<spanclass="hljs-number">21</span>:<spanclass="hljs-number">01</span>,<spanclass="hljs-number">430</span> CRITICAL:my_module:Running out of disk space.
2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space.
</code></pre></div>
<div><h2id="introspection"><ahref="#introspection"name="introspection">#</a>Introspection</h2><pre><codeclass="python language-python hljs"><list> = dir() <spanclass="hljs-comment"># Names of local vars, functions, classes and modules.</span>
<li><strong>Coroutines have a lot in common with threads, but unlike threads, they only give up control when they call another coroutine and they don’t use as much memory.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">':'</span></code> returns a slice of all dimension's indices. Omitted dimensions default to <codeclass="python hljs"><spanclass="hljs-string">':'</span></code>.</strong></li>
<li><strong>Indices should not be tuples because Python converts <codeclass="python hljs"><spanclass="hljs-string">'obj[i, j]'</span></code> to <codeclass="python hljs"><spanclass="hljs-string">'obj[(i, j)]'</span></code>!</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'ix_()'</span></code> returns two 2d arrays. Indices of different shapes get unified with broadcasting.</strong></li>
<li><strong>Indexing with a slice and 1d array works the same as when using two slices (lines 4, 6, 7).</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'ix_([1, 2], [3, 4])'</span></code> returns <codeclass="python hljs"><spanclass="hljs-string">'[[1], [2]]'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'[[3, 4]]'</span></code>. Due to broadcasting rules, this is the same as using <codeclass="python hljs"><spanclass="hljs-string">'[[1, 1], [2, 2]]'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'[[3, 4], [3, 4]]'</span></code>.</strong></li>
<li><strong>Any value that is broadcastable to the indexed shape can be assigned to the selection.</strong></li>
</ul>
<div><h3id="broadcasting">Broadcasting</h3><p><strong>Set of rules by which NumPy functions operate on arrays of different sizes and/or dimensions.</strong></p><pre><codeclass="python language-python hljs">left = [[<spanclass="hljs-number">0.1</span>], [<spanclass="hljs-number">0.6</span>], [<spanclass="hljs-number">0.8</span>]] <spanclass="hljs-comment"># Shape: (3, 1)</span>
right = [<spanclass="hljs-number">0.1</span> , <spanclass="hljs-number">0.6</span> , <spanclass="hljs-number">0.8</span>] <spanclass="hljs-comment"># Shape: (3,)</span>
<div><h3id="broadcasting">Broadcasting</h3><p><strong>Set of rules by which NumPy functions operate on arrays of different sizes and/or dimensions.</strong></p><pre><codeclass="python language-python hljs">left = [<spanclass="hljs-number">0.1</span> , <spanclass="hljs-number">0.6</span> , <spanclass="hljs-number">0.8</span>] <spanclass="hljs-comment"># Shape: (3,)</span>
right = [[<spanclass="hljs-number">0.1</span>], [<spanclass="hljs-number">0.6</span>], [<spanclass="hljs-number">0.8</span>]] <spanclass="hljs-comment"># Shape: (3, 1)</span>
</code></pre></div>
<div><h4id="1ifarrayshapesdifferinlengthleftpadtheshortershapewithones">1. If array shapes differ in length, left-pad the shorter shape with ones:</h4><pre><codeclass="python language-python hljs">left = [[<spanclass="hljs-number">0.1</span>], [<spanclass="hljs-number">0.6</span>], [<spanclass="hljs-number">0.8</span>]] <spanclass="hljs-comment"># Shape: (3, 1)</span>
<div><h4id="1ifarrayshapesdifferinlengthleftpadtheshortershapewithones">1. If array shapes differ in length, left-pad the shorter shape with ones:</h4><pre><codeclass="python language-python hljs">left = [[<spanclass="hljs-number">0.1</span> , <spanclass="hljs-number">0.6</span> , <spanclass="hljs-number">0.8</span>]] <spanclass="hljs-comment"># Shape: (1, 3) <- !</span>
right = [[<spanclass="hljs-number">0.1</span>], [<spanclass="hljs-number">0.6</span>], [<spanclass="hljs-number">0.8</span>]] <spanclass="hljs-comment"># Shape: (3, 1)</span>
</code></pre></div>
<div><h4id="2ifanydimensionsdifferinsizeexpandtheonesthathavesize1byduplicatingtheirelements">2. If any dimensions differ in size, expand the ones that have size 1 by duplicating their elements:</h4><pre><codeclass="python language-python hljs">left = [[<spanclass="hljs-number">0.1</span>, <spanclass="hljs-number">0.1</span>, <spanclass="hljs-number">0.1</span>], <spanclass="hljs-comment"># Shape: (3, 3) <- !</span>
<div><h4id="2ifanydimensionsdifferinsizeexpandtheonesthathavesize1byduplicatingtheirelements">2. If any dimensions differ in size, expand the ones that have size 1 by duplicating their elements:</h4><pre><codeclass="python language-python hljs">left = [[<spanclass="hljs-number">0.1</span>, <spanclass="hljs-number">0.6</span>, <spanclass="hljs-number">0.8</span>], <spanclass="hljs-comment"># Shape: (3, 3) <- !</span>
<div><h3id="example-3">Example</h3><div><h4id="foreachpointreturnsindexofitsnearestpoint010608121">For each point returns index of its nearest point (<codeclass="python hljs">[<spanclass="hljs-number">0.1</span>, <spanclass="hljs-number">0.6</span>, <spanclass="hljs-number">0.8</span>] => [<spanclass="hljs-number">1</span>, <spanclass="hljs-number">2</span>, <spanclass="hljs-number">1</span>]</code>):</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>points = np.array([<spanclass="hljs-number">0.1</span>, <spanclass="hljs-number">0.6</span>, <spanclass="hljs-number">0.8</span>])