today i am in the position to migrate some pretty old perforce repositories to git. While this is realy interesting there is one thing that caught my eye. All special characters in the commit messages and even the author names are not in the correct encoding. So i tried to investigate where the problem comes …
Tag: python
Comma Syntax: rationale behind a hanging comma in a statement being a SyntaxError
In Python, a variable or literal followed by a hanging comma is a one-tuple: …and a series of comma-separated variables/literals (whether or not they are followed by a hanging comma) is also a tuple: However, inside a callable/function, this syntax is treated differently, because the comma is used for s…
Convert a numpy.ndarray to string(or bytes) and convert it back to numpy.ndarray
I’m having a little trouble here, I’m trying to convert a numpy.ndarray to string, I’ve already done that like this: It works, but I’m wondering if I can transform it back to a numpy.ndarray. What’s the best way to do this? I’m using numpy 1.8.1 Context: The objective is to…
Computing the correlation coefficient between two multi-dimensional arrays
I have two arrays that have the shapes N X T and M X T. I’d like to compute the correlation coefficient across T between every possible pair of rows n and m (from N and M, respectively). What’s the fastest, most pythonic way to do this? (Looping over N and M would seem to me to be neither fast
Implement MATLAB’s im2col ‘sliding’ in Python
Q: How to speed this up? Below is my implementation of Matlab’s im2col ‘sliding’ with the additional feature of returning every n’th column. The function takes an image (or any 2 dim array) and slides from left to right, top to bottom, picking off every overlapping sub-image of a given…
NameError: name ‘true’ is not defined [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 7 y…
django mongo engine – DatabaseError: Unknown option auto_start_request
After going into the django shell and creating the following entry: i am not able to use i am getting the following error message My folder structure is as follows: The versions used are: Is there anything i am missing? Can somebody please help me on what the problem is? i am new to django and mongodb. I am n…
How to get a list of all indices of repeated elements in a numpy array
I’m trying to get the index of all repeated elements in a numpy array, but the solution I found for the moment is REALLY inefficient for a large (>20000 elements) input array (it takes more or less 9 seconds). The idea is simple: records_arrayis a numpy array of timestamps (datetime) from which we wa…
How do I remove 1 instance of x characters in a string and find the word it makes in Python3?
This is what I have so far, but I’m stuck. I’m using nltk for the word list and trying to find all the words with the letters in “sand”. From this list I want to find all the words I can make from the remaining letters. In this case I have to use all the letters to find the words
Python hide ticks but show tick labels
I can remove the ticks with but this removes the labels as well. Any way I can plot the tick labels but not the ticks and the spine Answer You can set the tick length to 0 using tick_params (http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.tick_params):