Skip to content

Commit

Permalink
style: ruff style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlangrose committed Feb 8, 2024
1 parent 48e6261 commit 54aafd1
Show file tree
Hide file tree
Showing 92 changed files with 47 additions and 243 deletions.
6 changes: 1 addition & 5 deletions LoopStructural/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
"""

import logging
from logging.config import dictConfig

__all__ = ["GeologicalModel"]
import tempfile
from pathlib import Path
from .version import __version__

experimental = False
ch = logging.StreamHandler()
Expand All @@ -19,7 +15,7 @@
ch.setLevel(logging.WARNING)
loggers = {}
from .modelling.core.geological_model import GeologicalModel
from .utils import log_to_console, log_to_file, getLogger
from .utils import getLogger

logger = getLogger(__name__)
logger.info("Imported LoopStructural")
3 changes: 0 additions & 3 deletions LoopStructural/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@
logger = getLogger(__name__)
if LoopStructural.experimental:
logger.warning("LoopStructural.analysis is experimental and may not perform as expected")
from ._fault_displacement import displacement_missfit
from ._fault_intersection import calculate_fault_intersections
from ._topology import calculate_fault_topology_matrix
2 changes: 0 additions & 2 deletions LoopStructural/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from ._interpolate import LoopInterpolator
from ._surface import LoopIsosurfacer
2 changes: 0 additions & 2 deletions LoopStructural/api/_interpolate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from ast import LShift
import numpy as np
import pandas as pd

from typing import Optional
from LoopStructural.interpolators import (
Expand Down
16 changes: 0 additions & 16 deletions LoopStructural/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,3 @@
Various datasets used for documentation and tutorials.
"""
from ._base import load_claudius
from ._base import load_grose2017
from ._base import load_grose2018
from ._base import load_grose2019
from ._base import load_laurent2016
from ._base import load_noddy_single_fold
from ._base import load_intrusion
from ._base import normal_vector_headers
from ._base import strike_dip_headers
from ._base import value_headers
from ._base import load_unconformity
from ._base import load_duplex
from ._base import load_tabular_intrusion
from ._base import load_geological_map_data
from ._base import load_fault_trace
from ._base import load_horizontal
4 changes: 1 addition & 3 deletions LoopStructural/datasets/_example_models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from _base import load_claudius
from .. import GeologicalModel

vis = True
try:
from LoopStructural.visualisation import LavaVuModelViewer
pass
except:
print("No visualisation")
vis = False
Expand Down
2 changes: 0 additions & 2 deletions LoopStructural/datatypes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from ._surface import Surface
from ._bounding_box import BoundingBox
8 changes: 3 additions & 5 deletions LoopStructural/datatypes/_bounding_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def nelements(self):

@property
def volume(self):
return np.product(self.maximum - self.origin)
return np.prod(self.maximum - self.origin)

@property
def bb(self):
Expand Down Expand Up @@ -159,9 +159,7 @@ def get_value(self, name):
if iy == -1:
return self.origin[ix]

return self.bb[
ix,
]
return self.bb[ix,]

def __getitem__(self, name):
if isinstance(name, str):
Expand Down Expand Up @@ -199,5 +197,5 @@ def regular_grid(self, nsteps=None, shuffle=False, order="C"):
).T
if shuffle:
# logger.info("Shuffling points")
np.random.shuffle(locs)
np.random.Generator.shuffle(locs)
return locs
2 changes: 1 addition & 1 deletion LoopStructural/datatypes/_surface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Optional, Union
from typing import Optional
import numpy as np


