Skip to content

Commit

Permalink
Merge topic 'remove-deprecated-python-functions'
Browse files Browse the repository at this point in the history
255d41d Release note for python deprecated API removal
e608328 Remove deprecated parameter simple.SaveAnimation(DisconnectAndSave)
72dc93d Remove deprecated parameter simple.SaveScreenshot(ImageQuality)
8a00e5a Remove deprecated paramater simple.CreateView(detachedFromLayout)
4fb6a52 Improve deprecated tags and message in python files
4740814 Remove float comparison support for paraview.compatibility
48253f7 Remove deprecated paraview.simple.ImportCinema
90a2594 Remove deprecated paraview.simple.WriteImage
...

Acked-by: Kitware Robot <[email protected]>
Acked-by: Nicolas Vuaille <[email protected]>
Merge-request: !6053
  • Loading branch information
Timothee Chabat authored and kwrobot committed Dec 12, 2022
2 parents 8dd819e + 255d41d commit 156e777
Show file tree
Hide file tree
Showing 22 changed files with 272 additions and 401 deletions.
2 changes: 1 addition & 1 deletion Adaptors/Python/cp_pythonadaptorscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def DoCoProcessing(datadescription):
for view in range(len(renderviews)):
fname = imagefilename.replace("%v", str(view))
fname = fname.replace("%t", str(timestep))
WriteImage(fname, renderviews[view])
SaveScreenshot(fname, renderviews[view])

# explicitly delete the proxies -- we do it this way to avoid problems with prototypes
tobedeleted = GetProxiesToDelete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
SetActiveView(view)
Render()
imageFile = os.path.splitext(os.path.basename(smtesting.StateXMLFileName))[0]
WriteImage('%s/../../%s.png'%(smtesting.TempDir, imageFile))
SaveScreenshot('%s/../../%s.png'%(smtesting.TempDir, imageFile))

if not smtesting.DoRegressionTesting(view.SMProxy):
raise smtesting.TestError ('Test failed.')
Expand Down
4 changes: 2 additions & 2 deletions Clients/PythonCatalyst/Testing/Legacy/PythonScriptTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def DoCoProcessing(datadescription):
DataRepresentation2.EdgeColor = [0.0, 0.0, 0.50000762951094835]

fname = 'CPGrid' + str(timestep) + '.png'
WriteImage(fname)
SaveScreenshot(fname)

DataRepresentation2 = Show(trivialproducer)
DataRepresentation2.LookupTable = MakeBlueToRedLT(2702, 3202)
Expand All @@ -55,7 +55,7 @@ def DoCoProcessing(datadescription):
RenderView1.CameraParallelScale = 13.743685418725535

fname = 'CPPressure' + str(timestep) + '.png'
WriteImage(fname)
SaveScreenshot(fname)


def RequestDataDescription(datadescription):
Expand Down
17 changes: 17 additions & 0 deletions Documentation/release/dev/deprecated-python-API-removal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Deprecated python API removal

Several deprecated python API that have been around for a few years are now gone.
This include :

- `paraview.simple.CreateScalarBar()`, replaced by `paraview.simple.GetScalarBar()`.
- `paraview.simple.WriteAnimation()`, replaced by `paraview.simple.SaveAnimation()`.
- `paraview.simple.WriteImage()`, replaced by `paraview.simple.SaveScreenshot()`.
- `paraview.simple.ImportCinema()`, no longer supported since 5.9.
- `paraview.compatibility.GetVersion().GetVersion()`, because of float comparison issue.

Other deprecated behaviors have been removed :

- `paraview.compatibility.GetVersion()` cannot be compared with float values anymore.
- In `paraview.simple.CreateView()`, removed support for positional argument `detachedFromLayout`.
- In `paraview.simple.SaveScreenshot()`, removed support for optional argument `ImageQuality`.
- In `paraview.simple.SaveAnimation()`, removed support for optional argument `DisconnectAndSave` and `ImageQuality`.
18 changes: 8 additions & 10 deletions Plugins/pvblot/blotish.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _getReader(self):
self._block_id_variable = "Part Index"
self._block_id_field = "POINT_DATA"
self._block_id_offset = 0

else:
self._reader = paraview.simple.ExodusIIReader(FileName=self.filename)
self._reader.add_attribute("DatabaseType", EXODUS)
Expand Down Expand Up @@ -289,7 +289,7 @@ def _rebuildSpectrumLookupTable(self, lt):
import paraview.vtk
# Find a good range for the data.
range = self.currentVariableInfo.GetRange(self.currentVariableComponent)

