Skip to content

Commit cac606f

Browse files
committed
Doc updates & clean ups
1 parent b694831 commit cac606f

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

fooof/bands.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
"""Oscillation band defintion object for OM."""
1+
"""A class for managing band definitions."""
22

33
from collections import OrderedDict
44

55
###################################################################################################
66
###################################################################################################
77

88
class Bands():
9-
"""Class to hold definitions of oscillation bands.
9+
"""Class to hold bands definitions.
1010
1111
Attributes
1212
----------
1313
bands : dict
1414
Dictionary of band definitions.
15+
Each entry should be as {'label' : (f_low, f_high)}.
1516
"""
1617

1718
def __init__(self, input_bands={}):
@@ -28,38 +29,33 @@ def __init__(self, input_bands={}):
2829
for label, band_def in input_bands.items():
2930
self.add_band(label, band_def)
3031

31-
32-
def __getitem__(self, name):
32+
def __getitem__(self, label):
3333

3434
try:
35-
return self.bands[name]
35+
return self.bands[label]
3636
except KeyError:
37-
raise BandNotDefinedError from None
38-
39-
40-
def __getattr__(self, name):
37+
message = "The label '{}' was not found in the defined bands.".format(label)
38+
raise BandNotDefinedError(message) from None
4139

42-
return self.__getitem__(name)
40+
def __getattr__(self, label):
4341

42+
return self.__getitem__(label)
4443

4544
def __repr__(self):
4645

4746
return '\n'.join(['{:8} : {:2} - {:2} Hz'.format(key, *val) \
4847
for key, val in self.bands.items()])
4948

50-
5149
def __len__(self):
5250

5351
return self.n_bands
5452

55-
5653
@property
5754
def labels(self):
5855
"""Get the labels for all bands defined in the object."""
5956

6057
return list(self.bands.keys())
6158

62-
6359
@property
6460
def n_bands(self):
6561
"""Get the number of bands defined in the object."""
@@ -73,7 +69,7 @@ def add_band(self, label, band_definition):
7369
Parameters
7470
----------
7571
label : str
76-
Label of the band to add.
72+
Band label to add.
7773
band_definition : tuple of (float, float)
7874
The lower and upper frequency limit of the band, in Hz.
7975
"""
@@ -121,7 +117,7 @@ def _check_band(label, band_definition):
121117

122118
# Safety check that limits are in correct order
123119
if not band_definition[0] < band_definition[1]:
124-
raise InconsistentDataError('Band limits are incorrect.')
120+
raise InconsistentDataError('Band limit definitions are invalid.')
125121

126122

127123
class BandNotDefinedError(Exception):

0 commit comments

Comments
 (0)