Skip to content

Commit

Permalink
Merge pull request #841 from to266/ENH_new_progressbar
Browse files Browse the repository at this point in the history
replaced old progressbar.
  • Loading branch information
francisco-dlp committed Jun 14, 2016
2 parents a3aa128 + 32e7e6c commit 9f5ba79
Show file tree
Hide file tree
Showing 28 changed files with 244 additions and 748 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ install:
- conda create -n testenv --yes python=$TRAVIS_PYTHON_VERSION $DEPS
- source activate testenv
- conda install pip
- pip install coverage coveralls traits traitsui request
- pip install coverage coveralls traits traitsui request tqdm
- python setup.py install

script: python continuous_integration/nosetest.py --with-coverage hyperspy
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ install:
- "%CMD_IN_ENV% move %PYTHON%\\sip %PYTHON%\\Lib\\site-packages\\PyQt4\\sip"
- "%CMD_IN_ENV% conda install pip"
# TODO: Remove once anaconda taitsui package is at v5:
- "IF \"%PYTHON_MAJOR%\" EQU \"3\" pip install --upgrade traitsui"
- "IF \"%PYTHON_MAJOR%\" EQU \"3\" pip install --upgrade traitsui tqdm"
- ps: Add-AppveyorMessage "Installing hyperspy..."
- "python setup.py install"

Expand Down Expand Up @@ -101,7 +101,7 @@ before_deploy:
- "SET PATH=%ORIGPATH%"
- "%CMD_IN_ENV% %WP_INSTDIR%/scripts/env.bat"
- "%CMD_IN_ENV% python.exe setup.py install"
- "%CMD_IN_ENV% pip install --upgrade configobj traitsui natsort start_jupyter_cm"
- "%CMD_IN_ENV% pip install --upgrade configobj traitsui natsort start_jupyter_cm tqdm"
# Custom installer step
# TODO: Re-run tests in WinPython environment
- ps: Add-AppveyorMessage "Creating installer..."
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinxext/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def _parse(self):
for (section, content) in self._read_sections():
if not section.startswith('..'):
section = ' '.join([s.capitalize()
for s in section.split(' ')])
for s in section.split(' ')])
if section in ('Parameters', 'Returns', 'Raises', 'Warns',
'Other Parameters', 'Attributes', 'Methods'):
self[section] = self._parse_param_list(content)
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinxext/gen_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def generate_example_rst(app):

# indent the contents
contents = '\n'.join([' %s' % row.rstrip()
for row in contents.split('\n')])
for row in contents.split('\n')])
fh.write(contents)

