qcodes/dataset/plotting.py
def _complex_to_real_preparser(
    alldata: Sequence[Sequence[DSPlotData]], conversion: str, degrees: bool = False
) -> NamedData:
    """
    Convert complex-valued parameters to two real-valued parameters, either
    real and imaginary part or phase and magnitude part

    Args:
        alldata: The data to convert, should be the output of `_get_data_from_ds`
        conversion: the conversion method, either "real_and_imag" or
            "mag_and_phase"
        degrees: Whether to return the phase in degrees. The default is to
            return the phase in radians
    """

    if conversion not in ['real_and_imag', 'mag_and_phase']:
        raise ValueError(f'Invalid conversion given. Received {conversion}, '
                         'but can only accept "real_and_imag" or '
                         '"mag_and_phase".')

    newdata: NamedData = []

    # we build a new NamedData object from the given `alldata` input.
    # Note that the length of `newdata` will be larger than that of `alldata`
    # in the case of complex top-level parameters, because a single complex
    # top-level parameter will be split into two real top-level parameters
    # (that have the same setpoints). This is the reason why we
    # use two variables below, new_group and new_groups.

    for group in alldata:
        new_group = []
        new_groups: NamedData = [[], []]
        for index, parameter in enumerate(group):
            data = parameter["data"]
            if data.dtype.kind == "c":
                p1, p2 = _convert_complex_to_real(
                    parameter, conversion=conversion, degrees=degrees
                )
                if index < len(group) - 1:
                    # if the above condition is met, we are dealing with
                    # complex setpoints
                    new_group.append(p1)
                    new_group.append(p2)
                else:
                    # in this case, we are dealing with a complex top-level
                    # parameter. Also, all the setpoints will have been handled
                    # by now. We split the group into two groups, one for each
                    # new (real) top-level parameter
                    new_groups[0] = new_group.copy()
                    new_groups[1] = new_group.copy()
                    new_groups[0].append(p1)
                    new_groups[1].append(p2)
            else:
                new_group.append(parameter)
        if new_groups == [[], []]:
            # if the above condition is met, the group did not contain a
            # complex top-level parameter and has thus not been split into two
            # new groups
            newdata.append(new_group)
        else:
            newdata.append(new_groups[0])
            newdata.append(new_groups[1])

    return newdata

    Convert complex-valued parameters to two real-valued parameters, either
    real and imaginary part or phase and magnitude part

    Args:
        alldata: The data to convert, should be the output of `_get_data_from_ds`
        conversion: the conversion method, either "real_and_imag" or
            "mag_and_phase"
        degrees: Whether to return the phase in degrees. The default is to
            return the phase in radians
    
Convert complex-valued parameters to two real-valued parameters, either
real and imaginary part or phase and magnitude part
Convert complex - valued parameters to two real - valued parameters either real and imaginary part or phase and magnitude part
def _complex_to_real_preparser(
    alldata: Sequence[Sequence[DSPlotData]], conversion: str, degrees: bool = False
) -> NamedData:
    if conversion not in ['real_and_imag', 'mag_and_phase']:
        raise ValueError(f'Invalid conversion given. Received {conversion}, '
                         'but can only accept "real_and_imag" or '
                         '"mag_and_phase".')
    newdata: NamedData = []
    for group in alldata:
        new_group = []
        new_groups: NamedData = [[], []]
        for index, parameter in enumerate(group):
            data = parameter["data"]
            if data.dtype.kind == "c":
                p1, p2 = _convert_complex_to_real(
                    parameter, conversion=conversion, degrees=degrees
                )
                if index < len(group) - 1:
                    new_group.append(p1)
                    new_group.append(p2)
                else:
                    new_groups[0] = new_group.copy()
                    new_groups[1] = new_group.copy()
                    new_groups[0].append(p1)
                    new_groups[1].append(p2)
            else:
                new_group.append(parameter)
        if new_groups == [[], []]:
            newdata.append(new_group)
        else:
            newdata.append(new_groups[0])
            newdata.append(new_groups[1])
    return newdata
def _complex_to_real_preparser ( alldata : Sequence [ Sequence [ DSPlotData ] ] , conversion : str , degrees : bool = False ) -> NamedData : if conversion not in [ 'real_and_imag' , 'mag_and_phase' ] : raise ValueError ( f'Invalid conversion given. Received {conversion}, ' 'but can only accept "real_and_imag" or ' '"mag_and_phase".' ) newdata : NamedData = [ ] for group in alldata : new_group = [ ] new_groups : NamedData = [ [ ] , [ ] ] for index , parameter in enumerate ( group ) : data = parameter [ "data" ] if data . dtype . kind == "c" : p1 , p2 = _convert_complex_to_real ( parameter , conversion = conversion , degrees = degrees ) if index < len ( group ) - 1 : new_group . append ( p1 ) new_group . append ( p2 ) else : new_groups [ 0 ] = new_group . copy ( ) new_groups [ 1 ] = new_group . copy ( ) new_groups [ 0 ] . append ( p1 ) new_groups [ 1 ] . append ( p2 ) else : new_group . append ( parameter ) if new_groups == [ [ ] , [ ] ] : newdata . append ( new_group ) else : newdata . append ( new_groups [ 0 ] ) newdata . append ( new_groups [ 1 ] ) return newdata
Convert complex-valued parameters to two real-valued parameters, either
real and imaginary part or phase and magnitude part
Convert complex - valued parameters to two real - valued parameters either real and imaginary part or phase and magnitude part
"""
    Convert complex-valued parameters to two real-valued parameters, either
    real and imaginary part or phase and magnitude part

    Args:
        alldata: The data to convert, should be the output of `_get_data_from_ds`
        conversion: the conversion method, either "real_and_imag" or
            "mag_and_phase"
        degrees: Whether to return the phase in degrees. The default is to
            return the phase in radians
    """ # we build a new NamedData object from the given `alldata` input. # Note that the length of `newdata` will be larger than that of `alldata` # in the case of complex top-level parameters, because a single complex # top-level parameter will be split into two real top-level parameters # (that have the same setpoints). This is the reason why we # use two variables below, new_group and new_groups. # if the above condition is met, we are dealing with # complex setpoints # in this case, we are dealing with a complex top-level # parameter. Also, all the setpoints will have been handled # by now. We split the group into two groups, one for each # new (real) top-level parameter # if the above condition is met, the group did not contain a # complex top-level parameter and has thus not been split into two # new groups
alldata
Sequence[Sequence[DSPlotData]]
The data to convert, should be the output of `_get_data_from_ds`
The data to convert should be the output of ` _get_data_from_ds `
conversion
str
the conversion method, either "real_and_imag" or
"mag_and_phase"
the conversion method either " real_and_imag " or " mag_and_phase "
degrees
bool
Whether to return the phase in degrees. The default is to
return the phase in radians
Whether to return the phase in degrees . The default is to return the phase in radians