Skip to content

Commit

Permalink
Fix all violations of code style
Browse files Browse the repository at this point in the history
  • Loading branch information
isteinbrecher committed Dec 16, 2024
1 parent dd24c54 commit 16253c4
Show file tree
Hide file tree
Showing 57 changed files with 55 additions and 202 deletions.
4 changes: 2 additions & 2 deletions .github/actions/code_check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ runs:
cd ${GITHUB_WORKSPACE}
source python-testing-environment/bin/activate
pip install -e .[CI-CD]
black . --check --exclude=python-testing-environment && exit 0
exit 1
pre-commit install --install-hooks
pre-commit run --all-files
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: v5.0.0
hooks:
- id: check-added-large-files
args: ['—-maxkb=1000']
args: [maxkb=1000]
name: Check for added large files
- id: check-ast
name: Check Python files for parse errors
Expand Down
8 changes: 1 addition & 7 deletions meshpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"""This module defines classes and functions to create and edit a 4C input
file."""

# Global configuration object.
# Mesh items.
from .base_mesh_item import BaseMeshItemString

Expand All @@ -45,13 +44,11 @@

# Functions to set default header options.
from .header_functions import (
get_comment,
get_yes_no,
set_beam_to_solid_meshtying,
set_header_static,
set_runtime_output,
)
from .inputfile import InputFile, InputSection, InputSectionMultiKey
from .inputfile import InputFile, InputSection
from .material import (
MaterialBeam,
MaterialEulerBernoulli,
Expand All @@ -69,9 +66,6 @@
# 3D rotations for nodes.
from .rotation import Rotation

# Utility functions.
from .utility import clean_simulation_directory

# Define the items that will be exported by default.
__all__ = [
# Option object.
Expand Down
4 changes: 2 additions & 2 deletions meshpy/abaqus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"""This module defines classes and functions to create an Abaqus beam input
file."""

from .beam import AbaqusBeamMaterial, generate_abaqus_beam
from .input_file import AbaqusBeamNormalDefinition, AbaqusInputFile
from meshpy.abaqus.beam import AbaqusBeamMaterial, generate_abaqus_beam
from meshpy.abaqus.input_file import AbaqusBeamNormalDefinition, AbaqusInputFile

# Define the items that will be exported by default.
__all__ = [
Expand Down
2 changes: 0 additions & 2 deletions meshpy/abaqus/beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
"""This file provides functions to create Abaqus beam element classes to be
used with MeshPy."""

# Python modules
import numpy as np

# MeshPy modules
from ..element_beam import Beam
from ..material import MaterialBeam

Expand Down
4 changes: 1 addition & 3 deletions meshpy/abaqus/input_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@
"""This module defines the class that is used to create an input file for
Abaqus."""

# Python modules
from enum import Enum, auto

import numpy as np

# MeshPy modules
from ..conf import mpy
from ..geometry_set import GeometrySet
from ..mesh import Mesh
Expand Down Expand Up @@ -215,7 +213,7 @@ def get_nodes_lines(self):
for coupling in self.mesh.boundary_conditions[
mpy.bc.point_coupling, mpy.geo.point
]:
if not coupling.coupling_dof_type is mpy.coupling_dof.fix:
if coupling.coupling_dof_type is not mpy.coupling_dof.fix:
raise ValueError(
"Abaqus coupling is only implemented for rigid joints at the DOFs"
)
Expand Down
3 changes: 0 additions & 3 deletions meshpy/boundary_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@
"""This module implements a class to handle boundary conditions in the input
file."""

# Python modules.
import warnings

from .base_mesh_item import BaseMeshItemFull

# Meshpy modules.
from .conf import mpy
from .geometry_set import GeometrySet
from .utility import find_close_nodes
Expand Down
1 change: 0 additions & 1 deletion meshpy/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"""This module defines a global object that manages all kind of stuff regarding
meshpy."""

# Python imports.
from enum import Enum, auto


Expand Down
5 changes: 1 addition & 4 deletions meshpy/coupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@
# -----------------------------------------------------------------------------
"""This module implements a class to couple geometry together."""

# Python modules.
import numpy as np

from .boundary_condition import BoundaryConditionBase

# Meshpy modules.
from .conf import mpy
from .geometry_set import GeometrySet, GeometrySetBase

Expand Down Expand Up @@ -154,7 +151,7 @@ def _get_dat(self):
beam_four_c_type = type(nodes[0].element_link[0])
for node in nodes:
for element in node.element_link:
if not beam_four_c_type == type(element):
if beam_four_c_type is not type(element):
raise ValueError(
"Coupling beams of different types is not yet possible!"
)
Expand Down
11 changes: 5 additions & 6 deletions meshpy/element_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
# -----------------------------------------------------------------------------
"""This module implements beam elements for the mesh."""

# Python modules.
import warnings
from typing import Any

import numpy as np
import vtk

# Meshpy modules.
from .conf import mpy
from .element import Element
from .material import (
Expand All @@ -57,14 +56,14 @@ class Beam(Element):
# [ xi, is_middle_node ], # fist node
# ...
# ]
nodes_create = []
nodes_create: Any = []

# A list of valid material types for this element.
valid_material = []
valid_material: Any = []

# Coupling strings.
coupling_fix_string = None
coupling_joint_string = None
coupling_fix_string = ""
coupling_joint_string = ""

def __init__(self, material=None, nodes=None):
super().__init__(nodes=nodes, material=material)
Expand Down
6 changes: 3 additions & 3 deletions meshpy/element_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
# -----------------------------------------------------------------------------
"""This module implements volume elements for the mesh."""

# Python modules.
from typing import List, Optional

import numpy as np
import vtk

# Meshpy modules.
from .element import Element
from .vtk_writer import add_point_data_node_sets

Expand All @@ -45,7 +45,7 @@ class VolumeElement(Element):
# This class variables stores the information about the element shape in
# vtk. And the connectivity to the nodes.
vtk_cell_type = None
vtk_topology = None
vtk_topology: list = []

def __init__(self, nodes=None, dat_pre_nodes="", dat_post_nodes="", **kwargs):
super().__init__(nodes=nodes, material=None, **kwargs)
Expand Down
4 changes: 0 additions & 4 deletions meshpy/four_c/beam_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
"""This file includes functions to ease the creation of input files using beam
interaction potentials."""

# Python modules
import numpy as np

# MeshPy modules
from ..boundary_condition import BoundaryCondition
from ..header_functions import get_yes_no
from ..inputfile import InputSection
Expand Down
4 changes: 1 addition & 3 deletions meshpy/four_c/dbc_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
"""This function converts the DBC monitor log files to Neumann input
sections."""

# Python modules.
import numpy as np

# Meshpy stuff.
from .. import BoundaryCondition, GeometrySet, mpy
from meshpy import BoundaryCondition, GeometrySet, mpy


def read_dbc_monitor_file(file_path):
Expand Down
5 changes: 4 additions & 1 deletion meshpy/four_c/solid_shell_thickness_direction.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ def set_solid_shell_thickness_direction(
for element in elements:
is_hex8 = isinstance(element, VolumeHEX8)
if is_hex8:
is_solid_shell = "SOLIDSH8" in element.dat_pre_nodes
is_solid_shell = (
hasattr(element, "dat_pre_nodes")
and "SOLIDSH8" in element.dat_pre_nodes
)
if is_solid_shell:
# Get the element center and the Jacobian at the center
(
Expand Down
2 changes: 0 additions & 2 deletions meshpy/function_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
"""This module implements utility functions to create 4C space time
function."""

# Python modules
import numpy as np

# Meshpy modules
from .function import Function


Expand Down
9 changes: 0 additions & 9 deletions meshpy/geometric_search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,3 @@
# SOFTWARE.
# -----------------------------------------------------------------------------
"""This module defines geometric search functionality."""

# Functions that should be used from the outside
from .find_close_points import (
FindClosePointAlgorithm,
find_close_points,
partner_indices_to_point_partners,
point_partners_to_partner_indices,
point_partners_to_unique_indices,
)
6 changes: 0 additions & 6 deletions meshpy/geometric_search/find_close_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,14 @@
"""Find unique points in a point cloud, i.e., points that are within a certain
tolerance of each other will be considered as unique."""

# Python modules
from enum import Enum, auto

# Cython modules
from .geometric_search_cython import cython_available

# Geometric search modules
# SciPy
from .geometric_search_scipy import find_close_points_scipy

if cython_available:
from .geometric_search_cython import find_close_points_brute_force_cython

# ArborX
from .geometric_search_arborx import arborx_available

if arborx_available:
Expand Down
3 changes: 1 addition & 2 deletions meshpy/geometric_search/geometric_search_arborx.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"""This file defines the interface to the ArborX geometric search
functionality."""

# Python modules
import os
import sys

Expand All @@ -43,7 +42,7 @@
import geometric_search_arborx_lib

arborx_available = True
except:
except ImportError:
arborx_available = False


Expand Down
2 changes: 1 addition & 1 deletion meshpy/geometric_search/geometric_search_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import geometric_search_cython_lib

cython_available = True
except:
except ImportError:
cython_available = False


Expand Down
2 changes: 0 additions & 2 deletions meshpy/geometric_search/geometric_search_cython_lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ It uses cython to gain performance.
"""


# Python imports.
import numpy as np
from libc.math cimport sqrt

# Cython imports.
cimport cython
cimport numpy as np

Expand Down
1 change: 0 additions & 1 deletion meshpy/geometric_search/geometric_search_scipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"""This file defines the interface to the Scipy spatial geometric search
functionality."""

import numpy as np
from scipy.spatial import KDTree


Expand Down
3 changes: 0 additions & 3 deletions meshpy/geometry_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@
"""This module implements a basic class to manage geometry in the input
file."""

# Python modules.
import numpy as np

from .base_mesh_item import BaseMeshItemFull

# Meshpy modules.
from .conf import mpy
from .element_beam import Beam
from .node import Node
Expand Down
1 change: 0 additions & 1 deletion meshpy/header_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"""This module defines functions that can be used to add header information to
an input file."""

# Meshpy imports.
from .conf import mpy
from .inputfile import InputSection

Expand Down
5 changes: 1 addition & 4 deletions meshpy/inputfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@
"""This module defines the classes that are used to create an input file for
4C."""

# Python modules.
import datetime
import os
import re
import sys

from .base_mesh_item import BaseMeshItemFull, BaseMeshItemString
from .boundary_condition import BoundaryConditionBase

# Meshpy modules.
from .conf import mpy
from .container import BoundaryConditionContainer, GeometrySetContainer
from .element import Element
Expand Down Expand Up @@ -203,7 +200,7 @@ def add(self, data, **kwargs):
def _add_data(self, option):
"""Add a InputLine object to the item."""

if (not option.get_key() in self.data.keys()) or option.overwrite:
if (option.get_key() not in self.data.keys()) or option.overwrite:
self.data[option.get_key()] = option
else:
raise KeyError(f"Key {option.get_key()} is already set!")
Expand Down
2 changes: 0 additions & 2 deletions meshpy/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
"""This module implements a basic class to manage materials in the 4C input
file."""

# Python modules.
import numpy as np

# Meshpy modules.
from .base_mesh_item import BaseMeshItemFull


Expand Down
Loading

0 comments on commit 16253c4

Please sign in to comment.