How does JS type coercion work?

“0” is a string containing the character 0, it is not the numeric value 0. The only string-type value which evaluates to false is “”. “0” is truthy. Section 9.2 of the ECMAScript 262 specification defines how different types are converted to Boolean: Argument Type Result Undefined false Null false Boolean The result equals the … Read more

Pandas DataFrames with NaNs equality comparison

You can use assert_frame_equals with check_names=False (so as not to check the index/columns names), which will raise if they are not equal: In [11]: from pandas.testing import assert_frame_equal In [12]: assert_frame_equal(df, expected, check_names=False) You can wrap this in a function with something like: try: assert_frame_equal(df, expected, check_names=False) return True except AssertionError: return False In more … Read more

String equality vs equality of location

Java only automatically interns String literals. New String objects (created using the new keyword) are not interned by default. You can use the String.intern() method to intern an existing String object. Calling intern will check the existing String pool for a matching object and return it if one exists or add it if there was … Read more

What problem does IStructuralEquatable and IStructuralComparable solve?

All types in .NET support the Object.Equals() method which, by default, compares two types for reference equality. However, sometimes, it also desirable to be able to compare two types for structural equality. The best example of this is arrays, which with .NET 4 now implement the IStructuralEquatable interface. This makes it possible to distinguish whether … Read more