def test_list(data_init): """ Test that the method general_plots.line() reads the data as lists """ # Create the object: ob = general_plots((1, 1), display=False) # Call the method: ob.line(data_init, [0, 1])
def test_dataframe(data_init): """ Test that the method general_plots.line() reads the data as a dataframe """ # Define the data as a dataframe: data = pd.DataFrame(data_init, columns=['x', 'cos', 'tan', 'sin']) # Create the object: ob = general_plots((1, 1), display=False) # Call the method: ob.line(data, ['x', 'sin'])
def test_array(data_init): """ Test that the method general_plots.line() reads the data as arrays """ # Define the data as an array: data = data_init # Create the object: ob = general_plots((1, 1), display=False) # Call the method: ob.line(data, [0, 1])
def test_tuple(): """ Test that the method general_plots.line() reads the data as tuples """ # Define the data as a tuple of tuples: data = ((9, 7, 5), (8, 6, 5), (3, 1, 2), (33, 4, 55), (4, 5, 6)) # Create the object: ob = general_plots((1, 1), display=False) # Call the method: #try: ob.line(data, [1, 2])
def test_saving(): """ Test that the method general_plots._savefig() saves the figure """ # Define the data as a tuple of tuples: data = ((9, 7, 5), (8, 6, 5), (3, 1, 2), (33, 4, 55), (4, 5, 6)) # Define the file path and name: file_path = "./test_fig.png" # Delete the file if it already exists: if os.path.isfile(file_path): os.remove(file_path) # Create the object: ob = general_plots((1, 1), display=False, save_path=file_path) # Call the method: ob.line(data, [1, 2]) # Check that the file has been created: assert os.path.isfile(file_path)
import sys import numpy as np import pandas as pd from package.plotting import general_plots if __name__ == "__main__": x = np.linspace(0, 10, 1000) y1 = np.cos(x) y2 = np.tan(x) y3 = np.sin(x) data = list([x, y1, y2, y3]) data0 = np.transpose(data) data1 = pd.DataFrame(data0, columns=['x', 'cos', 'tan', 'sin']) data2 = ((9,7,5), (8,6,5), (3,1,2), (33,4,55), (4,5,6)) data3 = [(9,7,5), (8,6,5), (3,1,2), (33,4,55), (4,5,6)] nb_rows_col = (1,1) c = general_plots(nb_rows_col, save_path="./test_fig.png") #c.line(data2,[1,2], xlim=[0,1]) # c.line(data0,[1,2], xlim=[0,1]) #c.histogram(data0, [1], bins=100, xlim=[0,1])