« first day (2138 days earlier)      last day (2825 days later) » 

12:00 AM
combinations with replacement = comb(n+k-1,k), so for limit <10^6 that means anywhere from k=2 to 6 digits, and the selection set {1,3,7,9} is of size 4, so comb(4+2-1,2) + comb(4+3-1,3) + comb(4+4-1,4) + comb(4+5-1,5) + comb(4+6-1,6) = 205
 
hmm. I started noticing that upvoted answers don't bubble to the top anymore.
strange.
 
basically that was what I was thinking: if numbers greater then 9 can only contain 1, 3, 7, 9 you could use the carthesian product of the numbers using itertool.product
 
@idjaw Do you have it sorted different?
I've had that happen before.
 
hmm...maybe. Let me see
durr
 
@MarcusS Thanks- it's been quite a few years since I took combinatorics
I'll have to freshen up on that
 
12:01 AM
that was it. well...that was silly. Thanks, Morgan.
 
Hahaha, no problem.
 
OK everyone, I should get going now, but thanks again for your insight and help
rhubarb!
 
DSM
Rhubarb for you.
 
12:14 AM
I think I found an odd little bug in a package I'm using. There seems to be a check for duplicate test ids. Turns out that because I'm inheriting a test class, the check is detecting it as a duplicate, when it shouldn't.
I'm thinking something along the lines of determining whether this "duplicate" is being inherited as to not flag as a duplicate
 
DSM
What's the current duplicate criterion?
 
trying to run this check inside my IDE so I can step in to the code and follow it more closely
 
DSM
Hmm, so when you inherit it's not picking up the right id creation logic?
 
here is the output that comes from tox yielding the error
ValueError: Duplicate test ids detected: {'virtualpdu.tests.unit.pdu.test_base.TestPDU.test_power_off_notifies_core': 2,
 'virtualpdu.tests.unit.pdu.test_base.TestPDU.test_power_on_notifies_core': 2,
 'virtualpdu.tests.unit.pdu.test_base.TestPDU.test_reboot_notifies_core': 2}
TestPDU has a series of tests. Then I have another class that inherits TestPDU
when I don't inherit and just paste over the same test cases, everything passes
 
DSM
Are you super/init-ing? (I'm trying to figure out why it's not increasing the ids appropriately.)
 
12:20 AM
I'm not actually.
ultimately it looks like this:
class TestPDU(base.TestCase):
    def setUp(self):
        # stuff
    # test methods

class APCTest(TestPDU):
    def setUp(self):
        # specific setUp code here
So, ultimately, the setUp code in APCTest will be used when running the test method from TestPDU
I made a mistake....sorry
I am supering
crap...
 
Tonight is just not your night, huh?
 
heheh....I was hoping that would have fixed my problem, but it resulted in the same problem.
and I can't run tox inside intelliJ it seems...so i can't easily trace the code
gonna have to throw in some print statements in the code and just run tox
see what I can figure out.
 
DSM
I'm just trying to figure out where it's picking up the id from in the first place.
 
that's why I'm trying to print out suite_or_case
and work backwards form there
 
DSM
(3.5) dsm@notebook:~/coding/idd$ python -m testtools.run newtest.py
Tests running...
hello
hello2
test1
hello
hello2
test2
hello
test1

Ran 3 tests in 0.001s
OK
Hmm, I need to work harder to reproduce the problem. :-/
 
12:36 AM
How come you can't run Tox inside PyCharm?
 
DSM
Using the above caller, sorted_tests doesn't even get called, so the problem isn't manifested. I need to find out what calls it.
 
I run py.test in it all the time.
 
For a practice fitness app I am making -- do you guys think this schema makes sense? i.stack.imgur.com/EJ3T4.jpg
 
@MorganThrapp oh man...never bothered doing that...."no module named tox"....need to do some configuratrix
 
@idjaw It's gotta be installed in the default project venv.
On a completely unrelated note, I'm currently in the middle of a mafia movie kick, anyone have any recommendations?
Watching Analyze This right now.
 
12:45 AM
Analyze This is about the mafia? thought that was some silly comedy
 
