Skip to content

Commit

Permalink
Refactor the repo (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewu63 authored Aug 25, 2021
1 parent 9d07275 commit 40ce163
Show file tree
Hide file tree
Showing 27 changed files with 74 additions and 168 deletions.
47 changes: 22 additions & 25 deletions baseclasses/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
__version__ = "1.5.2"

from .pyAero_problem import AeroProblem
from .pyTransi_problem import TransiProblem
from .pyStruct_problem import StructProblem
from .pyAeroStruct_problem import AeroStructProblem

from .pyAero_solver import AeroSolver
from .BaseSolver import BaseSolver

from .pyMission_problem import MissionProblem
from .pyMission_problem import MissionProfile
from .pyMission_problem import MissionSegment

from .pyWeight_problem import WeightProblem
from .pyWeight_problem import FuelCase

from .FluidProperties import FluidProperties
from .ICAOAtmosphere import ICAOAtmosphere
from .pyEngine_problem import EngineProblem

from .pyFieldPerformance_problem import FieldPerformanceProblem

from .pyLG_problem import LGProblem

from .py3Util import getPy3SafeString
from .BaseRegTest import BaseRegTest
from .problems import (
AeroProblem,
TransiProblem,
StructProblem,
AeroStructProblem,
MissionProblem,
MissionProfile,
MissionSegment,
WeightProblem,
FuelCase,
FluidProperties,
ICAOAtmosphere,
EngineProblem,
FieldPerformanceProblem,
LGProblem,
)

from .solvers import BaseSolver, AeroSolver

from .utils import getPy3SafeString

from .testing import BaseRegTest, getTol
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions baseclasses/problems/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from .pyAero_problem import AeroProblem
from .pyTransi_problem import TransiProblem
from .pyStruct_problem import StructProblem
from .pyAeroStruct_problem import AeroStructProblem
from .pyMission_problem import MissionProblem, MissionProfile, MissionSegment
from .pyWeight_problem import WeightProblem, FuelCase
from .FluidProperties import FluidProperties
from .ICAOAtmosphere import ICAOAtmosphere
from .pyEngine_problem import EngineProblem
from .pyFieldPerformance_problem import FieldPerformanceProblem
from .pyLG_problem import LGProblem
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# ======================================================================
from .pyAero_problem import AeroProblem
from .pyStruct_problem import StructProblem
from .utils import Error
from ..utils import Error


class AeroStructProblem:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import warnings
from .ICAOAtmosphere import ICAOAtmosphere
from .FluidProperties import FluidProperties
from .utils import CaseInsensitiveDict, Error
from ..utils import CaseInsensitiveDict, Error


class AeroProblem(FluidProperties):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# =============================================================================
# Imports
# =============================================================================
from baseclasses import AeroProblem
from .pyAero_problem import AeroProblem


class EngineProblem(AeroProblem):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import warnings
from .ICAOAtmosphere import ICAOAtmosphere
from .FluidProperties import FluidProperties
from .utils import CaseInsensitiveDict, Error
from ..utils import CaseInsensitiveDict, Error


class FieldPerformanceProblem:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from .ICAOAtmosphere import ICAOAtmosphere
from .FluidProperties import FluidProperties
from .utils import Error
from ..utils import Error


class MissionProblem:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Imports
# =============================================================================
import warnings
from .utils import Error
from ..utils import Error


class StructProblem:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pyAero_problem
"""
from .utils import Error
from ..utils import Error


class TransiProblem:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pygeo import geo_utils
except ImportError:
geo_utils = None
from .utils import Error
from ..utils import Error


class WeightProblem:
Expand Down
107 changes: 0 additions & 107 deletions baseclasses/pyAero_geometry.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pprint import pprint
import copy
import warnings
from .utils import CaseInsensitiveDict, CaseInsensitiveSet, Error
from ..utils import CaseInsensitiveDict, CaseInsensitiveSet, Error

# =============================================================================
# BaseSolver Class
Expand Down
2 changes: 2 additions & 0 deletions baseclasses/solvers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .BaseSolver import BaseSolver
from .pyAero_solver import AeroSolver
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Extension modules
# =============================================================================
from .BaseSolver import BaseSolver
from .utils import CaseInsensitiveDict, Error
from ..utils import CaseInsensitiveDict, Error

# =============================================================================
# AeroSolver Class
Expand Down
2 changes: 2 additions & 0 deletions baseclasses/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .pyRegTest import BaseRegTest, getTol
from .decorators import require_mpi
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import json
from collections import deque
from contextlib import contextmanager
from .utils import CaseInsensitiveDict, CaseInsensitiveSet, Error
from ..utils import CaseInsensitiveDict, CaseInsensitiveSet, Error


def getTol(**kwargs):
Expand Down
3 changes: 3 additions & 0 deletions baseclasses/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .containers import CaseInsensitiveSet, CaseInsensitiveDict
from .error import Error
from .py3Util import getPy3SafeString
21 changes: 0 additions & 21 deletions baseclasses/utils.py → baseclasses/utils/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,3 @@ def issubset(self, other) -> bool:

def __repr__(self):
return pformat(self.data)


class Error(Exception):
"""
Format the error message in a box to make it clear this
was a explicitly raised exception.
"""

def __init__(self, message):
self.message = message
msg = "\n+" + "-" * 78 + "+" + "\n" + "| Error: "
i = 8
for word in message.split():
if len(word) + i + 1 > 78: # Finish line and start new one
msg += " " * (78 - i) + "|\n| " + word + " "
i = 1 + len(word) + 1
else:
msg += word + " "
i += len(word) + 1
msg += " " * (78 - i) + "|\n" + "+" + "-" * 78 + "+" + "\n"
super().__init__(msg)
19 changes: 19 additions & 0 deletions baseclasses/utils/error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Error(Exception):
"""
Format the error message in a box to make it clear this
was a explicitly raised exception.
"""

def __init__(self, message):
self.message = message
msg = "\n+" + "-" * 78 + "+" + "\n" + "| Error: "
i = 8
for word in message.split():
if len(word) + i + 1 > 78: # Finish line and start new one
msg += " " * (78 - i) + "|\n| " + word + " "
i = 1 + len(word) + 1
else:
msg += word + " "
i += len(word) + 1
msg += " " * (78 - i) + "|\n" + "+" + "-" * 78 + "+" + "\n"
super().__init__(msg)
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/test_BaseRegTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import unittest
import numpy as np
from baseclasses import BaseRegTest
from baseclasses.BaseRegTest import getTol
from baseclasses.decorators import require_mpi
from baseclasses.testing import getTol
from baseclasses.testing.decorators import require_mpi
from baseclasses.utils import CaseInsensitiveDict

try:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_BaseSolver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from baseclasses import BaseSolver
from baseclasses.utils import Error
from baseclasses.decorators import require_mpi
from baseclasses.testing.decorators import require_mpi


class SOLVER(BaseSolver):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_CaseInsensitve.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pprint import pformat
from baseclasses.utils import CaseInsensitiveDict, CaseInsensitiveSet
from parameterized import parameterized
from baseclasses.decorators import require_mpi
from baseclasses.testing.decorators import require_mpi

value1 = 123
value2 = 321
Expand Down

0 comments on commit 40ce163

Please sign in to comment.