« first day (2844 days earlier)      last day (2103 days later) » 

2:53 AM
hey guys, does anyone know how shape works in Tensorflow? I know that (3,5) means 3x5 matrix for example, (?,?) means that both dimensions are dynamic, but what does (?,) mean
 
3:23 AM
hello guys, like i just needed some help
like is there any library or algorthm by which i can find insights of my line plot
like when a particular pattern repeats,
what the line plot represents, like whether it is a parabola or hyperbola, or is it sinusoidal ..
 
3:55 AM
I just want to know how a tensor can have shape [?, 0] or [0, ?]
how can a dimension have size
0
 
4:25 AM
it shouldn't
unless you're doing something wrong
Oh wait, you're the user whose question I answered. Nevermind...
 
5:09 AM
The title of this question is very misleading, esp. given that it was closed in favor of something non-list-comprehension-related. What to do?
The motivator is that this question actually asks about multiple clauses in list comprehension (although its original title didn't say that).
So Q2 would make a good canonical question for those keywords. Q1 should not even show up, for those keywords. Q1 should be renamed "How to test multiple string 'in' conditions in list-comprehension?". Should I rename Q1, or else how do we prevent it causing confusion with Q2?
 
5:23 AM
(I just went ahead and renamed Q1, since the original title was so off)
 
5:59 AM
Sometimes it's not worth the trouble...
 
6:23 AM
@coldspeed (to Evan or me?)
Seems we are overdue having tags for , (language-independent). I wrote a Meta post.
 
6:35 AM
evening cabbage
or...actually late night cabbage
anyone around?
 
Ain't nobody here but us cabbages.
5
 
That's good cuz we don't need no dirty lettuce around here
 
Tired cbg.
 
@smci To you.... that question is over half a year old and pretty much dead.
 
Am I being too pedantic here and in the follow-up comments? I think it's important to make a clear distinction between retrieving args from the command line and reading from stdin. Or is it simply the case that FK82 understands the distinction but is confused by my terminology?
 
7:01 AM
cbg all
Are there any good resources for how to structure Flask projects such that they are easily testable? I think I might be doing something a bit wrong by doing things like app.config['FOO'] as it makes testing harder when the app is used in various places. Is config better handled some other way?
 
7:30 AM
@shuttle87 I think you should take a look at some cookiecutter for flask repos
 
@coldspeed You've missed the point entirely. Q1's mistitling was obscuring the findability and canonical nature of Q2. Q2 is very live (asked today) and very important. Aren't you stunned that "How to have multiple condition clauses in list comprehension?" still doesn't have a canonical answer on SO? The feature came out 18 years ago. Shocking.
 
Monday cbg!
 
7:41 AM
@PM2Ring I think the confusion arises from the terms "terminal" vs "command line" vs "command line arguments" vs "stdin". "command line" can ambigously be understood as either "terminal" or "command line arguments".
and since stdin is often connected to the terminal, the two words are sometimes used interchangeably, albeit incorrectly.
"reading from the command line" seems technically inaccurate from my point of view. I read your original comment with this phrase as "accept command line arguments", but I see how someone could interpret it as "reading from stdin".
 
@shad0w_wa1k3r got any cookiecutters in mind? Or should I just search?
 
@shuttle87 just search, I only have some good ones for Django
 
OK, searching now :)
 
hey guys
 
@Code-Apprentice Yeah. I guess I should've originally said something to the effect that the phrase "reading from the command line" is misleading or ambiguous.
 
8:05 AM
@shamilpython stop being annoying. If you have a question, ask it. Read the room rules first
 
@AndrasDeak do you use python gtk3
 
@shamilpython that's not a real question. Read the rules now.
hold on, did we remove "just ask your question" from the rules?
 
There's "Ask your question directly"
 
aaah thanks, I couldn't find it
I think there used to be something about a preamble and django :P
 
8:12 AM
Yep, David revised them not too long ago
 
it sort of rings a bell...
 
@shad0w_wa1k3r Thanks for reminding me of cookiecutters, this just saved me a lot of time for a couple of outstanding tasks
 
Good day :)
 
8:38 AM
@shuttle87 :)
(I know you meant the actual page, but just in-case if anyone was curious)
 
morning everyone
 
good morning Andy!
 
@shad0w_wa1k3r thanks
 
@shad0w_wa1k3r sup man?
 
