小编Dri*_*ise的帖子

如何从文件中读取两行并在for循环中创建动态键,后续操作

这个问题遵循问题:如何从文件中读取两行并在for循环中创建动态键?

但是,问题的性质已演变为我想要解决的某种复杂性.

下面是按空格分隔的数据结构.

chr pos         M1  M2  Mk  Mg1  F1_hybrid     F1_PG    F1_block    S1  Sk1   S2    Sj
2   16229767    T/T T/T T/T G/T C|T 1|0 726  .  T/C T/C T/C
2   16229783    C/C C/C C/C A/C G|C 0|1 726 G/C G/C G/C C|G
2   16229992    A/A A/A A/A G/A G|A 1|0 726 A/A A/A A/A A|G
2   16230007    T/T T/T T/T A/T A|T 1|0 726 A|T A|T A|T A|T
2   16230011    G/G G/G G/G G/G C|G 1|0 726 G/C C|G …
Run Code Online (Sandbox Code Playgroud)

python dictionary numpy pandas defaultdict

9
推荐指数
1
解决办法
596
查看次数

为什么C#数组是协变的,它带来了什么好处?

我无法理解为什么C#中的数组是协变的,以及这种协方差带来的好处.考虑以下简单的代码示例:

object[] myArray = new string[1];
myArray[0] = 1;
Run Code Online (Sandbox Code Playgroud)

这段代码可以编译好,但是会毫不客气地在运行时爆炸.

如果我尝试使用泛型尝试同样的事情,编译器会抱怨我,我会在早期阶段意识到我的愚蠢,所以我的问题是:为什么C#编译器允许这种与数组的协方差,而且,什么是潜在的好处?

c# arrays covariance

8
推荐指数
1
解决办法
531
查看次数

Make在更改时不会重建标头

我有一个项目,我经常修改标题,当我这样做,忘记make clean那时make,我得到各种奇怪的行为.我目前正在使用Qt Creator作为我的IDE,但我已经看到这发生在一个独立于Qt的项目上.我的项目变得相当大,每次我更改标题时都必须重建,这种方法正变得无用.有什么想法吗?

备查:

如果使用QMake系统:

DEPENDPATH += . \
    HeaderLocation1/ \
    HeaderLocation2/ \
    HeaderLocation2/HeaderSubLocation1/ \
    HeaderLocation2/HeaderSubLocation2/ \
    HeaderLocation2/HeaderSubLocation3/ \
    HeaderLocation2/HeaderSubLocation4/ \
    HeaderLocation2/HeaderSubLocation5/ \
    HeaderLocation3/ \
    HeaderLocation3/HeaderSubLocation1/ \
    HeaderLocation3/HeaderSubLocation2/ \

c++ qt makefile compilation header-files

8
推荐指数
2
解决办法
6441
查看次数

Android计费 - 在文件Security.java中,base64EncodedPublicKey应该是编码值吗?

我应该将我的应用程序的实际公钥正确粘贴到此变量的值中吗?

或者我应该编码它然后编码的字符串是什么,我将该字符串变成这个变量的值?

应该是哪个?

android android-billing

8
推荐指数
1
解决办法
5939
查看次数

镶嵌点平面

我有一个填充3d点的文件.这些点形成一个平面.这是一个示例文件:

25
1 -1 0
1 -0.5 0
1 0 0
1 0.5 0
1 1 0
0.5 -1 0
0.5 -0.5 0
0.5 0 0
0.5 0.5 0
0.5 1 0
0 -1 0
0 -0.5 0
0 0 0
0 0.5 0
0 1 0
-0.5 -1 0
-0.5 -0.5 0
-0.5 0 0
-0.5 0.5 0
-0.5 1 0
-1 -1 0
-1 -0.5 0
-1 0 0
-1 0.5 0
-1 1 0
Run Code Online (Sandbox Code Playgroud)

编辑:由于我的示例点集太简单了,这里有一个更复杂的例子.

30
-0.298858 …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm math

8
推荐指数
1
解决办法
1298
查看次数

检查 argparse.ArgumentTypeError

我想用来pytest检查是否argparse.ArgumentTypeError为不正确的参数引发异常:

import argparse
import os
import pytest


def main(argsIn):

    def configFile_validation(configFile):
        if not os.path.exists(configFile):
            msg = 'Configuration file "{}" not found!'.format(configFile)
            raise argparse.ArgumentTypeError(msg)
        return configFile

    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--configFile', help='Path to configuration file', dest='configFile', required=True, type=configFile_validation)
    args = parser.parse_args(argsIn)


def test_non_existing_config_file():
    with pytest.raises(argparse.ArgumentTypeError):
        main(['--configFile', 'non_existing_config_file.json'])
Run Code Online (Sandbox Code Playgroud)

但是, runningpytestDuring handling of the above exception, another exception occurred:,因此测试失败。我究竟做错了什么?

python pytest argparse

8
推荐指数
1
解决办法
1591
查看次数

Scala AKKA Actor的错误消息

这是我的代码:

class testActor extends Actor   {
    var test = "test2"
    def receive = {
            case "test" ?
                    "works"
    }
} 

def test = Action {
    var test = "test"
    val system = ActorSystem("MySystem")
    val myActor = system.actorOf(Props[testActor.testActor], name = "testActor")

    test = Await.result(myActor ? "test", Duration(1, TimeUnit.SECONDS))
}
Run Code Online (Sandbox Code Playgroud)

我收到这行错误:

test = Await.result(myActor ? "test", Duration(1, TimeUnit.SECONDS))
Run Code Online (Sandbox Code Playgroud)

错误是:

找不到参数超时的隐含值:akka.util.Timeout

scala akka

7
推荐指数
1
解决办法
5700
查看次数

作业.C++ Book Example似乎有问题

以下代码是我的C++类幻灯片的一部分.IntelliSence给了我错误,我不知道为什么.不知道为什么它不喜欢构造函数和析构函数.有人可以帮忙吗?

class Vehicle {
     friend void guest();
 private:
     string make;
     string model;
     int year;
 public:
     void Vehicle();
     void Vehicle(string, string, int);
     void ~Vehicle();
     string getMake();
 }

 void guest() {
     cout << make;
 }

 1) IntelliSense: member function with the same name as its class must be a constructor
 2) IntelliSense: member function with the same name as its class must be a constructor
 3) IntelliSense: return type may not be specified on a destructor
Run Code Online (Sandbox Code Playgroud)

c++

7
推荐指数
1
解决办法
1735
查看次数

制作快速端口扫描仪

所以我在python中制作一个端口扫描器......

import socket
ip = "External IP"
s = socket.socket(2, 1) #socket.AF_INET, socket.SOCK_STREAM

def porttry(ip, port):
    try:
        s.connect((ip, port))
        return True
    except:
        return None

for port in range(0, 10000):
    value = porttry(ip, port)
    if value == None:
        print("Port not opened on %d" % port)
    else:
        print("Port opened on %d" % port)
        break
raw_input()
Run Code Online (Sandbox Code Playgroud)

但这太慢了,我想以某种方式能够在一段时间内没有返回任何内容之后有多接近或破坏代码.

python sockets port port-scanning

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

移位插值不会产生预期的行为

当使用scipy.ndimage.interpolation.shift使用周期性边界处理(mode = 'wrap')沿一个轴移动numpy数据数组时,我得到一个意外的行为.例程尝试强制第一个pixel(index 0)与最后一个(index N-1)相同而不是"last plus one(index N)".

最小的例子:

# module import
import numpy as np
from scipy.ndimage.interpolation import shift
import matplotlib.pyplot as plt

# print scipy.__version__
# 0.18.1

a = range(10)

plt.figure(figsize=(16,12))

for i, shift_pix in enumerate(range(10)):
    # shift the data via spline interpolation
    b = shift(a, shift=shift_pix, mode='wrap')

    # plotting the data
    plt.subplot(5,2,i+1)
    plt.plot(a, marker='o', label='data')
    plt.plot(np.roll(a, shift_pix), marker='o', label='data, roll')
    plt.plot(b, marker='o',label='shifted data')
    if i == 0: …
Run Code Online (Sandbox Code Playgroud)

python interpolation scipy ndimage

7
推荐指数
1
解决办法
350
查看次数