dimensions

ctypes - numpy array with no shape?

Deadly 提交于 2019-12-01 02:28:44
问题 I am using a python wrapper to call functions of a c++ dll library. A ctype is returned by the dll library, which I convert to numpy array score = np.ctypeslib.as_array(score,1) however, the array has no shape? score >>> array(-0.019486344729027664) score.shape >>> () score[0] >>> IndexError: too many indices for array How can I extract a double from the score array? Thank you. 回答1: You can access the data inside a 0-dimensional array via indexing [()] . For example, score[()] will retrieve

matrix and table names / dimnames

て烟熏妆下的殇ゞ 提交于 2019-12-01 00:48:59
Probably my question is answered somewhere but I have used my searching resources before asking. I have a sample table in R : munic Gender Mun1 Mun2 female 146980 285797 male 140436 270084 When I use dimnames(sample) I get the following: > dimnames(sample) $Gender [1] "female" "male" $munic [1] "Mun1" "Mun2" And I want to create one exactly alike. So I do the following: Mat<-matrix(c(148470,24721,22829,24777,26137,43169,49613,40406,48337,34296,19492,+ 176712, 27406, 23010, 25487, 27064, 48349, 52140, 44335, 50908, 35814, 18825), nrow=2) colnames(Mat) <-c("mun_5","mun_1","mun_2","mun_3","mun_4"

matrix and table names / dimnames

三世轮回 提交于 2019-11-30 18:32:21
问题 Probably my question is answered somewhere but I have used my searching resources before asking. I have a sample table in R : munic Gender Mun1 Mun2 female 146980 285797 male 140436 270084 When I use dimnames(sample) I get the following: > dimnames(sample) $Gender [1] "female" "male" $munic [1] "Mun1" "Mun2" And I want to create one exactly alike. So I do the following: Mat<-matrix(c(148470,24721,22829,24777,26137,43169,49613,40406,48337,34296,19492,+ 176712, 27406, 23010, 25487, 27064, 48349

Google Analytics Custom Dimension Not Being Set

北慕城南 提交于 2019-11-30 18:19:13
I've recently upgraded our site to use Universal Analytics and am trying to get some custom dimensions to work. However, no custom dimension data appears to be logged. Below is an example of my code. ga('create', 'UA-XXXXX', 'test.com'); ga('send', 'pageview'); ga('set', 'dimension1', '149377'); Do I need to set custom dimensions before sending pageview? A dimension is sent along with the either a page view or an event. It won't get sent by itself. So you should switch the order of the 'send' and 'set', then look in the network to see the page view call and you should see the dimension as one

Confused by document dimensions in JavaScript

梦想的初衷 提交于 2019-11-30 15:55:25
I am really confused by the different properties that exist in JavaScript for getting the dimensions of a document and how to get those numbers. Can someone recommend a good place to start to understand how I would get the size of the document and position stuff correctly? dkugappi I'll try to answer as simply as I can. The Document and Viewport In terms of geometry, there are two sets of dimensions to be aware of; the document dimensions, which reflect the entire size of the loaded page, including the content beyond the bottom of the window and the viewport dimensions, which reflect the size

Get user's screen&viewport dimensions in php on first load

╄→гoц情女王★ 提交于 2019-11-30 15:43:44
问题 I want to get in PHP the height/width of both the screen and the viewport when a user visits a page. I've tried different ways but they all cause other problems. My goals: Get the info on the first load (no jump page, no reload). Not change the url Not affect the rest of the PHP that runs on load, or make that PHP run twice What I've tried so far: Javascript to get viewport dimensions: if(!isset($_POST['width']) || !isset($_POST['height'])) { echo ' <script type="text/javascript" src="jquery

Get user's screen&viewport dimensions in php on first load

只谈情不闲聊 提交于 2019-11-30 15:17:17
I want to get in PHP the height/width of both the screen and the viewport when a user visits a page. I've tried different ways but they all cause other problems. My goals: Get the info on the first load (no jump page, no reload). Not change the url Not affect the rest of the PHP that runs on load, or make that PHP run twice What I've tried so far: Javascript to get viewport dimensions: if(!isset($_POST['width']) || !isset($_POST['height'])) { echo ' <script type="text/javascript" src="jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { var height = $(window

Assigning 'wrap_content' or '-2' to dimension

末鹿安然 提交于 2019-11-30 14:31:12
问题 I want to create a dimension that would be equal to 'wrap_content' constant. So according to developer.android.com Reference I write: <dimen name="horizontal_border_height">-2</dimen> But ADT says: Error: Integer types not allowed (at 'horizontal_border_height' with value '-2') Asigning 'wrap_content' value generates error too. What am I doing wrong? Any ideas how to make it work? 回答1: Check out app resources API guide and you can see supported unites for a dimension value. You can't use

numpy array that is (n,1) and (n,)

拟墨画扇 提交于 2019-11-30 13:04:14
What is the difference between a numpy array (lets say X) that has a shape of (N,1) and (N,). Aren't both of them Nx1 matrices ? The reason I ask is because sometimes computations return either one or the other. This is a 1D array: >>> np.array([1, 2, 3]).shape (3,) This array is a 2D but there is only one element in the first dimension: >>> np.array([[1, 2, 3]]).shape (1, 3) Transposing gives the shape you are asking for: >>> np.array([[1, 2, 3]]).T.shape (3, 1) Now, look at the array. Only the first column of this 2D array is filled. >>> np.array([[1, 2, 3]]).T array([[1], [2], [3]]) Given

How can I get the size of the android application window and not the physical screen size?

淺唱寂寞╮ 提交于 2019-11-30 09:11:25
In Android, how can I get the size of the app window? I'm NOT looking for the physical screen size, but the actual size of the applications window on the screen. E.g. generally what's left after you take away the notification bar, soft touch buttons, etc. logray If you want the size of your app's window you can just call yourview.getHeight() and yourview.getWidth(); But the view must be drawn for that to work. If you want to get the height before it's drawn you can do this: https://stackoverflow.com/a/10134260/1851478 There are a lot of different cases of screen/view measurement though, so if