柠栀

文章 评论 浏览 30

柠栀 2025-01-31 21:20:03

尝试了上面的所有内容,但是唯一有效的方法是使用 python -m pip install tensorflow gpu == 2.9.1 将TensorFlow降级到2.9.1。我之所以选择此版本,是因为在 pypi 页面之后没有任何版本。而(4个月!),所以我认为此版本稳定并且奏效!我在Mamba环境上使用Tensorflow 2.10.0遇到了这个错误。

Tried everything above but the only thing that worked is downgrading Tensorflow to 2.9.1 using python -m pip install tensorflow-gpu==2.9.1. I selected this version because on the PyPi page there wasn't any version after this for a while (4 months!) so I assumed that this version is stable and it worked! I was getting this error with Tensorflow 2.10.0 on a mamba environment.

TypeError:无法将函数返回值转换为Python类型!签名是() - >处理

柠栀 2025-01-31 10:04:01
file.list %>%
  set_names(.) %>%
  map_df(~mutate_all(read_excel(.x), as.character), .id = 'grp') %>%
  mutate(grp = str_remove(basename(grp), ".xlsx")) %>%
  separate(grp, c('col1', 'col2'), sep = '_', extra = 'merge')
file.list %>%
  set_names(.) %>%
  map_df(~mutate_all(read_excel(.x), as.character), .id = 'grp') %>%
  mutate(grp = str_remove(basename(grp), ".xlsx")) %>%
  separate(grp, c('col1', 'col2'), sep = '_', extra = 'merge')

提取部分文件名并将其添加为列中的值

柠栀 2025-01-31 04:32:28

我知道答案!
在ON_MESSAGE方法中

await self.client.process_commands(message)

,因此,该机器人每次发送2条消息!

I know the answer!
In the on_message method there was the

await self.client.process_commands(message)

because of this, the bot sent 2 messages every time!

discord.py齿轮冷却?

柠栀 2025-01-31 04:13:44

您只应该修复一些错字。

var Canvas = document.getElementById('ViewPort');
var Context = Canvas.getContext("2d");

Canvas.width = 250;
Canvas.height = 250;
Canvas.style.border = "1px solid black";

var Objects = [];

//Testing

Objects.push({

  x: 50,
  y: 50,
  width: 50,
  height: 50,
  style: "black",

})

Objects.push({

  x: 55,
  y: 55,
  width: 50,
  height: 50,
  style: "blue",

})

//End Testing

function RenderObjects() {

  for (var i = 0; i < Objects.length; i++) {

    for (var j = 0; j < Objects.length; j++) {

      if (Hitting(Objects[i], Objects[j])) { //instead of Object[i], Object[j]

        console.log("Hitting object " + j);
        console.log(Objects[j]) //instead of Object[j]

      } else {

        Context.fillStyle = Objects[i].fillstyle;
        Context.fillRect(Objects[i].x, Objects[i].y, Objects[i].width, Objects[i].height);

      }

    }


  }

}

function Hitting(rectA, rectB) {

  return !(rectA.x + rectA.width < rectB.x ||
    rectB.x + rectB.width < rectA.x ||
    rectA.y + rectA.height < rectB.y ||
    rectB.y + rectB.height < rectA.y);

}

RenderObjects();
<canvas id = "ViewPort"></canvas>

You only should fix some typo.

var Canvas = document.getElementById('ViewPort');
var Context = Canvas.getContext("2d");

Canvas.width = 250;
Canvas.height = 250;
Canvas.style.border = "1px solid black";

var Objects = [];

//Testing

Objects.push({

  x: 50,
  y: 50,
  width: 50,
  height: 50,
  style: "black",

})

Objects.push({

  x: 55,
  y: 55,
  width: 50,
  height: 50,
  style: "blue",

})

//End Testing

