Skip to content

Commit e0e7938

Browse files
authored
Merge pull request #836 from HEXRD/master-reorg
Reorganization to Core Structure - Phase 1
2 parents 003da9d + e09f301 commit e0e7938

File tree

322 files changed

+15998
-6377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

322 files changed

+15998
-6377
lines changed

conda.recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build:
99
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
1010
detect_binary_files_with_prefix: true
1111
entry_points:
12-
- hexrd = hexrd.cli.main:main
12+
- hexrd = hexrd.hedm.cli.main:main
1313

1414
requirements:
1515
build:

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import os
1414
import sys
1515

16-
from hexrd.constants import __version__ as version
16+
from hexrd.core.constants import __version__ as version
1717

1818
sys.path.insert(0, os.path.abspath('../..'))
1919

hexrd/__init__.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import importlib
2+
import importlib.abc
3+
import importlib.machinery
24
import sys
35

4-
from .material import crystallography
5-
from .material import jcpds
6-
from .material import mksupport
7-
from .material import spacegroup
8-
from .material import symbols
9-
from .material import symmetry
10-
from .material import unitcell
6+
from .core.material import crystallography
7+
from .core.material import jcpds
8+
from .core.material import mksupport
9+
from .core.material import spacegroup
10+
from .core.material import symbols
11+
from .core.material import symmetry
12+
from .core.material import unitcell
1113

1214
# These are aliases for import paths, so we don't break old HEXRD scripts.
1315
# We will verify the alias files *do not* exist, to avoid confusion.
@@ -30,3 +32,16 @@
3032
raise Exception(f'"{alias}" is an alias path and should not exist')
3133

3234
sys.modules[alias] = module
35+
36+
37+
from . import module_map
38+
39+
40+
def __getattr__(name):
41+
# __getattr__ is only called if the attribute doesn't exist
42+
module = module_map.get("hexrd." + name)
43+
if module is not None:
44+
if isinstance(module, str):
45+
return importlib.import_module(module)
46+
return module
47+
raise AttributeError(f"Module `hexrd` has no attribute {name}")

hexrd/copyright.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# ============================================================
2-
# Copyright (c) 2012, Lawrence Livermore National Security, LLC.
3-
# Produced at the Lawrence Livermore National Laboratory.
4-
# Written by Joel Bernier <[email protected]> and others.
5-
# LLNL-CODE-529294.
2+
# Copyright (c) 2012, Lawrence Livermore National Security, LLC.
3+
# Produced at the Lawrence Livermore National Laboratory.
4+
# Written by Joel Bernier <[email protected]> and others.
5+
# LLNL-CODE-529294.
66
# All rights reserved.
7-
#
7+
#
88
# This file is part of HEXRD. For details on dowloading the source,
99
# see the file COPYING.
10-
#
10+
#
1111
# Please also see the file LICENSE.
12-
#
12+
#
1313
# This program is free software; you can redistribute it and/or modify it under the
1414
# terms of the GNU Lesser General Public License (as published by the Free Software
1515
# Foundation) version 2.1 dated February 1999.
16-
#
16+
#
1717
# This program is distributed in the hope that it will be useful, but
18-
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY
19-
# or FITNESS FOR A PARTICULAR PURPOSE. See the terms and conditions of the
18+
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY
19+
# or FITNESS FOR A PARTICULAR PURPOSE. See the terms and conditions of the
2020
# GNU General Public License for more details.
21-
#
21+
#
2222
# You should have received a copy of the GNU Lesser General Public
2323
# License along with this program (see file LICENSE); if not, write to
2424
# the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
@@ -36,4 +36,4 @@
3636

3737
COPYRIGHT_FILE = 'COPYING'
3838
with open(os.path.join(os.path.dirname(__file__), COPYRIGHT_FILE), 'r') as f:
39-
COPYRIGHT_TEXT = f.read()
39+
COPYRIGHT_TEXT = f.read()
File renamed without changes.

hexrd/config/beam.py renamed to hexrd/core/config/beam.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44

55
from .config import Config
6-
from hexrd import imageseries
6+
from hexrd.core import imageseries
77

88

99
class Beam(Config):