8:59 AM
@AndyK getting engaged in a month :D Next level in life :-p
14
 
@shad0w_wa1k3r congrats my man!
 
thanks!
 
Annoying football practice eh vaultah? :-p
 
suspended that kid for 3h
 
9:13 AM
Thanks :P
 
also, wth is "ython rogramming"? :D
 
Shocker
@shad0w_wa1k3r pre-order congratulations ;)
 
thanks Andras!
 
@ThiefMaster y you ask?:P
 
@ThiefMaster the p is silent
 
9:42 AM
>>> n = input()
fe35/\?
>>>m = list(n)
print(m)
['f', 'e', '3', '5', '/', '\\', '?']
Hello everyone!
As you can see above, after printing out 'm' I have \\ whereas in the input was \. Why it doubles when converting that into list?
 
It's just escaping it
Because \ is a control character so \n for example is a newline and not 2 characters. Consequently \ itself must be escaped because of this
 
@shuttle87 Thank you!
 
10:15 AM
Please don't post code as images. Delete and post as text.
here's some help for formatting code in chat sopython.com/wiki/…
 
@AndrasDeak Ok I am going to change it.
 
thanks :)
 
@Tug'Tegin That code makes no real sense… You are calculating the factorial recursively, but asking for a new x on every recursion. You should split up the “ask for input” and “calculate the factorial” parts.
 
@poke Thank you!
 
10:26 AM
@IljaEverilä done, you can also use for higher visibility :)
 
@AndrasDeak Much appreciated, and will do. :)
 
10:43 AM
which is the best way to get the value of a key, where the dictionary is having only one key and the key is unknown, I got the value using keys() fucntion, Is there a better way to do this
 
d.values()[0] if you do not need to know the key
otherwise d.items()[0]
 
or v, = d.values()
 
in case of python3: next(iter(d.items())) (or values() if you do not need the key)
 
v, = d.values() in case of Python 2 or 3
 
or if you don't need the dict anymore you can .popitem()
 
10:50 AM
dict(d).popitem() to destroy only a clone isn't too bad either for a single-element dict
 
Every time I find myself working with datetimes in matplotlib I get the feeling it will stop at nothing short of demanding a blood sacrifice to get the formatting I want :/
 
11:25 AM
Hey. I have a "test" file that has more than 1.000 lines. Is it recomended to split this into a diferent file? It test the same module/feature
 
@roganjosh ... don't they have a library of helpers for simplifying it?
 
hey guys
 
hi
 
does anyone know how to setup django vagrant and pycharm?
I have set up but in my enterpreter, I dont see django listed
and in my code, django is red-underlined
 
@doniyor settings -> project -> interpreter, then select the one that has django in its side-packages
or is django not yet installed anywhere?
 
11:43 AM
ah ok
django is already installed
it takes /usr/bin/python by default
I am using vagrant, so django seems to be installed not systemwide
ok got it
thank you very much, I had to select the .virtualenvs folder
 
Unless you installed it for a specific virtualenv, it would be installed systemwide. Check if you installed it for python2.7 or python3
 
yes, thanks
it was installed in a virtualenv
 
@Mirv as part of the library itself or some separate wrapper?
They do have matplotlib.dates, which is what I ended up using. But you have to create locator objects, then pass them to the axis object. But, curiously, you use plt.xticks(rotation=90) to rotate the actual labels. I just don't have intuition on what properties are set on what objects.
 
12:04 PM
tickers+formatters doesn't sound too bad considering how hard it is to handle datetimes right
and it looks like you can use a DateFormatter for full strftime support
also you can just as well use ax.set_xticks so you can keep using the object-oriented API rather than the state machine
or can't you just rotate with that?
 
I couldn't get set_xticks to work
 
yeah, according to the docs it doesn't matplotlib.org/api/_as_gen/matplotlib.axes.Axes.set_xticks.html, sorry
 
In the end I had to import matplotlib.dates as md; hour_locator = md.HourLocator(); ax.xaxis.set_major_locator(hour_locator)
 
ah, extra kwargs are passed on to the Text objects matplotlib.org/api/_as_gen/matplotlib.pyplot.xticks.html
@roganjosh yeah, that's fine I'd say
 
The result is not some horribly convoluted code but getting to the result is more complicated than I expect when I set out
It's not intuitive to me that I have to make an object that locates hours, just to pass it to the axis
 
