Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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)