神爱温柔

文章 评论 浏览 27

神爱温柔 2025-02-20 23:23:36

由于使用__行____文件__,因此您只需要宏。所有其他逻辑都可以在通常的函数中完成:

// Required arguments for args:
// message [optional]
// __LINE__
// __FILE__
template<typename C, typename... Args>
constexpr void al_assert(C&& condition, Args&&... args) {
   static_assert(sizeof...(args) >= 2);
   static_assert(sizeof...(args) <= 3);
   if (!std::forward<C>(condition)) {
       assertDialog(std::forward<Args>(args)...);
       __debugbreak();
   }
}

// assuming al_assert is placed in global namespace scope
// but better use a private namespace for al_assert
#define AL_ASSERT(...) (::al_assert(__VA_ARGS__, __LINE__, __FILE__))

// or
// #define AL_ASSERT(...) do { ::al_assert(__VA_ARGS__, __LINE__, __FILE__); } while(0)

使用C ++ 20,根本不需要宏:

#include<source_location>

//...

template<typename C, typename... Args>
struct al_assert {
    constexpr al_assert(C&& condition, Args&&... args,
                        std::source_location location = std::source_location::current()) {
       static_assert(sizeof...(args) <= 1);
       if (!std::forward<C>(condition)) {
           assertDialog(std::forward<Args>(args)..., location.line(), location.file_name());
           __debugbreak();
       }
    }
};

template<typename C, typename... Args>
al_assert(C&&, Args&&...) -> al_assert<C, Args...>;

可以直接使用宏而不是将宏用作al_assert(/*.....*/)< /代码>。 std :: source_location在参数包工作之后的CTAD技巧是

(模板参数和转发引用涵盖了潜在的边缘情况,以使其与宏观行为尽可能近。根据您的用例,您可能会对EG进行>条件简单地简单地感到满意bool而不是。)

You only need the macro because of the use of __LINE__ and __FILE__. All the other logic can be done in a usual function:

// Required arguments for args:
// message [optional]
// __LINE__
// __FILE__
template<typename C, typename... Args>
constexpr void al_assert(C&& condition, Args&&... args) {
   static_assert(sizeof...(args) >= 2);
   static_assert(sizeof...(args) <= 3);
   if (!std::forward<C>(condition)) {
       assertDialog(std::forward<Args>(args)...);
       __debugbreak();
   }
}

// assuming al_assert is placed in global namespace scope
// but better use a private namespace for al_assert
#define AL_ASSERT(...) (::al_assert(__VA_ARGS__, __LINE__, __FILE__))

// or
// #define AL_ASSERT(...) do { ::al_assert(__VA_ARGS__, __LINE__, __FILE__); } while(0)

With C++20 the macro is not required at all:

#include<source_location>

//...

template<typename C, typename... Args>
struct al_assert {
    constexpr al_assert(C&& condition, Args&&... args,
                        std::source_location location = std::source_location::current()) {
       static_assert(sizeof...(args) <= 1);
       if (!std::forward<C>(condition)) {
           assertDialog(std::forward<Args>(args)..., location.line(), location.file_name());
           __debugbreak();
       }
    }
};

template<typename C, typename... Args>
al_assert(C&&, Args&&...) -> al_assert<C, Args...>;

This can be used directly instead of using the macro as al_assert(/*...*/). The CTAD trick to make std::source_location after the parameter pack work is due to this answer.

(The template parameters and forwarding references are there to cover potential edge cases to make it as close as possible to the macro behavior. Depending on your use case, you may be happy with e.g. making the condition simply a bool instead.)

宏无法正确扩展

神爱温柔 2025-02-20 23:20:00

页/
某物 - [slug] .jsx

这对我来说很好:

// next.config.js

module.exports = {
    async rewrites() {
        return [
            {
                source: "/something-:slug",
                destination: "/something-[slug]",
            }
        ];
    }
}

localhost:3000/shots slug

pages/
something-[slug].jsx

This worked just fine for me:

// next.config.js