12:08 PM
Eh, I don't think there's a unique straightforward way how it should work
I've grown fond of the object-oriented API because it's crystal clear what's happening. With plt.whatever you're screwed if the gca() changes, for instance
 
Presumably when they try to encompass a broad range of functionality, this kind of structure is necessary
 
Perhaps I'm just used to it by now but it makes a lot of sense to me to have axis-specific workers like formatters and locators which you then attach to the necessary axis. Note that for instance you have colorbars with axes of their own, which can and should also have the appropriate locators and formatters...
 
Yes, I agree that that makes sense
But setting the location and formatting of the strings with ax.xaxis.set_major_locator(hour_locator), but having to do the rotation on plt.xticks; do you have insight on what that would be the case?
 
7 mins ago, by Andras Deak
ah, extra kwargs are passed on to the Text objects https://matplotlib.org/api/_as_gen/matplotlib.pyplot.xticks.html
I think you'd have to call the rotation on every ticklabel separately
 
Ah sorry, I missed that, going to have a look
 
12:16 PM
and matplotlib.org/api/… to go with that of course, once it's been initialized
For this I'd just use plt.xtick for convenience, but I agree that it would be better to either use the state machine or the object-oriented API. I've grown accustomed to fig,ax = plt.subplots() and then just working with those objects whenever possible
and of course if you have more than one axes you'd definitely want to use the latter
 
re-cbg. I was going to answer this Numpy question earlier today, but I couldn't get sufficient clarification from the OP. Eventually, a reasonable answer was submitted, but the OP says it doesn't do the correct substitution.
Maybe I'm still misunderstanding the OP's requirements, but I suspect that the OP is just misreading the output from that answer. I tried to get the OP to explain what's wrong with that output: I even upvoted the question so that the OP has enough rep to talk in chat, but they've disappeared.
 
Yeah, because I could envision wanting to rotate one set of labels in something like this and to me it would definitely make my understanding clearer to set it on the axis
 
@PM2Ring I have no idea what they're asking; closing as unclear
 
I'm not clear on what they're asking either
 
@roganjosh you can always do ax.get_xticklabels() and manipulate those
 
12:23 PM
Good point, so there is flexibility in the approach. I'll work on getting a better mental map of the library
 
I'm not claiming it's always intuitive; there's quite a lot of legacy issues and whatnot. But I don't find it too unreasonable for not-so-weird things
 
@AndrasDeak I think BossaNova's interpretation is reasonable. But if the OP says it doesn't do what they want, then I guess the question really is unclear.
 
interpretations don't concern me ;)
 
Cabbage
 
cbg
 
12:28 PM
So , I have two python scripts totally independent of each other, slave has to return the status of the execution so that the master may use that data to either rerun the slave script or not.
Should I use pickling
or multiprocessing?
I mean , I just have to return a variable from the slave script
someone on SO suggested I can use something called PIPE
 
99% of the time, when one script needs to run another script, then it should import it
If you're not sure whether you're in the 1%, you probably aren't
 
Umm. Its not a "Python" script , its a sikuli script which uses the jython interpreter , so that has to be invoked in a way thich sikuli understands,
meaning , I cant import it
os.system(r'C:\Shobin\Boi\Trig\runsikulix.cmd -r C:\Shobin\Boi\sk_script\VM_ErrChk.sikuli')
Like so.
 
I don't know what all of those words mean, but that is approximately a good justification for not importing
 
Its at the core a .py file but it cant be imported in the traditional way.
 
Take a look at the subprocess module. Popen objects have a returncode attribute that may be useful to you.
 
12:35 PM
@Kevin Looked at it , Not useful.
 
In what way is it not useful?
 
Sometimes you have to try look harder
 
If we don't know what issue there is that makes it not useful for you, we can't make any further suggestions
 
So are you saying , that the subprocess can return a variable which is assigned inside a python script?
 
Sure. All processes can return an integer indicating their exit status.
 
12:38 PM
@roganjosh Simple, I just need to communicate between two independent python scripts which cannot be imported.
Oh wait!
 
Yes, I saw that part. You also dismissed an approach as "Looked at it , Not useful." but then didn't go on to say why
 
If you're about to say "but I want to return something other than an integer", then I take exception to your earlier phrasing of "to return the status of the execution" which in this context is usually understood to mean "the integer return status"
 
