Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 68 Online
OpenStudy (anonymous):

OK I'm in assignment 12, and the assignment explicitly says under the virus methods "Raises a NoChildException if this virus particle does not reproduce." I expect some virus particles to not reproduce, that is the method is even there. every time I hit the exception my program stops (as I expect it would) is there anyway to have my program run and fulfill the assignment specifications. until now I've had no trouble doing exactly as the assignment prescribes I don't think it'll help but the function specific code http://dpaste.com/566950/

OpenStudy (anonymous):

figured out the answer, some try: except: leaving the question here for anyone who has this problem here is update from simple patient http://dpaste.com/567020/

OpenStudy (anonymous):

wow assignment 12! Thats the farthest I've seen anyone get. I'm on assignment 10 but I'll check back here when I get through it all. Way to make it to the end!

OpenStudy (anonymous):

nope, it runs fine right now, are you running 3.1? might change things

OpenStudy (anonymous):

Actually I figured the mistake I was making, however, now the exception gets also appended to the list of viruses and in the next update it gets an error...

OpenStudy (anonymous):

yea, I used to get that, its why i started this question, I needed to do the "try: append()" "except: pass" when the error happens, it comes up one lever, the program sees teh except claus and passes instead of the append

OpenStudy (anonymous):

newList = self.viruses[:] for virus in newList: if virus.doesClear(): newList.remove(virus) self.popDensity = len(newList)/self.maxPop Reproduction = [] for virus in newList: try: Reproduction.append(virus.reproduce(self.popDensity)) except NoChildException: pass

OpenStudy (anonymous):

WHen I do this I still get the exception appended...

OpenStudy (anonymous):

wait, the exception appended? not a None Type error? are you returning the error or raising it?

OpenStudy (anonymous):

in the list of viruses (which I called Reproduction) it appendes something like this: reproduction [<__main__.SimpleVirus object at 0x5ca3d10>, NoChildException(<type 'exceptions.Exception'>,)]

OpenStudy (anonymous):

I see what you mean.... in update I have top raise the error instead of returning it. Thanks!

OpenStudy (anonymous):

so are you on assignment 12 as well or were you just testing my code out?

OpenStudy (anonymous):

i am in pset 12 right now i am in problem 5

OpenStudy (anonymous):

Do you have results to compare? I'm not sure if my simulations are right.

OpenStudy (anonymous):

not yet, I'm on problem 3 right now, I'll catch up sooner or later. I'm also eager to compare results

OpenStudy (anonymous):

ok problem 3 flew by, problem 4 only gave me one issue, adding the drug didn't seem to do much, going to have to do problem 5 to verify if the treatment was just too late or an error in my code, i know the drug does something, it just looks insignificant on my graphs

OpenStudy (anonymous):

For ,e it changed from about 520 to 370, so there was a change but not huge. DOes this sounds about right?

OpenStudy (anonymous):

OK definitely have some bug in the code, the population isn't dropping when I add a new drug to the prescription, I've written problem 5 and the histogram is just a mess of over lapping values (i put each delay on a different colour) here is my virus and patient classes, in theory you can substitute them for your own and run it, see if its in my classes or in my test simulation where something is going wrong http://dpaste.com/568959/

OpenStudy (anonymous):

OK also fixed this problem, my reproduce function stopped the reproduction if the virus DID have a resistance to the medication in question, fixed that, now I'd like to compare my charts, haven't done problem 7

OpenStudy (anonymous):

I think we understand the instructions of the reproduce function very differently... You have 1-self.mutProb if it is resistant and self.mutProb if it is not resistant. As I understand, the probability of changing (from fakse to true or from true to false) should be the same. http://dpaste.com/570956/

OpenStudy (anonymous):

Also I noticed differences in getResistPop. A minor bug in your code is that you return outpuz instead of output. But more importantly I think your code only works if you have 1 drug to consider if you have maany drugs you need to count a virus as resistant only once it it is resistant to more than one drug. http://dpaste.com/570961/

OpenStudy (anonymous):

As I said in a previous post in problem 4 I get a difference from about 520 to 370 with the introduction of the drud. Does that sound similar to what you get?

OpenStudy (anonymous):

Here are a couple of simulations from problem 5

OpenStudy (anonymous):

oh i fixed those bugs while trying to find out why the drug wasn't doing anything, I searched that code for everything i could find wrong, it runs just fine now, with what I'd expect. i'm just curious if i got the right answer, I'm actually curious what all your histograms look like, and if they are close to mine. PS my problem 4 chart looks slightly different then yours, blue and green line are the resistant pop, before and after the administering of the drug, realized they weren't the same colour just now

OpenStudy (anonymous):

damn! that means I have some bug somewhere... Can you look through it and tell me if you see something wrong? http://dpaste.com/571106/

OpenStudy (anonymous):

how does that mean you ahve a bug? I could have a bug, we simply have different answers, doesn't mean i'm right

OpenStudy (anonymous):

I'm away from a computer with python installed, so i'll have to debug your code later, hopefully we can come to a concensus about what is right

OpenStudy (anonymous):

I can't see anything that is wrong with your code, but when i switch out my virus for yours, from what i gather your reproduce has an error in it, i can't find where the error is though but i know where it is YAY! for classes

OpenStudy (anonymous):

That means you are sure is not in patient or problem4?

OpenStudy (anonymous):

well because all the inputs are the same and all the outputs should be the same i can swap in you classes and function systematically until the answer pops up wrong, your reproduce method under resistant virus had an error big enough to effect the output of the program significantly (although i couldn't see it) granted your problem 4 could have had the issue, throwing out slightly different graph i can't compare at a glance, your patient seemed to have no effect at all on the output of my program

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!