Almost equal operator bug

So i have a list contains of numbers and i wanted to make a boolean mask with almost equal operators, but what i get is not accurate.

It should be
[False, True, False, False, False, False, True]

im already try using python code

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line
# Input lists
list1 = IN[0]
list2 = IN[1]

# Determine the length of the longer list
max_len = max(len(list1), len(list2))

# Determine the length of the longer list
max_len = max(len(list1), len(list2))

# Pad the shorter list with None to match the length of the longer list
padded_list1 = list1 + [None] * (max_len - len(list1))
padded_list2 = list2 + [None] * (max_len - len(list2))

# Compare elements and create the output list
output = [(a == b) for a, b in zip(padded_list1, padded_list2)]

# Assign your output to the OUT variable.
OUT = output

but it turns out all false output…

hmm im curious whats causing this…


Even the rounded numbers too…


Edit, even the strings

The spings node uses Design Script Math.Abs(a - b) <= tol

Based on your graph with lacing set to longest it is checking against the last item in the shorter list.

Using zip in python is like Transpose in Dynamo nodes, as you have padded the shortest list with None the last four comparisons are <number> == None

If you want to compare numbers in two lists you could do this

import math

list1 = IN[0]
list2 = IN[1]
tol = IN[2]

# Uncomment line below to always compare against the longest list
# list1, list2 = max((list1, list2), key=len), min((list1, list2), key=len)

OUT = [[math.isclose(a, b, abs_tol=tol) for a in list1] for b in list2]
2 Likes


Lacing @ Lv2 & any true should also work…if you go the non python method.

1 Like