« first day (3659 days earlier)      last day (1272 days later) » 
00:00 - 18:0018:00 - 00:00

12:17 AM
Is the following old question bad recursive backtracking, tail-recursive backtracking, or non-recursive backtracking? Knights tour with Backtracking. Also, there are separate tags [backtracking] (1250 q's) and [recursive-backtracking] (219 q's). The tag [backtracking] doesn't mention tag [recursive-backtracking], nor does it explain that not all backtracking is recursive. How to clean this up?
 
12:56 AM
Python needs a shortcut for integer round up division
18 /^ 5
 
1:11 AM
What could be clearer than -(-18 // 5)?
 
 
1 hour later…
2:27 AM
@smci burn [recursive-backtracking], it's useless
 
 
1 hour later…
3:29 AM
Hi all. I'm wondering if someone could answer a question for me. I don't think it's appropriate for a full-blown SO question... I have a Python class, say,myClass, with about 10 instance variables. In one method, I perform a lot of calculations with these variables and, of course, have to use the self keyword ad nauseum. Is there a better way to do this? The issue for me is really only that the math is challenging and this (in my opinion) makes the code hard to read.
For example, I have a line something along the lines of self.xi + math.sqrt( (self.xf + self.dx) * (self.xi + self.dx) ) + self.i/self.n + self.xf * self.xf
 
there might be better ideas but since 3 out of 5 values there are repeated and if you use this line multiple times, you can have a method in the class that takes these are as args and have this expression over there, so you can just call it when needed
this wont work well if you only have this line once or if there are many different math operations
 
4:38 AM
is there a way to tell kernel to pass packets only to bpf vm without passing them to protocol stack in libpcap library or any other library which can be used in python ?
 
5:02 AM
@PaulMcG :-P
 
5:38 AM
@KeithMadison you can store them in local variables and use that instead. xf, xi = self.xf, self.xi etc.
 
6:04 AM
@Kevin That only applies to languages with just pure functions and explicit side-effects, which pretty much no main-stream programming language satisfies.
 
7:03 AM
@holdenweb Oh my, I was rather hoping for the opposite evolution of that PEP. As in, shrivel up and go away...
 
7:39 AM
is there a generally applicable canonical for "use the -m switch, Luke"?
I've just answered the m'teenth such question but they are all convoluted messes of Xs, Ys and Zs.
 
7:56 AM
Anyone familiar with how to integrate reCaptcha in flask-bootstrap? I am trying to display reCaptcha in a form but I keep getting the error RuntimeError: RECAPTCHA_PUBLIC_KEY config not set
 
@GitauHarrison It's telling you exactly what the issue is. You have to register for recaptcha to get a token, which needs to be set in your config
 
@roganjosh I have added the configurations in config.py file. The error however still persists
This is what I have dpaste.com/ERGFFMBRC
 
<braces for a token exposure>
It's case-sensitive so you need to cross reference the config key you've used with what the error is telling you
 
@roganjosh Thank you for the suggestions. I have been able to see where the problem is. Apparently, reCaptcha expects a config variable strictly called RECAPTCHA_PUBLIC_KEY while mine was reCAPTCHA_SITE_KEY. That change has gotten rid of the error.
Just needed to look a bit deeper in the error message to see that
 
9:05 AM
@inspectorG4dget Inspector, that is really cool
 
9:36 AM
cbg, is there a link / article that shows in which scenarios a dict's keys is used implicitly when one just uses something like "d={1: 'a', 2: 'b'}" "sum(d) # 3" "for i in d: # uses d.keys()"
but when I pass to function it goes as a dict itself, what am I not understanding here?
 
iterating over a dict merely provides its keys
sum receives the full dictionary but iterates over it to get its content
 
thanks for clarifying, I like how MCQ's can totally make forget my mental model for python lol
 
what error would you raise in case it doesn't matter? I have something which can raise various errors, but I don't want to catch them. I just want to throw 1 error and exit out
 
Exception as e and just throw a custom exception?
 
so just raise Exception?
 
9:40 AM
@Hakaishin you might want to create your own Exception, just to allow separating them from other errors you haven't thought about.
Using a too generic Exception makes it all too easy to accidentally silence real errors.
 
^ he said it better :)
 
