Skip to content
Open
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
8 changes: 4 additions & 4 deletions hexrd/core/instrument/hedm_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,7 @@ def __init__(self, filename):
self.fid = filename
else:
self.fid = open(filename, 'w')
print(self._header, file=self.fid)
logger.info(self._header, file=self.fid)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to just write to the file instead? Like:

self.fid.write(self._header)

I think using the logger would add extra stuff to the file contents. It looks like the print before was just intended to write to the file. Same for the other ones in this class.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe using the print() statement before implicitly added a '\n' after each call too, so you might need to add + '\n' to the writes.


def __del__(self):
self.close()
Expand Down Expand Up @@ -2282,7 +2282,7 @@ def dump_patch(
self._delim.join(np.tile('{:<23.16e}', 10)).format(*res[7:]),
]
)
print(output_str, file=self.fid)
logger.info(output_str, file=self.fid)
return output_str


Expand Down Expand Up @@ -2337,7 +2337,7 @@ def __init__(self, filename=None, array=None):
self.fid = filename
else:
self.fid = open(filename, 'w')
print(self._header, file=self.fid)
logger.info(self._header, file=self.fid)

def __del__(self):
self.close()
Expand Down Expand Up @@ -2373,7 +2373,7 @@ def dump_grain(self, grain_id, completeness, chisq, grain_params):
self._delim.join(np.tile('{:<23.16e}', len(res) - 3)).format(*res[3:]),
]
)
print(output_str, file=self.fid)
logger.info(output_str, file=self.fid)
return output_str


Expand Down
23 changes: 0 additions & 23 deletions hexrd/core/material/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -1562,26 +1562,3 @@ def get_hkl_strings(pdata):
'return_indices': True,
}
return np.intersect1d(**kwargs)[1:]


#
# ============================== Executable section for testing
#


if __name__ == '__main__':
#
# For testing
#
import sys

if len(sys.argv) == 1:
print("need argument: materials.cfg")
sys.exit()

ml = loadMaterialList(sys.argv[1])

print('MATERIAL LIST\n')
print((' from file: ', sys.argv[1]))
for m in ml:
print(m)
9 changes: 5 additions & 4 deletions hexrd/core/material/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,12 @@ def PrintPossibleSG(xtal_sys):

for i in range(sgmin, sgmax + 1):
j = i - sgmin + 1
pstr = f'{i}:{pstr_spacegroup[i - 1]}\t'
pstr = f"{i}:{pstr_spacegroup[i - 1]}\t"
line += pstr

if j % 4 == 0 or j == sgmax:
print(pstr)
else:
print(pstr, end='')
logger.info(line.rstrip())
line = ""

return sgmin, sgmax

Expand Down
29 changes: 0 additions & 29 deletions hexrd/core/valunits.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

"""

import doctest
import math

import numpy as np
Expand Down Expand Up @@ -308,31 +307,3 @@ def _degrees(x: float) -> valWUnit:

# Function alias
_angstroms = _angstrom

if __name__ == '__main__': # pragma: no cover
#
# doc testing
#
print("running doctest")
doctest.testmod()

#
# other tests
#
def testConversions():
print('===== Testing unit conversions ...')
print('..... angles:')
v = valWUnit('180d', 'angle', 180.0, 'degrees')
print(v)
print((' in degrees:', v.getVal('degrees')))
print((' in radians: ', v.getVal('radians')))

print('..... lengths:')
ulist = ['m', 'mm', 'meter', 'angstrom']
v = valWUnit('one meter', 'length', 1.0, 'meter')
print(v)
for u in ulist:
print((' in ', u, ': ', v.getVal(u)))
return

testConversions()
1 change: 0 additions & 1 deletion scripts/install/install_build_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,4 @@ def install(library, destination):
library = sys.argv[1]
destination = sys.argv[2]

print(f'Installing "{library}" to "{destination}"')
install(library, destination)
4 changes: 0 additions & 4 deletions tests/fit_grains_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,3 @@ def compare_grain_fits(
ctol=ctol,
vtol=vtol,
)
if cresult:
print("test passed")
else:
print("test failed")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're keeping this __main__ section, isn't this final printing the most important part of it? Otherwise, if you ran it, you wouldn't know if it passed or failed.

Loading