Programmable Filter - TypeError: min() got an unexpected keyword argument 'key'

Hi,
I have a a model with a temperature field. I have a .csv file with the fraction solid Vs temperature data. I am trying to use a programmable filter to read in the fraction solid data, then for each cell interpolate the Fraction Solid based on the temperature data.

I’m struggling with the error:
TypeError: min() got an unexpected keyword argument ‘key’

The function getFracLiq requires a float value. I pass in float with a value not requiring interpolation then the script works (temp = 700, temp = 300). However, if it is a value requiring interpolation (temp=600), then the min function is used and the script fails with the error.

Why does the min() function produce this error, and how do I get around this issue?

Below is the python from my Programmable Filter Window,

import os

# Temperature to Fraction liquid
def getFSdata(fsFileName):

    # Read in file
    FSdata = [[],[]]
    f1=open(fsFileName,'r')
    content=f1.readlines()
    for line in content:
        s1=line.rstrip('\n').split(',')
        FSdata[0].append(float(s1[0]))  # The dataList[0] in dataList stores the time column of the model output file
        FSdata[1].append(float(s1[1]))  # dataList[nodeNum+1] contains the temperature evolution of Point nodeNum
    f1.close()

    return FSdata


# This function returns the fraction liquid at a given temperature
def getFracLiq(temp,FSdata):

    #Confirm temperature within solidus liquidus range
    if temp <= FSdata[0][0]:
        FracSolid = 1.0
    elif temp >= FSdata[0][-1]:
        FracSolid = 0.0

    else:
        # Calculate the fraction solid by linearly interpolating data supplied
        # Find closest data entry to temp 

        close = min(FSdata[0], key=lambda x:abs(x-temp))

        if close > temp:
            indexH_Cons=FSdata[0].index(close)      # For temperatures higher than the constraint T, indexH_Cons is the index of the one that is closest to the constraint T
            indexL_Cons=FSdata[0].index(close) - 1
        else:
            indexH_Cons=FSdata[0].index(close) + 1  # For temperatures lower than the constraint T, indexL_Cons is the index of the one that is closest to the constraint T
            indexL_Cons=FSdata[0].index(close)

        FracSolid =(FSdata[0][indexH_Cons]-temp)/(FSdata[0][indexH_Cons]-FSdata[0][indexL_Cons])*(FSdata[1][indexL_Cons]-FSdata[1][indexH_Cons])+FSdata[1][indexH_Cons] 

    # Calculate the liquid fraction from fraction solid
    liqFrac = 1.0-FracSolid

     return (liqFrac)



# Load Fraction solid data

fsFileName = r'C:\Users\Carl\Desktop\cubes_porosityParaView\paraView\FSdata.csv'
FSdata = getFSdata(fsFileName)



# Calculate the Fraction liquid of the each cell

# Obtain temperature data
#temp = inputs[0].CellData['T']
temp = 600.0

fracLiq = getFracLiq(temp,FSdata)

output.CellData.append( fracLiq , 'FracLiquid')

You need to use an import builtins statement to access the module builtins directly. ProgrammableFilter may possibly overwrite the min() function by numpy.min().

import builtins

...
    close = builtins.min(FSdata[0], key=lambda x:abs(x-temp))