if self.currentVariableComponent == -1:
lt.VectorMode = "Magnitude"
else:
Expand Down Expand Up @@ -802,7 +802,7 @@ def _tplot_plot(io_helper=None):

if state.diskwrite:
fname = state.get_next_screenshot_filename("tplot_overlay")
paraview.simple.WriteImage(fname, state.tplot.view)
paraview.simple.SaveScreenshot(fname, state.tplot.view)

return

Expand All @@ -813,7 +813,7 @@ def _tplot_plot(io_helper=None):

if state.diskwrite:
fname = state.get_next_screenshot_filename("tplot_curve%02d"%i)
paraview.simple.WriteImage(fname, state.tplot.view)
paraview.simple.SaveScreenshot(fname, state.tplot.view)

if interactive and i < nCurves-1:
yield "Enter 'Q' to quit, '' to continue. "
Expand All @@ -824,7 +824,7 @@ def _tplot_plot(io_helper=None):

def _tplot_reset():
state.tplot.reset()

def _detour_reset():
wireframe()

Expand Down Expand Up @@ -921,7 +921,7 @@ def alltimes():

def show(name=""):
"""Show the given parameter name"""

name = name.lower()
if name in ["tmin", "tmax", "nintv", "zintv", "times", "steps"]:
sel = state.time_selection
Expand All @@ -947,7 +947,7 @@ def _detour_plot(io_helper=None):
paraview.simple.Render(view)

if state.diskwrite:
paraview.simple.WriteImage(state.get_next_screenshot_filename("detour"), view)
paraview.simple.SaveScreenshot(state.get_next_screenshot_filename("detour"), view)

if interactive and stepIdx != nSteps-1:
yield ("Time %f: Enter 'C' to complete, 'Q' to quit, '' to continue. " % t)
Expand All @@ -958,7 +958,7 @@ def _detour_plot(io_helper=None):
interactive = False

def autoplot(flag):
"""
"""
Turn autoplot on or off. The flag should be 0 (off) or 1 (on). When
autoplot is on, then a command that changes the state of the plot
automatically renders the last time step with the new features.
Expand Down Expand Up @@ -1099,5 +1099,3 @@ def _maybe_convert(token, number_class):
try: num = number_list_parser.convert_to_number_class(token, number_class)
except number_list_parser.Error, err: raise BlotishError(err)
return num


10 changes: 5 additions & 5 deletions Plugins/pvblot/tplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self):

def __del__(self):
self.reset()


def reset(self):
self._curves = []
Expand Down Expand Up @@ -182,8 +182,8 @@ def plot(self, curve_index=0):
curves_to_plot = self._curves
elif curve_index < len(self._curves):
curves_to_plot = [self._curves[curve_index]]
else: return
else: return

view = self.view
view.Representations = []

Expand Down Expand Up @@ -330,9 +330,9 @@ def get_series_label(self):
else:
return "%s %s %s" % (self.var.decorated_name,
self.var.type_name,
self.id)
self.id)




def _get_field_type_for_variable(var):
if var.type == NODE_VARIABLE: return "POINT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# This test tests backwards compatibility for ColorArrayName and ColorAttributeType
# properties.

assert (paraview.compatibility.GetVersion().GetVersion() == None),\
assert (bool(paraview.compatibility.GetVersion()) == False),\
"ParaView modules should never force backwards compatibility to any version"
assert ((paraview.compatibility.GetVersion() < 4.1) == False),\
assert ((paraview.compatibility.GetVersion() < (4, 1)) == False),\
"less-than test should always fail when version is not specified."
assert ((paraview.compatibility.GetVersion() <= 4.1) == False),\
assert ((paraview.compatibility.GetVersion() <= (4, 1)) == False),\
"less-equal test should always fail when version is not specified."
assert ((paraview.compatibility.GetVersion() > 4.1) == True),\
assert ((paraview.compatibility.GetVersion() > (4, 1)) == True),\
"greater-than test should always pass when version is not specified."
assert ((paraview.compatibility.GetVersion() >= 4.1) == True),\
assert ((paraview.compatibility.GetVersion() >= (4, 1)) == True),\
"greater-equal test should always pass when version is not specified."

Sphere()
Expand All @@ -39,10 +39,10 @@
# Now switch backwards compatibility to 4.1
paraview.compatibility.major = 4
paraview.compatibility.minor = 1
assert ((paraview.compatibility.GetVersion() < 4.1) == False), "version comparison failed"
assert ((paraview.compatibility.GetVersion() <= 4.1) == True), "version comparison failed"
assert ((paraview.compatibility.GetVersion() > 4.1) == False), "version comparison failed"
assert ((paraview.compatibility.GetVersion() >= 4.1) == True), "version comparison failed"
assert ((paraview.compatibility.GetVersion() < (4, 1)) == False), "version comparison failed"
assert ((paraview.compatibility.GetVersion() <= (4, 1)) == True), "version comparison failed"
assert ((paraview.compatibility.GetVersion() > (4, 1)) == False), "version comparison failed"
assert ((paraview.compatibility.GetVersion() >= (4, 1)) == True), "version comparison failed"

a = r.ColorAttributeType
assert (type(a) == str), "'ColorAttributeType' must return a string"
Expand Down
2 changes: 1 addition & 1 deletion Remoting/Application/Testing/Python/LinePlotInScripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@

for i in xrange(5):
w.Maximum = 2**i
WriteImage(smtesting.TempDir + "/LinePlotInScripts_%d.png" % i, Magnification=2)
SaveScreenshot(smtesting.TempDir + "/LinePlotInScripts_%d.png" % i, magnification=2)
print("Done")
5 changes: 3 additions & 2 deletions Remoting/Application/Testing/Python/MultiView.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@
testing2.AddArgument(baseline2)

v2 = CreateXYPlotView()

for i in [0, 1, 2]:
Render(v1)
filename = "%s/view1_%d.png" % (smtesting.TempDir, i)
WriteImage(filename, v1)
SaveScreenshot(filename, v1, ImageResolution=(400, 400))
if testing1.RegressionTest(filename, smtesting.Threshold) != testing1.PASSED:
raise RuntimeError("Failed image comparison for view 1 on run #%d"%i)

Render(v2)
filename = "%s/view2_%d.png" % (smtesting.TempDir, i)
WriteImage(filename, v2)
SaveScreenshot(filename, v2, ImageResolution=(400, 400))
if testing2.RegressionTest(filename, smtesting.Threshold) != testing2.PASSED:
raise RuntimeError("Failed image comparison for view 2 on run #%d"%i)
64 changes: 40 additions & 24 deletions Remoting/Application/Testing/Python/PythonVersion.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
# ensures paraview._version() works as expected.

from paraview import _version, compatibility
from paraview import compatibility

assert (compatibility.GetVersion().GetVersion() == None),\
assert (bool(compatibility.GetVersion()) == False),\
"ParaView modules should never force backwards compatibility to any version"
assert ((compatibility.GetVersion() < 4.1) == False),\
assert ((compatibility.GetVersion() < (4, 1)) == False),\
"less-than test should always fail when version is not specified."
assert ((compatibility.GetVersion() <= 4.1) == False),\
assert ((compatibility.GetVersion() <= (4, 1)) == False),\
"less-equal test should always fail when version is not specified."
assert ((compatibility.GetVersion() > 4.1) == True),\
assert ((compatibility.GetVersion() > (4, 1)) == True),\
"greater-than test should always pass when version is not specified."
assert ((compatibility.GetVersion() >= 4.1) == True),\
assert ((compatibility.GetVersion() >= (4, 1)) == True),\
"greater-equal test should always pass when version is not specified."


# Now switch backwards compatibility to 4.1
# Now switch backwards compatibility to (4, 1)
compatibility.major = 4
compatibility.minor = 1

assert ((compatibility.GetVersion() < 4.1) == False), "version comparison failed"
assert ((compatibility.GetVersion() <= 4.1) == True), "version comparison failed"
assert ((compatibility.GetVersion() > 4.1) == False), "version comparison failed"
assert ((compatibility.GetVersion() >= 4.1) == True), "version comparison failed"
try:
compatibility.GetVersion() < 4.1
assert (False), "version comparison with floating value should fail"
except TypeError:
assert (True)

assert ((compatibility.GetVersion() < (4, 10)) == True), "version comparison failed"
assert ((compatibility.GetVersion() <= (4,10)) == True), "version comparison failed"
assert ((compatibility.GetVersion() > (4,10)) == False), "version comparison failed"
assert ((compatibility.GetVersion() >= (4,10)) == False), "version comparison failed"
assert ((compatibility.GetVersion() < (4, 1)) == False), "version comparison failed"
assert ((compatibility.GetVersion() <= (4, 1)) == True), "version comparison failed"
assert ((compatibility.GetVersion() > (4, 1)) == False), "version comparison failed"
assert ((compatibility.GetVersion() >= (4, 1)) == True), "version comparison failed"

assert ((compatibility.GetVersion() < (4, 10)) == True), "version comparison failed"
assert ((compatibility.GetVersion() <= (4, 10)) == True), "version comparison failed"
assert ((compatibility.GetVersion() > (4, 10)) == False), "version comparison failed"
assert ((compatibility.GetVersion() >= (4, 10)) == False), "version comparison failed"

