qcodes/plots/base.py
def expand_trace(args, kwargs):
        """
        Complete the x, y (and possibly z) data definition for a trace.

        Also modifies kwargs in place so that all the data needed to fully
        specify the trace is present (ie either x and y or x and y and z)

        Both ``__init__`` (for the first trace) and the ``add`` method support
        multiple ways to specify the data in the trace:

        As ``*args``:
            - ``add(y)`` or ``add(z)`` specify just the main 1D or 2D data, with
              the setpoint axis or axes implied.
            - ``add(x, y)`` or ``add(x, y, z)`` specify all axes of the data.
        And as ``**kwargs``:
            - ``add(x=x, y=y, z=z)`` you specify exactly the data you want on
              each axis. Any but the last (y or z) can be omitted, which allows
              for all of the same forms as with ``*args``, plus x and z or y and
              z, with just one axis implied from the setpoints of the z data.

        This method takes any of those forms and converts them into a complete
        set of kwargs, containing all of the explicit or implied data to be used
        in plotting this trace.

        Args:
            args (Tuple[DataArray]): positional args, as passed to either
                ``__init__`` or ``add``
            kwargs (Dict(DataArray]): keyword args, as passed to either
                ``__init__`` or ``add``. kwargs may contain non-data items in
                keys other than x, y, and z.

        Raises:
           ValueError: if the shape of the data does not match that of args
           ValueError: if the data is provided twice
        """
        # TODO(giulioungaretti): replace with an explicit version:
        # return the new kwargs  instead of modifying in place
        # TODO this should really be a static method
        if args:
            if hasattr(args[-1][0], '__len__'):
                # 2D (or higher... but ignore this for now)
                # this test works for both numpy arrays and bare sequences
                axletters = 'xyz'
                ndim = 2
            else:
                axletters = 'xy'
                ndim = 1

            if len(args) not in (1, len(axletters)):
                raise ValueError('{}D data needs 1 or {} unnamed args'.format(
                    ndim, len(axletters)))

            arg_axletters = axletters[-len(args):]

            for arg, arg_axletters in zip(args, arg_axletters):
                if arg_axletters in kwargs:
                    raise ValueError(arg_axletters + ' data provided twice')
                kwargs[arg_axletters] = arg

        # reset axletters, we may or may not have found them above
        axletters = 'xyz' if 'z' in kwargs else 'xy'
        main_data = kwargs[axletters[-1]]
        if hasattr(main_data, 'set_arrays'):
            num_axes = len(axletters) - 1
            # things will probably fail if we try to plot arrays of the
            # wrong dimension... but we'll give it a shot anyway.
            set_arrays = main_data.set_arrays[-num_axes:]
            # for 2D: y is outer loop, which is earlier in set_arrays,
            # and x is the inner loop... is this the right convention?
            set_axletters = reversed(axletters[:-1])
            for axletter, set_array in zip(set_axletters, set_arrays):
                if axletter not in kwargs:
                    kwargs[axletter] = set_array

        Complete the x, y (and possibly z) data definition for a trace.

        Also modifies kwargs in place so that all the data needed to fully
        specify the trace is present (ie either x and y or x and y and z)

        Both ``__init__`` (for the first trace) and the ``add`` method support
        multiple ways to specify the data in the trace:

        As ``*args``:
            - ``add(y)`` or ``add(z)`` specify just the main 1D or 2D data, with
              the setpoint axis or axes implied.
            - ``add(x, y)`` or ``add(x, y, z)`` specify all axes of the data.
        And as ``**kwargs``:
            - ``add(x=x, y=y, z=z)`` you specify exactly the data you want on
              each axis. Any but the last (y or z) can be omitted, which allows
              for all of the same forms as with ``*args``, plus x and z or y and
              z, with just one axis implied from the setpoints of the z data.

        This method takes any of those forms and converts them into a complete
        set of kwargs, containing all of the explicit or implied data to be used
        in plotting this trace.

        Args:
            args (Tuple[DataArray]): positional args, as passed to either
                ``__init__`` or ``add``
            kwargs (Dict(DataArray]): keyword args, as passed to either
                ``__init__`` or ``add``. kwargs may contain non-data items in
                keys other than x, y, and z.

        Raises:
           ValueError: if the shape of the data does not match that of args
           ValueError: if the data is provided twice
        
Complete the x, y (and possibly z) data definition for a trace.
Also modifies kwargs in place so that all the data needed to fully
specify the trace is present





