我在bash(3.00)shell脚本中对变量进行了大量测试,如果未设置变量,则会分配一个默认值,例如:
if [ -z "${VARIABLE}" ]; then
FOO='default'
else
FOO=${VARIABLE}
fi
Run Code Online (Sandbox Code Playgroud)
我似乎记得在一行中有一些语法,类似于三元运算符,例如:
FOO=${ ${VARIABLE} : 'default' }
Run Code Online (Sandbox Code Playgroud)
(虽然我知道这不起作用......)
我疯了,还是有类似的东西存在?
我对Python有些新意.我在一系列项目中使用过它,但实际上并不需要偏离其标准设置.我正在尝试安装一些新的软件包来访问大学任务所需的功能.当我尝试安装时,我得到以下内容:
(base) C:\Anaconda2\Jupyter>conda install -c python-control -c cyclus slycot control
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- slycot
- control
Current channels:
- https://conda.anaconda.org/python-control/win-64
- https://conda.anaconda.org/python-control/noarch
- https://conda.anaconda.org/cyclus/win-64
...
Run Code Online (Sandbox Code Playgroud)
还有一堆类似上面的其他渠道.
我一直在寻找解决方案,但没有发现任何重大问题.我已经看到它可能是Windows的一个问题,这就是我正在使用它.过去我不知道发生了什么.
请记住,我并不真正了解渠道和套餐的运作方式,因此对此问题的任何见解都会很棒.
我想在我写的文章中提出一个距离矩阵,我正在为它寻找良好的可视化.
到目前为止,我遇到了气球图(我在这里使用它,但我不认为它会在这种情况下起作用),热图(这是一个很好的例子,但它们不允许在表中显示数字,正确我,如果我错了.也许一半的颜色和一半的数字将是很酷的)和最后的相关椭圆图(这里是一些代码和示例 - 使用一个形状很酷,但我不知道如何使用它这里).
还有各种聚类方法,但它们会聚合数据(这不是我想要的),而我想要的是呈现所有数据.
示例数据:
nba <- read.csv("http://datasets.flowingdata.com/ppg2008.csv")
dist(nba[1:20, -1], )
Run Code Online (Sandbox Code Playgroud)
我很开心.
我正在尝试使用MongoDB和Flask(使用pymongo驱动程序)创建Web服务.当然,对数据库的查询返回包含"_id"字段的文档.我不想将其发送给客户端,所以我该如何删除它?
这是一个Flask路线:
@app.route('/theobjects')
def index():
objects = db.collection.find()
return str(json.dumps({'results': list(objects)},
default = json_util.default,
indent = 4))
Run Code Online (Sandbox Code Playgroud)
返回:
{
"results": [
{
"whatever": {
"field1": "value",
"field2": "value",
},
"whatever2": {
"field3": "value"
},
...
"_id": {
"$oid": "..."
},
...
}
]}
Run Code Online (Sandbox Code Playgroud)
我以为它是一本字典,我可以在返回之前删除该元素:
del objects['_id']
Run Code Online (Sandbox Code Playgroud)
但是这会返回一个TypeError:
TypeError: 'Cursor' object does not support item deletion
Run Code Online (Sandbox Code Playgroud)
所以它不是字典,而是我必须将每个结果作为字典迭代.所以我试着用这段代码做到这一点:
for object in objects:
del object['_id']
Run Code Online (Sandbox Code Playgroud)
每个对象字典看起来都是我现在喜欢的方式,但是对象光标是空的.所以我尝试创建一个新的字典,并在从每个字典中删除_id后,添加到Flask将返回的新字典:
new_object = {}
for object in objects:
for key, item in objects.items():
if key == '_id':
del …
Run Code Online (Sandbox Code Playgroud) 我知道使用Eclipse创建任务的两种方法; 使用任务视图或TODO
注释中的注释:
//TODO: wtf? Rewrite it using constants.
int foo = 3.1 * 3;
Run Code Online (Sandbox Code Playgroud)
如果我使用第一种方式,我可以编辑任务并设置"优先级".
我可以为使用TODO
注释创建的任务执行此操作吗?
下面我发布了一个迷你示例,其中我想“[“
为S4类的方法编写文档.有人知道如何正确记录"["
使用roxygen和S4 的通用方法吗?
在建造后检查包装时我收到警告(见下文).
#' An S4 class that stores a string.
#' @slot a contains a string
#' @export
setClass("testClass",
representation(a="character"))
#' extract method for testClass
#'
#' @docType methods
#' @rdname extract-methods
setMethod("[", signature(x = "testClass", i = "ANY", j="ANY"),
function (x, i, j, ..., drop){
print("void function")
}
)
Run Code Online (Sandbox Code Playgroud)
包检查摘录:
* checking for missing documentation entries ... WARNING
Undocumented S4 methods:
generic '[' and siglist 'testClass'
All user-level objects in a package (including S4 …
Run Code Online (Sandbox Code Playgroud) 当我试图在R Pubs中发布我的作品时,我收到一个错误:
Error in function (type, msg, asError = TRUE) :
SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Calls: rpubsUpload ... <Anonymous> -> .postForm -> .Call -> <Anonymous> -> fun
Execution halted
Run Code Online (Sandbox Code Playgroud)
无论如何要解决它?
我需要将rda文件转换为csv.我试图在R中加载它,但是我收到以下错误:
In readChar(con, 5L, useBytes = TRUE) :
cannot open compressed file file 'data/matrix.rda', probable reason 'No such file or directory'
Run Code Online (Sandbox Code Playgroud)
这是rda文件的链接(http://elisacarli.altervista.org/matrix.rda)
提前感谢任何建议
我rgdal adn rgoes
在redhat linux机器上编译包时遇到错误.我试图做一些研究,但找不到可能的解决方案.能不能帮我解决这个问题,因为这对我来说非常重要.
**ERROR WHILE COMPILING RGDAL in R 3.0**
**strong text**
* installing *source* package ârgdalâ ...
** package ârgdalâ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgdal: 0.8-10
checking for /usr/bin/svnversion... yes
configure: svn revision: 496
configure: gdal-config: gdal-config
checking gdal-config usability... ./configure: line 1397: gdal-config: command not found
no
Error: gdal-config not found
The gdal-config script distributed with GDAL could not be found.
If you have not …
Run Code Online (Sandbox Code Playgroud) 我正在使用git-svn.我已将文件'A'移动到'B',并且我最近使用了svn HEAD(使用git svn rebase
).我可以毫无问题地提交所有其他更改.现在我已经决定将'B'移回'A'并提交更改.
当我执行移动并提交给我的本地主人时,它工作正常,但在执行以下操作时我得到以下内容git svn dcommit
:
Transaction is out of date: Out of date: 'A' in transaction '3652-1' at /opt/local/libexec/git-core/git-svn line 570
Run Code Online (Sandbox Code Playgroud)
所以我尝试在单独的提交中复制和删除导致:
Item already exists in filesystem: File already exists: filesystem '/usr/svn/db', transaction '3652-1', path 'A' at /opt/local/libexec/git-core/git-svn line 4735
Run Code Online (Sandbox Code Playgroud)
通过使用文档中描述的解决方法,我使用普通的svn恢复了这种情况,但我不知道如何使用git-svn进行恢复.发生了什么,我该如何解决?