烙印

文章 评论 浏览 31

烙印 2025-02-20 11:20:16

查看umap.jl,输入矩阵应具有形状(n_features x n_samples)。如果您的字典中的每个条目都是示例,并且我正在正确解释您的矩阵符号,则看来您已经反转了。

您应该能够将字典的键作为注释添加到图中(可能带有可选的每个坐标的额外偏移):

Plots.annotate!(
    embedding[1,:] .+ x_offset,
    embedding[2,:] .+ y_offset,
    string.(collect(keys(yourdict)))
)

最后,我不确定您实际上想映射到标记颜色的颜色哪些变量在散点图中。如果是钥匙的整数值,则应像上面一样将其传递给散点功能,除非不将它们变成字符串。

Looking at UMAP.jl, the input matrix should have the shape (n_features x n_samples). If each entry in your dictionary is a sample and I’m interpreting your matrix notation correctly, it appears you have this reversed.

You should be able to add the keys of the dictionary as annotations to the plot as follows (potentially with an optional additional offset to each coordinate):

Plots.annotate!(
    embedding[1,:] .+ x_offset,
    embedding[2,:] .+ y_offset,
    string.(collect(keys(yourdict)))
)

Finally, I’m not sure what variable you actually want to map to the color of the markers in the scatterplot. If it’s the integer value of the keys you should pass this to the scatter function just like above except without turning them into strings.

朱莉娅词典的UMAP

烙印 2025-02-19 22:09:12

Proble:在此情况下,如果(ISSET($ _ get ['image_url'])){....

1:您在if条件下未将image_url发送到服务器。2

:而缺少)。

您可以如下修改服务器上的代码

<?php
if (isset($_GET['id']) && $_GET['id']=='image_url') {
     $url = $_GET['IdCompanyAnbar']??0;
     // Save all user data
     if($url == 12){
         echo json_encode(array('success' => 0, 'message' => 'Please complete both fields'));
     } else {
         echo json_encode(array('success' => 1));
     }
}else{
         echo json_encode(array('success' => 1));
}
?>

