first of all i must say that i was able to pinpoint this issue thanks to LLM.
my code was working correctly when using paraview/python shell and running my code but when i was running it with pvbatch i was getting an error of the max() function not having the default input. this went thought a rabbit hole of ‘I am importing with wild cards, but this has been always worked etc etc’
and at the end i was able to pin point it when doing the pudate of the programmable filter.
import builtins
def checkMax(label):
print(f"{label}: {max} | built-in={max is builtins.max}",flush=True)
checkMax("13a")
self.programmableFilter.UpdatePipeline()
checkMax("13b")
which i was getting:
13a: <built-in function max> | built-in=True
13b: <function max at 0x7c527d068b80> | built-in=False
I made a small script that can reproduce this issue:
from paraview.simple import *
import builtins
print("BEFORE:",max)
print("BEFORE is builtins.max:",max is builtins.max)
# Create a simple input
sphere=Sphere()
# Create a Programmable Filter similar to yours
programmableFilter=ProgrammableFilter(Input=sphere)
script="""
import numpy as np
inputData=inputs[0]
output=self.GetOutput()
output.ShallowCopy(inputData.VTKObject)
"""
programmableFilter.Script=script
print("BEFORE UpdatePipeline:",max)
print("BEFORE is builtins.max:",max is builtins.max)
programmableFilter.UpdatePipeline()
print("AFTER UpdatePipeline:",max)
print("AFTER is builtins.max:",max is builtins.max)
# Test Python's max(default=...)
try:
result=max([],default=-1)
print("max works:",result)
except Exception as e:
print("max FAILED:",type(e).__name__,e)
I am getting a reproductable result:
BEFORE: <built-in function max>
BEFORE is builtins.max: True
BEFORE UpdatePipeline: <built-in function max>
BEFORE is builtins.max: True
AFTER UpdatePipeline: <function max at 0x71ec97372200>
AFTER is builtins.max: False
max FAILED: TypeError max() got an unexpected keyword argument 'default'
which is quite strange…
(at least for me)
this happens to me with pvbatch and pvpython