Skip to content

Commit

Permalink
bugfix & Linting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rpakishore committed Apr 5, 2024
1 parent b24819e commit f3ff984
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/ak_sap/Analyze/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def case_status(self) -> dict:
Returns:
list[dict]: Cases and their current status.
"""
return case_status(ret=self.__Analyze.GetCaseStatus()), 0
return case_status(ret=self.__Analyze.GetCaseStatus()), 0 # type: ignore

@smooth_sap_do
def get_run_flag(self) -> dict:
Expand All @@ -38,7 +38,7 @@ def get_run_flag(self) -> dict:
Returns:
dict: Loadcases and their run flags
"""
return get_run_flag(ret=self.__Analyze.GetRunCaseFlag()), 0
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 @@ -57,7 +57,7 @@ def get_solver(self) -> dict:
Returns:
dict: Solver Info
"""
return get_solver(ret = self.__Analyze.GetSolverOption_3()), 0
return get_solver(ret = self.__Analyze.GetSolverOption_3()), 0 # type: ignore

@smooth_sap_do
def set_solver(self,
Expand Down
1 change: 1 addition & 0 deletions src/ak_sap/Loads/Modal/Eigen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class Eigen(MasterClass):
def __init__(self, mySapObject) -> None:
super().__init__(mySapObject=mySapObject)
assert self.SapModel is not None
self.ModalEigen = self.SapModel.LoadCases.ModalEigen

def __str__(self) -> str:
Expand Down
1 change: 1 addition & 0 deletions src/ak_sap/Loads/Modal/Ritz/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class Ritz(MasterClass):
def __init__(self, mySapObject) -> None:
super().__init__(mySapObject=mySapObject)
assert self.SapModel is not None
self.ModalRitz = self.SapModel.LoadCases.ModalRitz

def __str__(self) -> str:
Expand Down
5 changes: 3 additions & 2 deletions src/ak_sap/Object/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ def __init__(self, mySapObject) -> None:

self.__EditFrame = mySapObject.SapModel.EditFrame
self.__EditGeneral = mySapObject.SapModel.EditGeneral
self.__FrameObj = mySapObject.SapModel.FrameObj

self.Prop = Prop(mySapObject=mySapObject)

@smooth_sap_do
def get_section(self, name: str) -> str:
self.check_obj_legal(name=name)
_ret = self.ElemObj.GetSection(name)
_ret = self.__FrameObj.GetSection(name)
return (_ret[0], _ret[-1]) # type: ignore

@smooth_sap_do
def get_points(self, name: str) -> tuple[str]:
"""retrieves the names of the point objects at each end of a specified frame object."""
#self.check_obj_legal(name=name)
return self.ElemObj.GetPoints(name)
return self.__FrameObj.GetPoints(name)

@smooth_sap_do
def divide_by_distance(self, name: str, dist: float, Iend: bool=True) -> tuple[str]:
Expand Down
2 changes: 1 addition & 1 deletion src/ak_sap/Object/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def move_selected(self, dx: float, dy: float, dz: float) -> bool:
dy (float): y offsets
dz (float): z offsets
"""
self.__EditGeneral.Move(dx, dy, dz)
return self.__EditGeneral.Move(dx, dy, dz)