hmm, ok seems simple enough. Now I just got class MyException(Exception): pass. Neat
 
Any particular reason for doing that? Seems to me it'd make more sense to just not catch it and see if the original exception ends up causing program exit... if it does, then you've got your desired effect but you haven't masked a lot of traceback info
 
It's a class connecting to a service over network. So it tries x, if it succeeds great keep going, if it fails it logs it and tries again a bit later. It needs to to x,y,z to be initialized. And the other classes using that class don't care if x or y or z didn't work. They just see it failed and want to stop and the class logged it's tracebacks already itself.
I think it makes sense, but I'm not completely sure myself. I'm in the process of refactoring that class to make it more convenient to use
Discovered that I need to do that while writing tests and realizing it's hard and annoying to test and there is some duplicate code for the logic dealing with potential network failures
 
@Hakaishin you could still raise a meaningful error and ignore that
Use the right error subclass to make handling easier
 
9:56 AM
but then I'd have to have a list with except (a,b,c) instead of just except myexception
 
@Hakaishin hence subclass
All your precise exceptions can inherit from HakException
 
You mean to futureproof it? Because atm I don't care if it's a networkout error or an authentificationerror
and I don't see what benefit I get from it
 
@Hakaishin you don't care on the calling side. It's a well-defined error in the underlying code, yes?
 
yes
 
@Hakaishin I guess I just don't see why you'd raise WhateverErrror when you know what happened exactly
But yeah, sure, just raise Whatever if that works for you
 
9:59 AM
because I don't care what happened on the calling side and throwing the exact error involves more work. Where the error happens I log it. I don't see what I should do with the exact exception on the calling side
 
What is the difference between sns.set() and sns.set_theme() in seaborn?
 
@Pherdindy does the docs help?
 
little bit off topic, is there a secure way to open a excel sheet with vba macro ?
other then a virtual machine
 
The docs only say that sns.set() is an alias of sns.set_theme()
 
10:03 AM
I think the clue is in the world alias?
 
Just wondering why they would make a .set() and .set_theme() when they mean the same thing
 
@Amundsen very off-topic
@Pherdindy probably historical reasons. Check sns.set is sns.set_theme.
 
It returns false
 
my uneducated guess would be that .set was renamed to clarify its scope
@Pherdindy then it's not an alias :)
They have a different signature
 
Hmm they do everything the same so far based on my test but maybe different somewhere
 
10:09 AM
Presumably the only way to know would be to check the source code
 
Yeah probably just gonna stick with set_theme() for now I guess since its the preferable method
 
FWIW I already found the code for it, so it's quick enough to do. You should get into the habit of tracing these things down rather than running on an assumption
 
Umm.. wonder why pip is insisting on the get source and compiling it approach vs just downloading a wheel like it does most times... sighs
oh... because there aren't any pandas wheels for 3.9 yet... that'd be why...
 
@roganjosh Right I would love to if I had time I kind of go with a 20% effort 80% results kind of approach so my foundation is not too good
 
@Pherdindy pushing the 80% on us is not exactly nice
 
10:20 AM
@Pherdindy The point of my message was that it took me less than 90 seconds to find it and not run on an assumption. It took nearly as long to parse my suggestion and type the response. 20% understanding kinda undermines the value of 80% of "results" given that they could be completely false
 
@Pherdindy you ask rarely and usually focussed things, so you're not being a problem. It's just that what you said comes across as "I can't be bothered to pull my weight" :P
 
^ :)
 
Lol yea I get it although I currently don't know how to do that :P I never really spent time to look into the code of libraries yet if it's not in the docs. And when I do open some modules I get too overwhelmed by the code
 
In light of that, I might as well give you the link rather than just close the tab
 
So I just skip it
I never used github also maybe I can find stuff there
 
10:24 AM
Pandas docs is nice, with links to source
@Pherdindy you should absolutely learn some version control system to protect from losing work
 
