def test_set_x_number_2(): # Create a Shape object from the header shape = Shape({ 'x_number': 143, 'x_start': 84000, 'x_step': 500, 'x_stop': 155000, 'y_number': 143, 'y_start': 455000, 'y_step': 500, 'y_stop': 526000 }) # Set the x number to 2 shape.set_x_number(2) # Extract the dict from the Shape object shape_dict = shape.to_dict() assert shape_dict == { 'x_number': 2, 'x_start': 84000, 'x_step': 155000 - 84000, 'x_stop': 155000, 'y_number': 143, 'y_start': 455000, 'y_step': 500, 'y_stop': 526000 }
def test_refine(): # Create a Shape object from the header shape = Shape({ 'x_number': 143, 'x_start': 84000, 'x_step': 500, 'x_stop': 155000, 'y_number': 143, 'y_start': 455000, 'y_step': 500, 'y_stop': 526000 }) # Refine shape with factor 2 shape.refine(2) # Extract the dict from the Shape object shape_dict = shape.to_dict() assert shape_dict == { 'x_number': 285, 'x_start': 84000, 'x_step': 250, 'x_stop': 155000, 'y_number': 285, 'y_start': 455000, 'y_step': 250, 'y_stop': 526000 }
def test_set_y_step(): # Create a Shape object from the header shape = Shape({ 'x_number': 143, 'x_start': 84000, 'x_step': 500, 'x_stop': 155000, 'y_number': 143, 'y_start': 455000, 'y_step': 500, 'y_stop': 526000 }) # Set the y_step to 250 shape.set_y_step(250) # Extract the dict from the Shape object shape_dict = shape.to_dict() # Compare with the desired input assert shape_dict == { 'x_number': 143, 'x_start': 84000, 'x_step': 500, 'x_stop': 155000, 'y_number': 285, 'y_start': 455000, 'y_step': 250, 'y_stop': 526000 }
def test_set_y_number_11(): # Create a Shape object from the header shape = Shape({ 'x_number': 143, 'x_start': 84000, 'x_step': 500, 'x_stop': 155000, 'y_number': 143, 'y_start': 455000, 'y_step': 500, 'y_stop': 526000 }) # Set the y number to 11 shape.set_y_number(11) # Extract the dict from the Shape object shape_dict = shape.to_dict() # todo: Compare with the desired output assert shape_dict == { 'x_number': 143, 'x_start': 84000, 'x_step': 500, 'x_stop': 155000, 'y_number': 11, 'y_start': 455000, 'y_step': (526000 - 455000) / 10, 'y_stop': 526000 }
def test_shape_to_dict(): # Get the path to the envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Read the data from the envira file header, data = read_envira(file_path) # Create a Shape object from the header shape = Shape(header) # Extract the dict from the Shape object shape_dict = shape.to_dict() assert shape_dict == { 'x_number': 143, 'x_start': 84000, 'x_step': 500, 'x_stop': 155000, 'y_number': 143, 'y_start': 455000, 'y_step': 500, 'y_stop': 526000 }