-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
66 lines (50 loc) · 2.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
DMATRICES = X Z Lambdatx Lambdati Lambdatp
FMATRICES = Whalf WX Wy ZtW XtWX XtWy ZtWX ZtWy L Lambdat-new L-new cu RZX DD deviance
DMATRICES_R = $(addsuffix -r.bin, $(DMATRICES))
DMATRICES_PY = $(addsuffix -py.bin, $(DMATRICES))
FMATRICES_R = $(addsuffix -r.bin, $(FMATRICES))
FMATRICES_PY = $(addsuffix -py.bin, $(FMATRICES))
# we can get -0 vs +0, so binary comparison won't work here
define cmp
echo 'Comparing $1 in Python and R...'
python3 cmp.py -a $1-py.bin -b $1-r.bin
endef
check: check_design check_fit
check_fit: lme4pureR $(FMATRICES_R) $(FMATRICES_PY) rand.bin
$(foreach mat,$(FMATRICES),$(call cmp,$(mat)))
$(FMATRICES_PY): data.feather formula.txt rand.bin
echo 'Generating fitting matrices in Python...'
python3 run_pls.py --formula formula.txt --data data.feather \
--randomdata rand.bin
$(FMATRICES_R): data.feather formula.txt rand.bin
echo 'Generating fitting matrices in R...'
Rscript run_pls.r --formula formula.txt --data data.feather \
--randomdata rand.bin
.PHONY: lme4pureR
lme4pureR:
echo 'Reinstalling lme4pureR...'
R CMD INSTALL --no-help --no-byte-compile --no-test-load $@ 2> /dev/null
check_design: $(DMATRICES_PY) $(DMATRICES_R)
$(foreach mat,$(DMATRICES),$(call cmp,$(mat)))
$(DMATRICES_R): data.feather formula.txt
echo 'Generating design matrices in R...'
Rscript build_matrices.r --data data.feather --formula formula.txt \
$(foreach m,$(DMATRICES),--$m $m-r.bin)
$(DMATRICES_PY): data.feather formula.txt
echo 'Generating design matrices in Python...'
python3 build_matrices.py --data data.feather --formula formula.txt \
$(foreach m,$(DMATRICES),--$m $m-py.bin)
# generate a pool of random data we can use for testing
rand.bin:
echo 'Generating random data...'
python3 -c "import numpy as np;\
np.random.seed(42);\
np.random.randn(1<<20).tofile('$@')"
data.feather: columns.txt
echo 'Generating data from list of columns...'
python3 generate_data.py --columns $^ --data $@
setup:
pip3 install -U patsy pandas feather-format scikit-sparse scipy
MAKE='make -j' Rscript -e 'install.packages(c("lme4", "optparse", "feather"), repos="cloud.r-project.org")'
clean:
rm -rf $(wildcard *.feather *.bin __pycache__)