Skip to content

Commit

Permalink
import from dgcode ncrystaldev git: candidate for version 3.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
tkittel committed Aug 20, 2024
1 parent 313843b commit b3a5aea
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v3.9.3 2024-08-20
* Fix NCrystal.cifutils plot labels with underscores in filenames.
* Fix MiniMC plotting.

v3.9.2 2024-08-19
* Prevent rare error in the MiniMC framework, which happened when acos was
evaluated on a value which due to numerical instabilities was ever so
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ endif()

cmake_policy( SET CMP0048 NEW )#Not sure if this is really needed

project( NCrystal VERSION 3.9.2 ${_project_metadata} )
project( NCrystal VERSION 3.9.3 ${_project_metadata} )

unset( _project_metadata )

Expand Down
2 changes: 1 addition & 1 deletion NCrystal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

#NB: Synchronize meta-data below with fields in setup.py+template_setup.py.in meta data:
__license__ = "Apache 2.0, http://www.apache.org/licenses/LICENSE-2.0"
__version__ = '3.9.2'
__version__ = '3.9.3'
__status__ = "Production"
__author__ = "NCrystal developers (Thomas Kittelmann, Xiao Xiao Cai)"
__copyright__ = "Copyright 2015-2024 %s"%__author__
Expand Down
3 changes: 2 additions & 1 deletion NCrystal/_mmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ def plot( self, *,
plt.figure()

do_legend = False
tot_integral_with_absorption = None#unknown

if breakdown_mode:

colors = {
Expand Down Expand Up @@ -357,7 +359,6 @@ def plot( self, *,
'NOSCAT'].index(h.title))

integrals = [ h.stats.get('integral',-1.0) for h in hists ]
tot_integral_with_absorption = None#unknown
tot_integral = ( sum(integrals)
if all( i>=0.0 for i in integrals )
else None )
Expand Down
18 changes: 13 additions & 5 deletions NCrystal/cifutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ def produce_validation_plots( files, verbose_lbls = True, pdf_target = None,
embed them in a PDF file. Any plot_kwargs will be passed along to the
produce_validation_plot(..) function.
"""
from .plot import _import_matplotlib_plt, _import_matplotlib_pdfpages, _fakepyplot_mode
from .plot import ( _import_matplotlib_plt,
_import_matplotlib_pdfpages,
_fakepyplot_mode )

if pdf_target:
pdfpages = _import_matplotlib_pdfpages()
Expand Down Expand Up @@ -508,7 +510,7 @@ def _extractID(s,pattern):
yield int(d)

import re as _re
_re_atomdbspecs = _re.compile("\[ *with ([a-zA-Z ]+)->([ a-zA-Z0-9+-\.]+) *\]")
_re_atomdbspecs = _re.compile(r"\[ *with ([a-zA-Z ]+)->([ a-zA-Z0-9+-\.]+) *\]")
def _extractAtomDBSpec(s):
#Look for remapping specs like "[with H->D]" and return in @ATOMDB format
#(i.e. "H is D").
Expand Down Expand Up @@ -537,7 +539,8 @@ def _extractAtomDBSpec(s):
ids = newids

def _atomdb_to_remap( atomdb):
_atomdb = list( ' '.join(e.strip().split()) for e in (atomdb or '').replace(':',' ').split('@') )
_atomdb = list( ' '.join(e.strip().split())
for e in (atomdb or '').replace(':',' ').split('@') )
_atomdb = list( e for e in _atomdb if e )
l = []
for c in _atomdb:
Expand Down Expand Up @@ -587,6 +590,9 @@ def _atomdb_to_remap( atomdb):
'pink',
'gray')]

def fix_lbl_for_plt(lbl):
return lbl.replace('_',"$"+'\\'+"mathrm{\\_}$")

for i,(lbl,mc) in enumerate(cmps):
lbl = str(lbl)
if '/' in lbl:
Expand All @@ -608,7 +614,7 @@ def _atomdb_to_remap( atomdb):
natoms_all.add(si['n_atoms'])

plt.plot(wls,mc.scatter.xsect(wl=wls),
label=lbl,
label=fix_lbl_for_plt(lbl),
linewidth=lw,
alpha=0.5 if i==0 else 0.5,
color = col_ordered[i] if i<len(col_ordered) else None,
Expand Down Expand Up @@ -1610,7 +1616,9 @@ def guess_elem_name( site_label ):
if elem_name:
_nc_common.warn(f'Assuming atomic symbol "{elem_name}" based on CIF label "{site.label}"')
else:
raise _nc_core.NCBadInput(f'Neither Gemmi nor NCrystal\'s custom code could deduce an atomic symbol for the CIF label "{site.label}"')
raise _nc_core.NCBadInput(f'Neither Gemmi nor NCrystal\'s custom'
' code could deduce an atomic symbol'
f' for the CIF label "{site.label}"')
elem_Z = None
else:
elem_name, elem_Z = site_en, int(site.element.atomic_number)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.2
3.9.3
6 changes: 3 additions & 3 deletions ncrystal_core/include/NCrystal/NCVersion.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@

#define NCRYSTAL_VERSION_MAJOR 3
#define NCRYSTAL_VERSION_MINOR 9
#define NCRYSTAL_VERSION_PATCH 2
#define NCRYSTAL_VERSION 3009002 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.2"
#define NCRYSTAL_VERSION_PATCH 3
#define NCRYSTAL_VERSION 3009003 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.3"

#include "NCrystal/ncapi.h"
#include <stdexcept>
Expand Down
6 changes: 3 additions & 3 deletions ncrystal_core/include/NCrystal/ncrystal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1201,9 +1201,9 @@ extern "C" {
#endif
#define NCRYSTAL_VERSION_MAJOR 3
#define NCRYSTAL_VERSION_MINOR 9
#define NCRYSTAL_VERSION_PATCH 2
#define NCRYSTAL_VERSION 3009002 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.2"
#define NCRYSTAL_VERSION_PATCH 3
#define NCRYSTAL_VERSION 3009003 /* (1000000*MAJOR+1000*MINOR+PATCH) */
#define NCRYSTAL_VERSION_STR "3.9.3"
NCRYSTAL_API int ncrystal_version(void); /* returns NCRYSTAL_VERSION */
NCRYSTAL_API const char * ncrystal_version_str(void); /* returns NCRYSTAL_VERSION_STR */

Expand Down

0 comments on commit b3a5aea

Please sign in to comment.