"seaborn github" in google --> straight to the source code. I made a value judgement on whether I needed to search for set_theme or whether (knowing matplotlib) rcmod.py might be a decent port-of-call. You might be less familiar with matplotlib though, so you may have had to search a bit more
 
You can search a given repo on github. That's the default search.
 
Yup github is something I should definitely look into an the code sharing/version control stuff
 
@Pherdindy just for completeness' sake: there's git and there's github. You don't need github but you need git (or hg or svn)
Although git + github has become standard. Gitlab is a non-microsoft competitor.
 
Thanks will check it out after dinner hah
Don't know much about matplotlib besides basic plotting I just went straight to seaborn because I get more stuff out easier compared to matplotlib but pretty sure i'll have to keep jumping back and forth to matplotlib
 
10:32 AM
@Pherdindy if you decide to extend that 20% and learn basic git, I recommend first reading tom.preston-werner.com/2009/05/19/the-git-parable.html then playing learngitbranching.js.org
 
10:53 AM
Building wheel for pandas (PEP 517) ... error... wow... great thanks... useful...
 
@JonClements cython perhaps?
numerical builds breaking always makes me think of that
 
In this case it seems it's just a boring that it's a rather small server and " virtual memory exhausted: Cannot allocate memory"
I don't need 3.9... will juts do 3.8 and hope it can use wheels instead of building stuff from source
 
ah
can't you build a wheel locally? Or is the server different?
 
it managed to build a wheel for numpy from source but pandas and its requirements blew it up
 
11:19 AM
@JonClements I mean build on your local machine, and then move the wheel to the server
 
ahh sorry - my bad... that's an option I guess :)... but I've just compiled 3.8.6 on the server and going from there for now...
 
@AndrasDeak thanks a lot checking them out
 
It will take a few hours to work your way through the tutorial game, but I believe it's a very good investment
 
 
2 hours later…
1:06 PM
Hmm, this task will take either 1 or 100 hours depending upon how well-documented Oracle's internal system tables are. I'm doomed.
 
Is it possible to use the sqlalchemy .filter_by() method within jinja2?
 
morning cabbages, all
 
nvm stupid question
 
1:43 PM
How can I write a "random" number generator whose results seem more random than an actual RNG? Use case: my application awards a small prize each week to one of its 8 users. User A has won the prize three times in a row. This has made users B through H upset.
 
permutation :P
 
Also, user B has never had a string of consecutive wins, but their total number of wins is 20% higher than any other user. This makes user A and users C through H upset.
The prizes have zero actual value, so it doesn't remotely matter if the distribution is truly random. It just needs to look that way to a human
Permutation is an interesting approach... Like the "bag" algorithm used by modern Tetris implementations. This guarantees that a user can only win two consecutive prizes at the "seam", and total win percentages remains almost perfectly even, even on short time frames
 
I'm reserving a little portion of my heart to sympathise with people who pull off a non-trivial set of conditional checks using np.where on their df... and then throw it into a for i, row in df.iterrows(): loop. Ouch.
 
sounds like you could use a standard RNG and put some heuristic rules around it (if user B has won 20% more than any other user, they are not allowed to win this time)
 
@Kevin the drawback is that it becomes predictable in each cycle
 
1:51 PM
Yeah, my users are fairly smart so they might notice
I also thought about doing some kind of weighted average, where each user's weight is equal to the difference between their total wins and the total wins of the player with the most wins.
 
you can add n dummy users and replace their turns with random draws
 
This approach is nice because I don't have to keep track of any state beyond per-user win count, which I'm already doing. One drawback is that the first place user will never get a win until everyone else catches up. Another drawback is that if user I joins and has 100 fewer wins than everyone else, then they'll have a disproportionately high chance of winning every week for a couple of years
Perhaps I can add a constant value to each weight so even the first place user has a chance, and declare that any new user has a de-facto total win count equal to the win count of the user in last place
 
2:30 PM
Hi all
 
Hello
;)
 
can I ask some knowledge question here which refers to os.walk functionality?
 
Sure.
 
