Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganise namespaces #111

Merged
merged 8 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# ChemCoord documentation build configuration file, created by
# sphinx-quickstart on Tue Jan 12 23:12:55 2016.
Expand Down Expand Up @@ -59,7 +58,6 @@
"pymatgen": ("http://pymatgen.org/", None),
"python": ("https://docs.python.org/3", None),
}
# 'sympy': ('http://www.sympy.org/', None)}


# 'numpydoc'
Expand Down Expand Up @@ -244,7 +242,7 @@

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
latex_elements: dict = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# explicitly blacklist files, this means we can easily add in stricter type checks
# by removing them from the blacklist
[mypy-chemcoord.cartesian_coordinates.asymmetric_unit_cartesian_class,chemcoord.cartesian_coordinates._cartesian_class_core,chemcoord.cartesian_coordinates._cartesian_class_get_zmat,chemcoord.cartesian_coordinates._cartesian_class_io,chemcoord.cartesian_coordinates.cartesian_class_main,chemcoord.cartesian_coordinates._cartesian_class_pandas_wrapper,chemcoord.cartesian_coordinates._cartesian_class_symmetry,chemcoord.cartesian_coordinates._cart_transformation,chemcoord.cartesian_coordinates._indexers,chemcoord.cartesian_coordinates.point_group,chemcoord.cartesian_coordinates.xyz_functions,chemcoord.configuration,chemcoord.constants,chemcoord.exceptions,chemcoord._generic_classes.generic_core,chemcoord._generic_classes.generic_IO,chemcoord.internal_coordinates._indexers,chemcoord.internal_coordinates._zmat_class_core,chemcoord.internal_coordinates._zmat_class_io,chemcoord.internal_coordinates.zmat_class_main,chemcoord.internal_coordinates._zmat_class_pandas_wrapper,chemcoord.internal_coordinates.zmat_functions,chemcoord.internal_coordinates._zmat_transformation,chemcoord.utilities._decorators,chemcoord.utilities._print_versions,chemcoord.utilities._temporary_deprecation_workarounds,chemcoord]
[mypy-chemcoord._cartesian_coordinates.asymmetric_unit_cartesian_class,chemcoord._cartesian_coordinates._cartesian_class_core,chemcoord._cartesian_coordinates._cartesian_class_get_zmat,chemcoord._cartesian_coordinates._cartesian_class_io,chemcoord._cartesian_coordinates.cartesian_class_main,chemcoord._cartesian_coordinates._cartesian_class_pandas_wrapper,chemcoord._cartesian_coordinates._cartesian_class_symmetry,chemcoord._cartesian_coordinates._cart_transformation,chemcoord._cartesian_coordinates._indexers,chemcoord._cartesian_coordinates.point_group,chemcoord._cartesian_coordinates.xyz_functions,chemcoord.configuration,chemcoord.constants,chemcoord.exceptions,chemcoord._generic_classes.generic_core,chemcoord._generic_classes.generic_IO,chemcoord._internal_coordinates._indexers,chemcoord._internal_coordinates._zmat_class_core,chemcoord._internal_coordinates._zmat_class_io,chemcoord._internal_coordinates.zmat_class_main,chemcoord._internal_coordinates._zmat_class_pandas_wrapper,chemcoord._internal_coordinates.zmat_functions,chemcoord._internal_coordinates._zmat_transformation,chemcoord._utilities._decorators,chemcoord._utilities._print_versions,chemcoord._utilities._temporary_deprecation_workarounds,chemcoord]
disallow_untyped_defs = False
check_untyped_defs = False

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Setup file for the chemcoord package."""

from setuptools import find_packages, setup
Expand Down
48 changes: 17 additions & 31 deletions src/chemcoord/__init__.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
# ruff: noqa: E402
# ruff: noqa: PLC0414
# ruff: noqa: F401

from importlib.metadata import version

__version__ = version("chemcoord")
_git_branch = "master"


def export(func):
if callable(func) and hasattr(func, "__name__"):
globals()[func.__name__] = func
try:
__all__.append(func.__name__)
except NameError:
__all__ = [func.__name__] # noqa: F841
return func


# have to be imported after export definition
import sys

import chemcoord.cartesian_coordinates.xyz_functions as xyz_functions
import chemcoord.configuration as configuration
import chemcoord.configuration
import chemcoord.constants
import chemcoord.internal_coordinates.zmat_functions as zmat_functions
import chemcoord.utilities
from chemcoord.cartesian_coordinates.asymmetric_unit_cartesian_class import (
AsymmetricUnitCartesian as AsymmetricUnitCartesian,
import chemcoord.xyz_functions
import chemcoord.zmat_functions
from chemcoord._cartesian_coordinates.asymmetric_unit_cartesian_class import (
AsymmetricUnitCartesian,
)
from chemcoord._cartesian_coordinates.cartesian_class_main import Cartesian
from chemcoord._cartesian_coordinates.point_group import PointGroupOperations
from chemcoord._internal_coordinates.zmat_class_main import Zmat
from chemcoord._utilities._print_versions import show_versions
from chemcoord.configuration import settings
from chemcoord.zmat_functions import (
DummyManipulation,
PureInternalMovement,
TestOperators,
)
from chemcoord.cartesian_coordinates.cartesian_class_main import Cartesian as Cartesian
from chemcoord.configuration import settings as settings
from chemcoord.internal_coordinates.zmat_class_main import Zmat as Zmat
from chemcoord.utilities._print_versions import show_versions as show_versions

sys.modules["chemcoord.xyz_functions"] = xyz_functions
sys.modules["chemcoord.zmat_functions"] = zmat_functions
__version__ = version("chemcoord")
_git_branch = "master"
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

import numba as nb
import numpy as np
from numba import jit
from numba.extending import overload
from numpy import arccos, arctan2, sqrt

import chemcoord.constants as constants
from chemcoord.cartesian_coordinates.xyz_functions import (
from chemcoord._cartesian_coordinates.xyz_functions import (
_jit_cross,
_jit_isclose,
_jit_normalize,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import collections
import copy
import itertools
Expand All @@ -10,12 +9,12 @@
from numba import jit
from sortedcontainers import SortedSet

import chemcoord.cartesian_coordinates.xyz_functions as xyz_functions
import chemcoord._cartesian_coordinates.xyz_functions as xyz_functions
import chemcoord.constants as constants
from chemcoord._generic_classes.generic_core import GenericCore
from chemcoord.cartesian_coordinates._cartesian_class_pandas_wrapper import (
from chemcoord._cartesian_coordinates._cartesian_class_pandas_wrapper import (
PandasWrapper,
)
from chemcoord._generic_classes.generic_core import GenericCore
from chemcoord.configuration import settings
from chemcoord.exceptions import IllegalArgumentCombination, PhysicalMeaning

Expand Down Expand Up @@ -69,8 +68,7 @@ def __init__(
raise ValueError("Need a pd.DataFrame as input")
if not self._required_cols <= set(frame.columns):
raise PhysicalMeaning(
"There are columns missing for a "
"meaningful description of a molecule"
"There are columns missing for a meaningful description of a molecule"
)
self._frame = frame.copy()
if metadata is None:
Expand Down Expand Up @@ -596,9 +594,9 @@ def _preserve_bonds(self, sliced_cartesian, use_lookup=None):
use_lookup = settings["defaults"]["use_lookup"]

included_atoms_set = set(sliced_cartesian.index)
assert included_atoms_set.issubset(
set(self.index)
), "The sliced Cartesian has to be a subset of the bigger frame"
assert included_atoms_set.issubset(set(self.index)), (
"The sliced Cartesian has to be a subset of the bigger frame"
)
bond_dic = self.get_bonds(use_lookup=use_lookup)
new_atoms = set([])
for atom in included_atoms_set:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import warnings
from collections import OrderedDict
from functools import partial
Expand All @@ -8,10 +7,12 @@
import pandas as pd
from numba.core.errors import NumbaPerformanceWarning

import chemcoord.cartesian_coordinates._cart_transformation as transformation
import chemcoord.cartesian_coordinates.xyz_functions as xyz_functions
import chemcoord._cartesian_coordinates._cart_transformation as transformation
import chemcoord._cartesian_coordinates.xyz_functions as xyz_functions
import chemcoord.constants as constants
from chemcoord.cartesian_coordinates._cartesian_class_core import CartesianCore
from chemcoord._cartesian_coordinates._cartesian_class_core import CartesianCore
from chemcoord._internal_coordinates.zmat_class_main import Zmat
from chemcoord._utilities._temporary_deprecation_workarounds import replace_without_warn
from chemcoord.configuration import settings
from chemcoord.exceptions import (
ERR_CODE_OK,
Expand All @@ -20,8 +21,6 @@
InvalidReference,
UndefinedCoordinateSystem,
)
from chemcoord.internal_coordinates.zmat_class_main import Zmat
from chemcoord.utilities._temporary_deprecation_workarounds import replace_without_warn


class CartesianGetZmat(CartesianCore):
Expand Down Expand Up @@ -82,7 +81,7 @@ def _get_frag_constr_table(

if start_atom is not None and predefined_table is not None:
raise IllegalArgumentCombination(
"Either start_atom or " "predefined_table has to be None"
"Either start_atom or predefined_table has to be None"
)
if bond_dict is None:
bond_dict = self._give_val_sorted_bond_dict(use_lookup=use_lookup)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import json
import os
import re
Expand All @@ -13,8 +12,8 @@
import pandas as pd

from chemcoord import constants
from chemcoord._cartesian_coordinates._cartesian_class_core import CartesianCore
from chemcoord._generic_classes.generic_IO import GenericIO
from chemcoord.cartesian_coordinates._cartesian_class_core import CartesianCore
from chemcoord.configuration import settings


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
import copy

import chemcoord.cartesian_coordinates._indexers as indexers
import chemcoord._cartesian_coordinates._indexers as indexers
from chemcoord.exceptions import PhysicalMeaning


Expand Down Expand Up @@ -156,8 +155,7 @@ def columns(self):
def columns(self, value):
if not self._required_cols <= set(value):
raise PhysicalMeaning(
"There are columns missing for a "
"meaningful description of a molecule"
"There are columns missing for a meaningful description of a molecule"
)
self._frame.columns = value

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from chemcoord.cartesian_coordinates._cartesian_class_core import CartesianCore
from chemcoord.cartesian_coordinates.point_group import PointGroupOperations
from chemcoord._cartesian_coordinates._cartesian_class_core import CartesianCore
from chemcoord._cartesian_coordinates.point_group import PointGroupOperations


class CartesianSymmetry(CartesianCore):
Expand Down Expand Up @@ -115,7 +114,7 @@ def symmetrize(self, max_n=10, tolerance=0.3, epsilon=1e-3):
def get_asymmetric_unit(self, eq=None):
eq = self.get_equivalent_atoms() if (eq is None) else eq
new_frame = self.loc[eq["eq_sets"].keys(), :]._frame
from chemcoord.cartesian_coordinates.asymmetric_unit_cartesian_class import ( # noqa: PLC0415
from chemcoord._cartesian_coordinates.asymmetric_unit_cartesian_class import ( # noqa: PLC0415
AsymmetricUnitCartesian,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-

import warnings

from chemcoord.utilities._temporary_deprecation_workarounds import is_iterable
from chemcoord._utilities._temporary_deprecation_workarounds import is_iterable


class _generic_Indexer(object):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd

from chemcoord.cartesian_coordinates.cartesian_class_main import Cartesian
from chemcoord._cartesian_coordinates.cartesian_class_main import Cartesian


class AsymmetricUnitCartesian(Cartesian):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from chemcoord.cartesian_coordinates._cartesian_class_get_zmat import CartesianGetZmat
from chemcoord.cartesian_coordinates._cartesian_class_io import CartesianIO
from chemcoord.cartesian_coordinates._cartesian_class_symmetry import CartesianSymmetry
from chemcoord._cartesian_coordinates._cartesian_class_get_zmat import CartesianGetZmat
from chemcoord._cartesian_coordinates._cartesian_class_io import CartesianIO
from chemcoord._cartesian_coordinates._cartesian_class_symmetry import CartesianSymmetry


class Cartesian(CartesianIO, CartesianGetZmat, CartesianSymmetry):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# -*- coding: utf-8 -*-
from chemcoord import export


@export
class PointGroupOperations(list):
"""Defines a point group as sequence of symmetry operations.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import math as m
import os
import subprocess
Expand Down Expand Up @@ -155,7 +154,7 @@ def read_molden(inputfile, start_index=0, get_bonds=True):
Returns:
list: A list containing :class:`~chemcoord.Cartesian` is returned.
"""
from chemcoord.cartesian_coordinates.cartesian_class_main import ( # noqa: PLC0415
from chemcoord._cartesian_coordinates.cartesian_class_main import ( # noqa: PLC0415
Cartesian,
)

Expand Down Expand Up @@ -460,7 +459,7 @@ def apply_grad_zmat_tensor(grad_C, construction_table, cart_dist):
if (construction_table.index != cart_dist.index).any():
message = "construction_table and cart_dist must use the same index"
raise ValueError(message)
from chemcoord.internal_coordinates.zmat_class_main import Zmat # noqa: PLC0415
from chemcoord._internal_coordinates.zmat_class_main import Zmat # noqa: PLC0415

dtypes = [
("atom", str),
Expand Down
1 change: 0 additions & 1 deletion src/chemcoord/_generic_classes/generic_IO.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import numpy as np
import sympy

Expand Down
1 change: 0 additions & 1 deletion src/chemcoord/_generic_classes/generic_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pandas as pd

import chemcoord.constants as constants
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-

import warnings

from chemcoord._utilities._temporary_deprecation_workarounds import is_iterable
from chemcoord.exceptions import InvalidReference
from chemcoord.utilities._temporary_deprecation_workarounds import is_iterable


class _generic_Indexer(object):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# -*- coding: utf-8 -*-
import copy
import warnings
from functools import partial

import numpy as np
import pandas as pd

import chemcoord._internal_coordinates._indexers as indexers
import chemcoord._internal_coordinates._zmat_transformation as transformation
import chemcoord.constants as constants
import chemcoord.internal_coordinates._indexers as indexers
import chemcoord.internal_coordinates._zmat_transformation as transformation
from chemcoord._generic_classes.generic_core import GenericCore
from chemcoord._internal_coordinates._zmat_class_pandas_wrapper import PandasWrapper
from chemcoord._utilities import _decorators
from chemcoord._utilities._temporary_deprecation_workarounds import replace_without_warn
from chemcoord.exceptions import (
ERR_CODE_OK,
ERR_CODE_InvalidReference,
InvalidReference,
PhysicalMeaning,
)
from chemcoord.internal_coordinates._zmat_class_pandas_wrapper import PandasWrapper
from chemcoord.utilities import _decorators
from chemcoord.utilities._temporary_deprecation_workarounds import replace_without_warn

append_indexer_docstring = _decorators.Appender(
"""In the case of obtaining elements, the indexing behaves like
Expand Down Expand Up @@ -58,8 +57,7 @@ def __init__(self, frame, metadata=None, _metadata=None):
"""
if not self._required_cols <= set(frame.columns):
raise PhysicalMeaning(
"There are columns missing for a "
"meaningful description of a molecule"
"There are columns missing for a meaningful description of a molecule"
)
self._frame = frame.copy()
if metadata is None:
Expand Down Expand Up @@ -508,7 +506,7 @@ def change_numbering(self, new_index=None):
c_table = c_table.astype("i8")
except ValueError:
raise ValueError(
"Due to a bug in pandas it is necessary to have " "integer columns"
"Due to a bug in pandas it is necessary to have integer columns"
)
c_table = c_table.replace(self.index, new_index)
c_table = c_table.replace({v: k for k, v in constants.int_label.items()})
Expand Down Expand Up @@ -667,7 +665,7 @@ def create_cartesian(positions, row):
)
xyz_frame["atom"] = self.loc[xyz_frame.index, "atom"]
xyz_frame.loc[:, ["x", "y", "z"]] = positions[:row]
from chemcoord.cartesian_coordinates.cartesian_class_main import ( # noqa: PLC0415
from chemcoord._cartesian_coordinates.cartesian_class_main import ( # noqa: PLC0415
Cartesian,
)

Expand Down Expand Up @@ -829,7 +827,7 @@ def drop_dummies(grad_X, zmolecule):
grad_X = drop_dummies(grad_X, self)

if as_function:
from chemcoord.internal_coordinates.zmat_functions import ( # noqa: PLC0415
from chemcoord._internal_coordinates.zmat_functions import ( # noqa: PLC0415
apply_grad_cartesian_tensor,
)

Expand Down
Loading