@MorganThrapp oh duh. that makes sense. It's using the venv created by tox and that venv doesn't have tox. :D
weeee
 
@JGreenwell Yeah, it's Billy Crystal playing Robert De Niro's therapist. It's a sendup of mafia movies.
 
oh, mob shrink - I see
 
@idjaw Ahhh, that would make sense. I haven't used Tox before.
 
my wife probably loves it - she's a big fan of both those two
 
12:47 AM
It's fantastic. As long as you pretend the sequel never happened. :P
 
isn't that usually the case? ;)
 
Very weird, and you have to really know your classic mafia movies to get it, but worth a watch.
Heh, true.
 
DSM
I give up, I can't reproduce the problem, it seems to work for me. :-/
 
C'mon, idjaw, no mcve? ;)
You're lucky you're pretty.
 
:) hehe
thanks for trying it out @DSM. There is in fact duplicate shenanigans happening. But I don't know why its duplicating the test cases
virtualpdu.tests.unit.pdu.test_base.TestPDU.test_power_off_notifies_core id=0x107bebb90
virtualpdu.tests.unit.pdu.test_base.TestPDU.test_power_on_notifies_core id=0x107bebc10
virtualpdu.tests.unit.pdu.test_base.TestPDU.test_reboot_notifies_core id=0x107bebc90

virtualpdu.tests.unit.pdu.test_base.TestPDU.test_power_off_notifies_core id=0x107bebd90
virtualpdu.tests.unit.pdu.test_base.TestPDU.test_power_on_notifies_core id=0x107bebe10
virtualpdu.tests.unit.pdu.test_base.TestPDU.test_reboot_notifies_core id=0x107bebe90
but, it is not using the ids
because the ids are clearly different
 
12:57 AM
Are they classes? Or functions? Could it be some weird hash collision?
 
DSM
Do you mean id like id(x), the memory location, or id like obj.id()?
 
seems to be obj.id()
so, not the id I was thinking about as well.
 
DSM
It makes sense that parent classes have their tests duplicated in the children (because they inherit them, obv.) But I don't get why the inheritance is causings dups for you but not for me.
 
I'm going to make an isolated test to replicate this and see if there is something else happening here that interfering
thanks for stabbing away at this DSM. :)
 
DSM
Ehh, in the last while I've relearned some stuff about unittests, made my first-ever tox.ini, and watched some TV. Not a bad way to kill half an hour. :-)
 
1:04 AM
hehe
 
Can you relink the code? I can give it a look if you want.
 
DSM
I should go escape, though. Don't forget to ping me with how the story ends!
Evening rhubarb for all!
 
sigh
â–¶ python -m testtools.run t
Tests running...
sdf
sdf

Ran 2 tests in 0.007s
OK
 
Night, DSM.
Hahaha, of course. The joys of a Heisenbug.
 
rbrb DSM :) Thanks again
 
1:07 AM
night DSM
 
@MorganThrapp this is the code that runs to find the duplicates
that code is straight forward and the data passed to that method I can clearly see that they are coming in twice as expected since I'm inheriting
 
Hey, Martijn.
Thanks again for passing my resume along! They got in touch with me a couple hours ago.
@idjaw Where are the cases coming from?
 
it's my own code. The diff is small, so I'll share. Sorry, it's not a small snippet example I can show here: github.com/internap/virtualpdu/pull/6/files
this is totally nowhere in the MCVE category :D
test_apc_rackpdu inherits from test_base
my tox run that validates for the duplicate tests ends up realizing that test_base is "used" twice
 
The best resume is anyone that is handed to "someone you know"
 
yup
 
1:10 AM
btw. I never looked at the resume SO makes for you - it is really bad
 
Huh, I can't even find where .id() is defined.
It looks like you may need to pass an explicit test id? github.com/testing-cabal/testtools/blob/master/testtools/…
 
oh...interesting. I just ran my code that inherits from base. Three tests should run...aaaand
â–¶ python -m testtools.run virtualpdu.tests.unit.pdu.test_apc_rackpdu
Tests running...

Ran 6 tests in 0.009s
OK
 