function RenderObjects() {

  for (var i = 0; i < Objects.length; i++) {

    for (var j = 0; j < Objects.length; j++) {

      if (Hitting(Objects[i], Objects[j])) { //instead of Object[i], Object[j]

        console.log("Hitting object " + j);
        console.log(Objects[j]) //instead of Object[j]

      } else {

        Context.fillStyle = Objects[i].fillstyle;
        Context.fillRect(Objects[i].x, Objects[i].y, Objects[i].width, Objects[i].height);

      }

    }


  }

}

function Hitting(rectA, rectB) {

  return !(rectA.x + rectA.width < rectB.x ||
    rectB.x + rectB.width < rectA.x ||
    rectA.y + rectA.height < rectB.y ||
    rectB.y + rectB.height < rectA.y);

}

RenderObjects();
<canvas id = "ViewPort"></canvas>

当定义时,为什么它会不断地丢弃读数不确定的可变错误?

柠栀 2025-01-30 21:54:00

这种NPE可能是由JPA实体模型定义中的某些内容引起的,Hibernate无法处理。在您的JPA实体定义中,这可能是一个错误的配置(但当然也可能是其他内容)。

您可以进行更深入研究的一种修改是启用调试或什至跟踪冬眠类别的记录。这可能会给您一些好的提示。

另外,您的JPA实体模型是否非常复杂?你可以在这里发布吗?

This NPE could be caused by something in your JPA entity model definition that Hibernate is not able to deal with. Probably this could be a misconfiguration in your JPA entities definition (but of course could be other stuff also).

One modification you could do in order to investigate deeper is to enable debug or even trace logging for the hibernate classes. This would probably give some good hint on where to look at.

Additionally, is your JPA entity model very complex? Can you post it here?

错误创建使用名称&#x27; entityManagerFactory的错误 - 嵌套异常是java.lang.nullpointerexception

柠栀 2025-01-30 21:45:00

您可以以这种方式实现这一目标:首先,您需要按 region 字段对数据进行分组并获取最大值。然后在条件中执行一个简单的 count

select * from my_table WHERE (region, count) in (select region, MAX(count) from my_table  GROUP BY region)

demo in sqldaddy.io

You can achieve this in this way: First you need to group the data by the region field and get the maximum value. Then execute a simple IN condition with fields region and count

select * from my_table WHERE (region, count) in (select region, MAX(count) from my_table  GROUP BY region)

Demo in sqldaddy.io

选择具有最大值的行,与其他两个列相关

柠栀 2025-01-30 20:05:13

使用静态 对称 randommatrices_ddrm

DMatrixRMaj d2 = RandomMatrices_DDRM.symmetric(20,-2,3,rand);

类似地 simplematrix

Use the static symmetric method in RandomMatrices_DDRM

DMatrixRMaj d2 = RandomMatrices_DDRM.symmetric(20,-2,3,rand);

and similarly for SimpleMatrix

线程中的EMJL例外“ Main” java.lang.runtimeException:不兼容的代码 - 找不到符号

柠栀 2025-01-30 08:11:09

您可以 tokenize() 可选空间的属性值 \ s 带有此Regex \ s?#,然后用谓词过滤出一个空项目使用 normalize-space()或测试字符串长度字符串长度(。)gt 0

let $ref :=  <ref target="#a1 #b2 #c3"/>
let $targets := tokenize($ref/@target, '\s?#')[normalize-space()]
return  
  $targets

或者您可以通过Space \ S 或空间和# \ s#,然后 translate() 剩下的任何 nothens:

let $ref :=  <ref target="#a1 #b2 #c3"/>
let $targets := tokenize($ref/@target, '\s#') ! translate(., '#', '')
return  
  $targets

读取空间分离 ref/@target 属性值作为序列的另一种方法是将它们读为 xs:nmtokens (它们是空间分离值),然后您只需要担心从每个值中删除

let $ref :=  <ref target="#a1 #b2 #c3"/>
let $target-tokens as xs:NMTOKENS := $ref/@target
let $targets :=  $target-tokens ! translate(., '#', '')
return
  $targets 

You could tokenize() the attribute value by an optional space \s and # with this regex \s?# and then filter out an empty item with a predicate using normalize-space() or testing the string length string-length(.) gt 0:

