code: def test_lytro_lfp_reading(test_images):
      """Test reading of lytro .lfr file"""
      # Get test images
      lfp_file = test_images / LFP_FILENAME
  
      # Read image and thumbnail
      img = iio.imread(lfp_file, format="lytro-lfp")
  
      # Test image shape and some pixel values
      # Pixel values are extracted from the Matlab reference implementation
      assert img.shape == (3280, 3280)
      assert round(img[171, 94], 15) == 0.284249084249084
      assert round(img[701, 292], 15) == 0.289865689865690
      assert round(img[1280, 94], 15) == 0.065201465201465
      assert round(img[2364, 2640], 15) == 0.056166056166056
      assert round(img[2733, 1549], 15) == 0.100366300366300
      assert round(img[2739, 2585], 15) == 0.078388278388278
      assert round(img[1032, 2230], 15) == 0.354578754578755
      assert round(img[1480, 1758], 15) == 0.098656898656899
  
      # Test metadata and privateMetadata against ground truth data
      metadata_gt = {
          "type": "lightField",
          "image": {
              "width": 3280,
              "height": 3280,
              "orientation": 1,
              "representation": "rawPacked",
              "rawDetails": {
                  "pixelFormat": {
                      "rightShift": 0,
                      "black": {
                          "r": 168,
                          "gr": 168,
                          "gb": 168,
                          "b": 168,
                      },
                      "white": {
                          "r": 4095,
                          "gr": 4095,
                          "gb": 4095,
                          "b": 4095,
                      },
                  },
                  "pixelPacking": {
                      "endianness": "big",
                      "bitsPerPixel": 12,
                  },
                  "mosaic": {
                      "tile": "r,gr:gb,b",
                      "upperLeftPixel": "b",
                  },
              },
              "color": {
                  "ccmRgbToSrgbArray": [
                      3.1115827560424805,
                      -1.9393929243087769,
                      -0.172189861536026,
                      -0.3629055917263031,
                      1.6408803462982178,
                      -0.27797481417655945,
                      0.07896701246500015,
                      -1.1558042764663696,
                      2.0768373012542725,
                  ],
                  "gamma": 0.41666001081466675,
                  "applied": {},
                  "whiteBalanceGain": {
                      "r": 1,
                      "gr": 1,
                      "gb": 1,
                      "b": 1.2578125,
                  },
              },
              "modulationExposureBias": -1.1139298677444458,
              "limitExposureBias": 0,
          },
          "devices": {
              "clock": {"zuluTime": "2014-05-16T13:31:21.000Z"},
              "sensor": {
                  "bitsPerPixel": 12,
                  "mosaic": {
                      "tile": "r,gr:gb,b",
                      "upperLeftPixel": "b",
                  },
                  "iso": 207,
                  "analogGain": {
                      "r": 5.625,
                      "gr": 4.125,
                      "gb": 4.125,
                      "b": 4.75,
                  },
                  "pixelPitch": 1.3999999761581417e-06,
              },
              "lens": {
                  "infinityLambda": 18.033008575439453,
                  "focalLength": 0.006840000152587891,
                  "zoomStep": 943,
                  "focusStep": 672,
                  "fNumber": 1.9199999570846558,
                  "temperature": 23.642822265625,
                  "temperatureAdc": 2896,
                  "zoomStepperOffset": -2,
                  "focusStepperOffset": 25,
                  "exitPupilOffset": {"z": 0.22357696533203125},
              },
              "ndfilter": {"exposureBias": 0},
              "shutter": {
                  "mechanism": "sensorOpenApertureClose",
                  "frameExposureDuration": 0.016554275527596474,
                  "pixelExposureDuration": 0.016554275527596474,
              },
              "soc": {
                  "temperature": 27.0545654296875,
                  "temperatureAdc": 3319,
              },
              "accelerometer": {
                  "sampleArray": [
                      {
                          "x": -0.019607843831181526,
                          "y": 1.015686273574829,
                          "z": 0.03529411926865578,
                          "time": 0,
                      }
                  ]
              },
              "mla": {
                  "tiling": "hexUniformRowMajor",
                  "lensPitch": 1.3999999999999998e-05,
                  "rotation": -0.0008588103810325265,
                  "defectArray": [],
                  "config": "com.lytro.mla.11",
                  "scaleFactor": {"x": 1, "y": 1.0003734827041626},
                  "sensorOffset": {
                      "x": -8.177771568298344e-06,
                      "y": 8.002278804779054e-07,
                      "z": 2.5e-05,
                  },
              },
          },
          "modes": {
              "creative": "tap",
              "regionOfInterestArray": [
                  {
                      "type": "exposure",
                      "x": 0.5125047564506531,
                      "y": 0.723964273929596,
                  },
                  {
                      "type": "creative",
                      "x": 0.5125047564506531,
                      "y": 0.723964273929596,
                  },
              ],
              "manualControls": False,
              "exposureDurationMode": "auto",
              "isoMode": "auto",
              "ndFilterMode": "auto",
              "exposureLock": False,
              "overscan": 1.0526316165924072,
          },
          "camera": {
              "make": "Lytro, Inc.",
              "model": "F01",
              "firmware": "v1.0a208, vv1.2.2, Wed Sep  4 14:43:36 PDT 2013, "
              "fec5f2a239a2823b391a385b94ec6fc8c56bb5b1, "
              "mods=0, ofw=0",
          },
      }
      private_metadata_gt = {
          "devices": {"sensor": {"sensorSerial": "0x408F1FB8B3515D9A"}},
          "camera": {"serialNumber": "A303134643"},
      }
  
      assert img._meta["metadata"] == metadata_gt
      assert img._meta["privateMetadata"] == private_metadata_gt
  
      # Read metadata only
      img = iio.imread(lfp_file, format="lytro-lfp", meta_only=True)
      assert np.array_equal(img, [])
      assert img._meta["metadata"] == metadata_gt
      assert img._meta["privateMetadata"] == private_metadata_gt
  
      # Test fail
      test_reader = iio.read(lfp_file, "lytro-lfp")
      with pytest.raises(IndexError):
          test_reader.get_data(-1)
      with pytest.raises(IndexError):
          test_reader.get_data(3)
  
file_path: imageio/tests/test_lytro.py
imports: from __future__ import division
  import numpy
  import json
  import pytest
  import imageio.v2
  from imageio.core import Request
  from conftest import deprecated_test
label_desc: Use image node_id 6 for calling a global function with example usage: test_lytro_lfp_reading(test_images) without return types