How to use the plonk._logging.logger.warning function in plonk

To help you get started, we’ve selected a few plonk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dmentipl / plonk / plonk / analysis / profile.py View on Github external
if self.snap._physical_units:
            xlabel = ' '.join([xlabel, f'[{_x.units:~P}]'])
            _x = _x.magnitude
        ax.set_xlabel(xlabel)

        for idx, yi in enumerate(y):
            _y = self[yi]
            if std_dev_shading:
                if yi.split('_')[-1] in _aggregations:
                    _yi = '_'.join(yi.split('_')[:-1])
                else:
                    _yi = yi
                try:
                    _y_std = self[_yi + '_std']
                except ValueError:
                    logger.warning('Cannot calculate standard deviation')
                if self.aggregation != 'mean':
                    _y_mean = self[_yi + '_mean']
                else:
                    _y_mean = _y
            label = yi.capitalize().replace('_', ' ')
            if self.snap._physical_units:
                if y_unit is not None:
                    _y = _y.to(y_unit[idx])
                    if std_dev_shading:
                        _y_std = _y_std.to(y_unit[idx])
                        _y_mean = _y_mean.to(y_unit[idx])
                label = ' '.join([label, f'[{_y.units:~P}]'])
                _y = _y.magnitude
                if std_dev_shading:
                    _y_std = _y_std.magnitude
                    _y_mean = _y_mean.magnitude
github dmentipl / plonk / plonk / simulation / simulation.py View on Github external
def _generate_snap_objects(self):
        """Generate Snap objects."""
        snaps = list()
        fail = 0
        for snap in self.paths['snaps']:
            try:
                snaps.append(load_snap(snap))
            except (OSError, RuntimeError):
                fail += 1
        if fail > 0:
            logger.warning(f'Cannot read {fail} snap(s)')
        self._snaps = snaps
github dmentipl / plonk / plonk / visualize / plots.py View on Github external
random_seed
        The random seed for sampling. Default is None.
    ax
        A matplotlib Axes handle.
    **kwargs
        Keyword arguments to pass to ax.scatter method.

    Returns
    -------
    paths
        A matplotlib PathCollection object.
    """
    if c is None and s is None:
        raise ValueError('Should set size or color')
    if n_samples > 100_000:
        logger.warning('n_samples > 100,000: this may be slow')
    if random_seed is not None:
        np.random.seed(random_seed)

    rand = np.random.choice(len(x), n_samples)

    x = x[rand]
    y = y[rand]
    if c is not None:
        c = c[rand]
    if s is not None:
        s = s[rand]

    _kwargs = copy(kwargs)
    alpha = _kwargs.pop('alpha', 0.5)

    return ax.scatter(x, y, c=c, s=s, alpha=alpha, **_kwargs)