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.

This tag is typically used for questions concerning how to determine if two objects or variables are either the same object or different objects with the same value. Questions almost always require a programming language tag and other tags for context.

Programming languages represent variables, objects, or other storage containers using different underlying mechanisms for the storage of the values of variables and objects. A test for equality is to compare some characteristic of two variables or objects to determine if the characteristic is the same.

This characteristic is typically either (1) the storage identifier such as a reference handle, memory address, etc. when checking if the two are the same object or (2) the characteristic is the value of the objects retrieved using a storage identifier when checking if the value of the two are the same value.

Different programming languages and different operating environments have differences in how equality is tested and what operators are used to express a test for equality. In some cases various conversions from underlying storage representations may be involved in testing for equality.

See What is the difference between equality and equivalence? as well as Equivalence relation and natural ordering on a class in Java

2095 questions
0
votes
3 answers

Equality in C++

I am still learning the fundamentals of programming through C++ and was trying some applications on C++ operators, but it seems there are things about them that I still don't understand. I tried writing the following line to test the possibility of…
0
votes
0 answers

Equality Operator Not Working On Strings Inside A Function

I've been experiencing this weird issue where equality operators will not work intuitively inside a function. When I call the script copied below in my terminal, the function returns "False", but I am expecting it to return "True". The equivalent…
dustmole
  • 1
  • 3
0
votes
1 answer

How to compare two string values in jolt

I want to filter out the input JSON based on two field values of input JSON. Input JSON [ { "from_Store": "Test1", "to_Store": "Test1", "items": [ { "UPC": "8240959370255", "shippedQuantity": 1 } ] }, …
0
votes
0 answers

Comparing two deques, one implemented by an Array and another implemented with a LinkedList, for equality?

I am working on implementing a custom Deque interface. Everything is working except the equals methods. Whenever I submit my code to an auto-checker, it fails one of the tests for equality and outputs: "ArrayDeques and LinkedListDeques with the same…
rdk7
  • 3
  • 2
0
votes
1 answer

Python: real order of execution for equalities/inequalities in expressions?

Imagine this "sneaky" python code: >>> 1 == 2 < 3 False According to Python documentation all of the operators in, not in, is, is not, <, <=, >, >=, !=, == have the same priority, but what happens here seems contradictory. I get even weirder…
0
votes
1 answer

TYPO3 form: How to check equality between two email addresses?

In the form extension I want to check two email fields for equality. But there seems to be no validator to check two fields for equality: https://docs.typo3.org/c/typo3/cms-form/main/en-us/I/Concepts/Validators/Index.html Has anyone already written…
Ralf
  • 1
  • 1
0
votes
0 answers

scipy to perform a t-test for equality

I am trying to perform a t-test to determine the equality of the means of two samples of data. I understand that I need to perform a t-test with a null hypothesis of difference and reject it: $$ H_0 = \| \mu_1 - \mu_2\| > \delta $$ $$ H_a = \|…
PanchoPaz
  • 3
  • 1
0
votes
0 answers

How to compare nested structures of np.arrays

I would like to compare nested structures of np arrays, possibly contained in python tuples and dictionaries. However, it fails due to np element-wise comparison for the equality operator, which returns a np.array rather than a bool. For…
Maximilian Mordig
  • 1,333
  • 1
  • 12
  • 16
0
votes
0 answers

Python symmetric_equality on two lists

I can do something like: set(df['col1'][0].split(" ")).symmetric_difference(set(df2['col1'][0].split(" "))) That gives me the different strings between these two lists. Moreover i am interested on finding the equality strings between these two…
Catarina Nogueira
  • 1,024
  • 2
  • 12
  • 28
0
votes
1 answer

Replacing the synthesized Equals() of C# record struct

In short: Is there any way to provide my own Equals( object? ) method for a record struct instead of being stuck with the one automagically generated by the compiler? Note: This question has nothing to do with replacing the automatically generated…
Mike Nakis
  • 56,297
  • 11
  • 110
  • 142
0
votes
1 answer

getClass() & instanceof semantic when classloaders are different

It seems that the "same" classes from different classloaders shouldn't appear in a same execution context, OSGI / app server ensure boundaries are not violated. Imaging we escaped a jail and are comparing objects, which are "equal" (data & package &…
gavenkoa
  • 45,285
  • 19
  • 251
  • 303
0
votes
3 answers

I sorted two dataframes by id that contain the same values but am getting that they are not equal

I have two dataframes: df1 ID Name 15 Max 7 Stacy 3 Frank 2 Joe df2 ID Name 2 Abigail 3 Josh 15 Jake 7 Brian I sorteded them by doing df1 =…
Angie
  • 183
  • 3
  • 13
0
votes
0 answers

String equality not producing expected output

I am trying to equate two variables for some other code but despite being the same string I keep getting false. Here is the code I wrote: app.post('/deletegraph', requireLogin, async (req, res) => { let {graph_name} = req.body …
Lux
  • 15
  • 3
0
votes
0 answers

Python sets hash and eq default call strategy

I have a problem where I need to optimize a specific part of my code. I am iterating over a list of objects called obs and for each object, I am calling a function do() which takes the object as an input. However, I don't want to call the do()…
Lahcen YAMOUN
  • 657
  • 3
  • 15
0
votes
1 answer

Why aren't identical datetimes equal?

I'm working on a simple Python3 script that considers data in five-minute increments. Thanks to this post, I have code which takes any Python datetime object and then rounds it down to the nearest five minutes. (:00, :05, :10, :15, etc.) Note…
Pete
  • 1,511
  • 2
  • 26
  • 49