File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ - read through everything
2+ - check docstrings
3+ - check naming (if you want to propose a consistent naming convention, go for it)
4+ - consider adding ` m_error_v_w.build_instances ` too, might be headache to pass arrays of things up and down correctly
5+ - clean up
6+ - final review (including deleting this file)
7+ - merge
8+ - move onto a basic result type with a subclass specifically for integers (` ResultInt ` or something)
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ if pyprojectwheelbuild_enabled
8282 ' src/example_fgen_basic/get_wavelength.py' ,
8383 ' src/example_fgen_basic/pyfgen_runtime/__init__.py' ,
8484 ' src/example_fgen_basic/pyfgen_runtime/exceptions.py' ,
85+ ' src/example_fgen_basic/typing.py' ,
8586 )
8687
8788 # The ancillary library,
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ source = [
149149]
150150branch = true
151151omit = [
152- # TODO: check this file
152+ # TODO: test these files directly when splitting out pyfgen_runtime
153153 " *exceptions.py" ,
154154 " *runtime_helpers.py" ,
155155]
Original file line number Diff line number Diff line change 2828 ) from exc
2929
3030if TYPE_CHECKING :
31- # TODO: bring back in numpy type hints
32- NP_ARRAY_OF_INT = None
31+ from example_fgen_basic .typing import NP_ARRAY_OF_INT
3332
3433
3534def create_error (inv : int ) -> ErrorV :
Original file line number Diff line number Diff line change 22! >
33! > Written by hand here.
44! > Generation to be automated in future (including docstrings of some sort).
5- !
6- ! TODO: make it possible to reallocate the number of instances
75module m_error_v_manager
86
97 use m_error_v, only: ErrorV
Original file line number Diff line number Diff line change 3030 ) from exc
3131
3232if TYPE_CHECKING :
33- # TODO: bring back in numpy type hints
34- NP_ARRAY_OF_INT = None
35- NP_ARRAY_OF_BOOL = None
33+ from example_fgen_basic .typing import NP_ARRAY_OF_BOOL , NP_ARRAY_OF_INT
3634
3735
3836def pass_error (inv : ErrorV ) -> bool :
Original file line number Diff line number Diff line change 1+ """
2+ Type hints which are too annoying to remember
3+ """
4+
5+ from __future__ import annotations
6+
7+ from typing import TYPE_CHECKING
8+
9+ if TYPE_CHECKING :
10+ from typing import Any , TypeAlias , Union
11+
12+ import numpy as np
13+ import numpy .typing as npt
14+
15+ NP_ARRAY_OF_INT : TypeAlias = npt .NDArray [np .integer ]
16+ """
17+ Type alias for an array of numpy int
18+ """
19+
20+ NP_ARRAY_OF_FLOAT : TypeAlias = npt .NDArray [np .floating ]
21+ """
22+ Type alias for an array of numpy floats
23+ """
24+
25+ NP_FLOAT_OR_INT : TypeAlias = Union [np .floating , np .integer ]
26+ """
27+ Type alias for a numpy float or int (not complex)
28+ """
29+
30+ NP_ARRAY_OF_FLOAT_OR_INT : TypeAlias = npt .NDArray [NP_FLOAT_OR_INT ]
31+ """
32+ Type alias for an array of numpy float or int (not complex)
33+ """
34+
35+ NP_ARRAY_OF_NUMBER : TypeAlias = npt .NDArray [np .number [Any ]]
36+ """
37+ Type alias for an array of numpy float or int (including complex)
38+ """
39+
40+ NP_ARRAY_OF_BOOL : TypeAlias = npt .NDArray [np .bool ]
41+ """
42+ Type alias for an array of booleans
43+ """
You can’t perform that action at this time.
0 commit comments