@Kevin Ohhhh......MY BAD... totally my bad.. Sorry.
I want to return a string. not an integer as i mentioned above..
 
The lazy solution is to print the string to stdout, and use subprocess.check_output
 
Should pay attention to what I am typing.. sigh
@Kevin Sounds interesting.
 
12:46 PM
This coincides with the "try using PIPE" advice you got earlier, since check_output is using PIPE under the hood
If the documentation at docs.python.org/3/library/… is to be believed
 
@Kevin I am giving it a shot.. Hope it works.
 
C:\Users\Kevin\Desktop>type test.py
print("Hello, world!")
C:\Users\Kevin\Desktop>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> s = subprocess.check_output(["python", "test.py"])
>>> s
b'Hello, world!\r\n'
>>>
 
Umm.. Stupid question, what is the difference between os.system() and subprocess.popen()
I slightly got confused between , both seem to do the same thing.
Nvm , just googled.
 
Someone is little too stubborn today :{
 
Rob
12:56 PM
I guess three hours wasn't enough to get the point across
 
Can some one help me with the question: stackoverflow.com/questions/51444526/…
 
When I get too fed up with some Dota game, usually get reset in 10 mins :)
 
guys
good news
I've landed a python dev position
15
 
Nice.
 
@AndyK Woot. Congrats !!
 
12:57 PM
Thank you for your efforts and patience
 
congrats Andy!
 
@shad0w_wa1k3r you helped me much
and @coldspeed too
 
@AndyK Congrats.. Where exactly?
 
and @AndrasDeak
 
haha, don't know about that, but happy to do so :D
 
12:58 PM
@JafferWilson in Paris
 
and @piRSquared and last but not least
 
@AndyK Great
 
@PM2Ring thank you for being here all that time, and nudging me
@AnttiHaapala and not mentionning you would be so unfair
 
A humble request
 
12:59 PM
You've already posted that
 
@Anarach thanks
 
I have looked at the question and determined that I don't know enough about Tensorflow to answer it.
 
and @Kevin plus @poke
 
@Kevin Thanks... for your look...
 
@shad0w_wa1k3r you did. You have been a reassuring presence
 
1:02 PM
Hmm, happy about it. Good luck in Paris! When's the joining?
 
@shad0w_wa1k3r mid september
 
When it comes to third party libraries, expertise can be a bit scattershot among chat users. For some libraries, we have core devs lurking. For other libraries, nobody has more than fifteen minutes of experience
 
@AndyK Congratulations! :)
 
Off the top of my head, I don't think we have any regular TF users actually do we?
And congratulations, Andy
 
They're good at hiding, if so ;-)
 
1:05 PM
@roganjosh We do I think. Arne knows some TF IIRC.
 
Ah possibly, he is into machine learning
That's a nice one to have coverage of really because it's really growing. I keep meaning to put some time aside for it.
 
@poke thank you
@roganjosh thank you
 
@AndyK Good luck with the new job!
 
@PM2Ring long time no see :)
@PM2Ring thank you
 
Is it a physical move for you going to Paris?
 
1:14 PM
I've been browsing over at SE.crypto and found this link to an amusing article about crypto in JavaScript.
 
@roganjosh it is
 
Ah, so an exciting and busy couple of months then :)
 
stackoverflow.com/q/51574509 no repro? solution is literally in title
 
@roganjosh leaving in mid september and starting 2 days later
 
Whirlwind then. I took a job in London last year, had just over a week to find a flat. Moved in Sunday night and started Monday. At least you'll get a little more breathing room than that :)
 
1:20 PM
@roganjosh lol. that's fast indeed
 
stackoverflow.com/questions/51589254/… unclear. OP has not made any clarification.
 
If someone has anything to say about my question please you can join the chat room here: chat.stackoverflow.com/rooms/177027/tensorflow-discussion
 
@davidism Gone
 
thanks
 
1:28 PM
@AndyK Gratz! I'm happy for you.
 
@piRSquared cheers mate
starting as a junior
I'm a bit anxious about it but I'm thinking about it for a long time. Often you have to jump in otherwise, you will always wonder if the sea is cold, hot, if there are sharks or actually, nothing, just your mind paralyzing you out of fear
 
hello
 
@Kevin I also thought the same about jsonlines but the documentation does seem to suggest bigquery requires newline delimiting
 
That's what courage is. Taking action despite the fear.
 
