Ejemplo n.º 1
0
def transform_nodes(from_data, to_data):
    _nodes = INodes()
    _nodes._interval = numpy.array(from_data['interval'])
    _nodes._nodes = numpy.array(from_data['nodes'])
    _nodes.transform(numpy.array(to_data['interval']))
    assert_equal(_nodes.nodes[0], to_data['interval'][0])
    assert_equal(_nodes.nodes[-1], to_data['interval'][1])
    assert_numpy_array_equal(_nodes.nodes, numpy.array(to_data['nodes']))
Ejemplo n.º 2
0
def on_finalize_collect_solutions_and_finalize(test_obj):
    _count = 0.0
    for step in test_obj:
        step.solution.value = numpy.array([1.0])
        step.solution.time_point = _count
        _count += 1

    assert_false(test_obj.solution.finalized)
    assert_numpy_array_equal(test_obj.solution.values, numpy.array([]))
    test_obj.finalize()
    assert_true(test_obj.solution.finalized)
    assert_numpy_array_equal(test_obj.solution.values, numpy.array([[1.0], [1.0], [1.0]]))

    # .done should reset the current_index counter
    assert_is(test_obj.current_index, 0)

    assert_raises(RuntimeError, test_obj.finalize)