L1 · Pyodide

Reproducing numpy/numpy#28287

Loading Pyodide runtime…

Reproduction script

import sys

import numpy as np

x = np.timedelta64(1, "ms")
y = np.timedelta64(2)
z = np.timedelta64(5, "ns")

x_lt_y = bool(x < y)
y_lt_z = bool(y < z)
x_lt_z = bool(x < z)
transitivity_violated = x_lt_y and y_lt_z and not x_lt_z

result = {
    "numpy_version": np.__version__,
    "python_version": sys.version.split()[0],
    "x_lt_y": x_lt_y,
    "y_lt_z": y_lt_z,
    "x_lt_z": x_lt_z,
    "transitivity_violated": transitivity_violated,
}

broken = "   <-- transitivity broken" if transitivity_violated else ""

print("Three timedelta64 values, two of them carrying a unit:")
print()
print("x = 1 ms")
print("y = 2 (generic unit)")
print("z = 5 ns")
print()
print("x < y  -> " + str(x_lt_y))
print("y < z  -> " + str(y_lt_z))
print("x < z  -> " + str(x_lt_z) + broken)
print()
if transitivity_violated:
    print("Ordering is not transitive: x < y and y < z, yet x >= z.")
else:
    print("Ordering is transitive on these three values.")
print("numpy " + result["numpy_version"] + " / Python " + result["python_version"])

Baseline output

Initialising…
(pending)

Fix-candidate output

(no fix candidate yet — numpy/numpy#28287 is still open upstream)