Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions pygem/filehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class FileHandler(object):

:cvar string infile: name of the input file to be processed.
:cvar string outfile: name of the output file where to write in.
:cvar list extensions: extensions of the input/output files. It is specific for each
subclass.
:cvar list extensions: extensions of the input/output files. It is specific
for each subclass.
"""

def __init__(self):
Expand Down Expand Up @@ -41,22 +41,23 @@ def write(self, *args):

def _check_extension(self, filename):
"""
This private class method checks if the given `filename` has the proper `extension` set
in the child class. If not it raises a ValueError.
This private class method checks if the given `filename` has the proper
`extension` set in the child class. If not it raises a ValueError.

:param string filename: file to check.
"""
__, file_ext = os.path.splitext(filename)
if file_ext not in self.extensions:
raise ValueError(
'The input file does not have the proper extension. \
It is {0!s}, instead of {1!s}.'.format(file_ext,
self.extensions))
It is {0!s}, instead of {1!s}.'
.format(file_ext, self.extensions))

@staticmethod
def _check_filename_type(filename):
"""
This private static method checks if `filename` is a string. If not it raises a TypeError.
This private static method checks if `filename` is a string. If not it
raises a TypeError.

:param string filename: file to check.
"""
Expand All @@ -66,9 +67,9 @@ def _check_filename_type(filename):

def _check_infile_instantiation(self):
"""
This private method checks if `self.infile` is instantiated. If not it means
that nobody called the parse method and `self.infile` is None. If the check fails
it raises a RuntimeError.
This private method checks if `self.infile` is instantiated. If not
it means that nobody called the parse method and `self.infile` is None.
If the check fails it raises a RuntimeError.

"""
if not self.infile:
Expand Down
27 changes: 13 additions & 14 deletions pygem/freeform.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ def perform(self):
self.original_mesh_points - translation, transformation)

# select mesh points inside bounding box
mesh_points = reference_frame_mesh_points[
(reference_frame_mesh_points[:, 0] >= 0.)
& (reference_frame_mesh_points[:, 0] <= 1.) &
(reference_frame_mesh_points[:, 1] >= 0.) &
(reference_frame_mesh_points[:, 1] <= 1.) &
(reference_frame_mesh_points[:, 2] >= 0.) &
(reference_frame_mesh_points[:, 2] <= 1.)]
mesh_points = reference_frame_mesh_points[(
reference_frame_mesh_points[:, 0] >= 0.) & (
reference_frame_mesh_points[:, 0] <= 1.) & (
reference_frame_mesh_points[:, 1] >= 0.) & (
reference_frame_mesh_points[:, 1] <= 1.) & (
reference_frame_mesh_points[:, 2] >= 0.) & (
reference_frame_mesh_points[:, 2] <= 1.)]
(n_rows_mesh, n_cols_mesh) = mesh_points.shape

# Initialization. In order to exploit the contiguity in memory the
Expand Down Expand Up @@ -156,13 +156,12 @@ def perform(self):

# merge non-shifted mesh points with shifted ones
self.modified_mesh_points = np.copy(self.original_mesh_points)
self.modified_mesh_points[(reference_frame_mesh_points[:, 0] >= 0.)
& (reference_frame_mesh_points[:, 0] <= 1.) &
(reference_frame_mesh_points[:, 1] >= 0.) &
(reference_frame_mesh_points[:, 1] <= 1.) &
(reference_frame_mesh_points[:, 2] >= 0.) &
(reference_frame_mesh_points[:, 2] <=
1.)] = new_mesh_points
self.modified_mesh_points[(reference_frame_mesh_points[:, 0] >= 0.) & (
reference_frame_mesh_points[:, 0] <= 1.
) & (reference_frame_mesh_points[:, 1] >= 0.) & (
reference_frame_mesh_points[:, 1] <= 1.) & (
reference_frame_mesh_points[:, 2] >= 0.) & (
reference_frame_mesh_points[:, 2] <= 1.)] = new_mesh_points

@staticmethod
def _transform_points(original_points, transformation):
Expand Down
Loading