Skip to content

Commit

Permalink
Merge pull request #44 from skylarjhdownes/master
Browse files Browse the repository at this point in the history
pep8 fixes and dependency documentation
  • Loading branch information
decarlof committed Dec 6, 2016
2 parents a061117 + 80c2e2f commit 2156024
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 41 deletions.
16 changes: 9 additions & 7 deletions doc/source/install.rst
Expand Up @@ -2,7 +2,7 @@
Install
=======

This section covers the basics of how to download and install
This section covers the basics of how to download and install
`DXchange <https://github.com/data-exchange/dxchange>`_.

.. contents:: Contents:
Expand All @@ -11,8 +11,8 @@ This section covers the basics of how to download and install

Installing from source
======================
Clone the `DXchange <https://github.com/data-exchange/dxchange>`_

Clone the `DXchange <https://github.com/data-exchange/dxchange>`_
from `GitHub <https://github.com>`_ repository::

git clone https://github.com/data-exchange/dxchange.git dxchange
Expand All @@ -22,11 +22,13 @@ then::
cd dxchange
python setup.py install

DXchange is dependent on other libraries, listed in the requirements.txt and
meta.yaml files.

Installing from Conda/Binstar
=============================

First you must have `Conda <http://continuum.io/downloads>`_
First you must have `Conda <http://continuum.io/downloads>`_
installed, then open a terminal or a command prompt window and run::

conda install -c dgursoy dxchange
Expand All @@ -35,11 +37,11 @@ installed, then open a terminal or a command prompt window and run::
Updating the installation
=========================

Data Management is an active project, so we suggest you update your installation
Data Management is an active project, so we suggest you update your installation
frequently. To update the installation run in your terminal::

conda update -c dgursoy dxchange

For some more information about using Conda, please refer to the
For some more information about using Conda, please refer to the
`docs <http://conda.pydata.org/docs>`__.

29 changes: 15 additions & 14 deletions dxchange/exchange.py
Expand Up @@ -53,6 +53,11 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import numpy as np
import os.path
import re
import logging
import dxchange.reader as dxreader

__authors__ = "Doga Gursoy, Luis Barroso-Luque, Francesco De Carlo"
__copyright__ = "Copyright (c) 2015-2016, UChicago Argonne, LLC."
Expand All @@ -77,13 +82,6 @@
'read_petraIII_p05',
'read_sls_tomcat']


import numpy as np
import os.path
import re
import logging
import dxchange.reader as dxreader

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -309,11 +307,11 @@ def read_als_832h5(fname, ind_tomo=None, ind_flat=None, ind_dark=None,
tomo = dxreader.read_hdf5_stack(
dgroup, tomo_name, ind_tomo, slc=(proj, sino))

flat = dxreader.read_hdf5_stack(dgroup, flat_name, ind_flat, slc=(None, sino),
out_ind=group_flat)
flat = dxreader.read_hdf5_stack(
dgroup, flat_name, ind_flat, slc=(None, sino), out_ind=group_flat)

dark = dxreader.read_hdf5_stack(dgroup, dark_name, ind_dark, slc=(None, sino),
out_ind=group_dark)
dark = dxreader.read_hdf5_stack(
dgroup, dark_name, ind_dark, slc=(None, sino), out_ind=group_dark)

return tomo, flat, dark, dxreader._map_loc(ind_tomo, group_flat)

Expand Down Expand Up @@ -740,9 +738,12 @@ def read_aus_microct(fname, ind_tomo, ind_flat, ind_dark, proj=None, sino=None):
flat_name = os.path.join(fname, 'BG__BEFORE_00.tif')
dark_name = os.path.join(fname, 'DF__BEFORE_00.tif')

tomo = dxreader.read_tiff_stack(tomo_name, ind=ind_tomo, digit=4, slc=(sino, proj))
flat = dxreader.read_tiff_stack(flat_name, ind=ind_flat, digit=2, slc=(sino, None))
dark = dxreader.read_tiff_stack(dark_name, ind=ind_dark, digit=2, slc=(sino, None))
tomo = dxreader.read_tiff_stack(
tomo_name, ind=ind_tomo, digit=4, slc=(sino, proj))
flat = dxreader.read_tiff_stack(
flat_name, ind=ind_flat, digit=2, slc=(sino, None))
dark = dxreader.read_tiff_stack(
dark_name, ind=ind_dark, digit=2, slc=(sino, None))
return tomo, flat, dark


Expand Down
13 changes: 2 additions & 11 deletions dxchange/reader.py
Expand Up @@ -220,15 +220,6 @@ def read_xrm(fname, slice_range=None):
else:
slice_range = _make_slice_object_a_tuple(slice_range)

# if metadata["data_type"] == 10:
# struct_fmt = "<{}f".format(
# metadata["image_width"] * metadata["image_height"])
# elif metadata["data_type"] == 5:
# struct_fmt = "<{}h".format(
# metadata["image_width"] * metadata["image_height"])

# img = _read_ole_data(ole, "ImageData1/Image1", struct_fmt)

stream = ole.openstream("ImageData1/Image1")
data = stream.read()

Expand All @@ -248,7 +239,7 @@ def read_xrm(fname, slice_range=None):
ole.close()
return arr, metadata


# Should slc just take over what ind is doing here?
def read_xrm_stack(fname, ind, slc=None):
"""
Read data from stack of xrm files in a folder.
Expand Down Expand Up @@ -768,7 +759,7 @@ def _list_file_stack(fname, ind, digit=None):
of the stacked files.
"""

if (digit is not None):
if digit is not None:
warnings.warn(("The 'digit' argument is deprecated and no longer used."
" It may be removed completely in a later version."),
FutureWarning)
Expand Down
25 changes: 16 additions & 9 deletions test/test_dxchange/test_writer.py
Expand Up @@ -54,22 +54,29 @@


class remove_trailing_digits_test_case(unittest.TestCase):
def test_remove_trailing_digits_handles_not_having_digits(self):
text, digits = writer.remove_trailing_digits("someText")
assert_equal(text, "someText")

def test_remove_trailing_digits_removes_zeroes(self):
text, digits = writer.remove_trailing_digits("someText0000")
text, number_of_digits = writer.remove_trailing_digits("someText0000")
assert_equal(text, "someText")

def test_remove_trailing_digits_removes_correct_number_of_zeroes(self):
text, digits = writer.remove_trailing_digits("someText0000")
assert_equal(digits, 4)
text, number_of_digits = writer.remove_trailing_digits("someText0000")
assert_equal(number_of_digits, 4)

def test_remove_trailing_digits_removes_digits(self):
text, digits = writer.remove_trailing_digits("someText1234567890")
text, number_of_digits = writer.remove_trailing_digits(
"someText1234567890")
assert_equal(text, "someText")

def test_remove_trailing_digits_does_not_remove_digits_in_the_middle(self):
text, digits = writer.remove_trailing_digits("8s7o6m5e4T3e2x1t00.0000")
text, number_of_digits = writer.remove_trailing_digits(
"8s7o6m5e4T3e2x1t00.0000")
assert_equal(text, "8s7o6m5e4T3e2x1t00.")

def test_remove_trailing_digits_handles_not_having_digits(self):
text, number_of_digits = writer.remove_trailing_digits("someText")
assert_equal(text, "someText")

def test_remove_trailing_digits_handles_empty_string(self):
text, number_of_digits = writer.remove_trailing_digits("")
assert_equal(text, "")
assert_equal(number_of_digits, 0)

0 comments on commit 2156024

Please sign in to comment.