Ejemplo n.º 1
0
def test_node_composite_add_origin():
    original = utilities.fake_single_sweep_stream()
    io = memory.Dictionary()
    name = 'sweep_stream'
    io.write(original, name)
    ss = io.read(name)
    ss_df = ss.to_dataframe()
    for k, row in ss_df.iterrows():
        assert row.io_class == 'Dictionary'
        assert row.root_path is None
        assert row.node_path == core.join('/', name)
    sweep = io.read(core.join(name, 'sweep'))
    stream = io.read(core.join(name, 'stream'))
    composite = basic.SingleSweepStream(sweep=sweep, stream=stream)
    composite_df = composite.to_dataframe()
    for k, row in composite_df.iterrows():
        assert row.io_class is None
        assert row.root_path is None
        assert row.node_path is None
        assert row['sweep.io_class'] == 'Dictionary'
        assert row['sweep.root_path'] is None
        assert row['sweep.node_path'] == core.join('/', name, 'sweep')
        assert row['stream.io_class'] == 'Dictionary'
        assert row['stream.root_path'] is None
        assert row['stream.node_path'] == core.join('/', name, 'stream')
Ejemplo n.º 2
0
def test_node_composite_add_origin():
    original = utilities.fake_single_sweep_stream()
    io = memory.Dictionary()
    name = 'sweep_stream'
    io.write(original, name)
    ss = io.read(name)
    ss_df = ss.to_dataframe()
    for k, row in ss_df.iterrows():
        assert row.io_class == 'Dictionary'
        assert row.root_path is None
        assert row.node_path == core.join('/', name)
    sweep = io.read(core.join(name, 'sweep'))
    stream = io.read(core.join(name, 'stream'))
    composite = basic.SingleSweepStream(sweep=sweep, stream=stream)
    composite_df = composite.to_dataframe()
    for k, row in composite_df.iterrows():
        assert row.io_class is None
        assert row.root_path is None
        assert row.node_path is None
        assert row['sweep.io_class'] == 'Dictionary'
        assert row['sweep.root_path'] is None
        assert row['sweep.node_path'] == core.join('/', name, 'sweep')
        assert row['stream.io_class'] == 'Dictionary'
        assert row['stream.root_path'] is None
        assert row['stream.node_path'] == core.join('/', name, 'stream')