my friend asked me if he could borrow my notes and got annoyed when I handed him a file - he still can't believe people take notes by hand anymore
 
6 tests! it's running things twice!!! There has to be something VERY obvious I'm doing wrong here.
 
Huh, yeah, I have no idea. Nothing in that repo jumps out to me as being wrong.
 
2:22 AM
SOD, you offer so many avenues for abuse it feels like trying to carry water in a bucket full of holes
 
2:40 AM
no takers for the schema? D:
 
3:13 AM
only thing I see is the use of value as a field name is a bad idea (I have no idea whether one refers to body fat or weight) use something more descriptive so people can tell how it is linked easier
 
It's whatever the user defines for that particular biometric
 
what metrics are there beside body fat and weight? (someone wanting muscle mass would need body fat and weight) - I would make those separate fields...actually when I did work out I kept track of both
 
Whatever the user wants to log -- circumference of any given muscle, weight, percentages, resting heartrate, happiness/mood level, blood glucose, whatever
Basically a "log whatever you want" section -- the only queries performed on this table are for when you are wanting to graph the data over time, in which case it's just taking all the timestamps and values corresponding to a particular biometric_id
 
Just a question: I guess that's fine if the measurements are all of the same type (one number), but what if you need something else? Are you making it needlessly generic?
 
if it is that opened ended a measurement then fine, other then that I am on deadline and only have time for a quick glance
 
3:24 AM
What do you mean?
 
As in you could record each type separately in its own table, and then if you need to query them all in a big homogenised list then make a view over the top, but at least then you can store different things in different ways if you need to.
If you really never need to do the latter then I doesn't matter, but it's worth considering
 
For example: i.stack.imgur.com/kLscc.png -- or i.stack.imgur.com/SguGu.png (UI details will change later -- mostly focusing on function for now)
 
 
1 hour later…
4:47 AM
zzz
 
 
1 hour later…
5:48 AM
cbg!
 
6:09 AM
happy internuts day
 
6:52 AM
cbg
 
7:34 AM
cabbage all
 
cbg
hehe...
3
A: Time complexity calculation for my algorithm

Antti HaapalaYour algorithm has time complexity of O(kn) where k is the number of unique characters in the string. If k is a constant then it is O(n). As the problem description clearly bounds the number of alternatives for elements ("assume lower-case (ASCII) letters"), thus k is constant and your algorithm ...

remember, python is slow, never do anything in python which can be done in c.
 
7:50 AM
@AnttiHaapala everything you can do in Python you can do in C.
 
cbg
 
@MartijnPieters :P
 
I personally prefer to do everyting in assembly
 
cpython was done in C
python programs are just data to a C program.
 
8:05 AM
@khajvah I prefer to use butterflies.
 
@MartijnPieters how many times do we need to post that pic each day :D
 
lol nice
 
@AnttiHaapala once more, apparently ;-)
 
I just got reminded again that django orm sucks
I need a query which doesn't exactly return an instance of a model
 
It's been posted 11 times so far. Or 12, since my message is not yet in that result set yet.
 
8:11 AM
How can I numpy.genfromtxt the content presented at api.bitcoincharts.com/v1/…?
 
@khajvah what do you mean, django is perfect
insert a random anecdote from a developer who didn't have any problems with django.
 
Nvm
 
the only time you won't have a problem with django is if your application is strict CRUD web app with nothing special
 
@khajvah aren't all web applications like that?
"I've written a blog for my cats and django surely was a great choice"
 
sure
:D
 
8:15 AM
To be fair to Django, it's got a lot of bells and whistles and a thriving ecosystem. But it's far too heavyweight for some applications, for which Flask is better-suited.
 
heavyweight?
 
the irony is that for those applications, Django is too bloated, making it completely useless
 
the orm is featherweight, rather.
 
8:29 AM
It seems that my answer on relative imports has always been correct, only a little incomplete. But still, can anyone read it and tell me if there're any inaccuracies or other solutions? stackoverflow.com/a/28154841/2301450
 
8:40 AM
The good thing about Django is there are lots of things that work with it that are fairly mature
 
