base

barplot in loop in R

大兔子大兔子 提交于 2019-12-03 17:11:29
Here is my question: #data 1: lab1 <- 1:10 group <- rep(1:3, each = length (lab1)) label <- rep(lab1, 3) avar <- rep(c(0, 1, 4, 5, 6, 8, 10, 11, 12, 13), 3) myd <- data.frame (group, label, avar) # data 2 fillcol <- rep(rnorm(length(lab1)-1, 0.5, 0.2), 3) group1 <- rep(1:3, each = length(fillcol)/3) # this variable will be used to fill color in bars filld <- data.frame(group1, fillcol) # now plotting par(mfrow = c(3, 1)) par(mar = c(2.5, 1, 2.5, 1)) #plot1 myd1 <- myd[myd$group ==1,] filld1 <- filld[filld$group1 ==1,] blues <- colorRampPalette(c("yellow", "blue")) barplot(as.matrix(diff(myd1

How do I pass variables to all templates in django? [duplicate]

六眼飞鱼酱① 提交于 2019-12-03 13:03:39
This question already has answers here : Django - How to make a variable available to all templates? (2 answers) I am trying to pass variables (browser variable) to all my templates in my app. Any advice on how to get it to work? View: def browser(request): primary_cat_list = Categories.objects.order_by("category") subcat_list = SubCategories.objects.order_by("sub_category") product = Productbackup.objects.order_by("website") browser = list(chain(primary_cat_list, subcat_list, product)) return render_to_response('reserve/templates/base.html', locals(), context_instance=RequestContext(request))

Fastest way to find the largest power of 10 smaller than x

陌路散爱 提交于 2019-12-03 12:42:39
Is there any fast way to find the largest power of 10 smaller than a given number? I'm using this algorithm, at the moment, but something inside myself dies anytime I see it: 10**( int( math.log10(x) ) ) # python pow( 10, (int) log10(x) ) // C I could implement simple log10 and pow functions for my problems with one loop each, but still I'm wondering if there is some bit magic for decimal numbers. An alternative algorithm is: i = 1; while((i * 10) < x) i *= 10; Log and power are expensive operations. If you want fast, you probably want to look up the IEEE binary exponent in table to get the

实验12

时光总嘲笑我的痴心妄想 提交于 2019-12-03 10:20:01
#include <stdio.h> #include <stdlib.h> #define OK 1 #define ERROR 0 #define NO 0 #define ADD_SIZE 20 #define INIT_SIZE 10 typedef int Status; typedef struct { int *top; int *base; int stacksize; }SqStack; Status InitStack(SqStack *S) { S->base=(int *)malloc(INIT_SIZE*sizeof(int)); if(!S->base) printf("ERROR!\n"); S->top=S->base; S->stacksize=INIT_SIZE; return OK; } Status Push(SqStack *S,int e) { if(S->top-S->base>=S->stacksize) { S->base=(int *)malloc((INIT_SIZE+ADD_SIZE)*sizeof(int)); if(!S->base) printf("ERROR!\n"); S->top=S->base+S->stacksize; S->stacksize+=ADD_SIZE; } *S->top++=e; return

数制转化

眉间皱痕 提交于 2019-12-03 10:19:06
# include <stdio.h> # include <stdlib.h> # include <malloc.h> # define stack_init_size 100 # define stackincrement 10 # define ok 1 # define error 0 struct sqstack{ int *top; int *base; int stacksize; }; int initstack(sqstack &s) { s.base=(int *)malloc(stack_init_size * sizeof(int)); if(!s.base){ return error; } s.top=s.base; s.stacksize=stack_init_size; return ok; } int stackempty(sqstack &s) { if(s.top==s.base){ return ok; } else return error; } int push(sqstack &s,int e) { if((s.top-s.base)>=s.stacksize) { s.base=(int *)realloc(s.base,(s.stacksize+stackincrement)*sizeof(int)); if(!s.base)

IllegalStateException: Expected configuration &#039;:module:debugFeatureCompileClasspath&#039; to contain exactly one file, however, it contains 2 files

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working with multi feature android application with instant app and wear app.Here i am able to successfully run my application but getting following error during building APK or rebuild projects . java.lang.IllegalStateException: Expected configuration ':module1:debugFeatureCompileClasspath' to contain exactly one file, however, it contains 2 files. at org.gradle.api.internal.file.AbstractFileCollection.getSingleFile(AbstractFileCollection.java:62) at com.android.build.gradle.tasks.MergeManifests.doFullTaskAction(MergeManifests.java:116

Proper SCSS Asset Structure in Rails

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So, I have an app/assets/stylesheets/ directory structure that looks something like this: |-dialogs |-mixins |---buttons |---gradients |---vendor_support |---widgets |-pages |-structure |-ui_elements In each directory, there are multiple sass partials (usually *.css.scss, but one or two *.css.scss.erb). I might be assuming a lot, but rails SHOULD automatically compile all the files in those directories because of *= require_tree . in application.css, right? I recently have tried restructuring these files by removing all color variables and

access base class variable in derived class

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: class Program { static void Main ( string [] args ) { baseClass obj = new baseClass (); obj . intF = 5 ; obj . intS = 4 ; child obj1 = new child (); Console . WriteLine ( Convert . ToString ( obj . addNo ())); Console . WriteLine ( Convert . ToString ( obj1 . add ())); Console . ReadLine (); } } public class baseClass { public int intF = 0 , intS = 0 ; public int addNo () { int intReturn = 0 ; intReturn = intF + intS ; return intReturn ; } } class child : baseClass { public int add () { int intReturn = 0 ; intReturn = base . intF *

Type inheritance in F#

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I can't find the proper syntax for coding a type D that inherits a base class B (written in C#) and his constructors other than the base class implicit constructor: C# code: public class B { private int _i ; private float _f ; public B () { _i = 0 ; _f = 0.0f ; } public B ( int i ) { _i = 0 ; _f = 0.0f ; } public B ( int i , float f ) { _i = i ; _f = f ; } } F# code: type D () = inherit B () //how to inherit from other constructors ? Thanks 回答1: I found a way to do it thanks this blog ! type D = class inherit B new () = { inherit B

Efficiency difference between copy and move constructor

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: C++11 introduced a new concept of rvalue reference. I was reading it somewhere and found following: class Base { public: Base() //Default Ctor Base(int t) //Parameterized Ctor Base(const Base& b) //Copy Ctor Base(Base&& b) //Move Ctor }; void foo(Base b) //Function 1 {} void foo(Base& b) //Function 2 {} int main() { Base b(10); foo(b); -- Line 1 (i know of ambiquity but lets ignore for understanding purpose) foo(Base()); -- Line 2 foo(2) ; -- Line 3 } Now with my limited understanding, my observations are as follows : Line 1 will simply call