Hot answers tagged

10

What you're trying to do can actually be done very quickly, without any loops, and can even be ported to make valuable use of a GPU. Here's a quick example that you can test yourself in octave-online: shots=0:50:250 lens = 0:10 bsxfun(@times,shots',lens) The outputs are as follows: shots=[0 50 100 150 200 250] lens =[0 1 2 3 4 5 ...


10

Assuming that your sample code is really what you are looking for (which I doubt judging by the full code example you had posted originally), the answer by @vtan707 would work, but is very awkward because of its requirement for specifically shaped 2D arrays. Having to do nested calls of np.array on a single-element list of a function output kinda gives it ...


8

You can use dot multiplication to achieve this: import numpy as np shot = np.array([np.arange(0, 100, 50)]).T lens = np.array([np.arange(10)]) total = np.dot(shot,lens) print(total) This gives you the below results: [[ 0 0 0 0 0 0 0 0 0 0] [ 0 50 100 150 200 250 300 350 400 450]]


7

Just adding some timings for @Antimon's answer. Using numpy.outer is definitely the way to go IMO. def list_version(shots, lens): list_total = [] for shot in list_shot: list_out = [] for lens in list_lens: val = shot * lens list_out.append(val) list_total.append(list_out) return list_total def ...


6

I know this was long ago, but for those that find the same problem in the future, the sisl python package might be useful. It has a generic Grid object and it knows how to read the grids from VASP: import sisl grid = sisl.get_sile("path/to/your/CHGCAR").read_grid() Then grid is a sisl Grid object, so: grid.grid contains the numpy array of values ...


4

Ertl and Schuffenhauer, who developed the synthetic accessibility score, provide an implementation packaged with RDKit called sascorer.py. This is provided in the Contrib folder of the RDKit repo; what this means is it isn't formally part of RDKit, but with a little work can be accessed from RDKit. An example of how to do this is given in an issue on the ...


3

This is basic bash-script which will be quite useful, just start with scratch phonopy -d --dim 2 2 2 --pa auto -c POSCAR for m in `ls POSCAR-0*` do fol=`echo ...


3

Here are a couple of extra links that might be helpful in your (now 5months old) quest: [1], [2]. It would be helpful for all of us if you could put up that green chekmarck on the answers you found helpful and maybe tell us how you ended up resolving your issue, if you already have that is ...


Only top voted, non community-wiki answers of a minimum length are eligible