Skip to content

Commit

Permalink
Store citations as list (#13)
Browse files Browse the repository at this point in the history
* Update YAML files

* Update documentation

---------

Co-authored-by: Rastislav Turanyi <[email protected]>
  • Loading branch information
RastislavTuranyi and Rastislav Turanyi authored Jan 13, 2025
1 parent 9a07eca commit 5061e3f
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class and get the instrument object of your choice:

```
>>> from resolution_functions import Instrument
>>> tosca = Instrument('TOSCA')
>>> tosca = Instrument.from_default('TOSCA')
>>> tosca
Instrument(name='TOSCA', version='TOSCA', models=['AbINS', 'book', 'vision'])
```
Expand All @@ -36,8 +36,8 @@ which model you want to use, as well as any model-specific parameters.
<Signature (model_name: Optional[str] = 'book', *, detector_bank: Literal['Backward', 'Forward'] = 'Backward', _) -> resolution_functions.models.tosca_book.ToscaBookModel>
>>> # Now we can get the resolution function
>>> book = tosca.get_resolution_function('book', detector_bank='Forward')
>>> book
<resolution_functions.models.tosca_book.ToscaBookModel object at 0x000000000>
>>> print(book)
ToscaBookModel(citation=[''])
>>> book(100)
0.81802604002035
>>> import numpy as np
Expand Down
4 changes: 2 additions & 2 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ via the
method:

>>> book = tosca.get_resolution_function('book', detector_bank='Forward')
>>> book
<resolution_functions.models.tosca_book.ToscaBookModel object at 0x000000000>
>>> print(book)
ToscaBookModel(citation=[''])

.. note::

Expand Down
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/arcs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ version:
models:
PyChop_fit:
function: "pychop_fit_fermi"
citation: ""
citation: [""]
parameters:
<<: *constants
settings: *settings
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/cncs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ version:
models:
PyChop_fit:
function: "pychop_fit_cncs"
citation: ""
citation: [""]
parameters:
<<: *constants
settings: *settings
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/hyspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ version:
models:
PyChop_fit:
function: "pychop_fit_fermi"
citation: ""
citation: [""]
parameters:
<<: *constants
settings: *settings
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/lagrange.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ version:
models:
AbINS:
function: "discontinuous_polynomial"
citation: ""
citation: [""]
parameters: {}
settings: *lagrange_settings
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/let.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ version:
models:
PyChop_fit:
function: "pychop_fit_let"
citation: ""
citation: [""]
parameters:
<<: *constants
settings: *settings
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/maps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ version:
models:
PyChop_fit:
function: "pychop_fit_fermi"
citation: ""
citation: [""]
parameters:
<<: *maps_constants
settings: *maps_settings
Expand Down
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/mari.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ version:
models:
PyChop_fit:
function: "pychop_fit_fermi"
citation: ""
citation: [""]
parameters:
<<: *mari_constants
settings: *mari_settings
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/merlin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ version:
models:
PyChop_fit:
function: "pychop_fit_fermi"
citation: ""
citation: [""]
parameters:
<<: *constants
settings: *settings
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/panther.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ version:
# sigma = polyval(abs_meV, ɛ) + polyval(ei_dependence, E_i) + polyval(ei_energy_product, E_i × ɛ)
# (Here a quartic polynomial in ɛ, plus quadratic on Ei and cubic on ɛ×Ei)
function: "panther_abins_polynomial"
citation: ""
citation: [""]
settings: {}
parameters:
abs:
Expand Down
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/sequoia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ version:
models:
PyChop_fit:
function: "pychop_fit_fermi"
citation: ""
citation: [""]
parameters:
<<: *constants
settings: *settings
10 changes: 5 additions & 5 deletions src/resolution_functions/instrument_data/tosca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ version:
models:
book:
function: "tosca_book"
citation: ""
citation: [""]
parameters: *tfxa_constants
settings: *tfxa_settings
TOSCA1:
Expand Down Expand Up @@ -60,7 +60,7 @@ version:
models:
book:
function: "tosca_book"
citation: ""
citation: [""]
parameters: *tosca1_constants
settings: *tosca1_settings
TOSCA:
Expand Down Expand Up @@ -88,14 +88,14 @@ version:
# sigma = tosca_a * omega * omega + tosca_b * omega + tosca_c
# where sigma is width of Gaussian function
function: "polynomial_1d"
citation: ""
citation: [""]
#original_parameters: [2.5, 0.005, 0.0000001] wavenumber
parameters:
fit: [ 0.3099604960830007, 0.005, 8.065543937349209e-07 ] # meV
settings: {}
book:
function: "tosca_book"
citation: ""
citation: [""]
parameters:
<<: *tosca_constants
water_moderator_constant: 44 # us
Expand All @@ -118,7 +118,7 @@ version:
change_average_bragg_angle_graphite: 17.59374274222979
vision:
function: "vision_paper"
citation: "https://doi.org/10.1016/j.nima.2009.03.204"
citation: ["https://doi.org/10.1016/j.nima.2009.03.204"]
parameters:
<<: *tosca_constants
d_r: 12.9e-6
Expand Down
2 changes: 1 addition & 1 deletion src/resolution_functions/instrument_data/vision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ version:
models:
vision:
function: "vision_paper"
citation: "https://doi.org/10.1016/j.nima.2009.03.204"
citation: ["https://doi.org/10.1016/j.nima.2009.03.204"]
parameters:
<<: *vision_constants
d_r: 11.6e-6
Expand Down
6 changes: 3 additions & 3 deletions src/resolution_functions/models/model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ModelData(ABC):
defaults
"""
function: str
citation: str
citation: list[str]

@property
def restrictions(self) -> dict[str, list[int | float]]:
Expand Down Expand Up @@ -174,10 +174,10 @@ def __call__(self, *args, **kwargs):
raise NotImplementedError()

def __str__(self) -> str:
return f'{type(self).__name__}(citation="{self.citation}")'
return f'{type(self).__name__}(citation={self.citation})'

@property
def citation(self) -> str:
def citation(self) -> list[str]:
"""
The citation for this model. Please use this to look up more details and cite the model.
Expand Down

0 comments on commit 5061e3f

Please sign in to comment.