arrays,python-3.x,indexing,indices,abuse

I know an array sounds like a good representation of a chessboard, but why not use a dictionary? you can have the positions as keys and the value as the piece: chessboard = { "a1": "Rw", "a2": "pw", "a3": "", ... "h7": "pb", "h8": ""} You can call/set/update a position...

You are indexing your lists with a non-int type index: for count in list_kp2_ok: for count1 in list_kp2_2_ok: if list_kp2_ok[count]==list_kp2_2_ok[count1]: So a quick fix for that is to do it this way: for coord1 in list_kp2_ok: for coord2 in list_kp2_2_ok: if coord1==coord2: You can even do the whole coding in...

c++,templates,template-specialization,c++14,indices

I would simply reduce your integer_range to a single, non-recursive call to std::integer_sequence: namespace details { template<typename Int, typename, Int S> struct increasing_integer_range; template<typename Int, Int... N, Int S> struct increasing_integer_range<Int, std::integer_sequence<Int, N...>, S> : std::integer_sequence<Int, N+S...> {}; template<typename Int, typename, Int S> struct decreasing_integer_range; template<typename Int, Int... N, Int...

My team and I came across the same problem a year or two ago. MathWorks explained that the sqrt() function has an issue with powers when they are added. To overcome this issue and achieve the same result, square each term outside of the sqrt() function: input1 = 4^2; input2...

arrays,join,elasticsearch,indices

Clear the indices if you have any curl -XDELETE "http://example.com:9200/currencylookup/" curl -XDELETE "http://example.com:9200/currency/" Create the lookup table curl -XPUT http://example.com:9200/currencylookup/type/2 -d ' { "conv" : [ { "currency":"usd","username":"abc", "location":"USA" }, { "currency":"inr", "username":"def", "location":"India" }, { "currency":"IDR", "username":"def", "location":"Indonesia" }] }' Lets put some dummy docs curl -XPUT "http://example.com:9200/currency/type/USA" -d...

As I believe others have mentioned in your comments, the issues relating to your code are lifetime issues. Note that you're passing the second parameter, 5, to curry as an rvalue: auto add5 = curry(add, 5); Then, in the invocation of the curry function, you're creating a copy of that...

numpy,multidimensional-array,indices

You can use a list of tuples, but the convention is different from what you want. numpy expects a list of row indices, followed by a list of column values. You, apparently, want to specify a list of (x,y) pairs. http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#integer-array-indexing The relevant section in the documentation is 'integer array...

python,list,python-3.x,swap,indices

Using the enumerate() function to decorate each value with their index, sorting with sorted() on the values, and then un-decorate again to extract the indices in value order: [i for i, v in sorted(enumerate(A), key=lambda iv: iv[1])] This has a O(NlogN) time complexity because we used sorting. Demo: >>> A...

arrays,algorithm,matlab,increment,indices

I suspect by 'pointers' you mean the arrows of a clock, but that doesn't make it any clearer. What I get from your pattern is that you want the binomial coefficients, you can get them with the nchoosek function: array=[1 2 3 4]; for k= 1:numel(array) b{k,1} = nchoosek(array,k); end...

Approach 1 To convert F from its current linear-index form into row indices, use mod: rows = cellfun(@(x) mod(x-1,size(A,1))+1, F, 'UniformOutput', false); You can combine this with your code into a single line. Note also that you can directly use B as an input to arrayfun, and you avoid one...

One approach - [colID,~] = find(squeeze(any(bsxfun(@eq,b,permute(a,[1 3 2])),1))) Or if you would like to avoid squeeze and any - [~,colID,~] = ind2sub([size(b) numel(a)],find(bsxfun(@eq,b(:),a))) ...

You just need to use the boolean indexing of numpy. Add this line: y[((t>0.5)&(t<=1.5))|((t>3)&(t<=4))]=0. ...

Are you using left-handed view coordinates or right-handed view coordinates in your application (see link)? If you are using left-handed view coordinates, you need to flip the winding of each triangle in the index buffer. assert( (indices.size() % 3) == 0 ); for( auto it = indices.begin(); it != indices.end();...

javascript,function,callback,add,indices

You are returning too early, the first iteration through the loop is going to end the function call. It looks like you want to use a callback to do the merge work, much like you would with .filter, .sort of Array. If that is the case, you do either the...

pandas,dataframes,indices,columnname

You basically just need to manipulate the column names, in your case. Starting with your original DataFrame (and a tiny index manipulation): from StringIO import StringIO import numpy as np a = pd.read_csv(StringIO('T,Ax,Ay,Az,Bx,By,Bz,Cx,Cy,Cz,Dx,Dy,Dz\n\ 0,1,2,1,3,2,1,4,2,1,5,2,1\n\ 1,8,2,3,3,2,9,9,1,3,4,9,1\n\ 2,4,5,7,7,7,1,8,3,6,9,2,3')) a.set_index('T', inplace=True) So that: >> a Ax Ay Az Bx By Bz Cx Cy...

Try this. import numpy as np arr = np.array([[0,1,2], [1,2,3], [2,3,4], [3,4,5]]) indices = np.where(arr>2) for r, c in zip(*indices): print(r, c) Prints 1 2 2 1 2 2 3 0 3 1 3 2 So, it should work. You can use itertools.izip as well, it would even be a...

c#,properties,unity3d,indices,indexer

The problem is that your TileMap property is not of type TileMap, it's of type PathFindingMapTile[,], which requires two indexes.

python,string,comparison,indices

I assume you mean the number of indices where the character is the same in both strings. Therefore, I would do: >>> sum(a==b for a, b in zip('bob', 'boa')) 2 Wrapping that in a function should be trivial....

If I understand correctly, you want the 3rd, 5th, and 7th entry in c(1:3, 4:6, 10:12, ...), which means you want extract specific sets of indices from a vector. When you do something like c(1:3, 4:6, ...), the resulting vector isn't what it sounds like you want. Instead, use list(1:3,...

arrays,string,matlab,data-structures,indices

I found the following to work. First assigning b(1).b.c to an array S and then comparing that with the data structure c using ismember. S = [b(1).b.c] S = S' [~, ind] = ismember(S,{c(1).b.c}) I have found this to work. Also, [~, ind] = ismember([b(1).b.c}],[c(1).b.c]) does not give an error...

r,list,criteria,subset,indices

Your question isn't totally clear. It sounds like you're looking for the following: > df$ID %in% df$ID[which(df$ACTION == "Work")] [1] FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE [11] TRUE FALSE FALSE FALSE FALSE FALSE Step by step: ## Which rows have "Work" in the "ACTION" column? >...

python,arrays,interpolation,indices,interpolate

Does Numpy interp do what you want?: import numpy as np x = [0,1,2] y = [2,3,4] np.interp(0.56, x, y) Out[81]: 2.56 ...

indexing,customization,kibana,indices

I'm not sure if i understood perfectly but you can use an index pattern in kibana like "server*" Or an other possibility would be to add alias to your indices, they would be accessible with the same index name in kibana...

python,numpy,dynamically-generated,indices

Your first example can be produced via numpy methods as: In [860]: np.concatenate((np.zeros((3,1),int),np.arange(1,16).reshape(3,5)),axis=1).ravel() Out[860]: array([ 0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 10, 0, 11, 12, 13, 14, 15]) That's because I see this 2d repeated pattern array([[ 0, 1, 2, 3, 4, 5], [ 0,...

python,matrix,multidimensional-array,indices

You need to change your where line to something like: data_indices = numpy.where((data<=obj_value_max) & (data>=obj_value_min)) Notice the ()s around each conditional clause and the use of & (meaning "and"). This works because in numpy, <,<=,>,>=,&,|,... are overridden, i.e. they act differently than in native python. and and or cannot be...

python,arrays,numpy,scipy,indices

Here's a way of finding a specific value that is applicable to both numpy arrays and sparse matrices In [119]: A=sparse.csr_matrix(np.arange(12).reshape(3,4)) In [120]: A==10 Out[120]: <3x4 sparse matrix of type '<class 'numpy.bool_'>' with 1 stored elements in Compressed Sparse Row format> In [121]: (A==10).nonzero() Out[121]: (array([2], dtype=int32), array([2], dtype=int32)) In...

c++,templates,c++11,variadic-templates,indices

Yes, you can concat recursively: template <typename, typename, typename> struct Concat; template <typename T, template <T...> class P, T... A, T... B> struct Concat<T, P<A...>, P<B...>> { using type = P<A..., B...>; }; template <typename T, typename IndexPack> struct Make; template <typename T, template <T...> class P, T... I, T...

python,python-3.x,encryption,indices,vigenere

for i in range(len(text)): print(alphabet.index(text.lower()[i])) just add lower() and it will work...

python,list,histogram,typeerror,indices

That error is because you are trying to assign a key to a list, and list only can be indexed by intenger list[0], list[1], so on. So, hinstogram must be a dict not a list Make sure when you call add_to_hist method, pass a dict. You can init a dict...

For you first question: N=300; v=rand(1000,1); %// sample data v(1:N)=[]; And the second: O=Q(I) ...

You can use which to find the indices of the maximum for your matrix. set.seed(1234) mat <- matrix(sample(1:20), ncol = 5) mat # [,1] [,2] [,3] [,4] [,5] # [1,] 3 14 8 20 17 # [2,] 12 10 6 15 16 # [3,] 11 1 7 2 19 #...

Q. I want to have the user input how many items they want to extract, as a percentage of the overall list length, and the same indices from each list to be randomly extracted. A. The most straight-forward approach directly matches your specification: percentage = float(raw_input('What percentage? ')) k =...

You are declaring Array as: int [] Array = {12,11,10,15,16,17}; and then iterating in: for (int i=0; i< inputData.Array().length;i++){ this means that the values of i are {0,1,2,3,4,5} and x is defined like IloNumVar[6][6][6] when you do: this.x[inputData.Array()[i]] is and error because you dont have indexes {12,11,10,15,16,17} in the x...