Expand Down
1 change: 0 additions & 1 deletion LoopStructural/export/exporters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Routines to export geological model data to file in a variety of formats
"""
import logging
import os
from types import SimpleNamespace
from pyevtk.hl import unstructuredGridToVTK, pointsToVTK
Expand Down
2 changes: 0 additions & 2 deletions LoopStructural/interpolators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class InterpolatorType(IntEnum):
logger.warning('Can\'t import surfepy - to install "pip install surfe"')

from ._p1interpolator import P1Interpolator
from ._p2interpolator import P2Interpolator

interpolator_map = {
InterpolatorType.BASE: GeologicalInterpolator,
Expand All @@ -105,4 +104,3 @@ class InterpolatorType(IntEnum):
}


from ._interpolator_factory import InterpolatorFactory
4 changes: 1 addition & 3 deletions LoopStructural/interpolators/_builders.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from LoopStructural.utils.exceptions import LoopException
import numpy as np
from typing import Optional, Union
from typing import Optional
from LoopStructural.interpolators import (
PiecewiseLinearInterpolator,
P1Interpolator,
P2Interpolator,
FiniteDifferenceInterpolator,
GeologicalInterpolator,
DiscreteInterpolator,
DiscreteFoldInterpolator,
StructuredGrid,
TetMesh,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Piecewise linear interpolator using folds
"""
import logging
from typing import Optional

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion LoopStructural/interpolators/_discrete_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

logger = getLogger(__name__)

from ._geological_interpolator import GeologicalInterpolator


class DiscreteInterpolator(GeologicalInterpolator):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
FiniteDifference interpolator
"""
import logging

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion LoopStructural/interpolators/_geological_interpolator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Base geological interpolator
"""
from abc import ABC, ABCMeta, abstractmethod
from abc import ABCMeta, abstractmethod
from LoopStructural.utils.exceptions import LoopTypeError
from ..interpolators import InterpolatorType
import numpy as np
Expand Down
4 changes: 1 addition & 3 deletions LoopStructural/interpolators/_interpolator_factory.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from typing import Optional, Union
from .supports import support_map, SupportFactory
from .supports import SupportFactory
from . import (
interpolator_map,
InterpolatorType,
support_interpolator_map,
interpolator_string_map,
)
from LoopStructural.utils import BoundingBox
from typing import Optional
import numpy as np

from ..interpolators.supports import SupportFactory


class InterpolatorFactory:
Expand Down
Empty file.
1 change: 0 additions & 1 deletion LoopStructural/interpolators/_operator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Finite difference masks
"""
import logging

import numpy as np

Expand Down
1 change: 0 additions & 1 deletion LoopStructural/interpolators/_p1interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import numpy as np

from ._discrete_interpolator import DiscreteInterpolator
from ..utils import get_vectors

logger = logging.getLogger(__name__)

Expand Down
1 change: 0 additions & 1 deletion LoopStructural/interpolators/_p2interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import numpy as np

from ..interpolators import DiscreteInterpolator
from ..utils import get_vectors

logger = logging.getLogger(__name__)

Expand Down
2 changes: 0 additions & 2 deletions LoopStructural/interpolators/_surfe_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""
Wrapper for using surfepy
"""
import sys, os

from ..utils.helper import get_vectors
from ..interpolators import GeologicalInterpolator

import logging
import numpy as np

from ..utils import getLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Tetmesh based on cartesian grid for piecewise linear interpolation
"""
import logging
from re import S

import numpy as np
from ._2d_base_unstructured import BaseUnstructured2d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import logging

import numpy as np

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

from ast import Tuple
import logging

import numpy as np
from scipy.sparse import csr_matrix, coo_matrix, tril
Expand Down
1 change: 0 additions & 1 deletion LoopStructural/interpolators/supports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class SupportType(IntEnum):
SupportType.P2UnstructuredTetMesh: P2UnstructuredTetMesh,
}

from ._support_factory import SupportFactory

__all__ = [
"BaseUnstructured2d",
Expand Down
4 changes: 2 additions & 2 deletions LoopStructural/modelling/core/geological_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
all_heading,
gradient_vec_names,
)
from ...utils import strikedip2vector, get_vectors
from ...utils import strikedip2vector
from ...utils import BoundingBox

from ...modelling.intrusions import IntrusionBuilder
Expand Down Expand Up @@ -1172,7 +1172,7 @@ def add_unconformity(self, feature: GeologicalFeature, value: float) -> Unconfor
"""
logger.debug(f"Adding {feature.name} as unconformity at {value}")
if feature is None:
logger.warning(f"Cannot add unconformtiy, base feature is None")
logger.warning("Cannot add unconformtiy, base feature is None")
return
# look backwards through features and add the unconformity as a region until
# we get to an unconformity
Expand Down
9 changes: 0 additions & 9 deletions LoopStructural/modelling/features/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from enum import IntEnum
from ...utils import getLogger


