Skip to content
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

Implement xarray <-> dataset #56

Merged
merged 14 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ os:
- linux
- osx
osx_image: xcode9.1
dist: xenial
services:
- xvfb
install:
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
MINICONDA_VERSION=2 ;
Expand Down
9 changes: 6 additions & 3 deletions .travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ check () {
conda create -n imagej -y python=$TRAVIS_PYTHON_VERSION
source activate imagej
conda env update -f environment.yml
conda install pytest

# -- ensure supporting tools are available --
check curl git unzip
Expand All @@ -41,7 +42,7 @@ fi
case "$(uname -s),$(uname -m)" in
Linux,x86_64) launcher=ImageJ-linux64 ;;
Linux,*) launcher=ImageJ-linux32 ;;
Darwin,*) launcher=Contents/MacOS/ImageJ-macosx ;;
Darwin,*) launcher=Contents/MacOS/ImageJ-macosx; skipGUI=1 ;;
MING*,*) launcher=ImageJ-win32.exe ;;
*) die "Unknown platform" ;;
esac
Expand All @@ -62,7 +63,9 @@ python setup.py install
unset JAVA_HOME

# -- run tests with local Fiji.app --
python -O test/test_imagej.py --ij "$ij_dir"
python -m pytest --ij="$ij_dir"
test "$skipGUI" || python -m pytest --ij="$ij_dir" --headless=false

# -- run tests with ImageJ from Maven repository --
python -m unittest discover test -v
python -m pytest

48 changes: 48 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import imagej
import pytest
import argparse


def pytest_addoption(parser):
"""
Set up the command line parser for IJ location and headless mode
:param parser: pytest's parser, passed in automatically
:return: None
"""
parser.addoption(
"--ij", action="store", default=None, help="directory to IJ"
)
parser.addoption(
"--headless", type=str2bool, action="store", default=True, help="Start in headless mode"
)


@pytest.fixture(scope='session')
def ij_fixture(request):
"""
Create an ImageJ instance to be used by the whole testing environment
:param request: Pytest variable passed in to fixtures
:return: pyimageJ instance
"""
ij_dir = request.config.getoption('--ij')
headless = request.config.getoption('--headless')

ij_wrapper = imagej.init(ij_dir, headless=headless)

return ij_wrapper


def str2bool(v):
"""
Convert string inputs into bool
:param v: A string
:return: Corresponding boolean
"""
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
return False
else:
raise argparse.ArgumentTypeError('Boolean value expected')
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dependencies:
- scyjava
- pillow # for server
- requests # for server
- xarray
Loading