diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 679bcf068..2f267be9d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: trailing-whitespace exclude: setup.cfg - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black args: [--line-length=80] diff --git a/mbuild/__init__.py b/mbuild/__init__.py index 02d471c49..67279916d 100644 --- a/mbuild/__init__.py +++ b/mbuild/__init__.py @@ -1,4 +1,5 @@ """mBuild: a hierarchical, component based molecule builder.""" + from mbuild.box import Box from mbuild.coarse_graining import coarse_grain from mbuild.compound import * diff --git a/mbuild/box.py b/mbuild/box.py index 2b04dcda4..8a739db62 100644 --- a/mbuild/box.py +++ b/mbuild/box.py @@ -1,4 +1,5 @@ """mBuild box module.""" + from warnings import warn import numpy as np diff --git a/mbuild/coarse_graining.py b/mbuild/coarse_graining.py index 732fb1f47..2e619afbf 100644 --- a/mbuild/coarse_graining.py +++ b/mbuild/coarse_graining.py @@ -1,4 +1,5 @@ """Tools for coarse-grained systems.""" + from collections import OrderedDict from copy import deepcopy diff --git a/mbuild/compound.py b/mbuild/compound.py index 30d2f27f7..b53d7fbdc 100644 --- a/mbuild/compound.py +++ b/mbuild/compound.py @@ -1,4 +1,5 @@ """Module for working with mBuild Compounds.""" + __all__ = ["clone", "Compound", "Particle"] import itertools @@ -1864,7 +1865,11 @@ def particles_in_range( return particle_array[idxs] def visualize( - self, show_ports=False, backend="py3dmol", color_scheme={} + self, + show_ports=False, + backend="py3dmol", + color_scheme={}, + bead_size=0.3, ): # pragma: no cover """Visualize the Compound using py3dmol (default) or nglview. @@ -1882,6 +1887,8 @@ def visualize( keys are strings of the particle names values are strings of the colors i.e. {'_CGBEAD': 'blue'} + bead_size : float, Optional, default=0.3 + Size of beads in visualization """ viz_pkg = { "nglview": self._visualize_nglview, @@ -1890,7 +1897,9 @@ def visualize( if run_from_ipython(): if backend.lower() in viz_pkg: return viz_pkg[backend.lower()]( - show_ports=show_ports, color_scheme=color_scheme + show_ports=show_ports, + color_scheme=color_scheme, + bead_size=bead_size, ) else: raise RuntimeError( @@ -1903,7 +1912,9 @@ def visualize( "Visualization is only supported in Jupyter Notebooks." ) - def _visualize_py3dmol(self, show_ports=False, color_scheme={}): + def _visualize_py3dmol( + self, show_ports=False, color_scheme={}, bead_size=0.3 + ): """Visualize the Compound using py3Dmol. Allows for visualization of a Compound within a Jupyter Notebook. @@ -1917,6 +1928,8 @@ def _visualize_py3dmol(self, show_ports=False, color_scheme={}): keys are strings of the particle names values are strings of the colors i.e. {'_CGBEAD': 'blue'} + bead_size : float, Optional, default=0.3 + Size of beads in visualization Returns ------- @@ -1951,15 +1964,20 @@ def _visualize_py3dmol(self, show_ports=False, color_scheme={}): view.setStyle( { - "stick": {"radius": 0.2, "color": "grey"}, - "sphere": {"scale": 0.3, "colorscheme": modified_color_scheme}, + "stick": {"radius": bead_size * 0.6, "color": "grey"}, + "sphere": { + "scale": bead_size, + "colorscheme": modified_color_scheme, + }, } ) view.zoomTo() return view - def _visualize_nglview(self, show_ports=False, color_scheme={}): + def _visualize_nglview( + self, show_ports=False, color_scheme={}, bead_size=0.3 + ): """Visualize the Compound using nglview. Allows for visualization of a Compound within a Jupyter Notebook. diff --git a/mbuild/conversion.py b/mbuild/conversion.py index 25ce152b7..bca251d1b 100644 --- a/mbuild/conversion.py +++ b/mbuild/conversion.py @@ -1,4 +1,5 @@ """Module for handling conversions in mBuild.""" + import os import sys from collections import defaultdict diff --git a/mbuild/coordinate_transform.py b/mbuild/coordinate_transform.py index 30c723d22..1edf2d609 100644 --- a/mbuild/coordinate_transform.py +++ b/mbuild/coordinate_transform.py @@ -1,4 +1,5 @@ """Coordinate transformation functions.""" + from warnings import simplefilter, warn simplefilter("always", DeprecationWarning) diff --git a/mbuild/formats/cassandramcf.py b/mbuild/formats/cassandramcf.py index 8a6b4e890..14d92cb1f 100644 --- a/mbuild/formats/cassandramcf.py +++ b/mbuild/formats/cassandramcf.py @@ -2,6 +2,7 @@ https://cassandra-mc.readthedocs.io/en/latest/guides/input_files.html#molecular-connectivity-file """ + from __future__ import division import warnings diff --git a/mbuild/formats/gsdwriter.py b/mbuild/formats/gsdwriter.py index 3ab4b5c03..2de3d5cd3 100644 --- a/mbuild/formats/gsdwriter.py +++ b/mbuild/formats/gsdwriter.py @@ -2,6 +2,7 @@ https://gsd.readthedocs.io/en/stable/ """ + import numpy as np from mbuild.utils.geometry import coord_shift diff --git a/mbuild/formats/hoomd_forcefield.py b/mbuild/formats/hoomd_forcefield.py index 8090991cd..8cd4b39c0 100644 --- a/mbuild/formats/hoomd_forcefield.py +++ b/mbuild/formats/hoomd_forcefield.py @@ -1,4 +1,5 @@ """HOOMD v3 forcefield format.""" + import itertools import operator import warnings diff --git a/mbuild/formats/hoomd_simulation.py b/mbuild/formats/hoomd_simulation.py index 38452bb47..d1c847cbb 100644 --- a/mbuild/formats/hoomd_simulation.py +++ b/mbuild/formats/hoomd_simulation.py @@ -1,4 +1,5 @@ """HOOMD simulation format.""" + import itertools import operator import warnings diff --git a/mbuild/formats/hoomd_snapshot.py b/mbuild/formats/hoomd_snapshot.py index 673e0415b..b52b9db72 100644 --- a/mbuild/formats/hoomd_snapshot.py +++ b/mbuild/formats/hoomd_snapshot.py @@ -1,4 +1,5 @@ """HOOMD snapshot format.""" + import operator from collections import namedtuple diff --git a/mbuild/formats/hoomdxml.py b/mbuild/formats/hoomdxml.py index bd1efd120..6a564c804 100644 --- a/mbuild/formats/hoomdxml.py +++ b/mbuild/formats/hoomdxml.py @@ -1,4 +1,5 @@ """HOOMD xml format.""" + import operator from collections import namedtuple from math import radians diff --git a/mbuild/formats/json_formats.py b/mbuild/formats/json_formats.py index c354ab2da..33bbb53de 100644 --- a/mbuild/formats/json_formats.py +++ b/mbuild/formats/json_formats.py @@ -1,4 +1,5 @@ """JSON format.""" + import json from collections import OrderedDict diff --git a/mbuild/formats/lammpsdata.py b/mbuild/formats/lammpsdata.py index 46e434ec7..bf6fb6d5d 100644 --- a/mbuild/formats/lammpsdata.py +++ b/mbuild/formats/lammpsdata.py @@ -1,4 +1,5 @@ """LAMMPS data format.""" + import itertools as it from collections import OrderedDict from warnings import warn @@ -708,9 +709,7 @@ def _get_bond_types( ( round( bond.type.k - * ( - sigma_conversion_factor**2 / epsilon_conversion_factor - ), + * (sigma_conversion_factor**2 / epsilon_conversion_factor), bond_precision, ), round(bond.type.req / sigma_conversion_factor, bond_precision), diff --git a/mbuild/formats/par_writer.py b/mbuild/formats/par_writer.py index db8d368d8..26410efa9 100644 --- a/mbuild/formats/par_writer.py +++ b/mbuild/formats/par_writer.py @@ -1,4 +1,5 @@ """CHARMM Par format.""" + import warnings __all__ = ["write_par"] diff --git a/mbuild/formats/protobuf.py b/mbuild/formats/protobuf.py index b3fdec61b..1c8c8f1c2 100644 --- a/mbuild/formats/protobuf.py +++ b/mbuild/formats/protobuf.py @@ -3,6 +3,7 @@ A language-agnostic data serialization format developed by Google https://developers.google.com/protocol-buffers """ + import ele import numpy as np from google.protobuf.text_format import Merge, PrintMessage diff --git a/mbuild/formats/vasp.py b/mbuild/formats/vasp.py index 5b0ee8e7e..2d2b1d7c0 100644 --- a/mbuild/formats/vasp.py +++ b/mbuild/formats/vasp.py @@ -1,4 +1,5 @@ """VASP POSCAR format.""" + import warnings from itertools import chain diff --git a/mbuild/formats/xyz.py b/mbuild/formats/xyz.py index 53a4090ad..f4def4843 100644 --- a/mbuild/formats/xyz.py +++ b/mbuild/formats/xyz.py @@ -1,4 +1,5 @@ """XYZ format.""" + from warnings import warn import numpy as np diff --git a/mbuild/lattice.py b/mbuild/lattice.py index df7252250..df81c5cab 100644 --- a/mbuild/lattice.py +++ b/mbuild/lattice.py @@ -1,4 +1,5 @@ """mBuild lattice module for working with crystalline systems.""" + import itertools as it import pathlib import warnings @@ -679,8 +680,8 @@ def populate(self, compound_dict=None, x=1, y=1, z=1): # if coordinates are below a certain threshold, set to 0 tolerance = 1e-12 - ret_lattice.xyz_with_ports[ - ret_lattice.xyz_with_ports <= tolerance - ] = 0.0 + ret_lattice.xyz_with_ports[ret_lattice.xyz_with_ports <= tolerance] = ( + 0.0 + ) return ret_lattice diff --git a/mbuild/lib/atoms/__init__.py b/mbuild/lib/atoms/__init__.py index 0f8bda678..fb9d8cbc1 100644 --- a/mbuild/lib/atoms/__init__.py +++ b/mbuild/lib/atoms/__init__.py @@ -1,4 +1,5 @@ """mBuild library of atoms.""" + from mbuild.lib.atoms.c3 import C3 from mbuild.lib.atoms.h import H from mbuild.lib.atoms.n4 import N4 diff --git a/mbuild/lib/atoms/c3.py b/mbuild/lib/atoms/c3.py index ebf6863aa..09f84c7e4 100644 --- a/mbuild/lib/atoms/c3.py +++ b/mbuild/lib/atoms/c3.py @@ -1,4 +1,5 @@ """A tri-valent, planar carbon atom.""" + import numpy as np import mbuild as mb diff --git a/mbuild/lib/atoms/h.py b/mbuild/lib/atoms/h.py index 6e8d667d8..a96e658e6 100644 --- a/mbuild/lib/atoms/h.py +++ b/mbuild/lib/atoms/h.py @@ -1,4 +1,5 @@ """An H atom.""" + import numpy as np import mbuild as mb diff --git a/mbuild/lib/atoms/n4.py b/mbuild/lib/atoms/n4.py index 79b80e694..7f4103400 100644 --- a/mbuild/lib/atoms/n4.py +++ b/mbuild/lib/atoms/n4.py @@ -1,4 +1,5 @@ """mBuild atom library for tetravalent nitrogen.""" + import numpy as np import mbuild as mb diff --git a/mbuild/lib/bulk_materials/__init__.py b/mbuild/lib/bulk_materials/__init__.py index 79fd5c1e6..9417b96a3 100644 --- a/mbuild/lib/bulk_materials/__init__.py +++ b/mbuild/lib/bulk_materials/__init__.py @@ -1,2 +1,3 @@ """mBuild bulk materials library.""" + from mbuild.lib.bulk_materials.amorphous_silica_bulk import AmorphousSilicaBulk diff --git a/mbuild/lib/bulk_materials/amorphous_silica_bulk.py b/mbuild/lib/bulk_materials/amorphous_silica_bulk.py index 427eba32d..0b13c7d2d 100644 --- a/mbuild/lib/bulk_materials/amorphous_silica_bulk.py +++ b/mbuild/lib/bulk_materials/amorphous_silica_bulk.py @@ -1,4 +1,5 @@ """A bulk structure of amorphous silica.""" + import mbuild as mb diff --git a/mbuild/lib/moieties/__init__.py b/mbuild/lib/moieties/__init__.py index b437b5575..a1978ef0b 100644 --- a/mbuild/lib/moieties/__init__.py +++ b/mbuild/lib/moieties/__init__.py @@ -1,4 +1,5 @@ """mBuild library of common chemical moieties.""" + from mbuild.lib.moieties.ch2 import CH2 from mbuild.lib.moieties.ch3 import CH3 from mbuild.lib.moieties.ester import Ester diff --git a/mbuild/lib/moieties/ch2.py b/mbuild/lib/moieties/ch2.py index 390d4a2af..216610d83 100644 --- a/mbuild/lib/moieties/ch2.py +++ b/mbuild/lib/moieties/ch2.py @@ -1,4 +1,5 @@ """CH2 moiety.""" + import mbuild as mb diff --git a/mbuild/lib/moieties/ch3.py b/mbuild/lib/moieties/ch3.py index 6bec892ce..9cb50c1d8 100644 --- a/mbuild/lib/moieties/ch3.py +++ b/mbuild/lib/moieties/ch3.py @@ -1,4 +1,5 @@ """mBuild CH3 moiety.""" + import mbuild as mb diff --git a/mbuild/lib/moieties/ester.py b/mbuild/lib/moieties/ester.py index 18d90c709..d25d560db 100644 --- a/mbuild/lib/moieties/ester.py +++ b/mbuild/lib/moieties/ester.py @@ -1,4 +1,5 @@ """Ester moiety.""" + import numpy as np import mbuild as mb diff --git a/mbuild/lib/moieties/h2o.py b/mbuild/lib/moieties/h2o.py index a07092693..337fd7532 100644 --- a/mbuild/lib/moieties/h2o.py +++ b/mbuild/lib/moieties/h2o.py @@ -1,4 +1,5 @@ """A water molecule.""" + import mbuild as mb diff --git a/mbuild/lib/moieties/peg.py b/mbuild/lib/moieties/peg.py index dbf9a1431..47db0a676 100644 --- a/mbuild/lib/moieties/peg.py +++ b/mbuild/lib/moieties/peg.py @@ -1,4 +1,5 @@ """mBuild polyethylene glycol (PEG) monomer moiety.""" + __author__ = "jonestj1" import mbuild as mb diff --git a/mbuild/lib/moieties/silane.py b/mbuild/lib/moieties/silane.py index 4d94eae1d..e444d86cb 100644 --- a/mbuild/lib/moieties/silane.py +++ b/mbuild/lib/moieties/silane.py @@ -1,4 +1,5 @@ """A Silane (Si(OH)2) moiety.""" + import numpy as np import mbuild as mb diff --git a/mbuild/lib/molecules/__init__.py b/mbuild/lib/molecules/__init__.py index 9f2b8111a..f39893047 100644 --- a/mbuild/lib/molecules/__init__.py +++ b/mbuild/lib/molecules/__init__.py @@ -1,4 +1,5 @@ """Library of molecules for mBuild.""" + from mbuild.lib.molecules.ethane import Ethane from mbuild.lib.molecules.methane import Methane from mbuild.lib.molecules.water import ( diff --git a/mbuild/lib/molecules/ethane.py b/mbuild/lib/molecules/ethane.py index 733475713..0722208d2 100644 --- a/mbuild/lib/molecules/ethane.py +++ b/mbuild/lib/molecules/ethane.py @@ -1,4 +1,5 @@ """An ethane molecule.""" + import mbuild as mb from mbuild.lib.moieties import CH3 diff --git a/mbuild/lib/molecules/methane.py b/mbuild/lib/molecules/methane.py index 2e4c688e8..869433858 100644 --- a/mbuild/lib/molecules/methane.py +++ b/mbuild/lib/molecules/methane.py @@ -1,4 +1,5 @@ """A methane molecule.""" + import mbuild as mb diff --git a/mbuild/lib/molecules/water.py b/mbuild/lib/molecules/water.py index ff12d2513..071c0e4bb 100644 --- a/mbuild/lib/molecules/water.py +++ b/mbuild/lib/molecules/water.py @@ -1,4 +1,5 @@ """Water molecules with geometries from different models.""" + import numpy as np import mbuild as mb diff --git a/mbuild/lib/recipes/__init__.py b/mbuild/lib/recipes/__init__.py index 82ee28ffa..9d4fc9b3a 100644 --- a/mbuild/lib/recipes/__init__.py +++ b/mbuild/lib/recipes/__init__.py @@ -1,4 +1,5 @@ """Library of recipes for mBuild.""" + from mbuild.lib.recipes.alkane import Alkane from mbuild.lib.recipes.monolayer import Monolayer from mbuild.lib.recipes.polymer import Polymer diff --git a/mbuild/lib/recipes/alkane.py b/mbuild/lib/recipes/alkane.py index 33509e01b..b0e908403 100644 --- a/mbuild/lib/recipes/alkane.py +++ b/mbuild/lib/recipes/alkane.py @@ -1,4 +1,5 @@ """mBuild recipe for a generic alkane chain.""" + import mbuild as mb from mbuild.lib.moieties import CH2, CH3 from mbuild.lib.molecules import Ethane, Methane diff --git a/mbuild/lib/recipes/monolayer.py b/mbuild/lib/recipes/monolayer.py index a475d36e3..25ab4a7f3 100644 --- a/mbuild/lib/recipes/monolayer.py +++ b/mbuild/lib/recipes/monolayer.py @@ -1,4 +1,5 @@ """mBuild monolayer recipe.""" + from copy import deepcopy from warnings import warn diff --git a/mbuild/lib/recipes/polymer.py b/mbuild/lib/recipes/polymer.py index abf2b34ac..3b1eb623b 100644 --- a/mbuild/lib/recipes/polymer.py +++ b/mbuild/lib/recipes/polymer.py @@ -1,4 +1,5 @@ """Recipe for an mBuild polymer.""" + import itertools as it import numpy as np diff --git a/mbuild/lib/recipes/silica_interface.py b/mbuild/lib/recipes/silica_interface.py index b1365c391..4f0149563 100644 --- a/mbuild/lib/recipes/silica_interface.py +++ b/mbuild/lib/recipes/silica_interface.py @@ -1,4 +1,5 @@ """mBuild recipe for a silica interface.""" + import math import random diff --git a/mbuild/lib/recipes/tiled_compound.py b/mbuild/lib/recipes/tiled_compound.py index 3f6864b9d..4c228ca69 100644 --- a/mbuild/lib/recipes/tiled_compound.py +++ b/mbuild/lib/recipes/tiled_compound.py @@ -1,4 +1,5 @@ """Module for creating TiledCompounds.""" + __all__ = ["TiledCompound"] import itertools as it diff --git a/mbuild/lib/recipes/water_box.py b/mbuild/lib/recipes/water_box.py index 0bec3b4ba..6e15b4940 100644 --- a/mbuild/lib/recipes/water_box.py +++ b/mbuild/lib/recipes/water_box.py @@ -1,4 +1,5 @@ """mBuild recipe for building a water box.""" + import itertools import math as math from collections.abc import Iterable diff --git a/mbuild/lib/surfaces/__init__.py b/mbuild/lib/surfaces/__init__.py index 13e26df3c..b7e40474b 100644 --- a/mbuild/lib/surfaces/__init__.py +++ b/mbuild/lib/surfaces/__init__.py @@ -1,3 +1,4 @@ """mBuild surface library.""" + from mbuild.lib.surfaces.amorphous_silica_surface import AmorphousSilicaSurface from mbuild.lib.surfaces.betacristobalite import Betacristobalite diff --git a/mbuild/lib/surfaces/amorphous_silica_surface.py b/mbuild/lib/surfaces/amorphous_silica_surface.py index 7076517fa..646229f3c 100644 --- a/mbuild/lib/surfaces/amorphous_silica_surface.py +++ b/mbuild/lib/surfaces/amorphous_silica_surface.py @@ -1,4 +1,5 @@ """Amorphous silica surface.""" + import mbuild as mb diff --git a/mbuild/lib/surfaces/betacristobalite.py b/mbuild/lib/surfaces/betacristobalite.py index c97b11f3c..d78c7246b 100644 --- a/mbuild/lib/surfaces/betacristobalite.py +++ b/mbuild/lib/surfaces/betacristobalite.py @@ -1,4 +1,5 @@ """Beta-cristobalite surface.""" + import mbuild as mb diff --git a/mbuild/packing.py b/mbuild/packing.py index 71dd98e4e..0e7e06316 100644 --- a/mbuild/packing.py +++ b/mbuild/packing.py @@ -2,6 +2,7 @@ http://leandro.iqm.unicamp.br/m3g/packmol/home.shtml """ + import os import sys import tempfile diff --git a/mbuild/pattern.py b/mbuild/pattern.py index b5a58181d..8173c0e1a 100644 --- a/mbuild/pattern.py +++ b/mbuild/pattern.py @@ -1,4 +1,5 @@ """mBuild pattern module.""" + from itertools import product import numpy as np diff --git a/mbuild/port.py b/mbuild/port.py index fcc77d4dd..31be5ef98 100644 --- a/mbuild/port.py +++ b/mbuild/port.py @@ -1,4 +1,5 @@ """Ports used to facilitate bond formation.""" + import itertools from warnings import warn diff --git a/mbuild/utils/conversion.py b/mbuild/utils/conversion.py index cde18c540..bd3c47a97 100644 --- a/mbuild/utils/conversion.py +++ b/mbuild/utils/conversion.py @@ -1,4 +1,5 @@ """mBuild conversion utilities.""" + from warnings import warn import numpy as np diff --git a/mbuild/utils/decorators.py b/mbuild/utils/decorators.py index 7da2a3671..b7a75f16f 100644 --- a/mbuild/utils/decorators.py +++ b/mbuild/utils/decorators.py @@ -1,4 +1,5 @@ """Some helpful decorators.""" + from functools import wraps from warnings import warn diff --git a/mbuild/utils/geometry.py b/mbuild/utils/geometry.py index 8b558273a..972fd1e3b 100644 --- a/mbuild/utils/geometry.py +++ b/mbuild/utils/geometry.py @@ -1,4 +1,5 @@ """mBuild utilites for geometrical operations.""" + import numpy as np import mbuild as mb diff --git a/mbuild/utils/io.py b/mbuild/utils/io.py index 80558a83b..8b233cbf1 100644 --- a/mbuild/utils/io.py +++ b/mbuild/utils/io.py @@ -18,6 +18,7 @@ # License along with MDTraj. If not, see . ############################################################################## """ + import importlib import inspect import os diff --git a/mbuild/utils/jsutils.py b/mbuild/utils/jsutils.py index 403241b0f..5eeb1066b 100644 --- a/mbuild/utils/jsutils.py +++ b/mbuild/utils/jsutils.py @@ -4,6 +4,7 @@ underlying 'js' libraries by the various notebook visualization libraries used by mBuild. """ + from .io import import_ diff --git a/mbuild/utils/orderedset.py b/mbuild/utils/orderedset.py index c83227d56..6ca17aab4 100644 --- a/mbuild/utils/orderedset.py +++ b/mbuild/utils/orderedset.py @@ -1,4 +1,5 @@ """Ordered set module.""" + from collections.abc import MutableSet diff --git a/mbuild/utils/sorting.py b/mbuild/utils/sorting.py index c33a45fce..6f775da39 100644 --- a/mbuild/utils/sorting.py +++ b/mbuild/utils/sorting.py @@ -1,4 +1,5 @@ """mBuild sorting utilities.""" + import re