一念一轮回

文章 评论 浏览 30

一念一轮回 2025-02-20 12:25:48

有几种方法可以实现这一目标。

您需要定义,如果您在用.map()的数组迭代时使用React创建DOM元素(否则您将在控制台中会收到警告您的浏览器)。您可以使用获取user.id

<select onChange={(e) => selectedUser(e)} className=" form-select-control">
    <option value="">Please select the user</option>
    {active &&
        users.map((user: any) => (
            <option key={user.id}>{user.displayName}</option>
        ))}
</select>;

const selectedUser = (e: any) => {
    setUser(e.target.key);
};

您还可以保存user.id in id = {user。 id}并通过e.target.id获取它。

There are several ways to achieve this.

You need to define a key if you create DOM elements with React when you iterate through an array with .map() anyway (else you'll get a warning in the console of your browser). You can use the key to get the user.id:

<select onChange={(e) => selectedUser(e)} className=" form-select-control">
    <option value="">Please select the user</option>
    {active &&
        users.map((user: any) => (
            <option key={user.id}>{user.displayName}</option>
        ))}
</select>;

const selectedUser = (e: any) => {
    setUser(e.target.key);
};

You could also save the user.id in id={user.id} and grab it via e.target.id.

在React中的下拉中选择用户时获取ID

一念一轮回 2025-02-20 04:12:10

您可以使用

re.findall(r'.*\b(?:for|at|of)\s+(.*)', text)

regex demo 详细信息

  • 。* - 除线断裂字符以外的任何零或更多字符,尽可能多的
  • \ b - 一个Word Boundare
  • (?:for | at | of) - for , at 或的
  • \ s+ -一个或多个空格
  • (。*) - 第1组:除折扣以外的任何零或更多字符,尽可能多。

另一个将获得相同结果的正则是

re.findall(r'\b(?:for|at|of)\s+((?:(?!\b(?:for|at|of)\b).)*)

详细信息

  • \ b - word boundard boundary
  • (?for | AT | of) - 对于, 或
  • \ s+ - 一个或多个whitepsepaces
  • ((?:(?) ,或的 的总体 yat a 尽可能多的事件, 整个单词char sequence
  • $ 代码> - 字符串的结尾。

注意,您还可以使用 re.Search ,因为您期望一个匹配:

match = re.search(r'.*\b(?:for|at|of)\s+(.*)', text)
if match:
    print(match.group(1))
, text)

详细信息

  • \ b - word boundard boundary
  • (?for | AT | of) - 对于, 或
  • \ s+ - 一个或多个whitepsepaces
  • ((?:(?),或的 的总体 yat a 尽可能多的事件, 整个单词char sequence
  • $ 代码> - 字符串的结尾。

注意,您还可以使用re.Search,因为您期望一个匹配:

You can use

re.findall(r'.*\b(?:for|at|of)\s+(.*)', text)

See the regex demo. Details:

  • .* - any zero or more chars other than line break chars, as many as possible
  • \b - a word boundary
  • (?:for|at|of) - for, at or of
  • \s+ - one or more whitespaces
  • (.*) - Group 1: any zero or more chars other than line break chars, as many as possible.

Another regex that will fetch the same results is

re.findall(r'\b(?:for|at|of)\s+((?:(?!\b(?:for|at|of)\b).)*)

Details:

  • \b - a word boundary
  • (?:for|at|of) - for, at or of
  • \s+ - one or more whitespaces
  • ((?:(?!\b(?:for|at|of)\b).)*) - Group 1: any char, other than a line break char, zero or more but as many as possible, occurrences, that does not start a for, at or of as a whole word char sequence
  • $ - end of string.

Note you can also use re.search since you expect a single match:

match = re.search(r'.*\b(?:for|at|of)\s+(.*)', text)
if match:
    print(match.group(1))
, text)

Details:

  • \b - a word boundary
  • (?:for|at|of) - for, at or of
  • \s+ - one or more whitespaces
  • ((?:(?!\b(?:for|at|of)\b).)*) - Group 1: any char, other than a line break char, zero or more but as many as possible, occurrences, that does not start a for, at or of as a whole word char sequence
  • $ - end of string.

Note you can also use re.search since you expect a single match:

从末端找到字符串中的第一匹匹配

一念一轮回 2025-02-19 18:18:37

这让我想起了找到包括集合的所有成员的最小窗口的问题,该窗口可以在O(n)时间和O(k)空间中使用两个指针来解决。在我们的情况下,o(1)空间似乎足够了,因为我们只对一笔款项感兴趣。

移动正确的指针,直到达到总和为止。移动左指针,直到总和再次太低为止。然后移动正确的指针等。解决读者留给读者的gragmax约束。

This reminds me of the problem of finding the smallest window that includes all members of a set, which can be solved in O(n) time and O(k) space with two pointers. In our case, O(1) space would seem to be enough since we're only interested in a sum.

Move the right pointer until the sum is achieved. Move the left pointer just until the sum is again too low. Then move the right pointer, etc. Addressing the argmax constraint left to the reader.

总和超过阈值的最小间隔

一念一轮回 2025-02-19 08:39:12

为Groupby提供了2种不同的解决方案。从您的问题来看,尚不清楚您要寻找哪种类型的最终数据结构。

df = pd.DataFrame({"state":['A&N','A&N','A&N','A&N','A&N','A&N','A&N'],
                    'district': ['SA','SA','SA','N','N','N','N'],
                    'HS Code': [3,3,3,40,42,63,72],
                    'Feb Value': np.random.randint(200,300,7),
                    'Mar Value': np.random.randint(200,300,7),
                    'Apr Value': np.random.randint(200,300,7),})
df['Apr_district_by_sum'] = df.groupby(['HS Code','district'])['Apr Value'].transform(np.sum)
print(df)



state district  HS Code  Feb Value  Mar Value  Apr Value  Apr_district_by_sum
0   A&N       SA        3        252        249        277                  773
1   A&N       SA        3        268        267        268                  773
2   A&N       SA        3        295        241        228                  773
3   A&N        N       40        222        235        271                  271
4   A&N        N       42        225        226        202                  202
5   A&N        N       63        268        217        248                  248
6   A&N        N       72        292        257        270                  270

或者

df = pd.DataFrame({"state":['A&N','A&N','A&N','A&N','A&N','A&N','A&N'],
                    'district': ['SA','SA','SA','N','N','N','N'],
                    'HS Code': [3,3,3,40,42,63,72],
                    'Feb Value': np.random.randint(200,300,7),
                    'Mar Value': np.random.randint(200,300,7),
                    'Apr Value': np.random.randint(200,300,7),})
df1 = df.groupby(['HS Code','district'])['Apr Value'].sum().reset_index()
print(df1)

 HS Code district  Apr Value
0        3       SA        735
1       40        N        206
2       42        N        207
3       63        N        235
4       72        N        275

2 different solutions are given for groupby. From your question, it is not clear which type of final data structure you are looking for.

df = pd.DataFrame({"state":['A&N','A&N','A&N','A&N','A&N','A&N','A&N'],
                    'district': ['SA','SA','SA','N','N','N','N'],
                    'HS Code': [3,3,3,40,42,63,72],
                    'Feb Value': np.random.randint(200,300,7),
                    'Mar Value': np.random.randint(200,300,7),
                    'Apr Value': np.random.randint(200,300,7),})
df['Apr_district_by_sum'] = df.groupby(['HS Code','district'])['Apr Value'].transform(np.sum)
print(df)



state district  HS Code  Feb Value  Mar Value  Apr Value  Apr_district_by_sum
0   A&N       SA        3        252        249        277                  773
1   A&N       SA        3        268        267        268                  773
2   A&N       SA        3        295        241        228                  773
3   A&N        N       40        222        235        271                  271
4   A&N        N       42        225        226        202                  202
5   A&N        N       63        268        217        248                  248
6   A&N        N       72        292        257        270                  270

or

df = pd.DataFrame({"state":['A&N','A&N','A&N','A&N','A&N','A&N','A&N'],
                    'district': ['SA','SA','SA','N','N','N','N'],
                    'HS Code': [3,3,3,40,42,63,72],
                    'Feb Value': np.random.randint(200,300,7),
                    'Mar Value': np.random.randint(200,300,7),
                    'Apr Value': np.random.randint(200,300,7),})
df1 = df.groupby(['HS Code','district'])['Apr Value'].sum().reset_index()
print(df1)

 HS Code district  Apr Value
0        3       SA        735
1       40        N        206
2       42        N        207
3       63        N        235
4       72        N        275

无法在列中获得匹配字符串的行总和

一念一轮回 2025-02-19 08:38:48

我也遇到了一个类似的问题,但是我想创建的容器需要将/var/run/docker.sock挂载为音量(Portainer代理),而在不同的名称空间下运行它们时。通常,一个容器不在乎其启动的命名空间 - 这是重点 - 但是由于访问是由不同的名称空间进行的,因此必须规避这一点。

- userns = host添加到容器的运行命令中,使其能够使用正确的权限。

相当特定的用例,但是经过比我想承认更多的研究时间后,我只是认为如果其他人最终在这种情况下,我应该与世界分享:)

I ran into a similar problem as well, but where the container I wanted to create needed to mount /var/run/docker.sock as a volume (Portainer Agent), while running it all under a different namespace. Normally a container does not care about which namespace it is started in -- that is sort of the point -- but since access was made from a different namespace, this had to be circumvented.

Adding --userns=host to the run command for the container enabled it to use the attain the correct permissions.

Quite a specific use case, but after more research hours than I want to admit I just thought I should share it with the world if someone else ends up in this situation :)

如何修复Docker:获得许可的问题

一念一轮回 2025-02-19 07:14:53

没有将任意掩码转换为ROI的命令或简单方法。

这部分是如此,因为ROI定义为一组顶点。

为了进行转换,首先必须从二进制掩码中创建“大纲”掩码,然后获取所有轮廓点的XY坐标,然后具有算法来对这些点进行分类,以便它们形成A(闭环。
然后,可以创建ROI并将点添加为顶点。都是可行的,但不平凡。

但是我想知道为什么要竭尽全力?

如果主要用例是使用ROI限制SI中的某些数据,则必须将ROI转换回一个或另一个点的二进制掩码。那么,为什么不首先使用口罩呢?

如果这只是掩码可视化的问题,那么我建议使用用于任务的注释:覆盖注释。

image front := GetFrontImage().ImageClone()
number sx, sy
front.ImageGetDimensionSizes(sx,sy)
image mask = front > mean(front) ? 1 : 0
front.ShowImage()
mask.Showimage()
component maskComp = NewOverlayAnnotation(0,0,sy,sx)
maskComp.ComponentSetForegroundColor(0,0,1)
maskComp.ComponentSetMask(mask)
maskComp.ComponentSetTransparency(0.5)
front.ImageGetImageDisplay(0).ComponentAddChildAtEnd(maskComp)

编辑:GMS的较旧版本不支持这种类型的注释。在这种情况下,可以创建一个RGB混合图像以显示。

There is no command or simple way to convert an arbitrary mask into a ROI.

This is partly so, because a ROI is defined as a set of vertices.

In order to do the conversion, one would first have to create the "outline" mask from the binary mask, then get the XY coordinates of all of the outline points, and then have an algorithm to sort these points so that they form a (closed) loop.
Then, one could create a ROI and add the points as vertices. All doable, but non-trivial.

But I'm wondering why one would even go to that length?

If the primary use-case is to use the ROI to limit some data in the SI, then one will have to convert the ROI back into a binary mask at one or another point. So why not just use the mask in the first place?

If it is just a question of visualization of the mask, then I would recommend using the annotation that is meant for the task: the overlay annotation.
enter image description here

image front := GetFrontImage().ImageClone()
number sx, sy
front.ImageGetDimensionSizes(sx,sy)
image mask = front > mean(front) ? 1 : 0
front.ShowImage()
mask.Showimage()
component maskComp = NewOverlayAnnotation(0,0,sy,sx)
maskComp.ComponentSetForegroundColor(0,0,1)
maskComp.ComponentSetMask(mask)
maskComp.ComponentSetTransparency(0.5)
front.ImageGetImageDisplay(0).ComponentAddChildAtEnd(maskComp)

Edit: Older versions of GMS do not support this type of annotation. In this case, one could instead create a RGB mix image for display.

如何使用脚本将(位蒙版)图像转换为图像中的ROI

一念一轮回 2025-02-19 00:54:10

如果您使用的是javascript SDK,建议对本机的建议:

将用户添加到对话

基本上

conversation.add(<identity>)

If you are using the JavaScript SDK as recommended for React Native:

Add a user to a conversation

So basically

conversation.add(<identity>)

如何在反应本地使用Twilio转换来将成员添加到对话/通道中?

一念一轮回 2025-02-18 14:55:25

对于这种类型的事情,我通常会尝试将类别表示为逻辑表达式,然后使用scale _*_手动值。也许在这里使用cut我不理解的效用,但是在此示例中,您可以做...

if (input$fairness_metric == "Equal Opportunity Difference") {
      heatmap_data <- rw

对于这种类型的事情,我通常会尝试将类别表示为逻辑表达式,然后使用 scale _*_手动值。也许在这里使用 cut 我不理解的效用,但是在此示例中,您可以做...

Equal Opportunity Difference` fair <- (abs(round(heatmap_data, 2)) > 0.11) color <- ifelse((round(heatmap_data, 2) <= 0.10000) & (round(heatmap_data, 2) >= -0.10000), "black", "white") } # else if ... # Create heatmap ggplot(rw, # ... + scale_fill_manual("Fairness", breaks = c(TRUE, FALSE), labels = c("Fair", "Unfair"), values = c(fair_color, unfair_color)) # ...

For this type of thing I usually try to express the category as a logical expression, then use scale_*_manual with logical values. Maybe there is some utility in using cut here that I don't understand, but for this example, you could do...

if (input$fairness_metric == "Equal Opportunity Difference") {
      heatmap_data <- rw

For this type of thing I usually try to express the category as a logical expression, then use scale_*_manual with logical values. Maybe there is some utility in using cut here that I don't understand, but for this example, you could do...

Equal Opportunity Difference` fair <- (abs(round(heatmap_data, 2)) > 0.11) color <- ifelse((round(heatmap_data, 2) <= 0.10000) & (round(heatmap_data, 2) >= -0.10000), "black", "white") } # else if ... # Create heatmap ggplot(rw, # ... + scale_fill_manual("Fairness", breaks = c(TRUE, FALSE), labels = c("Fair", "Unfair"), values = c(fair_color, unfair_color)) # ...

如何通过在GGPLOT热图上的离散颜色组合比例元素?

一念一轮回 2025-02-18 05:42:04

我将针对这种类型的设置,其中每个微服务都是一组函数:

每个API可以如我的API ,它指向 https://api.authsamples。 com/api

然后将只有一个API域,可以映射到自定义域。我的写入在有用的情况下解释我如何将其放在一起。

I would aim for this type of setup, where each microservice is a set of functions:

Each API can have its own base path in its serverless.yml file, as in this API of mine, which points to endoints under https://api.authsamples.com/api.

There will then be only one API domain, that maps to the custom domain. My write up explains how I put this together, in case useful.

如何使用单个域管理多个无AWS无服务器API?

一念一轮回 2025-02-18 05:12:02

当未在app.module.ts文件中添加有关组件时,通常会发生这种情况。
请验证并相应确认。

This typically happens when the component in question has not been added in app.module.ts file.
Please verify and confirm accordingly.

&#x27; app-sidenav-list&#x27;不是已知元素

一念一轮回 2025-02-17 12:09:16

它对我有用的是第2点中描述的。从拉法的答案来看:

$ npm cache clean --force
$ rm -rf node_modules package-lock.json
$ npm install

不幸的是,我仍然不明白为什么这些步骤解决了问题。

What it worked for me is what is described in point 2. from Raphaël's answer:

$ npm cache clean --force
$ rm -rf node_modules package-lock.json
$ npm install

Unfortunately, I still don't understand why these steps solves the issue.

NPM 7/8没有安装同行依赖关系

一念一轮回 2025-02-17 08:13:10

TimeIt具有循环和运行。您刚刚指定了每次运行的循环。

> In [80]: alist = []    
In [81]: %%timeit
    ...: alist.append(1)
    ...: 
    ...: 
146 ns ± 12.6 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)

In [82]: len(alist)
Out[82]: 81111111

In [83]: alist=[]    
In [84]: %%timeit -n2 -r1
    ...: alist.append(1)
    ...: 
    ...: 
1.75 µs ± 0 ns per loop (mean ± std. dev. of 1 run, 2 loops each)

In [85]: len(alist)
Out[85]: 2

In [86]: alist=[]    
In [87]: %%timeit -n2
    ...: alist.append(1)
    ...: 
    ...: 
993 ns ± 129 ns per loop (mean ± std. dev. of 7 runs, 2 loops each)

In [88]: len(alist)
Out[88]: 14

通常,我尝试设置一个时间IT,因此我不在乎“结果”是什么,因为我想要时间,而不是某种累积的列表或数组。

对于新清单,每个运行

In [89]: %%timeit -n2  -r10 alist=[]
    ...: alist.append(1)
    ...: 
    ...: 
The slowest run took 4.75 times longer than the fastest. This could mean that an intermediate result is being cached.
1.21 µs ± 889 ns per loop (mean ± std. dev. of 10 runs, 2 loops each)

timeit has loops and runs. You just specified the loops per run.

> In [80]: alist = []    
In [81]: %%timeit
    ...: alist.append(1)
    ...: 
    ...: 
146 ns ± 12.6 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)

In [82]: len(alist)
Out[82]: 81111111

In [83]: alist=[]    
In [84]: %%timeit -n2 -r1
    ...: alist.append(1)
    ...: 
    ...: 
1.75 µs ± 0 ns per loop (mean ± std. dev. of 1 run, 2 loops each)

In [85]: len(alist)
Out[85]: 2

In [86]: alist=[]    
In [87]: %%timeit -n2
    ...: alist.append(1)
    ...: 
    ...: 
993 ns ± 129 ns per loop (mean ± std. dev. of 7 runs, 2 loops each)

In [88]: len(alist)
Out[88]: 14

Generally I try to setup a timeit so I don't care what the "result" is, since I want the times, not some sort of accumulated list or array.

For a fresh list each run:

In [89]: %%timeit -n2  -r10 alist=[]
    ...: alist.append(1)
    ...: 
    ...: 
The slowest run took 4.75 times longer than the fastest. This could mean that an intermediate result is being cached.
1.21 µs ± 889 ns per loop (mean ± std. dev. of 10 runs, 2 loops each)

ipython /关于百分比循环过程的问题

一念一轮回 2025-02-17 04:03:47

您可以使用应该等于字符串关键字:

  Open Browser   https://www.google.com/  chrome
  Maximize Browser Window
  Wait Until Element Is Visible    xpath=//input[contains(@class,'gLFyf')]
  Input Text    xpath=//input[contains(@class,'gLFyf')]    stackoverflow.com
  Press Keys    xpath=//input[contains(@class,'gLFyf')]    ENTER  
  ${first_result}=    Get Text    xpath=(//*[contains(@class,'LC20lb ')])[1]
  Should Be Equal As Strings    ${first_result}     Stack Overflow - Where 
  Developers Learn, Share, & Build ...

you can use Should Be Equal As Strings keyword :

  Open Browser   https://www.google.com/  chrome
  Maximize Browser Window
  Wait Until Element Is Visible    xpath=//input[contains(@class,'gLFyf')]
  Input Text    xpath=//input[contains(@class,'gLFyf')]    stackoverflow.com
  Press Keys    xpath=//input[contains(@class,'gLFyf')]    ENTER  
  ${first_result}=    Get Text    xpath=(//*[contains(@class,'LC20lb ')])[1]
  Should Be Equal As Strings    ${first_result}     Stack Overflow - Where 
  Developers Learn, Share, & Build ...

如何使用机器人框架验证第一个Google搜索结果的价值?

一念一轮回 2025-02-17 03:02:52

因此,(2,1)输入返回a(1,1)结果:

In [83]: gaussian(np.ones((2,1)))
Out[83]: array([[0.90483742]])

添加一些领先维度:

In [84]: gaussian(np.ones((3,4,2,1)))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [84], in <cell line: 1>()
----> 1 gaussian(np.ones((3,4,2,1)))

Input In [80], in gaussian(x)
      4 sigma = np.array([[10, 0],
      5                   [0, 10]])
      6 xm = x - mu
----> 7 result = np.exp((-1/2) * xm.T @ np.linalg.inv(sigma) @ xm)
      8 return result

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 3)

x-mu有效,因为(3,4,2,1)广播(2,1)

该错误发生在( - 1/2) * xm.t @ np.linalg.inv(sigma)

np.linalg.inv(sigma) is(2,2) )

xm(3,4,2,1),因此其转置为(1,2,4,3)。

相反,如果数组为(3,4,1,2) @(2,2) @(3,4,2,1)结果应为(3,4,1,1)。

因此,让我们完善转言:

def  gaussian(x):
    mu = np.array([[2],
                   [2]])
    sigma = np.array([[10, 0],
                      [0, 10]])
    xm = x - mu
    xmt =xm.swapaxes(-2,-1)
    result = np.exp((-1/2) * xmt @ np.linalg.inv(sigma) @ xm)
    return result

现在它适用于原始(2,1)和任何其他(N,M,2,1)形状:

In [87]: gaussian(np.ones((3,4,2,1))).shape
Out[87]: (3, 4, 1, 1)

In [88]: gaussian(np.ones((2,1))).shape
Out[88]: (1, 1)

So a (2,1) input returns a (1,1) result:

In [83]: gaussian(np.ones((2,1)))
Out[83]: array([[0.90483742]])

Adding some leading dimensions:

In [84]: gaussian(np.ones((3,4,2,1)))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [84], in <cell line: 1>()
----> 1 gaussian(np.ones((3,4,2,1)))

Input In [80], in gaussian(x)
      4 sigma = np.array([[10, 0],
      5                   [0, 10]])
      6 xm = x - mu
----> 7 result = np.exp((-1/2) * xm.T @ np.linalg.inv(sigma) @ xm)
      8 return result

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 2 is different from 3)

x-mu works because (3,4,2,1) broadcasts with (2,1)

The error occurs in (-1/2) * xm.T @ np.linalg.inv(sigma)

np.linalg.inv(sigma) is (2,2)

xm is (3,4,2,1), so its transpose is (1,2,4,3).

If instead the arrays are (3,4,1,2) @ (2,2) @ (3,4,2,1) the result should be (3,4,1,1).

So let's refine the transpose:

def  gaussian(x):
    mu = np.array([[2],
                   [2]])
    sigma = np.array([[10, 0],
                      [0, 10]])
    xm = x - mu
    xmt =xm.swapaxes(-2,-1)
    result = np.exp((-1/2) * xmt @ np.linalg.inv(sigma) @ xm)
    return result

Now it works for both the original (2,1), and any other (n,m,2,1) shape:

In [87]: gaussian(np.ones((3,4,2,1))).shape
Out[87]: (3, 4, 1, 1)

In [88]: gaussian(np.ones((2,1))).shape
Out[88]: (1, 1)

在涉及线性代数的功能上应用Numpy广播

一念一轮回 2025-02-17 00:54:31

我不熟悉使用nmake。以下是我进行的测试,将DLL与CPP相同的目录。

makefile:

foo: main.cpp
  cl main.cpp TestDll.lib

I am not familiar with using nmake. Below is a test I did, putting the DLL in the same directory as cpp.

makefile:

foo: main.cpp
  cl main.cpp TestDll.lib

错误的LNK2019使用库中的makefile配置类型

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文