@AndrasDeak Ah, I studied Physics at University :)
 
the bad thing about it that those fairly mature things only work with django
 
Cabbage!
 
The "nice" thing about something like Django is that it has a shared structure so everyone using it has a fairly good idea of what is going on in another project.
Which does foster community and collaboration.
cbg(poke)
 
8:56 AM
hmm
I've got some silly library ideas.
One is an AST library that would allow one to have AST templates
another is pretty old idea but I think I iwll do it soon,
called "algometer"
so algometer could easily settle once and for all the questions about time complexity of a function
 
brief cabbage
@IntrepidBrit poor thing;)
 
9:14 AM
@vaultah well I upvoted, and took back
it is not completely correct, the relative imports do not work like that in Python 3 any longer, and you shouldn't use them in Python 2 either
lol :D
@vaultah a sec, wrong answer :d
"wait, this wasn't written by vaultah" :D
 
:D
lol
 
haha
 
"should've nuked the other one"
 
I was like "why does vaultah call this only somewhat incomplete" :D
and I've upvoted your answer already it seems :D
 
9:18 AM
Cabbage
 
cabbage
 
Naturally I'd put the setup.py UP there... perhaps a tl;dr link section or something
can one link to a heading in stackoverflow answer?
 
Heading? No anchors, no. But the share links point to the top already
 
to me they do:P
 
9:19 AM
@AndrasDeak the answer is already several screenfuls
 
yes
 
Can anyone reproduce this error? At first I thought it was going to be the old "OP has a script with the same name as the imported module" but that doesn't seem to be the case here. stackoverflow.com/questions/39096185/using-pycrypto-python
 
@PM2Ring butt hat \o/
awww you ruined it:(
 
Sorry. :)
 
works in 2.7.6 on ubuntu
i.e. can't reproduce the error
and Crypto 2.6.1 like OP
 
9:26 AM
@AnttiHaapala yeah, maybe I'll do that
 
these path hacks are awful
 
I don't suppose there's any point closing it as "no repro" though. It's not attracting answers, and maybe someone else will be able to reproduce it. I was kinda hoping that the OP would comment that they're running it in a weird VM or on some bizarre *nix variant, but they've ignored my request for which OS / distro they're using.
 
@PM2Ring that just further says "close it now" to me:P
 
I've got one idea
perhaps crypto installation has failed
and there is a left-around .so from older version
 
well our working installs work, so there's a huge chance that OP's installation is indeed borkd:)
 
9:31 AM
I can't even find a module called Crypto - only crypto
 
Try reinstalling crypto. The _counter in question is an extension module written in C; chances are you've got a left-around module from an older version somewhre. — Antti Haapala 1 min ago
 
And that doesn't have a Random in it ...
 
@holdenweb it seems to have been preinstalled on my python
must be batteries included
 
no it is not, it is an extension module from pypi
 
really?
 
9:33 AM
pycrypto IIRC
really period.
 
:P
rhetorical question
 
I mean, your OS has batteries included.
 
I'm just thinking about when it might have gotten installed
 
it is a dependency for some-heap-of-crap-project (tm)
 
I did install a bunch of crap from apt when I encrypted my home folder, so there's a contender:P
 
9:39 AM
@holdenweb Sorry, I should've mentioned that it's a 3rd party module: dlitz.net/software/pycrypto
 
9:55 AM
but so is crypto
 
10:09 AM
I have an sql query with 10 joins
should I feel bad about myself?
 
no
you should feel normal.
if you didn't have a query with 10 joins, you should feel ashamed.
 
10:31 AM
 
@poke YoYo wallet obviously means that your wallet will be on a yo-yo diet when working for them
 
:D
 
10:50 AM
meter = algometer.Algometer(first_unique_character)
meter.arguments(lambda n: string.ascii_lowercase * n)
meter.timeit()
sketching api for my lib.
 
@khajvah don't feel bad. I've seen SQL queries that run to almost two pages. I've never written one, but I've seen them. People abuse databases in all sorts of ways. You're just using it for what it was designed for.
 
nice, thanks
 
