小编gce*_*edo的帖子

Karma和React,有警告导致错误

我正在使用Karmamocha来测试我的React组件.当PropTypes不匹配时,我会显示一些警告.然而,让这些警告引起实际错误将是非常有趣的,以便跟踪测试并修复它.

你知道怎么做到这一点吗?

mocha.js karma-runner reactjs karma-mocha

11
推荐指数
2
解决办法
2160
查看次数

在heroku上部署git子目录

我必须从非主分支部署一个git子目录.我看过这个答案关于Heroku的文档,但是当我发布时

git subtree push --prefix visualizations heroku develop:master
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

error: src refspec d02911f4e410256fae0760f87f186289436ff98b:refs/heads/develop does not match any
Run Code Online (Sandbox Code Playgroud)

我真的不知道该怎么办.

git heroku git-subtree

6
推荐指数
1
解决办法
1688
查看次数

给出距离矩阵的Python中最近的邻居

我必须在Python中应用Nearest Neighbors,我正在寻找广告scikit-learnscipy库,它们都需要数据作为输入,然后计算距离并应用算法.

在我的情况下,我必须计算非常规距离,因此我想知道是否有一种方法可以直接输入距离矩阵.

python machine-learning scipy scikit-learn

5
推荐指数
2
解决办法
2962
查看次数

字符串子序列使用Python的内核和SVM

如何使用Subsequence String Kernel(SSK)[Lodhi 2002]在Python中训练SVM(支持向量机)?

python machine-learning svm supervised-learning

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

Android自定义操作栏未填充父级,标题不对中

我一直在试验以下问题:我创建了一个自定义操作栏:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/com_facebook_blue" >

<TextView 
    android:id="@+id/action_bar_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:maxLines="1"
    android:layout_marginLeft="@dimen/activity_horizontal_margin"
    android:layout_centerInParent="true"
    android:textSize="30dp"
    android:textColor="#ffffff"
    android:text="@string/app_title"/>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是由GraphicsBuilder类以下列方式膨胀:

public static void setupActionBar(String title, Activity a) {

        final ViewGroup actionBarLayout = (ViewGroup) a.getLayoutInflater()
                .inflate(R.layout.action_bar_layout, null);
        final ActionBar actionBar = a.getActionBar();

        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(actionBarLayout);
        final int actionBarColor = a.getResources().getColor(R.color.main_red);
        actionBar.setBackgroundDrawable(new ColorDrawable(actionBarColor));

        TextView tv = (TextView) actionBarLayout.findViewById(R.id.action_bar_title);
        Typeface font = Typeface.createFromAsset(a.getAssets(), "fonts/Molle-Regular.ttf");
        tv.setText(title);
        tv.setTypeface(font);
    }
Run Code Online (Sandbox Code Playgroud)

这导致以下结果(我将标题栏背景保持为蓝色以突出显示问题):

在此输入图像描述

基本上看起来自定义操作栏不会填充父宽度,因此任何尝试在中心对齐标题都是无用的.我怎样才能解决这个问题?

java user-interface android android-actionbar

3
推荐指数
1
解决办法
3480
查看次数