Absent any other requirements, a format that accepts newline-delimited values must necessarily also accept a single line of data
For the same reason that you can write a valid csv file without any commas, as long as there's only one column
 
1:33 PM
That's a fair point, I'm not sure the core reason for them making this restriction
 
@piRSquared you need to, otherwise you are stuck. I've seen so many people, metaphorically speaking, looking at the land from the sea and never touch the land because they were unwilling to be disappointed by the reality of the land or just too afraid with they would discover with the "what if"
 
absolutely!
 
\o cbg
 
@MooingRawr o/
 
@roganjosh I use TF but not sure if I'm a regular
 
1:59 PM
@AndyK congratulations :)
 
@AndrasDeak cheers
 
Yoyoyo guy keeps coming here when I'm in commute :(
 
2:15 PM
I'm sure he'll be back with more yo-yoing
He's pretty decent already, gonna give him that
 
Hmm, I've misplaced the dongle for my wireless controller. Maybe it's time to get a new one. What do the kids use these days? XBox?
 
@vaultah hehe
 
I guess I'll just pick the first thing on Amazon I see that supports Windows 7, runs on something other than disposable AA batteries, doesn't have any reviews describing it as a piece of junk, and isn't some cheerful bright color that will show dirt with the highest possible contrast after 15 minutes of use.
My first attempt last night to meet all these criteria was a rousing failure
 
I've heard it claim that the xbox controller is best
 
@Kevin I answered the jsonlines question
 
2:28 PM
I think I heard someone mentioning Steam Controller
 
I've heard it mentioned too... In conversations discussing about how much of a flop it was
 
It does have to be syntactically invalid json as a whole in order to get multiple records uploaded in one go
 
@Kevin that I haven't heard
 
@roganjosh Mm hmm. But I didn't get the impression that the OP was trying to upload multiple records. He had a dict, not a list of dicts.
 
Yeah, I took a jump and they edited at the same time to show that the initial dict contained multiple records
 
2:37 PM
@AndyK Pineapples !
 
Possibly what he wants to have is a list of dicts, and he simply can't articulate his problem well enough. The ambiguous description is exactly why I lost interest in the question
 
@MooingRawr cheers man!
I push, push , push, send cv's , quite a lot of them
 
if u dont mind me asking but what kind of work will you be doing? web dev? some ML? some company product?
 
I went through the BigQuery specifications and it shows examples that you really do need to have jsonlines
 
@MooingRawr web dev on a company product
 
2:39 PM
Other valid JSON structures are also not allowed
 
they use ittools and more obscure framework, ikaaro
 
oh hohoho nice :D
 
I have never refuted the claim that BigQuery requires valid JSON Lines. I have refuted the claim that valid json cannot also be valid JSON Lines.
 
they were interested by my understanding of business, project management side plus understanding what it takes to work in a small organisation
and that I know Python
the aim is that I ramp up my python and in exchange, I bring them more perspective on managing
 
Ah no, I misread your other comment and thought you were making a statement on what the OP wants now. You were instead referring to the way you read the initial question. Wires crossed.
And I agree with your claim
 
2:43 PM
@AndyK oh interesting u came from a "business" background
 
@MooingRawr I'm coming from a diverse background, having started a fablab on my spare time that is still working today to working on IT projects and having done support / key account care with large corp
I don't fit a specific hole
 
sure you do, it just so happens you dig yourself a bigger hole than most people :D
but anyways moving up in the world, must be exciting :D
 
@MooingRawr probably. I'm not coming from the business but I understand business well, very well
@MooingRawr it is a very exciting time
the funniest part was for this role, when I went for the interview, the guy I'm replacing, I helped him 5 years ago to set his python's initiative
I was surprised to meet him before the beginning of the interview
 
morning cabbage!
 
@Code-Apprentice morning
 
3:02 PM
Python 3 I hope :)
 
@AndrasDeak not there, no...
they seem to be with python2.x
and why ikaaro instead of flask?
 
3:23 PM
rb folks
 
After explaining to the OP that print() returns None in three separate comments and it precisely explained the behaviour they were seeing, they settled on it definitely being an issue with the library they are using. I think that's reverse progress :/
 
3:38 PM
What's an elegant way to determine whether the element you're iterating over is the first or last element of the iterable?
 
what kind of iterable?
Doesn't sound universally solveable nicely
 