the proble: in this condition if (isset($_GET['image_url']) {....

1: you didn't send the image_url to the server.

2: and missing the ) in the if condition.

You can modify the code on the server as follows

<?php
if (isset($_GET['id']) && $_GET['id']=='image_url') {
     $url = $_GET['IdCompanyAnbar']??0;
     // Save all user data
     if($url == 12){
         echo json_encode(array('success' => 0, 'message' => 'Please complete both fields'));
     } else {
         echo json_encode(array('success' => 1));
     }
}else{
         echo json_encode(array('success' => 1));
}
?>

在Ajax中发送静态文本

烙印 2025-02-19 10:49:22

Python中的 self < / code>关键字类似于 c ++ / java / c#中的此< / code>关键字。

在Python 2中,这是由编译器隐式完成的(是的,python在内部进行了编译)。
只是在Python 3中,您需要在构造函数和成员功能中明确提及。例子:

class Pump():
    # member variable
    # account_holder
    # balance_amount

    # constructor
    def __init__(self,ah,bal):
        self.account_holder = ah
        self.balance_amount = bal

    def getPumps(self):
        print("The details of your account are:"+self.account_number + self.balance_amount)

# object = class(*passing values to constructor*)
p = Pump("Tahir",12000)
p.getPumps()

The self keyword in Python is analogous to this keyword in C++ / Java / C#.

In Python 2 it is done implicitly by the compiler (yes Python does compilation internally).
It's just that in Python 3 you need to mention it explicitly in the constructor and member functions. example:

class Pump():
    # member variable
    # account_holder
    # balance_amount

    # constructor
    def __init__(self,ah,bal):
        self.account_holder = ah
        self.balance_amount = bal

    def getPumps(self):
        print("The details of your account are:"+self.account_number + self.balance_amount)

# object = class(*passing values to constructor*)
p = Pump("Tahir",12000)
p.getPumps()

为什么我会得到“ TypeError:缺少1所需的位置参数:&#x27; self&quot”?

烙印 2025-02-19 09:38:27

JavaScript中的属性对病例敏感。因此,您必须使用 widget.data 而不是 widget.data

Properties in JavaScript are case-sensitive. Therefore, you have to use widget.data instead of widget.Data.

无法通过ReactJ中的Prop访问对象特定属性

烙印 2025-02-19 07:00:54
my_timeframe = input.timeframe(title="Custom Timeframe", defval="1", group="Strategy parameters")
    
changed_data = request.security(syminfo.tickerid, my_timeframe, graph_data, gaps=barmerge.gaps_on)
    
plot(changed_data , title = "Your custom graph", color=color.orange)

对于版本5:定义时间范围输入以允许从设置部分进行自定义,请请求安全更新与您的时间范围不同,该更新与您的视图不同,显示图形。

my_timeframe = input.timeframe(title="Custom Timeframe", defval="1", group="Strategy parameters")
    
changed_data = request.security(syminfo.tickerid, my_timeframe, graph_data, gaps=barmerge.gaps_on)
    
plot(changed_data , title = "Your custom graph", color=color.orange)

For version 5: define timeframe input to allow customize from settings section, request security update with your timeframe that is different than deafult for your view, show graph.

如何使用较低时间框架指示器的日末值绘制更高的时间框架指示器?

烙印 2025-02-19 05:52:05

如果您想使用输入字段或类型,则可以使用CheckVality()。
https://developer.mozilla.org/en-us/docs/web/api/htmlinputelement/checkvality

<html>
  <body>
    <script>
      function validation() {
        const inp = document.getElementById("url");
        const p = document.getElementById("text");
        if(!inp.checkValidity()){
          p.innerText = inp.validationMessage;
        }
      }
    </script>
    <form>
      <input id="url" type="url" placeholder="URL Here">
      <input type="submit" value="Submit" onclick="validation()">
    </form>
    <p id="text"></p>
  </body>
</html>

If you are looking to use an input field or something of the sorts, you can use checkValidity().
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity

<html>
  <body>
    <script>
      function validation() {
        const inp = document.getElementById("url");
        const p = document.getElementById("text");
        if(!inp.checkValidity()){
          p.innerText = inp.validationMessage;
        }
      }
    </script>
    <form>
      <input id="url" type="url" placeholder="URL Here">
      <input type="submit" value="Submit" onclick="validation()">
    </form>
    <p id="text"></p>
  </body>
</html>

检查URL是否在工作,如果这样做

烙印 2025-02-19 04:56:49

那将是类似的东西


this.metricCreateConfigureStore.queryBuilderFields$.pipe(
   switchMap((fields) => this.config$.pipe(
      map((item) => {
         return { ... use fields and item }
      })
   ))
)


,而且我不会在流操作中使用 this.l()函数调用,而是要使用要使用的参数,所以纯粹的函数。

That would be something like


this.metricCreateConfigureStore.queryBuilderFields$.pipe(
   switchMap((fields) => this.config$.pipe(
      map((item) => {
         return { ... use fields and item }
      })
   ))
)


And also, I would not use this.l() function call inside the stream handlind, but put a parameter to be used, so pure function.

获取可观察的RXJ内观察的价值

烙印 2025-02-19 01:32:37

由于这是第一篇文章,我将在我的具体情况下发布另一个解决方案:
我正在隐藏 parentView 使用 recyclerview 使用


parentView.setvisibility(view.gone);

recyclerview不喜欢这种情况,显然,如果要隐藏包含RecyClerview的视图,则只能使用 view.indible.indible

Since this is the first post to come up I'll post another solution to the problem which helped in my specific case:
I was hiding the parentview containing the recyclerview using


parentView.setVisibility(View.GONE);

recyclerview does not like that, apparently if you want to hide a view which contains a recyclerview, you can only use View.INVISIBLE.

当使用可运行的可运行的notifyEmchangemchange时,recyclerview崩溃了[IllegalArgumentException]

烙印 2025-02-18 17:17:15

在您的示例中, int(input(...))在任何情况下都可以做到这一点, python-future 's incoreins.input 值得考虑,因为这确保您的代码可适用于Python 2和3 and 禁用 input 的Python2的默认行为,试图对输入数据类型“聪明”( nelidens.input.input 基本上只是 raw_input /代码>)。

While in your example, int(input(...)) does the trick in any case, python-future's builtins.input is worth consideration since that makes sure your code works for both Python 2 and 3 and disables Python2's default behaviour of input trying to be "clever" about the input data type (builtins.input basically just behaves like raw_input).

如何将输入读为数字?

烙印 2025-02-18 13:37:16

我需要根据 https://nx.dev/nx-api/angular/documents/angular-nx-version-matrix 我能够使用以下以下内容升级到角度特定的主要版本迁移命令:

npx nx migrate 12.2.0 // Angular 11.2.0
npx nx migrate 13.1.4 // Angular 12.8.18
npx nx migrate 14.1.9 // Angular 13.3.12
npx nx migrate 14.6.0 // Angular 14.2.12
npx nx migrate 15.9.7 // Angular 15.2.10

I needed to update to Angular version 15 instead of the latest (v17 at the time of writing), based on https://nx.dev/nx-api/angular/documents/angular-nx-version-matrix I was able to upgrade to the Angular specific major version using the following migration commands:

npx nx migrate 12.2.0 // Angular 11.2.0
npx nx migrate 13.1.4 // Angular 12.8.18
npx nx migrate 14.1.9 // Angular 13.3.12
npx nx migrate 14.6.0 // Angular 14.2.12
npx nx migrate 15.9.7 // Angular 15.2.10

将NX角项目更新为特定的Angular

烙印 2025-02-18 12:55:24

这是调试时最小化代码的重要性的一个很好的例子。在此处考虑代码:

def start_game(screen, snake):
    game_on = True
    while game_on: # infinite loop
        screen.update()
        time.sleep(0.1)
        snake.move()

def control_snake(screen, snake):
    # add key listeners, the failing behavior

def main():
    # ...
    start_game(screen, snake)
    control_snake(screen, snake)

main 调用 start_game ,但是 start_game 在其中循环中具有无限 game_on 永远不会设置为 false ,因此 control_snake 永远不会达到。

尝试在之前添加关键的侦听器您进入无限渲染循环,而不是之后。

移动 control_snake start_game 引入了一个新问题,即 screen.exitonclick() control> control> control_snake 的一部分。 ,但是如果 control_snake start_game 之前调用,则 screet.exitonclick() blocks and blocks并预防 start_game 从运行中。因此,我们需要删除 screen.exitonClick()

但是,触发重复事件的方法比更好,而/ sleep screen.exitonclick()呼叫上阻止。 这篇文章显示了一个示例。


退后一步,这里还有一些其他提示,这些技巧解决了错误的误解和根本原因。

start_game 调用 setup_screen 有点奇怪。我会从 main 中调用 setup_screen 将其解除。我可以想象一个情况下,我们想设置一次屏幕,但是在蛇死后多次重新启动游戏。

通常,在您拥有基本代码工作之前,我不必担心将事情分解为功能。不要仅仅因为您听说过功能超过5或6行很差而写抽象。这些函数应该具有明确的奇异目的,并避免奇怪的依赖性。

例如, control_snake 应真正称为 add_snake_controls_then_block_until_exit 或类似的东西,因为它不仅添加了蛇控件(它并不是真正“控制蛇”注册执行此操作的控件,还可以阻止整个脚本并运行Turtle的内部更新循环,直到用户单击窗口。这听起来可能是ped的,但是如果您将此功能命名为准确说明其所做的事情,那么该错误将更加明显,并且通常会带来更清晰的代码的辅助益处。

您的游戏循环代码:

while game_on:
    screen.update()
    time.sleep(0.1)
    snake.move()

遵循有点混乱。通常的渲染顺序是:

  1. 更新位置
  2. rerender
  3. 睡眠/递送控制,直到下一个更新周期,

我建议更清楚的

while game_on:
    snake.move()    # update positions
    screen.update() # render the frame
    time.sleep(0.1) # defer/pause until the next tick

另一个提示/经验法则是在小块中工作,经常运行代码。看来您编写了大量代码,然后第一次运行它,不确定在哪里开始调试。如果我正在写蛇游戏,则我不必担心尾巴逻辑,直到我设置头并确定它有效。

如果您尽了最大的努力,请使用很多代码和错误,请系统地添加打印件,以查看达到控制权的位置。如果您在 control_snake 中添加了打印,您会发现它永远不会被调用,这几乎会散发出问题(因此是其解决方案)。

另一个调试策略是删除代码,直到问题消失,然后将最后一块返回,以确切查看问题是什么。

话虽如此,您的类似乎有目的且写得很好。

这是我的重写建议:

import turtle


class Snake:
    def __init__(self, grid_size, initial_x_positions):
        self.grid_size = grid_size
        self.create_snake(initial_x_positions)

    def create_snake(self, initial_x_positions):
        self.segments = []

        for x in initial_x_positions:
            segment = turtle.Turtle("square")
            segment.color("RoyalBlue")
            segment.penup()
            segment.goto(x, 0)
            self.segments.append(segment)

        self.head = self.segments[0]

    def move(self):
        for i in range(len(self.segments) - 1, 0, -1):
            x_pos = self.segments[i - 1].xcor()
            y_pos = self.segments[i - 1].ycor()
            self.segments[i].goto(x_pos, y_pos)

        self.head.forward(self.grid_size)

    def up(self):
        self.head.setheading(90)

    def down(self):
        self.head.setheading(270)

    def left(self):
        self.head.setheading(180)

    def right(self):
        self.head.setheading(0)


def create_screen():
    screen = turtle.Screen()
    screen.tracer(0)
    screen.bgcolor("black")
    screen.title("Snake Game")
    screen.setup(width=600, height=600)
    screen.listen()
    return screen


def main():
    initial_x_positions = 0, -20, -40
    frame_delay_ms = 80
    grid_size = 20

    screen = create_screen()
    snake = Snake(grid_size, initial_x_positions)
    screen.onkey(key="Up", fun=snake.up)
    screen.onkey(key="Down", fun=snake.down)
    screen.onkey(key="Left", fun=snake.left)
    screen.onkey(key="Right", fun=snake.right)

    def tick():
        snake.move()
        screen.update()
        turtle.ontimer(tick, frame_delay_ms)

    tick()
    screen.exitonclick()


if __name__ == "__main__":
    main()

由于没有重新启动条件或随附的逻辑,因此可能需要重新分配以允许“游戏上的游戏”屏幕并重置蛇或类似的东西,但至少没有稳固的必须提出推论的过早抽象。

This is a good example of the importance of minimizing the code when you debug. Consider the code here:

def start_game(screen, snake):
    game_on = True
    while game_on: # infinite loop
        screen.update()
        time.sleep(0.1)
        snake.move()

def control_snake(screen, snake):
    # add key listeners, the failing behavior

def main():
    # ...
    start_game(screen, snake)
    control_snake(screen, snake)

main calls start_game, but start_game has an infinite while loop in it. game_on is never set to False, and so control_snake will never be reached.

Try adding key listeners before you go into your infinite rendering loop, not after.

Moving control_snake ahead of start_game introduces a new problem, which is that screen.exitonclick() is part of control_snake, but if control_snake is called before start_game, then the screen.exitonclick() blocks and prevents start_game from running. So we need to remove screen.exitonclick().

But there's a better way to trigger repeated events than while/sleep, which is screen.ontimer. This lets you defer control back to your main loop and block on a screen.exitonclick() call. This post shows an example.


Taking a step back, here are a few other tips that address underlying misconceptions and root causes of your bugs.

It's a bit odd that setup_screen is called from start_game. I'd call setup_screen from main to decouple these. I can imagine a case where we want to set up the screen once, but restart the game multiple times, for example, after the snake dies.

In general, I'd worry less about breaking things out into functions until you have the basic code working. Don't write abstractions just because you've heard that functions longer than 5 or 6 lines are bad. The functions should have a clear, singular purpose foremost and avoid odd dependencies.

For example, control_snake should really be called add_snake_controls_then_block_until_exit or something like that, because not only does it add snake controls (it doesn't really "control the snake" exactly, it registers the controls that do so), it also blocks the whole script and runs turtle's internal update loop until the user clicks the window. This might sound pedantic, but if you'd named this function to state exactly what it does, the bug would be much more obvious, with the side benefit of clearer code in general.

Your game loop code:

while game_on:
    screen.update()
    time.sleep(0.1)
    snake.move()

is a bit confusing to follow. The usual rendering sequence is:

  1. update positions
  2. rerender
  3. sleep/defer control until the next update cycle

I suggest the clearer

while game_on:
    snake.move()    # update positions
    screen.update() # render the frame
    time.sleep(0.1) # defer/pause until the next tick

Another tip/rule of thumb is to work in small chunks, running your code often. It looks like you wrote a huge amount of code, then ran it for the first time and weren't sure where to begin debugging. If I were writing a snake game, I wouldn't worry about the tail logic until I've set up the head and established that it works, for example.

If you do wind up with a lot of code and a bug in spite of your best efforts, systematically add prints to see where control is reached. If you added a print in control_snake, you'd see it never gets called, which pretty much gives away the problem (and therefore its solution).

Another debugging strategy is to remove code until the problem goes away, then bring back the last chunk to see exactly what the problem was.

All that said, your Snake class seems purposeful and well-written.

Here's my rewrite suggestion:

import turtle


class Snake:
    def __init__(self, grid_size, initial_x_positions):
        self.grid_size = grid_size
        self.create_snake(initial_x_positions)

    def create_snake(self, initial_x_positions):
        self.segments = []

        for x in initial_x_positions:
            segment = turtle.Turtle("square")
            segment.color("RoyalBlue")
            segment.penup()
            segment.goto(x, 0)
            self.segments.append(segment)

        self.head = self.segments[0]

    def move(self):
        for i in range(len(self.segments) - 1, 0, -1):
            x_pos = self.segments[i - 1].xcor()
            y_pos = self.segments[i - 1].ycor()
            self.segments[i].goto(x_pos, y_pos)

        self.head.forward(self.grid_size)

    def up(self):
        self.head.setheading(90)

    def down(self):
        self.head.setheading(270)

    def left(self):
        self.head.setheading(180)

    def right(self):
        self.head.setheading(0)


def create_screen():
    screen = turtle.Screen()
    screen.tracer(0)
    screen.bgcolor("black")
    screen.title("Snake Game")
    screen.setup(width=600, height=600)
    screen.listen()
    return screen


def main():
    initial_x_positions = 0, -20, -40
    frame_delay_ms = 80
    grid_size = 20

    screen = create_screen()
    snake = Snake(grid_size, initial_x_positions)
    screen.onkey(key="Up", fun=snake.up)
    screen.onkey(key="Down", fun=snake.down)
    screen.onkey(key="Left", fun=snake.left)
    screen.onkey(key="Right", fun=snake.right)

    def tick():
        snake.move()
        screen.update()
        turtle.ontimer(tick, frame_delay_ms)

    tick()
    screen.exitonclick()


if __name__ == "__main__":
    main()

Since there's no restarting condition or accompanying logic, this will probably need to be refactored to allow for a "game over" screen and resetting the snake or something like that, but at least it's solid and there aren't a lot of premature abstractions to have to reason about.

Python Turtle模块没有回应要发出的击键

烙印 2025-02-18 12:00:00

VBA这是一个大锤,可以破裂螺母。

很容易用枢轴表完成。
要获得具有多个单元的行以具有每个单元的单独记录:
在m1中put use_unit
在m2 = h2 中,然后拖动。
然后在当前数据以下的区域(例如,从第1002行开始):
在A1002 = a2 中,并在m1002 put = if(i2 =“”,“ ignore”,i2),i2)(或i1002)中进行拖动。
同样,对于第三和第四个块,分别看起来是AD J和K。
然后执行枢轴表,然后过滤unit_use =忽略

VBA here is a sledgehammer to crack a nut.

It is easily done with a Pivot Table.
To get the rows with multiple units to have separate records for each unit:
in M1 put Use_Unit.
In M2 =H2 and drag down.
Then in a area below the current data (say starting at row 1002):
In A1002 =A2 and drag across and down, except that in M1002 put =if(I2="","Ignore", I2) (or I1002).
Similarly for third and fourth blocks, looking ad J and K respectively.
Then do the Pivot Table, and filter out Unit_Use = Ignore

具有多个值的转置列成一个列,并匹配类别

烙印 2025-02-18 11:20:19

唯一类似于您要做的事情的唯一一件事是 data

activity("tickets") {
    this.activityClass = ExternalActivity::class
    this.data = "Hello World".toUri()    <--
}

[ExternalActivity]
override fun onCreate(savedInstanceState: Bundle?) {
    ...
    val data = intent.data

但是 data uri ,因此它可能不适合您的需求,尤其是在与外部库打交道时。然后 context.startactivity()将是下一个选择,如您的第二种方法。

要注意的一件事是,当您使用 context.startactivity()(而不是 navgraphbuilder.activity())时,您需要正确设置“当前”目标时活动关闭(例如呼叫 navcontroller.navigateup() navcontroller.popbackstack())。如果不是这样,它将跳回您刚刚关闭的活动,因为就NavController而言,您启动的活动(现在关闭)是当前的目的地。

The only thing that remotely resembles what you are trying to do would be data.

activity("tickets") {
    this.activityClass = ExternalActivity::class
    this.data = "Hello World".toUri()    <--
}

[ExternalActivity]
override fun onCreate(savedInstanceState: Bundle?) {
    ...
    val data = intent.data

But data is Uri, so it might not suit your needs, especially if you are dealing with an external library. Then context.startActivity() would be the next choice, as in your second approach.

One thing to note is that when you use context.startActivity() (instead of NavGraphBuilder.activity()), you need to set the "current" destination correctly when the Activity closes (e.g. call navController.navigateUp() or navController.popBackStack()). If not, it will jump back to the Activity you just closed, because as far as NavController is concerned, the Activity you started (and now closed) is the current destination.

使用组合导航开始活动

烙印 2025-02-18 03:36:29

也许您可以使用类似的东西:

docker save -o backup.tar $(docker images --format "{{.Repository}}:{{.Tag}}")

另外:

 docker save $(docker images --format "{{.Repository}}:{{.Tag}}") > backup.tar

这将用名称和标签标记您的图像。

一旦您执行

docker load -i backup.tar

并执行:

docker images -a

您将能够根据名称使用图像:TAG

Maybe you can use something like this:

docker save -o backup.tar $(docker images --format "{{.Repository}}:{{.Tag}}")

Alternatively:

 docker save $(docker images --format "{{.Repository}}:{{.Tag}}") > backup.tar

This will tag your images with the name and tags.

Once you do

docker load -i backup.tar

and perform:

docker images -a

you will be able to use the images based on the name:tag

将Docker容器移至新服务器

烙印 2025-02-17 23:11:07

这似乎是一个解决方案和图像质量问题。即使是人类看本文也很难识别这是0还是8。形成识别器返回0的信心是什么

This seems like a resolution and image quality issue. It is hard even for a human looking at this text to identify if this is a 0 or an 8. What is the confidence that Form Recognizer returns for the 0

Azure形式识别器 - 如果DOT矩阵打印机&#x27; 0&#x27; (零)被认为为&#x27; 8&#x27;

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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