This method takes any of those forms and converts them into a complete
set of kwargs, containing all of the explicit or implied data to be used
in plotting this trace.
Complete the x y ( and possibly z ) data definition for a trace . Also modifies kwargs in place so that all the data needed to fully specify the trace is present This method takes any of those forms and converts them into a complete set of kwargs containing all of the explicit or implied data to be used in plotting this trace .
def expand_trace(args, kwargs):
        if args:
            if hasattr(args[-1][0], '__len__'):
                axletters = 'xyz'
                ndim = 2
            else:
                axletters = 'xy'
                ndim = 1
            if len(args) not in (1, len(axletters)):
                raise ValueError('{}D data needs 1 or {} unnamed args'.format(
                    ndim, len(axletters)))
            arg_axletters = axletters[-len(args):]
            for arg, arg_axletters in zip(args, arg_axletters):
                if arg_axletters in kwargs:
                    raise ValueError(arg_axletters + ' data provided twice')
                kwargs[arg_axletters] = arg
        axletters = 'xyz' if 'z' in kwargs else 'xy'
        main_data = kwargs[axletters[-1]]
        if hasattr(main_data, 'set_arrays'):
            num_axes = len(axletters) - 1
            set_arrays = main_data.set_arrays[-num_axes:]
            set_axletters = reversed(axletters[:-1])
            for axletter, set_array in zip(set_axletters, set_arrays):
                if axletter not in kwargs:
                    kwargs[axletter] = set_array
def expand_trace ( args , kwargs ) : if args : if hasattr ( args [ - 1 ] [ 0 ] , '__len__' ) : axletters = 'xyz' ndim = 2 else : axletters = 'xy' ndim = 1 if len ( args ) not in ( 1 , len ( axletters ) ) : raise ValueError ( '{}D data needs 1 or {} unnamed args' . format ( ndim , len ( axletters ) ) ) arg_axletters = axletters [ - len ( args ) : ] for arg , arg_axletters in zip ( args , arg_axletters ) : if arg_axletters in kwargs : raise ValueError ( arg_axletters + ' data provided twice' ) kwargs [ arg_axletters ] = arg axletters = 'xyz' if 'z' in kwargs else 'xy' main_data = kwargs [ axletters [ - 1 ] ] if hasattr ( main_data , 'set_arrays' ) : num_axes = len ( axletters ) - 1 set_arrays = main_data . set_arrays [ - num_axes : ] set_axletters = reversed ( axletters [ : - 1 ] ) for axletter , set_array in zip ( set_axletters , set_arrays ) : if axletter not in kwargs : kwargs [ axletter ] = set_array
Complete the x, y (and possibly z) data definition for a trace.
Complete the x y ( and possibly z ) data definition for a trace .
"""
        Complete the x, y (and possibly z) data definition for a trace.

        Also modifies kwargs in place so that all the data needed to fully
        specify the trace is present (ie either x and y or x and y and z)

        Both ``__init__`` (for the first trace) and the ``add`` method support
        multiple ways to specify the data in the trace:

        As ``*args``:
            - ``add(y)`` or ``add(z)`` specify just the main 1D or 2D data, with
              the setpoint axis or axes implied.
            - ``add(x, y)`` or ``add(x, y, z)`` specify all axes of the data.
        And as ``**kwargs``:
            - ``add(x=x, y=y, z=z)`` you specify exactly the data you want on
              each axis. Any but the last (y or z) can be omitted, which allows
              for all of the same forms as with ``*args``, plus x and z or y and
              z, with just one axis implied from the setpoints of the z data.

        This method takes any of those forms and converts them into a complete
        set of kwargs, containing all of the explicit or implied data to be used
        in plotting this trace.

        Args:
            args (Tuple[DataArray]): positional args, as passed to either
                ``__init__`` or ``add``
            kwargs (Dict(DataArray]): keyword args, as passed to either
                ``__init__`` or ``add``. kwargs may contain non-data items in
                keys other than x, y, and z.

        Raises:
           ValueError: if the shape of the data does not match that of args
           ValueError: if the data is provided twice
        """ # TODO(giulioungaretti): replace with an explicit version: # return the new kwargs  instead of modifying in place # TODO this should really be a static method # 2D (or higher... but ignore this for now) # this test works for both numpy arrays and bare sequences # reset axletters, we may or may not have found them above # things will probably fail if we try to plot arrays of the # wrong dimension... but we'll give it a shot anyway. # for 2D: y is outer loop, which is earlier in set_arrays, # and x is the inner loop... is this the right convention?
if the shape of the data does not match that of args
if the shape of the data does not match that of args
ValueError
if the data is provided twice
if the data is provided twice
ValueError
args
positional args, as passed to either
``__init__`` or ``add``
positional args as passed to either ` ` __init__ ` ` or ` ` add ` `
kwargs
keyword args, as passed to either
``__init__`` or ``add``. kwargs may contain non-data items in
keys other than x, y, and z.
keyword args as passed to either ` ` __init__ ` ` or ` ` add ` ` . kwargs may contain non - data items in keys other than x y and z .