小编Bli*_*0ne的帖子

AttributeError:'Cycler'对象没有属性'change_key'

我正在尝试import matplotlib使用Ubuntu.我从源重新安装matplotlib因为我无法使用TkAgg后端.现在我面临一个我无法解决的新问题,也无法在任何地方找到解决方案.我正在使用Python 3.5.当我运行一个简单的导入时,我有这个错误显示我:

Traceback (most recent call last):
  File "plot_test.py", line 17, in <module>
    import matplotlib
  File "/usr/local/lib/python3.5/site-packages/matplotlib-2.0.0b3+1955.g888bf17-py3.5-linux-x86_64.egg/matplotlib/__init__.py", line 1174, in <module>
    rcParams = rc_params()
  File "/usr/local/lib/python3.5/site-packages/matplotlib-2.0.0b3+1955.g888bf17-py3.5-linux-x86_64.egg/matplotlib/__init__.py", line 1017, in rc_params
    return rc_params_from_file(fname, fail_on_error)
  File "/usr/local/lib/python3.5/site-packages/matplotlib-2.0.0b3+1955.g888bf17-py3.5-linux-x86_64.egg/matplotlib/__init__.py", line 1149, in rc_params_from_file
    config = RcParams([(key, default) for key, (default, _) in iter_params
  File "/usr/local/lib/python3.5/site-packages/matplotlib-2.0.0b3+1955.g888bf17-py3.5-linux-x86_64.egg/matplotlib/__init__.py", line 901, in __init__
    self[k] = v
  File "/usr/local/lib/python3.5/site-packages/matplotlib-2.0.0b3+1955.g888bf17-py3.5-linux-x86_64.egg/matplotlib/__init__.py", line 918, in __setitem__
    cval = self.validate[key](val)
  File "/usr/local/lib/python3.5/site-packages/matplotlib-2.0.0b3+1955.g888bf17-py3.5-linux-x86_64.egg/matplotlib/rcsetup.py", line 844, in validate_cycler

    cycler_inst.change_key(prop, norm_prop) …
Run Code Online (Sandbox Code Playgroud)

python matplotlib python-3.x

5
推荐指数
1
解决办法
2996
查看次数

如何在不闪烁的情况下更新 Shiny 中的值?

我每秒都会更新一个闪亮的文本输出,该文本输出是从 SQL 数据库读取的,这只需要一些时间。在仪表板中,我只想看看输出如何变化而没有花哨的动画/闪烁。是否可以在等待更新时删除动画并仅显示文本?

这是一些代码示例,您可以在其中看到更新的闪烁:

# ui.R
library(shiny)

shinyUI(fluidPage(

  # App title ----
  titlePanel("Title"),

  # Sidebar layout with input and output definitions ----
  sidebarLayout(

    # Sidebar panel for inputs ----
    sidebarPanel(),

    # Main panel for displaying outputs ----
    mainPanel(
      # Output: Data file ----
      # Output: Tabset w/ plot, summary, and table ----
      tabsetPanel(type = "tabs",
                  tabPanel("Main", 
                           textOutput("foo"))
      )

    )
  )
)
)
Run Code Online (Sandbox Code Playgroud)
# server.R
library(shiny)

check_for_update <- function() {
  Sys.time()
}
get_data <- function() {
  df <- data.frame(replicate(20000,sample(0:1000,rep=TRUE)))
}


shinyServer( …
Run Code Online (Sandbox Code Playgroud)

r shiny

5
推荐指数
1
解决办法
1869
查看次数

在 python 中使用 C++ 对象与 pybind11

我的main.cpp文件如下所示:

// Embeding the interpreter into c++
// https://pybind11.readthedocs.io/en/master/advanced/embedding.html


#include <pybind11/embed.h>
#include <iostream>
#include <string>

// Define namespace for pybind11
namespace py = pybind11;

class Vehiclee
{ 
    // Access specifier 
    public: 

    // Data Members 
    int vehicle_id;
    std::string vehicle_name; 
    std::string vehicle_color;

    // Member Functions() 
    void printname() 
    { 
       std::cout << "Vehicle id is: " << vehicle_id; 
       std::cout << "Vehicle name is: " << vehicle_name; 
       std::cout << "Vehicle color is: " << vehicle_color; 
    } 
}; 


int main() {
    // Initialize the …
Run Code Online (Sandbox Code Playgroud)

c++ python pybind11

5
推荐指数
1
解决办法
6463
查看次数

R data.table 根据字符串值将一行拆分为多行

我有一个像这样的 data.table:

dt <- data.table("title"=c("First Title", "Second Title", "Third Title", "Fourth Title"), 
                 "sha"=c("12345", "2345; 66543; 33423", "22222; 12345678;", "666662345; 444"))
Run Code Online (Sandbox Code Playgroud)

我怎样才能得到这个:

      title                sha
1:  First Title           12345
2: Second Title           2345 
3: Second Title           66543
4: Second Title           33423
5:  Third Title           22222
6:  Third Title           12345678
7: Fourth Title           666662345
8: Fourth Title           444
Run Code Online (Sandbox Code Playgroud)

提前致谢!

r data.table

4
推荐指数
2
解决办法
2728
查看次数

C ++从互联网获取本地时间/格林威治时间进行许可

当前是否存在从互联网而不是从机器获取本地时间的实现,因为在机器上,用户可以篡改时间?当我运行以下代码时,它向我显示:

#include <iostream>
#include <iomanip>
#include <ctime>

int main()
{
    std::time_t t = std::time(nullptr);
    std::cout << "UTC:   " << std::put_time(std::gmtime(&t), "%c %Z") << '\n';
    std::cout << "local: " << std::put_time(std::localtime(&t), "%c %Z") << '\n';
}
Run Code Online (Sandbox Code Playgroud)

输出:

UTC:   Mon Sep 16 09:56:10 2019 GMT
local: Mon Sep 16 11:56:10 2019 CEST
Run Code Online (Sandbox Code Playgroud)

但是,当我在Ubuntu 18.04机器上更改时间时,两个函数的时间输出也会更改。用例将使用它进行许可,因为像repopp这样的回购协议仅使用普通的gmtime,这具有简单的解决方法,只需更改计算机时间以使其超过到期日期即可。

是否有一个可以使用互联网在不使用机器时间的情况下获得与上述类似的输出的功能?任何链接,代码片段的赞赏。谢谢。

c++

-2
推荐指数
1
解决办法
64
查看次数

标签 统计

c++ ×2

python ×2

r ×2

data.table ×1

matplotlib ×1

pybind11 ×1

python-3.x ×1

shiny ×1