Skip to content

Commit

Permalink
PEP8 Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rpakishore committed Sep 12, 2024
1 parent 57d57f9 commit 8a23c03
Show file tree
Hide file tree
Showing 44 changed files with 928 additions and 697 deletions.
2 changes: 1 addition & 1 deletion src/ak_sap/Analyze/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .main import Analyze
from .main import Analyze
87 changes: 44 additions & 43 deletions src/ak_sap/Analyze/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,34 @@
from ak_sap.utils import MasterClass, log
from ak_sap.utils.decorators import smooth_sap_do


class Analyze(MasterClass):
def __init__(self, mySapObject) -> None:
super().__init__(mySapObject=mySapObject)
self.__Analyze = mySapObject.SapModel.Analyze

@smooth_sap_do
def create_model(self) -> bool:
"""creates the analysis model.
"""creates the analysis model.
If the analysis model is already created and current, nothing is done.
"""
return self.__Analyze.CreateAnalyzeModel()

@smooth_sap_do
def run(self):
"""runs the analysis.
"""runs the analysis.
The analysis model is automatically created as part of this function.
"""
return self.__Analyze.RunAnalysis()

@smooth_sap_do
def case_status(self) -> dict:
"""retrieves the status for all load cases.
Returns:
list[dict]: Cases and their current status.
"""
return case_status(ret=self.__Analyze.GetCaseStatus()), 0 # type: ignore
return case_status(ret=self.__Analyze.GetCaseStatus()), 0 # type: ignore

@smooth_sap_do
def get_run_flag(self) -> dict:
Expand All @@ -38,7 +39,7 @@ def get_run_flag(self) -> dict:
Returns:
dict: Loadcases and their run flags
"""
return get_run_flag(ret=self.__Analyze.GetRunCaseFlag()), 0 # type: ignore
return get_run_flag(ret=self.__Analyze.GetRunCaseFlag()), 0 # type: ignore

@smooth_sap_do
def set_run_flag(self, case: str, status: bool):
Expand All @@ -49,23 +50,24 @@ def set_run_flag(self, case: str, status: bool):
status (bool): If this item is True, the specified load case is to be run
"""
return self.__Analyze.SetRunCaseFlag(case, status)

@smooth_sap_do
def get_solver(self) -> dict:
"""retrieves the model solver options
Returns:
dict: Solver Info
"""
return get_solver(ret = self.__Analyze.GetSolverOption_3()), 0 # type: ignore
return get_solver(ret=self.__Analyze.GetSolverOption_3()), 0 # type: ignore

@smooth_sap_do
def set_solver(self,
SolverType: Literal['Standard', 'Advanced', 'Multi-threaded'],
SolverProcessType: Literal['Auto', 'GUI', 'Separate'],
NumberParallelRuns: Literal[0,1,2,3,4,5,6,7,8],
StiffCase: str = ''
) -> bool:
def set_solver(
self,
SolverType: Literal["Standard", "Advanced", "Multi-threaded"],
SolverProcessType: Literal["Auto", "GUI", "Separate"],
NumberParallelRuns: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8],
StiffCase: str = "",
) -> bool:
"""sets the model solver options
Args:
Expand All @@ -75,49 +77,48 @@ def set_solver(self,
StiffCase (str, optional): name of the load case used when outputting the mass and stiffness matrices to text files. Defaults to ''.
"""
return self.__Analyze.SetSolverOption_3(
['Standard', 'Advanced', 'Multi-threaded'].index(SolverType),
['Auto', 'GUI', 'Separate'].index(SolverProcessType),
["Standard", "Advanced", "Multi-threaded"].index(SolverType),
["Auto", "GUI", "Separate"].index(SolverProcessType),
NumberParallelRuns,
0,0,
StiffCase
0,
0,
StiffCase,
)


def get_solver(ret: list) -> dict:
assert ret[-1] == 0
return {
'SolverType': ['Standard', 'Advanced', 'Multi-threaded'][ret[0]],
'SolverProcessType': ['Auto', 'GUI', 'Separate'][ret[1]],
'NumberParallelRuns': abs(ret[2]),
'StiffCase': ret[5]
"SolverType": ["Standard", "Advanced", "Multi-threaded"][ret[0]],
"SolverProcessType": ["Auto", "GUI", "Separate"][ret[1]],
"NumberParallelRuns": abs(ret[2]),
"StiffCase": ret[5],
}

def get_run_flag(ret: list)->dict:

def get_run_flag(ret: list) -> dict:
assert ret[-1] == 0
status: dict = {}

if ret[0] == 1:
#If cases is not a iterable
# If cases is not a iterable
return {ret[1]: ret[2]}
#Else if cases are iterables

# Else if cases are iterables
for _case, _status in zip(list(ret[1]), list(ret[2])):
status[_case] = _status
status[_case] = _status
return status

def case_status(ret: list)->dict:

def case_status(ret: list) -> dict:
assert ret[-1] == 0
status: dict = {}
_status_exp = [
'Not run',
'Could not start',
'Not finished',
'Finished'
]
_status_exp = ["Not run", "Could not start", "Not finished", "Finished"]
if ret[0] == 1:
#If cases is not a iterable
return {ret[1]: _status_exp[ret[2]-1]}
#Else if cases are iterables
# If cases is not a iterable
return {ret[1]: _status_exp[ret[2] - 1]}

# Else if cases are iterables
for _case, _status in zip(list(ret[1]), list(ret[2])):
status[_case] = _status_exp[_status-1]
return status
status[_case] = _status_exp[_status - 1]
return status
2 changes: 1 addition & 1 deletion src/ak_sap/Database/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .tables import Table
from .tables import Table
10 changes: 6 additions & 4 deletions src/ak_sap/Database/table_constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Literal

ImportType_Literals = Literal['not importable',
'importable, but not interactively importable',
'importable and interactive importable when he model is unlocked',
'importable and interactive importable when he model is unlocked and locked',]
ImportType_Literals = Literal[
"not importable",
"importable, but not interactively importable",
"importable and interactive importable when he model is unlocked",
"importable and interactive importable when he model is unlocked and locked",
]
7 changes: 5 additions & 2 deletions src/ak_sap/Database/table_structured_data.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
from dataclasses import dataclass

from .table_constants import ImportType_Literals


@dataclass
class DatabaseTable:
TableKey: str
TableName: str
ImportType: ImportType_Literals
IsEmpty: bool



@dataclass
class FieldData:
FieldKey: str
FieldName: str
Description: str
UnitsStr: str
isImportable: bool
isImportable: bool
Loading

0 comments on commit 8a23c03

Please sign in to comment.