Skip to content

Commit

Permalink
Try to fix testncmat2hkl on osx
Browse files Browse the repository at this point in the history
  • Loading branch information
tkittel committed Oct 29, 2024
1 parent 34da1ef commit adaae5d
Show file tree
Hide file tree
Showing 4 changed files with 47,015 additions and 46,983 deletions.
32 changes: 26 additions & 6 deletions NCrystal/_cli_ncmat2hkl.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,43 @@ def create_argparser_for_sphinx( progname ):

@cli_entry_point
def main( progname, arglist ):

#parse hidden option (needed for unit tests):
override_prec = None
override_opt = '--override-prec='
hidden_args, standard_args = [], []
for a in arglist:
(hidden_args
if a.startswith(override_opt)
else standard_args).append( a )
arglist = standard_args
if hidden_args:
override_prec = int(hidden_args[-1][len(override_opt):])

args = parseArgs( progname, arglist )
do_quiet = ( args.quiet or args.output == 'stdout' )

def invoke():
_main_impl(args,do_quiet,override_prec)

if do_quiet:
from ._common import modify_ncrystal_print_fct_ctxmgr
with modify_ncrystal_print_fct_ctxmgr('block'):
_main_impl(args,do_quiet)
invoke()
else:
_main_impl(args,do_quiet)
invoke()

def _main_impl( args, do_quiet ):
def _main_impl( args, do_quiet, override_prec ):

from . import mcstasutils
full_info = True
content_iter = mcstasutils.cfgstr_2_hkl( cfgstr = args.CFGSTR,
tgtformat = args.format,
verbose = full_info )
kwargs = dict(cfgstr = args.CFGSTR,
tgtformat = args.format,
verbose = full_info)
if override_prec:
kwargs['fp_format'] = f'%.{override_prec}g'

content_iter = mcstasutils.cfgstr_2_hkl( **kwargs )
#Fixme: common helper function?
if args.output is None or args.output == 'stdout':
#FIXME: use _common.print or sys.stdout.write?
Expand Down
3 changes: 2 additions & 1 deletion NCrystal/mcstasutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def cfgstr_2_union_instrument_code( *, cfgstr, name, split_by_physics = False ):
"""
return res

def cfgstr_2_hkl(*, cfgstr, tgtformat, verbose=True, fp_format = '%.13g' ):
def cfgstr_2_hkl(*, cfgstr, tgtformat, verbose=True, fp_format = '%.14g' ):
"""Function which can be used to create input files with reflections for
McStas crystalline sample components like PowderN and Single_crystal, based
on NCrystal cfg-strings (usually referring to NCMAT files with crystalline
Expand All @@ -141,6 +141,7 @@ def cfgstr_2_hkl(*, cfgstr, tgtformat, verbose=True, fp_format = '%.13g' ):
time.
"""

import numbers
import functools
import math
Expand Down
Loading

0 comments on commit adaae5d

Please sign in to comment.