so I'm running the below command on my directory:
my_path="funcs"
for dirs in os.walk (my_path):
print (dirs)
the results are:
funcs
funcs/moshe
funcs/moshe/tests
funcs/echo
funcs/echo/tests
funcs/sum
funcs/sum/tests
how can I get only those:
funcs/moshe/tests
funcs/echo/tetss
funcs/sum/tests
 
So you only want directories that don't contain other directories? Hmm
 
2:33 PM
strictly non-recursive walk?
ah, no
only the graph tips
 
I'm skeptical that this is your exact output, since os.walk is supposed to yield a (dirpath, dirnames, filenames) tuple, but whatever
def iter_terminal_directories(top):
    for dirpath, dirnames, filenames in os.walk(top):
        if not dirnames:
            yield dirpath
 
ok, let me try it :)
'yield' outside function
 
uh-oh
 
Impossible! It's definitely inside a function :-)
See, there's a def right there
that's short for "definitely function"
If you're not inclined to include the def, try changing the yield to a print call
 
I will just try with echo
 
2:44 PM
to be fair with the def we'd still have to talk about how generator functions should be used
 
print
 
yield is just a monoid in the category of endofunctors, what's the big deal?
 
yep, it worked
 
👍
 
I have extra question on top of it :)
 
2:50 PM
That's why we're here, mostly
 
@A.Man Did you bring a nice bit of cake to pay for your extra question? :p
 
Also memes and complaining, I'm especially here for those
 
:) will bake it soon
 
that's a shame - just having a nice cup of tea and feeling peckish... oh well :p
 
@Kevin Warcraft3/DotA has a nice increasing pseudo random number generator approach. The underlying distribution increases until there is a hit, creating a sawtooth pattern of propability.
 
2:55 PM
propability, the likelihood of getting props for your actions
Does that translate to the "draw among n people" situation?
 
how can I use dirpath as a variable in path?
 
@AndrasDeak I leave that as an exercise for the Kevin.
 
for example:
shuti.move ("test.py","tests/echo/{dirpath}
 
@A.Man "python put variable into string"?
 
Hmm, it's a neat idea. Extending it to N people would basically be like weighting each user by the number of weeks since their last win. Slightly different from the win count delta weight I proposed earlier.
 
3:00 PM
first google hit has some atrocious answers on top
 
@Kevin I've added an answer to your "mypy+Dict+union"-typing question. Let me know if the amount of endofunctors is too high.
 
I see. it's using %
 
I have been slowly reading the answer. I need to google what "invariant" means.
 
@A.Man oldest version
you can also use str.format (newer) or f-strings (newest) or string concatenation (oldestest?)
 
@A.Man consider using os.path.join or pathlib when you specifically want to create path strings
 
3:01 PM
there's also os.path.join and pathlib.Path methods one level higher
 
got em
 
heh
according to finest tradition
 
@Kevin "Invariant" is fancy talk for "Then shalt thou count to three, no more, no less."
 
shtil.move("test.py","tests/echo/{}".format(dirpath))
this should work right?
 
@A.Man Try printing the string first, see what it looks like.
We're not your interpreter. Your interpreter is your interpreter.
5
If the string looks like what you expect, another question is whether the shutil.move call should succeed
 
3:07 PM
is it possible to involve shell script inside python?
 
Sure, with the subprocess module. You should only need to use it quite rarely though.
Python can do almost anything with file and directories etc without using shell commands
Python has been Turing complete for a while now which means it's very versatile ;-)
 
how can I take from this output:
funcs/moshe/tests
only
moshe/tests
 
You can subtract directories from the front of a path using relpath, assuming you know the names of the directories you want to subtract.
>>> print(os.path.relpath("funcs/moshe/tests", "funcs"))
moshe\tests
 
can I use this function to replace funcs/moshe/tests to testreport/moshe/tests
 
3:16 PM
Sure.
>>> print(os.path.join("testreport", os.path.relpath("funcs/moshe/tests", "funcs")))
testreport\moshe\tests
 
or just use replace right?
 
@Kevin I'm a sucker for etymology; thanks for that one! I love learning all these little facts :P
 
No problem. The language specification doesn't specify what def actually means in a function definition block, so I'm happy to step forward and define it for them.
@A.Man replace isn't very safe, because it would turn "funcs/kevins_cool_funcs/tests" into "testreport/kevins_cool_testreport/tests", which is presumably wrong
 
got you
 
perhaps a str.replace call that specifies a count of 1... Maybe, but I like to use path or pathlib because it has more semantic weight. YMMV.
 
3:27 PM
positive feeling on the PEP front after so many rants from me: it looks as if most of the typing module will become redundant, to be replaced by regular Python syntax.
 
Inspired by Scala [2] and Pike [3], this proposal adds operator type.__or__(). With this new operator, it is possible to write int | str instead of Union[int, str]. In addition to annotations, the result of this expression would then be valid in isinstance() and issubclass():
oh wow... haven't seen Pike mentioned in ages - had completely forgotten that was even a language
 
Huh, that PEP has a BDFL-Delegate and it's Guido. I guess things have calmed down a bit then? I kinda interpreted his stepping down as not wanting to be in that position again but I guess he just wanted to pick what he leads on
 
@JonClements There is a notable number of languages I only know from reading PEPs. :/
 
I think I played with it for a bit in 95/96 but ended up just sticking with C
 
Hmm! While reading github.com/python/mypy/blob/…, I clicked on TypeVarType, and it offered to take me to the class definition. Is this a new feature?
 
3:47 PM
Cabbage peaches and pears. I've been lurking in the shadows of this room for a few days without saying anything. Just wanted to say hi and ... runs
 
cbg :)
 
