-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add loom package #3
Changes from 1 commit
8ae0e5e
185bceb
e2c348d
b6e4bad
b530fde
2501750
6802132
1e41a13
d4f6b3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
result | ||
result-* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- a/examples/mixture/main.py | ||
+++ b/examples/mixture/main.py | ||
@@ -30,6 +30,7 @@ | ||
import numpy | ||
import scipy | ||
import scipy.misc | ||
+import imageio | ||
import scipy.ndimage | ||
from distributions.dbg.random import sample_discrete, sample_discrete_log | ||
from distributions.lp.models import nich | ||
@@ -45,7 +46,7 @@ | ||
DATA = os.path.join(ROOT, 'data') | ||
RESULTS = os.path.join(ROOT, 'results') | ||
SAMPLES = os.path.join(DATA, 'samples.json.gz') | ||
-IMAGE = scipy.misc.imread(os.path.join(ROOT, 'fox.png')) | ||
+IMAGE = imageio.imread(os.path.join(ROOT, 'fox.png')) | ||
SAMPLE_COUNT = 10000 | ||
PASSES = 10 | ||
EMPTY_GROUP_COUNT = 10 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
fetchFromGitHub, | ||
callPackage, | ||
fetchPypi, | ||
eigen, | ||
parsable, | ||
goftests, | ||
protobuf3_20, | ||
python3Packages, | ||
}: | ||
let | ||
version = "2.2.1"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "posterior"; | ||
repo = "distributions"; | ||
rev = "c2a9dccb09ab525927037ed59f3ceffb38e8a995"; # there is no tag | ||
sha256 = "sha256-KP8o5w0PKdcwgmQJqRBRmEPrHesHvPQCp+g22mk5wOs="; | ||
}; | ||
|
||
distributions-shared = callPackage ./distributions-shared.nix { inherit version src; }; | ||
|
||
imageio = python3Packages.buildPythonPackage rec { | ||
pname = "imageio"; | ||
version = "2.6.1"; | ||
|
||
src = fetchPypi { | ||
inherit pname version; | ||
hash = "sha256-9E6yMbnfSFh08v/SLf0MPHEefeB2UWuTdO3qXGW8Z64="; | ||
}; | ||
|
||
doCheck = false; | ||
|
||
nativeBuildInputs = with python3Packages; [ | ||
pytest | ||
]; | ||
|
||
propagatedBuildInputs = with python3Packages; [ | ||
pillow | ||
]; | ||
|
||
buildInputs = with python3Packages; [ | ||
enum34 | ||
numpy | ||
]; | ||
}; | ||
in | ||
python3Packages.buildPythonPackage { | ||
pname = "distributions"; | ||
|
||
inherit version src; | ||
|
||
nativeBuildInputs = [ | ||
protobuf3_20 | ||
python3Packages.pyflakes | ||
]; | ||
|
||
buildInputs = [ | ||
eigen | ||
# TODO: we're not sure if this is even needed | ||
distributions-shared | ||
protobuf3_20 | ||
]; | ||
|
||
propagatedBuildInputs = with python3Packages; [ | ||
protobuf3_20 | ||
cython | ||
numpy | ||
parsable | ||
scipy | ||
simplejson | ||
]; | ||
|
||
# TODO: be more precise. Some tests seem to be still in Python 2. | ||
doCheck = false; | ||
nativeCheckInputs = with python3Packages; [ | ||
imageio | ||
nose | ||
goftests | ||
]; | ||
|
||
preBuild = '' | ||
make protobuf | ||
''; | ||
|
||
patches = [ | ||
#./distributions-01-imread.patch | ||
]; | ||
|
||
DISTRIBUTIONS_USE_PROTOBUF = 1; | ||
|
||
# https://github.com/numba/numba/issues/8698#issuecomment-1584888063 | ||
NUMPY_EXPERIMENTAL_DTYPE_API = 1; | ||
|
||
pythonImportsCheck = [ | ||
"distributions" | ||
"distributions.io" | ||
"distributions.io.stream" | ||
]; | ||
|
||
passthru = { | ||
# TODO: we're not sure if this is even needed | ||
inherit distributions-shared; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
stdenv, | ||
cmake, | ||
eigen, | ||
protobuf3_20, | ||
src, version | ||
}: | ||
stdenv.mkDerivation { | ||
pname = "distributions-shared"; | ||
|
||
inherit version src; | ||
|
||
nativeBuildInputs = [ cmake ]; | ||
buildInputs = [eigen protobuf3_20 ]; | ||
|
||
DISTRIBUTIONS_USE_PROTOBUF = 1; | ||
|
||
preConfigure = '' | ||
make protobuf | ||
''; | ||
|
||
fixupPhase = '' | ||
ln -sv $out/lib/libdistributions_shared_release.so $out/lib/libdistributions_shared.so | ||
ln -sv $out/lib/libdistributions_shared_release.so $out/lib/libdistributions_shared_debug.so | ||
''; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ fetchFromGitHub }: | ||
fetchFromGitHub { | ||
owner = "posterior"; | ||
repo = "distributions"; | ||
rev = "c2a9dccb09ab525927037ed59f3ceffb38e8a995"; | ||
sha256 = "sha256-KP8o5w0PKdcwgmQJqRBRmEPrHesHvPQCp+g22mk5wOs="; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
fetchPypi, | ||
python3Packages, | ||
}: | ||
python3Packages.buildPythonPackage rec { | ||
pname = "goftests"; | ||
version = "0.2.7"; | ||
format = "setuptools"; | ||
|
||
src = fetchPypi { | ||
inherit pname version; | ||
hash = "sha256-5s0NugSus2TuZIInesCNJNAtxEHnZLQIjn0pxGgwL/o="; | ||
}; | ||
|
||
buildInputs = with python3Packages; [ numpy scipy ]; | ||
|
||
doCheck = false; | ||
|
||
# https://github.com/numba/numba/issues/8698#issuecomment-1584888063 | ||
NUMPY_EXPERIMENTAL_DTYPE_API = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does nix handle these arbitrary keys at the top level in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be set as an environment variable in the builder context of the derivation's various phases. Gonna change this to |
||
|
||
patchPhase = '' | ||
mkdir -p dist | ||
''; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this abstraction, but it looks like it's not called. What's the best way to import and invoke it? And what's more idiomatic -- src.nix or included in default.nix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this file was accidentally left in from an earlier iteration, it made more sense in the end to just declare it in a
let
and then pass it into thecallPackage
args ofdistributions-shared
. More idiomatic to have it in the default.nix as alet
binding and then pass it to both places it's used. I've removed this file now.