@smooth_sap_do
def copy(self, dx: float, dy: float, dz: float, num: int) -> tuple:
Expand Down
2 changes: 1 addition & 1 deletion src/ak_sap/Object/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def add_by_coord(self, point: tuple[float, float, float], name: str='', coord_sy
name (str, optional): Custom name for point. Defaults to ''.
coord_sys (str, optional): Name of coordinate system. Defaults to 'Global'.
"""
return self.ElemObj.AddCartesian(*point, '', name, coord_sys)
return self.__PointObj.AddCartesian(*point, '', name, coord_sys)

@smooth_sap_do
def align(self, axis: Literal['X', 'Y', 'Z'], ordinate: float) -> tuple:
Expand Down
10 changes: 5 additions & 5 deletions src/ak_sap/Results/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def delete(self, casename: str|Literal['All']) -> bool:
Args:
casename (str | Literal['All']): name of an existing load case that is to have its results deleted.
"""
return self.mySapObject.SapModel.Analyze.DeleteResykts(casename, casename.casefold() == 'all')
return self.mySapObject.SapModel.Analyze.DeleteResykts(casename, casename.casefold() == 'all') # type: ignore

@smooth_sap_do
def joint_reactions(self, jointname:str) -> list[dict]:
Expand All @@ -27,7 +27,7 @@ def joint_reactions(self, jointname:str) -> list[dict]:
Args:
jointname (str): name of an existing point object
"""
return joint_reactions_parse(ret=self.__Results.JointReact(jointname, 1)), 0
return joint_reactions_parse(ret=self.__Results.JointReact(jointname, 1)), 0 # type: ignore


@smooth_sap_do
Expand All @@ -37,7 +37,7 @@ def joint_displacements(self, jointname:str) -> list[dict]:
Args:
jointname (str): name of an existing point object
"""
return joint_displacements_parse(ret=self.__Results.JointDispl(jointname, 1)), 0
return joint_displacements_parse(ret=self.__Results.JointDispl(jointname, 1)), 0 # type: ignore

@smooth_sap_do
def joint_accelerations(self, jointname:str) -> list[dict]:
Expand All @@ -46,7 +46,7 @@ def joint_accelerations(self, jointname:str) -> list[dict]:
Args:
jointname (str): name of an existing point object
"""
return joint_displacements_parse(ret=self.__Results.JointAcc(jointname, 1)), 0
return joint_displacements_parse(ret=self.__Results.JointAcc(jointname, 1)), 0 # type: ignore

@smooth_sap_do
def joint_velocities(self, jointname:str, format: Literal['Pandas', 'List']= 'List') -> list[dict]:
Expand All @@ -55,7 +55,7 @@ def joint_velocities(self, jointname:str, format: Literal['Pandas', 'List']= 'Li
Args:
jointname (str): name of an existing point object
"""
return joint_displacements_parse(ret=self.__Results.JointVel(jointname, 1)), 0
return joint_displacements_parse(ret=self.__Results.JointVel(jointname, 1)), 0 # type: ignore

def joint_displacements_parse(ret: list) -> list[dict]:
assert ret[-1] == 0
Expand Down
2 changes: 1 addition & 1 deletion src/ak_sap/Select/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def constraint(self, name: str, reverse: bool=False) -> bool:

@property
def selected(self) -> list[dict]:
return selected_parse(ret=self.__SelectObj.GetSelected()), 0
return selected_parse(ret=self.__SelectObj.GetSelected()), 0 # type: ignore

@smooth_sap_do
def in_plane(self, pointname: str, plane: Literal['XY', 'YZ', 'XZ'], reverse: bool=False) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion src/ak_sap/misc/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class Coord:
y: float
z: float

def as_tuple(self) -> tuple[float]:
def as_tuple(self) -> tuple[float, float, float]:
return (self.x, self.y, self.z)
6 changes: 3 additions & 3 deletions src/ak_sap/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ def info(self, msg):

def warning(self, msg):
try:
suffix = f'Warning in {Path(inspect.stack()[1].filename).name} -> {inspect.currentframe().f_back.f_code.co_name}: '
suffix = f'Warning in {Path(inspect.stack()[1].filename).name} -> {inspect.currentframe().f_back.f_code.co_name}: ' # type: ignore
except Exception:
suffix = f'Warning in {Path(inspect.stack()[1].filename).name}: '
self.logger.warning(suffix + msg)

def error(self, msg):
try:
suffix = f'Error in {Path(inspect.stack()[1].filename).name} -> {inspect.currentframe().f_back.f_code.co_name}: '
suffix = f'Error in {Path(inspect.stack()[1].filename).name} -> {inspect.currentframe().f_back.f_code.co_name}: ' # type: ignore
except Exception:
suffix = f'Error in {Path(inspect.stack()[1].filename).name}: '
self.logger.error(suffix + str(msg))
self.logger.exception(msg)

def critical(self, msg):
try:
suffix = f'Critical in {Path(inspect.stack()[1].filename).name} -> {inspect.currentframe().f_back.f_code.co_name}: '
suffix = f'Critical in {Path(inspect.stack()[1].filename).name} -> {inspect.currentframe().f_back.f_code.co_name}: ' # type: ignore
except Exception:
suffix = f'Error in {Path(inspect.stack()[1].filename).name}: '
self.logger.critical(suffix + str(msg))
Expand Down

0 comments on commit f3ff984

Please sign in to comment.