module.exports = {
    async rewrites() {
        return [
            {
                source: "/something-:slug",
                destination: "/something-[slug]",
            }
        ];
    }
}

localhost:3000/something-slug

如何将静态字符串与Next.js动态路线中的动态sl结合在一起?

神爱温柔 2025-02-20 22:14:35

该代码解决了问题。

dataframe = [group_metro_manila_sorted.reset_index(drop=True), city_location_sorted[['Latitude', 'Longitude']]]

concat_df = pd.concat(dataframe, join='inner',axis=1)

然后重置第一个数据框的索引,然后,不用合并尝试使用concat并设置axis = 1,以便将其水平串联

“

感谢在评论部分帮助的人。

This code resolved the problem.

dataframe = [group_metro_manila_sorted.reset_index(drop=True), city_location_sorted[['Latitude', 'Longitude']]]

concat_df = pd.concat(dataframe, join='inner',axis=1)

Reset the index of the first dataframe, then, instead of merge try to use concat and set the axis=1 so that it will be concatenated horizontally

concat_df

Thanks to the guys who helped in the comment section.

熊猫加入值成为nan

神爱温柔 2025-02-20 04:42:29

尝试将所有CSS文件加载到启动中,然后将所有JS文件放在末尾,然后删除不需要的注释或文件。这可能有助于提高网站的速度。而且,您在网站中使用的图像的分辨率或大小将使您的网站更快。

try to load all CSS files in starting and put all js files at the end and remove unwanted comments or files. this might help to improve the speed of your site. and also the resolution or maybe size of images which you use in your site it will make much faster your website.

网站在Local主机上很快,但在服务器上很慢

神爱温柔 2025-02-19 21:53:06

实际上,从交互式(node.js)提示符中,一个人可以“等待”:

> y = new Promise((resolve, reject) => resolve(23));
Promise {
   23,
   [Symbol(async_id_symbol)]: 10419,
   [Symbol(trigger_async_id_symbol)]: 5,
   [Symbol(destroyed)]: { destroyed: false }
}
> v = await y;
23

repl

您不能在“普通”函数中执行此操作:

> function foo() { let z = await y; return z; }
Uncaught SyntaxError:
Unexpected token 'y'

您可以在“异步函数”中执行此操作,但是这会使您持希望,而不是您想要的价值:

> async function foo() { let z = await y; return z; }
undefined
> foo()
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 10571,
  [Symbol(trigger_async_id_symbol)]: 5,
  [Symbol(destroyed)]: { destroyed: false }
}

Actually, from the interactive (Node.js) prompt, one can just "await":

> y = new Promise((resolve, reject) => resolve(23));
Promise {
   23,
   [Symbol(async_id_symbol)]: 10419,
   [Symbol(trigger_async_id_symbol)]: 5,
   [Symbol(destroyed)]: { destroyed: false }
}
> v = await y;
23

This is useful when experimenting at the REPL.

You can't do this in an "ordinary" function:

> function foo() { let z = await y; return z; }
Uncaught SyntaxError:
Unexpected token 'y'

You can do this in an "async function", but that leaves you back holding a promise, not the value you want:

> async function foo() { let z = await y; return z; }
undefined
> foo()
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 10571,
  [Symbol(trigger_async_id_symbol)]: 5,
  [Symbol(destroyed)]: { destroyed: false }
}

如何获得承诺的价值?

神爱温柔 2025-02-19 20:39:08

问题已解决。
删除此行:

testImplementation 'junit:junit:' 

从build.gradle(app),也将编译SDK从32降低到31
并添加以下行:

android.suppressUnsupportedCompileSdk=32

在Gradle的属性(项目)中

Issue is resolved.
Removed this line:

testImplementation 'junit:junit:' 

from build.gradle (app) and also downgrade the compile SDK from 32 to 31
and added following line:

android.suppressUnsupportedCompileSdk=32

in the gradle's properties(Project)

连接到Firebase时,无法解析Android应用程序模块的Gradle配置

神爱温柔 2025-02-18 11:17:39

有很多表达“对象”的方法,但请考虑以下示例。有对象对象{}{[k:t]:u} and code>记录&lt; k,t&gt; 。 JS中的几乎所有内容(以及扩展ts)是一个

这仅仅是因为

  • 对象
  • 。 表示任何非竞争
  • {}Object
  • {[K:String]:Any}相同,等于record> record&lt; string,any&gt;
  • 记录&lt; k,t&gt;是一种创建映射类型的实用程序类型。通常用作用Record&lt; string,Any&gt;(如上所述)的索引签名的替代品。还可以使用record&lt;'foo'|的确切键/值对开处方。 'bar','baz'| 'ang'&gt;等效于{bar:“ baz” | “砰”; foo:“ baz” | “砰”; }
  • 要键入一个空对象,建议使用record&lt; string,nove&gt;
  • 键入任何对象,您应该使用record&lt; string,norknoine&gt;record&lt; string,any&gt;
  • 要输入任何值,您应该使用未知任何 emon

示例

请考虑以下有关object 代码>:

class C {}
const a: Object = 0
const b: Object = ""
const c: Object = []
const d: Object = {}
const e: Object = C
const f: Object = null // <-- error!
const g: Object = undefined // <-- error!
const h: Object = { foo: "bar" }
h.bar // Property 'foo' does not exist on type 'Object'.

考虑以下有关对象

class C {}
const a: object = 0 // <-- error!
const b: object = "" // <-- error!
const c: object = []
const d: object = {}
const e: object = C
const f: object = undefined // <-- error!
const g: object = null // <-- error!
const h: object = { foo: "bar" }
h.bar // Property 'foo' does not exist on type 'object'.

相关文档

读取有关记录&lt; k,t&gt;

阅读有关 index签名

vers 映射类型

There are many ways to express 'objects', but consider the following examples. There is Object, object, {}, { [k: T]: U } and Record<K, T>. This is just because almost everything in JS (and by extension TS) is an object.*

I'll put the answer up-front with examples below:

  • Object means any non-nullish value
  • object means any non-primitive
    value
  • {} is the same as Object
  • { [k: string]: any } is equivalent to Record<string, any>
  • Record<K, T> is a utility type to create mapped types. Often used for as a substitute for index signatures with Record<string, any> (shown above). Also can prescribe exact key/value pairs with something like Record<'foo' | 'bar', 'baz' | 'bang'> being equivalent to { bar: "baz" | "bang"; foo: "baz" | "bang"; }
  • To type an empty object, it is recommended to use Record<string, never>
  • To type any object, you should use Record<string, unknown> or Record<string, any>
  • To type any value, you should use unknown or any

Examples

Consider the following about Object:

class C {}
const a: Object = 0
const b: Object = ""
const c: Object = []
const d: Object = {}
const e: Object = C
const f: Object = null // <-- error!
const g: Object = undefined // <-- error!
const h: Object = { foo: "bar" }
h.bar // Property 'foo' does not exist on type 'Object'.

Consider the following about object:

class C {}
const a: object = 0 // <-- error!
const b: object = "" // <-- error!
const c: object = []
const d: object = {}
const e: object = C
const f: object = undefined // <-- error!
const g: object = null // <-- error!
const h: object = { foo: "bar" }
h.bar // Property 'foo' does not exist on type 'object'.

Relevant Docs

Read about Record<K, T>.

Read about index signatures.

versus mapped types

为什么使用索引签名`{[key:string]:任何}`而不是``object'type''?

神爱温柔 2025-02-18 10:36:30

当您拥有数字数据时,使用''代替NAN不是一个好习惯。

也就是说,您问题的通用解决方案是使用 sum 使用skipna = false选项:

df1['Sum'] = (df1[['AuM', 'NNA']] # you can use as many columns as you want
        .apply(pd.to_numeric, errors='coerce')  # convert to numeric
        .sum(1, skipna=False)                   # sum if all are non-NaN
        .fillna('')               # fill NaN with empty string (bad practice)
       )

输出:输出:

       Date  AuM  NNA    Sum
0  01012021       100       
1  01012021        50       
2  01022021  140    5  145.0
3  01022021  160   12  172.0
4  01032021        20       
5  01032021  200   25  225.0

It is not a good practice to use '' in place of NaN when you have numeric data.

That said, a generic solution to your issue would be to use sum with the skipna=False option:

df1['Sum'] = (df1[['AuM', 'NNA']] # you can use as many columns as you want
        .apply(pd.to_numeric, errors='coerce')  # convert to numeric
        .sum(1, skipna=False)                   # sum if all are non-NaN
        .fillna('')               # fill NaN with empty string (bad practice)
       )

output:

       Date  AuM  NNA    Sum
0  01012021       100       
1  01012021        50       
2  01022021  140    5  145.0
3  01022021  160   12  172.0
4  01032021        20       
5  01032021  200   25  225.0

仅当一列的值更大/更大0时,只有两个列总和

神爱温柔 2025-02-18 05:16:36

我认为您需要提供有关如何调用这两个功能的更多信息。从理论上讲,它们只能在

顺便说一句,由于您通过用户创建了这些元素,为什么不使用this.users而不是const People并使用V-Show控制显示样式?如果此user不在您正在处理的组件中,则可以考虑使用道具或提供/注射或pinia/vuex。直接操作文件可能不是一个不错的选择。

I think you need to provide more information about how you call these two functions. In theory, they can work only in mounted hook, please check this.

Btw, since you created these elements by users, why don't you just use this.users instead of const people and use v-show to control display style? If this.users is not in the component you are working on, you can consider about using props or Provide/Inject or pinia/vuex. Operating document directly may not be a good choice.

加载页面后,如何声明我的VUE变量?

神爱温柔 2025-02-17 20:55:33

这只是扩展的问题

>>> a=[10,11,12,13,14,15,16,17,18,19,20]
>>> for b in a:
...     int(round(b/5.0)*5.0)
... 
10
10
10
15
15
15
15
15
20
20
20

It's just a matter of scaling

>>> a=[10,11,12,13,14,15,16,17,18,19,20]
>>> for b in a:
...     int(round(b/5.0)*5.0)
... 
10
10
10
15
15
15
15
15
20
20
20

在Python中舍入到5(或其他数字)

神爱温柔 2025-02-17 19:11:54

找不到我想要的东西,所以我自己滚动了几个...

这是有点言行,但是有一个优势,可以同时处理许多同名的超载方法(和返回类型):

struct C {
  int x[10];

  int const* getp() const { return x; }
  int const* getp(int i) const { return &x[i]; }
  int const* getp(int* p) const { return &x[*p]; }

  int const& getr() const { return x[0]; }
  int const& getr(int i) const { return x[i]; }
  int const& getr(int* p) const { return x[*p]; }

  template<typename... Ts>
  auto* getp(Ts... args) {
    auto const* p = this;
    return const_cast<int*>(p->getp(args...));
  }

  template<typename... Ts>
  auto& getr(Ts... args) {
    auto const* p = this;
    return const_cast<int&>(p->getr(args...));
  }
};

如果您每个名称只有一个const方法,但仍然有很多重复的方法,那么您可能会更喜欢以下方法:

  template<typename T, typename... Ts>
  auto* pwrap(T const* (C::*f)(Ts...) const, Ts... args) {
    return const_cast<T*>((this->*f)(args...));
  }

  int* getp_i(int i) { return pwrap(&C::getp_i, i); }
  int* getp_p(int* p) { return pwrap(&C::getp_p, p); }

不幸的是,当您开始重载该名称(函数指针参数的参数列表)时,这会立即崩溃当时似乎尚未解决,因此找不到函数参数的匹配)。尽管您也可以将其模板转换为:

  template<typename... Ts>
  auto* getp(Ts... args) { return pwrap<int, Ts...>(&C::getp, args...); }

