Questions tagged [inequality]

Inequalities are mathematical statements involving an order relation between two quantities, such as 'a is less than b' or 'a is greater than or equal to b'. These are usually expressed in symbols, i.e. 'a < b' or 'a>=b'.

273 questions
254
votes
2 answers

">", "<", ">=" and "<=" don't work with "filter()" in Django

With = below, I could filter persons by age: qs = Person.objects.filter(age = 20) # ↑ Here But with >, <, >= and <= below, I couldn't filter persons by age: qs = Person.objects.filter(age > 20) …
Finglish
  • 9,692
  • 14
  • 70
  • 114
127
votes
4 answers

Should __ne__ be implemented as the negation of __eq__?

I have a class where I want to override the __eq__ method. It seems to make sense that I should override the __ne__ method as well. Should I implement __ne__ as the negation of __eq__ as such or is it a bad idea? class A: def __init__(self,…
Falmarri
  • 47,727
  • 41
  • 151
  • 191
104
votes
4 answers

What is the equivalent of "!=" in Excel VBA?

The problem is that != does not work as a function in excel vba. I want to be able to use If strTest != "" Then instead of If strTest = "" Then Is there another approach to do this besides !=? My function to mimic != is Sub test() Dim intTest As…
HelloWorld1
  • 13,688
  • 28
  • 82
  • 145
48
votes
4 answers

Testing for inequality in T-SQL

I've just come across this in a WHERE clause: AND NOT (t.id = @id) How does this compare with: AND t.id != @id Or with: AND t.id <> @id I'd always write the latter myself, but clearly someone else thinks differently. Is one going to perform any…
ninesided
  • 23,085
  • 14
  • 83
  • 107
37
votes
6 answers

Using the correct, or preferable, not equal operator in MySQL

Which of the two (semantically equivalent) ways is preferable to test for inequality? 'foo' != 'bar' (exclamation mark and equals sign) 'foo' <> 'bar' (less than and greater than chevron symbols together) The MySQL documentation clearly indicates…
Rob Van Dam
  • 7,812
  • 3
  • 31
  • 34
30
votes
8 answers

SQL Server RowVersion/Timestamp - Comparisons

I know that the value itself for a RowVersion column is not in and of itself useful, except that it changes each time the row is updated. However, I was wondering if they are useful for relative (inequality) comparison. If I have a table with a…
David Pfeffer
  • 38,869
  • 30
  • 127
  • 202
21
votes
5 answers

inequality comparison of numpy array with nan to a scalar

I am trying to set members of an array that are below a threshold to nan. This is part of a QA/QC process and the incoming data may already have slots that are nan. So as an example my threshold might be -1000 and hence I would want to set -3000 to…
Eli S
  • 1,379
  • 4
  • 14
  • 35
18
votes
3 answers

Filter data.table using inequalities and variable column names

I have a data.table that i want to filter based on some inequality criteria: dt <- data.table(A=letters[1:3], B=2:4) dt # A B # 1: a 2 # 2: b 3 # 3: c 4 dt[B>2] # A B # 1: b 3 # 2: c 4 The above works well as a vector scan solution. But I…
MattLBeck
  • 5,701
  • 7
  • 40
  • 56
14
votes
1 answer

Why do the Python docs say I need to define __ne__ when I define __eq__?

According to the Python docs: "when defining __eq__(), one should also define __ne__() so that the operators will behave as expected". However, it appears that Python computes __ne__ as not __eq__ automatically: In [8]: class Test: def…
asmeurer
  • 86,894
  • 26
  • 169
  • 240
13
votes
3 answers

how to effectively run two inequality filters on queries in app engine

I'm aware that app engine has the restriction of "Inequality Filters Are Allowed On One Property Only" as described here: http://code.google.com/appengine/docs/python/datastore/queriesandindexes.html#Introducing_Indexes However is there some way to…
Joey
  • 7,537
  • 12
  • 52
  • 104
11
votes
2 answers

R data.table join with inequality conditions

I would like to subset my data based on multiple inequality conditions using the data.table package. The examples in the data.table manual show how to do this with character variables, but not with numeric inequalities. I also see how to do this…
user1491868
  • 596
  • 4
  • 15
  • 42
11
votes
3 answers

RegEx for "does not begin with"

The following checks if it begins with "End": if [[ "$line" =~ ^End ]] I am trying to find out how to match something that does not begin with "02/18/13". I have tried the following: if [[ "$line" != ^02/18/13 ]] if [[ "$line" != ^02\/18\/13…
dalawh
  • 886
  • 8
  • 15
  • 37
10
votes
1 answer

Python SymPy: Error while solving inequality

Problem: I am trying to solve an inequality to obtain a variable coeff_rw, which is the value of the symbol rw satisfying the inequality. This value should be in terms of other symbols (variables) that are defined in the following code. I am first…
user238469
10
votes
2 answers

Plotting a number of inequalities as planes

I would like to plot a number of planes, each is an inequality. After I have plottet all the planes, I would like to have them combined, and color the area inside these lines. Image drawing a lot of 3d lines and coloring the area inside - this is…
Thorst
  • 1,590
  • 1
  • 21
  • 35
10
votes
1 answer

Python Matplotlib: Drawing linear inequality functions

How can I draw an area bounded by some linear inequality functions using matplotlib. For example, if we have 3 functions: y <= -2+4x, y >= 2+0.5x, y <= 7 -0.3x I would like to draw something similar as wolfram alpha does:…
N10
  • 429
  • 2
  • 4
  • 17
1
2 3
18 19