朮生

文章 评论 浏览 28

朮生 2025-02-21 01:35:30

找到一个有效的答案,尽管我不确定这是正确的方法还是软糖。

  [Route("api/customers/{customerId}/clients")]
  [Authorize]
  [ApiController]

  public class ClientsController : ControllerBase {

    [HttpGet]
    public ActionResult<IEnumerable<Client>> GetClients(int customerId) {
      // Retrieve data
      List<object> objects = new List<object>(clients);
      return Ok(objects);
    }

    [HttpGet("{clientId}", Name = "GetClient")]
    public ActionResult<Client> GetClient(int customerId, int clientId) {
      // Retrieve data
      return Ok(client);
    }
  }

如果我将客户端对象的列表转换为对象列表,则串行器在列表中的每个元素上调用getType,并且输出包含特定于单个子类的属性。

Found an answer that works, although I'm not sure if it's the correct way to do it, or a fudge.

  [Route("api/customers/{customerId}/clients")]
  [Authorize]
  [ApiController]

  public class ClientsController : ControllerBase {

    [HttpGet]
    public ActionResult<IEnumerable<Client>> GetClients(int customerId) {
      // Retrieve data
      List<object> objects = new List<object>(clients);
      return Ok(objects);
    }

    [HttpGet("{clientId}", Name = "GetClient")]
    public ActionResult<Client> GetClient(int customerId, int clientId) {
      // Retrieve data
      return Ok(client);
    }
  }

If I convert my list of Client objects to a list of object objects, then the serialiser calls GetType on each individual element in the list, and the output includes the properties that are specific to the individual subclasses.

从WebAPI返回多态性列表

朮生 2025-02-21 00:58:55

