# Path: cubical/machines/parameterised_machine.py
# class ParameterisedGains(PerIntervalGains):
#     """
#     This is a base class for all gain solution machines that use full-resolution
#     gain arrays derived from some other parameters.
#     """
# 
#     def init_gains(self):
#         """
#         Construct gain and flag arrays at full-resolution. Parameterisation of gains may not be at
#         full resolution.
#         """
#         self.gain_intervals = 1, 1
#         self.gain_grid = self.data_grid
#         self.gain_shape = [self.n_dir,self.n_tim,self.n_fre,self.n_ant,self.n_cor,self.n_cor]
#         self.gains = np.empty(self.gain_shape, dtype=self.dtype)
#         self.gains[:] = np.eye(self.n_cor)
#         self.gflags = np.zeros(self.gain_shape[:-2],FL.dtype)
# 
#         # Function used to unpack the gains or flags into full time/freq resolution.
#         self._gainres_to_fullres  = self.copy_or_identity
# 
#         # function used to unpack interval resolution to gain resolution.
#         self._interval_to_gainres = self.unpack_intervals
# 
# Path: cubical/tools/logger.py
# def logToFile(filename, append=False):
# def getLogFilename():
#     def __init__(self, logger, level, color=None, bold=None):
#     def write(self, message, level_override=None, print_once=None):
#     def print(self, *args):
#     def __init__(self, logger, verbose=None, log_verbose=None):
#     def verbosity(self, set_verb=None):
#     def log_verbosity(self, set_verb=None):
#     def __call__(self, level, color=None):
#     def warn(self, msg, color=None, print_once=None):
#     def error(self, msg, color="red", print_once=None):
#     def info(self, msg, color=None, print_once=None):
#     def critical(self, msg, color=None, print_once=None):
#     def debug(self, msg, color=None, print_once=None):
#     def exception(self, msg, color=None, print_once=None):
#     def print(self, *args):
#     def write(self, message, level=logging.INFO, verbosity=0, print_once=None, color=None):
# def enableMemoryLogging(level=1):
# def set_subprocess_label(label):
# def get_subprocess_label():
# def _sigusr1_handler(signum, frame):
# def _sigusr2_handler(signum, frame):
#     def setMemoryLogging(level):
#     def filter(self, event):
#     def __init__(self, fmt, datefmt, strip=True):
#     def label(self, record):
#     def format(self, record):
# def init(app_name):
# def getLogger(name, verbose=None, log_verbose=None):
# def setBoring(boring=True):
# def setGlobalVerbosity(verbosity):
# def setGlobalLogVerbosity(verbosity):
# def setSilent(Lname):
# def setLoud(Lname):
# class _DefaultWriter(object):
# class LoggerWrapper(object):
# class LogFilter(logging.Filter):
# class ColorStrippingFormatter(logging.Formatter):
# GB = float(1024 ** 3)
#                 KEYS = _log_memory_types[memlevel]


from cubical.machines.parameterised_machine import ParameterisedGains
from numpy.ma import masked_array
from cubical.tools import logger
        from .phase_diag_machine import PhaseDiagGains
import numpy as np
import cubical.kernels
import builtins
    def profile(func): return func
    builtins.profile = profile


class PhaseSlopeGains(ParameterisedGains):
    """
    This class implements the diagonal phase-only parameterised slope gain machine.
    """

    def __init__(self, label, data_arr, ndir, nmod, chunk_ts, chunk_fs, chunk_label, options):
        """
        Initialises a diagonal phase-slope gain machine.

        Args:
            label (str):
                Label identifying the Jones term.
            data_arr (np.ndarray):
                Shape (n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing observed
                visibilities.
            ndir (int):
                Number of directions.
            nmod (nmod):
                Number of models.
            chunk_ts (np.ndarray):
                Times for the data being processed.
            chunk_fs (np.ndarray):
                Frequencies for the data being processsed.
            options (dict):
                Dictionary of options.
        """