Heyo :)
 
This mypy stuff is mindbending
 
@Kevin stay away from the buzzing blue light
 
but it's so pretty....
 
3:55 PM
I can follow these answers as far as "dicts are invariant so it usually requires an exact type match", but then I get lost around "... Except for your function h, which is special in a hard to describe way"
 
I'm at work this weekend again. Anyone have a job for me that doesn't involve working on weekends? :/ I don't mind finishing some work at home and the like, but this is too much for me.
 
I think when mypy compares the concrete type of {"a": "1"} against the not-so-concrete type of Dict[..., Union[str, ...]], _is_subtype falls through to left.accept, which I can't easily trace
About a hundred classes implement accept and all I know about left is that it's a subclass of ProperType, and ProperType's accept simply throws Not Implemented
 
4:10 PM
@Kevin It's more like MyPy grinning sheepishly and adjusting its type inference result.
It's the equivalent of new users having an edit-race against the commenters pointing out all the flaws in their train of thought.
Admittedly, I did not make it far enough through the inference code to find out where they cheat.
handwaves at all the special cases for Union
 
Pardon my ignorance, but what's the difference between typing and mypy, other than the fact that typing is in the std lib?
 
4:26 PM
¯\_(ツ)_/¯
 
What I (think I) know: typing provides types for statically typing things using function annotations, but doesn't actually do type checking. Mypy does do type checking, but also provides types?
 
That matches my best guess
 
@Kevin According to this blog post's date, it's been here for almost a year? Hmm
I'm surely missing something by saying that.
 
If mypy does magic to make sure that {"a": 1} matches Dict[str, Union[int, float]], then what am I supposed to do if I want the strict logic of "the value must be a subtype of both int and float"?
@BožoStojković Hmm, I must have missed it because most of my source diving is done within C files.
 
Ahh I C (sorry)
Not sure what kind of jump it would be to support C too
 
4:33 PM
Just as well, CPython sometimes performs some macro trickery that would surely confound any type looker upper
As an oversimplified semi-fictional example, you might find uint_32 used all over the place, but there's no struct uint_32 anywhere. There is, however, a struct uint_NATIVEINTSIZE, as well as a #define NATIVEINTSIZE 32 squirreled away in one of the system architecture dependent .h files
You'd need to embed a significant portion of the C compiler into the type looker upper to deduce that uint_32 depends on uint_NATIVEINTSIZE
 
Oh wow
But I guess some implementation of type looker-upper would be better than none. Or?
 
I'd be happy with an implementation that gives the right answer 75% of the time, doesn't know the answer 20% of the time, and gives the wrong answer 5% of the time. Github might have higher standards than me, though.
 
