You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Carefully document which fields are used by your function or method.
42
42
43
43
* Dictionary-like objects may be allowed for user input, but should be internally converted to a ``DataClass`` object with the `~sbpy.data.dataclass_input` decorator:
44
44
45
-
.. code-block:: python
46
-
47
-
@dataclass_input(eph=Ephem)
48
-
defH11(eph):
49
-
...
45
+
.. code-block:: python
50
46
51
-
The same, but using function annotations:
52
-
53
-
.. code-block:: python
54
-
55
-
@dataclass_input
56
-
defH11(eph: Ephem):
57
-
...
47
+
@dataclass_input(eph=Ephem)
48
+
defH11(eph):
49
+
...
50
+
51
+
The same, but using function annotations:
52
+
53
+
.. code-block:: python
54
+
55
+
@dataclass_input
56
+
defH11(eph: Ephem):
57
+
...
58
58
59
59
* Exceptions are allowed when only one parameter is needed, e.g., ``phase_func(phase)``. But instead consider using the relevant ``DataClass`` object, and decorating the function with `~sbpy.data.quantity_to_dataclass`:
60
60
61
-
.. code-block:: python
61
+
.. code-block:: python
62
62
63
-
@quantity_to_dataclass(eph=(Ephem, 'phase'))
64
-
defphase_func(eph):
65
-
...
63
+
@quantity_to_dataclass(eph=(Ephem, 'phase'))
64
+
defphase_func(eph):
65
+
...
66
66
67
-
The decorator may be stacked with``dataclass_input``for maximum
68
-
flexibility:
67
+
The decorator may be stacked with ``dataclass_input`` for maximum
68
+
flexibility:
69
69
70
-
.. code-block:: python
70
+
.. code-block:: python
71
71
72
-
@dataclass_input
73
-
@quantity_to_dataclass(eph=(Ephem, 'phase'))
74
-
def phase_func(eph):
75
-
...
72
+
@dataclass_input
73
+
@quantity_to_dataclass(eph=(Ephem, 'phase'))
74
+
defphase_func(eph):
75
+
...
76
76
77
77
78
78
Append fields to ``DataClass`` at the user's request
@@ -94,11 +94,11 @@ Cite relevant works
94
94
95
95
* Citations may be executed internally with :func:`sbpy.bib.register`, or via the `~sbpy.bib.cite` decorator:
96
96
97
-
.. code-block:: python
97
+
.. code-block:: python
98
98
99
-
@cite({'method': '1687pnpm.book.....N'})
100
-
def force(mass, acceleration):
101
-
return mass * acceleration
99
+
@cite({'method': '1687pnpm.book.....N'})
100
+
defforce(mass, acceleration):
101
+
return mass * acceleration
102
102
103
103
* Labels describing references (``'method'`` in the above example) are
104
104
required to start with the following strings: ``'method'`` (for
0 commit comments