小编Iva*_*van的帖子

不支持非平凡的指定初始值设定项

我的结构如下:

struct app_data
{
    int port;
    int ib_port;
    unsigned size;
    int tx_depth;
    int sockfd;
    char *servername;
    struct ib_connection local_connection;
    struct ib_connection *remote_connection;
    struct ibv_device *ib_dev;

};
Run Code Online (Sandbox Code Playgroud)

当我尝试初始化它时:

struct app_data data =
{
    .port = 18515,
    .ib_port = 1,
    .size = 65536,
    .tx_depth = 100,
    .sockfd = -1,
    .servername = NULL,
    .remote_connection = NULL,
    .ib_dev = NULL
};
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

sorry, unimplemented: non-trivial designated initializers not supported
Run Code Online (Sandbox Code Playgroud)

我认为它需要完全按照声明的顺序进行初始化,并且local_connection缺少.我不需要初始化它,并将其设置为NULL不起作用.

如果我将其更改为g ++,仍会得到相同的错误:

struct app_data data =
{
    port : 18515,
    ib_port : …
Run Code Online (Sandbox Code Playgroud)

c++ initialization

53
推荐指数
4
解决办法
4万
查看次数

brew安装zlib-devel在Mac OS X Mavericks上

尝试使用自制软件在mac os x mavericks上安装zlib-devel不起作用:

brew install zlib-devel
Error: No available formula for zlib-devel 
Searching taps...
Run Code Online (Sandbox Code Playgroud)

这个安装

brew install zlib
Run Code Online (Sandbox Code Playgroud)

虽然工作得很好.

homebrew zlib osx-mavericks

38
推荐指数
5
解决办法
5万
查看次数

使用Boost.Fiber,c ++是否更接近Erlang风格的流程/线程?

我正在阅读http://olk.github.io/libs/fiber/doc/html/在我看来,使用Boost.Fiber C++正在接近Erlang拥有数千个"进程"的能力,也被称为"绿色"进程[threads]" http://en.wikipedia.org/wiki/Green_threads.

我的问题是,是Boost.Fiber为生产做好准备,还有现在 ç有更好的文档和示例++的替代品?有人提到轻量级线程,但我似乎无法找到它的引用.最后一个问题是,为什么C++标准不包括Fibers?

我对此感兴趣的原因是因为我有实时更新,其中值更改可能会影响(产生)数百个/小型的小型但令人尴尬的并行计算.imo,C++线程模型不能很好地工作.请不要使用GPU,因为它目前需要很长时间才能将信息传输到GPU或从GPU传输信息.

我意识到Erlang远不止这个,所以请不要在一般情况下教我Erlang vs C++.

erlang boost real-time fiber c++11

13
推荐指数
1
解决办法
7550
查看次数

pandas.tools在哪里

安装后pandas

idf:~/Documents/python/plot$ pip3 install pandas --user
Collecting pandas
  Using cached https://files.pythonhosted.org/packages/f9/e1/4a63ed31e1b1362d40ce845a5735c717a959bda992669468dae3420af2cd/pandas-0.24.0-cp36-cp36m-manylinux1_x86_64.whl
Requirement already satisfied: numpy>=1.12.0 in /home/idf/.local/lib/python3.6/site-packages (from pandas) (1.15.4)
Requirement already satisfied: pytz>=2011k in /home/idf/.local/lib/python3.6/site-packages (from pandas) (2018.7)
Requirement already satisfied: python-dateutil>=2.5.0 in /home/idf/.local/lib/python3.6/site-packages (from pandas) (2.7.5)
Requirement already satisfied: six>=1.5 in /home/idf/.local/lib/python3.6/site-packages (from python-dateutil>=2.5.0->pandas) (1.12.0)
zipline 1.3.0 has requirement pandas<=0.22,>=0.18.1, but you'll have pandas 0.24.0 which is incompatible.
Installing collected packages: pandas
Successfully installed pandas-0.24.0
idf:~/Documents/python/plot$ 
Run Code Online (Sandbox Code Playgroud)

我尝试加载pandas.tools

from pandas.tools.plotting import autocorrelation_plot

ModuleNotFoundError                       Traceback (most …
Run Code Online (Sandbox Code Playgroud)

python-3.x pandas

13
推荐指数
3
解决办法
7926
查看次数

Cassandra cql:如何从表中选择最后n行

我想验证行是否已添加到表中.什么cql语句会显示下表中的最后 n行?

表格说明如下:

cqlsh:timeseries> describe table option_data;

CREATE TABLE option_data (
  ts bigint,
  id text,
  strike decimal,
  callask decimal,
  callbid decimal,
  maturity timestamp,
  putask decimal,
  putbid decimal,
  PRIMARY KEY ((ts), id, strike)
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.100000 AND
  gc_grace_seconds=864000 AND
  index_interval=128 AND
  read_repair_chance=0.000000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  default_time_to_live=0 AND
  speculative_retry='99.0PERCENTILE' AND
  memtable_flush_period_in_ms=0 AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'LZ4Compressor'};

cqlsh:timeseries>
Run Code Online (Sandbox Code Playgroud)

cassandra cql3

11
推荐指数
1
解决办法
2万
查看次数

使用额外参数增加变体访问者

我有类似下面的代码.

typedef uint32_t IntType;
typedef IntType IntValue;
typedef boost::variant<IntValue, std::string>  MsgValue;

MsgValue v;
Run Code Online (Sandbox Code Playgroud)

而不是说这个,

IntValue value = boost::apply_visitor(d_string_int_visitor(), v);
Run Code Online (Sandbox Code Playgroud)

我想传递一个额外的参数,如下所示:但是operator()给出了编译错误.

//This gives an error since the overload below doesn't work.
IntValue value = boost::apply_visitor(d_string_int_visitor(), v, anotherStr);

class d_string_int_visitor : public boost::static_visitor<IntType>
{
public:
    inline IntType operator()(IntType i) const
    {
        return i;
    }

    inline IntValue operator()(const std::string& str) const noexcept
    {
        // code in here
    }

    //I want this, but compiler error.
    inline IntValue operator()(const std::string& str, const std::string s) …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-variant c++11 c++14

8
推荐指数
1
解决办法
2914
查看次数

更改 Flask/Dash 中的图标

尝试favicon加载我遵循了互联网的建议:

server = Flask(__name__, static_folder='static')
app =  dash.Dash(external_stylesheets=external_stylesheets, server=server)

app.css.config.serve_locally = False
app.scripts.config.serve_locally = True

@server.route('/favicon.ico')
def favicon():
    print('Server root path', server.root_path)
    return send_from_directory(os.path.join(server.root_path, 'static'),
                               'dice.ico', mimetype='image/vnd.microsoft.icon')

   ...
   app.run_server(debug=True)
Run Code Online (Sandbox Code Playgroud)

如果我浏览到favicon,我会看到它:

http://www.example.com/favicon.ico
Run Code Online (Sandbox Code Playgroud)

但是,当我浏览到

http://www.example.com
Run Code Online (Sandbox Code Playgroud)

我看到dash带有自己描述的默认图标。我如何确保我自己的favicon负载正确?

flask plotly-dash

8
推荐指数
1
解决办法
6112
查看次数

使用非均匀毫秒的日内数据同步和重新采样两个时间序列

我在python 文档中看到了重新采样和同步两个时间序列的能力.我的问题更难,因为时间序列没有时间规律.我读了三个具有非确定性的日内时间戳的时间序列.但是,为了对这两个时间序列进行大多数分析(协方差,相关性等),我需要它们具有相同的长度.

在Matlab中,给定了三个ts1, ts2, ts3具有非确定性日内时间戳的时间序列,我可以通过说明来同步它们

[ts1, ts2] = synchronize(ts1, ts2, 'union');
[ts1, ts3] = synchronize(ts1, ts3, 'union');
[ts2, ts3] = synchronize(ts2, ts3, 'union');
Run Code Online (Sandbox Code Playgroud)

请注意,时间序列已经读入pandas DataFrame,因此我需要能够与已创建的DataFrames同步(并重新采样?).

python time-series pandas

6
推荐指数
1
解决办法
2922
查看次数

块占用6%CPU的python程序?

我有一个使用这个的程序基本上做了一些非常简单的事情,就像这样

   receiver = multicast.MulticastUDPReceiver ("192.168.0.2", symbolMCIPAddrStr, symbolMCPort )
   while True:
            print 'Spinning'
            try:
                    b = MD()

                    data = receiver.read(1024)
Run Code Online (Sandbox Code Playgroud)

接收器套接字阻塞,直到数据进入,因此print 'Spinning'只有在套接字上接收数据之前才会打印一次.当我向操作系统询问这个过程需要多少CPU时,即使它正在等待接收,它还会返回:

[idf@node1 ~]$ ps -p  4294 -o %cpu,%mem,cmd
%CPU %MEM CMD
 6.3  0.4 python ./mc.py -s EUR/USD
[idf@node1 ~]$
Run Code Online (Sandbox Code Playgroud)

事实上,如果我运行其中的几个进程,我的计算机每个都有两个CPU和8个内核,所有内核都会达到100%的使用率,而计算机也无法使用.

我必须误解python的"阻塞"概念,因为即使是一个基本上没有睡觉的无处理过程占用了大量的CPU.

是否有更正确的方法来编写它,以便基本上等待I/O [中断驱动]的程序放弃CPU?

python sockets performance process blocking

6
推荐指数
1
解决办法
177
查看次数

熊猫的时间分组部分

TimeGrouper 还存在吗?

print(pd.__version__)

0.25.0
Run Code Online (Sandbox Code Playgroud)

这曾经有效:

tg = pd.TimeGrouper(freq='M')
Run Code Online (Sandbox Code Playgroud)

现在它给

AttributeError: module 'pandas' has no attribute 'TimeGrouper'
Run Code Online (Sandbox Code Playgroud)

pandas python-3.7

6
推荐指数
0
解决办法
4924
查看次数