Also, I thought looker upper was something you made up. It actually seems to be a word :P
 
I have a question about encodings. Every time I run into issues with string encoding I just get so lost.
I have some unicode items in python, like u'The mendicant\x92s wife'
 
"looker upper" is highly colloquial but not something I invented ;-)
 
4:44 PM
The \x92 is some encoding (I don't know which one). But now I want to display this in html/js
Anybody has any hints? Should I encode the unicode items? Then I can figure out how to properly display the unicode items in html
 
@Kevin Intersection? :P
 
@MitchellvanZuylen If you just write that string to an html file without trying to do any special encoding, what does it look like in your browser?
 
stackoverflow.com/questions/15564063/… leads me to believe that the encoding is window-1252.
How you might fix this depends on where that unicode string is coming from in the first place. If you're writing literally x = u'The mendicant’s wife' in your file, then you should be able to just change your text editor's encoding setting to UTF-8 and Python will understand it as such
If you're loading the string from some external source that you don't have control over, some encoding/decoding may be in order.
 
The strings are coming from a database, and then being render using django
<p class="title"> {{image.photo.title}} </p>
 
4:53 PM
Oh, I meant to ask: are you using Python 3? Strings and bytes and unicode got quite an overhaul after 2.7.
 
Using 2.7.12
I'm trying to google for this issue, but I'm not even sure what to look for
'django display window-1252 string`
 
I don't think the problem is specific to django, so not too surprising if that query doesn't return many useful results
How are you talking to the database? sqlalchemy? something else?
 
No, also all django
I can load a table in as a python class and each instance of the class is a row
And then in a .html file, I add <p class="title"> {{image.photo.title}} </p>
 
Ok. What does your photo class look like?
 
Where image is the actual database instance, where the fields on the item represent datatable columns
 
4:58 PM
Or your image class, whichever
 
Uhh, it's a very, very long class haha
The title itself is title = models.CharField(max_length=512,null=True,blank=True)
 
@MitchellvanZuylen Do you really have to use python 2?
 
class Photo():
title = models.CharField(max_length=512,null=True,blank=True)
Yeah :/
 
Ok, that's the bit I was interested in anyway.
 
@MitchellvanZuylen my condolences
 
5:00 PM
I'm depended on a really old piece of software
Honestly, it really is a miserable situation. it NEEDS ubuntu 14
 
Basically I'm trying to figure out if we can make the field map to a str instead of a unicode and do the encoding ourselves
 
@MitchellvanZuylen the plot thickens...
 
Or alternatively tell the field to use a particular encoding
 
I spend 4 months of my life trying to upgrade the software to ubuntu 18 (which was brand new then)
 
Are you being held in a legacy factory?
 
5:01 PM
Worse, academia
 
heh
Oh, Trusty Tahr. That was a good one.
 
One complication is that the current documentation for Charfield will probably be using the Python 3 version of strings/bytes rather than the 2.7 version of unicodes/strings
 
Is it impossible that conda would magically work on it? That's the most common solution I've heard for "I'm stuck with ancient software in academia"
I've never used it but conda often Just Works^TM
 
I believe I tried to use conda at some point. I think it didn't work with the integreted ipython notebooks
And don't get me started on trying to get jupyter notebooks running on this sad, sad server
 
@AndrasDeak I believe it's Just Works™ that you're looking for
 
5:04 PM
I see no difference
 
pedants do :P
 
docs.djangoproject.com/en/3.1/ref/unicode/… appears to recommend setting the encoding of your database to UTF-8 or UTF-16. I believe this would fix the \x92 problem.
 
Okay, I should be able to try this
But.. then how do I actually get this string from it's current encoding to utf8?
 
If that turns out to be too hard to do, perhaps you could set django's DEFAULT_CHARSET setting to "windows-1252"... But since this affects much more than just how bytes in the database are interpreted, I would thoroughly review the code to make sure it doesn't mangle any non-unicode string literals that can be decoded to utf8 but not windows-1252
 
I'd be very scared to change something so impactful :/
 
5:10 PM
@MitchellvanZuylen If the database uses UTF8, then you shouldn't need to do anything else to make django write utf8 to your html
 
Hmm
I think I'm getting somewhere
I tried to decode/encode the string but was getting an unicodeencodeerror
I found a SO post that said my string might be encoded in latin1
And if I apply this monstrosity it works:
print(t.encode('latin1').decode('cp1252').encode('UTF-8'))
(At least in the console, getting it to JS might be something else)
 
uuuh that smells
latin1 and windows 1252 are almost the same; what you have would try to fix a very subtle mojibake
 
I can smell it, but not understand it
 
which is not to say it's wrong; mojibake happen
@MitchellvanZuylen python 2 makes it even harder to make sure that t where you're starting from makes sense :(
 
The t.encode('latin1') implies that the current t is encoded in latin1?
Or is it currently in some form that CAN be encoded into latin1 but nothing else?
 
5:17 PM
@MitchellvanZuylen that question is ambiguous. If t is a string rather than data (which is impossible to tell in python 2) then t.encode('latin1') will be the latin1-encoded data version of that string
 
Hello, i have trouble multiplying np.ndarray objects into matrixes :
I have 1x2 ndarrays and i want to create a matrix by multplying a vector by its transposed self
I do : np.dot(x_train[i] - mu_1, np.transpose(x_train[i] - mu_1))
But it returns a float even i put the np.transpose on the other side
 
@colin transposing scalars is a no-op
transposing 1d arrays is also a no-op
what shapes do x_train and mu_1 have?
np.outer(..., ...) probably does what you need
@MitchellvanZuylen in python 3 we could see that t is an str and t.encode('latin1') is bytes, i.e. data
That data can only be turned into text (a string) again if you decode it with latin1
 
latin-1 is often used to fix mojibake because it losslessly converts unicode to bytes as long as the unicode only uses code points 0 through 255.
 
encoding with latin1 and decoding with cp1252 will almost be a no-op, except for the subtle differences where latin1 and windows encoding differ (blame microsoft for the confusion)
 
x_train[i] is of shape (2,) and same for mu_1
 
5:20 PM
@colin OK, so you probably want arr = x_train[i] - mu_1; np.outer(arr, arr), or arr * arr[:, None].
Is this in a loop? Are there other things in the loop? Multiplications like this should be possible on the full x_train array.
 
It works now!
Thanks @kevin, @AndrasDeak
 
@MitchellvanZuylen I'm curious what this software has to do with a django app? (I'm envisioning you might be able to get a virtual machine running on the hardware and bridge some local network connections. At least then you can have an isolated version of Ubuntu 18 and Python 3?)
 
