我试图让以下脚本工作.输入文件由3列组成:基因关联类型,基因名称和疾病名称.
cols = ['Gene type', 'Gene name', 'Disorder name']
no_headers = pd.read_csv('orphanet_infoneeded.csv', sep=',',header=None,names=cols)
gene_type = no_headers.iloc[1:,[0]]
gene_name = no_headers.iloc[1:,[1]]
disease_name = no_headers.iloc[1:,[2]]
query = 'Disease-causing germline mutation(s) in' ###add query as required
orph_dict = {}
for x in gene_name:
if gene_name[x] in orph_dict:
if gene_type[x] == query:
orph_dict[gene_name[x]]=+ 1
else:
pass
else:
orph_dict[gene_name[x]] = 0
Run Code Online (Sandbox Code Playgroud)
我一直收到错误消息:
系列对象是可变的,不能进行哈希处理
任何帮助将非常感谢!
假设我们有一个像这样的类的C++库:
class TheClass {
public:
TheClass() { ... }
void magic() { ... }
private:
int x;
}
Run Code Online (Sandbox Code Playgroud)
此类的典型用法包括堆栈分配:
TheClass object;
object.magic();
Run Code Online (Sandbox Code Playgroud)
我们需要为这个类创建一个C包装器.最常见的方法如下:
struct TheClassH;
extern "C" struct TheClassH* create_the_class() {
return reinterpret_cast<struct TheClassH*>(new TheClass());
}
extern "C" void the_class_magic(struct TheClassH* self) {
reinterpret_cast<TheClass*>(self)->magic();
}
Run Code Online (Sandbox Code Playgroud)
但是,它需要堆分配,这对于这么小的类显然是不希望的.
我正在寻找一种允许从C代码中分配此类的堆栈的方法.这是我能想到的:
struct TheClassW {
char space[SIZEOF_THECLASS];
}
void create_the_class(struct TheClassW* self) {
TheClass* cpp_self = reinterpret_cast<TheClass*>(self);
new(cpp_self) TheClass();
}
void the_class_magic(struct TheClassW* self) {
TheClass* cpp_self = reinterpret_cast<TheClass*>(self);
cpp_self->magic();
}
Run Code Online (Sandbox Code Playgroud)
很难将类的实际内容放在struct的字段中.我们不能只包含C++标头,因为C不理解它,所以它需要我们编写兼容的C标头.这并不总是可行的.我认为C库并不需要关心结构的内容.
这个包装器的用法如下所示:
TheClassW object; …
Run Code Online (Sandbox Code Playgroud) 考虑使用船舶在蓝色div上方移动的CSS3动画.由于某种原因,船没有移动.HTML如下:
<div id="wrapper">
<div id="sea">
<img src="ship.png" alt="ship" width="128" height="128"/>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
为了制作CSS3动画,我使用以下内容:
#wrapper { position:relative;top:50px;width:700px;height:320px;
margin:0 auto;background:white;border-radius:10px;}
#sea { position:relative;background:#2875DE;width:700px;height:170px;
border-radius:10px;top:190px; }
#sea img {
position:relative;left:480px;top:-20px;
animation:myship 10s;
-moz-animation:myship 10s; /* Firefox */
-webkit-animation:myship 10s; /* Safari and Chrome */
@keyframes myship {
from {left: 480px;}
to{left:20px;}
}
@-moz-keyframes myship {
from {left: 480px;}
to {left:20px;}
}
@-webkit-keyframes myship {
from {left: 480px;}
to{left:20px;}
}
}
Run Code Online (Sandbox Code Playgroud)
船舶图像没有移动.任何帮助是极大的赞赏.
我试图让Guake终端在Unity中正常工作.它的窗口宽度等于屏幕宽度.但由于Unity左侧酒吧窗口的右边界变得无形.所以,我想为窗口设置合适的宽度.它必须小于实际窗口大小.并且代码必须在有或没有Unity的情况下正常工作.
这就是Guake如何确定其窗口的位置和大小:
def get_final_window_rect(self):
"""Gets the final size of the main window of guake. The height
is the window_height property, width is window_width and the
horizontal alignment is given by window_alignment.
"""
screen = self.window.get_screen()
height = self.client.get_int(KEY('/general/window_height'))
width = 100
halignment = self.client.get_int(KEY('/general/window_halignment'))
# get the rectangle just from the first/default monitor in the
# future we might create a field to select which monitor you
# wanna use
window_rect = screen.get_monitor_geometry(0)
total_width = window_rect.width
window_rect.height = window_rect.height * …
Run Code Online (Sandbox Code Playgroud) 我正在使用SQLite作为iPhone应用程序,我正在使用这样的查询:
NSString *query = [[NSString alloc] initWithFormat:@"INSERT INTO Courses (name, credits, web, tName, tSurname, tMail, tOffice) VALUES (\'%@\', \'%@\', \'%@\', \'%@\', \'%@\', \'%@\', \'%@\');", self.name, self.credits, self.web, self.tName, self.tSurname, self.tMail, self.tOffice];
这是一个简单的INSERT,但我来自西班牙,我遇到了一些问题.如果我这样做:
INSERT INTO Courses (name, credits, web, tName, tSurname, tMail, tOffice) VALUES ('test', 'test', 'test', 'test', 'test', 'test', 'test');", self.name, self.credits, self.web, self.tName, self.tSurname, self.tMail, self.tOffice];
一切都很完美.
问题变成了当我插入两个或更多带有"特殊字符"的单词时,如¿,¡,`,',ñ...而且我不知道如何解决它:S如果查询只包含一个特殊的性格没有问题.
例如:
此查询正在运行(因为只有"á"):
INSERT INTO Courses (name, credits, web, tName, tSurname, tMail, tOffice) VALUES ('Matemáticas', '1', '', 'Name', 'Surname', 'a@a.com', '');", self.name, …
下面的代码是抛出错误.我不知道为什么.任何人都能解释一下吗?所有代码都在不同的文件上.
#ifndef MAINSESSION_H
#define MAINSESSION_H
#include "sessionsuper.h"
#include "mainwindow.h"
class MainSession : public SessionSuper
{
public:
MainSession();
private:
};
#include "mainsession.h"
MainSession::MainSession()
{
}
#endif // MAINSESSION_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "mainsession.h"
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
MainSession *ms; //Error here
};
#endif // MAINWINDOW_H
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//ms=new MainSession(this); …
Run Code Online (Sandbox Code Playgroud) 我为 Doctrine 创建了 yaml 配置。当我尝试时doctrine orm:generate-entities
,它会创建带有驼峰式大小写的 getter 和 setter 的 php 文件。因此,is_public
领域转化为setIsPublic
方法getIsPublic
。真是太糟糕了。我怎样才能得到set_is_public
和get_is_public
?我可以手动编辑生成的 php 文件,但我不知道更改架构时会发生什么。
我想使用PySide创建一个简单的应用程序,只是为了从python日志记录输出.
def mpm_print():
print 'OK'
def mpm_log():
log.info('OK')
class LabWindow(QtGui.QMainWindow):
def __init__(self):
super(LabWindow, self).__init__()
self.initUI()
mpm_print()
mpm_log()
def initUI(self):
font = QtGui.QFont()
font.setFamily("Courier")
font.setFixedPitch(True)
font.setPointSize(10)
self.qtxt = QtGui.QTextEdit(self)
self.qtxt.resize(self.size())
self.qtxt.setReadOnly(True)
self.qtxt.setFont(font)
self.resize(640, 512)
self.setWindowTitle('Efficient Algorithms Lab')
self.show()
Run Code Online (Sandbox Code Playgroud)
我想知道:
谢谢
我正在尝试使用C++建立一个简单的窗口,但我的CreateWindowEx
回调NULL
.我使用的大部分代码都来自MSDN网站上的示例.我尝试过的任何东西都没有用,任何帮助都会受到赞赏.
这是代码:
//Include the windows header
#include <Windows.h>
//Forward declaration of the WndProc function
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
//Main entry point
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) {
//Window class name
const wchar_t windowName[] = L"Window Class";
//Set up window class
WNDCLASS wnd;
wnd.lpfnWndProc = WndProc;
wnd.hInstance = hInstance;
wnd.lpszClassName = windowName;
//Register window class
RegisterClass(&wnd);
//Create window
//! This returns NULL
HWND hWnd …
Run Code Online (Sandbox Code Playgroud) 据我所知,这不是由无限递归引起的.
该程序使用较小的数组(它是一个音频编辑器)正常运行.现在我增加了功能以允许更大的阵列(最多5分钟的音频,26460000个16位数据~50mb).
由于增加了数组的大小,我在一个特定的函数上收到堆栈溢出错误,它应该通过向后将数组写入新数组来反转输入文件的回放,然后覆盖原始数组.我猜测每个阵列可能高达50MB,这可能是问题所在:
//initialise temporary new array to place samples in
short signed int reverse_data[max_number_samples];
for (i=0; i<track_samples; i++)
{ //puts data from sound_data into reverse_data backwards.
reverse_data[(max_number_samples-1)-i]=sound_data[i];
}
for (i=0; i<track_samples; i++)
{ //now overwrites sound_data with the data in reverse_data
sound_data[i]=reverse_data[i];
}
Run Code Online (Sandbox Code Playgroud)
我对C++和编程很新,并且不确定我在调试期间得到的错误是什么告诉我的.
任何帮助将不胜感激,我确信有一个简单的解决方案(我读过涉及'堆'的东西,但我不确定'堆'真的是什么).