Re: at what complexity, a comparison fails ?



On Mon, 31 Dec 2007 11:45:55 +0100, Stef Mientki wrote:

Now one of the interface mechanisms was to see if some parameter was
changed in a an instance,
by comparing the value from the instance with its previous value

This went all well, untill I added a too complex variable,
then the program stopped working, without generating exceptions.

So it seems that comparing a too complex value isn't allowed.

Then you get the wrong impression.

the variable was something like:

A = [ <ndarray>, <ndarray>, ..., [<color>,<color>,...], [<float>,
<float>, ... ] ]

So what I need was something like:
if A != A_prev :
... do something
A_prev = A

And this crashes, or at least it doesn't work but also doesn't generate
exceptions.
It does seems to work, if A only contains 1 array.

Why am I not allowed to compare A and A_prev ??

You are allowed and you do in the above code.

And in general, how complex might a list be to make a valid comparison,
or what are the rules ?

There are no rules about the complexity. Lists are compared element wise.
If the lists are of the same length and all elements at the corresponding
indexes compare equal, the lists are considered equal.

Ciao,
Marc 'BlackJack' Rintsch
.



Relevant Pages

  • Re: Can a simple a==b hang in and endless loop?
    ... comparing only two 'values'. ... Coming from C or Javascript one would ... over all elements of the lists. ... 'is' does the C, Javascript job when comparing lists, but I mean it fails to give fully predictable results when applied to elements of lists in case there exist duplicate objects with same 'value' i.e. e.g. there are two different objects storing the integer value 1, what I mean can happen when there is enough other code between the Python code lines assigning the integer value 1 to a list element or any other identifier. ...
    (comp.lang.python)
  • Re: expandable test if token-lists consist of the same set of tokens?
    ... \detokenize-ation of the two lists are the same, ... Check if it is possible to strip off surrounding braces (a ... I think you can test this by comparing \detokenize ... Otherwise terminate with \@secondoftwo. ...
    (comp.text.tex)
  • Compare two datasets and extract unique records from each
    ... compare two lists with single columns, but I need a very basic guide ... There are no duplicate records within each dataset, ... so it's not a matter of comparing Row 1 to Row 1 and so on. ... One (or a way to highlight these records). ...
    (microsoft.public.excel.worksheet.functions)
  • RE: Compare two datasets and extract unique records from each
    ... Have you tried Advanced Filter Unique Records? ... compare two lists with single columns, but I need a very basic guide ... so it's not a matter of comparing Row 1 to Row 1 and so on. ... One (or a way to highlight these records). ...
    (microsoft.public.excel.worksheet.functions)
  • Re: List Flatten
    ... Removing them (we expand lists only) we obtan the short ... In may book all three versions (Alex Martelli's yours and mine) use the ... _same_ flattening algorithm with _different_ methods to test for atomicity. ... somebody thought that comparing them was a good idea :-), but again, it ...
    (comp.lang.python)