let $ref :=  <ref target="#a1 #b2 #c3"/>
let $targets := tokenize($ref/@target, '\s?#')[normalize-space()]
return  
  $targets

or you could tokenize by space \s or space and # \s#, then translate() any remaining # into nothing:

let $ref :=  <ref target="#a1 #b2 #c3"/>
let $targets := tokenize($ref/@target, '\s#') ! translate(., '#', '')
return  
  $targets

Another way to read the space separated ref/@target attribute values as a sequence is to read them as xs:NMTOKENS (which are space separated values), and then you just need to worry about removing the # from each value:

let $ref :=  <ref target="#a1 #b2 #c3"/>
let $target-tokens as xs:NMTOKENS := $ref/@target
let $targets :=  $target-tokens ! translate(., '#', '')
return
  $targets 

XQuery在定界符之间获取字符串

柠栀 2025-01-29 21:10:49

You should configure error-handling like in https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html to define a dead letter queue, because to day, if your documents have a 6 hours for maximum age, they will simply be lost.

lambda节流事件信息

柠栀 2025-01-29 20:18:09

字符串#localecompare 获取三个参数

参数名称 预期值
比较 比较 cofeenceStr 的字符串。
Locales 选项 这些参数自定义函数的行为,并让应用程序指定应使用其格式约定的语言。在忽略 erentes 选项参数的实现中,所使用的语言环境和返回的字符串形式完全取决于实现。

参见

当您传递 locales 参数的值时,它将传递给 intl.collat​​or 构建器,该构建器文档可在此处获得。构建 intl.collat​​or 所采取的步骤包括:

  1. 返回? initializecollat​​or ,<代码>选项)。

inditizecollat​​or 的文档包括步骤:

  1. requestedLocales 为? canononicalizelecalelist locales locales )。

那么,这是实际答案。 canonicalizealizelecalelist 的文档包括用于处理值的步骤传递到 Locales 一直以字符串#localecompare

  1. 如果 locales undefined ,然后

    。返回新的空 list

  2. [...]
  3. 如果 type Locales )是字符串类型 Locales )是对象 locales 具有 [[InitializedLocale]] 内部插槽,然后
    a。令 o 为! creat arearrayFromlist (« LOCALES »)。
  4. 否则
    a。令 o 为? <
  5. [...]
  6. [...]
  7. [...]
  8. [...]

toObject(参数)的文档

参数类型 结果
undefined 投掷 typeerror 异常。
null 投掷 typeerror 异常。
布尔 返回一个新的布尔对象,其[[booleandata]]内部插槽设置为参数。有关布尔对象的描述,请参见20.3。
编号 返回一个新的数字对象,其[[numberData]]内部插槽设置为参数。有关数字对象的描述,请参见21.1。
字符串 返回一个新的字符串对象,其[[StringData]]内部插槽设置为参数。有关字符串对象的描述,请参见22.1。
符号 返回一个新的符号对象,其[[Symboldata]]内部插槽设置为参数。有关符号对象的描述,请参见20.4。
bigint 返回一个新的bigint对象,其[[bigintdata]]内部插槽设置为 grognm 。有关Bigint对象的描述,请参见21.2。
对象 返回参数

总而言之,如果您通过:

未定义

localecompare 将传递给 intl.collat​​or()。构造函数将传递到 initizecoldizecollat​​or 传递到 Canonicalizelecalelist 具有明确的步骤,该步骤返回新的空 list

null

localecompare 传递给 intl.collat​​or()。构造函数,它传递到 initizecollat​​or ,该将传递给 canononicalializeizelocalelistist 呼叫 toObject typeerror 如果传递 null ,则会抛出。


您在注释中询问了其他两个情况:

{} (空对象)

localecompare 将传递给 intl.collat​​or()。 initializecollat​​or 传递给 canonicalizelecalelist ,它调用 toObject ,它返回传递的对象。

请注意,如果对象具有 [[[InitializedLocale]] 内部插槽,则 canonicalizelecalelist 将处理该对象。

''(空字符串)

localecompare 传递到 intl.collat​​or()。构造函数,它传递给 initializecollat​​or 传递到 canonicalizelecalelist 调用 toObject 返回新的字符串对象的零长度为零,因此 canononicalizeizelecalelist 的其余部分都有没有效果,返回了空的列表

我承认,我不知道为什么空弦盒不起作用。规格中可能会更深入地处理这种情况。

String#localeCompare takes three parameters:

Parameter name Expected value
compareString The string against which the referenceStr is compared.
locales and options These arguments customize the behavior of the function and let applications specify the language whose formatting conventions should be used. In implementations which ignore the locales and options arguments, the locale used and the form of the string returned are entirely implementation-dependent.

See the Intl.Collator() constructor for details on these parameters and how to use them.

When you pass a value for the locales parameter, it's passed to the Intl.Collator constructor listed above whose documentation is available here. The steps taken to construct an Intl.Collator include:

  1. Return ? InitializeCollator(collator, locales, options).

The documentation for InitializeCollator includes the step:

  1. Let requestedLocales be ? CanonicalizeLocaleList(locales).

Here's the actual answer, then. The documentation for CanonicalizeLocaleList includes the steps for handling the value you passed to locales all the way back in String#localeCompare:

  1. If locales is undefined, then
    a. Return a new empty List.
  2. [...]
  3. If Type(locales) is String or Type(locales) is Object and locales has an [[InitializedLocale]] internal slot, then
    a. Let O be ! CreateArrayFromListlocales »).
  4. Else
    a. Let O be ? ToObject(locales).
  5. [...]
  6. [...]
  7. [...]
  8. [...]

Looking at the documentation for ToObject(argument):

Argument Type Result
Undefined Throw a TypeError exception.
Null Throw a TypeError exception.
Boolean Return a new Boolean object whose [[BooleanData]] internal slot is set to argument. See 20.3 for a description of Boolean objects.
Number Return a new Number object whose [[NumberData]] internal slot is set to argument. See 21.1 for a description of Number objects.
String Return a new String object whose [[StringData]] internal slot is set to argument. See 22.1 for a description of String objects.
Symbol Return a new Symbol object whose [[SymbolData]] internal slot is set to argument. See 20.4 for a description of Symbol objects.
BigInt Return a new BigInt object whose [[BigIntData]] internal slot is set to argument. See 21.2 for a description of BigInt objects.
Object Return argument.

To summarize, if you pass:

undefined

localeCompare passes to Intl.Collator().constructor which passes to InitializeCollator which passes to CanonicalizeLocaleList which has an explicit step that returns a new empty List.

null

localeCompare passes to Intl.Collator().constructor which passes to InitializeCollator which passes to CanonicalizeLocaleList which calls ToObject which throws a TypeError if it's passed null.


You asked about two other cases in the comments:

{} (empty object)

localeCompare passes to Intl.Collator().constructor which passes to InitializeCollator which passes to CanonicalizeLocaleList which calls ToObject which returns the object it is passed.

Note that CanonicalizeLocaleList would have handled the object if it had an [[InitializedLocale]] internal slot.

'' (empty string)

localeCompare passes to Intl.Collator().constructor which passes to InitializeCollator which passes to CanonicalizeLocaleList which calls ToObject which returns a new String object which a length of zero so the rest of CanonicalizeLocaleList has no effect and an empty List is returned.

I'll admit, I don't know why the empty string case doesn't work. There's probably something deeper in the spec that handles that case.

JavaScript字符串方法LocaleCompare()接受&#x27; undefined&#x27;并拒绝&#x27; null&#x27;作为a aCale&#x27;参数

柠栀 2025-01-29 05:39:18

主要问题是 comb_array 具有的形状(R,3)其中 r = n ** 3 find_pairs 至少在二次时间内运行,因为 idx.remove 以线性时间运行,并在for循环中调用。此外,在某些情况下,for循环不会更改 idx 的大小,并且循环似乎永远运行(例如,使用 n = 4 )。

