想象一个离散的x,y,z空间:我正在尝试创建一个迭代器,它将返回位于距点一定径向距离的球体内的所有点.
我的方法是先看一个更大的立方体内的所有点,保证包含所需的所有点,然后剔除或跳过太远的点.
我的第一次尝试是:
x,y,z=(0,0,1)
dist=2
#this doesn't work
it_0=((x+xp,y+yp,z+zp) for xp in range(-dist,dist+1) for yp in range(-dist,dist+1) for zp in range(-dist,dist+1) if ( ((x-xp)**2+(y-yp)**2+(z-zp)**2) <= dist**2+sys.float_info.epsilon ) )
Run Code Online (Sandbox Code Playgroud)
一个简单的
for d,e,f in it_0:
#print(d,e,f)
print( ((x-d)**2+(y-e)**2+(z-f)**2) <= dist**2+sys.float_info.epsilon, d,e,f)
Run Code Online (Sandbox Code Playgroud)
验证it_0不会产生正确的结果.我相信它只是将条件应用于第三个(即:z)'for'子句
以下作品:
it_1=((x+xp,y+yp,z+zp) for xp in range(-dist,dist+1) for yp in range(-dist,dist+1) for zp in range(-dist,dist+1))
it_2=filter( lambda p: ((x-p[0])**2+(y-p[1])**2+(z-p[2])**2) <= dist**2+sys.float_info.epsilon, it_1)
Run Code Online (Sandbox Code Playgroud)
它收集所有点,然后过滤那些不符合条件的点.
我希望可能有一种方法可以纠正第一次尝试的实现,或者使这些表达式更具可读性或紧凑性.
我无法克隆或推送到我的服务器上的存储库。
我有一个裸存储库,它位于我尝试通过 访问的user@host目录中的一个目录。我曾经添加过我的 ssh 密钥。它要求我提供密码。然后我就可以成功了。home/user/test.gitgit clonessh-add <pathtokey>ssh user@host
但是,如果我尝试这样做,git clone ssh://user@host/~/test.git我会得到:
Cloning into 'test'...
user@host: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
也尝试过
git clone ssh://user@host/home/user/test.gitgit clone user@host:home/user/test.gitgit clone user@host:/home/user/test.git结果相同
我猜 git 凭证管理器没有拿起密钥?
服务器上/var/auth/log说
Feb 20 02:25:36 xxxxx sshd[24674]: Connection closed by authenticating user XXXX x.x.x.x port 56433 [preauth]
git …