@@ -72,7 +72,7 @@ def _validate_datetime(data: Union[str, int, float, datetime.datetime]) -> int:
72
72
"""
73
73
Validate and transform dates into integers
74
74
75
- : param data: representation of a year
75
+ param data: representation of a year
76
76
:type data: Union[str,int,float, datetime.datetime]
77
77
:raises TypeError: raise if the data is not of type str, int, float or datetime.datetime
78
78
:return: integer representing a year
@@ -87,27 +87,27 @@ def _validate_datetime(data: Union[str, int, float, datetime.datetime]) -> int:
87
87
return data
88
88
89
89
90
- def _validate_sources (data : Union [dict , list [dict ]]) -> list [dict ]:
90
+ def _validate_sources (
91
+ data : Union [dict [str , Any ], list [dict [str , Any ]]],
92
+ ) -> list [dict [str , Any ]]:
91
93
"""
92
94
Validate the sources for the potential.
93
95
94
96
This checks whether the entry is a dictionary that can be used to describe
95
97
the citation for a potential.
96
98
97
99
:param data: citation data for a potential
98
- :type data: Union[dict, List[dict]]
100
+ :type data: Union[dict, List[dict[str, Any] ]]
99
101
:raises TypeError: raises if the data is not a dict or list of dicts
100
102
:raises TypeError: raises if not all the entries in the list are dicts
101
103
:return: list of references for a potential
102
- :rtype: List[dict]
104
+ :rtype: List[dict[str, Any] ]
103
105
"""
104
106
105
- def _validate_single_source (source : dict ) -> dict :
107
+ def _validate_single_source (source : dict [ str , Any ] ) -> dict [ str , Any ] :
106
108
"""
107
109
Validate a single potential citation data
108
-
109
110
This will check if certain keys exists and add them to the citation data
110
-
111
111
:param source: citation data for a potential
112
112
:type source: dict
113
113
:return: validated potential data
@@ -140,21 +140,12 @@ class LammpsPotentialData(orm.SinglefileData):
140
140
"""
141
141
Base class for the LAMMPS potentials.
142
142
143
- This class allows the storage/recovering of LAMMPS potentials, it allows
144
- one to store any LAMMPS potential as a :py:class:`~aiida.orm.nodes.data.singlefile.SinglefileData` object, which can
145
- then be either written to the LAMMPS input script and/or to a file, where
146
- it can be easily read by LAMMPS. This distinction depends on the assigned
147
- ``pair_style`` which require different ``pair_coeff`` entries in the input
148
- file.
149
-
150
- Based on the
151
- `pseudo <https://github.com/aiidateam/aiida-pseudo/blob/master/aiida_pseudo/data/pseudo/pseudo.py>`_
152
- class written by Sebaastian Huber.
153
-
154
- The potentials are also tagged by following the KIM-API
155
- `schema <https://openkim.org/doc/schema/kimspec/>`_, as to make them more easy
156
- to track and as compatible as possible to the KIM schema.
157
- """ # pylint: disable=line-too-long
143
+ This class allows the storage/recovering of LAMMPS potentials, it allows one to store any LAMMPS potential as a
144
+ :py:class:`~aiida.orm.nodes.data.singlefile.SinglefileData` object, which can then be either written to the LAMMPS
145
+ input script and/or to a file, where it can be easily read by LAMMPS.
146
+ This distinction depends on the assigned ``pair_style`` which require different ``pair_coeff`` entries in
147
+ the input file.
148
+ """
158
149
159
150
# pylint: disable=too-many-arguments, too-many-ancestors
160
151
_key_element = "element"
@@ -221,10 +212,8 @@ def get_or_create(
221
212
:param extra_tags: Dictionary with extra information to tag the
222
213
potential, based on the KIM schema.
223
214
:type extra_tags: dict
224
- :return: instance of ``LammpsPotentialData``, stored if taken from
225
- database, unstored otherwise.
226
- :raises TypeError: if the source is not a ``str``, ``pathlib.Path``
227
- instance or binary stream.
215
+ :return: instance of ``LammpsPotentialData``, stored if taken from database, unstored otherwise.
216
+ :raises TypeError: if the source is not a ``str``, ``pathlib.Path`` instance or binary stream.
228
217
:raises FileNotFoundError: if the source is a filepath but does not exist.
229
218
"""
230
219
# pylint: disable=too-many-arguments
@@ -253,9 +242,10 @@ def get_or_create(
253
242
return potential
254
243
255
244
@classmethod
256
- def get_entry_point_name (cls ):
245
+ def get_entry_point_name (cls ) -> str :
257
246
"""Return the entry point name associated with this data class.
258
247
:return: the entry point name.
248
+ :rtype: str
259
249
"""
260
250
_ , entry_point = plugins .entry_point .get_entry_point_from_class (
261
251
cls .__module__ ,
@@ -268,8 +258,9 @@ def is_readable_byte_stream(stream) -> bool:
268
258
"""Return if object is a readable filelike object in binary mode or stream of bytes.
269
259
270
260
:param stream: the object to analyze.
271
- :returns : True if ``stream`` appears to be a readable filelike object
261
+ :return : True if ``stream`` appears to be a readable filelike object
272
262
in binary mode, False otherwise.
263
+ :rtype: bool
273
264
"""
274
265
return isinstance (stream , io .BytesIO ) or (
275
266
hasattr (stream , "read" ) and hasattr (stream , "mode" ) and "b" in stream .mode
@@ -285,6 +276,8 @@ def prepare_source(cls, source: Union[str, pathlib.Path, BinaryIO]) -> BinaryIO:
285
276
:raises TypeError: if the source is not a ``str``, ``pathlib.Path``
286
277
instance or binary stream.
287
278
:raises FileNotFoundError: if the source is a filepath but does not exist.
279
+ :return: byte stream with the potential information
280
+ :rtype: BinaryIO
288
281
"""
289
282
if not isinstance (
290
283
source , (str , pathlib .Path )
@@ -545,10 +538,10 @@ def pair_style(self) -> str:
545
538
return self .base .attributes .get ("pair_style" )
546
539
547
540
@property
548
- def species (self ) -> list :
541
+ def species (self ) -> list [ str ] :
549
542
"""Return the list of species which this potential can be used for.
550
543
:return: The list of chemical species which are contained in this potential.
551
- :rtype: list
544
+ :rtype: list[str]
552
545
"""
553
546
return self .base .attributes .get ("species" )
554
547
@@ -579,15 +572,15 @@ def content_origin(self) -> str:
579
572
return self .base .attributes .get ("content_origin" )
580
573
581
574
@property
582
- def content_other_locations (self ) -> Union [str , list ]:
575
+ def content_other_locations (self ) -> Union [str , list [ str ] ]:
583
576
"""
584
577
Return other locations where the potential can be found.
585
578
586
579
As based in the KIM schema. A description of and/or web address(es)
587
580
to other location(s) where the content is available.
588
581
589
582
:return: other locations where the potential can be found.
590
- :rtype: Union[str, list]
583
+ :rtype: Union[str, list[str] ]
591
584
"""
592
585
return self .base .attributes .get ("content_other_locations" )
593
586
@@ -621,7 +614,7 @@ def description(self) -> str:
621
614
return self .base .attributes .get ("description" )
622
615
623
616
@property
624
- def developer (self ) -> Union [str , list ]:
617
+ def developer (self ) -> Union [str , list [ str ] ]:
625
618
"""
626
619
Return the developer information of this potential.
627
620
@@ -632,7 +625,7 @@ def developer(self) -> Union[str, list]:
632
625
of an interatomic model or a specific parameter set for it.
633
626
634
627
:return: developer information of this potential
635
- :rtype: Union[str, list]
628
+ :rtype: Union[str, list[str] ]
636
629
"""
637
630
return self .base .attributes .get ("developer" )
638
631
@@ -651,14 +644,14 @@ def disclaimer(self) -> str:
651
644
return self .base .attributes .get ("disclaimer" )
652
645
653
646
@property
654
- def properties (self ) -> Union [str , list ]:
647
+ def properties (self ) -> Union [str , list [ str ] ]:
655
648
"""
656
649
Return the properties for which this potential was devised.
657
650
658
651
As based in the KIM schema. A list of properties reported by a KIM Item.
659
652
660
653
:return: properties fow which this potential was devised.
661
- :rtype: Union[str, list]
654
+ :rtype: Union[str, list[str] ]
662
655
"""
663
656
return self .base .attributes .get ("properties" )
664
657
@@ -675,15 +668,15 @@ def publication_year(self) -> Union[str, datetime.datetime, int]:
675
668
return self .base .attributes .get ("publication_year" )
676
669
677
670
@property
678
- def source_citations (self ) -> Union [str , list ]:
671
+ def source_citations (self ) -> Union [str , list [ str ] ]:
679
672
"""
680
673
Return the citation where the potential was originally published.
681
674
682
675
As based in the KIM schema. An array of BibTeX-style EDN dictionaries
683
676
corresponding to primary published work(s) describing the KIM Item.
684
677
685
678
:return: the citation where the potential was originally published.
686
- :rtype: Union[str, list]
679
+ :rtype: Union[str, list[str] ]
687
680
"""
688
681
return self .base .attributes .get ("source_citations" )
689
682
0 commit comments