Questions tagged [equality]
Equality is a relationship between two or more items or variables or objects that exists if (1) the items are the same item, variable, or object or (2) the items are different items, variables or objects but they have the same value. This tag should generally be used with programming language specific tags as well as other contextual tags such as database system. The post should include as much context about the equality test as is possible.
equality
2,207
questions
1
vote
1
answer
40
views
several custom __eq__ for python classes in context of serialization
Assume I have some complex class structure with some hierarchy, public and private fields.
I need to do some custom serialization for such class. In some test after deserialize I want to compare ...
1
vote
2
answers
131
views
Efficiently check for equality of memory blocks in C/C++
I'm interested in the most efficient way to check for equality of memory blocks.
Currently, I use memcmp(...) == 0 to determine if two memory blocks are equal. While this works, memcmp is designed not ...
0
votes
0
answers
92
views
Haskell Typeclass for non-transative equality
I know that the laws for the Eq class include reflectivity, symmetry, and transitivity. Is there another class for the case where equality is not necessarily transitive?
I could write one myself (see ...
-3
votes
2
answers
107
views
Compare lists of string in terraform
What's the best way to compare two lists of string in terraform?
["arm64"] == ["arm64"] evaluates to false
My use case is constructing lambda extension ARNs based on ...
2
votes
1
answer
49
views
How do I compare 2 elements (variable prices) in Cypress?
I am testing the eshop.
I'm trying to verify that if you buy one product, the price will be the same as the final purchase price.
The first element "Final Price" is calculated by the price ...
3
votes
3
answers
107
views
Understanding the details of equality in Python
When trying to construct an example where a == b is not the same as b == a, it seems that I have accidentally constructed an example where a == b is not the same as a.__eq__(b):
class A:
def ...
1
vote
3
answers
133
views
.NET combine hash codes insensitive to order
I'm looking for an implementation of hash code to use alongside IReadOnlySet<T>.SetEquals.
.NET's HashCode type appears to be order sensitive, so it is not a good fit.
var random = new Random();
...
2
votes
1
answer
69
views
Comparing hashtables in Pester
What's the correct way to compare hashtables in Pester tests?
i.e. the following gives the error: InvalidResult: Expected System.Collections.Hashtable, but got System.Collections.Hashtable.
$expected =...
-4
votes
1
answer
105
views
How do Java's equality tests (`==`) work between same primitives (e.g. int, char) and what is most efficient?
How do Java's equality tests work between primitives? I'm specifically looking for efficiency (and speed) within single-type comparisons. Is the char == char comparison faster than int == int?
I ...
8
votes
1
answer
313
views
A type with `Eq a` but not `Ord a`
In (an idealized version of) Haskell, is there a concrete type a such that we can implement Eq a lawfully, but it is impossible to implement Ord a? The order doesn't need to be meaningful, and any ...
0
votes
2
answers
69
views
Uniquness of a record containing a collection
I am using C# records in a HashSet to enforce uniqueness. This works well, but as soon as the record contains a Collection then it stops working.
ie. this passes:
public record Person
{
public ...
0
votes
1
answer
55
views
How to solve an inequality that contains standard deviation in python?
I have the past 19 days of stock price stored in the pd.dataframe and I am trying to find out the price P that is smaller than (mean - 2.5*standard deviation), where mean and standard deviation are ...
0
votes
2
answers
49
views
In Tcl, why do I have to use quotes and curly braces for expr's argument when comparing two string literals?
I wanna compare two literal strings using expr command in Tcl. The correct command is:
expr {"string1" == "string1"}
In my understanding, curly braces in Tcl is used to prevent ...
1
vote
1
answer
67
views
== and Equals for Tuple<object>
i have a question why it works like this
var a = new Tuple<object, object, object>(1, 1, 1);
var b = new Tuple<object, object, object>(1, 1, 1);
Console.WriteLine(a.Item1==b.Item1);//...
1
vote
1
answer
198
views
Custom equality comparator for set operation in Kotlin
As mentioned here: Efficient way to compare an partition two collections in Kotlin I am working on a Kotlin application that needs to compare lists of Json objects. To find the elements that are ...