我正在使用 ChatGPT,它说将这行代码用于 API 端点:
$endpoint = 'https://api.openai.com/v1/engines/text-davinci-003/completions';
Run Code Online (Sandbox Code Playgroud)
但这不起作用。我收到以下错误:
{ "error": { "message": "The model `text-davinci-003` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations", "type": "invalid_request_error", "param": null, "code": "model_not_found" } }
Run Code Online (Sandbox Code Playgroud)
我真的找不到任何东西可以解决它。
我尝试更改 URL 本身中的模型,但没有成功。
上下文:我有一个队列,支持来自两个不同(/或非)线程的单读/单写,为了强制执行此行为,即一次单读/单写,我需要限制拥有的线程数量队列一次为2(作者已经拥有该队列),我当时正在考虑为队列创建一个shared_ptr,并将编译时已知的最大引用计数设置为2。因此我的问题如下。
问题:有没有一种方法可以实现unique_pointer具有编译时已知的最大引用计数的共享指针(可能使用 's)?我的情况是max_ref_count = 2,超过引用计数限制 = 2 应该是编译时错误。
const auto p = std::make_shared<2, double>(2159); //works fine
const auto q = p; // works fine
const auto err1 = p; // does not compile
const auto err2 = q; // does not compile
Run Code Online (Sandbox Code Playgroud) 仅供参考:我在 CLion。这只是我好奇的事情,但我编写了一个程序来使用我所有的内存来娱乐。它创建了一个int* array = new int[3'900'000'000]{};.
当我在调试构建选项中运行该程序时,它确实使用了我的所有内存。但在发布模式下,它不会耗尽我的任何内存。我什至尝试修改数组中的某些值,看看这是否会强制编译器创建完整的数组。在发布模式下,我还尝试使用该方法fill并手动使用for循环来填充数组中的每个数字。
Java版本:1.8.0_202
见下面的代码:
DateTimeFormatter yy = DateTimeFormatter.ofPattern("yy");
DateTimeFormatter yyy = new DateTimeFormatterBuilder()
.appendValueReduced(ChronoField.YEAR, 3, 3, 0)
.toFormatter();
DateTimeFormatter yyyy = DateTimeFormatter.ofPattern("yyyy");
LocalDateTime now = LocalDateTime.now();
// set year is 0
LocalDateTime year0 = now.withYear(0);
System.out.println("year0: " + year0); // year0: 0000-01-10T09:53:03.551
System.out.println("year0.getYear(): \t" + year0.getYear()); // year0.getYear(): 0
System.out.println("year0.format(yyyy): " + year0.format(yyyy)); // year0.format(yyyy): 0001
System.out.println("year0.format(yyy): \t" + year0.format(yyy)); // year0.format(yyy): 000
System.out.println("year0.format(yy): \t" + year0.format(yy)); // year0.format(yy): 01
System.out.println("============================================================");
// set year is 1
LocalDateTime year1 = now.withYear(1);
System.out.println("year1: …Run Code Online (Sandbox Code Playgroud) 我正在使用 pandas 版本 1.0.5
下面的示例数据框列出了三天内记录的时间间隔,我寻找每天都有哪些时间间隔重叠的地方。
例如,所有三个日期(黄色突出显示)的重叠时间之一是 1:16 - 2:13。另一个(蓝色突出显示)为 18:45 - 19:00
所以我的预期输出是这样的:[57,15]因为
请使用输入数据帧的生成器:
import pandas as pd
dat1 = [
['2023-12-27','2023-12-27 00:00:00','2023-12-27 02:14:00'],
['2023-12-27','2023-12-27 03:16:00','2023-12-27 04:19:00'],
['2023-12-27','2023-12-27 18:11:00','2023-12-27 20:13:00'],
['2023-12-28','2023-12-28 01:16:00','2023-12-28 02:14:00'],
['2023-12-28','2023-12-28 02:16:00','2023-12-28 02:28:00'],
['2023-12-28','2023-12-28 02:30:00','2023-12-28 02:56:00'],
['2023-12-28','2023-12-28 18:45:00','2023-12-28 19:00:00'],
['2023-12-29','2023-12-29 01:16:00','2023-12-29 02:13:00'],
['2023-12-29','2023-12-29 04:16:00','2023-12-29 05:09:00'],
['2023-12-29','2023-12-29 05:11:00','2023-12-29 05:14:00'],
['2023-12-29','2023-12-29 18:00:00','2023-12-29 19:00:00']
]
df = pd.DataFrame(dat1,columns = ['date','Start_tmp','End_tmp'])
df["Start_tmp"] = pd.to_datetime(df["Start_tmp"])
df["End_tmp"] …Run Code Online (Sandbox Code Playgroud) 我有一个适用于 Windows 平台的 C++ 应用程序。此应用程序创建 MAT 文件。目前我们仅支持 MATLAB 版本 4、5 和 7.3。我们希望添加对更高版本 MATLAB 的支持。
在.h(从https://sourceforge.net/projects/matio/下载)中,在 enum 中mat_ft,仅支持三个 MATLAB 版本:4、5 和 7.3。
enum mat_ft {
MAT_FT_MAT73 = 0x0200, /**< @brief Matlab version 7.3 file */
MAT_FT_MAT5 = 0x0100, /**< @brief Matlab version 5 file */
MAT_FT_MAT4 = 0x0010, /**< @brief Matlab version 4 file */
MAT_FT_UNDEFINED = 0 /**< @brief Undefined version */
Run Code Online (Sandbox Code Playgroud)
};
要在调用时创建 MAT 文件,Mat_CreateVer我们传递上面的枚举
pMat = Mat_CreateVer(matFileName.append(".mat").toLocal8Bit().data(), NULL, MAT_FT_MAT73);
Run Code Online (Sandbox Code Playgroud)
这对于 …
以下代码可以使用 MSVC(v19.38) 编译,但使用 GCC(13.2) 和 Clang(17.0.1) 编译失败。但旧版本的 GCC,例如 11.2,可以正常工作。
#include <type_traits>
#ifdef MY_INT
template<typename T, T V> struct my_int
{
static constexpr T value = V;
using value_type = T;
constexpr operator value_type() const noexcept { return value; }
constexpr value_type operator()() const noexcept { return value; }
};
template<auto V> using constant_int_t = my_int<decltype(V), V>;
#else
template<auto V> using constant_int_t = std::integral_constant<decltype(V), V>;
#endif
template<typename T1, typename T2>
using add_t = decltype(T1{} + T2{});
template<typename T1, typename T2>
constexpr …Run Code Online (Sandbox Code Playgroud) 函数的限制限定指针参数是允许编译器优化该函数的有效方法:
int f(const int *restrict p) {
int n=*p;
printf("Debug\n");
return *p==n;
}
Run Code Online (Sandbox Code Playgroud)
这里带有 -O3 的 Clang 17 将只返回 1 ,而不重新检查*p,也不执行比较。如果没有restrict,*p则必须重新检查并进行比较。这是因为printf是一个外部函数,编译器不知道它是否会修改*p. 事实上,如果p碰巧指向 的文件位置指示器stdout,printf实际上会修改它。
因此,作为一般原则,如果您希望对函数进行最大程度的优化,并且您的函数曾经调用外部函数,那么声明所有参数并不是没有意义的restrict。当然,这对调用者施加了严格的限制,因为它要求他们承诺不会使用别名到意外位置的指针来调用您的函数。
我的问题比这个观察更进一步。我问是否也restrict允许优化您的函数的调用者?
int f(const int *restrict p);
int caller(int *p) {
int n=*p;
f(p);
return *p==n;
}
Run Code Online (Sandbox Code Playgroud)
在我看来,这保证了编译器f不会修改*p,因此它可以省略重新检查*p和比较,并且可以安全地返回 1。Clang 和 GCC 都没有进行此优化。
我知道他们不优化调用者是可以的。我问是否允许优化。(这主要是关于我的程序的语义的问题,而不是关于性能的问题。)
我正在安装 DARTS TimeSeries 库(https://github.com/unit8co/darts/blob/master/INSTALL.md#enabling-optical-dependencies),但遇到了依赖项安装问题。在 DARTS 安装指南中,它说如果我们遇到这个问题,我们必须参考 PyTorch 的官方安装指南,然后尝试再次安装 Darts。然后,当我尝试在 python 3.12.1 上安装 torch 时,我遇到了这个错误:
\n\n\n错误:找不到满足火炬要求的版本(来自版本:无)
\n错误:找不到火炬的匹配发行版。
\n
怎么解决呢?
\n我使用 PyCharm 作为 Python 代码编辑器。
\n我尝试了pip install darts,但它没有安装所有软件包并遇到此错误 error: subprocess-exited-with-error
pip subprocess to install build dependencies did not run successfully.\n \xe2\x94\x82 exit code: 1\n \xe2\x95\xb0\xe2\x94\x80> [136 lines of output]\n Collecting setuptools>=64.0\n Obtaining dependency information for setuptools>=64.0 from https://files.pythonhosted.org/packages\nRun Code Online (Sandbox Code Playgroud)\n然后,我尝试使用 pip install torch 来安装 torch 并遇到此错误\n错误:找不到满足需求 torch 的版本(来自版本:无)\n错误:找不到 torch 的匹配发行版
\n有没有一种方法或公式可以检查奇数是否是替代奇数。
解说员
1
3 alt
5
7 alt
9
11 alt
13
15 alt...
Run Code Online (Sandbox Code Playgroud)
我尝试过谷歌搜索来寻找答案,但只能找到奇数/偶数的模数或带有要检查的值的数组。
int half = (gridsize) / 2;
int row = 0;
for (int x = 0; x < gridsize; x++)
{
int tilesThisRow = gridsize - (half - row);
int drop = gridsize - tilesThisRow;
int frontDrop;
int backDrop;
if(drop % 2 != 0)
{
//3 front
//5 back
//7 front
//9 back
//11 fron
//13 back
//15 front
//17 back
// it's this i need …Run Code Online (Sandbox Code Playgroud)