Skip to content
Snippets Groups Projects
Commit 8ba826a0 authored by Fengshan Zheng's avatar Fengshan Zheng
Browse files

pull

parent 3239d34c
No related branches found
No related tags found
No related merge requests found
Showing
with 103 additions and 48 deletions
image: "python:3.5"
before_script:
# Check and print Python version
- python --version
# Create SSH configuration directory if necessary (also parents with -p, mode: read/write/exec):
- mkdir -p --mode=700 ~/.ssh/
# Add SSH key for jutil:
- echo "$ID_RSA_JUTIL_PRIVATE" > ~/.ssh/id_rsa_jutil
# Provide read access to owner (octal value code: 400) to jutil key and known_hosts with chmod:
- chmod 400 ~/.ssh/id_rsa_jutil
# Configure SSH to use ~/.ssh/jutil_key for iffgit.fz-juelich.de (-e allows \n):
- echo -e "Host iffgit.fz-juelich.de\n\tIdentityFile ~/.ssh/id_rsa_jutil\n" > ~/.ssh/config
# Add iffgit.fz-juelich.de to known_hosts (not the same key as Jutil!):
- echo iffgit.fz-juelich.de,134.94.161.83 "$ID_RSA_IFFGIT_PUBLIC" > ~/.ssh/known_hosts
# Provide read access to owner (octal value code: 400) to known_hosts with chmod:
- chmod 400 ~/.ssh/known_hosts
# Install jutil via secure ssh connection:
- pip install git+ssh://gitlab@iffgit.fz-juelich.de/unger/jutil.git
stages:
- test
test:
before_script:
# Create SSH configuration directory if necessary (also parents with -p, mode: read/write/exec):
- mkdir -p --mode=700 ~/.ssh/
# Add SSH key for jutil:
- echo "$ID_RSA_JUTIL_PRIVATE" > ~/.ssh/id_rsa_jutil
# Provide read access to owner (octal value code: 400) to jutil key and known_hosts with chmod:
- chmod 400 ~/.ssh/id_rsa_jutil
# Configure SSH to use ~/.ssh/jutil_key for iffgit.fz-juelich.de (-e allows \n):
- echo -e "Host iffgit.fz-juelich.de\n\tIdentityFile ~/.ssh/id_rsa_jutil\n" > ~/.ssh/config
# Add iffgit.fz-juelich.de to known_hosts (not the same key as Jutil!):
- echo iffgit.fz-juelich.de,134.94.161.83 "$ID_RSA_IFFGIT_PUBLIC" > ~/.ssh/known_hosts
# Provide read access to owner (octal value code: 400) to known_hosts with chmod:
- chmod 400 ~/.ssh/known_hosts
# Install necessary apps like git and mesa-utils (needed for GL):
# TODO: Check if this is still needed after removing mayavi!?
- apt-get update
- apt-get install -y curl bzip2 git mesa-utils
test_miniconda:
stage: test
image: continuumio/miniconda3
script:
# TODO: Different jobs with custom develop arguments? extra_requires (hyperspy, plotting)?
# TODO: Use pip install -e .[hyperspy], etc.
# Install requirements:
# - pip install -r requirements.txt # TODO: DOES NOT WORK (because mayavi and stuff...)
- pip install -e .['tests']
# Install requirements for pyramid:
- conda info --envs
- conda env create -q # -q: quiet/ no progressbar, because it spams the log!
- source activate pyramid
- conda info --envs
- conda uninstall mayavi vtk -y # TODO: necessary, because mayavi does not play nice with qt5!
- conda install pyqt=5 # TODO: This is needed for tests to run, but breaks mayavi (not used)!
# Install jutil via secure ssh connection:
- pip install git+ssh://gitlab@iffgit.fz-juelich.de/unger/jutil.git
# Execute tests:
- python setup.py test
# Create coverage report:
- coverage html
artifacts:
paths:
- htmlcov/
test_conda_ubuntu:
stage: test
image: ubuntu:16.04
script:
# Install miniconda:
- curl -O -L https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
- chmod +x Miniconda3-latest-Linux-x86_64.sh
- ./Miniconda3-latest-Linux-x86_64.sh -b -p /opt/miniconda3
- export PATH="/opt/miniconda3/bin:${PATH}"
# Install requirements for pyramid:
- conda info --envs
- conda env create -q # -q: quiet/ no progressbar, because it spams the log!
- source activate pyramid
- conda info --envs
- conda uninstall mayavi vtk -y # TODO: necessary, because mayavi does not play nice with qt5!
- conda install pyqt=5 # TODO: This is needed for tests to run, but breaks mayavi (not used)!
# Install jutil via secure ssh connection:
- pip install git+ssh://gitlab@iffgit.fz-juelich.de/unger/jutil.git
# Execute tests:
- python setup.py test
test_pip_minimal:
stage: test
image: python:3.5
script:
# TODO: Different jobs with custom develop arguments? extra_requires (hyperspy, plotting)?
# TODO: Use pip install -e .[hyperspy], etc.
# Install requirements:
- pip install -e .['tests'] # TODO: other case with ['all']? After getting rid of mayavi...
# Install jutil via secure ssh connection:
- pip install git+ssh://gitlab@iffgit.fz-juelich.de/unger/jutil.git
# Execute tests:
- python setup.py test
test_pip_requirements:
stage: test
image: python:3.5
script:
# Install requirements:
- pip install -r requirements.txt # TODO: mayavi/pyfftw commented out by hand to make work!
# Install jutil via secure ssh connection:
- pip install git+ssh://gitlab@iffgit.fz-juelich.de/unger/jutil.git
# Execute tests:
- python setup.py test
# TODO: What about windows? Better have one test (miniconda?) for windows/max/linux, each!
......@@ -2,6 +2,7 @@
# This file contains the top level dependencies of the pyramid project!
# requirements.txt also contains sub-dependencies, generated by "pip freeze > requirements.txt"!
# Add new dependencies here, then "conda env update", then "pip freeze > requirements.txt"!
# To see if compatible upgrades are available for the current packages, use "conda upgrade --all"!
# When packages are deprecated/deleted, it may be best to recreate the environment from scratch!
name: pyramid
......@@ -23,13 +24,13 @@ dependencies:
# File IO:
- hyperspy=1.3
- hyperspy-gui-ipywidgets=1.0
- hyperspy-gui-traitsui=1.0 # TODO: Optional! Delete when mayavi is gone!
# - hyperspy-gui-traitsui=1.0 # TODO: Optional! Delete when mayavi is gone!
- h5py=2.7
# Plotting and colors: # TODO: Shift to plotting package?
- matplotlib=2.0 # Only works with qt4 from conda-forge channel!
- matplotlib=2.0 # Only conda-forge channel has working version for qt4!
- Pillow=4.1
- cmocean=1.1
- qt=4.8 # Necessary because of traits in mayavi...
- qt=4.8 # Necessary because of traits in mayavi... On server, pyqt=5.6 is needed!
- mayavi=4.5 # TODO: Get rid of!
#- colorspacious # TODO: NOT USED?
#- visvis # TODO: NOT USED?
......@@ -50,9 +51,3 @@ dependencies:
# - pip:
# # ALSO NEEDS JUTIL!
# - "git+ssh://gitlab@iffgit.fz-juelich.de/unger/jutil.git"
#
# # FOLLOWING NOT USED ANYMORE, CONDA WORKS, TOO (with appropriate channels):
# # Install pyFFTW=0.10 from wheel:
# - http://www.lfd.uci.edu/~gohlke/pythonlibs/pyFFTW‑0.10.4‑cp35‑cp35m‑win_amd64.whl
# # Install mayavi=4.5 and VTK from wheel:
# - http://www.lfd.uci.edu/~gohlke/pythonlibs/mayavi‑4.5.0+vtk71‑cp35‑cp35m‑win_amd64.whl
......@@ -164,8 +164,7 @@ def phase_mag_sphere(dim, a, phi, center, radius, b_0=1):
r = np.hypot(x - x0, y - y0)
result = coeff * R ** 3 / (r + 1E-30) ** 2 * (
(y - y0) * np.cos(phi) - (x - x0) * np.sin(phi))
# TODO: During testing: "RuntimeWarning: invalid value encountered in power":
result *= np.where(r > R, 1, (1 - (1 - (r / R) ** 2) ** (3. / 2.)))
result *= 1 - np.clip(1 - (r / R) ** 2, 0, 1) ** (3. / 2.)
return result
# Process input parameters:
......
......@@ -155,11 +155,15 @@ def _load_from_ovf(filename, a):
field = np.asarray((x_mag, y_mag, z_mag)) * float(header.get('valuemultiplier', 1))
if a is None:
# TODO: If transferred to HyperSpy, this has to stay in Pyramid reader!
if not header.get('xstepsize') == header.get('ystepsize') == header.get('zstepsize'):
_log.warning('Grid spacing is not equal in x, y and z (x will be used)!')
a = float(header.get('xstepsize', 1.))
meshunit = header.get('meshunit', 'nm')
a *= {'m': 1e9, 'mm': 1e6, 'µm': 1e3, 'nm': 1}[meshunit] # Conversion to nm
xstep = float(header.get('xstepsize'))
ystep = float(header.get('ystepsize'))
zstep = float(header.get('zstepsize'))
if not np.allclose(xstep, ystep) and np.allclose(xstep, zstep):
_log.warning('Grid spacing is not equal in x, y and z (x will be used)!\n'
'Found step sizes are x:{}, y:{}, z:{} (all in {})!'.format(
xstep, ystep, zstep, header.get('meshunit')))
# Extract grid spacing from xstepsize and convert according to meshunit:
a = xstep * {'m': 1e9, 'mm': 1e6, 'µm': 1e3, 'nm': 1}[header.get('meshunit', 'nm')]
return VectorData(a, field)
......
......@@ -101,15 +101,18 @@ class Kernel(object):
u = np.linspace(-(u_dim - 1), u_dim - 1, num=2 * u_dim - 1)
v = np.linspace(-(v_dim - 1), v_dim - 1, num=2 * v_dim - 1)
uu, vv = np.meshgrid(u, v)
# TODO: u, v are coordinates, rename self.u/v to self.kern_u/v!
self.u = np.empty(self.dim_kern, dtype=dtype)
self.v = np.empty(self.dim_kern, dtype=dtype)
self.u[...] = coeff * self._get_elementary_phase(geometry, uu, vv, a)
# TODO: The minus sign belongs into the phasemapper (debatable)!
self.v[...] = coeff * -self._get_elementary_phase(geometry, vv, uu, a)
# Include perturbed reference wave:
if prw_vec is not None:
uu += prw_vec[1]
vv += prw_vec[0]
self.u[...] -= coeff * self._get_elementary_phase(geometry, uu, vv, a)
# TODO: The minus sign belongs into the phasemapper (debatable)!
self.v[...] -= coeff * -self._get_elementary_phase(geometry, vv, uu, a)
# Calculate Fourier trafo of kernel components:
self.u_fft = fft.rfftn(self.u, self.dim_pad)
......@@ -128,6 +131,7 @@ class Kernel(object):
def _get_elementary_phase(self, geometry, n, m, a):
self._log.debug('Calling _get_elementary_phase')
# TODO: Rename n m to p q ?
if geometry == 'disc':
in_or_out = ~ np.logical_and(n == 0, m == 0)
return m / (n ** 2 + m ** 2 + 1E-30) * in_or_out
......
......@@ -28,13 +28,14 @@ FIGSIZE_DEFAULT = (6.7, 5) # TODO: Apparently does not fit as well as before...
FONTSIZE_DEFAULT = 20
STROKE_DEFAULT = None
# TODO: Replace by matplotlib styles!
def pretty_plots(figsize=None, fontsize=None, stroke=None):
"""Set IPython formats (for interactive and PDF output) and set pretty matplotlib font."""
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('png', 'pdf') # png for interactive, pdf, for PDF output!
mpl.rcParams['mathtext.fontset'] = 'stix' # Mathtext in $...$!
mpl.rcParams['font.family'] = 'STIXGeneral' # Set normal text to look the same!
# TODO: set 'font.size' = FONTSIZE! Does this change everything relative to this value???
mpl.rcParams['figure.max_open_warning'] = 0 # Disable Max Open Figure warning!
if figsize is not None:
global FIGSIZE_DEFAULT
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -32,7 +32,7 @@ test=pytest
branch = True
source = pyramid
omit =
pyramid/tests/*
tests/*
[tool:pytest]
addopts = --cov --flake8
......
......@@ -7,7 +7,7 @@ import re
import subprocess
import sys
import itertools
from distutils.command.build import build
#from distutils.command.build import build
#import numpy
from setuptools import setup, find_packages
......@@ -150,8 +150,8 @@ extras_require["all"] = list(itertools.chain(*list(extras_require.values())))
print('\n-------------------------------------------------------------------------------')
print('checking requirements')
check_requirements()
# print('checking requirements') # TODO: Get rid of!
# check_requirements()
print('write version.py')
write_version_py()
setup(name=DISTNAME,
......@@ -168,6 +168,6 @@ setup(name=DISTNAME,
#tests_require=['pytest', 'pytest-cov', 'pytest-flake8'],
install_requires=install_requires,
extras_require=extras_require,
cmdclass={'build': build} # TODO: necessary?
#cmdclass={'build': build} # TODO: necessary?
)
print('-------------------------------------------------------------------------------\n')
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment