Skip to content

Commit

Permalink
improved standard output
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Stolker committed Oct 1, 2019
1 parent 578acdc commit 2c710c4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 37 deletions.
6 changes: 4 additions & 2 deletions pynpoint/core/pypeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ def run(self):
module_info(self._m_modules[name])

if hasattr(self._m_modules[name], '_m_input_ports'):
input_info(self._m_modules[name])
if len(self._m_modules[name]._m_input_ports) > 0:
input_info(self._m_modules[name])

self._m_modules[name].run()

Expand Down Expand Up @@ -440,7 +441,8 @@ def run_module(self,
module_info(self._m_modules[name])

if hasattr(self._m_modules[name], '_m_input_ports'):
input_info(self._m_modules[name])
if len(self._m_modules[name]._m_input_ports) > 0:
input_info(self._m_modules[name])

self._m_modules[name].run()

Expand Down
1 change: 0 additions & 1 deletion pynpoint/readwrite/fitsreading.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import os
import sys
import time

from typing import Union, Tuple, List
Expand Down
7 changes: 2 additions & 5 deletions pynpoint/readwrite/fitswriting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import os
import sys
import warnings

from typing import Tuple
Expand Down Expand Up @@ -91,8 +90,7 @@ def run(self) -> None:

out_name = os.path.join(self.m_output_location, self.m_file_name)

sys.stdout.write('Writing FITS file...')
sys.stdout.flush()
print('Writing FITS file...', end='')

if os.path.isfile(out_name) and not self.m_overwrite:
warnings.warn('Filename already present. Use overwrite=True to overwrite an existing '
Expand Down Expand Up @@ -150,7 +148,6 @@ def run(self) -> None:
filename = f'{out_name[:-5]}{i:03d}.fits'
fits.writeto(filename, data_select, header, overwrite=self.m_overwrite)

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()
print(' [DONE]')

self.m_data_port.close_port()
1 change: 0 additions & 1 deletion pynpoint/readwrite/hdf5reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

import os
import sys
import time
import warnings

Expand Down
7 changes: 2 additions & 5 deletions pynpoint/readwrite/hdf5writing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import os
import sys

import h5py
from typeguard import typechecked
Expand Down Expand Up @@ -75,8 +74,7 @@ def run(self) -> None:
None
"""

sys.stdout.write('Writing HDF5 file...')
sys.stdout.flush()
print('Writing HDF5 file...', end='')

if self.m_overwrite:
out_file = h5py.File(os.path.join(self.m_output_location, self.m_file_name), mode='w')
Expand Down Expand Up @@ -113,5 +111,4 @@ def run(self) -> None:

out_file.close()

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()
print(' [DONE]')
1 change: 0 additions & 1 deletion pynpoint/readwrite/nearreading.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import os
import sys
import math
import time
import shlex
Expand Down
13 changes: 4 additions & 9 deletions pynpoint/readwrite/textreading.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import os
import sys
import warnings

import numpy as np
Expand Down Expand Up @@ -68,8 +67,7 @@ def run(self) -> None:
None
"""

sys.stdout.write('Reading parallactic angles...')
sys.stdout.flush()
print('Reading parallactic angles...', end='')

parang = np.loadtxt(os.path.join(self.m_input_location, self.m_file_name))

Expand All @@ -94,8 +92,7 @@ def run(self) -> None:
warnings.warn(f'The PARANG attribute is already present and contains the same values '
f'as are present in {self.m_file_name}.')

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()
print(' [DONE]')

self.m_data_port.close_port()

Expand Down Expand Up @@ -159,8 +156,7 @@ def run(self) -> None:
None
"""

sys.stdout.write('Reading attribute data...')
sys.stdout.flush()
print('Reading attribute data...', end='')

attributes = get_attributes()

Expand Down Expand Up @@ -191,7 +187,6 @@ def run(self) -> None:
warnings.warn(f'The \'{self.m_attribute}\' attribute is already present and '
f'contains the same values as are present in {self.m_file_name}.')

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()
print(' [DONE]')

self.m_data_port.close_port()
19 changes: 6 additions & 13 deletions pynpoint/readwrite/textwriting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import os
import sys

import numpy as np

Expand Down Expand Up @@ -70,8 +69,7 @@ def run(self) -> None:
if self.m_header is None:
self.m_header = ''

sys.stdout.write('Writing text file...')
sys.stdout.flush()
print('Writing text file...', end='')

out_name = os.path.join(self.m_output_location, self.m_file_name)

Expand All @@ -89,8 +87,7 @@ def run(self) -> None:
elif data.dtype == 'float32' or data.dtype == 'float64':
np.savetxt(out_name, data, header=self.m_header, comments='# ')

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()
print(' [DONE]')

self.m_data_port.close_port()

Expand Down Expand Up @@ -149,8 +146,7 @@ def run(self) -> None:
None
"""

sys.stdout.write('Writing parallactic angles...')
sys.stdout.flush()
print('Writing parallactic angles...', end='')

if self.m_header is None:
self.m_header = ''
Expand All @@ -164,8 +160,7 @@ def run(self) -> None:

np.savetxt(out_name, parang, header=self.m_header, comments='# ')

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()
print(' [DONE]')

self.m_data_port.close_port()

Expand Down Expand Up @@ -231,8 +226,7 @@ def run(self) -> None:
if self.m_header is None:
self.m_header = ''

sys.stdout.write('Writing attribute data...')
sys.stdout.flush()
print('Writing attribute data...', end='')

out_name = os.path.join(self.m_output_location, self.m_file_name)

Expand All @@ -244,7 +238,6 @@ def run(self) -> None:

np.savetxt(out_name, values, header=self.m_header, comments='# ')

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()
print(' [DONE]')

self.m_data_port.close_port()

0 comments on commit 2c710c4

Please sign in to comment.