scalar

Python RuntimeWarning: overflow encountered in long scalars

梦想与她 提交于 2019-11-27 07:33:05
I am new to programming. In my latest Python 2.7 project I encountered the following: RuntimeWarning: overflow encountered in long_scalars Could someone please elaborate what this means and what I could do to fix that? The code runs through, but I'm not sure if it is a good idea to just ignore the warning. It happens during an append process like: SomeList.append(VeryLongFormula) Here's an example which issues the same warning: import numpy as np np.seterr(all='warn') A = np.array([10]) a=A[-1] a**a yields RuntimeWarning: overflow encountered in long_scalars In the example above it happens

PHP - cannot use a scalar as an array warning

混江龙づ霸主 提交于 2019-11-27 06:33:28
问题 I have the following code: $final = array(); foreach ($words as $word) { $query = "SELECT Something"; $result = $this->_db->fetchAll($query, "%".$word."%"); foreach ($result as $row) { $id = $row['page_id']; if (!empty($final[$id][0])) { $final[$id][0] = $final[$id][0]+3; } else { $final[$id][0] = 3; $final[$id]['link'] = "/".$row['permalink']; $final[$id]['title'] = $row['title']; } } } The code SEEMS to work fine, but I get this warning: Warning: Cannot use a scalar value as an array in

Scalar vs. primitive data type - are they the same thing?

≡放荡痞女 提交于 2019-11-27 04:59:15
问题 In various articles I have read, there are sometimes references to primitive data types and sometimes there are references to scalars. My understanding of each is that they are data types of something simple like an int, boolean, char, etc. Is there something I am missing that means you should use particular terminology or are the terms simply interchangeable? The Wikipedia pages for each one doesn't show anything obvious. If the terms are simply interchangeable, which is the preferred one?

Python RuntimeWarning: overflow encountered in long scalars

∥☆過路亽.° 提交于 2019-11-26 22:14:49
问题 I am new to programming. In my latest Python 2.7 project I encountered the following: RuntimeWarning: overflow encountered in long_scalars Could someone please elaborate what this means and what I could do to fix that? The code runs through, but I'm not sure if it is a good idea to just ignore the warning. It happens during an append process like: SomeList.append(VeryLongFormula) 回答1: Here's an example which issues the same warning: import numpy as np np.seterr(all='warn') A = np.array([10])

Constructing pandas DataFrame from values in variables gives “ValueError: If using all scalar values, you must pass an index”

南笙酒味 提交于 2019-11-26 18:05:46
This may be a simple question, but I can not figure out how to do this. Lets say that I have two variables as follows. a = 2 b = 3 I want to construct a DataFrame from this: df2 = pd.DataFrame({'A':a,'B':b}) This generates an error: ValueError: If using all scalar values, you must pass an index I tried this also: df2 = (pd.DataFrame({'a':a,'b':b})).reset_index() This gives the same error message. The error message says that if you're passing scalar values, you have to pass an index. So you can either not use scalar values for the columns -- e.g. use a list: >>> df = pd.DataFrame({'A': [a], 'B'

How can a scalar be passed to a vector (1D array) to a Fortran subroutine?

拥有回忆 提交于 2019-11-26 12:32:29
问题 There is this program: INTEGER i,k REAL*8 mp(15,48) REAL*8 sp(15) k=0 do i=1,12 k=k+1 call Equaltensors(sp,mp(1,k),15) enddo end c===================== subroutine Equaltensors(tensA,tensB,n) REAL*8 tensA(n),tensB(n) INTEGER i do i=1,n tensB(i)=tensA(i) enddo return end So basically the value of mp(1,1) and so on is passed to the subroutine as a vector tensB(15) with n=15. What I don\'t understand is how a real number can be stored in a one-dimension array in a subroutine. 回答1: The title of

How to multiply all integers inside list [duplicate]

馋奶兔 提交于 2019-11-26 09:46:37
问题 This question already has answers here : How to multiply individual elements of a list with a number? (4 answers) How do I multiply each element in a list by a number? (7 answers) Closed last year . Hello so I want to multiply the integers inside a list. For example; l = [1, 2, 3] l = [1*2, 2*2, 3*2] output: l = [2, 4, 6] So I was searching online and most of the answers were regarding multiply all the integers with each other such as: [1*2*3] 回答1: Try a list comprehension: l = [x * 2 for x

PHP Constants Containing Arrays?

元气小坏坏 提交于 2019-11-26 00:35:09
问题 This failed: define(\'DEFAULT_ROLES\', array(\'guy\', \'development team\')); Apparently, constants can\'t hold arrays. What is the best way to get around this? define(\'DEFAULT_ROLES\', \'guy|development team\'); //... $default = explode(\'|\', DEFAULT_ROLES); This seems like unnecessary effort. 回答1: NOTE: while this is the accepted answer, it's worth noting that in PHP 5.6+ you can have const arrays - see Andrea Faulds' answer below. You can also serialize your array and then put it into