我有一个php文件,其中的代码如下:
def numpy_ema(data, com=None, span=None, halflife=None, alpha=None):
"""Summary
Calculate ema with automatically-generated alpha. Weight of past effect
decreases as the length of window increasing.
# these functions reproduce the pandas result when the flag adjust=False is set.
References:
https://stackoverflow.com/questions/42869495/numpy-version-of-exponential-weighted-moving-average-equivalent-to-pandas-ewm
Args:
data (TYPE): Description
com (float, optional): Specify decay in terms of center of mass, alpha=1/(1+com), for com>=0
span (float, optional): Specify decay in terms of span, alpha=2/(span+1), for span>=1
halflife (float, optional): Specify decay in terms of half-life, alpha=1-exp(log(0.5)/halflife), for halflife>0
alpha (float, optional): Specify smoothing factor alpha directly, 0<alpha<=1
Returns:
TYPE: Description
Raises:
ValueError: Description
"""
n_input = sum(map(bool, [com, span, halflife, alpha]))
if n_input != 1:
raise ValueError(
'com, span, halflife, and alpha are mutually exclusive')
nrow = data.shape[0]
if np.isnan(data).any() or (nrow > 13835) or (data.ndim == 2):
df = pd.DataFrame(data)
df_ewm = df.ewm(com=com, span=span, halflife=halflife,
alpha=alpha, adjust=False)
out = df_ewm.mean().values.squeeze()
else:
if com:
alpha = 1 / (1 + com)
elif span:
alpha = 2 / (span + 1.0)
elif halflife:
alpha = 1 - np.exp(np.log(0.5) / halflife)
alpha_rev = 1 - alpha
pows = alpha_rev**(np.arange(nrow + 1))
scale_arr = 1 / pows[:-1]
offset = data[0] * pows[1:]
pw0 = alpha * alpha_rev**(nrow - 1)
mult = data * pw0 * scale_arr
cumsums = np.cumsum(mult)
out = offset + cumsums * scale_arr[::-1]
return out
如果我单击提交,为什么<?php
if (isset($_GET['action']) && $_GET['action'] == 'view') {
echo "get";
print_r($_GET);
} else {
}
?>
<html>
<form method="get" action="<?php echo ($_SERVER['PHP_SELF'] . '?action=view&id=4') ; ?>">
<input type="text" />
<input type="submit" />
</form>
</html>
和echo "post";
不输出到屏幕上?
EDIT01
我将代码更改为以下代码:
print_r($_POST);
但是,它没有经过<?php
if (isset($_GET['action']) && $_GET['action'] == 'view') {
echo "if ";
var_dump($_GET);
} else {
echo "else ";
var_dump($_GET) ;
}
?>
<html>
<form method="get" action="?action=view&id=4">
<input type="text" name="username" />
<input type="submit" />
</form>
</html>
,而是经过if
。
屏幕输出如下:
答案 0 :(得分:-1)
Take a look at this code $_GET['action']
. This code will seek the tag with name=action
. Since there is no tag with name=action
, your code will enter else
instead of if
.
To solve this, fix your input submit tag into this.
<input type="submit" name="action" />