473,785 Members | 3,285 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

at what complexity, a comparison fails ?

hello,

I had a program that worked perfectly well.
In this program modules were dynamically added,
just by putting the file in a predefined directory.

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.
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 ??
And in general, how complex might a list be to make a valid comparison,
or what are the rules ?

thanks,
Stef Mientki
Dec 31 '07 #1
4 1382
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
Dec 31 '07 #2
On Mon, 31 Dec 2007 11:45:55 +0100, Stef Mientki wrote:
hello,

I had a program that worked perfectly well. In this program modules were
dynamically added, just by putting the file in a predefined directory.

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.
What do you mean "stopped working"?

So it seems that comparing a too complex value isn't allowed. the
variable was something like:

A = [ <ndarray>, <ndarray>, ..., [<color>,<color> ,...], [<float>,
<float>, ... ] ]
Doesn't seem complex to me, and I daresay probably not to Python either
-- although a lot depends on what "ndarray" and "colour" are.

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 "crashes"? Explain please.
It does seems to work, if A only contains 1 array.

Why am I not allowed to compare A and A_prev ?? And in general, how
complex might a list be to make a valid comparison, or what are the
rules ?
As complicated as you like.

--
Steven
Dec 31 '07 #3
On Dec 31, 2:45 am, Stef Mientki <stef.mien...@g mail.comwrote:
So what I need was something like:
if A != A_prev :
... do something
A_prev = A
If A_prev is not declared prior to the if statement, you will get an
error when you try to compare the non-existing variable to A. This
code will work, at least for the snippet you provided.
A_prev=""
if A != A_prev :
... do something
A_prev = A
Please cut and paste the exact error message in the future.
Dec 31 '07 #4
Stef Mientki wrote:
hello,

I had a program that worked perfectly well.
In this program modules were dynamically added,
just by putting the file in a predefined directory.

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.
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 ??
And in general, how complex might a list be to make a valid comparison,
or what are the rules ?
I suspect that some of the objects in A have either undefined (or ill-defined)
comparison methods, so that the overall list comparison does not do what you
expect. I'm not sure what ndarray and color are, but check their comparison
methods (you know, __cmp__, __lt__, __eq__, etc). (If that isn't clear, please
see http://effbot.org/pyref/__lt__.htm.)

--Hans
Dec 31 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1909
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool This article makes a detailed comparison among SourceAnyWhere, SourceOffSite, VSS Remoting and possible others. Keywords: VSS Remote Access, VSS Web Access, VSS Internet Access,
4
2816
by: Generic Usenet Account | last post by:
Consider two entities A and B such that there is a 1:n association between them. I mean that associated with each instance of A there are up to n instances of B. Currently in our software we are using an STL map in which instances of A are the key and each value is a set (STL set) of instances of B. There is some thought now that we should instead have a "transpose" of this data structure. By this I mean that the key should be an...
10
7259
by: chandra.somesh | last post by:
Hi I recently had to write a small code in a competition ,but my code was rejected cause it failed in 1 of test cases. The problm was .....we are given vector of strings....each string consists of either 1 or 2("12122" 0r "2121" so on..)...i had to find the that string where percentage of '1' is minimum.Now the problem and solution both are trivial but i was told that comparing double with < or > sign doesn't ensure a correct...
5
5691
by: mayamorning123 | last post by:
A comparison among six VSS remote tools including SourceOffSite , SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool This article makes a detailed comparison among SourceAnyWhere 4.0, SourceOffSite 4.1, VSS Connect 1.5, SourceXT 2.1, VSS Remoting 2.5,
5
3931
by: junky_fellow | last post by:
How do we calculate the complexity of an algorithm? Am i right if i say the complexity of an algorithm is the number of comparisons done in that algorithm? thanx in advance .......
0
1421
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool This article makes a detailed comparison among SourceAnyWhere, SourceOffSite, VSS Remoting and possible others. Keywords: VSS Remote Access, VSS Web Access, VSS Internet Access,
26
7214
by: Lionel B | last post by:
Hi, Anyone know if the Standard has anything to say about the time complexity of size() for std::set? I need to access a set's size (/not/ to know if it is empty!) heavily during an algorithm and was thus wondering whether I'd be better off tracking the size "manually" or whether that'd be pointless. Thanks,
1
6321
by: Lars B | last post by:
Hey guys, I have written a C++ program that passes data from a file to an FPGA board and back again using software and DMA buffers. In my program I need to compare the size of a given file against a software buffer of size 3MB. This is needed so as to see which function to use to read from the file. As the files used range from very large (>30GB) to very small (<3MB), I have enabled large file support and I obtain the file size by using the...
5
1195
by: Joris van Lier | last post by:
Given two implementations of an algorithm how do I determine the relative computational complexity of each? Are there tools that can determine the relative performance of two algorithms or implementations? Joris van Lier
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.