compatibility.major = 4
compatibility.major = 11
assert ((compatibility.GetVersion() < 4.1) == False), "version comparison failed"
assert ((compatibility.GetVersion() <= 4.1) == False), "version comparison failed"
assert ((compatibility.GetVersion() > 4.1) == True), "version comparison failed"
assert ((compatibility.GetVersion() >= 4.1) == True), "version comparison failed"
compatibility.minor = 11

assert ((compatibility.GetVersion() < (4, 1)) == False), "version comparison failed"
assert ((compatibility.GetVersion() <= (4, 1)) == False), "version comparison failed"
assert ((compatibility.GetVersion() > (4, 1)) == True), "version comparison failed"
assert ((compatibility.GetVersion() >= (4, 1)) == True), "version comparison failed"

assert ((compatibility.GetVersion() < (4, 10)) == False), "version comparison failed"
assert ((compatibility.GetVersion() <= (4,10)) == False), "version comparison failed"
assert ((compatibility.GetVersion() > (4,10)) == True), "version comparison failed"
assert ((compatibility.GetVersion() >= (4,10)) == True), "version comparison failed"
assert ((compatibility.GetVersion() <= (4, 10)) == False), "version comparison failed"
assert ((compatibility.GetVersion() > (4, 10)) == True), "version comparison failed"
assert ((compatibility.GetVersion() >= (4, 10)) == True), "version comparison failed"

assert ((compatibility.GetVersion() < (4, 11)) == False), "version comparison failed"
assert ((compatibility.GetVersion() <= (4, 11)) == True), "version comparison failed"
assert ((compatibility.GetVersion() > (4, 11)) == False), "version comparison failed"
assert ((compatibility.GetVersion() >= (4, 11)) == True), "version comparison failed"

assert ((compatibility.GetVersion() < (5, 0)) == True), "version comparison failed"
assert ((compatibility.GetVersion() > (3, 12)) == True), "version comparison failed"

assert ((compatibility.GetVersion() < 5) == True), "major version comparison failed"
assert ((compatibility.GetVersion() > 3) == True), "major version comparison failed"
8 changes: 3 additions & 5 deletions Remoting/Application/Testing/Python/SaveAnimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ def RegressionTest(imageName, baselineName):
canex2Display = Show(reader, renderView1)

# Save animation images
SaveAnimation(tempdir + "/SaveAnimation.png", ImageResolution=[600, 600], ImageQuality=40)
SaveAnimation(tempdir + "/SaveAnimation.png", ImageResolution=[600, 600])

# Lets save stereo animation images (two eyes at the same time)
SaveAnimation(tempdir + "/SaveAnimationStereo.png",
ImageResolution=[600, 600], ImageQuality=40,
StereoMode="Both Eyes")
ImageResolution=[600, 600], StereoMode="Both Eyes")

# Lets save stere video
SaveAnimation(tempdir + "/SaveAnimationStereo.ogv",
ImageResolution=[600, 600], ImageQuality=40,
StereoMode="Both Eyes")
ImageResolution=[600, 600], StereoMode="Both Eyes")

pm = servermanager.vtkProcessModule.GetProcessModule()
if pm.GetPartitionId() == 0:
Expand Down
7 changes: 0 additions & 7 deletions Remoting/ServerManager/vtkSMStateVersionController.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ class UniqueIdGenerator
vtkTypeUInt32 GetNextUniqueId() { return (++this->LastUniqueId); }
};

string toString(int i)
{
ostringstream ostr;
ostr << i;
return ostr.str();
}

class vtkSMVersion
{
public:
Expand Down
2 changes: 1 addition & 1 deletion Remoting/Views/Testing/Python/SurfaceLICTestDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
SetActiveView(view)
Render()
imageFile = os.path.splitext(os.path.basename(smtesting.StateXMLFileName))[0]
WriteImage('%s/../../%s.png'%(smtesting.TempDir, imageFile))
SaveScreenshot('%s/../../%s.png'%(smtesting.TempDir, imageFile))

if not smtesting.DoRegressionTesting(view.SMProxy):
raise smtesting.TestError('Test failed.')
Expand Down
2 changes: 1 addition & 1 deletion Web/Python/paraview/web/dataset_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(self, location, imageMimeType, cameraInfo, metadata={}):
def writeImages(self):
for cam in self.camera:
update_camera(self.view, cam)
simple.WriteImage(self.dataHandler.getDataAbsoluteFilePath("image"))
simple.SaveScreenshot(self.dataHandler.getDataAbsoluteFilePath("image"))


# -----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 156e777

Please sign in to comment.