如何解决堆栈:检测到随机依赖性周期
stack.yaml
的内容如下:
resolver: lts-16.19
packages:
- .
extra-deps:
- text-1.2.4.0
- random-1.2.0
- git: https://github.com/LeventErkok/sbv.git # sbv
commit: 4f4baa7b5970ef2ab9b322c6694bf9df6ccdbc4b
- git: https://github.com/bos/aeson # aeson
commit: 8579faf30e0f977425fbf330038fb1d5c2c34727
- data-fix-0.3.0@sha256:058a266d1e658500e0ffb8babe68195b0ce06a081dcfc3814afc784b083fd9a5,1645
- strict-0.4@sha256:1b50c7c9c636c3a1bbc7f8873b9be48f6ca0faca4df6eec6a014de6208fb1c0e,4200
test
具有以下部分:
executable test
hs-source-dirs: src
main-is: Main.hs
default-language: Haskell2010
build-depends: text,random,sbv,aeson,base >= 4.7 && < 5
我添加了text
和random
,因为如果不这样做,则在运行stack ghci
时会出现以下错误:
Could not load module ‘Data.Text’
Could not load module ‘System.Random’
但是现在,在上面添加了这些软件包的情况下,Stack抱怨循环依赖:
$ stack setup
$ stack ghci
Error: While constructing the build plan,the following exceptions were encountered:
In the dependencies for QuickCheck-2.13.2:
random dependency cycle detected: random,splitmix,uuid-types,test
needed due to test-0.1.0.0 -> QuickCheck-2.13.2
In the dependencies for test-0.1.0.0:
random dependency cycle detected: random,test
needed since test is a build target.
Dependency cycle detected in packages:
[random,test]
In the dependencies for sbv-8.8.5:
random dependency cycle detected: random,test
needed due to test-0.1.0.0 -> sbv-8.8.5
In the dependencies for splitmix-0.0.5:
random dependency cycle detected: random,test
needed due to test-0.1.0.0 -> splitmix-0.0.5
Some different approaches to resolving this:
Error: Plan construction Failed.
根据错误消息,看起来splitmix
和random
之间有一个循环。我只问了random
,所以不确定如何解决这个问题。
任何解决此问题并使导入工作的方式都可以避免此循环导入问题,将不胜感激。
解决方法
最新的splitmix
与lts-16.19
快照中的旧版本的splitmix
不兼容。在extra-deps
中添加新版本的extra-deps:
- ... # your other extra-deps
- splitmix-0.1.0.3
:
import numpy as np
import random
data=np.load("olivetti_faces.npy")
target=np.load("olivetti_faces_target.npy")
# target is groups of 10,so select random index in each block
for i in range(40): # class 0-39
rndindex.append(i*10 + random.randint(0,9)) # one per class
for i in range(60): # up to 100
idx = rndindex[0]
while idx in rndindex: # prevent duplicates
idx = random.randint(0,399) # other indexes can be anywhere
rndindex.append(idx)
rand_indeces = [] # np array objects
for idx in rndindex:
rand_indeces.append(data[idx])
print(rndindex)
#print(rand_indeces)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。