Exemple #1
0
def test_array_of_objects():
    o = {"foo": [{"bar": "baz"}]}
    assert blueprint(o) == O({
        ".foo": "array",
        ".foo[]": "object",
        ".foo[].bar": "string"
    })
Exemple #2
0
def draw_trend():
    # plot style
    style = np.random.choice(plt.style.available); print(style); plt.style.use('grayscale') # [u'dark_background', u'bmh', u'grayscale', u'ggplot', u'fivethirtyeight']
    # plot setting
    mpl.rcParams['mathtext.fontset'] = 'stix'
    mpl.rcParams['font.family'] = 'STIXGeneral'
    mpl.rcParams['legend.fontsize'] = 11
    # mpl.rcParams['legend.family'] = 'Times New Roman'
    mpl.rcParams['font.family'] = ['Times New Roman']
    mpl.rcParams['font.size'] = 11.0
    # mpl.style.use('classic')
    font = {'family' : 'Times New Roman', #'serif',
            'color' : 'darkblue',
            'weight' : 'normal',
            'size' : 11,}
    textfont = {'family' : 'Times New Roman', #'serif',
                'color' : 'darkblue',
                'weight' : 'normal',
                'size' : 9,}

    df_profiles = pd.read_csv(r"./algorithm.dat", na_values = ['1.#QNAN', '-1#INF00', '-1#IND00'])
    df_info = pd.read_csv(r"./info.dat", na_values = ['1.#QNAN', '-1#INF00', '-1#IND00'])
    
    # df_profiles["rpm_cmd"]=df_profiles["ACM.rpm_cmd"]
    # df_profiles["rpm_mes"]=df_profiles["ACM.rpm_cmd"]-df_profiles["e_omega"]
    #print(df_profiles.keys())
    
    no_samples = df_profiles.shape[0]
    no_traces  = df_profiles.shape[1]
    print(df_info, 'Simulated time: %g s.'%(no_samples * df_info['TS'].values[0] * df_info['DOWN_SAMPLE'].values[0]), 'Key list:', sep='\n')
    for key in df_profiles.keys():
        print('\t', key)

    time = np.arange(1, no_samples+1) * df_info['DOWN_SAMPLE'].values[0] * df_info['TS'].values[0]

    ax_list = []
    for i in range(0, no_traces, 6):
        ax_list += list(get_axis((1,6)))

    for idx, key in enumerate(df_profiles.keys()):
        plot_it(ax_list[idx], key, O([
                                        (str(idx), df_profiles[key]),  
                                        # (str(idx), df_profiles[key]),  
                                        ]),time,font)
        #print(idx,key)
    # ax_list[12].plot(time,df_profiles["rpm_mes"],color="red")
    plt.show()
Exemple #3
0
            ax.plot(time, v, '-', lw=1)
        else:
            # ax.plot(time, v, '-', lw=2, label=k)
            ax.plot(time, v, '-', lw=1)

    # ax.legend(loc='lower right', shadow=True)
    # ax.legend(bbox_to_anchor=(1.08,0.5), borderaxespad=0., loc='center', shadow=True)
    ax.set_ylabel(ylabel, fontdict=font)
    # ax.set_xlim(0,35) # shared x
    # ax.set_ylim(0.85,1.45)


time = np.arange(
    1, no_samples +
    1) * df_info['DOWN_SAMPLE'].values[0] * df_info['TS'].values[0]

ax_list = []
for i in range(0, no_traces, 5):
    ax_list += list(get_axis((1, 5)))

for idx, key in enumerate(df_profiles.keys()):
    plot_it(
        ax_list[idx],
        key,
        O([
            (str(idx), df_profiles[key]),
            # (str(idx), df_profiles[key]),
        ]))
plt.show()
quit()
Exemple #4
0
        print('\t', key)
    #   print all key of the data ,which is the first row string in data file
    #   the value of key is corresponding list
    time = np.arange(1, no_samples+1) * df_info['WRITE_PER_TIME'].values[0]

    ax_list = []
#    for i in range(0, no_traces, 2):    #   for i in range(1, 101,1) print from 1 to 101
#        ax_list += list(get_axis((1,2)))    #   add axis list to ax_list
    for i in range(0, no_traces):    #   for i in range(1, 101,1) print from 1 to 101
        ax_list.append(get_axis())
        #ax_list.append(get_axis(1,1))    #   add axis list to ax_list


    for ID_x, key in enumerate(df_profiles.keys()):     #   enumerate() is utilized to give num for every key
        plot_it(ax_list[ID_x], key, O([
                                        (str(ID_x), df_profiles[key]),
                                        # (str(idx), df_profiles[key]),
                                        ]), time)
        # input("Wait for key")
        # time.sleep(0.05) # wait for 0.05 second



    #   fig.savefig('figure_name.png')  must be placed before   plt.show
    #fig.savefig('%s.tif',ylabel)
    #   the final direction in the script to creat the defined figure
    plt.show()

    # do some stuff in script
    variable = input('input something!: ')

    quit()
Exemple #5
0
def test_string():
    assert blueprint({"foo": "bar"}) == O({".foo": "string"})
Exemple #6
0
def test_array():
    o = {"foo": [1, 2, 3]}
    assert blueprint(o) == O({".foo": "array", ".foo[]": "number"})
Exemple #7
0
def test_object():
    o = {"foo": {"bar": "baz"}}
    assert blueprint(o) == O({".foo": "object", ".foo.bar": "string"})
Exemple #8
0
def test_boolean():
    assert blueprint({"foo": True}) == O({".foo": "boolean"})
Exemple #9
0
def test_number():
    assert blueprint({"foo": 1}) == O({".foo": "number"})
    assert blueprint({"foo": 1.1}) == O({".foo": "number"})