柠栀

文章 评论 浏览 30

柠栀 2025-02-21 01:04:17

通常可以安全地删除参考,该参考不会在缺乏时阻止汇编。

microsoft.visualstudio.web.codegeneration.design 似乎是在项目中引用的一件非常奇怪的事情 - 我相信它用于生成视图&amp&控制器,所以我很确定只要它仍然编译,就可以将其删除。

It's generally safe to remove a reference which doesn't prevent compilation when absent.

Microsoft.VisualStudio.Web.CodeGeneration.Design seems like a very weird thing to reference in a project - I believe it's used for generating the default code for views & controllers so I'm pretty sure it can be removed as long as it still compiles.

如何确定是否使用Microsoft.visualstudio.web.codegener.design?

柠栀 2025-02-20 21:27:46

我找到了问题的根源。

解决方案:
adafruit_mpu6050.h

#define MPU6050_DEVICE_ID 0x68 ///< The correct MPU6050_WHO_AM_I value

更改为0x98,

此“ 0x68”必须仅在此行中

而不是在这里:

#define MPU6050_I2CADDR_DEFAULT \
0x68 ///< MPU6050 default i2c address w/ AD0 high

必须保持相同的0x68

I found the root of the problem.

solution:
Adafruit_MPU6050.h

#define MPU6050_DEVICE_ID 0x68 ///< The correct MPU6050_WHO_AM_I value

this "0x68" must be changed to 0x98

ONLY in this line

NOT here :

#define MPU6050_I2CADDR_DEFAULT \
0x68 ///< MPU6050 default i2c address w/ AD0 high

it must stay the same 0x68

无法使用ESP32找到MPU6050

柠栀 2025-02-20 20:26:53

也许您可以尝试这样的事情:

\A(?:^.*$\n){5}\K^.*$

其中5是以前的行。所以5表示您想获得第6行。

工作示例:
https://regex101.com/r/qudon0/1

Maybe you can try something like this:

\A(?:^.*$\n){5}\K^.*$

Where 5 are the previous lines. So 5 means you want to get line number 6.

Working Example:
https://regex101.com/r/QuDon0/1

仅在特定行#(REGEX)上替换一个单词

柠栀 2025-02-20 17:16:13

这里.project文件缺少结尾标签:

</buildSpec>

将标签添加到损坏项目的.project文件中,可以解决我的问题。

Here .project file was missing the ending tag:

</buildSpec>

Adding the tag to the .project file of the corrupted project resolved my issue.

某些项目无法导入,因为他们的项目描述文件已损坏

柠栀 2025-02-20 16:58:59

要添加到 Mathias'有用的答案

  • 错误地期望在'...'...'...'...'字符串(与内部“ ...” 相反)以前出现了很多次,并且像您这样的问题通常会以这篇文章


  • 但是,您的问题值得单独回答,因为:

    • 您的用例引入了后续问题,即嵌入式 字符在“ ...”中无法用作字符。

    • 更一般地,链接的帖子是在 crign-passing 的上下文中,其中其他规则适用。


注意:下面的一些链接与概念 about_quoting_rules 帮助主题。