I believe the utf8->latin1->cp1252->utf8 conversion can only fail if the database contains windows-1252 characters with ordinal value greater than or equal to 192. So, primarily, letters with umlauts and other accent marks.
 
@AndrasDeak this is basically what i do now : imgur.com/a/CokXXVe
 
5:27 PM
UTF8 uses bytes greater than 192 to indicate code points that take up more than one byte to express, so django will dutifully gobble up two bytes when it sees a windows-1252 À in the db, and either hand you a nonsense character, or fail to find a code point at all
 
@MitchellvanZuylen Their github page seems to suggest the same idea as me, just reversed (with it installed on a VM)
 
Hmm, neither would be great. But one I can live with, one not so much
 
@AndrasDeak Probably should alias rather than burninate -> , since someone is likely to create it again if deleted.
 
@smci Works for me
 
Ohh, nm, I've started going through the docs and you're tried to Django to query the DB. This seems "fun"
 
5:31 PM
Or, hmm, I believe Python's utf8 decoder is fairly fault-tolerant, so it probably won't gobble up an extra byte unless that second byte maps to a meaningful value. So it's only when that second byte begins with 0b01xxxxxx that it will gobble two bytes against your wishes.
The rest of the time it will say "this isn't a valid two-byte code point, I'm just going to give you two one-byte characters, 'kay?" which happens to be exactly what you want
TLDR: you won't get a unicodeDecodeError, and you won't get mojibake nearly as often as I previously thought. It's still a distant possibility though.
 