# Path: cubical/machines/parameterised_machine.py
# class ParameterisedGains(PerIntervalGains):
#     """
#     This is a base class for all gain solution machines that use full-resolution
#     gain arrays derived from some other parameters.
#     """
# 
#     def init_gains(self):
#         """
#         Construct gain and flag arrays at full-resolution. Parameterisation of gains may not be at
#         full resolution.
#         """
#         self.gain_intervals = 1, 1
#         self.gain_grid = self.data_grid
#         self.gain_shape = [self.n_dir,self.n_tim,self.n_fre,self.n_ant,self.n_cor,self.n_cor]
#         self.gains = np.empty(self.gain_shape, dtype=self.dtype)
#         self.gains[:] = np.eye(self.n_cor)
#         self.gflags = np.zeros(self.gain_shape[:-2],FL.dtype)
# 
#         # Function used to unpack the gains or flags into full time/freq resolution.
#         self._gainres_to_fullres  = self.copy_or_identity
# 
#         # function used to unpack interval resolution to gain resolution.
#         self._interval_to_gainres = self.unpack_intervals
# 
# Path: cubical/tools/logger.py
# def logToFile(filename, append=False):
# def getLogFilename():
#     def __init__(self, logger, level, color=None, bold=None):
#     def write(self, message, level_override=None, print_once=None):
#     def print(self, *args):
#     def __init__(self, logger, verbose=None, log_verbose=None):
#     def verbosity(self, set_verb=None):
#     def log_verbosity(self, set_verb=None):
#     def __call__(self, level, color=None):
#     def warn(self, msg, color=None, print_once=None):
#     def error(self, msg, color="red", print_once=None):
#     def info(self, msg, color=None, print_once=None):
#     def critical(self, msg, color=None, print_once=None):
#     def debug(self, msg, color=None, print_once=None):
#     def exception(self, msg, color=None, print_once=None):
#     def print(self, *args):
#     def write(self, message, level=logging.INFO, verbosity=0, print_once=None, color=None):
# def enableMemoryLogging(level=1):
# def set_subprocess_label(label):
# def get_subprocess_label():
# def _sigusr1_handler(signum, frame):
# def _sigusr2_handler(signum, frame):
#     def setMemoryLogging(level):
#     def filter(self, event):
#     def __init__(self, fmt, datefmt, strip=True):
#     def label(self, record):
#     def format(self, record):
# def init(app_name):
# def getLogger(name, verbose=None, log_verbose=None):
# def setBoring(boring=True):
# def setGlobalVerbosity(verbosity):
# def setGlobalLogVerbosity(verbosity):
# def setSilent(Lname):
# def setLoud(Lname):
# class _DefaultWriter(object):
# class LoggerWrapper(object):
# class LogFilter(logging.Filter):
# class ColorStrippingFormatter(logging.Formatter):
# GB = float(1024 ** 3)
#                 KEYS = _log_memory_types[memlevel]


# Path: cubical/machines/slope_machine.py
from cubical.machines.parameterised_machine import ParameterisedGains
from numpy.ma import masked_array
from cubical.tools import logger
        from .phase_diag_machine import PhaseDiagGains
import numpy as np
import cubical.kernels
import builtins

    def profile(func): return func
    builtins.profile = profile


class PhaseSlopeGains(ParameterisedGains):
    """
    This class implements the diagonal phase-only parameterised slope gain machine.
    """

    def __init__(self, label, data_arr, ndir, nmod, chunk_ts, chunk_fs, chunk_label, options):
        """
        Initialises a diagonal phase-slope gain machine.

        Args:
            label (str):
                Label identifying the Jones term.
            data_arr (np.ndarray):
                Shape (n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing observed
                visibilities.
            ndir (int):
                Number of directions.
            nmod (nmod):
                Number of models.
            chunk_ts (np.ndarray):
                Times for the data being processed.
            chunk_fs (np.ndarray):
                Frequencies for the data being processsed.
            options (dict):
                Dictionary of options.
        """

        ParameterisedGains.__init__(self, label, data_arr, ndir, nmod,