在PowerShell中:

  • 唯一“ ...” strings (双引号,称为 可扩展的字符串 执行字符串interpolation ,IE扩展可变值(例如“ ... $ var” 和子表达(例如,“ ... $($ var.prop)”


  • '...'...'字符串(single-Quoted,称为 逐字字符串 ),其值为使用 verbatim (从字面上看)。

使用“ ...” 如果字符串值本身包含chars。

  • 要么 将它们作为`“ ”逃脱了


  • 使用双引号 there-string 而不是(@@@@newline&gt; ...&lt; ...&lt; newline&gt;“@):

    • 请参阅Mathias的答案,但通常会注意到此处的严格的多行语法
      • 什么都没有(除了whitespace除外)必须遵循同一行的开放定界符(@“ /@'
      • 关闭定界符(“@/'@)必须在该行的开始时 - 甚至甚至没有之前都可能出现它。




相关答案:


替代方案字符串插值:

在情况下,动态构造字符串的其他方法可能很有用:

To add to Mathias' helpful answer:

  • Mistakenly expecting string interpolation inside '...' strings (as opposed to inside "...") has come up many times before, and questions such as yours are often closed as a duplicate of this post.

  • However, your question is worth answering separately, because:

    • Your use case introduces a follow-up problem, namely that embedded " characters cannot be used as-is inside "...".

    • More generally, the linked post is in the context of argument-passing, where additional rules apply.


Note: Some links below are to the relevant sections of the conceptual about_Quoting_Rules help topic.

In PowerShell:

  • only "..." strings (double-quoted, called expandable strings) perform string interpolation, i.e. expansion of variable values (e.g. "... $var" and subexpressions (e.g., "... $($var.Prop)")

  • not '...' strings (single-quoted, called verbatim strings), whose values are used verbatim (literally).

With "...", if the string value itself contains " chars.:

  • either escape them as `" or ""

    • E.g., with `"; note that while use of $(...), the subexpression operator never hurts (e.g. $($mynumber)), it isn't necessary with stand-alone variable references such as $mynumber:

      $mynumber= 2
      $tag = "{`"number`" = `"$mynumber`", `"application`" = `"test`",`"color`" = `"blue`", `"class`" = `"Java`"}"
      
    • Similarly, if you want to selectively suppress string interpolation, escape $ as `$

      # Note the ` before the first $mynumber.
      # -> '$mynumber = 2'
      $mynumber = 2; "`$mynumber` = $mynumber"
      
    • See the conceptual about_Special_Characters help topic for info on escaping and escape sequences.

    • If you need to embed ' inside '...', use '', or use a (single-quoted) here-string (see next).

  • or use a double-quoted here-string instead (@"<newline>...<newline>"@):

    • See Mathias' answer, but generally note the strict, multiline syntax of here-strings:
      • Nothing (except whitespace) must follow the opening delimiter on the same line (@" / @')
      • The closing delimiter ("@ / '@) must be at the very start of the line - not even whitespace may come before it.

Related answers:


Alternatives to string interpolation:

Situationally, other approaches to constructing a string dynamically can be useful:

  • Use a (verbatim) template string with placeholders, with -f, the format operator:

    $mynumber= 2
    # {0} is the placeholder for the first RHS operand ({1} for the 2nd, ...)
    '"number" = "{0}", ...' -f $mynumber # -> "number" = "2", ...
    
  • Use simple string concatenation with the + operator:

    $mynumber= 2
    '"number" = "' + $mynumber + '", ...' # -> "number" = "2", ...
    

powershell格式为字符串

柠栀 2025-02-20 13:40:17

tldr;简短的答案是您不能。

state_dict a nn.module 包含模块的状态,但不是其功能。不可能仅使用其状态词典实例化模型。

您可以根据状态 dict 键和重量形状来初始化一些子模型,但这不能保证。在任何情况下,您都无法知道模型的行为,因为此信息根本不包含在其状态词典中。因此,您必须访问模型的 forward 定义,以了解远期逻辑, ie 哪些功能在输入和中间输出以及哪个功能上应用订购这些子模型。


看看这个最小示例,显示了两个具有相同状态词典的模型。但是,他们的 forward 彼此不同:

class A(nn.Linear):
    def forward(self, x):
        return super().forward(x)

class B(nn.Linear):
    def forward(self, x):
        return super().forward(x)**2

此处, a b 是初始化的从一个到另一个复制:

>>> a = A(2,1)
>>> b = B(2,1)
>>> a.load_state_dict(b.state_dict())

a b 具有完全相同的状态...但实际上实现了两个不同的功能!

TLDR; the short answer is you can't.

The state_dict of a nn.Module contains the module's state, but not its function. It is not possible to instantiate a model with its state dictionary alone.

You can manage to initialize some of the sub-modules based on the state dict keys and the weight shapes, but this is not guaranteed. In any case you won't be able to know the model's behaviour because this information is simply not contained in its state dictionary. Therefore you are required to have access to the forward definition of the model in order to know the forward logic, i.e. which functions are applied on the input and intermediate outputs and in which order those submodules are used.


Have a look at this minimal example showing two models with identical state dictionaries. However, their forward is different from one another:

class A(nn.Linear):
    def forward(self, x):
        return super().forward(x)

class B(nn.Linear):
    def forward(self, x):
        return super().forward(x)**2

Here, a and b are initialized and the state dict is copied from one to the other:

>>> a = A(2,1)
>>> b = B(2,1)
>>> a.load_state_dict(b.state_dict())

Both a and b have the exact same state... but actually implement two different functions!

如何从状态命令中创建模型?

柠栀 2025-02-20 11:26:55

此示例将帮助您记住*Args ** Kwargs ,甚至 super 和sustaritance and python中的继承。

class base(object):
    def __init__(self, base_param):
        self.base_param = base_param


class child1(base): # inherited from base class
    def __init__(self, child_param, *args) # *args for non-keyword args
        self.child_param = child_param
        super(child1, self).__init__(*args) # call __init__ of the base class and initialize it with a NON-KEYWORD arg

class child2(base):
    def __init__(self, child_param, **kwargs):
        self.child_param = child_param
        super(child2, self).__init__(**kwargs) # call __init__ of the base class and initialize it with a KEYWORD arg

c1 = child1(1,0)
c2 = child2(1,base_param=0)
print c1.base_param # 0
print c1.child_param # 1
print c2.base_param # 0
print c2.child_param # 1

This example would help you remember *args, **kwargs and even super and inheritance in Python at once.

class base(object):
    def __init__(self, base_param):
        self.base_param = base_param


class child1(base): # inherited from base class
    def __init__(self, child_param, *args) # *args for non-keyword args
        self.child_param = child_param
        super(child1, self).__init__(*args) # call __init__ of the base class and initialize it with a NON-KEYWORD arg

class child2(base):
    def __init__(self, child_param, **kwargs):
        self.child_param = child_param
        super(child2, self).__init__(**kwargs) # call __init__ of the base class and initialize it with a KEYWORD arg

c1 = child1(1,0)
c2 = child2(1,base_param=0)
print c1.base_param # 0
print c1.child_param # 1
print c2.base_param # 0
print c2.child_param # 1

**(双星/星号)和 *(星/星号)对参数有什么作用?

柠栀 2025-02-20 07:38:19

我有类似的问题,但在我的情况下解决方案有所不同。
我持有PHP代码的文件称为“ somename.html”
将其更改为“ somename.php” 工作正常

i had similar problem but in my case solution was different.
my file that held php code was called "somename.html"
changed it to "somename.php" worked fine

PHP代码尚未执行,但代码在浏览器源代码中显示

柠栀 2025-02-19 19:13:44

一种方法,即使在Java的较旧版本上也可以使用,并且不需要使用最新版本的预览功能是结合使用 instanceof switch> switch


import java.util.*;
import java.lang.*;
import java.io.*;

class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        List list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add("XY");
        list.add(3);
        list.add("test");
        for (var element : list) {
            if (element instanceof Integer) {
                Integer element2 = (Integer) element;
                switch (element2) {
                    case 1: System.out.println(1); break;
                    case 2: System.out.println(2); break;
                    default: System.out.println("Not 1 or 2"); 
                }
            }
            if (element instanceof String) {
                String element3 = (String) element;
                switch (element3) {
                    case "XY": System.out.println("XY"); break;
                    default: System.out.println("NOT XY");
                }
            }
        }
    }   
}

输出:

1

2

xy

不是1或2

xy

A way to do this that should work even on older versions of Java and doesn't require the use of preview features from the latest versions is to combine the use of instanceof and switch:


import java.util.*;
import java.lang.*;
import java.io.*;

class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        List list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add("XY");
        list.add(3);
        list.add("test");
        for (var element : list) {
            if (element instanceof Integer) {
                Integer element2 = (Integer) element;
                switch (element2) {
                    case 1: System.out.println(1); break;
                    case 2: System.out.println(2); break;
                    default: System.out.println("Not 1 or 2"); 
                }
            }
            if (element instanceof String) {
                String element3 = (String) element;
                switch (element3) {
                    case "XY": System.out.println("XY"); break;
                    default: System.out.println("NOT XY");
                }
            }
        }
    }   
}

Output:

1

2

XY

Not 1 or 2

NOT XY

在开关情况下,是否可以将整数和字符串用作案例?

柠栀 2025-02-19 18:00:16

您可以使用供应商扩展名 https://zircote.github.io/swagger-php/guide/common-techniques.html#vendor-extensions

这些都是标准的一部分,但可以忽略,以便您可以以任何自己喜欢的方式使用它们。

You could use vendor extensions https://zircote.github.io/swagger-php/guide/common-techniques.html#vendor-extensions

These are part of the standard but ignored so you can use them in whatever way you like.

OpenAPI 3中是否有自定义属性?

柠栀 2025-02-19 09:46:02

如果我按以下编辑我的功能,则测试工作:

exports.findAllUsers = (req, res) => {
UserCollection.find()
    .then(users => {
        res.status(500)
        res.send(users) // added res, not using concatenation
    })
    .catch(err => {
        res.status(500)
            .send({message: err.message || "error occurred retriving users informations"})
    })

}

If I edit my function as in the following, the test work:

exports.findAllUsers = (req, res) => {
UserCollection.find()
    .then(users => {
        res.status(500)
        res.send(users) // added res, not using concatenation
    })
    .catch(err => {
        res.status(500)
            .send({message: err.message || "error occurred retriving users informations"})
    })

}

Sinon间谍返回“未定义”

柠栀 2025-02-18 19:19:20

您使用 - 版本从图表存储库中摘下图表时。例如:

helm upgrade app chart_name \
  --version 1.0.0 \
  --repo https://chart.repo.example.com \
  --install --values ./values.yml

这说明在定义的URL上找到并使用1.0.0版本 - repo

You use --version when pulling a chart from a chart repository. For example:

helm upgrade app chart_name \
  --version 1.0.0 \
  --repo https://chart.repo.example.com \
  --install --values ./values.yml

This says to find and use version 1.0.0 found at the url defined by --repo

何时在Helm升级中使用 - Version选项

柠栀 2025-02-18 19:04:22

当它包含一个!sub。

时,您无法使用!

AWS没有提供其内部实现的详细信息,为什么它们以这种方式实现 importValue

The docs explain:

You can't use the short form of !ImportValue when it contains a !Sub.

AWS does not provide details of its internal implementations, why they implemented ImportValue this way.

fn :: importValue在简短的符号中不喜欢fn :: sub

柠栀 2025-02-18 16:43:50

而不是我做的

}).catch(async err => {

,然后是我的代码。解决了

Instead of else I did

}).catch(async err => {

And then my code. That solved it

如何通过代码选择单选按钮? (vue.js 3&amp; tailwind)

柠栀 2025-02-18 00:49:18

如您所提到的,DeepCopy不会复制数据框中的列表。


“请注意,复制包含Python对象的对象时,深副本将复制数据,但不会递归地进行。更新嵌套的数据对象将反映在深层副本中。”

import pandas as pd
df = pd.DataFrame({'q': ['a', 'b', 'c'], 'w': [1, 2, [3, 4, 5]]})
>>> df
   q          w
0  a          1
1  b          2
2  c  [3, 4, 5]

# Use this method to avoid importing copy.
df_c = df.copy(deep=True)
# Make a new list to avoid the issue.
new_list = df_c.loc[2, 'w']
# Do what you need to with it.
df_c.loc[2, 'w'] = new_list[1:3]
>>> df_c
   q       w
0  a       1
1  b       2
2  c  [4, 5]
>>> df
   q          w
0  a          1
1  b          2
2  c  [3, 4, 5]

As you have mentioned, deepcopy does not copy the lists within your dataframe.

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.copy.html
"Note that when copying an object containing Python objects, a deep copy will copy the data, but will not do so recursively. Updating a nested data object will be reflected in the deep copy."

import pandas as pd
df = pd.DataFrame({'q': ['a', 'b', 'c'], 'w': [1, 2, [3, 4, 5]]})
>>> df
   q          w
0  a          1
1  b          2
2  c  [3, 4, 5]

# Use this method to avoid importing copy.
df_c = df.copy(deep=True)
# Make a new list to avoid the issue.
new_list = df_c.loc[2, 'w']
# Do what you need to with it.
df_c.loc[2, 'w'] = new_list[1:3]
>>> df_c
   q       w
0  a       1
1  b       2
2  c  [4, 5]
>>> df
   q          w
0  a          1
1  b          2
2  c  [3, 4, 5]

DeepCopy在包含列表的数据框架上不起作用吗?如何解决

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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