Those are chances I'm willing to take haha
Luckily the part these strings are going with the encode/decode/encode are not super critical
@roganjosh Yeah, I think what you suggest might work, but then the DB would need to be a server itself, I think. Which would probably slow everything down
Also, the pip-requirements, half those packages are no longer supported
But it sort-off works and my thesis deadline is approaching so..
Whatever boat floats
 
I'd be tempted to spend another 4 months on making python 3 happens. Ah, deadline; the best kind of inspiration.
 
Just don't submit. I didn't and look at how happy I am! <haunts me every night>
 
Haha, I wish
 
"Titanic: a thesis. By Mitchell van Zuylen"
3
 
5:38 PM
But my university it pretty strict. In two months, money stops flowing
 
I guess that's normal
 
Yeah. Mine stopped too. We didn't have to submit at the end of funding - we had an extra 6 months (?) I think
 
A few years ago, PhD could get a few years of paid extension (at my uni)
 
Woah, that's surely atypical
 
Yeah. Absolutely not a thing here.
 
5:39 PM
Yeah, that'll be similar. I think I have a little less, but with COVID and everything I can probably get some extension
 
Don't do it. Like, my serious advice, don't
 
No extension or no submission?
 
Just get something in by that deadline and get it off your shoulders
 
shush, don't curse the poor guy :'D
 
5:40 PM
oh I thought you meant submit, hehe
 
Sorry, I should have clarified :P I enjoyed the opportunity for ambiguity too much :P
 
I wish I could just be done with this, but then how am I going to get a post doc?
Honestly, my escape-fantasy was to quit the PhD and start a restaurant. With COVID I think that's off the table too
 
If you missed my clarification: I'm absolutely advocating submitting your thesis. I'm objecting to even considering the option of getting an extension
It landed me in such an unsustainable mess when I had to take a job to support myself and I ended up throwing away 3 years to get no qualification. I took all the learnings I needed from it I guess, but I walked away empty-handed
 
Ouch, that's harsh. I'm sorry that happened
 
It hasn't really impacted me in the long-run. It just sucks is all
 
5:44 PM
I definitely want to avoid that situation. I have a grant I want to apply for in March. So I'm going to have submit before that time as the grant requires it
 
@roganjosh at least you have cool malaria stories
 
This is true!
 
cool malaria stories - umm... :p
 
I just popped back in after a while to rant about graphing libraries and saw gradstudentwoes. What's happening?
 
Nothing much, @roganjosh was insisting I drop out of my PhD
 
5:56 PM
@MitchellvanZuylen Seconding the other opinions: just roll your sleeves up and get on with PhD by deadline. Also, I don't understand why so many rational people have restaurant fantasies; 90% of new restaurants fail, and that was before the worst recession in 50-90 years. The latest trend now there are so many unemployed chefs and closed restaurants that aren't able to economically reopen, at 100% capacity, is underground restaurants: aka you hire chefs to come and cook at/outside your place for a party.
 
actually, I read the thread in the last couple of minutes - I think he's advocating that you submit your thesis
 
('underground restaurant' != 'ghost kitchen', which is an interesting coincidence for Halloween)
 
@smci I'm another statistic, then. I learned to cook in the last 2-3 years of my PhD, which then became my backup plan (/ escape fantasy)
 
I think the fantasy is just that, a fantasy. Probably with all the cooking shows that make it look glorious. In actually, I would be a terrible restaurant owner
 
FWIW, just yesterday I got one of my PhD students to get an extension by 2-4 months. It really depends on the circumstances and your progress.
 
5:58 PM
@inspectorG4dget totally had a building lined up for my quirky restaurant idea
 
@MitchellvanZuylen I never wanted to own a restaurant - I just wanted to cook in one
@roganjosh pray tell
 
@smci That is my plan! I submitted 2 papers in the last two weeks, and have a 3rd ready to go. Then I have a little over 2 months to write my thesis - which will basically be these papers with a nice introduction and that should be that
 
00:00 - 18:0018:00 - 00:00

« first day (3659 days earlier)      last day (1272 days later) »