Skip to content

Commit a22e951

Browse files
authored
Merge pull request #457 from grlee77/backport_pr438
MAINT: 1.0.x Fix spelling of "Garrote"
2 parents bb84363 + 6a41e86 commit a22e951

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

doc/source/pyplots/plot_thresholds.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
s_soft = pywt.threshold(s, value=0.5, mode='soft')
88
s_hard = pywt.threshold(s, value=0.5, mode='hard')
9-
s_garotte = pywt.threshold(s, value=0.5, mode='garotte')
9+
s_garrote = pywt.threshold(s, value=0.5, mode='garrote')
1010
s_firm1 = pywt.threshold_firm(s, value_low=0.5, value_high=1)
1111
s_firm2 = pywt.threshold_firm(s, value_low=0.5, value_high=2)
1212
s_firm3 = pywt.threshold_firm(s, value_low=0.5, value_high=4)
1313

1414
fig, ax = plt.subplots(1, 2, figsize=(10, 4))
1515
ax[0].plot(s, s_soft)
1616
ax[0].plot(s, s_hard)
17-
ax[0].plot(s, s_garotte)
18-
ax[0].legend(['soft (0.5)', 'hard (0.5)', 'non-neg. garotte (0.5)'])
17+
ax[0].plot(s, s_garrote)
18+
ax[0].legend(['soft (0.5)', 'hard (0.5)', 'non-neg. garrote (0.5)'])
1919
ax[0].set_xlabel('input value')
2020
ax[0].set_ylabel('thresholded value')
2121

pywt/_thresholding.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def soft(data, value, substitute=0):
3232

3333

3434
def nn_garrote(data, value, substitute=0):
35-
"""Non-negative Garotte."""
35+
"""Non-negative Garrote."""
3636
data = np.asarray(data)
3737
magnitude = np.absolute(data)
3838

@@ -73,7 +73,10 @@ def less(data, value, substitute=0):
7373
'hard': hard,
7474
'greater': greater,
7575
'less': less,
76-
'garotte': nn_garrote}
76+
'garrote': nn_garrote,
77+
# misspelled garrote for backwards compatibility
78+
'garotte': nn_garrote,
79+
}
7780

7881

7982
def threshold(data, value, mode='soft', substitute=0):
@@ -90,7 +93,7 @@ def threshold(data, value, mode='soft', substitute=0):
9093
less than the value param are replaced with `substitute`. Data values with
9194
absolute value greater or equal to the thresholding value stay untouched.
9295
93-
``garotte`` corresponds to the Non-negative garrote threshold [2]_, [3]_.
96+
``garrote`` corresponds to the Non-negative garrote threshold [2]_, [3]_.
9497
It is intermediate between ``hard`` and ``soft`` thresholding. It behaves
9598
like soft thresholding for small data values and approaches hard
9699
thresholding for large data values.
@@ -109,7 +112,7 @@ def threshold(data, value, mode='soft', substitute=0):
109112
Numeric data.
110113
value : scalar
111114
Thresholding value.
112-
mode : {'soft', 'hard', 'greater', 'less'}
115+
mode : {'soft', 'hard', 'garrote', 'greater', 'less'}
113116
Decides the type of thresholding to be applied on input data. Default
114117
is 'soft'.
115118
substitute : float, optional
@@ -148,7 +151,7 @@ def threshold(data, value, mode='soft', substitute=0):
148151
array([ 0. , 0. , 0. , 0.5, 1. , 1.5, 2. ])
149152
>>> pywt.threshold(data, 2, 'hard')
150153
array([ 0. , 0. , 2. , 2.5, 3. , 3.5, 4. ])
151-
>>> pywt.threshold(data, 2, 'garotte')
154+
>>> pywt.threshold(data, 2, 'garrote')
152155
array([ 0. , 0. , 0. , 0.9 , 1.66666667,
153156
2.35714286, 3. ])
154157
>>> pywt.threshold(data, 2, 'greater')

0 commit comments

Comments
 (0)