anyone here knows how to make pandas dataframe from list?
currently, it cannot separate my columns based on commas. Any help?
 
@khajvah @IljaEverilä is expert on horrible queries (not horrible in quality :D)
 
11:05 AM
@tourist how is the data presented? I don't see why Pandas should be having to cope with commas if it's already in a list.
 
strings2 = list()
strings2.append("one, s")
strings2.append("two, a")
this creates a frame of a single column:
 
>>> pandas.DataFrame([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]], columns=['a', 'b'])
   a   b
0  1   2
1  3   4
2  5   6
3  7   8
4  9  10
>>>
/me hopes that wasn't too long a paste ...
 
@holdenweb doesn't work for list like i created above
 
I'm not psychic. What does your data look like. "A list" is not a sufficient description
 
["one, s", "two, a"] I assume
 
11:16 AM
Assume away. I want hard information
 
one, s,
two, a,
three, m,
As robert described, yes
 
@holdenweb ...okay
 
got it! df = pd.DataFrame([x.split(",") for x in list])
but, is it the optimal way?
 
Shouldn't you split on ", " because there's a space?
 
right, but the result looks same to me. i might be wrong
 
11:23 AM
The results will be strings. Spaces aren't visible when they are printed.
 
i see, thanks :)
 
11:59 AM
does 2to3 handle things like f.read() returning a byte-string?
 
@FlorianMargaine no
nothing can handle the bytes/unicode distinction
if it could be dealt automatically, then there would not really have been for this big divide between python 2 and 3; there could've been a proper compatibility layer
 
Anyone tell me offhand how to insert vertical whitespace between successive matplotlib plots, please?
 
12:08 PM
I never manage to do anything in matplotlib without hours of googling :D
 
12:20 PM
@AnttiHaapala first rule of SO: if you can't do it in 5 minutes, write a question.
 
0
A: Skip new line while printing with ternary operator in python

Antti Haapalafrom __future__ import print_function print('A' if True else 'B', end=' ') Future imports/Python 3 solved your problem efficiently, and the strange statement syntax is just a bad memory from past. As a plus, you're now forward-compatible!

my take: every time python 2 noob has a problem with python 2 features, shamelessly plug Python 3.
and like: wat? that question worth an upvote :D
lol
I wrote this
> [...] to prevent going into the new line one could simply add a comma in the end
The solution is in your question already. One could simply add a comma in the end:
 
I had all our developers fill out a self-assessed "Programmer Competency Matrix", and now I'm creating spider charts for each one individually, overlaid on the group average. Interesting ...
 
my datastructure fu is mostly level 2 :(
 
Annoyingly it chops the name off when I save it, but that's me and the average in red
 
hmm
half of the level 3 stuff is trivial,
 
12:31 PM
Howdy! I am fiddling around with SqlAlchemy and a Sqlite database for a simple text based game I am making with a friend just for laughs ( not meant for actual distribution or anything ). I managed to get a row of data back --- [(2, 'test', 1, None, 'test', 'test', None, None, None, None, None, 'test', 1)] --- If I recall correctly [ ] is list and ( ) are tuples... so that means the return I got is wrapped up twice... Is there any neat/clean way to break these items apart?
 
some of it is quite arcane.
 
Or should I just use split after making it a string?
(( ps ty for any thoughts regarding this ))
 
@ToddLewden no, you didn't get this wrapped up twice.
the return value is list of tuples
that is a list of n tuples where n happens to be one
 
@AnttiHaapala , Oh , it only looks odd to me because I only needed/got a single item returned otherwise there would be a proper list between the [ ]
 
exactly
however, if you do an orm query with sqla (you didn't)
you can do .one() which will throw exception if != 1 rows were returned
or first() to get first row
 
12:34 PM
@AnttiHaapala it's only intended to be informative. But it will lead eventually to a similar system for evaluating applicants (not necessarily on the dimensions chosen for the Competency Matrix) and assessing how they would complement the team's existing strengths
 
so the yellow is maximum of your team or your profile or what ?:d
 
Just wanted some data to prepare.
 
@AnttiHaapala , well that clears up that confusion. I think speaking to you has given me an idea on how I can handle my little programmatic issue :)
Thank you for your time!
 
The yellow is my scores, the red is the team average
 
the avl/skiplist and so on ... vs...
"has used git" :D
you should update it
the has used git should be first level.
the third level is "can undo multimerge, can recover from lost head, can write commit hooks" and so.
 
12:38 PM
@AnttiHaapala if you want to dick with it, go ahead. I've already mentioned it's advisory, and I'm not going to try and turn a well-established metric upside down. Next step is to determine the competencies we want to map
 
The programmer competency matrix does a pretty good job of triggering twelve independent instances of impostor syndrome in me at once
 
hehehe :d
 
Only twelve? :)
 