Ejemplo n.º 3
0
def test_sweep_stream_array_node_path():
    original = utilities.fake_sweep_stream_array()
    # The current node path reflects the existing structure, while the IO node path is None until a read or write.
    assert original.current_node_path == '/'
    assert original.io_node_path is None
    assert original.sweep_array.current_node_path == '/sweep_array'
    assert original.sweep_array.io_node_path is None
    assert original.sweep_array.stream_arrays.current_node_path == '/sweep_array/stream_arrays'
    assert original.sweep_array.stream_arrays.io_node_path is None
    assert original.sweep_array.stream_arrays[
        0].current_node_path == '/sweep_array/stream_arrays/0'
    assert original.sweep_array.stream_arrays[0].io_node_path is None
    # Write the tree to disk.
    io = memory.Dictionary()
    name = 'ssa'
    io.write(original, name)
    # The current node path is unchanged, while the IO node path reflects how it has been stored to disk.
    assert original.current_node_path == '/'
    assert original.io_node_path == '/ssa'
    assert original.sweep_array.current_node_path == '/sweep_array'
    assert original.sweep_array.io_node_path == '/ssa/sweep_array'
    assert original.sweep_array.stream_arrays.current_node_path == '/sweep_array/stream_arrays'
    assert original.sweep_array.stream_arrays.io_node_path == '/ssa/sweep_array/stream_arrays'
    assert original.sweep_array.stream_arrays[
        0].current_node_path == '/sweep_array/stream_arrays/0'
    assert original.sweep_array.stream_arrays[
        0].io_node_path == '/ssa/sweep_array/stream_arrays/0'
    # The IO node path should be the same regardless of how much of the tree was loaded, while the current node path
    # depends on the actual measurement structure that exists.
    ssa = io.read(name)
    assert ssa.current_node_path == '/'
    assert ssa._io_node_path == '/ssa'
    assert ssa.sweep_array.current_node_path == '/sweep_array'
    assert ssa.sweep_array.io_node_path == '/ssa/sweep_array'
    assert ssa.sweep_array.stream_arrays.current_node_path == '/sweep_array/stream_arrays'
    assert ssa.sweep_array.stream_arrays.io_node_path == '/ssa/sweep_array/stream_arrays'
    assert ssa.sweep_array.stream_arrays[
        0].current_node_path == '/sweep_array/stream_arrays/0'
    assert ssa.sweep_array.stream_arrays[
        0].io_node_path == '/ssa/sweep_array/stream_arrays/0'
    sweep_array = io.read(core.join(name, 'sweep_array'))
    assert sweep_array.current_node_path == '/'
    assert sweep_array._io_node_path == '/ssa/sweep_array'
    assert sweep_array.stream_arrays.current_node_path == '/stream_arrays'
    assert sweep_array.stream_arrays.io_node_path == '/ssa/sweep_array/stream_arrays'
    assert sweep_array.stream_arrays[0].current_node_path == '/stream_arrays/0'
    assert sweep_array.stream_arrays[
        0].io_node_path == '/ssa/sweep_array/stream_arrays/0'
    stream_arrays = io.read(core.join(name, 'sweep_array', 'stream_arrays'))
    assert stream_arrays.current_node_path == '/'
    assert stream_arrays._io_node_path == '/ssa/sweep_array/stream_arrays'
    assert stream_arrays[0].current_node_path == '/0'
    assert stream_arrays[0].io_node_path == '/ssa/sweep_array/stream_arrays/0'
    stream_array_0 = io.read(
        core.join(name, 'sweep_array', 'stream_arrays', '0'))
    assert stream_array_0.current_node_path == '/'
    assert stream_array_0._io_node_path == '/ssa/sweep_array/stream_arrays/0'
    # Add the tree to a new measurement:
    m = core.Measurement()
    moved = ssa.sweep_array
    m.moved = moved
    # The IO node path is unchanged, while the current node path now reflects that the sweep array was last added to
    # the new measurement with the name 'moved'.
    assert ssa.current_node_path == '/'
    assert ssa._io_node_path == '/ssa'
    assert moved.current_node_path == '/moved'
    assert moved.io_node_path == '/ssa/sweep_array'
    assert moved.stream_arrays.current_node_path == '/moved/stream_arrays'
    assert moved.stream_arrays.io_node_path == '/ssa/sweep_array/stream_arrays'
    assert moved.stream_arrays[0].current_node_path == '/moved/stream_arrays/0'
    assert moved.stream_arrays[
        0].io_node_path == '/ssa/sweep_array/stream_arrays/0'
Ejemplo n.º 4
0
def test_join():
    assert core.join('one') == 'one'
    assert core.join('one', 'two', 'three') == 'one/two/three'
    assert core.join('/one', '/two', '/three') == '/three'
