Skip to content

Commit

Permalink
STY, DOC: Fix issues from prettier and linters
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed May 9, 2024
1 parent 3138209 commit 4d1dcf0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 29 deletions.
4 changes: 2 additions & 2 deletions doc/source/regression/dwt-idwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function:
# for documentation tests -->
<!-- though the doctests might not be needed anymore because MyST is testing -->
<!-- these by executing the notebooks? -->

```{code-cell}
int(pywt.dwt_coeff_len(data_len=len(x), filter_len=w.dec_len, mode='symmetric'))
```
Expand Down Expand Up @@ -143,10 +144,9 @@ print(pywt.idwt(cA, cD, 'sym3', 'periodization'))
### Passing `None` instead of coefficients data to {func}`idwt`

Now, we showcase some tips & tricks. Passing `None` as one of the coefficient
arrays parameters is similar to passing a *zero-filled* array. The results are
arrays parameters is similar to passing a _zero-filled_ array. The results are
simply the same:


```{code-cell}
print(pywt.idwt([1,2,0,1], None, 'db2', 'symmetric'))
```
Expand Down
5 changes: 3 additions & 2 deletions doc/source/regression/gotchas.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ The results are:
```{code-cell}
numpy.all(numpy.isnan(cA))
```
<!-- True -->

<!-- True -->

```{code-cell}
numpy.all(numpy.isnan(cD))
```
<!-- True -->

<!-- True -->

```{code-cell}
rec = pywt.idwt(cA, cD, wavelet, mode)
numpy.all(numpy.isnan(rec))
```

<!-- True -->
2 changes: 0 additions & 2 deletions doc/source/regression/multilevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ cA2
cD2
```



```{code-cell}
[(cA2, cD2)] = pywt.swt(cA1, db1, level=1, start_level=1)
```
Expand Down
10 changes: 4 additions & 6 deletions doc/source/regression/wavelet.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ kernelspec:
## Wavelet families and builtin Wavelets names

{class}`Wavelet` objects are really a handy carriers of a bunch of DWT-specific
data like *quadrature mirror filters* and some general properties associated
data like _quadrature mirror filters_ and some general properties associated
with them.

At first let's go through the methods of creating a {class}`Wavelet` object.
Expand Down Expand Up @@ -108,6 +108,7 @@ print(w.family_name)

<!-- # int() is for normalizing longs and ints for doctest -->
<!-- TODO: FIXME: note: might not be needed anymore -->

```{code-cell}
int(w.dec_len)
```
Expand All @@ -122,21 +123,18 @@ int(w.rec_len)
w.orthogonal
```


```{code-cell}
w.biorthogonal
```


3. Symmetry ({attr}`~Wavelet.symmetry`):

```{code-cell}
print(w.symmetry)
```


4. Number of vanishing moments for the scaling function `phi` ({attr}`~Wavelet.vanishing_moments_phi`)
and the wavelet function `psi` ({attr}`~Wavelet.vanishing_moments_psi`), associated with the filters:
and the wavelet function `psi` ({attr}`~Wavelet.vanishing_moments_psi`), associated with the filters:

```{code-cell}
w.vanishing_moments_phi
Expand All @@ -150,7 +148,7 @@ Now when we know a bit about the builtin Wavelets, let's see how to create
{ref}`custom Wavelets <custom-wavelets>` objects. These can be done in two ways:

1. Passing the filter bank object that implements the `filter_bank` attribute. The
attribute must return four filters coefficients.
attribute must return four filters coefficients.

```{code-cell}
class MyHaarFilterBank(object):
Expand Down
8 changes: 2 additions & 6 deletions doc/source/regression/wp.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ kernelspec:
```

<!-- not sure if this is needed anymore? -->

```{code-cell}
---
tags: [hide-input]
Expand Down Expand Up @@ -51,7 +52,6 @@ def format_array(a):
return numpy.array2string(a, precision=5, separator=' ', suppress_small=True)
```


## Create Wavelet Packet structure

Okay, let's create a sample {class}`WaveletPacket` object:
Expand Down Expand Up @@ -115,7 +115,6 @@ print(wp['a'].data)
print(wp['a'].path)
```


- 2nd level:

```{code-cell}
Expand All @@ -126,7 +125,6 @@ print(wp['aa'].data)
print(wp['aa'].path)
```


- 3rd level:

```{code-cell}
Expand Down Expand Up @@ -225,7 +223,6 @@ print([node.path for node in wp.get_level(3, 'freq')])
Note that {meth}`WaveletPacket.get_level` also performs automatic decomposition
until it reaches the specified `level`.


## Reconstructing data from Wavelet Packets

```{code-cell}
Expand Down Expand Up @@ -284,7 +281,6 @@ print([n.path for n in new_wp.get_leaf_nodes(False)])
print([n.path for n in new_wp.get_leaf_nodes(True)])
```


## Removing nodes from Wavelet Packet tree

Let's create some sample data:
Expand Down Expand Up @@ -366,7 +362,7 @@ print(wp.a)
**Remember that you should not rely on the attribute access.**

2. At the first attempt to access the node, it is computed via the decomposition
of its parent node (which is the `wp` object itself).
of its parent node (which is the `wp` object itself).

```{code-cell}
print(wp['a'])
Expand Down
15 changes: 4 additions & 11 deletions doc/source/regression/wp2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ kernelspec:
## Import pywt

<!-- TODO: check if needed anymore -->

```{code-cell}
from __future__ import print_function
import pywt
Expand Down Expand Up @@ -159,6 +160,7 @@ print(wp['aaaa'].data)
```

<!-- not sure what "Ups" means in the next sentence -->

Ups, we have reached the maximum level of decomposition for the `'aaaa'` path,
which, by the way, was:

Expand Down Expand Up @@ -186,42 +188,34 @@ just like with {class}`Node` and {class}`WaveletPacket` for the 1D case.).
print(wp['av'].data)
```


```{code-cell}
print(wp['av'].path)
```


```{code-cell}
print(wp['av'].node_name)
```


```{code-cell}
print(wp['av'].parent.path)
```


```{code-cell}
print(wp['av'].parent.data)
```


```{code-cell}
print(wp['av'].level)
```


```{code-cell}
print(wp['av'].maxlevel)
```


```{code-cell}
print(wp['av'].mode)
```


### Collecting nodes

We can get all nodes on the particular level using the
Expand All @@ -247,7 +241,6 @@ len(wp.get_level(1))
print([node.path for node in wp.get_level(1)])
```


- 2nd level of decomposition:

```{code-cell}
Expand Down Expand Up @@ -314,7 +307,7 @@ Note: just remember to not assign to the `node.data parameter directly (TODO).

And reconstruct the data from the `a`, `d`, `vh`, `vv`, `vd` and `h`
packets (Note that `va` node was not set and the WP tree is "not complete"
\- the `va` branch will be treated as *zero-array*):
\- the `va` branch will be treated as _zero-array_):

```{code-cell}
print(new_wp.reconstruct(update=False))
Expand Down Expand Up @@ -371,7 +364,7 @@ print([n.path for n in new_wp.get_leaf_nodes()])
```

Passing the `decompose = True` parameter to the method will force the WP
object to do a full decomposition up to the *maximum level* of decomposition:
object to do a full decomposition up to the _maximum level_ of decomposition:

```{code-cell}
paths = [n.path for n in new_wp.get_leaf_nodes(decompose=True)]
Expand Down

0 comments on commit 4d1dcf0

Please sign in to comment.