我看到您的问题,您的逻辑是正确的,但是实现不佳,一旦您过滤了数据,它才会呈现一个新组件:
import { EmailIcon, LocationIcon } from "./assets/FormSvgIcons";
import React, { useEffect, useState } from "react";
export default function SettingsForm() {
const [stateList, setStateList] = useState([]);
useEffect(() => {
fetch("https://servicodados.ibge.gov.br/api/v1/localidades/estados/")
.then((response) => {
return response.json();
})
.then((data) => {
console.log(data);
setStateList(data);
});
}, []);
return (
<form>
<div className="user-country">
<label className="white-label">Local</label>
<div className="input-icon-wrapper">
<div className="icon-input w-embed">
<LocationIcon />
</div>
<select
className="select-field white-select w-select"
id="locationField"
name="locationField"
onChange={handleLocation}
>
{stateList.map((state) => {
return <CreateDropdownOptions state={state} />;
})}
</select>
</div>
</div>
</form>
);
}
function CreateDropdownOptions({ state }) {
return (
<option key={state.id} value={state.sigla}>
{state.sigla}
</option>
);
}
我建议为每个选项使用一个组件,如果您以后需要使用一个组件,那么它将变得更加容易对
只需添加statelist
和CitiesList
的数组。
stateList = [{ name: 'England' }];
citiesList = ['London'];
RES变量不是初始化的。用 @mock 享用注释使用
@ExtendWith(MockitoExtension.class)
public class ATest {
...
如某些注释中所述,您不仅可以短路路径并在没有返回
关键字的情况下返回值。 返回
仅在该方法的最后值中不需要。无论如何,通常,避免在方法中具有多个回报的短路是一种好习惯。
在您的示例中,添加两个else
您可以在不使用return
关键字的情况下构造每个可能输出的最后值的路径:
def balance(chars: List[Char]): Boolean = {
def parenBalance(char : List[Char]) :Boolean = {
parenBalanceRecur(char, 0 , 0)
}
@tailrec
def parenBalanceRecur(charSequence: List[Char], itr : Int, imbalance : Int) : Boolean = {
if (imbalance < 0) then false
else if (itr == charSequence.length ) {
if (imbalance == 0) then true else false // #1
}
else if (charSequence(itr) == '(') { // # 2
parenBalanceRecur(charSequence, (itr + 1), (imbalance + 1))
}
else if (charSequence(itr) == ')') {
parenBalanceRecur(charSequence, itr + 1, imbalance -1)
}
else {
parenBalanceRecur (charSequence, itr +1, imbalance)
}
}
parenBalance(chars)
}
如果您这样做了:
if ($request->hasFile('slider_image')) {
$data['slider_image'] = [];
$data['slider_image_url'] = [];
foreach($request->file('slider_image') as $slider_image)
{
$filenameWithExt = $slider_image->getClientOriginalName ();
$filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
$extension = $slider_image->getClientOriginalExtension();
$fileNameToStore = $filename. '_'. time().'.'.$extension;
$slider_image->storeAs('public/artists/products/slider_image', $fileNameToStore);
array_push($data['slider_image'], $fileNameToStore);
array_push($data['slider_image_url'], url('storage/artists/products/slider_image/'.$fileNameToStoreImgUrl));
}
dd($data); // see if this solves your problem
}
在$ data ['slider_image']上,您将拥有一系列文件名,在$ data ['slider_image_url']上,您将拥有一系列URL。
ViewLoader
是一个抽象类。 Guice只是说您需要提供可以实施的东西。 Guice无法实例化抽象类。因此,提供具有具体实现的绑定:
class MyViewLoader extends ViewLoader {
// Implement abstract methods.
}
然后在模块中绑定实现:
@Override public void configure() {
bind(ViewLoader.class).to(MyViewLoader.class);
}
您可以将其与套接字合作,但是如果您已经安装了Visa驱动程序,则使用pyvisa
是必不可少的方法。我不使用Agilent(Keysight)E4980A,但应该相似。
在计算机上,您安装了Keysight IO库,使用Keysight连接专家应用程序添加您的LAN设备,然后以下代码可行:
% py
Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvisa
>>> rm = pyvisa.ResourceManager()
>>> rm.list_resources()
('TCPIP0::192.168.1.15::inst0::INSTR')
>>> inst=rm.open_resource('TCPIP0::192.168.1.15::inst0::INSTR')
>>> inst.query('*IDN?')
'Agilent Technologies,N9040B\n'
在Keysight Connectigh Connection Expert中,您也可以分配Aliases,以便您可以做以下操作:
>>> inst=rm.open_resource('MyDevice')
您是否尝试过复制现有文件(例如,单_post.php的精确副本)只是为了查看它是否有效?
如果页面有标题和页脚,则该错误在此PHP文件上,否则在其他地方。
你可以有这样的想法
TL:DR将Getters和Setters添加到QueitalSteNaireDtoreQuest
。
另外,这只会使值无效,而不是QuageSnaireDtoreQuest
对象。是这样吗?
我跑了:
curl --location --request POST 'localhost:8081/' \
--header 'Content-Type: application/json' \
--data-raw ' {
"description": "Third questionnaire",
"createdDate": "2022-06-23",
"approvalStatus": "Approved",
"questionnaireVersion": "V1",
"isActive": false,
"questionSet": [
{
"text": "Question text" }
]
}'
我的控制器:
@RestController
public class MyController {
@PostMapping(
produces = MediaType.APPLICATION_JSON_VALUE ,
consumes = MediaType.APPLICATION_JSON_VALUE
)
public String createQuestionnaire(@RequestBody QuestionnaireDTORequest questionnaireDTORequest){
if(questionnaireDTORequest != null)
return "Questionnaire created successfully";
else
return "Questionnaire cannot be created";
}
}
模型是相同的仅添加的getters和setter。
首先在列表中使用flatten dictonary创建元组列表,然后传递到dataframe
构造函数:
L = [(a, k, v) for a, b in zip(df['TopicID'], df['keywords']) for k, v in b.items()]
df_final = pd.DataFrame(L, columns=['TopicID','Keyword','Value'])
print (df_final)
TopicID Keyword Value
0 797 licence 0.529
1 797 chapter 0.462
2 797 explains 0.263
3 797 visitor 0.244
4 797 resident 0.220
5 797 applying 0.205
6 797 privileges 0.199
7 797 graduated 0.188
8 797 tests 0.184
9 797 licensing 0.180
10 798 emotional 0.352
11 798 mental 0.327
12 798 state 0.309
13 798 operate 0.295
14 798 drive 0.242
15 798 motor 0.227
16 798 ability 0.227
17 798 next 0.176
18 798 illness 0.176
19 798 diminish 0.176
一种选择是,
bool foo4(uint64_t x)
{
return (((x << 1) >> 53) + 1) >> 11;
}
哪个与GCC一起编译到
foo:
ubfx r0, r1, #20, #11
adds r0, r0, #1
ubfx r0, r0, #11, #1
bx lr
此处的保存中,主要来自不必转换为0/1结果,而是直接生成1位。如果将此功能夹住并将结果用于分支,则无用,实际上可能导致代码较慢。
最后,我从队列和进程更改为conturrent.futures
's ProcessPoolExecutor
,正如@CharChit所暗示的,我必须移动我的映射函数计算
到模块的顶级级别,以便可以腌制。该解决方案对我来说非常有用,因为除了这个问题外,我还需要在Multecrocess.pool
本身内运行start_multicore_task
,这是一个无法产生孩子的守护程序虽然来自并发的一个池,但在其内部运行平稳。
from concurrent.futures import ProcessPoolExecutor as Pool
from functools import partial
import numpy as np
def calculate_row(in_data, nres):
"function to fill a row of what will be a square numpy array"
res, others = in_data
row = np.zeros((nres,))
for other in others:
# in my real code, which also doesn't work, obviously this performs a more
# complex calculation to add to the row[other] array position
row[other] = other
return res, row
def start_multicore_task(nres, cores_per_task):
in_data = []
iterator = set(range(nres))
for res1 in iterator:
# "others" are every value in "iterator" higher than res1 itself
others = list(iterator - set(range(res1)) - {res1})
if len(others) > 0:
# a check because the last value in "iterator" won't have any value higher than itself
in_data.append((res1, others))
with Pool(cores_per_task) as p:
results = list(p.map(partial(calculate_row, nres=nres), in_data, chunksize=len(in_data)/(cores_per_task*2)))
p.shutdown()
corr = np.zeros((nres, nres))
for result in results:
res, row = result
corr[res, :] = row
return corr
外键是一对一的关系。在您的情况下,一个类别可以拥有许多品牌,因此,如果该品牌必须属于另一个类别,则在这种情况下也意味着您必须将关系从外国密钥关系更改为多一到多的关系。
检查以下链接以获取参考
https:> https://djangoproject.com /EN/4.0/topics/db/examples/many_to_many/
class Brand(models.Model):
"""
This model is use to store the data of products sub category
"""
user = models.ForeignKey(User, related_name='brand_user', on_delete=models.CASCADE,null=True,blank=True, default=None)
name = models.CharField(max_length=50, unique=True, verbose_name="Brand Name")
brand_img = models.FileField(verbose_name='Upload Image')
category = models.ManyToManyField(Brand_Category,related_name='brand_category')
slug = models.SlugField(max_length=140, unique=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True)
当您指定AWS :: :: serverless :: function的体系结构时,体系结构来自Temlate文件中指定的内容。
从github repo中获取:
软件包CI
用于无服务器应用程序的 。它创建了Lambda应用程序捆绑包并将其上传到Amazon S3。然后写道
lambda功能代码的位置更新为
应用程序包上载的位置。在AWS CodePipeline中,该命令可以作为 codebuild 的一部分执行
舞台作为构建工件返回转换的模板。稍后,在转换无服务器的管道中。
与云形式阶段一起部署应用程序。
注释
dotnet lambda package-ci
检查并使用架构
aws :: serverless :: function
确定软件包的运行时。例如:
将执行
dotnet Publish
使用- runtime
值的参数linux-arm64
:The architecture comes from whatever is specified in your temlate file when you specify the architecture for the AWS::Serverless::Function.
Taken from the GitHub repo:
Package CI
Used for serverless applications. It creates the Lambda application bundle and uploads it to Amazon S3. It then writes
a new version of the serverless.template with the location of the Lambda function code updated to
where the application bundle was uploaded. In an AWS CodePipeline this command can be executed as part of a CodeBuild
stage returning the transformed template as the build artifact. Later in the pipeline that transformed serverless.template can
be used with a CloudFormation stage to deploy the application.
Notes
dotnet lambda package-ci
inspects and uses theArchitectures
property ofAWS::Serverless::Function
to determine the runtime of the package.For example:
will execute
dotnet publish
with a--runtime
argument of valuelinux-arm64
:您如何“ dotnet lambda package-ci”对于ARM64?