Ejemplo n.º 5
0
def test_sweep_stream_array_node_path():
    original = utilities.fake_sweep_stream_array()
    # The current node path reflects the existing structure, while the IO node path is None until a read or write.
    assert original.current_node_path == '/'
    assert original.io_node_path is None
    assert original.sweep_array.current_node_path == '/sweep_array'
    assert original.sweep_array.io_node_path is None
    assert original.sweep_array.stream_arrays.current_node_path == '/sweep_array/stream_arrays'
    assert original.sweep_array.stream_arrays.io_node_path is None
    assert original.sweep_array.stream_arrays[0].current_node_path == '/sweep_array/stream_arrays/0'
    assert original.sweep_array.stream_arrays[0].io_node_path is None
    # Write the tree to disk.
    io = memory.Dictionary()
    name = 'ssa'
    io.write(original, name)
    # The current node path is unchanged, while the IO node path reflects how it has been stored to disk.
    assert original.current_node_path == '/'
    assert original.io_node_path == '/ssa'
    assert original.sweep_array.current_node_path == '/sweep_array'
    assert original.sweep_array.io_node_path == '/ssa/sweep_array'
    assert original.sweep_array.stream_arrays.current_node_path == '/sweep_array/stream_arrays'
    assert original.sweep_array.stream_arrays.io_node_path == '/ssa/sweep_array/stream_arrays'
    assert original.sweep_array.stream_arrays[0].current_node_path == '/sweep_array/stream_arrays/0'
    assert original.sweep_array.stream_arrays[0].io_node_path == '/ssa/sweep_array/stream_arrays/0'
    # The IO node path should be the same regardless of how much of the tree was loaded, while the current node path
    # depends on the actual measurement structure that exists.
    ssa = io.read(name)
    assert ssa.current_node_path == '/'
    assert ssa._io_node_path == '/ssa'
    assert ssa.sweep_array.current_node_path == '/sweep_array'
    assert ssa.sweep_array.io_node_path == '/ssa/sweep_array'
    assert ssa.sweep_array.stream_arrays.current_node_path == '/sweep_array/stream_arrays'
    assert ssa.sweep_array.stream_arrays.io_node_path == '/ssa/sweep_array/stream_arrays'
    assert ssa.sweep_array.stream_arrays[0].current_node_path == '/sweep_array/stream_arrays/0'
    assert ssa.sweep_array.stream_arrays[0].io_node_path == '/ssa/sweep_array/stream_arrays/0'
    sweep_array = io.read(core.join(name, 'sweep_array'))
    assert sweep_array.current_node_path == '/'
    assert sweep_array._io_node_path == '/ssa/sweep_array'
    assert sweep_array.stream_arrays.current_node_path == '/stream_arrays'
    assert sweep_array.stream_arrays.io_node_path == '/ssa/sweep_array/stream_arrays'
    assert sweep_array.stream_arrays[0].current_node_path == '/stream_arrays/0'
    assert sweep_array.stream_arrays[0].io_node_path == '/ssa/sweep_array/stream_arrays/0'
    stream_arrays = io.read(core.join(name, 'sweep_array', 'stream_arrays'))
    assert stream_arrays.current_node_path == '/'
    assert stream_arrays._io_node_path == '/ssa/sweep_array/stream_arrays'
    assert stream_arrays[0].current_node_path == '/0'
    assert stream_arrays[0].io_node_path == '/ssa/sweep_array/stream_arrays/0'
    stream_array_0 = io.read(core.join(name, 'sweep_array', 'stream_arrays', '0'))
    assert stream_array_0.current_node_path == '/'
    assert stream_array_0._io_node_path == '/ssa/sweep_array/stream_arrays/0'
    # Add the tree to a new measurement:
    m = core.Measurement()
    moved = ssa.sweep_array
    m.moved = moved
    # The IO node path is unchanged, while the current node path now reflects that the sweep array was last added to
    # the new measurement with the name 'moved'.
    assert ssa.current_node_path == '/'
    assert ssa._io_node_path == '/ssa'
    assert moved.current_node_path == '/moved'
    assert moved.io_node_path == '/ssa/sweep_array'
    assert moved.stream_arrays.current_node_path == '/moved/stream_arrays'
    assert moved.stream_arrays.io_node_path == '/ssa/sweep_array/stream_arrays'
    assert moved.stream_arrays[0].current_node_path == '/moved/stream_arrays/0'
    assert moved.stream_arrays[0].io_node_path == '/ssa/sweep_array/stream_arrays/0'
Ejemplo n.º 6
0
def test_join():
    assert core.join('one') == 'one'
    assert core.join('one', 'two', 'three') == 'one/two/three'
    assert core.join('/one', '/two', '/three') == '/three'