1 | #! /usr/bin/env python |
||
2 | # |
||
3 | # Copyright (C) 2015-2016 Rich Lewis <[email protected]> |
||
4 | # License: 3-clause BSD |
||
5 | |||
6 | 1 | """ |
|
7 | ## skchem.vis.atom |
||
8 | |||
9 | Module for atom contribution visualization. |
||
10 | """ |
||
11 | |||
12 | 1 | from rdkit.Chem.Draw import MolToImage, DrawingOptions |
|
0 ignored issues
–
show
|
|||
13 | |||
14 | 1 | import numpy as np |
|
0 ignored issues
–
show
The import
numpy could not be resolved.
This can be caused by one of the following: 1. Missing DependenciesThis error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands. # .scrutinizer.yml
before_commands:
- sudo pip install abc # Python2
- sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use
the command for the correct version.
2. Missing __init__.py filesThis error could also result from missing ![]() |
|||
15 | 1 | from matplotlib import pyplot as plt |
|
0 ignored issues
–
show
The import
matplotlib could not be resolved.
This can be caused by one of the following: 1. Missing DependenciesThis error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands. # .scrutinizer.yml
before_commands:
- sudo pip install abc # Python2
- sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use
the command for the correct version.
2. Missing __init__.py filesThis error could also result from missing ![]() |
|||
16 | |||
17 | |||
18 | 1 | def plot_weights(mol, weights, quality=1, l=0.4, step=50, levels=20, |
|
0 ignored issues
–
show
The name
l does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() The name
ax does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() |
|||
19 | contour_opacity=0.5, cmap='RdBu', ax=None, **kwargs): |
||
20 | """ Plot weights as a sum of gaussians across a structure image. |
||
21 | |||
22 | Args: |
||
23 | mol (skchem.Mol): |
||
24 | Molecule to visualize weights for. |
||
25 | weights (iterable<float>): |
||
26 | Array of weights in atom index order. |
||
27 | l (float): |
||
28 | Lengthscale of gaussians to visualize as a multiple of bond length. |
||
29 | step (int): |
||
30 | Size of grid edge to calculate the gaussians. |
||
31 | levels (int): |
||
32 | Number of contours to plot. |
||
33 | contour_opacity (float): |
||
34 | Alpha applied to the contour layer. |
||
35 | ax (plt.axis): |
||
36 | Axis to apply the plot to. Defaults to current axis. |
||
37 | cmap (plt.cm): |
||
38 | Colormap to use for the contour. |
||
39 | **kwargs: |
||
40 | Passed to contourf function. |
||
41 | |||
42 | Returns: |
||
43 | matplotlib.AxesSubplot: The plot. |
||
44 | """ |
||
45 | |||
46 | if not ax: |
||
47 | ax = plt.gca() |
||
48 | ax.grid('off') |
||
49 | ax.axis('off') |
||
50 | |||
51 | opts = DrawingOptions() |
||
52 | opts.dotsPerAngstrom *= quality |
||
53 | opts.atomLabelFontSize *= quality |
||
54 | opts.bondLineWidth *= quality |
||
55 | |||
56 | size = 300 * quality |
||
57 | |||
58 | img, canvas, drawer = MolToImage(mol, size=(size, size), options=opts, |
||
59 | returnCanvas=True) |
||
60 | canvas.flush() |
||
61 | coords = [[i / size, 1 - j / size] |
||
62 | for k, (i, j) in list(drawer.atomPs.values())[0].items()] |
||
0 ignored issues
–
show
|
|||
63 | coords = np.array(coords) |
||
64 | |||
65 | b = mol.bonds[0] |
||
0 ignored issues
–
show
The name
b does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() |
|||
66 | begin, end = b.GetBeginAtom().GetIdx(), b.GetEndAtom().GetIdx() |
||
67 | length = np.linalg.norm(coords[end] - coords[begin]) |
||
68 | |||
69 | x = np.linspace(0, 1, 500) |
||
0 ignored issues
–
show
The name
x does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() |
|||
70 | y = np.linspace(0, 1, 500) |
||
0 ignored issues
–
show
The name
y does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() |
|||
71 | x, y = np.meshgrid(x, y) |
||
0 ignored issues
–
show
The name
x does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() The name
y does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() |
|||
72 | |||
73 | def gaussian(x, y, mu=np.zeros(2), sigma=np.identity(2), size=50): |
||
0 ignored issues
–
show
The name
x does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() The name
y does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() The name
mu does not conform to the argument naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() This function should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
74 | return (1 / (2 * np.pi * sigma[0, 0] * sigma[1, 1]) * |
||
75 | np.exp(-((x - mu[0]) ** 2 / (2 * sigma[0, 0] ** 2) + |
||
76 | (y - mu[1]) ** 2 / (2 * sigma[1, 1] ** 2)))) |
||
77 | |||
78 | if not np.max(weights) == np.min(weights) == 0: |
||
79 | z = sum([w * gaussian(x, y, mu, sigma=l * length * np.identity(2)) |
||
0 ignored issues
–
show
The name
z does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() |
|||
80 | for mu, w in zip(coords, weights)]) |
||
81 | v = np.max((np.abs(z.min()), np.abs(z.max()))) |
||
0 ignored issues
–
show
The name
v does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() |
|||
82 | else: |
||
83 | z = np.zeros(x.shape) |
||
0 ignored issues
–
show
The name
z does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() |
|||
84 | v = 1 |
||
0 ignored issues
–
show
The name
v does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$ ).
This check looks for invalid names for a range of different identifiers. You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements. If your project includes a Pylint configuration file, the settings contained in that file take precedence. To find out more about Pylint, please refer to their site. ![]() |
|||
85 | |||
86 | if z.min() >= 0: |
||
87 | levels = int(levels/2) |
||
88 | ax.contourf(x, y, z, levels, alpha=contour_opacity, |
||
89 | extent=(0, 1, 0, 1), vmin=-v, vmax=v, cmap=cmap, **kwargs) |
||
90 | |||
91 | ax.imshow(img, extent=(0, 1, 0, 1)) |
||
92 | return ax |
||
93 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.