Skip to content

Commit

Permalink
Refactor scale_factor -> factor
Browse files Browse the repository at this point in the history
  • Loading branch information
banesullivan committed Apr 30, 2019
1 parent 5ccad7a commit 367e5bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/01-filter/compute-normals.py
Expand Up @@ -29,7 +29,7 @@
mesh.compute_normals() # this activates the normals as well

# Now use those normals to warp the surface
warp = mesh.warp_by_scalar(scale_factor=0.5e-5)
warp = mesh.warp_by_scalar(factor=0.5e-5)

# And let's see it!
warp.plot(cmap='gist_earth', show_scalar_bar=False)
14 changes: 9 additions & 5 deletions vtki/filters.py
Expand Up @@ -811,8 +811,8 @@ def split_bodies(dataset, label=False):
return bodies


def warp_by_scalar(dataset, scalars=None, scale_factor=1.0, normal=None,
inplace=False):
def warp_by_scalar(dataset, scalars=None, factor=1.0, normal=None,
inplace=False, **kwargs):
"""
Warp the dataset's points by a point data scalar array's values.
This modifies point coordinates by moving points along point normals by
Expand All @@ -823,8 +823,9 @@ def warp_by_scalar(dataset, scalars=None, scale_factor=1.0, normal=None,
scalars : str, optional
Name of scalars to warb by. Defaults to currently active scalars.
scale_factor : float, optional
A scalaing factor to increase the scaling effect
factor : float, optional
A scalaing factor to increase the scaling effect. Alias
``scale_factor`` also accepted - if present, overrides ``factor``.
normal : np.array, list, tuple of length 3
User specified normal. If given, data normals will be ignored and
Expand All @@ -838,11 +839,14 @@ def warp_by_scalar(dataset, scalars=None, scale_factor=1.0, normal=None,
arr, field = get_scalar(dataset, scalars, preference='point', info=True)
if field != vtki.POINT_DATA_FIELD:
raise AssertionError('Dataset can only by warped by a point data array.')
scale_factor = kwargs.get('scale_factor', None)
if scale_factor is not None:
factor = scale_factor
# Run the algorithm
alg = vtk.vtkWarpScalar()
alg.SetInputDataObject(dataset)
alg.SetInputArrayToProcess(0, 0, 0, field, scalars) # args: (idx, port, connection, field, name)
alg.SetScaleFactor(scale_factor)
alg.SetScaleFactor(factor)
if normal is not None:
alg.SetNormal(normal)
alg.SetUseNormal(True)
Expand Down

0 comments on commit 367e5bb

Please sign in to comment.