well, becuase there is evidence that kevin has used git, he'd score 3 on it already.
 
It would be more but I can never keep reading all the way to the end
I know cargo cult git. I can commit/push using the magic commands, but have no understanding of their meaning.
 
12:40 PM
@JGreenwell Good idea. I generally give a quick explanation for why code-as-an-image is bad, and link them to a meta post, eg Why may I not upload images of code on SO when asking a question?. I recently uploaded this image, but Martijn wasn't pleased.
 
"Knowledge of distributed VCS systems. Has tried out Bzr/Mercurial/Darcs/Git"
yep
actualy I haven't tried out darcs
but who cares
 
I technically qualify for that category. The best kind of qualification.
 
Ooh, nice.
 
Yay! I just got an accept for a non-Pandas answer to a Pandas question that I answered almost a month ago. stackoverflow.com/questions/38636460/…
 
12:44 PM
Could use feedback on the schema for the practice fitness app I'm making -- i.stack.imgur.com/EJ3T4.jpg (example of the Biometric thing: i.stack.imgur.com/kLscc.png, i.stack.imgur.com/SguGu.png)
 
Morning cabbage.
 
Hi, Morgan. How's it going? (Or would you prefer we not ask?)
 
Oh, no, it's fine. It's going better than I would've expected. :P
 
Good to hear!
 
Apartment/job hunting and just generally keeping busy.
 
12:47 PM
I saw in the transcripts that Facebook have already responded to you. That could be an interesting move.
 
I've mentioned it in chat once or twice before, but in case there's people who missed it. If anyone knows of jobs in their area that offer relocation, I'm interested in moving somewhere else.
Yeah, I've been in touch with them and Amazon.
 
Do we have a canonical for this sort of thing "how to remove closing brackets,letter u and comma from this string" ?
 
grumble....so, my irritating unit test issue was solved with a very irritating design change. Had to create a base test class that did not inherit from TestCase, and then each implementation that needed to be tested using the common base features would inherit from both TestCase and from that base Class of tests.
Really don't like that...but it passes the irritating validation for weird duplicate test ids
</rant>
 
Wow, that does seem dumb.
 
very annoying
 
12:51 PM
Might be worth filing an issue if you haven't already.
 
I guess "Understanding repr( ) function in Python" could be helpful, but it doesn't cover the u prefix stuff
 
I wrote a note in my pr to see what others think about it. The alternative solution is to simply make do without the inheritance and throw in the repeating test cases in each test case
 
So basically, either weird inheritance or violating DRY? Sounds fun. :P
 
when I see "how do I remove the u?" questions, I just mumble "map-territory confusion" and try to accept it as the inescapable background noise of the site
 
@MorganThrapp When I was replicating my issue, running with "testtools.run" would clearly duplicate the test runs when it shouldn't have.
when I ran it in IntelliJ using unittest, it would not
so it's narrowed down a bit. When I get in to work I might checkout that code and try to replicate with my own unittest
it might be a bug or something I'm clearly not understanding that is obvious
 
12:54 PM
@idjaw I feel like that sums up 90% of my programming.
 
@Kevin Fair enough. I just wanted to close it fast. It's already got 3 answers. stackoverflow.com/questions/39101508/…
 
Which isn't to say that there can't possibly be a good dupe target for such questions; merely that I've never seen one that's up to my exacting standards.
 

« first day (2138 days earlier)      last day (2825 days later) »