class FeatureType(IntEnum):
Expand All @@ -24,14 +23,6 @@ class FeatureType(IntEnum):
INACTIVEFAULT = 11


from ._base_geological_feature import BaseFeature
from ._geological_feature import GeologicalFeature
from ._lambda_geological_feature import LambdaGeologicalFeature

# from .builders._geological_feature_builder import GeologicalFeatureBuilder
from ._structural_frame import StructuralFrame
from ._cross_product_geological_feature import CrossProductGeologicalFeature

from ._unconformity_feature import UnconformityFeature
from ._analytical_feature import AnalyticalGeologicalFeature
from ._structural_frame import StructuralFrame
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

# from LoopStructural import GeologicalModel
import numpy as np
from uuid import uuid4

logger = getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""
"""
import logging

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion LoopStructural/modelling/features/_geological_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ...interpolators import GeologicalInterpolator
import numpy as np

from ...utils import getLogger, LoopValueError, rotate
from ...utils import LoopValueError, rotate

logger = getLogger(__name__)

Expand Down
1 change: 0 additions & 1 deletion LoopStructural/modelling/features/_structural_frame.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Structural frames
"""
import logging
from ..features import BaseFeature
import numpy as np
from ...utils import getLogger
Expand Down
5 changes: 0 additions & 5 deletions LoopStructural/modelling/features/builders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
from ._base_builder import BaseBuilder
from ._geological_feature_builder import GeologicalFeatureBuilder
from ._folded_feature_builder import FoldedFeatureBuilder
from ._structural_frame_builder import StructuralFrameBuilder
from ._fault_builder import FaultBuilder
8 changes: 4 additions & 4 deletions LoopStructural/modelling/features/builders/_fault_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def create_data_from_geometry(
logger.error(
"You cannot model a fault without defining the location of the fault"
)
raise ValueError(f"There are no points on the fault trace")
raise ValueError("There are no points on the fault trace")

# get all of the gradient data associated with the fault trace
if fault_normal_vector is None:
Expand Down Expand Up @@ -255,19 +255,19 @@ def create_data_from_geometry(
fault_frame_data.reset_index(inplace=True)
if not self.fault_major_axis:
logger.warning(
f"Fault major axis is not set and cannot be determined from the fault trace. \
"Fault major axis is not set and cannot be determined from the fault trace. \
This will result in a fault that is represented by a 1 unit major axis. \
If this is not intended add major_axis to fault parameters."
)
if not self.fault_intermediate_axis:
logger.warning(
f"Fault intermediate axis is not set and cannot be determined from the fault trace. \
"Fault intermediate axis is not set and cannot be determined from the fault trace. \
This will result in a fault that is represented by a 1 unit intermediate axis. \
If this is not intended add intermediate_axis to fault parameters."
)
if not self.fault_minor_axis:
logger.warning(
f"Fault minor axis is not set and cannot be determined from the fault trace. \
"Fault minor axis is not set and cannot be determined from the fault trace. \
This will result in a fault that is represented by a 1 unit minor axis. \
If this is not intended add minor_axis to fault parameters."
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Union
from ....modelling.features.builders import GeologicalFeatureBuilder
from ....modelling.features.fold import FoldRotationAngle
import numpy as np
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from typing import Union

import logging
from LoopStructural.utils.exceptions import LoopException

import numpy as np
Expand Down
3 changes: 0 additions & 3 deletions LoopStructural/modelling/features/fault/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from ._fault_function import Composite, CubicFunction, Ones, Zeros
from ._fault_function_feature import FaultDisplacementFeature
from ._fault_segment import FaultSegment
1 change: 0 additions & 1 deletion LoopStructural/modelling/features/fault/_fault_function.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging

import numpy as np

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging
from ....modelling.features import BaseFeature, StructuralFrame

from ....utils import getLogger
Expand Down
Loading

0 comments on commit 54aafd1

Please sign in to comment.