FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
diffpy.structure/src/diffpy/structure/__init__.py at main · diffpy/diffpy.structure · GitHub
diffpy
diffpy.structure
Repository navigation
Code
Issues
9
(9)
Pull requests
1
(1)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
diffpy.structure
/
src
/
diffpy
/
structure
/
__init__.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
134 lines (108 loc) · 3.73 KB
Breadcrumbs
diffpy.structure
/
src
/
diffpy
/
structure
/
__init__.py
Copy path
File metadata and controls
134 lines (108 loc) · 3.73 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env python
##############################################################################
#
# (c) 2024-2026 The Trustees of Columbia University in the City of New York.
# All rights reserved.
#
# File coded by: Chris Farrow, Pavol Juhas, Simon Billinge, Billinge Group members.
#
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/diffpy/diffpy.structure/graphs/contributors
#
# See LICENSE.rst for license information.
#
##############################################################################
"""Crystal structure container and parsers for structure formats.
Classes related to the structure of materials:
* Atom
* Lattice
* Structure
* PDFFitStructure
Other classes:
* SpaceGroup
* SymOp
* ExpandAsymmetricUnit
* GeneratorSite
* SymmetryConstraints
Exceptions:
* StructureFormatError
* LatticeError
* SymmetryError
"""
import
os
import
sys
import
diffpy
.
structure
as
_structure
from
diffpy
.
structure
.
atom
import
Atom
from
diffpy
.
structure
.
lattice
import
Lattice
from
diffpy
.
structure
.
parsers
import
get_parser
from
diffpy
.
structure
.
pdffitstructure
import
PDFFitStructure
from
diffpy
.
structure
.
structure
import
Structure
from
diffpy
.
structure
.
structureerrors
import
LatticeError
,
StructureFormatError
,
SymmetryError
# package version
from
diffpy
.
structure
.
version
import
__version__
from
diffpy
.
utils
.
_deprecator
import
build_deprecation_message
,
deprecated
# Deprecations -------------------------------------------------------
base
=
"diffpy.structure"
removal_version
=
"4.0.0"
loadStructure_deprecation_msg
=
build_deprecation_message
(
base
,
"loadStructure"
,
"load_structure"
,
removal_version
,
)
# @deprecated
# custom deprecator for diffpy.Structure module
class
DeprecatedStructureModule
:
"""Proxy for backward compatibility of diffpy.Structure."""
def
__getattr__
(
self
,
name
):
import
warnings
warnings
.
warn
(
"Module 'diffpy.Structure' is deprecated and will be removed in version 4.0. "
"Use 'diffpy.structure' instead."
,
DeprecationWarning
,
stacklevel
=
2
,
)
return
getattr
(
_structure
,
name
)
sys
.
modules
[
"diffpy.Structure"
]
=
DeprecatedStructureModule
()
# top level routines
@
deprecated
(
loadStructure_deprecation_msg
)
def
loadStructure
(
filename
,
fmt
=
"auto"
,
**
kw
):
"""This function has been deprecated and will be removed in version
4.0.0.
Please use diffpy.structure.load_structure instead.
"""
return
load_structure
(
filename
,
fmt
,
**
kw
)
def
load_structure
(
filename
,
fmt
=
"auto"
,
**
kw
):
"""Load new structure object from the specified file.
Parameters
----------
filename : str
Path to the file to be loaded.
fmt : str, Optional
Format of the structure file such as 'cif' or 'xyz'. Must be
one of the formats listed by the `parsers.input_formats` function.
When 'auto', all supported formats are tried in a sequence.
kw : Optional
Extra keyword arguments that are passed to `parsers.get_parser`
function. These configure the dedicated Parser object that
is used to read content in filename.
Returns
-------
stru : `Structure`, `PDFFitStructure`
The new Structure object loaded from the specified file.
Return a more specific PDFFitStructure type for 'pdffit'
and 'discus' formats.
"""
filename
=
os
.
fspath
(
filename
)
p
=
get_parser
(
fmt
,
**
kw
)
rv
=
p
.
parse_file
(
filename
)
return
rv
# silence pyflakes checker
assert
StructureFormatError
and
LatticeError
and
SymmetryError
assert
Atom
assert
Lattice
assert
Structure
assert
PDFFitStructure
# silence the pyflakes syntax checker
assert
__version__
or
True
# End of file
Back
|
FazBrowse Home
|
New Git URL