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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
24 views

How to check if an object exists in an array in Ballerina

I want to know how to check if a particular object already exists in an array. I tried with following approach and it gives a compile time error. import ballerina/io; class A { private int a = 2; ...
Sasindu Dilshara's user avatar
2 votes
1 answer
56 views

Testing PowerShell string equality

I am trying to ascertain whether 2 application version strings are equal in PowerShell and am getting a confusing result: PS C:\> $version = wmic product where "caption like '%Citrix Workspace ...
PumpkinBreath's user avatar
-5 votes
0 answers
50 views

strange string equality issue [duplicate]

My program connect to a web service and receive messages, one of the fields is string, the string is just one character long and I need to compare it to a few values to decide the next processing. The ...
fluter's user avatar
  • 13.3k
-1 votes
0 answers
60 views

Difference between == and .equals() [duplicate]

Can some one explain the difference between == and .equals() when used to compare objects in Java? I attempted to perform comparisons on Java objects using both the == operator and the .equals() ...
Samitha Wijenayake's user avatar
0 votes
0 answers
43 views

Equality check for double type gives strange results in C++ [duplicate]

I have the following code: #include <iostream> #include <math.h> #include <vector> int main() { size_t N = 20; double from = 0.0; double to = 1.0; std::vector<...
Daniel's user avatar
  • 393
-1 votes
0 answers
24 views

Appending list in dict.fromkeys(keys, []) references the same list [duplicate]

Can someone explain how this works for different types? I've seen some examples here of there being issues when referencing empty sets versus integers. I'm confused about how different types change ...
mijung's user avatar
  • 1
1 vote
1 answer
32 views

Wrong behavior of "not" in SPARQL filter with equals and bound

I found strange behaviour of "not" in filter inside sparql. To demonstrate i prepare simple example here is data: @prefix tst: <http://data.test.org/resource/ontology/tst#> . @...
Wizzard's user avatar
  • 355
0 votes
0 answers
46 views

Why do anonymous classes not implement System.IEquatable<T>?

Anonymous classes (a.k.a. anonymous types) are implicitly created and used by the C# compiler for code like this: var obj = new { X1 = 0, X2 = 1 }; They have value equality semantics, i.e., the ...
Bartosz's user avatar
  • 461
2 votes
1 answer
100 views

Unexpected equality semantics of Java byte arrays in Clojure

I'm trying to check equality between two byte arrays: I'm running the following code: ;; Test 1 (= (byte-array [0 0 0 0]) (byte-array [0 0 0 0])) ;; => false ;; Test 2 (= (seq (byte-array [0 0 ...
Ioannis Mourginakis's user avatar
-1 votes
2 answers
70 views

Equal vs DeepEqual [closed]

Why is there a difference between Equal and DeepEqual? s1 := "abc" s2 := "abc" sv1 := reflect.ValueOf(s1) sv2 := reflect.ValueOf(s2) fmt.Println(sv1.Equal(sv2)) fmt.Println(...
ceving's user avatar
  • 22.2k
0 votes
1 answer
24 views

Check if dataframe or specific string literal was passed to function

I have a function that takes an argument which, among other things, could be either a dataframe or a string literal. def func(could_be_df): if could_be_df=='optionA':data=stuffA() elif ...
Kalev Maricq's user avatar
0 votes
0 answers
38 views

Find all combinations of coefficients for an equality

I have a mathematical problem, and I don't know how to solve it in python. I have the following equality: P = ∑αi Pi I know P and all Pi and I am looking for all αi combinations for the equality. ...
Thomas Maugis's user avatar
-2 votes
2 answers
94 views

Why are these 2 python class instance could equal to each other?

from dataclasses import dataclass @dataclass class ThreeDPoint: x: int | float y = 0.0 z: int | float = 0.0 point_1 = ThreeDPoint(1.0,2) point_3 = ThreeDPoint(1,2) print(point_1 == ...
anonNEWlearner's user avatar
0 votes
2 answers
64 views

C# Removing List Item with same value but different identity, works, but why?

I was trying to make a code that removes some list items, but then I realized, my code is not supposed to be working, but works. I will explain the reason why I thought that my code 'should not be ...
Argo's user avatar
  • 23
1 vote
2 answers
185 views

Cannot disable SwiftUI View updates

My app has two modes: A "run" mode executes very fast without any SwiftUI View update, and a "single step" mode where the user advances the app state manually and needs View ...
Reinhard Männer's user avatar
-2 votes
1 answer
70 views

Hash function for or equality

I'm working on a program that checks for incomplete data. class Contact: def __init__(self, name, phone, email): self.names = {name} if pd.notna(name) else set() self.phones = {...
Simon Van den Bossche's user avatar
0 votes
0 answers
43 views

Random Choices - Weighting Errors

I am trying to build a lottery system for admissions and the code keeps throwing up the weights error: The code is appended below - import tkinter as tk from tkinter import filedialog, messagebox ...
user3671171's user avatar
4 votes
3 answers
99 views

IEquatable<string> doesn't work with static Equals method

I implemented a class called NonEmptyString which doesn't allow creation when it's not empty. I made this class implement IEquatable<NonEmptyString> and IEquatable<string>. I have ...
Pavel Kalandra's user avatar
0 votes
1 answer
24 views

String comparision returning False even if they are the same in python , inside a html file in DJANGO

so there is this IF statement inside a html file , which is failing to return a TRUE when both the strings are the same , i dont know why , i copy pasted the same strings from database to another ...
Rebellio _69's user avatar
0 votes
1 answer
36 views

testing equality of Eq (not Expr) in SymPy

YourHomicidalApe asked a question which is essentially this: Given two strings that represent equations that are converted to SymPy Eq instances, how would you tell if they represent the same ...
smichr's user avatar
  • 17.3k
1 vote
1 answer
45 views

Check if multiple columns are identical in r (with missing data)

I am trying to determine if multiple columns are identical to each other in R. Each variable contains string data. An example might look something like this. There is some missing data in the file. ...
Eric Boorman's user avatar
1 vote
1 answer
43 views

Does .NET Hashtable uses the specialized Font equality comparer when fonts are used as keys?

I need to create a set of unique Font objects each of which should have an associated object. This should be done in a .NET Framework WinForms app. These Font objects come from various sources, and ...
TecMan's user avatar
  • 2,829
0 votes
3 answers
95 views

Equality in C++ [duplicate]

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 ...
SeriousN00b's user avatar
1 vote
1 answer
198 views

Jolt - How to compare two values for if else condition

I have to transform in Jolt on the condition that if the value in name and displayName are same, then the output should set the flag value displayOnUI to true else false Input: [ { "name&...
Nishu's user avatar
  • 25
-1 votes
2 answers
185 views

Figures. Extra Challenge

Please help to create a method like public boolean isTheSame(Figure figure){} Description: Please, make Triangle, Quadrilateral, Circle classes extend Figure abstract class. Implement methods in ...
Andrii's user avatar
  • 11
0 votes
0 answers
19 views

Equality Operator Not Working On Strings Inside A Function [duplicate]

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",...
dustmole's user avatar
0 votes
1 answer
73 views

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", "...
Bhavna Gawhade's user avatar
2 votes
1 answer
91 views

Idiomatic way to force AssertJ to compare by identity?

AssertJ's assertThat(...).isEqualTo() method compares using .equals() by default. This is often the right choice, but sometimes you really do want to compare by exact object identity / referential ...
sh-at-cs's user avatar
1 vote
1 answer
41 views

How std::unordered_set correctly detects equal elements if Hash and KeyEqual are based on different subobjects?

Consider this snippet: struct Foo { int a, b; }; template<> struct std::hash<Foo> { constexpr std::size_t operator()(const Foo& obj) const noexcept { return std::...
Sourav Kannantha B's user avatar
0 votes
2 answers
156 views

Javascript - Check if arrays within an array are the same

Whats the best way to check if the arrays within an array are the same in my case? var arrSession = [ { type: '1', usecase: [ '1' ] }, { type: '1', usecase: [ '1' ] } ]; var ...
Philipp M's user avatar
  • 3,346
0 votes
1 answer
13 views

Is it worth throwing an error when override the equals(Object obj) method if the types are not equal

In OOP, is it worth throwing an error when override the equals(Object obj) method if the types are not equal? I want to prevent comparison of non-comparable types. Problem For example, i create like ...
GreenFed's user avatar
1 vote
0 answers
87 views

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:...
bobcob's user avatar
  • 13
0 votes
1 answer
31 views

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

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 ...
oBrstisf8o's user avatar
0 votes
1 answer
57 views

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/...
Ralf's user avatar
  • 1
4 votes
1 answer
120 views

Why does the Visual Studio Watch panel evaluate equality differently than my program?

I'm using Visual Studio's Watch panel to investigate variables as I run my program. In the following code, both test1 and test2 variables are added to the Watch panel. As expected, they both evaluate ...
AndrewR's user avatar
  • 592
1 vote
1 answer
41 views

Distribute automatically and equitly on EXCEL, in a certain number of cells, the result of the division of two numbers

Ok this is my problem. I have the an total shipping cost( in this example 14.6) that normallys is a decimal number. This number have to be divide by the quantity of products that cames in a box( in ...
memo08's user avatar
  • 9
-1 votes
2 answers
77 views

How to compare two Pandas Dataframes with text, numerical, and None values

I have two dataframes df1 and df2 that both contain text and numerical data in addition to Nones as well. However, df1 has integer numbers, and df2 has float numbers. I've tried comparing their ...
Pro Q's user avatar
  • 4,524
1 vote
2 answers
75 views

numpy assert_equals for nested floating point

I got a strange behaviour regarding an equal check for the weights for the vgg16 machine learning model loading two times the model import torch from torch import nn from torchvision.models import ...
Nikaido's user avatar
  • 4,481
0 votes
1 answer
37 views

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 = ...
PanchoPaz's user avatar
5 votes
1 answer
51 views

What allows NaN to work with the Python list inclusion operator?

Pretty much anyone who works with IEEE floating-point values has run into NaN, or "not a number", at some point. Famously, NaN is not equal to itself. >>> x = float('nan') >>&...
Silvio Mayolo's user avatar
2 votes
1 answer
94 views

Confused about object pointers/equality

public class Practice { public int value; public Practice child; public Practice(int value) { this.value = value; } public static void main(String[] args) { ...
Andrew's user avatar
  • 21
0 votes
0 answers
27 views

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 ...
Maximilian Mordig's user avatar
1 vote
3 answers
121 views

Since when is Python None equal to None?

I always thought that Python nulls are not equal, as is common in many other languages and based on simple logic (if the value is unknown, how can it be equal to another unknown?). However, recently I ...
Dommondke's user avatar
  • 382
-1 votes
2 answers
136 views

Ruby Application using When/Case yielding Nil when it shouldn't

The following code should print one of the three options given depending on the results of any of the == checks, but it doesn't. It yields nil for any value of your_message provided via gets.chomp. ...
Panamaniac507's user avatar
0 votes
0 answers
17 views

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 ...
Catarina Nogueira's user avatar
1 vote
2 answers
86 views

What is the proper way to compare equality of two variables that could be NaN?

I found a bug in the codebase I'm working in where they check for equality of two doubles (first, second) using first == second, but these 2 variables could be NaN. If both variables were NaN the ...
roulette01's user avatar
  • 2,054
0 votes
1 answer
151 views

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 ...
Mike Nakis's user avatar
0 votes
1 answer
76 views

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 ...
gavenkoa's user avatar
  • 46.1k
1 vote
1 answer
166 views

What are equality witnesses like `Type.eq` / `Typing_equal.equal` used for?

What is type (_, _) eq = Equal: ('a, 'a) eq (source) useful for? I've used refl in Coq, but haven't needed anything like in OCaml yet. The type is defined and in an upcoming version of the OCaml ...
Max Heiber's user avatar
  • 14.6k
1 vote
1 answer
131 views

Is it possible for byte arrays, returned from BufferedStream.Read(), to have different lengths?

We have this old code in our repo: bool BufferByteCompareFiles(string filePath1, string filePath2) { int bufferCapacity = 0x400000; var firstFile = File.OpenRead(filePath1); ...
notarobot's user avatar
  • 119

1
2 3 4 5
43