DSM
And do you care which of the two it is, or only that it's either the first or last? (E.g. if there's only one element, what would you want to see?)
Belated morning cabbage.
 
Literally an iterable. All we know about it is that we can call next on it, and sometimes it returns a value, and sometimes it raises StopIteration.
 
oh you mean like using enumerate and checking the index
Cbg for DSM
 
@DSM For my current use case, I don't care which of the two it is.
 
3:42 PM
@Kevin enumerate or sentinel for first and (for-)else for last?
@Kevin iterator?
 
Oops, yeah. "iterator" is what I meant.
 
Or take the first item separately and loop after
 
stackoverflow.com/q/51597597 recommendation / opinion
 
I got as far as pastebin.com/VcvnJch9 but I've brainfarted and haven't yet been able to turn this into [expr for value, is_first_or_last in informatively_iterate(g)]
 
DSM
Oh, we're allowed to write a wrapper?
 
3:50 PM
To part the veil a little, I'm trying to write a solution for invert edge values in python boolean list that uses groupby and inverts only the first and last items
Or I guess "invert" is a bad term. "unconditionally sets to True" better reflects what I'd ultimately do
@DSM Yeah although a magical one-liner would impress the superstitious locals more.
I could just convert everything to a list, but that's not fun.
 
DSM
4:12 PM
@Kevin: maybe something like this?
(Should probably toss an iter in there for generality, but you get the idea.)
 
jpp
@Kevin, Not sure if this is what you are after, but I added a solution using next.
 
tee and next are probably important components of the hypothetical best solution. I'd need higher blood sugar than what I've got to work through all the corner cases though
 
DSM
The headache comes in because you can't know something is the last until you've hit the StopIteration somehow.. oh, well, maybe lunch will bring me insight.
 
@jpp It's clear to me what the OP is trying to do. But I suppose it should be closed as too broad, due to the lack of a code attempt. And I don't like the "give me solution" attitude, but I guess that's probably a language / culture issue.
 
jpp
4:34 PM
@PM2Ring, Fair enough. I (try and) go out of my way to add a couple of sentences of explanation. In my opinion, it's middle-of-the-road compared to the many people who just write "Use:..."
 
4:46 PM
May 28 '17 at 13:00, by Andras Deak
I believe questions should be evaluated by absolute criteria, "not as bad as could be" is not enough
But it's established that we have different norms for answering
 
@jpp I won't post an answer, since the OP hasn't made enough effort. But I'd do it like this:
def insert(d, keystring, v):
    *keylist, final = keystring.split('/')[::-1]
    for key in keylist:
        d = d.setdefault(key, {})
    d[final] = v
 
5:07 PM
So I have a 3d axis graph. The X and Y axis both have the same view settings, etc but not the data. Is there a good way to compress these statements down into 1 line each? I've considered using eval() in a for loop with these as strings and the "x" and "y" parameter in a list.

If the answer is long, etc. I can write this as a good question.

ax.xaxis.set_major_locator(locator)
ax.yaxis.set_major_locator(locator)

ax.xaxis.set_major_formatter(StrMethodFormatter("{{x:0{}d}}".format(length)))
ax.yaxis.set_major_formatter(StrMethodFormatter("{{x:0{}d}}".format(length)))
 
Don't eval! Ever!
for axis in ax.xaxis,ax.yaxis: axis.do_stuff()
 
DSM
"ever" might be a bit strong, but yeah, it's best avoided except in very rare circumstances. :-) I'm a little surprised there isn't already a data structure and/or function which contains the axes, but I can't think of one offhand.
 
There could be one but they need 2 out of 3 axes
And yes, eval could be necessary but not under these circumstances :P
 
wim
Yeah I mean if you never use eval then your REPL won't work
 
(currently pondering whether I should bring up getattr at all...)
The only bug-free program is one that never evaluates
Python devs, please provide a RPL so I can achieve perfection
 
5:15 PM
Ah yes. Didn't think of that. But the problem is that wouldn't work for this as you also have to deal with the yticks + ax.yaxis.

yticks = ax.yaxis.get_major_ticks()
yticks[-number_ticks+1].set_visible(False)
 
DSM
I keep going back and forth on to what degree DSMScript should support lisp-style metaprogramming.
 
You should be able to create DSMScript in DSMScript. Otherwise you're just not commited to metaprogramming.
 
@Number1 I don't understand
Byt I also have to leave so...
 
