# Path: retina/input/photoreceptor_input.py
# def get_singleinput_cls(input_type):
#     # I think this implementation will find only the classes defined in this
#     # file
#     all_input_cls = PhotorInput.__subclasses__()
#     all_input_names = [cls.__name__ for cls in all_input_cls]
#     try:
#         input_cls = all_input_cls[all_input_names.index(input_type)]
#     except ValueError:
#         print('Invalid PhotorInput subclass name: {}'.format(input_type))
#         print('Valid names: {}'.format(all_input_names))
#         return None
# 
#     return input_cls


import neurokernel.LPU.utils.simpleio as sio
from neurokernel.tools.timing import Timer
from retina.input.photoreceptor_input import get_singleinput_cls
from __future__ import division




def gen_input_norfscreen(config):
    steps = config['General']['steps']
    input_file = config['Photoreceptor']['input_file']
    input_type = config['Photoreceptor']['single_intype']
    input_obj = get_singleinput_cls(input_type)(config)

    with Timer('getting photoreceptor inputs'):
        # although not configurable one can use
        # alternatives like .get_flat_image()
        # if available by manually
        # changing command below
        photor_inputs = input_obj.get_input(steps)

        config['General']['steps'] = photor_inputs[:, 0].size


# Path: retina/input/photoreceptor_input.py
# def get_singleinput_cls(input_type):
#     # I think this implementation will find only the classes defined in this
#     # file
#     all_input_cls = PhotorInput.__subclasses__()
#     all_input_names = [cls.__name__ for cls in all_input_cls]
#     try:
#         input_cls = all_input_cls[all_input_names.index(input_type)]
#     except ValueError:
#         print('Invalid PhotorInput subclass name: {}'.format(input_type))
#         print('Valid names: {}'.format(all_input_names))
#         return None
# 
#     return input_cls


# Path: examples/photoreceptor_demo/gen_input.py
import neurokernel.LPU.utils.simpleio as sio
from neurokernel.tools.timing import Timer
from retina.input.photoreceptor_input import get_singleinput_cls

from __future__ import division




def gen_input_norfscreen(config):
    steps = config['General']['steps']
    input_file = config['Photoreceptor']['input_file']
    input_type = config['Photoreceptor']['single_intype']
    input_obj = get_singleinput_cls(input_type)(config)

    with Timer('getting photoreceptor inputs'):
        # although not configurable one can use
        # alternatives like .get_flat_image()
        # if available by manually
        # changing command below
        photor_inputs = input_obj.get_input(steps)

        config['General']['steps'] = photor_inputs[:, 0].size


    sio.write_array(photor_inputs, filename=input_file)