o(r log r)中解决此问题的一种解决方案是对数组进行排序,然后在线性时间内检查相反的值:

import numpy as np
import numba as nb

# Give array of 3D vectors
krange = np.fft.fftfreq(N)
comb_array = np.array(np.meshgrid(krange, krange, krange)).T.reshape(-1, 3)

# Sorting
packed = comb_array.view([('x', 'f8'), ('y', 'f8'), ('z', 'f8')])
idx = np.argsort(packed, axis=0).ravel()
sorted_comb = comb_array[idx]

# Find pairs
@nb.njit
def findPairs(sorted_comb, idx):
    n = idx.size
    boolean = np.zeros(n, dtype=np.bool_)
    pairs = []
    cur = n-1
    for i in range(n):
        while cur >= i:
            if np.all(sorted_comb[i] == -sorted_comb[cur]):
                boolean[idx[i]] = True
                pairs.append([idx[i], idx[cur]])
                cur -= 1
                break
            cur -= 1
    return boolean, pairs

findPairs(sorted_comb, idx)

请注意,该算法假定对于每一行,一个有效的匹配对。如果有几个相等的行,则将它们配对2乘两个。如果您的目标是在这种情况下提取相等行的所有组合,请注意,输出将成倍增长(这不是合理的IMHO)。

即使对于 n = 100 ,此解决方案也非常快。大多数时间都花在不太有效的情况下(不幸的是,Numpy并没有提供一种有效地进行行的词典Argsort的方法,尽管此操作从根本上讲是昂贵的)。

The main problem is that comb_array has a shape of (R, 3) where R = N**3 and the nested loop in find_pairs runs at least in quadratic time since idx.remove runs in linear time and is called in the for loop. Moreover, there are cases where the for loop does not change the size of idx and the loop appear to run forever (eg. with N=4).

One solution to solve this problem in O(R log R) is to sort the array and then check for opposite values in linear time:

import numpy as np
import numba as nb

# Give array of 3D vectors
krange = np.fft.fftfreq(N)
comb_array = np.array(np.meshgrid(krange, krange, krange)).T.reshape(-1, 3)

# Sorting
packed = comb_array.view([('x', 'f8'), ('y', 'f8'), ('z', 'f8')])
idx = np.argsort(packed, axis=0).ravel()
sorted_comb = comb_array[idx]

# Find pairs
@nb.njit
def findPairs(sorted_comb, idx):
    n = idx.size
    boolean = np.zeros(n, dtype=np.bool_)
    pairs = []
    cur = n-1
    for i in range(n):
        while cur >= i:
            if np.all(sorted_comb[i] == -sorted_comb[cur]):
                boolean[idx[i]] = True
                pairs.append([idx[i], idx[cur]])
                cur -= 1
                break
            cur -= 1
    return boolean, pairs

findPairs(sorted_comb, idx)

Note that the algorithm assume that for each row, there are only up to one valid matching pair. If there are several equal rows, they are paired 2 by two. If your goal is to extract all the combination of equal rows in this case, then please note that the output will grow exponentially (which is not reasonable IMHO).

This solution is pretty fast even for N = 100. Most of the time is spent in the sort that is not very efficient (unfortunately Numpy does not provide a way to do a lexicographic argsort of the row efficiently yet though this operation is fundamentally expensive).

查找一对数组,例如array_1 = -array_2

柠栀 2025-01-29 02:59:10

我认为您遇到的问题是新网页不是真实的页面。这是PDF,您无法从PDF文件获得页面标题。

I think the problem you have is the new webpage is not a real page. It's a pdf, you can't get a page title from a pdf file.

我正在尝试打开一个新的URL页面并获取新页面的标题

柠栀 2025-01-29 02:10:52

您可以定义 pure :: a - &gt; f a lift ::(a - &gt; b)的方面 - &gt; f(a - &gt; b)&lt;*&gt;

pure x = lift (const x) <*> lift (const ())