Couldn't you just do:
for axis in ax.xaxis,ax.yaxis:
    axis.set_major_locator(locator)
    axis.set_major_formatter(StrMethodFormatter("{{x:0{}d}}".format(length)))
    axis.get_major_ticks()[-number_ticks+1].set_visible(False)
If you're saying "I couldn't generalize my code into a loop because the bit that operates on yaxis also creates a yticks value, and the bit that operates on xaxis creates an xticks value", then you can just skip creating the value :-)
 
5:18 PM
... Assuming you only need the value so you can call set_visible on it a line later
 
DSM
@KevinMGranger: I'd of course write the first DSMScript compiler in DSMScript but the first interpreter would probably be in Python, I'll admit..
(Also it needs a better name. Unfortunately the letters "DSM" don't contribute to a lot of good words-- so far the best are DiSMay and DiSMal, both of which seem darkly appropriate.)
 
Dat Scripting Machine
Also, I meant more how you can define almost every single language construct of scheme from within scheme given just macros (and in fact, the end of SICP has you do that)
 
@Kevin Ah true. Thanks! I don't know why I wrote the major ticks thing that way....
 
DSM
@KevinMGranger: no disagreement here :-)
 
5:38 PM
I assume mylist here is a list of Numpy arrays. Is there any benefit to doing np.asarray(mylist)? I'd expect it to be faster to just iterate over the list directly.
 
DSM
Not that I can think of.
 
6:12 PM
When in doubt, do more numpy to it
 
6:55 PM
Creating a Python generator that yields ordered products of integers from two large lists is interesting... I don't think you can do it with O(1) additional memory, but I suspect O(N) is possible. Basically, if you draw a multiplication table and X out all the ones you visited, then the next smallest number must have exactly two Xed out neighbors. So you really only need to store the "edge" that demarcates the Xed out zone and the unvisited zone.
the edge's coordinates are strictly increasing along both axes, so it can't double back on itself, which means that in the worst case it goes from one corner of the table to the other, which is only N items
 
DSM
I think you might be able to do it with one of those "moving index" tricks, and the fact that [certain product condition which I wrote incorrectly here originally holds.] I haven't thought it through yet, though.
 
I'm sorely tempted to use a priority queue here. I don't know if it would be useful, I just think they're neat.
I think my edge search idea is O(N^3) time, which isn't as good as "make a big list, then sort", which is O(N^2 log N^2)
Sometimes you trade space for speed I guess
Nice try, answerer that said "hey, can you guys edit my post so it's correct? thanks"
 
7:53 PM
@PM2Ring list of jagged arrays won't convert to a single array anyway
@Kevin PR trick: call the latter O(N^2 log N)
 
8:18 PM
@Kevin Yes, it can be done with a heap, but I'm not sure how big the heap can grow. I thought you might be able to do it more conservatively by scanning along the diagonals, but it doesn't look like you gain much, if anything. But here's my diagonal scanning code:
a = [6, 7, 8, 9]
b = [1, 2, 3, 4, 5]
for x in a:
    print(*[f'{x * y:2}' for y in b])
print()

mi, mj = len(a), len(b)
for n in range(mi + mj):
    for i in range(n + 1):
        j = n - i
        if i >= mi or j >= mj: continue
        print((a[i] * b[j]), end=' ')
    print()
 6 12 18 24 30
 7 14 21 28 35
 8 16 24 32 40
 9 18 27 36 45

6
12 7
18 14 8
24 21 16 9
30 28 24 18
35 32 27
40 36
45
 
time to zzz guys
see ya
 
8:30 PM
On second thoughts, diagonalization does help. :)
 
DSM
I've been too lazy to work out the details, but assume the values are unique to make the argument simpler. We know that a[i] * b[j] < a[i+1] * b[j+1], so at every step you know that you have to look through at most ~ (len(a)-i) + (len(b)-j) possible products to sort. I.e. you have to look at [i+1, j], [i+2, j]... and [i, j+1, j+2, ...]]. You can break as soon as you pass the 'diagonal' product. heapq.merge those, and then take the +1, +1 step. I think something like that works.
 
9:23 PM
I'm not sure I understood that correctly, but I'm getting too tired to think about it anymore. :) Rhubarb.
 
rbrb
 
9:46 PM
afternoon cabbage
 
late evening cabbage
 

« first day (2844 days earlier)      last day (2103 days later) »