hexrd/config/config.py renamed to hexrd/core/config/config.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
logger = logging.getLogger('hexrd.config')
99

10+
1011
class Config(object):
1112
"""Access a level of the YAML configuration file
1213
@@ -15,6 +16,7 @@ class Config(object):
1516
cfg: Config instance or a (pyyaml) YAMLObject
1617
config representings a level of the YAML input
1718
"""
19+
1820
_dirty = False
1921

2022
def __init__(self, cfg):
@@ -41,14 +43,12 @@ def get(self, key, default=null):
4143
res = temp[item]
4244
except KeyError:
4345
if default is not null:
44-
logger.info(
45-
'%s not specified, defaulting to %s', key, default
46-
)
46+
logger.info('%s not specified, defaulting to %s', key, default)
4747
res = temp.get(item, default)
4848
else:
4949
raise RuntimeError(
5050
'%s must be specified in configuration file' % key
51-
)
51+
)
5252
return res
5353

5454
def set(self, key, val):
@@ -80,12 +80,10 @@ def check_filename(fname, wdir):
8080
8181
If fname is an absolute path, use that; otherwise take it as a path
8282
relative to the working directory.
83-
"""
83+
"""
8484
temp = fname
8585
if not os.path.isabs(fname):
8686
temp = os.path.join(wdir, temp)
8787
if os.path.exists(temp):
8888
return temp
89-
raise IOError(
90-
'file: "%s" not found' % temp
91-
)
89+
raise IOError('file: "%s" not found' % temp)

hexrd/config/dumper.py renamed to hexrd/core/config/dumper.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def _dict_path_by_id(d, value, path=()):
88
return path
99
elif isinstance(d, dict):
1010
for k, v in d.items():
11-
p = _dict_path_by_id(v, value, path + (k, ))
11+
p = _dict_path_by_id(v, value, path + (k,))
1212
if p is not None:
1313
return p
1414
elif isinstance(d, list):
@@ -32,6 +32,7 @@ class NumPyIncludeDumper(yaml.Dumper):
3232
The ndarray would be saved in foo/bar.npy.
3333
3434
"""
35+
3536
def __init__(self, stream, **kwargs):
3637
super().__init__(stream, **kwargs)
3738

@@ -58,5 +59,6 @@ def represent(self, data):
5859
return super().represent(data)
5960

6061

61-
NumPyIncludeDumper.add_representer(np.ndarray,
62-
NumPyIncludeDumper.ndarray_representer)
62+
NumPyIncludeDumper.add_representer(
63+
np.ndarray, NumPyIncludeDumper.ndarray_representer
64+
)

hexrd/config/imageseries.py renamed to hexrd/core/config/imageseries.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .config import Config
2-
from hexrd import imageseries
2+
from hexrd.core import imageseries
33

4-
from hexrd.constants import shared_ims_key
4+
from hexrd.core.constants import shared_ims_key
55

66

77
class ImageSeries(Config):
@@ -34,7 +34,7 @@ def imageseries(self):
3434
panel = '_'.join(panel)
3535
elif panel is None:
3636
panel = shared_ims_key
37-
except(KeyError):
37+
except KeyError:
3838
panel = shared_ims_key
3939
self._image_dict[panel] = oms
4040

hexrd/config/instrument.py renamed to hexrd/core/config/instrument.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .config import Config
55
from .loader import NumPyIncludeLoader
66

7-
from hexrd import instrument
7+
from hexrd.core import instrument
88

99

1010
class Instrument(Config):
@@ -31,7 +31,7 @@ def hedm(self):
3131

3232
try:
3333
icfg = h5py.File(self.configuration, 'r')
34-
except(OSError):
34+
except OSError:
3535
with open(self.configuration, 'r') as f:
3636
icfg = yaml.load(f, Loader=NumPyIncludeLoader)
3737

@@ -47,7 +47,7 @@ def hedm(self, icfg_fname):
4747
"""Set the HEDMInstrument class."""
4848
try:
4949
icfg = h5py.File(icfg_fname, 'r')
50-
except(OSError):
50+
except OSError:
5151
with open(icfg_fname, 'r') as f:
5252
icfg = yaml.load(f, Loader=NumPyIncludeLoader)
5353

0 commit comments

Comments
 (0)