<commit_before>from pymatbridge import Matlab
import matplotlib.pylab as plt
import os
import numpy as np

mlab = Matlab()
mlab.start()
dir_path = os.path.dirname(os.path.realpath(__file__))
dir_list = ['/HHT_MATLAB_package', '/HHT_MATLAB_package/EEMD',
          '/HHT_MATLAB_package/checkIMFs', '/HHT_MATLAB_package/HSA']
for d in dir_list:
    res = mlab.run_func('addpath', dir_path + d)

class HSA():
    def __init__(self, imfs, dt, ifmethod='hilbtm', normmethod='pchip', nfilter=0):
        fa_res = mlab.run_func('fa', imfs, dt, ifmethod, normmethod, nfilter, nargout=2)
        fa = fa_res['result']
        self.imfs = imfs
        self.ifmethod = ifmethod
        self.normmethod = normmethod
        self.ifreq = fa[0]
        self.iamp = fa[1]

    def plot_hs(self, time, trange, frange, tres, fres, hsize, sigma,
                tunit='s', funit='Hz', colorbar = 'energy', savefig_name=''):
        time = time - time[0]
        tstart = trange[0]
        tend = trange[1]
        fstart = frange[0]
        fend = frange[1]
        if colorbar == 'amplitude':<commit_msg>fix shape error of ifreq and iamp<commit_after>from pymatbridge import Matlab
import matplotlib.pylab as plt
import os
import numpy as np

mlab = Matlab()
mlab.start()
dir_path = os.path.dirname(os.path.realpath(__file__))
dir_list = ['/HHT_MATLAB_package', '/HHT_MATLAB_package/EEMD',
          '/HHT_MATLAB_package/checkIMFs', '/HHT_MATLAB_package/HSA']
for d in dir_list:
    res = mlab.run_func('addpath', dir_path + d)

class HSA():
    def __init__(self, imfs, dt, ifmethod='hilbtm', normmethod='pchip', nfilter=0):
        fa_res = mlab.run_func('fa', imfs, dt, ifmethod, normmethod, nfilter, nargout=2)
        fa = fa_res['result']
        self.imfs = imfs
        self.ifmethod = ifmethod
        self.normmethod = normmethod
        if len(fa[0]) != 1:
            ifreq = fa[0]
            iamp = fa[1]
        else:
            ifreq = fa[0].T
            iamp = fa[1].T
        self.ifreq = ifreq
        self.iamp = iamp

    def plot_hs(self, time, trange, frange, tres, fres, hsize, sigma,
                tunit='s', funit='Hz', colorbar = 'energy', savefig_name=''):
        time = time - time[0]
        tstart = trange[0]
        tend = trange[1]
        fstart = frange[0]
        fend = frange[1]
        if colorbar == 'amplitude':
{'fraction_non_alphanumeric': 0.13242204186245193, 'fraction_numerical': 0.009397693293464331, 'mean_word_length': 2.670846394984326, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7348635', 'n_tokens_mistral': 854, 'n_tokens_neox': 850, 'n_words': 195}