我有以下附庸配置/etc/uwsgi/vassals/gsd.ini:
[uwsgi]
plugins = python
env = DJANGO_SETTINGS_MODULE=%n.settings
virtualenv = /home/toogy/.pyenv/versions/%n
chdir = /home/webapps/%n
module = %n.wsgi:application
master = true
vacuum = true
pidfile = /tmp/uwsgi-%n.pid
socket = /tmp/uwsgi-%n.sock
daemonize = /var/log/uwsgi/%n.log
chmod-socket = 666
uid = toogy
gid = toogy
Run Code Online (Sandbox Code Playgroud)
这是我得到的uwsgi日志
Tue Feb 7 10:49:12 2017 - received message 1 from emperor
...gracefully killing workers...
Gracefully killing worker 1 (pid: 31406)...
worker 1 buried after 1 seconds
binary reloading uWSGI...
chdir() to /etc/uwsgi/vassals
closing all non-uwsgi socket …Run Code Online (Sandbox Code Playgroud) 这是一个玩具的例子
#include <iostream>
#include <functional>
struct Obj
{
int x;
int foo()
{
return 42;
}
};
int main()
{
Obj a, b;
std::function<int()> f1 = std::bind(&Obj::foo, &a);
std::function<int()> f2 = std::bind(&Obj::foo, &b);
std::function<int()> f3 = std::bind(&Obj::foo, &a);
std::function<int()> f4 = std::bind(&Obj::foo, &b);
}
Run Code Online (Sandbox Code Playgroud)
我如何验证,f1 == f3并且f2 == f4,==比较器在这里,这意味着两个std::function对象对应于同一对象的相同方法?
numpy.nonzero对于获取非零元素的索引很有用。它返回一个数组元组,每个数组都包含特定轴的非零元素的索引。
除了零元素之外是否有等价的?
这意味着对于给定的 numpy 数组
x = [[1, 2, 0],
[8, 0, 2],
[0, 0, 1]]
Run Code Online (Sandbox Code Playgroud)
我可以得到如下索引
ax0_zero_idxs, ax1_zero_idxs = numpy.zero(x)
Run Code Online (Sandbox Code Playgroud)
在哪里
ax0_zero_idxs = [0, 1, 2, 2]
ax1_zero_idxs = [2, 1, 0, 1]
Run Code Online (Sandbox Code Playgroud) 编辑:这个结构是真正糟糕的设计,不要使用它!
是否可以在C++ 11中初始化一个指向对象的指针列表(同时初始化所有内容)?
例如,假设我想要创建my_list哪种类型:
list<pair<string, map<string, string> *> *>.
我想用原始值初始化它.
list<pair<string, map<string, string> *> *> my_list = { ??? }
???:创建新的指针到新的对原始字符串和新指针的原始字符串的地图.
(为什么我需要这样做:这个数据结构存储从文件中读取的配置,但如果找不到该文件,我的代码中需要一个默认值)
我正在试验std::reference_wrapper.我不明白为什么以下内容适用于a std::vector但不适用于std::unordered_map:
#include <functional>
#include <vector>
#include <unordered_map>
using namespace std;
int main()
{
vector<vector<long>> x;
vector<reference_wrapper<vector<vector<long>>>> y;
y.push_back(ref(x)); // OK
unordered_map<string, reference_wrapper<vector<vector<long>>>> m;
m["lol"] = ref(x); // NOT OK
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的编译错误
/usr/include/c++/7.2.0/tuple:1652:70: error: no matching function for call to ‘std::
reference_wrapper<std::vector<std::vector<long int> > >::reference_wrapper()’
second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
^
In file included from /usr/include/c++/7.2.0/bits/std_function.h:44:0,
from /usr/include/c++/7.2.0/functional:58,
from test.cpp:1:
/usr/include/c++/7.2.0/bits/refwrap.h:325:7: note: candidate: constexpr std::referen
ce_wrapper<_Tp>::reference_wrapper(const std::reference_wrapper<_Tp>&) [with _Tp = s
td::vector<std::vector<long int> >]
reference_wrapper(const reference_wrapper&) = default;
^~~~~~~~~~~~~~~~~ …Run Code Online (Sandbox Code Playgroud) 以下代码将文件中的图像读入cv::Mat对象.
#include <string>
#include <opencv2/opencv.hpp>
cv::Mat load_image(std::string img_path)
{
cv::Mat img = cv::imread(img_path, CV_LOAD_IMAGE_GRAYSCALE);
cv::Scalar intensity = img.at<uchar>(0, 0);
std::cout << intensity << std::endl;
return img;
}
Run Code Online (Sandbox Code Playgroud)
我希望cv::Mat只有一个通道(即图像的强度),但它有4个.
$ ./test_load_image
[164, 0, 0, 0]
Run Code Online (Sandbox Code Playgroud)
我也试过转换图像
cv::Mat gray(img.size(), CV_8UC1);
img.convertTo(gray, CV_8UC1);
Run Code Online (Sandbox Code Playgroud)
但gray矩阵也是一个4通道.
我想知道是否可以有一个频道cv::Mat.直观地说,这是我在处理灰度(因此,单通道)图像时所期望的.