Skip to content

function naming convention #60

@agramfort

Description

@agramfort

what are the naming convention for functions?

  • is seems weird that get_spectra is the only name that starts with get_*. Why not spectra?
  • functions that returns similar quantities (eg. PSD estimates) should have common name prefix (or maybe suffix).
  • freq_response should make explicit that it works on IR models.
  • I don't like get_spectra_bi as it reminds me of bispectrum estimates which is not.
  • functions that are auxiliary functions (ie should not be used by average user) should start with _ to be explicitly marked as private (eg. it seems in coherence.py that all foo_compute functions are auxiliary functions to foo functions hence should be name rather _foo). The point is that the user should quickly see which function to use.
  • why sometimes mtm_ and sometimes multi_taper_ to refer to multi-taper method?

below the list of functions in spectral.

algorithms/spectral.py:
20 : def get_spectra(time_series, method=None):
144 : def get_spectra_bi(x, y, method=None):
186 : def periodogram(s, Fs=2 * np.pi, Sk=None, N=None, sides='default',
262 : def periodogram_csd(s, Fs=2 * np.pi, Sk=None, NFFT=None, sides='default',
369 : def dpss_windows(N, NW, Kmax):
449 : def mtm_cross_spectrum(tx, ty, weights, sides='twosided'):
557 : def multi_taper_psd(s, Fs=2 * np.pi, BW=None, adaptive=False,
710 : def multi_taper_csd(s, Fs=2 * np.pi, BW=None, low_bias=True,
834 : def freq_response(b, a=1., n_freqs=1024, sides='onesided'):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions