如何将Java Date转换为double代表Julian日的Java ?
如何将Julian日数转换为Java Date?
public static double dateToJulian(Date date) {
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
int year;
int month;
float day;
int a;
int b;
double d;
double frac;
frac = (calendar.get(Calendar.HOUR_OF_DAY) / 0.000024 + calendar.get(Calendar.MINUTE) / 0.001440);
b = 0;
year = calendar.get(Calendar.YEAR);
month = calendar.get(Calendar.MONTH) + 1;
DecimalFormat ceroPlaces = new DecimalFormat("0");
day = calendar.get(Calendar.DAY_OF_MONTH);
day = Float.parseFloat(ceroPlaces.format(day) + "." + ceroPlaces.format(Math.round(frac)));
if (month < 3) {
year--;
month += 12;
} …Run Code Online (Sandbox Code Playgroud) 我git svn在我的本地机器上使用与SVN仓库同步.
最近,我团队中的某个人在SVN仓库中添加了一些实验性内容(他试图添加一些标签),并在下一次提交中将其删除.在此之后,我的git svn拒绝获取.它只是到了某个点并且一直停留在那里.
无论如何,我不想将所有实验内容都提取到本地机器中.所以,我想忽略 SVN存储库中的某些提交.这有可能git svn吗?
我正在为命令行工具编写一个bash完成脚本:
_plink()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--1 --23file --a1-allele --a2-allele --adjust --aec"
if [[ ${cur} == --*file ]] || [[ ${cur} == --out ]]; then
COMPREPLY=( $(compgen -W "$(ls)" -- ${cur}) )
elif [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F _plink plink1.9
Run Code Online (Sandbox Code Playgroud)
这个想法是,如果选项--*file和--outbash之后应该自动完成文件路径.现在我正在使用" $(ls)",它只完成当前工作路径中的文件名.有什么建议?
我正在使用TfidfVectorizer将原始文档的集合转换为TF-IDF特征的矩阵,然后我计划将其输入到k-means算法(我将实现).在该算法中,我将不得不计算质心(文章类别)和数据点(文章)之间的距离.我将使用欧几里德距离,所以我需要这两个实体具有相同的尺寸,在我的情况下max_features.这是我有的:
tfidf = TfidfVectorizer(max_features=10, strip_accents='unicode', analyzer='word', stop_words=stop_words.extra_stopwords, lowercase=True, use_idf=True)
X = tfidf.fit_transform(data['Content']) # the matrix articles x max_features(=words)
for i, row in enumerate(X):
print X[i]
Run Code Online (Sandbox Code Playgroud)
然而,X似乎是一个稀疏(?)矩阵,因为输出是:
(0, 9) 0.723131915847
(0, 8) 0.090245047798
(0, 6) 0.117465276892
(0, 4) 0.379981697363
(0, 3) 0.235921470645
(0, 2) 0.0968780456528
(0, 1) 0.495689001273
(0, 9) 0.624910843051
(0, 8) 0.545911131362
(0, 7) 0.160545991411
(0, 5) 0.49900042174
(0, 4) 0.191549050212
...
Run Code Online (Sandbox Code Playgroud)
当我想的(0, col)状态列索引的矩阵,这实际上就像一个阵列,每一个细胞都指向一个列表,其中.
如何将此矩阵转换为密集矩阵(以便每行具有相同的列数)?
>print type(X)
<class 'scipy.sparse.csr.csr_matrix'>
Run Code Online (Sandbox Code Playgroud) 我的意见是:
input = ['(var1, )', '(var2,var3)']
Run Code Online (Sandbox Code Playgroud)
预期产出是:
output = [('var1', ), ('var2','var3')]
Run Code Online (Sandbox Code Playgroud)
迭代输入并在元组字符串上使用eval/ literal_eval是不可能的:
>>> eval('(var1, )')
>>> NameError: name 'var1' is not defined
Run Code Online (Sandbox Code Playgroud)
如何将项目转换为'(var1, )'元组,其中内部对象被视为字符串而不是变量?
有没有比编写解析器或使用正则表达式更简单的方法?
我按照这些代码批量PutObject进入S3.我使用的是最新的PHP SDK(3.x).但我得到:
传递给Aws\AwsClient :: execute()的参数1必须实现接口Aws\CommandInterface,给出数组
$commands = array();
$commands[] = $s3->getCommand('PutObject', array(
'Bucket' => $bucket,
'Key' => 'images/1.jpg',
'Body' => base64_decode( 'xxx' ),
'ACL' => 'public-read',
'ContentType' => 'image/jpeg'
));
$commands[] = $s3->getCommand('PutObject', array(
'Bucket' => $bucket,
'Key' => 'images/2.jpg',
'Body' => base64_decode( 'xxx' ),
'ACL' => 'public-read',
'ContentType' => 'image/jpeg'
));
// Execute the commands in parallel
$s3->execute($commands);
Run Code Online (Sandbox Code Playgroud) 这是我的代码:
switch(age) {
case 10:
System.out.println("You are too young to drive.");
break;
case 20:
System.out.println("You can drive!");
break;
default:
System.out.println("Error");
}
Run Code Online (Sandbox Code Playgroud)
如果年龄是15岁会怎么样?好吧,它给了我一个错误.所以我想知道是否有可能在案件中包含一个条件.例如,
case (age>=10 && age<=20):
System.out.println("You're still too young to drive...");
break;
Run Code Online (Sandbox Code Playgroud)
我可以使用if语句,但我想知道这是否可以通过一个开关.
我从以下网址下载并安装了php7:http://windows.php.net/qa/#php-7.0-ts-VC14-x64
的PHP代码运行正常。我无法使用“ mysqli”类连接数据库。它说“找不到类'mysqli'”。我没有评论:php.ini文件中的extension = php_mysqli.dll。我在安装php7时没有错过任何东西吗?
谢谢
有这样的代码
numbers = '1 2 3 4 5 6 7 8'
nums = {'evens': [], 'odds': []}
for number in numbers.split(' '):
if int(number) % 2:
nums['odds'].append(number)
else:
nums['evens'].append(number)
Run Code Online (Sandbox Code Playgroud)
如何在更少的线上完成相同的工作?
python ×4
java ×2
amazon-s3 ×1
autocomplete ×1
aws-php-sdk ×1
aws-sdk ×1
bash ×1
date ×1
git ×1
git-svn ×1
julian-date ×1
mysqli ×1
numpy ×1
php-7 ×1
scikit-learn ×1
scipy ×1
shell ×1
tf-idf ×1