Skip to content

Commit

Permalink
Avoid doubled underscore in method names (#181)
Browse files Browse the repository at this point in the history
* renamed functions with __

* removed random commit

* Revert "removed random commit"

This reverts commit f35b217.
  • Loading branch information
shimwell authored and psauvan committed Jun 17, 2024
1 parent 855c96b commit e9adc26
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 159 deletions.
16 changes: 8 additions & 8 deletions src/geouned/GEOUNED/utils/geometry_gu.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ def __init__(self, solid, tolerances, plane3Pts=False):
toroidIndex.append(i)

if len(toroidIndex) != 0:
tFaces = self.__same_torus_surf__(toroidIndex)
tFaces = self.same_torus_surf(toroidIndex)
for i, tSet in enumerate(tFaces):
URange = self.__merge_periodic_uv__("U", tSet)
VRange = self.__merge_periodic_uv__("V", tSet)
URange = self.merge_periodic_uv("U", tSet)
VRange = self.merge_periodic_uv("V", tSet)
for t in tSet:
self.TorusVParams[t] = (i, VRange)
self.TorusUParams[t] = (i, URange)

def __same_torus_surf__(self, torusList):
def same_torus_surf(self, torusList):
"""group as a single face all the neighbour faces of the same torus"""
sameTorusFace = []
temp = torusList[:]
Expand All @@ -145,9 +145,9 @@ def __same_torus_surf__(self, torusList):
temp.remove(c)
sameTorusFace.append(current)

return self.__separate_surfaces__(sameTorusFace)
return self.separate_surfaces(sameTorusFace)

def __separate_surfaces__(self, faceList):
def separate_surfaces(self, faceList):
"""group all faces in faceList forming a continuous surface"""
sameSurfaces = []
for tset in faceList:
Expand All @@ -171,7 +171,7 @@ def __separate_surfaces__(self, faceList):
return sameSurfaces

# TODO check if this function is used as it appears to be nut used in the code
def __merge_no_periodic_uv__(self, parameter, faceList):
def merge_no_periodic_uv(self, parameter, faceList):
if parameter == "U":
i1 = 0
i2 = 2
Expand All @@ -188,7 +188,7 @@ def __merge_no_periodic_uv__(self, parameter, faceList):

return mergedParams

def __merge_periodic_uv__(self, parameter, faceList):
def merge_periodic_uv(self, parameter, faceList):
two_pi = 2.0 * math.pi
if parameter == "U":
i1 = 0
Expand Down
10 changes: 5 additions & 5 deletions src/geouned/GEOUNED/void/void_box_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def __init__(self, MetaSolids, Enclosure):
continue
if m.BoundBox.isValid():
if self.BoundBox.intersect(m.BoundBox):
Obj = self.__copy_meta__(m)
self.__remove_extra_comp__(Obj, self.BoundBox)
Obj = self.copy_meta(m)
self.remove_extra_comp(Obj, self.BoundBox)
self.Objects.append(Obj)
return

Expand Down Expand Up @@ -161,7 +161,7 @@ def refine(self):
)

for m in self.Objects:
self.__remove_extra_comp__(m, Cube, mode="dist")
self.remove_extra_comp(m, Cube, mode="dist")
return

def get_void_complementary(self, Surfaces, options, tolerances, numeric_format, simplify="no"):
Expand Down Expand Up @@ -450,7 +450,7 @@ def get_bound_planes(self):

return (PXMin, PXMax, PYMin, PYMax, PZMin, PZMax)

def __remove_extra_comp__(self, Obj, Box, mode="box"):
def remove_extra_comp(self, Obj, Box, mode="box"):
reducedSol = []
reducedDef = BoolSequence(operator="OR")
if not Obj.Solids:
Expand All @@ -476,7 +476,7 @@ def __remove_extra_comp__(self, Obj, Box, mode="box"):
Obj.set_definition(reducedDef)
return

