Commit b54137bb authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

First commit

parents
.bash_history
.cache
__pycache__
*.so
FROM python:3
MAINTAINER Matthieu Boileau <matthieu.boileau@math.unistra.fr>
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
RUN apt-get update --fix-missing && \
apt-get install -y \
vim
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN useradd -m -s /bin/bash euler
ENV HOME /home/euler
RUN chown -R euler:euler /home/euler
USER euler
WORKDIR $HOME
CMD /bin/bash
FROM boileaum/pythran:latest
MAINTAINER Matthieu Boileau <matthieu.boileau@math.unistra.fr>
ENV HOME /home/euler
ADD . $HOME/rosen
USER root
RUN chown -R euler:euler /home/euler
WORKDIR $HOME/rosen
USER euler
RUN make clean && make
CMD /bin/bash
version: '2'
services:
env:
build:
context: ../
dockerfile: docker/Dockerfile-pythran
image: boileaum/pythran:latest
user:
build:
context: ../
dockerfile: docker/Dockerfile-rosen
image: boileaum/rosen:latest
depends_on:
- env
# -*- coding: utf-8 -*-
#runas import numpy as np; r = np.arange(0.,10., .01); rosen(r)
#bench import numpy as np; r = np.arange(50000000); rosen(r)
#pythran export rosen(int[])
#pythran export rosen(float[])
import numpy as np
def rosen(x):
t0 = 100 * (x[1:] - x[:-1] ** 2) ** 2
t1 = (1 - x[:-1]) ** 2
return np.sum(t0 + t1)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Test Rosenbrock
"""
from rosenbrock_pythran import rosen as rosen_pythran
from rosenbrock import rosen as rosen_python
from pytest import mark, approx
import numpy as np
r_float = np.arange(0., 10., .01)
expect_float = 152089858.36719903
r_int = np.arange(50000000)
expect_int = 7842832767944603480
param = [(r_float, expect_float), (r_int, expect_int)]
@mark.parametrize('r, result', param)
def test_rosen_python(r, result):
assert rosen_python(r) == approx(result)
@mark.parametrize('r, result', param)
def test_rosen_pythran(r, result):
assert rosen_pythran(r) == approx(result)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment