array

excel VBA - return Criteria1 Array from an Autofilter

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a table that I need to return all of the toggled values. When i record a macro after selecting which ones i want it looks like this ActiveSheet.Range("$A$1:$P$1000").AutoFilter Field:=6, Criteria1:=Array("A" _ , "B", "C", "D", "E", "G"), Operator:=xlFilterValues the problem i have is that the a,b,c, etc values that will be filtered by the user will always be changing so I can't hardcode any criteria that way. is there a way i can return an array of what is toggled on in a fashion similar to how this looks? msgbox ActiveSheet.Range("$A

php Checking if value exists in array of array

匿名 (未验证) 提交于 2019-12-03 02:18:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an array within an array. $a = array ( 0 => array ( 'value' => 'America', ), 1 => array ( 'value' => 'England', ), ) How do I check if 'America' exists in the array? The America array could be any key, and there could be any number of subarrays, so a generalized solution please. Looking on the php manual I see in_array, but that only works for the top layer. so something like in_array("America", $a) would not work. Thanks. 回答1: A general solution would be: function deep_in_array($needle, $haystack) { if(in_array($needle, $haystack)) {

Python 3.x's dictionary view objects and matplotlib

匿名 (未验证) 提交于 2019-12-03 02:18:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In python 3.x keys() , values() and items() return views . Now while views certainly have advantages , they also seem to cause some compatibility issues. For example with matplotlib (ultimately it's with numpy ). As an example this and this answers on stackexchange questions work just fine with python 2.x but raise an Exception when executing them in python 3.4. A minimal example would be: import matplotlib.pyplot as plt d = {1: 2, 2: 10} plt.scatter(d.keys(), d.values()) Which raises TypeError: float() argument must be a string or a number,

Python memory usage of numpy arrays

匿名 (未验证) 提交于 2019-12-03 02:18:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm using python to analyse some large files and I'm running into memory issues, so I've been using sys.getsizeof() to try and keep track of the usage, but it's behaviour with numpy arrays is bizarre. Here's an example involving a map of albedos that I'm having to open: >>> import numpy as np >>> import struct >>> from sys import getsizeof >>> f = open ( 'Albedo_map.assoc' , 'rb' ) >>> getsizeof ( f ) 144 >>> albedo = struct . unpack ( '%df' % ( 7200 * 3600 ), f . read ( 7200 * 3600 * 4 )) >>> getsizeof ( albedo ) 207360056 >>>

python why use numpy.r_ instead of concatenate

匿名 (未验证) 提交于 2019-12-03 02:17:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In which case using objects like numpy.r_ or numpy.c_ is better (more efficient, more suitable) than using fonctions like concatenate or vstack for example ? I am trying to understand a code where the programmer wrote something like: return np.r_[0.0, 1d_array, 0.0] == 2 where 1d_array is an array whose values can be 0, 1 or 2. Why not using np.concatenate (for example) instead ? Like : return np.concatenate([[0.0], 1d_array, [0.0]]) == 2 It is more readable and apparently it does the same thing. 回答1: np.r_ is implemented in the numpy/lib

ArrayList initial capacity and IndexOutOfBoundsException [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: Initial size for the ArrayList 11 answers Consider this sample code: List myList = new ArrayList (7); myList.add(5, "Hello"); myList.removeAll(Collections.singleton(null)); System.out.println(myList.size() + " objects:" ); for (String s : myList) { System.out.println("\t" + s); } myList is initialized with an initial capacity of 7, then the next line attempts to add the String "Hello" at position 5. This throws an IndexOutOfBoundsException: Exception in thread "main" java.lang

Updating the array object in React state using immutability helper

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am updating an object within an array in React state using immutability helper . The object I want to modify is nested: this.state = { a: { b: [{ c: '', d: ''}, ...] } } I want to update the prop c within the nth element of b using immutability helper. The equivalent code without the immutability helper is: const newState = Object.assign({}, this.state); newState.a = Object.assign({}, newState.a); newState.a.b = newState.a.b.slice(); newState.a.b[n] = Object.assign({}, newState.a.b[n]); newState.a.b[n].c = 'new value'; this.setState({

Concatenate/merge array values during grouping/aggregation

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a table with the an array column type: title tags "ridealong" ; "{comedy,other}" "ridealong" ; "{comedy,tragedy}" "freddyjason" ; "{horror,silliness}" I would like to write a query that produces a single array per title(in an ideal world it would be a set/deduplicated array) e.g. select array_cat ( tags ), title from my_test group by title The above query doesn't work of course, but I would like to produce 2 rows: "ridealong" ; "{comedy,other,tragedy}" "freddyjason" ; "{horror,silliness}" Any help or pointers would be very

Finding out the filename that called my function in PHP

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I find out the filename of the script that called my function? For example, function sthing() { echo __FILE__; // echoes myself echo __CALLER_FILE__; // echoes the file that called me } 回答1: A solution might be to use the debug_backtrace function : in the backtrace, that kind of information should be present. Or, as Gordon pointed out in a comment, you can also use debug_print_backtrace if you just want to output that information and not work with it. For instance, with temp.php containing this : <?php include 'temp-2.php'; my

Why it is impossible to create an array of references in c++?

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: C++ Standard 8.3.2/4 says: There shall be no references to references, no arrays of references, and no pointers to references. But I can't understand why this restriction is added to c++. In my opinion the code bellow can easily be compiled and work? What is the real cause of this restriction? int a = 10, b = 20; int &c[] = {a, b}; 回答1: Because indexation into an array is actually defined in terms of an implicit conversion to a pointer, then pointer arithmetic. So to support this, you'd have to also support pointers to references, and define