def __copy_meta__(self, m):
def copy_meta(self, m):
solidsCopy = m.Solids[:]
facesCopy = m.Faces[:]
Meta = GeounedSolid(m.__id__, solidsCopy)
Expand Down
66 changes: 33 additions & 33 deletions src/geouned/GEOUNED/write/mcnp_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def __init__(
if isinstance(self.StepFile, (tuple, list)):
self.StepFile = "; ".join(self.StepFile)

self.__get_surface_table__()
self.__simplify_planes__(Surfaces)
self.get_surface_table()
self.simplify_planes(Surfaces)

self.Surfaces = self.__sorted_surfaces__(Surfaces)
self.Surfaces = self.sorted_surfaces(Surfaces)
self.Materials = set()

return
Expand Down Expand Up @@ -87,8 +87,8 @@ def write_input(self, filename):
Path(filename).parent.mkdir(parents=True, exist_ok=True)
logger.info(f"write MCNP file {filename}")
self.inpfile = open(filename, "w", encoding="utf-8")
self.__write_header__()
self.__write_cell_block__()
self.write_header()
self.write_cell_block()
self.inpfile.write(" \n")

surfaceHeader = """\
Expand All @@ -97,15 +97,15 @@ def write_input(self, filename):
C ##########################################################
"""
self.inpfile.write(surfaceHeader)
self.__write_surface_block__()
self.write_surface_block()
self.inpfile.write(" \n")

self.__write_source_block__()
self.write_source_block()

self.inpfile.close()
return

def __write_header__(self):
def write_header(self):

freeCAD_Version = "{V[0]:}.{V[1]:}.{V[2]:}".format(V=FreeCAD.Version())

Expand Down Expand Up @@ -133,25 +133,25 @@ def __write_header__(self):
self.inpfile.write(Information)
return

def __write_cell_block__(self):
def write_cell_block(self):

for i, cell in enumerate(self.Cells):
self.__write_cells__(cell)
self.write_cells(cell)
return

def __write_surface_block__(self):
def write_surface_block(self):

for surf in self.Surfaces:
self.__write_surfaces__(surf)
self.write_surfaces(surf)

def __write_cells__(self, cell):
def write_cells(self, cell):

index = cell.label

# if index is None objet not contain cell definition
# but a comment to insert between cells
if cell.__id__ is None:
comment = self.__comment_line__(cell.Comments)
comment = self.comment_line(cell.Comments)
self.inpfile.write(comment)
return

Expand All @@ -166,14 +166,14 @@ def __write_cells__(self, cell):

mcnpcell = "{}{}\n{}{}".format(
cellHeader,
self.__cell_format__(cell.Definition, offset=len(cellHeader)),
self.__option_format__(cell),
self.__comment_format__(cell.Comments, cell.MatInfo),
self.cell_format(cell.Definition, offset=len(cellHeader)),
self.option_format(cell),
self.comment_format(cell.Comments, cell.MatInfo),
)
self.inpfile.write(mcnpcell)
return

def __write_surfaces__(self, surface):
def write_surfaces(self, surface):
"""Write the surfaces in MCNP format"""

MCNP_def = mcnp_surface(
Expand All @@ -191,7 +191,7 @@ def __write_surfaces__(self, surface):
logger.info(f"Surface {surface.Type} cannot be written in MCNP input")
return

def __write_source_block__(self):
def write_source_block(self):

if self.SDEF_sphere is None:
return
Expand All @@ -214,7 +214,7 @@ def __write_source_block__(self):
for line in self.SDEF_sphere:
Block += line

celList, volList = self.__get_solid_cell_volume__()
celList, volList = self.get_solid_cell_volume()

F4Tally = CardLine(f"F4:{self.part} ")
F4Tally.extend(celList)
Expand All @@ -234,10 +234,10 @@ def __write_source_block__(self):

self.inpfile.write(Block)

def __cell_format__(self, Definition, offset=11):
def cell_format(self, Definition, offset=11):
return write_mcnp_cell_def(Definition, tabspace=11, offset=offset)

def __option_format__(self, cell):
def option_format(self, cell):

option = ""
if self.Options["Volume"]:
Expand All @@ -259,7 +259,7 @@ def __option_format__(self, cell):

return option

def __comment_format__(self, cComment, mComment=None):
def comment_format(self, cComment, mComment=None):

comment = ""
if mComment:
Expand All @@ -275,7 +275,7 @@ def __comment_format__(self, cComment, mComment=None):
comment += f"{'':11s}${c}\n"
return comment

def __comment_line__(self, lineComment):
def comment_line(self, lineComment):
lineComment = lineComment.strip().split("\n")
comment = ""
if lineComment:
Expand All @@ -286,7 +286,7 @@ def __comment_line__(self, lineComment):
comment += "C \n"
return comment

def __get_surface_table__(self):
def get_surface_table(self):
self.surfaceTable = {}
self.__solidCells__ = 0
self.__cells__ = 0
Expand All @@ -309,33 +309,33 @@ def __get_surface_table__(self):
self.surfaceTable[index] = {i}
return

def __simplify_planes__(self, Surfaces):
def simplify_planes(self, Surfaces):

for p in Surfaces["PX"]:
if p.Surf.Axis[0] < 0:
p.Surf.Axis = FreeCAD.Vector(1, 0, 0)
self.__change_surf_sign__(p)
self.change_surf_sign(p)

for p in Surfaces["PY"]:
if p.Surf.Axis[1] < 0:
p.Surf.Axis = FreeCAD.Vector(0, 1, 0)
self.__change_surf_sign__(p)
self.change_surf_sign(p)

for p in Surfaces["PZ"]:
if p.Surf.Axis[2] < 0:
p.Surf.Axis = FreeCAD.Vector(0, 0, 1)
self.__change_surf_sign__(p)
self.change_surf_sign(p)

if self.options.prnt3PPlane:
for p in Surfaces["P"]:
if p.Surf.pointDef:
axis, d = points_to_coeffs(p.Surf.Points)
if is_opposite(axis, p.Surf.Axis):
self.__change_surf_sign__(p)
self.change_surf_sign(p)

return

def __sorted_surfaces__(self, Surfaces):
def sorted_surfaces(self, Surfaces):
temp = SurfacesDict(Surfaces)
surfList = []
for ind in range(Surfaces.IndexOffset, Surfaces.surfaceNumber + Surfaces.IndexOffset):
Expand All @@ -345,7 +345,7 @@ def __sorted_surfaces__(self, Surfaces):
temp.del_surface(ind + 1)
return surfList

def __change_surf_sign__(self, p):
def change_surf_sign(self, p):

if p.Index not in self.surfaceTable.keys():
logger.info(f"{p.Type} Surface {p.Index} not used in cell definition) {p.Surf.Axis} {p.Surf.Position}")
Expand All @@ -357,7 +357,7 @@ def __change_surf_sign__(self, p):
if s == p.Index:
change_surf_sign(s, self.Cells[ic].Definition)

def __get_solid_cell_volume__(self):
def get_solid_cell_volume(self):

solidList = []
volumeList = []
Expand Down
Loading

0 comments on commit e9adc26

Please sign in to comment.