fh.write(
Expand Down
4 changes: 2 additions & 2 deletions doc/user_guide/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Installing the required libraries

When installing HyperSpy using Python installers or from source the Python
programming language and the following libraries must be installed in the
system: numpy, scipy, matplotlib (>= 1.2), ipython, natsort, traits and
system: numpy, scipy, matplotlib (>= 1.2), ipython, natsort, tqdm, traits and
traitsui. For full functionality it is recommended to also install h5py and
scikit-learn. In addition, since version 0.7.2 the lowess filter requires
statsmodels. In Windows HyperSpy uses the Ipython's QtConsole and therefore Qt
Expand All @@ -221,7 +221,7 @@ In Debian/Ubuntu you can install the libraries as follows:
$ sudo apt-get install python-numpy python-matplotlib ipython
ipython-notebook python-traits python-traitsui python-h5py
python-scikits-learn python-nose python-statsmodels
python-scikits-learn python-nose python-statsmodels python3-tqdm
In Arch Linux, the following command should install the required packages to
get a fully functional installation:
Expand Down
1 change: 0 additions & 1 deletion hyperspy/Release.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@
http://www.hyperspy.org
""" % version.replace('_', ' ')

3 changes: 2 additions & 1 deletion hyperspy/_components/eels_vignetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def function(self, x):
if self.side_vignetting is True:

x = x.tolist()
x = list(range(-ex, 0)) + x + list(range(int(x[-1]) + 1, int(x[-1]) + ex + 1))
x = list(range(-ex, 0)) + x + \
list(range(int(x[-1]) + 1, int(x[-1]) + ex + 1))
x = np.array(x)
v1 = A * np.cos((x - x0) / (2 * np.pi * period)) ** 4
v2 = np.where(x < l,
Expand Down
10 changes: 5 additions & 5 deletions hyperspy/_signals/eds_tem.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def set_microscope_parameters(self,
probe_area)
if real_time is not None:
md.set_item(
"Acquisition_instrument.TEM.Detector.EDS.real_time",
real_time)
"Acquisition_instrument.TEM.Detector.EDS.real_time",
real_time)

if set([beam_energy, live_time, tilt_stage, azimuth_angle,
elevation_angle, energy_resolution_MnKa]) == {None}:
Expand Down Expand Up @@ -382,9 +382,9 @@ def quantification(self,
mass_thickness.metadata.General.title = 'Mass thickness'
elif method == 'cross_section':
results = utils_eds.quantification_cross_section(
composition.data,
cross_sections=factors,
dose=self._get_dose(method))
composition.data,
cross_sections=factors,
dose=self._get_dose(method))
composition.data = results[0] * 100
number_of_atoms = utils.stack(intensities)
number_of_atoms.data = results[1]
Expand Down
22 changes: 8 additions & 14 deletions hyperspy/_signals/eels.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,18 +336,16 @@ def estimate_elastic_scattering_intensity(
else:
I0 = self._get_navigation_signal()
I0.axes_manager.set_signal_dimension(0)
pbar = hyperspy.external.progressbar.progressbar(
maxval=self.axes_manager.navigation_size,
)
for i, s in enumerate(I0):
for i, s in progressbar(enumerate(self),
total=self.axes_manager.navigation_size,
disable=not show_progressbar,
leave=True):
threshold_ = threshold.isig[I0.axes_manager.indices].data[0]
if np.isnan(threshold_):
s.data[:] = np.nan
else:
s.data[:] = (self.inav[I0.axes_manager.indices].isig[
:threshold_].integrate1D(-1).data)
pbar.update(i)
pbar.finish()
I0.axes_manager.set_signal_dimension(
self.axes_manager.navigation_dimension)
I0.metadata.General.title = (
Expand Down Expand Up @@ -749,10 +747,10 @@ def richardson_lucy_deconvolution(self, psf, iterations=15, mask=None,
imax = kernel.argmax()
j = 0
maxval = self.axes_manager.navigation_size
if maxval > 0:
pbar = progressbar(maxval=maxval,
disabled=not show_progressbar)
for D in self:
show_progressbar = show_progressbar and (maxval > 0)
for D in progressbar(self, total=maxval,
disable=not show_progressbar,
leave=True):
D = D.data.copy()
if psf.axes_manager.navigation_dimension != 0:
kernel = psf(axes_manager=self.axes_manager)
Expand All @@ -767,10 +765,6 @@ def richardson_lucy_deconvolution(self, psf, iterations=15, mask=None,
D / first)[mimax: mimax + psf_size])
s[:] = O
j += 1
if maxval > 0:
pbar.update(j)
if maxval > 0:
pbar.finish()

return ds

Expand Down
3 changes: 2 additions & 1 deletion hyperspy/external/mpfit/mpfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,8 @@ def defiter(self, fcn, x, iter, fnorm=None, functkw=None,

# Determine which parameters to print
nprint = len(x)
print("Iter ", ('%6i' % iter), " CHI-SQUARE = ", ('%.10g' % fnorm), " DOF = ", ('%i' % dof))
print("Iter ", ('%6i' % iter), " CHI-SQUARE = ", ('%.10g' % fnorm),
" DOF = ", ('%i' % dof))
for i in range(nprint):
if (parinfo is not None) and ('parname' in parinfo[i]):
p = ' ' + parinfo[i]['parname'] + ' = '
Expand Down

0 comments on commit 9f5ba79

Please sign in to comment.