つ低調成傷

文章 评论 浏览 28

つ低調成傷 2025-02-20 23:41:18

当我遇到Jaws 23和FF 115的问题时,这里列出的建议对我没有帮助。有帮助的是在FF设置中进行检查,并在浏览部分中检查“始终使用光标键在页面内导航”的复选框。

The recommendation listed here didn't help me when i ran into this issue with JAWS 23 and FF 115 today. What did help was to go in the FF settings and checking the checkbox labeled "Always use the cursor keys to navigate within pages" in the browsing section.

JAWS屏幕读取器用箭头键向上/向上滚动Firefox页面,而不是在元素之间导航

つ低調成傷 2025-02-20 22:50:18

我首选的方法是使您的main()函数直接从变量中获取其

def main(args):
    if len(args) == 1:
        print(print_help())
    elif len(args) == 2 or len(args) == 3:
        if args[1] == 'help' or args[1] == 'h' or args[1] == 'H':
            print(print_help())
    else:
        print('no such command arguments try python project.py help')

def print_help:
    the_help = 'the help section'
    return the_help

if __name__ =='__main__':
    main(sys.argv)

输入href =“ https://docs.pytest.org/en/7.1.x/how-to/capture-stdout-stderr.html#accessing-captrud-captured-capture-from-a-a-test-test-------------- from-a-a-test-finction“ rel =” nofollow noreferrer “> Capsys 在您的测试功能中测试输出,并且可以轻松地通过您要测试的任何参数列表,而无需修补或模拟 任何事物。

另外, argparse 为您进行此类命令行处理。我很高,高度建议使用它(或其他类似库),而不是重新发明轮子。

My preferred approach is make your main() function take its inputs from a variable instead of from sys.argv directly:

def main(args):
    if len(args) == 1:
        print(print_help())
    elif len(args) == 2 or len(args) == 3:
        if args[1] == 'help' or args[1] == 'h' or args[1] == 'H':
            print(print_help())
    else:
        print('no such command arguments try python project.py help')

def print_help:
    the_help = 'the help section'
    return the_help

if __name__ =='__main__':
    main(sys.argv)

Now you can use capsys in your test function to test the output, and can easily pass in whatever list of arguments you want to test without having to patch or mock anything.

Also, argparse does this sort of command line processing for you. I highly, highly recommend using it (or other similar libraries) instead of re-inventing the wheel.

pytest断言是否sys。 argv ==它将运行一个功能

つ低調成傷 2025-02-20 21:03:12

某种形式的传奇可能在这里很有用。周围有很多图书馆,它们通常都可以处理“补偿交易”。

预烘烤库

  • 是否要
  • 使用

不管 最后一步失败,将消息发送到其他队列。它的消费者将负责从Mongo中删除数据。

我还建议使用发件框图案提高弹性。

(免责声明,我是Opensleigh的作者,一个.NET SAGA库)

some form of Saga might be useful here. There's plenty of libraries around, and they usually all have a way to deal with "compensating transactions".

Regardless you go for a pre-baked library or not, the flow might be something like this:

  • write data to Mongo inside a transaction
  • if write is successful, send a message to a queue
  • the message consumer takes care of writing to Neo4j

in case the last step fails, send a message to a different queue. Its consumer will take care of removing data from Mongo.

I'd also suggest to use the Outbox pattern to improve the resiliency.

