Closed RylieWeaver closed 2 months ago
If this is better to put in feedback in the google doc, let me know.
@RylieWeaver That's a good effort! A few things:
assert()
inside try
. What do you think?assert np.array_equal(v1, v2[2:])
Thanks for the encouragement! As you know I'm still learning, hopefully I continue to get better with your feedback.
Other Implementation:
if not np.array_equal(v1, v2):
print("Loaded y data vector is not equal to the true vector")
# Print positions of the first 10 values of v1 in v2 to help with debugging
for i, value in enumerate(v1[:10]):
if value in v2:
positions = np.where(v2 == value)[0]
print(f"Value {value} from v1 (index {i}) is found at positions {positions} in v2")
else:
print(f"Value {value} from v1 (index {i}) is not found in v2")
raise ValueError("v1 is not equal to v2")
Output:
Loaded y data vector is not equal to the true vector
Value 0.4724000096321106 from v1 (index 0) is found at positions [337] in v2
Value 0.7627999782562256 from v1 (index 1) is found at positions [3] in v2
Value 0.8429999947547913 from v1 (index 2) is found at positions [53] in v2
Value 0.7447999715805054 from v1 (index 3) is found at positions [161] in v2
Value 0.6991000175476074 from v1 (index 4) is found at positions [77] in v2
Value 0.802299976348877 from v1 (index 5) is found at positions [421] in v2
Value 0.6606000065803528 from v1 (index 6) is found at positions [332] in v2
Value 0.6740999817848206 from v1 (index 7) is found at positions [32] in v2
Value 0.5396999716758728 from v1 (index 8) is found at positions [120] in v2
Value 0.5291000008583069 from v1 (index 9) is found at positions [136] in v2
Exiting due to assertion failure.
As always don't feel forced to respond during my unconventional student working hours haha
@RylieWeaver I just pushed an alternative version for the assertion script. Let me know if it's more clear now.
Yes, I think that's clear and a very efficient way to do it, thanks.
Help users debug why the arrays are not equal. Printing the placements should help to determine whether there was an undesirable shuffle vs a shift