julia

what does numpy.vectorize(lambda x:1 – x^3) do?

what does numpy.vectorize(lambda x:1 – x^3) do? Question: I’m new to python and also to numpy package. I was wondering what does this specific line really do. a = numpy.vectorize(lambda x:1 – x^3) I’ve searched about vectorize function but didn’t really get what it does. I’m familiar with julia if there is any instance in …

Total answers: 3

Is it possible to improve python performance for this code?

Is it possible to improve python performance for this code? Question: I have a simple code that: Read a trajectory file that can be seen as a list of 2D arrays (list of positions in space) stored in Y I then want to compute for each pair (scipy.pdist style) the RMSD My code works fine: …

Total answers: 4

Julia running an order of magnitude slower than python

Julia running an order of magnitude slower than python Question: I was trying to port a python code into Julia to try it out (both codes are given below). Julia is running about 10 times slower on my machine than python. What am I doing wrong? I am pretty new to Julia, so appreciate any …

Total answers: 1

Find intervals of true values in vector

Find intervals of true values in vector Question: I am looking for a quick way to find the start and end indexes of each "block" of consecutive trues in a Vector. Both julia or python would do the job for me. I’ll write my example in julia syntax: Say I have a vector a = …

Total answers: 4

Julia code not finishing while Python code does

Julia code not finishing while Python code does Question: I am very new to Julia and was trying to implement/rewrite some of my previous Python code as practice. I was using the Project Euler problem 25 as practice In Python I have def fibonacci(N): """Returns the Nth Fibonacci Number""" F = [0, 1] i = …

Total answers: 4

Python Rand function

Python Rand function Question: Background In Julia programming we have a Rand function which sintaxis is : rand([rng=GLOBAL_RNG], [S], [dims…]) which pick a random element or array of random elements from the set of values specified by S and gives an array of dimension of the third arg. Question I want to apply the same …

Total answers: 1

Multicursor selection in Jupyter without mouse

Multicursor selection in Jupyter without mouse Question: Well-known way to use multicursor selection in jupyter notebook is to press Alt and then use the mouse. However is there some way to do it without mouse? E.g. like Ctrl+Shift in Visual Studio. Doing it with mouse is much more slower than it can be done with …

Total answers: 2

Sieve of Eratosthenes Speed Comparison: Python vs Julia

Sieve of Eratosthenes Speed Comparison: Python vs Julia Question: So I have a little sieve of Eratosthenes function written in both Python and Julia, and I’m comparing run times. Here is the Python code: import time def get_primes(n): numbers = set(range(n, 1, -1)) primes = [] while numbers: p = numbers.pop() primes.append(p) numbers.difference_update(set(range(p*2, n+1, p))) …

Total answers: 4