def __init__(self): """Initializes the :class:`clusterking.scan.Scanner` class.""" super().__init__() # todo: move self.log = get_logger("Scanner") #: Points in wilson space #: Use self.spoints to access this self._spoints = None # type: Optional[np.ndarray] #: Instance of SpointCalculator to perform the claculations of #: the wilson space points. self._spoint_calculator = SpointCalculator() # todo: move self.md = nested_dict() self.md["git"] = version_info(self.log) self.md["time"] = time.strftime("%a %d %b %Y %H:%M", time.gmtime()) # todo: shouldn't that be in metadata? #: Names of the parameters self._coeffs = [] # type: List[str] self._no_workers = None # type: Optional[int] self._progress_bar = True self._tqdm_kwargs = {} self.set_imaginary_prefix("im_")
def __init__(self): """ """ super().__init__() self.bpoints = None self.md = nested_dict() self.log = get_logger("Benchmark") self.set_cluster_column()
def __init__(self, data): """ Args: data: :py:class:`~clusterking.data.data.Data` object """ #: logging.Logger object self.log = get_logger("BundlePlot", sh_level=logging.WARNING) #: pandas dataframe self.data = data #: Name of the column holding the cluster number self.cluster_column = "cluster" self.bpoint_column = "bpoint" #: Color scheme # fixme: this will be problematic if I reinitialize this if self._has_clusters: self.color_scheme = ColorScheme(self._clusters) else: self.color_scheme = ColorScheme([0]) #: Draw legend? self.draw_legend = True #: Override default titles with this title. If None, the default title #: is used. self.title = None #: Instance of matplotlib.axes.Axes self.ax = None
def __init__(self): super().__init__() self._noise_kwargs = {} self._noise_args = [] self._repeat = 10 self._cache_data = True self.set_repeat() self.log = get_logger("NoisySample")
def __init__( self, path: Optional[Union[str, PurePath]] = None, log: Optional[Union[str, logging.Logger]] = None, ): """ Initialize a DFMD object. Args: path: Optional: load from this file (specified as string or :class:`pathlib.PurePath`) log: Optional: instance of :py:class:`logging.Logger` or name of logger to be created """ # These are the three attributes of this class #: This will hold all the configuration that we will write out self.md = None #: :py:class:`pandas.DataFrame` to hold all of the results self.df = None # type: Optional[pd.DataFrame] #: Instance of :py:class:`logging.Logger` self.log = None # todo: remember path? if not path: # Initialize blank self.md = nested_dict() self.df = pd.DataFrame() self.log = None else: self._load(path) # Overwrite log if user wants that. if isinstance(log, logging.Logger): self.log = log elif isinstance(log, str): self.log = get_logger(log) elif log is None: if not self.log: self.log = get_logger("DFMD") else: raise ValueError( "Unsupported type '{}' for 'log' argument.".format(type(log)))
def __init__(self, data: Data): """ Initializer of the object. .. note:: The :class:`~clusterking.result.Result` is not meant to be initialized by the user. Rather it is a return object of the :meth:`clusterking.worker.Worker.run` method. """ super().__init__() self._data = data # type: Data self.log = get_logger(str(type(self)))
def import_matplotlib(): """ Tries to import matplotlib, printing help message if it fails. """ try: import matplotlib except ImportError: from clusterking.util.log import get_logger log = get_logger() msg = ( "Could not import matplotlib. Perhaps you didn't install " "ClusterKinG with the 'plotting' option? Please install matplotlib " "to use ClusterKinG's plotting funcionality. ") log.critical(msg) raise ImportError(msg)
def __init__(self): """ Args: data: :py:class:`~clusterking.data.Data` object """ super().__init__() self.log = get_logger("Scanner") self.clusters = None # self.bpoints = None #: Metadata self.md = nested_dict() self.md["git"] = version_info(self.log) self.md["time"] = time.strftime("%a %d %b %Y %H:%M", time.gmtime())
def __init__( self, clusters: Optional[List[int]] = None, colors: Optional[List[str]] = None, ): """ Initialize `ColorScheme` object. Args: clusters: List of cluster names colors: List of colors """ self.log = get_logger("Colors", sh_level=logging.WARNING) self._cluster_colors = None # todo: perhaps use this: https://personal.sron.nl/~pault/ self.cluster_colors = [ "xkcd:light red", "xkcd:apple green", "xkcd:bright blue", "xkcd:charcoal grey", "xkcd:orange", "xkcd:purple", "xkcd:brick red", "xkcd:hunter green", "xkcd:marigold", "xkcd:darkish blue", "xkcd:dirt brown", "xkcd:vivid green", "xkcd:periwinkle", ] if colors: self.cluster_colors = colors if not clusters: self.clusters = range(len(self.cluster_colors)) else: self.clusters = list(clusters) if len(self.clusters) > len(self.cluster_colors): self.log.warning( "Not enough colors for all clusters. Some clusters might end up" " with identical colors.")
def __init__(self, data): """ Args: data: :py:class:`~clusterking.data.data.Data` object """ #: logging.Logger object self.log = get_logger("ClusterPlot", sh_level=logging.WARNING) #: Instance of pandas.DataFrame self.data = data # (Advanced) config values # Documented in docstring of this class #: Color scheme self.color_scheme = None #: List of markers of the get_clusters (scatter plot only). self.markers = None if not self.markers: self.markers = ["o", "v", "^", "v", "<", ">"] #: Maximal number of subplots self.max_subplots = 16 #: Maximal number of columns of the subplot grid self.max_cols = 4 #: Formatting of key-value pairs in title of plots self.kv_formatter = "{}={:.2f}" #: figure size of each subplot self.fig_base_size = 4 #: Ratio of height/width. None: Automatically inferred self.aspect_ratio = None #: The name of the column that holds the cluster index self.cluster_column = "cluster" #: The name of the column that holds the benchmark yes/no information self.bpoint_column = "bpoint" #: Default marker size self.default_marker_size = (1 / 2 * matplotlib.rcParams["lines.markersize"]**2) #: Marker size of benchmark points self.bpoint_marker_size = 6 * self.default_marker_size #: If true, a legend is drawn self.draw_legend = True # Internal values: Do not modify # ---------------------------------------------------------------------- # Names of the columns to be on the axes of # the plot. self._axis_columns = None self._clusters = None self._df_dofs = None self._fig = None self._axs = None
#!/usr/bin/env python3 # std import sys # ours import clusterking.cluster import clusterking.data import clusterking.maths import clusterking.scan import clusterking.util from clusterking.data import Data, DataWithErrors from clusterking.benchmark.benchmark import Benchmark from clusterking.util.metadata import get_version as _get_version from clusterking.util.log import get_logger version = _get_version() if sys.version_info < (3, 6): get_logger().warning("The newer versions of ClusterKinG will require " "python >= 3.6. Anything below that has reached" " its end of life. Please consider upgrading.")