简单地将每个第四个项目添加到新列表并返回该列表并不容易?这也将消除从列表中删除元素时可能涉及的任何重复复制。目标列表可以适当尺寸开始。
public static List<String> reduziereKommentare(List<String> zeilen) {
Objects.requireNonNull(zeilen);
List<String> zeilen1= new ArrayList<>(zeilen.size()/4);
for(int i = 3; i < zeilen.size(); i+=4) {
zeilen1.add(zeilen.get(i));
}
return zeilen1;
}
您也可以使用流。
zeilen = IntStream.iterate(3, i ->i < zeilen.size(), i->i+=4)
.mapToObj(zeilen::get).toList();
注意:
- 是列表是空还是大小不被
4
排除,这将起作用。它将忽略额外的元素。 - 将结果分配给原始变量将导致收集的旧列表。
- 我只检查一个零论点,因为这会导致例外。当然,如果向用户提醒大小很重要,只需添加其他检查。
您可以使用被动事件侦听器即使在运行时创建/破坏/重新加载元素,也可以保留它们
function updateDiv() { $("#here").load(window.location.href + " #here");}
$("#here").on("click", () => { alert(" hello world !") })
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="here">here</div>
<button onclick="updateDiv()">Click here</button>
对于这个特定的问题,为什么不基因呢?
特定的正则:“^[。]+\\ public \\”
常规式,仅保留最后两个路径:“^([^\\]*\\)*(。+) \\)“
并将其替换为第二组:“ $ 2”
如果您想学习Regex,这是非常简洁的资源: https://github.com/ziishaned/learn-regex
您应该能够使用get_template_part(字符串$ slug,string $ name = null,array $ args = array())
本身传递值。您可以在此处阅读更多详细信息: get_template_part_part_part
WordPress的示例
get_template_part(
'template-part',
'name',
array(
'key' => 'value',
'key2' => 'value2'
));
来自
var_dump( $args ); // Everything
echo $args['key'];` // Specific values
在您的示例中,您可以在数组中传递AltColorClass的参数,并在模板部分中检索它,希望这会有所帮助。
我找到了这个解决方案,
$all_posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'news'
));
$myMonth = array();
foreach ($all_posts as $single) {
$month = mysql2date('F', $single->post_date);
$month_number = mysql2date('m', $single->post_date);
$myMonth[$month] = $month_number;
}
$ordered_posts = array();
foreach ($all_posts as $single) {
$year = mysql2date('Y', $single->post_date);
$month = mysql2date('F', $single->post_date);
$month_number = mysql2date('m', $single->post_date);
$ordered_posts[$year][$month][] = $single;
}
foreach ($ordered_posts as $year => $months) {
foreach ($months as $month => $posts ) {
?>
<?php
?>
<a href="/news-date/<?php echo $year ?>/<?php echo $myMonth[$month]; ?>">
<div class="arch-year-month">
<div class="arch-month"><?php echo $month ?></div><div class="arch-year"> <?php echo $year ?>
</div>
</div>
</a>
<?php
}
}
?>
以某种方式,我过度复杂化了,当我尝试了有效的绝对最低限度时。
import requests
headers = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36' }
response = requests.get("http://www.example.com/insert.php?network=testnet&id=1245200&c=2803824&lat=7555457", headers=headers)
print(response.text)
DataGenerator并未创建新图像,而只是为每个时代转换它。
如果您的x_train)= [x1,x2,x3]整个训练集中的图像,在每个时期训练时,模型应看到相同的x_train,但是您的x_train很小(只有3张图像) datagen将为模型提供整个x_train稍微转换(根据您在成像中的参数(根据您放入的参数)),例如:
- 对于epoch 1 x_train:[x1,x2,x3]
- for epoch 2 x_train:[x1_t1,x2_t1,x2_t1,x3_t1
- for Epoch 3 for Epoch 3 x_train:[x1_t2,x2_t2,x3_t2]
ETC...
您可以使用循环的:
for item in data:
if item['name'] == 'kabuto':
print(item)
break
此输出:
{'name': 'kabuto', 'id': 140}
同样,您可以使用日期解析器 -
from dateutil.parser import parse
fecha_csv = row[7]
csv_date = parse(fetch_csv).date()
我的问题最终是Ubuntu 22.04安装了WSL版本
。
NAME STATE VERSION
Ubuntu-22.04 Running 1
1
使用这种方式不需要其他表
table#customDataTable{
width:100%;}
table#customDataTable th{text-align:left;}
@media screen and (max-width: 640px) {
table#customDataTable caption {
background-image: none;
}
table#customDataTable thead {
display: none;
}
table#customDataTable tbody td {
display: block;
padding: .6rem;
}
table#customDataTable tbody tr td:first-child {
background: #666;
color: #fff;
}
table#customDataTable tbody tr td:first-child a {
color: #fff;
}
table#customDataTable tbody tr td:first-child:before {
color: rgb(225, 181, 71);
}
table#customDataTable tbody td:before {
content: attr(data-th);
font-weight: bold;
display: inline-block;
width: 10rem;
}
table#customDataTable tr th:last-child,
table#customDataTable tr td:last-child {
max-width: 100% !important;
min-width: 100px !important;
width: 100% !important;
}
}
<table class="table" id="customDataTable">
<thead>
<tr>
<th>#</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
<th>City</th>
<th>Country</th>
</tr>
</thead>
<tbody>
<tr>
<td data-th="#">1</td>
<td data-th="Firstname">Anna</td>
<td data-th="Lastname">Pitt</td>
<td data-th="Age">35</td>
<td data-th="City">New York</td>
<td data-th="Country">USA</td>
</tr>
<tr>
<td data-th="#">1</td>
<td data-th="Firstname">Anna</td>
<td data-th="Lastname">Pitt</td>
<td data-th="Age">35</td>
<td data-th="City">New York</td>
<td data-th="Country">USA</td>
</tr>
<tr>
<td data-th="#">1</td>
<td data-th="Firstname">Anna</td>
<td data-th="Lastname">Pitt</td>
<td data-th="Age">35</td>
<td data-th="City">New York</td>
<td data-th="Country">USA</td>
</tr>
<tr>
<td data-th="#">1</td>
<td data-th="Firstname">Anna</td>
<td data-th="Lastname">Pitt</td>
<td data-th="Age">35</td>
<td data-th="City">New York</td>
<td data-th="Country">USA</td>
</tr>
<tr>
<td data-th="#">1</td>
<td data-th="Firstname">Anna</td>
<td data-th="Lastname">Pitt</td>
<td data-th="Age">35</td>
<td data-th="City">New York</td>
<td data-th="Country">USA</td>
</tr>
</tbody>
</table>
首先,我认为目标函数内的!= np.nan
没有必要检查。取而代之的是,您可以清理数据框,并用零替换所有np.nan
。在优化程序中,该目标函数被调用多次,因此应将其写入尽可能效率和快速。因此,我们删除了np.where
的呼叫。还要注意,依靠索引变量i
在外部范围中知道的事实是不良练习,并且使代码难以读取。我建议这样的事情:
col1 = df1.col1.values[df1.col1.values != np.nan]
col2 = df1.col2.values[df1.col2.values != np.nan]
col1_const = np.array([0,0,0,0,60.0,0,0,0])
col2_const = np.array([0,0,0,0,0,100.0,0,0])
def cost_fun1(v, *args):
i, col1, col2, col1_const, col2_const = args
col1_res = ((1/0.095)*(np.sqrt(col1[i]) - np.sqrt(col1_const[4]*(0.1*v[1]+v[2])**2)))**2
col2_res = ((1/0.12)*(np.sqrt(col2[i]) - np.sqrt(col2_const[5]*(0.1*v[0]+v[2])**2)))**2
return 0.5*np.sqrt(col1_res + col2_res)
接下来,更重要的是,您正在解决多个优化问题,而不是解决一个大规模优化问题。从数学上讲,由于您的目标函数保证是积极的,因此您可以以同样的方式重新重新制定问题,以此答案。然后,cost_fun2
基本上返回所有索引i的所有cost_fun1
的总和。使用一些重塑魔法,该功能几乎看起来相同:
def cost_fun2(vv, *args):
col1, col2, col1_const, col2_const = args
v = vv.reshape(3, col1.size)
col1_res = ((1/0.095)*(np.sqrt(col1) - np.sqrt(col1_const[4]*(0.1*v[1]+v[2])**2)))**2
col2_res = ((1/0.12)*(np.sqrt(col2) - np.sqrt(col2_const[5]*(0.1*v[0]+v[2])**2)))**2
return np.sum(0.5*np.sqrt(col1_res + col2_res))
然后,我们只需解决问题并将解决方案值写入数据框中:
from scipy.optimize import minimize
# initial guess
x0 = np.ones(3*col1.size)
# solve the problem
res = minimize(lambda vv: cost_fun2(vv, col1, col2, col1_const, col2_const), x0=x0, method="trust-constr")
# write to dataframe
type1_vals, type2_vals, type3_vals = np.split(res.x, 3)
df1['type1'] = type1_vals
df1['type2'] = type2_vals
df1['type3'] = type3_vals
如果您需要col1_res
和col2_res
在数据框中,相应地修改目标函数是直截了当的。
最后但并非最不重要的一点是,根据您的数据框的大小,强烈建议将确切的目标梯度传递给scipy.optimize.minimize
,以获得良好的收敛性能。目前,梯度被有限差异近似,该差异很慢,容易舍入错误。
您想使用关联阵列。例如,在这种情况下,使用箭头
令牌将吉他名称与“名称”键关联。
$guitars = ['names' => ['Warvick', 'Gibson', 'Fender']];
$guitars['names'][] = "Ibanez";
echo "<pre>";
var_dump($guitars);
echo "</pre>";
要遇到以下错误,
New-AzSqlServerVirtualNetworkRule: The client has permission to perform action 'Microsoft.Network/virtualNetworks/subnets/joinViaServiceEndpoint/Action' on scope '/subscriptions/{subscription ID}/resourceGroups/{resource group name}/providers/Microsoft.Sql/servers/{SQL Server name}/virtualNetworkRules/{rule name}', however the current tenant 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' is not authorized to access linked subscription 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.
- Azure SQL Server中的服务连接跨Azure租户只能访问一个租户中的虚拟网络。它无法访问其他租户中的虚拟网络。
- 您可以在以下步骤中为该虚拟网络分配网络撰稿人角色:
转到 azure portal - &gt; 资源组 - &gt; 访问控制(IAM) - &gt; 添加角色分配。 - &gt; 选择网络 贡献者 - &gt;添加
这是您想要的吗?
Is this what you are looking for?
订购和分组的甘特图