Numeric don't compare arrays correctly
a_salnikov at yahoo.com
Fri Jun 6 22:18:52 CEST 2003
"Alexander Schmolck" <a.schmolck at gmx.net> wrote in message
news:yfsbrxbufxn.fsf at black132.ex.ac.uk...
> Maurix <maurix78_remove_this_ at wanadoo.es> writes:
> > Hi to all,
> > I'm new in python world and in this group too so, nice to meet you all
> > I have a problem with Numeric: (linux, python2.2, numeric 21.0)
> > It seem that don't compare correctly arrays.
> > See at this session:
> > >>> a=array([1.1,2.2,3.3,4.4,5.5])
> > >>> print 2.<a<4.
> This is just a python wart, reflecting the unhappy interaction between two
> sometimes convinient but somewhat messy language features.
> Feature 1:
> a < b < c in most programming languages is the same as (a < b) < c. Python
> instead treats such chained comparisons specially to make them behave as
> typical in (the somewhat messy) standard math notation.
> So ``1 < 3 < 4`` is False and not True, because it is treated as
> ``1 < 3 and 3 < 4``.
'1 < 3 and 3 < 4' cannot be False like '1 < 3 < 4` (in Python at least).
Problem is in comparing apples and oranges, objects can be in any order
More information about the Python-list