但是,将参数引用到const方法无法与显然的串联参数匹配到模板,并且会破裂。 不确定为什么。 这就是为什么

Didn't find what I was looking for, so I rolled a couple of my own...

This one is a little wordy, but has the advantage of handling many overloaded methods of the same name (and return type) all at once:

struct C {
  int x[10];

  int const* getp() const { return x; }
  int const* getp(int i) const { return &x[i]; }
  int const* getp(int* p) const { return &x[*p]; }

  int const& getr() const { return x[0]; }
  int const& getr(int i) const { return x[i]; }
  int const& getr(int* p) const { return x[*p]; }

  template<typename... Ts>
  auto* getp(Ts... args) {
    auto const* p = this;
    return const_cast<int*>(p->getp(args...));
  }

  template<typename... Ts>
  auto& getr(Ts... args) {
    auto const* p = this;
    return const_cast<int&>(p->getr(args...));
  }
};

If you have only one const method per name, but still plenty of methods to duplicate, then you might prefer this:

  template<typename T, typename... Ts>
  auto* pwrap(T const* (C::*f)(Ts...) const, Ts... args) {
    return const_cast<T*>((this->*f)(args...));
  }

  int* getp_i(int i) { return pwrap(&C::getp_i, i); }
  int* getp_p(int* p) { return pwrap(&C::getp_p, p); }

Unfortunately this breaks down as soon as you start overloading the name (the function pointer argument's argument list seems to be unresolved at that point, so it can't find a match for the function argument). Although you can template your way out of that, too:

  template<typename... Ts>
  auto* getp(Ts... args) { return pwrap<int, Ts...>(&C::getp, args...); }

But reference arguments to the const method fail to match against the apparently by-value arguments to the template and it breaks. Not sure why.Here's why.

如何在类似的const和非CONST成员功能之间删除代码重复?

神爱温柔 2025-02-17 09:19:40

解决方案:

我使用的是从VS代码的Live Server扩展程序来自动刷新页面。重定向后,该扩展程序一次又一次地重新加载页面。因此,现在将其关闭后,一切正常。

Solution:

I was using Live Server extension from VS Code to auto refresh the page. This extension was reloading the page again and again after redirect. So, now after turning it off everything works fine.

Laravel重定向后继续重新加载页面

神爱温柔 2025-02-17 07:38:06

迭代字符串的字符,并用str.isspace标准进行分类。

def camel_characters(s):
    new_s = ''
    counter = 0
    for char in s:
        if char.isspace():
            new_s += char
        else:
            if counter % 2:
                new_s += char.lower()
            else:
                new_s += char.upper()
                counter = 0 # can be commented as well
            counter += 1

    return new_s

s = "Hello my guyy"
print(camel_characters(s))

Iterate over string's characters and classify with a str.isspace criteria.

def camel_characters(s):
    new_s = ''
    counter = 0
    for char in s:
        if char.isspace():
            new_s += char
        else:
            if counter % 2:
                new_s += char.lower()
            else:
                new_s += char.upper()
                counter = 0 # can be commented as well
            counter += 1

    return new_s

s = "Hello my guyy"
print(camel_characters(s))

如何使枚举不计算空白的索引?

神爱温柔 2025-02-16 19:05:53

是的,这是可能的,但是您需要返回完整的字符串,例如bg-primary(如尾风仅识别字符串),而不是primary,其中priendar> primary <) /代码>颜色应在tailwind.config.js文件中定义。

例如,您可以参考我的答案这个问题。

Yes this is possible but instead of only primary, you need to return the complete string like bg-primary(as tailwind only recognises the string) where your primary color should be defined in tailwind.config.js file.

For an example you can refer to my answer for this question.

尾风CS中的动态颜色

神爱温柔 2025-02-15 18:40:09

您缺少()尝试调用.distinct() in search()中的方法

You are missing () when trying to call .distinct() method in search()

django搜索返回异常值:类型的对象&#x27;方法&#x27;没有Len()

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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