# -*- coding: utf-8 -*-
#
# <NAME> <<EMAIL>>
# (c) 1998-2022 all rights reserved


# externals
import graphene
# the pixel values as represented by each channel
from .ChannelRep import ChannelRep


# a sample from a dataset
class Sample(graphene.ObjectType):
    """
    The value of a dataset sample
    """

    # fields
    pixel = graphene.List(graphene.Int)
    value = graphene.List(ChannelRep)


    # resolvers
    def resolve_value(context, info, **kwds):
        """
        Get the value of a dataset at the specified location
        """
        # unpack my context
        dataset = context["dataset"]
        line = context["line"]
        sample = context["sample"]

        # ask the dataset for the pixel value projected on its favorite channels
        for channel, reps in dataset.peek(pixel=(line, sample)):
            # and assemble a resolution context for my {value}
            yield {
                "channel": channel,
                "reps": reps,
            }

        # all done
        return


    def resolve_pixel(context, info, **kwds):
        """
        Get the value of a dataset at the specified location
        """
        # all done
        return [context["line"], context["sample"]]


# end of file

# -*- coding: utf-8 -*-
#
# <NAME> <<EMAIL>>
# (c) 1998-2022 all rights reserved


# externals
import graphene
# the pixel values as represented by each channel
from .ChannelRep import ChannelRep


# a sample from a dataset
class Sample(graphene.ObjectType):
    """
    The value of a dataset sample
    """

    # fields
    pixel = graphene.List(graphene.Int)
    value = graphene.List(ChannelRep)


    # resolvers
    def resolve_value(context, info, **kwds):
        """
        Get the value of a dataset at the specified location
        """
        # unpack my context
        dataset = context["dataset"]
        line = context["line"]
        sample = context["sample"]

        # ask the dataset for the pixel value projected on its favorite channels
        for channel, reps in dataset.peek(pixel=(line, sample)):
            # and assemble a resolution context for my {value}
            yield {
                "channel": channel,
                "reps": reps,
            }

        # all done
        return


    def resolve_pixel(context, info, **kwds):
        """
        Get the value of a dataset at the specified location
        """
        # all done
        return [context["line"], context["sample"]]


# end of file

# -*- coding: utf-8 -*- # # <NAME> <<EMAIL>> # (c) 1998-2022 all rights reserved # externals # the pixel values as represented by each channel # a sample from a dataset The value of a dataset sample # fields # resolvers Get the value of a dataset at the specified location # unpack my context # ask the dataset for the pixel value projected on its favorite channels # and assemble a resolution context for my {value} # all done Get the value of a dataset at the specified location # all done # end of file