问题列表 - 第317996页

cypress 组件测试未捕获从我的 Vue3 组件发出的更新事件

我是组件测试和在赛普拉斯中使用间谍的新手,所以这可能是一个愚蠢的问题。

我有一个非常简单的组件,我正在测试它,当您在组件中进行选择时,选择会通过 modelValue 属性发送回父级。

我的组件在我的应用程序中工作(v-model 更新为选择的正确值就好),但我似乎无法在测试中捕获和验证它。

在我的组件内部,这是我执行发射的方式:

handleSelectionChange() {
  console.log("emitting update:modelValue= ", this.selectedOption);
  this.$emit('update:modelValue', this.selectedOption);
}, 
Run Code Online (Sandbox Code Playgroud)

控制台显示测试运行时值的变化,所以我认为这部分没问题。同样,当我在应用程序中使用该组件时,v-model 正在更新,因此我希望这不是问题。

我的Cypress 组件测试如下所示:

it.only('should emit an event when the value is changed', () => {
const mockData = ["one", "two", "three"];

cy.intercept('GET', '/v1/product', {
  statusCode: 200,
  body: mockData,
}).as('getProductData');

cy.mount(ProductPicker, {
  props: { modelValue: null },
  on: {
    'update:modelValue': cy.spy().as('updateModelValueSpy'),
  },
}).then(() => {
  cy.get('select').select('two');

  // Wait added as part of trouble shooting, hopefully not needed
  cy.wait(500); 

  // Ensure the …
Run Code Online (Sandbox Code Playgroud)

cypress cypress-component-test-runner cypress-intercept

3
推荐指数
1
解决办法
116
查看次数

如何有效地将对划分为簇,以便每个簇包含给定集合的所有条目

假设我们有一组v偶数基数,例如 ,v <- 1:6和一个由 的df条目组成的data.frame v,它是由每列中每个元素的固定出现次数定义的v,即k,例如

k <- 2
x <- rep(v, each = k)
df <- data.frame(A = x, B = c(tail(x, -(k + 1)), head(x, k + 1)))
Run Code Online (Sandbox Code Playgroud)

显示为

> df
   A B
1  1 2
2  1 3
3  2 3
4  2 4
5  3 4
6  3 5
7  4 5
8  4 6
9  5 6
10 5 1
11 6 1
12 …
Run Code Online (Sandbox Code Playgroud)

algorithm performance grouping r

15
推荐指数
1
解决办法
531
查看次数

导入张量流问题:系统错误:_pywrap_checkpoint_reader 的初始化引发了未报告的异常

在 Ubuntu 22.04 机器上运行,安装了 Spyder 3.9,安装了tensorflow 2.15。

只是尝试导入包,我运行并返回以下错误:

import tensorflow as tf
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xe

Traceback (most recent call last):

  File "/tmp/ipykernel_275746/3793406994.py", line 1, in <module>
    import tensorflow as tf

  File "/home/chris/anaconda3/lib/python3.9/site-packages/tensorflow/__init__.py", line 48, in <module>
    from tensorflow._api.v2 import __internal__

  File "/home/chris/anaconda3/lib/python3.9/site-packages/tensorflow/_api/v2/__internal__/__init__.py", line 11, in <module>
    from tensorflow._api.v2.__internal__ import distribute

  File "/home/chris/anaconda3/lib/python3.9/site-packages/tensorflow/_api/v2/__internal__/distribute/__init__.py", line 8, in <module>
    from tensorflow._api.v2.__internal__.distribute import combinations

  File "/home/chris/anaconda3/lib/python3.9/site-packages/tensorflow/_api/v2/__internal__/distribute/combinations/__init__.py", line 8, in <module>
    from tensorflow.python.distribute.combinations import …
Run Code Online (Sandbox Code Playgroud)

python tensorflow

6
推荐指数
0
解决办法
1880
查看次数

在 .ForEach() 方法中使用 continue/return 语句 - 使用 foreach ($item in $collection) 是否更好?

有相当详细的记录表明,foreach 处理速度根据 foreach 循环的执行方式而变化(从最快到最慢排序):

  1. .ForEach() 方法
  2. foreach($collection 中的$item){}
  3. $收藏| ForEach-对象{}


  • 当处理(非常)大的集合时,#1 和#2 之间的速度比较可能很重要,并且管道的开销使得#3 在这些情况下不适合。
  • #2 提供了该continue声明,而 #1 没有
    • 如果不准确,请纠正/评论
  • 从我在网上和现实生活中看到的,return是如何“continue使用”.ForEach()方法时。



我的问题:

  1. 当该方法的速度优势.ForEach()太大而难以满足foreach而您又需要时,正确的使用continue方法是什么?continue.ForEach({})
  2. return在方法内部使用时,您应该注意哪些含义或陷阱.ForEach()?

powershell foreach loops continue return

5
推荐指数
1
解决办法
194
查看次数

std::forward 在折叠表达式的上下文中如何工作?

在MSVC STL中,实现std::apply如下:

template <class _Callable, _Tuple_like _Tuple, size_t... _Indices>
constexpr decltype(auto) _Apply_impl(_Callable&& _Obj, _Tuple&& _Tpl, index_sequence<_Indices...>) noexcept(/* [...] */) {
    return _STD invoke(_STD forward<_Callable>(_Obj), _STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...);
}
Run Code Online (Sandbox Code Playgroud)

在表达式 中_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...,std::get被调用的次数与元组的长度相同。但是,每次调用 时std::get,都会有一个相应的调用std::forward.当转发右值时,std::forward相当于,意味着对该对象的std::move多次调用。这似乎可能是无效的。有人可以帮助解释我的担忧吗?std::move_Tpl

我尝试搜索各种资源,但找不到我正在寻找的答案。从定义开始也没有说服我。

c++ templates reference rvalue stdmove

5
推荐指数
1
解决办法
100
查看次数

使用 mongoose 和 mongodb 社区版进行矢量搜索

  • 我需要一种对作为文档存储在 Mongodb 中的文本、图像和视频属性实现矢量搜索的方法。我正在使用 mongoose 节点包作为节点 js 应用程序的模型文件。
  • 是否可以使用 mongodb 社区版执行矢量搜索?或任何可用于执行矢量搜索的替代方案。请分享一个在不使用 mongoDB Atlas 版本的情况下使用 mongoDB 实现 Node js 应用程序矢量搜索的路径。

mongoose mongodb node.js

5
推荐指数
0
解决办法
342
查看次数

由于 class(x) 返回矩阵和数组,旧 R 包中出现错误 - 这是新的吗?

我正在使用一个名为PIMixture(请参阅此处)的旧包,它在代码的各个位置引发了很多错误。它们看起来都像这样或类似(以下几行实际上来自可重现的示例):

> library(PIMixture)
> data(PIdata)
> model<-"C_CIN3PLUS+L_CIN3PLUS+R_CIN3PLUS~RES_HPV16"
> fit1<-PIMixture(p.model=model,data=PIdata1, model="logistic-Weibull")
Error in if (class(mat2) == "numeric") { : the condition has length > 1
Run Code Online (Sandbox Code Playgroud)

经过调查我发现

> class(mat2)
[1] "matrix" "array" 
Run Code Online (Sandbox Code Playgroud)

因此 if 子句返回错误。我不敢相信这是开发包时的一个问题,因为它会被注意到。因此我想知道在 R 的早期版本中是否class(mat2)可能评估为"Matrix"only,因此长度为 1。我可以在源代码中应用修复,PIMixture如下所示:class(mat2)[1]。不太好,但是这个包就可以工作了。我想知道这个问题是否是由于 R 跨版本的更改而发生的,或者为什么会发生这个问题。

arrays r version matrix

2
推荐指数
1
解决办法
87
查看次数

提取R中没有重复顶点属性的所有子图

我有一个像这样的图形对象:

# Create an empty graph
gss <- make_empty_graph(n = 12, directed = FALSE)

# Define vertex attributes
vertex_attr(gss) <- list(
  name = c("1", "2", "3", "4", "6", "7", "8", "10", "11", "17", "21", "23"),
  label = c("st_con_rt=main-room", "st_con_rt=sub-room", "st_con_tr=direct", "st_con_tr=terrace", "st_th=tsuma", "st_adsb=add", "st_adsb=sub", "tr_adsb=sub", "st_sub_main_th=hira", "roo_com=1a+7", "roo_com=2a+7", "roo_com=4a"),
  index = c(1, 2, 3, 4, 6, 7, 8, 10, 11, 17, 21, 23),
  element = c("st_con_rt", "st_con_rt", "st_con_tr", "st_con_tr", "st_th", "st_adsb", "st_adsb", "tr_adsb", "st_sub_main_th", "roo_com", "roo_com", "roo_com")
)

# Define …
Run Code Online (Sandbox Code Playgroud)

algorithm r igraph

5
推荐指数
1
解决办法
152
查看次数

升级到 django 5.0 后出现问题“AttributeError: 'BlankChoiceIterator' 对象没有属性 '__len__'”

我是 django triad 的新手,要升级到版本 5.0,但在我的项目中遇到了这个问题

Traceback (most recent call last):
  File "dirto/env/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "dirto/env/lib/python3.10/site-packages/django/core/handlers/base.py", line 220, in _get_response
    response = response.render()
  File "dirto/env/lib/python3.10/site-packages/django/template/response.py", line 114, in render
    self.content = self.rendered_content
  File "dirto/env/lib/python3.10/site-packages/django/template/response.py", line 92, in rendered_content
    return template.render(context, self._request)
  File "dirto/env/lib/python3.10/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "dirto/env/lib/python3.10/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "dirto/env/lib/python3.10/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "dirto/env/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node …
Run Code Online (Sandbox Code Playgroud)

python django

5
推荐指数
2
解决办法
821
查看次数

无法定义名为“new”且不将 self 作为第一个参数的关联函数

我在 期间收到以下错误cargo build。我不知道如何解决这个问题。

error: not &self method
  --> src/new_service.rs:20:18
   |
20 |     pub async fn new() -> Self {
   |                  ^^^

Run Code Online (Sandbox Code Playgroud)

src/new_service.rs 的相关部分:

pub struct Service {
    start: Event,
    collections: Vec<Collection>,
    clients: Vec<Client>,
}

#[dbus_interface(name ="org.freedesktop.Secret.Service")]
impl Service {
    pub async fn new() -> Self {
        Service {
            start: event_listener::Event::new(),
            collections: Vec::new(),
            clients: Vec::new(),
        }
    }
.....
Run Code Online (Sandbox Code Playgroud)

rust

1
推荐指数
1
解决办法
58
查看次数