因此,无论哪种方式,它都是等效的,通常更简单地编写 pure

(这是Iceland_jack的设计原因的出色总结,这是应该这样的。)

You can define pure :: a -> f a in terms of lift :: (a -> b) -> f (a -> b) and <*>:

pure x = lift (const x) <*> lift (const ())

So it's equivalent either way, and usually simpler to write pure.

(This is in addition to Iceland_jack's excellent summary of the design reasons it should be this way.)

为什么纯的类型是 - &gt; fa,而不是(a - &gt; b) - &gt; F(a - &gt; b)应用?

柠栀 2025-01-28 15:06:18

我的看法:
我不确定您想要的“振荡”是什么样的,因为目前看起来像一个。但是,以下是我处理它的方法:

通过使用NP.Convolve在数据点上迭代,您可以创建一个函数以使其平滑。曲线拟合,数据平滑,n度多项式甚至Lowess(最佳方法)都可以在该功能中使用。这是一个很棒的我发现您可以研究以创建您的功能。

对于这种情况,我已经完成了以下方式:

def smooth(y, data_points):
    plot_point = np.ones(data_points)/data_points
    y_smooth_points = np.convolve(y, plot_point, mode='same')
    return y_smooth_points

您可以调整参数以定义图表上的点。之后,我将数据点添加到了一个新列中并绘制了它们:

这是其中一种方法的完整代码:

import pandas as pd
import numpy as np
import plotly.express as px
import plotly.graph_objects as go


def smooth(y, data_points):
    plot_point = np.ones(data_points)/data_points
    y_smooth = np.convolve(y, plot_point, mode='same')
    return y_smooth

df['smoothen_1']= smooth(df['long'],100)

fig = px.line(df, x='date', y=smooth(df['smoothen_1'],250))
fig.show()

结果:

”

My take:
I'm not sure what you want the 'oscillation' to look like, because it currently looks like one. However, here's how I handle it:

By iterating over the data points with np.convolve, you can create a function to smooth them. Curve fitting, data smoothing, n-degree polynomials, and even Lowess(the best approach) might all be used in the function. Here's a great article I found that you can research in order to create your function.

For this case I have done the following way:

def smooth(y, data_points):
    plot_point = np.ones(data_points)/data_points
    y_smooth_points = np.convolve(y, plot_point, mode='same')
    return y_smooth_points

You could adjust the parameters to define the points on the graph. Following that, I added the data points to a new column and plotted them:

Here's the complete code for one of the approaches:

import pandas as pd
import numpy as np
import plotly.express as px
import plotly.graph_objects as go


def smooth(y, data_points):
    plot_point = np.ones(data_points)/data_points
    y_smooth = np.convolve(y, plot_point, mode='same')
    return y_smooth

df['smoothen_1']= smooth(df['long'],100)

fig = px.line(df, x='date', y=smooth(df['smoothen_1'],250))
fig.show()

Result:

Result Image from Plotly Plot

Readjusting interactive plot

如何绘制时间序列相对于零?

柠栀 2025-01-28 08:29:19

我看到您有 pandarellel 标签,要在此处使用它,您将代码更改为:

from pandarallel import pandarallel
pandarallel.initialize()

values_list = []
indices_list = []

offset_by_w = pd.tseries.frequencies.to_offset(135)

_ = signal[::-1].rolling(offset_by_w, min_periods=4, closed='both').\
    parallel_apply(lambda x: [0, indices_list.append((x.index[-1], x.index[0])), values_list.append(x[::-1])][0], raw=True)

I see you have the pandarellel tag, to use it here you'd change your code to:

from pandarallel import pandarallel
pandarallel.initialize()

values_list = []
indices_list = []

offset_by_w = pd.tseries.frequencies.to_offset(135)

_ = signal[::-1].rolling(offset_by_w, min_periods=4, closed='both').\
    parallel_apply(lambda x: [0, indices_list.append((x.index[-1], x.index[0])), values_list.append(x[::-1])][0], raw=True)

如何将numba与pandas.rolling.apply使用

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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