How to use the pvl.Units function in pvl

To help you get started, we’ve selected a few pvl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github planetarypy / planetaryimage / tests / test_pds3file.py View on Github external
# ^PTR = nnn 
    assert Pointer.parse(Units(101337, 'BYTES'), 0) == Pointer(None, 101337)

    # ^PTR = "filename"
    assert Pointer.parse('W1782844276_1.IMG', 1024) == Pointer('W1782844276_1.IMG', 0)

    # ^PTR = ("filename")
    assert Pointer.parse(['W1782844276_1.IMG'], 1024) == Pointer('W1782844276_1.IMG', 0)

    # ^PTR = ("filename", nnn)
    # Example tests/mission_data/W1782844276_1.LBL
    assert Pointer.parse(['W1782844276_1.IMG', 5], 1024) == Pointer('W1782844276_1.IMG', 4096)

    # ^PTR = ("filename", nnn )
    assert Pointer.parse(['W1782844276_1.IMG', Units(101337, 'BYTES')], 1024) == Pointer('W1782844276_1.IMG', 101337)

    # Test bad type
    with pytest.raises(ValueError):
        Pointer.parse(None, 64)

    # Test wrong sized arrays
    with pytest.raises(ValueError):
        Pointer.parse([], 64)

    with pytest.raises(ValueError):
        Pointer.parse(['W1782844276_1.IMG', 5, 6], 64)
github planetarypy / planetaryimage / tests / test_pds3file.py View on Github external
def test_parse_pointer():
    # ^PTR = nnn
    # Example tests/mission_data/1p432690858esfc847p2111l2m1.img
    assert Pointer.parse(56, 640) == Pointer(None, 35200)

    # ^PTR = nnn 
    assert Pointer.parse(Units(101337, 'BYTES'), 0) == Pointer(None, 101337)

    # ^PTR = "filename"
    assert Pointer.parse('W1782844276_1.IMG', 1024) == Pointer('W1782844276_1.IMG', 0)

    # ^PTR = ("filename")
    assert Pointer.parse(['W1782844276_1.IMG'], 1024) == Pointer('W1782844276_1.IMG', 0)

    # ^PTR = ("filename", nnn)
    # Example tests/mission_data/W1782844276_1.LBL
    assert Pointer.parse(['W1782844276_1.IMG', 5], 1024) == Pointer('W1782844276_1.IMG', 4096)

    # ^PTR = ("filename", nnn )
    assert Pointer.parse(['W1782844276_1.IMG', Units(101337, 'BYTES')], 1024) == Pointer('W1782844276_1.IMG', 101337)

    # Test bad type
    with pytest.raises(ValueError):
github planetarypy / planetaryimage / planetaryimage / pds3image.py View on Github external
def _parse_bytes(value, record_bytes):
        if isinstance(value, six.integer_types):
            return (value - 1) * record_bytes

        if isinstance(value, pvl.Units) and value.units == 'BYTES':
            return value.value

        raise ValueError('Unsupported pointer type')

pvl

Python implementation for PVL (Parameter Value Language) parsing and encoding.

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis

Similar packages