我正在尝试创建一个热图ggplot2(你看到下面的代码)现在有两件事我想改变:
我想在图例中显示超过6个值.我尝试了例如休息,标签,但这不起作用
(p <- ggplot(dataPVal.m, aes(variable, structure)) +
geom_tile(aes(fill = pValue), colour = "white") +
scale_colour_gradientn(colour = rainbow(100), breaks = c(1,2,3,4,5,6), labels =c("a","b","c","d","e","f")) +
theme_grey(base_size = base_size) +
labs(x = "position (0=seed start)",y = "structure") + ## labels
#scale_x_discrete(expand = c(0.01, 0.01)) + ## grauer rand oben/unten
#scale_y_discrete(expand = c(0.01, 0.01)) + ## grauer rand links/rechts
opts(title=plot_title,legend.position = "left",axis.ticks = theme_blank(), axis.text.x = theme_text(size = base_size * 0.8, angle = 330, hjust = 0, colour = …Run Code Online (Sandbox Code Playgroud)我正在从Windows命令提示符运行python脚本.它调用下面的函数,它使用LAME将MP3文件转换为波形文件.
def convert_mp3_to_wav(input_filename, output_filename):
"""
converts the incoming mp3 file to wave file
"""
if not os.path.exists(input_filename):
raise AudioProcessingException, "file %s does not exist" % input_filename
command = ["lame", "--silent", "--decode", input_filename, output_filename]
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = process.communicate()
if process.returncode != 0 or not os.path.exists(output_filename):
raise AudioProcessingException, stdout
return output_filename
Run Code Online (Sandbox Code Playgroud)
不幸的是,LAME总是在某些MP3上崩溃(并且不辜负它的名字).出现Windows"你的程序已崩溃"对话框,冻结了我的脚本.关闭Windows对话框后,将引发AudioProcessingException.我不想告诉Windows关闭,我只是喜欢脚本来引发异常,然后移动到下一个MP3.
有没有办法解决?最好是通过改变脚本而不是用Unix运行它.
我使用的是Windows 7和Python 2.6
在WPF中,是否有一种方法可以枚举特定嵌入式资源目录中的所有文件?也就是说,所有项目的目录都具有设置为"资源"的"构建动作".
我正在使用@AspectJ样式来编写方面,以处理我们的应用程序中的日志记录.基本上我有一个切入点设置如下:
@Pointcut("call(public * com.example..*(..))")
public void logging() {}
Run Code Online (Sandbox Code Playgroud)
然后像之前和之后的建议一样:
@Before("logging()")
public void entering() {...}
...
@After("logging()")
public void exiting() {...}
Run Code Online (Sandbox Code Playgroud)
我想以下列格式创建这些方法的日志:
logger.trace("ENTERING/EXITING [" className + "." + methodName "()]");
Run Code Online (Sandbox Code Playgroud)
问题是我不知道如何获取类和方法名称的引用.我试过了:
joinPoint.getThis().getClass()
Run Code Online (Sandbox Code Playgroud)
但这似乎返回了调用者的类名.
class A {
public void a() {
B.b();
}
}
class B {
public void b() {
...
}
}
Run Code Online (Sandbox Code Playgroud)
会导致以下日志
ENTERING [A.b()]
Run Code Online (Sandbox Code Playgroud)
有人可以提供一些关于如何获得实际的连接点类和方法名称的帮助
我有这样的事情:
select = document.getElementById("select");
select.onchange = function(){
alert(this.value); //returns the selected value
alert(this.innerHTML); //returns the entire select with all the options
alert(this.selected.innerHTML); //this is what I want, but doesn't work, of course
};
Run Code Online (Sandbox Code Playgroud)
如何在纯js中获取所选选项的innerHTML?(没有框架).
我使用Mongoid和Fabrication宝石.我从beta20切换到Mongoid.rc7,现在我无法使用嵌入文档制作文档:
#Models
class User
include Mongoid::Document
embeds_many :roles
end
class Role
include Mongoid::Document
field :name, :type => String
embedded_in :user, :inverse_of => :roles
end
#Fabricators
Fabricator(:role) do
name { "role" }
end
Fabricator(:user) do
email { Faker::Internet.email }
password { "password" }
password_confirmation { |user| user.password }
roles { [] }
end
Fabricator(:admin_user, :from => :user) do
roles(:count => 1) { |user| Fabricate(:role, :user => user, :name => "admin") }
end
Run Code Online (Sandbox Code Playgroud)
当我尝试制作时,admin_user我得到没有角色的用户.当我尝试制作角色时,我收到错误.
#<User _id: 4d62a2fd1d41c87f09000003, email: …Run Code Online (Sandbox Code Playgroud) 我正在自动生成C代码来计算大型表达式,并试图用简单的例子弄清楚在单独的变量中预定义某些子部分是否有意义.
举个简单的例子,假设我们计算了一些形式:
#include <cmath>
double test(double x, double y) {
const double c[9][9] = { ... }; // constants properly initialized, irrelevant
double expr = c[0][0]*x*y
+ c[1][0]*pow(x,2)*y + ... + c[8][0]*pow(x,9)*y
+ c[1][1]*pow(x,2)*pow(y,2) + ... + c[8][1]*pow(x,9)*pow(y,2)
+ ...
Run Code Online (Sandbox Code Playgroud)
所有c [i] [j]正确初始化.实际上,这些表达式包含数以千万计的乘法和加法.
现在提出一个同事 - 减少对pow()的调用次数并缓存表达式中经常需要的值 - 在单独的变量中定义x和y的每个幂,这没什么大不了的,因为代码是自动的无论如何生成,像这样:
double xp2 = pow(x,2);
double xp3 = pow(x,3);
double xp4 = pow(x,4);
// ...
// same for pow(y,n)
Run Code Online (Sandbox Code Playgroud)
但是,我认为这是不必要的,因为编译器应该处理这些优化.
不幸的是,我没有阅读和解释汇编的经验,但我想我看到所有对pow()的调用都被优化了,这是对的吗?此外,编译器是否缓存pow(x,2),pow(x,3)等的值?
提前感谢您的意见!
我正在用C#.Net开发一个Windows服务,我有一些难以执行和测试我的服务.我正在使用计时器组件不时运行它并执行我的方法.我必须始终将服务初始化以运行它.有人知道更实用的方法来测试服务吗?
我搜索一种方法,将使用可读名称("类别")定义的Bson对象映射到短名称("ct"),并限制主文档库中项目名称占用的空间.我已经看到这个使用其他驱动程序,但如何使用官方驱动程序.我怎么做,哪里是最好的定义地点.可以在查询中使用长名并检索短内容吗?
谢谢.
public class Parent {
public enum ChildType {
FIRST_CHILD("I am the first."),
SECOND_CHILD("I am the second.");
private String myChildStatement;
ChildType(String myChildStatement) {
this.myChildStatement = myChildStatement;
}
public String getMyChildStatement() {
return this.myChildStatement;
}
}
public static void main(String[] args) {
// Why does this work?
System.out.println(Parent.ChildType.FIRST_CHILD.myChildStatement);
}
}
Run Code Online (Sandbox Code Playgroud)
在参考这个枚举时,是否有关于Parent子类,同一包中的类等的访问控制的附加规则?我在哪里可以找到规范中的规则?