(disclaimer, I'm the author of OpenSleigh, a .NET Saga library)

如何实施同步交易系统?

つ低調成傷 2025-02-20 20:10:07

您将需要按正确的顺序将因子的水平放置。您可以对此

ggplot(koka, aes(
  x=factor(format(M_Datum, "%b %Y"), levels=format(sort(unique(M_Datum)),"%b %Y")), 
  y=Yiel,
  group = 1)) + ...

有点混乱,因此您可以编写一个辅助功能来清理,

date_factor <- function(dates, format_string="%b %Y") {
  factor(format(dates, format_string), levels=format(sort(unique(dates)), format_string))
}
ggplot(koka, aes(x=date_factor(M_Datum), y=Yiel,group = 1)) + ...

从而导致以下图

“在此处输入图像说明”

You will need to put the levels of the factor in the correct order. You can do that with

ggplot(koka, aes(
  x=factor(format(M_Datum, "%b %Y"), levels=format(sort(unique(M_Datum)),"%b %Y")), 
  y=Yiel,
  group = 1)) + ...

Which is a bit messy so you could write a helper function to clean up up

date_factor <- function(dates, format_string="%b %Y") {
  factor(format(dates, format_string), levels=format(sort(unique(dates)), format_string))
}
ggplot(koka, aes(x=date_factor(M_Datum), y=Yiel,group = 1)) + ...

That results in the following plot

enter image description here

在X轴是日期的因素的命令或对X轴上排序?

つ低調成傷 2025-02-20 12:44:29

您可以使用$ redion为此:

db.collection.aggregate([
  {
    $match: {
      createdAt: {
        $gte: ISODate("2022-06-28T00:00:00.000Z"),
        $lte: ISODate("2022-06-30T00:00:00.000Z")
      }
    }
  },
  {
    $project: {
      grandTotal: {
        $reduce: {
          input: "$payments",
          initialValue: 0,
          in: {
            $cond: [
              {$eq: ["$this.paymentType", "charge"]},
              {$add: ["$this.paymentTotal", "$value"]},
              {$subtract: ["$value", "$this.paymentTotal"]}
            ]
          }
        }
      }
    }
  }
])

查看其在

You can use $reduce for it:

db.collection.aggregate([
  {
    $match: {
      createdAt: {
        $gte: ISODate("2022-06-28T00:00:00.000Z"),
        $lte: ISODate("2022-06-30T00:00:00.000Z")
      }
    }
  },
  {
    $project: {
      grandTotal: {
        $reduce: {
          input: "$payments",
          initialValue: 0,
          in: {
            $cond: [
              {$eq: ["$this.paymentType", "charge"]},
              {$add: ["$this.paymentTotal", "$value"]},
              {$subtract: ["$value", "$this.paymentTotal"]}
            ]
          }
        }
      }
    }
  }
])

See how it works on the playground example

如何在MongoDB中执行有条件的算术操作

つ低調成傷 2025-02-20 09:24:10

由于您执行回归,因此crossentropyloss()内部实现nllloss()函数。 crossentropyloss()期望c c预测的类,但您仅指定了一个类。 nllloss()试图根据地面真实值索引到预测逻辑。例如,在您的情况下,地面真相是单个值14。损失步骤试图将预测的第14个logit索引以获取其相应的值,以便它可以计算出其上的负日志可能性,这实际上是 - 这是 - -log(probinality_k)其中k是基地真相输出的索引。由于您的预测中只有logit,因此它会出现错误 - index out bounds

对于回归问题,您应该考虑使用基于距离的损失,例如mseloss()

尝试替换损失函数 - lose_function = crossentropyloss() lose_function = mseloss()

Since you are performing regression, the CrossEntropyLoss() internally implements the NLLLoss() function. The CrossEntropyLoss() expects C classes for C predictions but you have specified only one class. The NLLLoss() tries to index into the prediction logits based on the ground-truth value. E.g., in your case, the ground-truth is a single value 14. The loss step tries to index into the 14th logit of your predictions to get its corresponding value so that it can compute the negative log likelihood on it, which is essentially - -log(probability_k) where k is the index that the ground-truth outputs. Since you have only logit in your predictions, it throws an error - index out of bounds.

For regression problems, you should consider using distance based losses such as MSELoss().

Try replacing your loss function - loss_function = CrossEntropyLoss() with loss_function = MSELoss()

使用Pytorch回归的神经网络

つ低調成傷 2025-02-18 13:50:34

首先,我认为ceil(1/divide * 1&lt; 32)可以取决于鸿沟,而结果却不在一个情况下。因此,您不需要循环,但是有时您需要纠正因素。

其次,JS代码似乎允许32shift = p -32 //移位量返回。但是它永远不会返回。因此,不确定那里发生了什么。

为什么不在C ++中实现JS代码,然后在所有INT32_T上运行一个循环,然后看看它们是否给出相同的结果?那不应该花太久。

当您找到d时,您可以使用魔术数字来测试所有a/d in int32_t a a/d ,a * m_ceila * m_js

First I think ceil(1/divide * 1<<32) can, depending on the divide, have cases where the result is off by one. So you don't need a loop but sometimes you need a corrective factor.

Secondly the JS code seems to allow for other shifts than 32: shift = p - 32 // shift amount to return. But then it never returns that. So not sure what is going on there.

Why not implement the JS code in C++ as well and then run a loop over all int32_t and see if they give the same result? That shouldn't take too long.

And when you find a d where they differ you can then test a / d for all int32_t a using both magic numbers and compare a / d, a * m_ceil and a * m_js.

为什么JavaScript部门在乘法代码中有一个循环?

つ低調成傷 2025-02-18 04:12:07

我认为当您进入Docker网络时,问题是在端口中使用的

- Redis__Port=6380

,您应该使用内部端口,而不是外部暴露的端口。
应该是

- Redis__Port=6379

I think the issue is with port

- Redis__Port=6380

when you are in docker network you should use internal port, not the one which is exposed for outside.
it should be

- Redis__Port=6379

Docker组成Redis,无法连接到Redis服务器。现在连接错误

つ低調成傷 2025-02-18 03:29:07

我对Nestjs Kafka客户端代码进行了探索越多,我找到了解决问题的解决方案。另外,此 https://github.com/nestjs/nestjs/nest/nest/sissues/issues/3726 帮助我解决了这个问题。

确切的问题是:在Kafka中,微服务缓冲区的值始终被串制,这禁止解析正确的格式。

解决方案是设置解析器选项:Kafkaconfig中的keepbinary为true,以保留缓冲区格式。

{
  transport: Transport.KAFKA,

  options: {
    client: {
      brokers: ['localhost:9092'],
    },
    consumer: {
      groupId: 'consumer-1',
    },
    parser: { keepBinary: true },
  },
}

The more i explored into nestjs kafka client code, i found the solution to my problem. Also, this https://github.com/nestjs/nest/issues/3726 helped me resolve the issue.

The exact issue was : In Kafka Microservice Buffer values are always stringified, which was prohibiting the parsing to the right format.

The solution is to set parser options: keepBinary as true in the kafkaconfig, so as to preserve the buffer format.

{
  transport: Transport.KAFKA,

  options: {
    client: {
      brokers: ['localhost:9092'],
    },
    consumer: {
      groupId: 'consumer-1',
    },
    parser: { keepBinary: true },
  },
}

无法在Nestjs进行Kafka事件

つ低調成傷 2025-02-17 23:54:40

您需要使用 /a>为了正确注册patch模块的列表mode> model nn.module

class Model(nn.Module):
   def __init__(self, patches=10, *kwargs):
      super().__init__()
      self.patch = Patch()
      enc = []
      for i in range(patches):
         enc.append(Encoder())
      self.enc = nn.ModuleList(enc)

以稍微重新的形式:

class Model(nn.Module):
   def __init__(self, patches=10, *kwargs):
      super().__init__()
      self.patch = Patch()
      self.enc = nn.ModuleList(Encoder() for _ in range(patches))

   def forward(self, x):
      patches = self.patch(x)
      output_feats = torch.cat([enc(patch) for enc, patch in zip(self.enc, patches])

You need to use a nn.ModuleList in order to properly register the list of Patch modules inside Model nn.Module:

class Model(nn.Module):
   def __init__(self, patches=10, *kwargs):
      super().__init__()
      self.patch = Patch()
      enc = []
      for i in range(patches):
         enc.append(Encoder())
      self.enc = nn.ModuleList(enc)

In a slightly refactored form:

class Model(nn.Module):
   def __init__(self, patches=10, *kwargs):
      super().__init__()
      self.patch = Patch()
      self.enc = nn.ModuleList(Encoder() for _ in range(patches))

   def forward(self, x):
      patches = self.patch(x)
      output_feats = torch.cat([enc(patch) for enc, patch in zip(self.enc, patches])

Pytorch中的多个平行图像编码器

つ低調成傷 2025-02-17 23:16:40

使用隐式递归DFS。您可以使用货物expand 或工具 - &gt;在操场上展开宏。 #[derive(partiaLeq)]在您的示例输出中:

impl ::core::marker::StructuralPartialEq for TreeNode {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for TreeNode {
    #[inline]
    fn eq(&self, other: &TreeNode) -> bool {
        match *other {
            Self {
                val: ref __self_1_0,
                left: ref __self_1_1,
                right: ref __self_1_2,
            } => match *self {
                Self {
                    val: ref __self_0_0,
                    left: ref __self_0_1,
                    right: ref __self_0_2,
                } => {
                    (*__self_0_0) == (*__self_1_0)
                        && (*__self_0_1) == (*__self_1_1)
                        && (*__self_0_2) == (*__self_1_2)
                }
            },
        }
    }
    #[inline]
    fn ne(&self, other: &TreeNode) -> bool {
        match *other {
            Self {
                val: ref __self_1_0,
                left: ref __self_1_1,
                right: ref __self_1_2,
            } => match *self {
                Self {
                    val: ref __self_0_0,
                    left: ref __self_0_1,
                    right: ref __self_0_2,
                } => {
                    (*__self_0_0) != (*__self_1_0)
                        || (*__self_0_1) != (*__self_1_1)
                        || (*__self_0_2) != (*__self_1_2)
                }
            },
        }
    }
}

这可能令人生畏,但实际上与以下内容相同:

impl PartialEq for TreeNode {
    fn eq(&self, other: &TreeNode) -> bool {
        self.val == other.val && self.left == other.left && self.right == other.right
    }
}

因此,它首先比较该值,然后递归到left,它将再次比较其价值...直到我们完成左边并从权利开始。 DFS。它可能与您手中写的内容不同,因为它是递归的并且可能会炸毁堆栈,但仍然有效。

Using implicit recursive DFS. You can observe the result of macros (including #[derive()] macros) using cargo-expand, or Tools->Expand Macros in the playground. The #[derive(PartialEq)] in your example outputs:

impl ::core::marker::StructuralPartialEq for TreeNode {}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::cmp::PartialEq for TreeNode {
    #[inline]
    fn eq(&self, other: &TreeNode) -> bool {
        match *other {
            Self {
                val: ref __self_1_0,
                left: ref __self_1_1,
                right: ref __self_1_2,
            } => match *self {
                Self {
                    val: ref __self_0_0,
                    left: ref __self_0_1,
                    right: ref __self_0_2,
                } => {
                    (*__self_0_0) == (*__self_1_0)
                        && (*__self_0_1) == (*__self_1_1)
                        && (*__self_0_2) == (*__self_1_2)
                }
            },
        }
    }
    #[inline]
    fn ne(&self, other: &TreeNode) -> bool {
        match *other {
            Self {
                val: ref __self_1_0,
                left: ref __self_1_1,
                right: ref __self_1_2,
            } => match *self {
                Self {
                    val: ref __self_0_0,
                    left: ref __self_0_1,
                    right: ref __self_0_2,
                } => {
                    (*__self_0_0) != (*__self_1_0)
                        || (*__self_0_1) != (*__self_1_1)
                        || (*__self_0_2) != (*__self_1_2)
                }
            },
        }
    }
}

That might be daunting, but is actually the same as:

impl PartialEq for TreeNode {
    fn eq(&self, other: &TreeNode) -> bool {
        self.val == other.val && self.left == other.left && self.right == other.right
    }
}

So it first compares the value, and then recurses into left, which will again compare its value... until we finish the left and start with the rights. A DFS. It may not be the same as what you wrote in hand because it is recursive and may blow the stack, but it still works.

为什么生锈可以直接使用==检查两棵树?

つ低調成傷 2025-02-17 21:15:31

尝试用灵活的小部件将您的ListView/GridView包装。另外,您还将物理学设置为NeverScrollables Crollphysics(),因此将其更改为其他卷轴物理(例如OblisyScrollablesCrollphysics()),如果您希望它可以滚动

Try wrapping your ListView/GridView with a Flexible Widget. Also Youve set physics to NeverScrollableScrollPhysics() so change it to some other scroll physics(like AlwaysScrollableScrollPhysics()) if you want it to be scrollable

gridview.count()don&#x27; t滚动-Flutter

つ低調成傷 2025-02-17 18:53:26

另一个解决方案是通过顺序执行器执行代码 nsynjs

如果基础函数受到承诺,则

NSYNJS将依次评估所有承诺,并将承诺结果放入data属性中:

function synchronousCode() {

    var getURL = function(url) {
        return window.fetch(url).data.text().data;
    };
    
    var url = 'https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js';
    console.log('received bytes:',getURL(url).length);
    
};

nsynjs.run(synchronousCode,{},function(){
    console.log('synchronousCode done');
});
<script src="https://rawgit.com/amaksr/nsynjs/master/nsynjs.js"></script>

如果基础函数不承诺

步骤1。将函数用回调包装到Nsynjs-Aware Warper包装器(如果它具有合理的版本,您可以跳过此步骤):

var ajaxGet = function (ctx,url) {
    var res = {};
    var ex;
    $.ajax(url)
    .done(function (data) {
        res.data = data;
    })
    .fail(function(e) {
        ex = e;
    })
    .always(function() {
        ctx.resume(ex);
    });
    return res;
};
ajaxGet.nsynjsHasCallback = true;

步骤2。将同步逻辑放入函数:

function process() {
    console.log('got data:', ajaxGet(nsynjsCtx, "data/file1.json").data);
}

步骤3。运行。运行。运行 。通过NSYNJS以同步方式函数:

nsynjs.run(process,this,function () {
    console.log("synchronous function finished");
});

Nsynjs将评估所有操作员和表达式,并逐步评估执行,以防如果某些慢速功能的结果尚未准备就绪。

更多示例是在这里

Another solution is to execute code via the sequential executor nsynjs.

If the underlying function is promisified

nsynjs will evaluate all promises sequentially, and put the promise result into the data property:

function synchronousCode() {

    var getURL = function(url) {
        return window.fetch(url).data.text().data;
    };
    
    var url = 'https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js';
    console.log('received bytes:',getURL(url).length);
    
};

nsynjs.run(synchronousCode,{},function(){
    console.log('synchronousCode done');
});
<script src="https://rawgit.com/amaksr/nsynjs/master/nsynjs.js"></script>

If the underlying function is not promisified

Step 1. Wrap the function with a callback into the nsynjs-aware wrapper (if it has a promisified version, you can skip this step):

var ajaxGet = function (ctx,url) {
    var res = {};
    var ex;
    $.ajax(url)
    .done(function (data) {
        res.data = data;
    })
    .fail(function(e) {
        ex = e;
    })
    .always(function() {
        ctx.resume(ex);
    });
    return res;
};
ajaxGet.nsynjsHasCallback = true;

Step 2. Put synchronous logic into function:

function process() {
    console.log('got data:', ajaxGet(nsynjsCtx, "data/file1.json").data);
}

Step 3. Run function in synchronous manner via nsynjs:

nsynjs.run(process,this,function () {
    console.log("synchronous function finished");
});

Nsynjs will evaluate all operators and expressions step-by-step, pausing execution in case if the result of some slow function is not ready.

More examples are here.

如何从异步电话中返回响应?

つ低調成傷 2025-02-17 07:41:57

在jQuery库旁边和脚本之前添加以下脚本

<!-- check Xsrf Token -->
<script>
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
</script>

add the following script next to jquery library and before your script

<!-- check Xsrf Token -->
<script>
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
</script>

我的Laravel&amp; Ajax表单正在返回错误419

つ低調成傷 2025-02-17 05:19:35

您已经在onModeLcreating中绘制了错误的实体 table警报。

尝试

modelBuilder.Entity<Alert>().ToTable("Alert")

You have mapped the wrong entity in your OnModelCreating for table Alert.

Try with

modelBuilder.Entity<Alert>().ToTable("Alert")

EF核心:实体需要一个钥匙 - 但它确实有一个钥匙

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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