假设两个/对和{/}对配对,您可以查找平衡参数列表的,然后}平衡了身体的第一个{

我们要确保<代码> void还捕获了Test_func(){} 等,因此我将支票删除到本地功能中,因此我们开始在同一条线上查看下一对字符。

file = open(path_of_file)
data = file.readlines()

start = None
params = None
body = None
open = 0
close = 0

for index, line in enumerate(data):

    def balanced(o, c):
        open += line.count(o)
        close += line.count(c)
        return open > 0 and open = close
    
    def checkBody():
        if balanced('{', '}'):
            body = index
    
    def checkParams():
        if balanced('(', ')'):
            params = index
            open = 0
            close = 0
            checkBody()
    
    def checkStart():
        if line.find('void test_func') != -1:
            start = index
            checkParams()

    if start is None:
        checkStart()
    elif params is None:
        checkParams()
    elif body is None:
        checkBody()

if start is not None and body is not None:
    data.insert(start, '/*')
    data.insert(body + 1, '*/')

Assuming that both ( / ) pairs and { / } pairs are balanced, you can look for the ) that balances the parameter list's ( and then the } that balances the body's first {.

We want to ensure that void test_func() {} etc is also caught, so I've pulled out the checks into local functions, so we start looking on the same line for the next pair of characters.

file = open(path_of_file)
data = file.readlines()

start = None
params = None
body = None
open = 0
close = 0

for index, line in enumerate(data):

    def balanced(o, c):
        open += line.count(o)
        close += line.count(c)
        return open > 0 and open = close
    
    def checkBody():
        if balanced('{', '}'):
            body = index
    
    def checkParams():
        if balanced('(', ')'):
            params = index
            open = 0
            close = 0
            checkBody()
    
    def checkStart():
        if line.find('void test_func') != -1:
            start = index
            checkParams()

    if start is None:
        checkStart()
    elif params is None:
        checkParams()
    elif body is None:
        checkBody()

if start is not None and body is not None:
    data.insert(start, '/*')
    data.insert(body + 1, '*/')

给定一个C&#x2B;&#x2B;具有许多功能定义的文件,如何使用Python获取特定函数的启动和结束索引?

朮生 2025-02-20 21:25:36

可变名称应在编译时知道。如果您打算在运行时动态填充这些

 var variables = List<Variable>();
 variables.Add(new Variable { Name = inputStr1 });
 variables.Add(new Variable { Name = inputStr2 });

名称

Variable names should be known at compile time. If you intend to populate those names dynamically at runtime you could use a List<T>

 var variables = List<Variable>();
 variables.Add(new Variable { Name = inputStr1 });
 variables.Add(new Variable { Name = inputStr2 });

here input string maybe any text or any list

创建动态变量名称

朮生 2025-02-20 16:21:31

您需要确定是否可以从S。

You need to determine if every vertex is reachable from S. To do this, perform a depth first search and check that every vertex was visited.

设计流媒体算法来验证有向图是否具有母顶?

朮生 2025-02-20 13:41:53

@fravadona回答了您问的问题,因此您应该接受他们的答案,但这太长了,无法作为评论并需要格式化格式化。因此,这里是 - 仅供参考,除了您的时间戳比较外,您不需要管道时使用awk时的grep和wc:

t1='2022-01-01-10:01'
t2='2022-01-03-13:05'

pass=$(
    awk -v beg="$t1" -v end="$t2" '
        (beg <= $1) && ($1 <= end) && /AAA-passed/ { cnt++ }
        END { print cnt+0 }
    ' values.log
)
echo "$pass"

@Fravadona answered the question you asked so you should accept their answer but this is too long to add as a comment and requires formatting so here it is - FYI in addition to your timestamp comparison, you don't need pipes to grep and wc when you're using awk:

t1='2022-01-01-10:01'
t2='2022-01-03-13:05'

pass=$(
    awk -v beg="$t1" -v end="$t2" '
        (beg <= $1) && ($1 <= end) && /AAA-passed/ { cnt++ }
        END { print cnt+0 }
    ' values.log
)
echo "$pass"

当未输入日志中的确切时间戳时,如何在日期范围内过滤值

朮生 2025-02-20 12:01:13

您可以将其团结

x = 0
y = 1
z = 3

在一个变量中。

In [1]: xyz = (0,1,3,) 
In [2]: mylist = []

将我们的条件更改为:

In [3]: if 0 in xyz: 
    ...:     mylist.append("c") 
    ...: if 1 in xyz: 
    ...:     mylist.append("d") 
    ...: if 2 in xyz: 
    ...:     mylist.append("e") 
    ...: if 3 in xyz:  
    ...:     mylist.append("f") 

输出:

In [21]: mylist                                                                                
Out[21]: ['c', 'd', 'f']

You can unite this

x = 0
y = 1
z = 3

in one variable.

In [1]: xyz = (0,1,3,) 
In [2]: mylist = []

Change our conditions as:

In [3]: if 0 in xyz: 
    ...:     mylist.append("c") 
    ...: if 1 in xyz: 
    ...:     mylist.append("d") 
    ...: if 2 in xyz: 
    ...:     mylist.append("e") 
    ...: if 3 in xyz:  
    ...:     mylist.append("f") 

Output:

In [21]: mylist                                                                                
Out[21]: ['c', 'd', 'f']

朮生 2025-02-20 08:42:58

= condenate(text(i39,“ mm/dd/yyyy”),“”,j39)

text> text(cell,format)将转换为适合您的需求

=CONCATENATE(TEXT(I39,"mm/dd/yyyy"), " ", J39)

the TEXT(cell, format) will convert it to fit your need

Excel将句子中的日期返回到序列号而不是实际日期

朮生 2025-02-20 05:00:31

尝试这样 -

$(document).on( 'click', '.click-activity', function () { ... });

Try like this way -

$(document).on( 'click', '.click-activity', function () { ... });

事件绑定在动态创建的元素上?

朮生 2025-02-19 19:23:00
model = AutoModelForSequenceClassification.from_pretrained("dbmdz/bert-base-german-cased", num_labels=2).to(device)
all(p.requires_grad for p in model.parameters()
# True

因此,如果您希望它们冻结,则需要自己冻结它们。

model = AutoModelForSequenceClassification.from_pretrained("dbmdz/bert-base-german-cased", num_labels=2).to(device)
all(p.requires_grad for p in model.parameters()
# True

So you'll need to freeze them yourself if you want them frozen.

Huggingface Bert模型的预训练层是否冻结了?

朮生 2025-02-19 18:14:55
const tempobj = [
{
    id: "1",
    fanimate: [
        {
            id: "111",
            animate: "xyz",
        },
    ],
}];

const modified = tempobj.map(temp => {
  const newtemp = {
    id: temp.id,
    fanimate: [...temp.fanimate, {id:"222", animate:"def"}]
  }
  return newtemp;
})

console.log(modified);
const tempobj = [
{
    id: "1",
    fanimate: [
        {
            id: "111",
            animate: "xyz",
        },
    ],
}];

const modified = tempobj.map(temp => {
  const newtemp = {
    id: temp.id,
    fanimate: [...temp.fanimate, {id:"222", animate:"def"}]
  }
  return newtemp;
})

console.log(modified);

如何更新reactj中的嵌套对象

朮生 2025-02-19 16:05:33

Snakemake使用输出中的模式来推断要使用的输入。在最后一个规则中,输出为raw_counts,它没有指出{sample> {sample} Wildcard的使用。将其更改为这样的东西可能适用于您的用例:

rule featureCounts:
    input:
        samples="aligned/{sample}.sorted.bam",   
        gtf=rules.get_genome_gtf.output.gtf
    output:
        "raw_Counts_{sample}.txt"

这需要将扩展​​的版本添加到规则all

    # add this target to rule all
    expand("raw_Counts_{sample}.txt", sample=SAMPLE),

edit:如果此规则作为汇总打算,则在输入指令中,您将需要通过替换所有值来删除通配符搜索。

rule featureCounts:
    input:
        samples=expand("aligned/{sample}.sorted.bam", sample=SAMPLE),   
        gtf=rules.get_genome_gtf.output.gtf
    output:
        "raw_Counts"

编辑2:请注意,glob_wildcards不会返回每个通配符的唯一值,而是与每个GlobBed文件关联的通配符。如果您想要唯一的值,那么实现这一目标的一种简单方法是将示例转换为集合(专门针对此规则)。

rule featureCounts:
    input:
        samples=expand("aligned/{sample}.sorted.bam", sample=set(SAMPLE)),   
        gtf=rules.get_genome_gtf.output.gtf
    output:
        "raw_Counts"

Snakemake uses pattern in the output to infer which inputs to use. In the last rule, output is raw_Counts, which gives no indication of what to use for {sample} wildcard. Changing it to something like this might work for your use case:

rule featureCounts:
    input:
        samples="aligned/{sample}.sorted.bam",   
        gtf=rules.get_genome_gtf.output.gtf
    output:
        "raw_Counts_{sample}.txt"

This will require adding the expanded version to rule all:

    # add this target to rule all
    expand("raw_Counts_{sample}.txt", sample=SAMPLE),

Edit: if this rule is intended as an aggregate, then in the input directive you will want to remove wildcard search by substituting all the values.

rule featureCounts:
    input:
        samples=expand("aligned/{sample}.sorted.bam", sample=SAMPLE),   
        gtf=rules.get_genome_gtf.output.gtf
    output:
        "raw_Counts"

Edit 2: note that glob_wildcards does not return unique values for each wildcard, but rather the wildcards associated with each globbed file. If you want unique values, then one easy way to achieve that is to convert SAMPLE to a set (specifically for this rule).

rule featureCounts:
    input:
        samples=expand("aligned/{sample}.sorted.bam", sample=set(SAMPLE)),   
        gtf=rules.get_genome_gtf.output.gtf
    output:
        "raw_Counts"

请向我解释为什么我在Snakemake中遇到这个错误?我几天都在努力,请告知我怎么了

朮生 2025-02-19 10:37:36

当我使用Google-cloud-automl&lt; = 0.1.2时,我会使用您的代码出现相同的错误。如果您使用Google-cloud-automl&gt; = 0.1.2,则将解决您的错误。但是我建议始终通过执行pip install-upgrade google-cloud-automl来安装最新版本,以最大程度地提高Google Cloud的最新更新。

I got the same error using your code when I used google-cloud-automl<=0.1.2. Your error will be fixed if you use google-cloud-automl>=0.1.2. But I suggest to always install the latest version by doing pip install --upgrade google-cloud-automl to maximize the latest updates from Google Cloud.

如何使用Google Cloud Automl创建数据集

朮生 2025-02-19 03:43:30

尝试一下它可能是有用的

应用程序。

您不需要“/”“ JS”之前,因为它已经包括上述:

<script src="test.js"></script>

try this it might be helpful

app.use(express.static('/'));

you do not need the "/" before "js" because it is already included above:

<script src="test.js"></script>

node.js&#x2b; express.js:如何使用root(/)用于服务静态文件?

朮生 2025-02-19 02:25:03

创建列

A <- c(4, 5, 6, 73, 23)
B <- c(8, 12, 23, 234, 23)
C <- c(23, 325, 56, 21, 213)
ID <- c(1, 2, 3, 4, 5)

添加到数据框架

df = data.frame(A, B, C, ID)

划分并打印

df$A <- df$A / df$C
df$B <- df$B / df$C
df$C <- df$C / df$C

print(df)

Create Columns

A <- c(4, 5, 6, 73, 23)
B <- c(8, 12, 23, 234, 23)
C <- c(23, 325, 56, 21, 213)
ID <- c(1, 2, 3, 4, 5)

Add to data frame

df = data.frame(A, B, C, ID)

divide by and print

df$A <- df$A / df$C
df$B <- df$B / df$C
df$C <- df$C / df$C

print(df)

将所有列除以特定列,除了一个

朮生 2025-02-18 16:48:39

Firefox似乎是一个问题。这种解决方法可以毫无疑问。

确保您没有启用光滑的滚动行为。

html {
  /* Make sure this line is disabled! */
  /* scroll-behavior: smooth; */
}

创建一个变量,该变量将用于以后存储当前的y滚动位置,也可能是类属性。

let currentScroll = 0;

在HCAPTCHA初始化时,将其指向一个回调,该回调将在挑战出现时被解雇。

function onCaptchaOpen() {
  if (('netscape' in window) && / rv:/.test(navigator.userAgent)) {
    window.scrollTo({ top: currentScroll });
  }
}

let widgetId = window.hcaptcha.render('contact-captcha', {
  sitekey: '10000000-ffff-ffff-ffff-000000000001',
  size: 'invisible',
  'open-callback': onCaptchaOpen,
});

然后找到提交按钮,然后在触发验证码挑战之前立即存储当前的滚动位置。

function validate(event) {
  event.preventDefault();

  currentScroll = (window.pageYOffset || document.scrollTop) - (document.clientTop || 0);

  window.hcaptcha
    .execute(widgetId, { async: true })
    .then(({ response }) => console.log(response));
}

const submitButton = $('#submit-button').get(0);
submitButton.onclick = validate;

固定codepen:

It seems to be an issue with Firefox. This workaround can fix it seemlessly.

Make sure you don't have the smooth-scrolling behavior enabled.

html {
  /* Make sure this line is disabled! */
  /* scroll-behavior: smooth; */
}

Create a variable which will be used to store your current Y scroll position later, might be a class attribute too.

let currentScroll = 0;

At the hCaptcha initialization, point it to a callback which will be fired when the challenge will appear.

function onCaptchaOpen() {
  if (('netscape' in window) && / rv:/.test(navigator.userAgent)) {
    window.scrollTo({ top: currentScroll });
  }
}

let widgetId = window.hcaptcha.render('contact-captcha', {
  sitekey: '10000000-ffff-ffff-ffff-000000000001',
  size: 'invisible',
  'open-callback': onCaptchaOpen,
});

Then find the submit button, and store the current scroll position right before triggering a captcha challenge.

function validate(event) {
  event.preventDefault();

  currentScroll = (window.pageYOffset || document.scrollTop) - (document.clientTop || 0);

  window.hcaptcha
    .execute(widgetId, { async: true })
    .then(({ response }) => console.log(response));
}

const submitButton = $('#submit-button').get(0);
submitButton.onclick = validate;

Fixed codepen: https://codepen.io/aisouard/pen/NWYEbpp

hcaptcha卷轴在援引中登上顶部

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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