Example #1
0
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
    }
Example #2
0
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
    }
Example #3
0
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
    }
Example #4
0
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
    }
Example #5
0
def test_get_y_coordinates_nan():
    shape = Shape({
        'x_number': 500,
        'x_start': 84000,
        'x_step': 500,
        'x_stop': 155000,
        'y_number': np.nan,
        'y_start': 455000,
        'y_step': 500,
        'y_stop': 526000
    })

    y = shape.get_y_coordinates()
    assert False
Example #6
0
def test_get_x_coordinates_inf():
    shape = Shape({
        'x_number': np.inf,
        'x_start': 84000,
        'x_step': 500,
        'x_stop': 155000,
        'y_number': 143,
        'y_start': 455000,
        'y_step': 500,
        'y_stop': 526000
    })

    x = shape.get_x_coordinates()
    assert False
Example #7
0
def test_get_y_coordinates():
    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
    })

    y = shape.get_y_coordinates()

    assert len(y) == shape.y_number
Example #8
0
def test_set_x_number_1():
    # 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 1
    shape.set_x_number(1)
Example #9
0
def test_set_y_number_nan():
    # 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 NaN
    shape.set_y_number(np.nan)
    assert False
Example #10
0
def test_refine_inf():
    # 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 the shape with factor NaN
    factor = np.inf
    shape.refine(factor)
    assert False
Example #11
0
def test_set_y_step_inf():
    # 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_step to nan
    step = np.inf
    shape.set_y_step(step)
    assert False
Example #12
0
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
    }
Example #13
0
def test_read_envira_shape():
    # 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)

    assert shape.x_number == 143
    assert shape.x_start == 84000
    assert shape.x_step == 500
    assert shape.x_stop == 155000
    assert shape.y_number == 143
    assert shape.y_start == 455000
    assert shape.y_step == 500
    assert shape.y_stop == 526000