Skip to content

Commit

Permalink
update PDG identifiers to use latex description
Browse files Browse the repository at this point in the history
  • Loading branch information
karolina-siemieniuk-morawska committed Jun 10, 2024
1 parent 7aab90e commit bfe7472
Show file tree
Hide file tree
Showing 8 changed files with 19,964 additions and 11,399 deletions.
11,376 changes: 0 additions & 11,376 deletions backend/inspirehep/records/marshmallow/literature/pdg_identifiers.py

This file was deleted.

19,929 changes: 19,929 additions & 0 deletions backend/inspirehep/records/marshmallow/literature/pdg_identifiers_latex.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions backend/inspirehep/records/marshmallow/literature/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
PublicationInfoItemSchemaV1,
ThesisInfoSchemaV1,
)
from .pdg_identifiers import PDG_IDS_TO_DESCRIPTION_MAPPING
from .pdg_identifiers_latex import PDG_IDS_TO_LATEX_DESCRIPTION_MAPPING

DATASET_SCHEMA_TO_URL_PREFIX_MAP = {
"hepdata": "https://www.hepdata.net/record/",
Expand Down Expand Up @@ -285,7 +285,7 @@ def get_pdg_keywords(self, data):
pdg_keywords.append(
{
"value": pdg_identifier,
"description": PDG_IDS_TO_DESCRIPTION_MAPPING[pdg_identifier],
"description": PDG_IDS_TO_LATEX_DESCRIPTION_MAPPING[pdg_identifier],
}
)

Expand Down
4 changes: 2 additions & 2 deletions backend/tests/integration-async/curation/test_curation_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


@mock.patch(
"inspirehep.records.marshmallow.literature.ui.PDG_IDS_TO_DESCRIPTION_MAPPING",
"inspirehep.records.marshmallow.literature.ui.PDG_IDS_TO_LATEX_DESCRIPTION_MAPPING",
{
"S000": "gamma (photon)",
"S000.99": "test",
Expand Down Expand Up @@ -134,7 +134,7 @@ def assert_keywords_are_updated():


@mock.patch(
"inspirehep.records.marshmallow.literature.ui.PDG_IDS_TO_DESCRIPTION_MAPPING",
"inspirehep.records.marshmallow.literature.ui.PDG_IDS_TO_LATEX_DESCRIPTION_MAPPING",
{
"S000": "gamma (photon)",
"S000.99": "test",
Expand Down
19 changes: 11 additions & 8 deletions backend/tests/unit/records/marshmallow/literature/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,29 +280,32 @@ def test_documents_doesnt_contain_error_from_fulltext(
serialized = serializer.dump(entry_data).data
assert "_error" not in serialized


def test_filter_non_pdg_keywords():
data = {
"keywords": [
{ "schema": "PDG", "source": "PDG", "value": "M013WX" },
{ "source": "publisher", "value": "Strong Interactions" },
{"schema": "PDG", "source": "PDG", "value": "M013WX"},
{"source": "publisher", "value": "Strong Interactions"},
]
}
expected_data = [
{ "source": "publisher", "value": "Strong Interactions" }
]
expected_data = [{"source": "publisher", "value": "Strong Interactions"}]
serializer = LiteratureDetailSchema()
serialized = serializer.dump(data).data
assert serialized["keywords"] == expected_data


def test_filter_pdg_keywords():
data = {
"keywords": [
{ "schema": "PDG", "source": "PDG", "value": "M013WX" },
{ "source": "publisher", "value": "Strong Interactions" },
{"schema": "PDG", "source": "PDG", "value": "M013WX"},
{"source": "publisher", "value": "Strong Interactions"},
]
}
expected_data = [
{ "value": "M013WX", "description": "f(2)'(1525) WIDTH" }
{
"value": "M013WX",
"description": "${{\\mathit f}_{{{2}}}^{\\,'}{(1525)}}$ WIDTH",
}
]
serializer = LiteratureDetailSchema()
serialized = serializer.dump(data).data
Expand Down
19 changes: 12 additions & 7 deletions ui/src/literature/components/PDGKeywords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { Modal, List } from 'antd';

import SecondaryButton from '../../common/components/SecondaryButton';
import LinkWithTargetBlank from '../../common/components/LinkWithTargetBlank';
import Latex from '../../common/components/Latex';

interface IKeyword {
get: (arg: string) => string;
size: number;
valueSeq: () => {get: (arg: number) => IKeyword}
valueSeq: () => { get: (arg: number) => IKeyword };
}

export const PDGKeywords = ({ keywords }: { keywords: IKeyword }) => {
Expand All @@ -26,10 +27,12 @@ export const PDGKeywords = ({ keywords }: { keywords: IKeyword }) => {
const renderKeyword = (keyword: IKeyword) => {
const keywordValue = keyword && keyword.get('value');
const keywordDescription = keyword && keyword.get('description');

return (
<LinkWithTargetBlank href={`https://pdglive.lbl.gov/view/${keywordValue}`}>
{keywordDescription}
<LinkWithTargetBlank
href={`https://pdglive.lbl.gov/view/${keywordValue}`}
>
<Latex>{keywordDescription}</Latex>
</LinkWithTargetBlank>
);
};
Expand All @@ -46,18 +49,20 @@ export const PDGKeywords = ({ keywords }: { keywords: IKeyword }) => {
open={modalVisibility}
footer={null}
onCancel={toggleModal}
bodyStyle={{padding: '12px 24px 24px 24px'}}
bodyStyle={{ padding: '12px 24px 24px 24px' }}
>
<List
// @ts-ignore
dataSource={keywords}
size="small"
pagination={{
pageSize: 10,
size: "small",
size: 'small',
hideOnSinglePage: true,
}}
renderItem={(keyword: IKeyword) => <List.Item>{renderKeyword(keyword)}</List.Item>}
renderItem={(keyword: IKeyword) => (
<List.Item>{renderKeyword(keyword)}</List.Item>
)}
/>
</Modal>
</>
Expand Down
6 changes: 4 additions & 2 deletions ui/src/literature/components/__tests__/PDGKeywords.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ describe('PDGKeywords', () => {
const keywords = fromJS([
{
value: 'Q007TP',
description: 'Test description'
description:
// eslint-disable-next-line no-template-curly-in-string
'\\Gamma($ ${{\\mathit W}^{+}}$ $\\rightarrow$ ${{\\mathit \\ell}^{+}}{{\\mathit \\nu}})/\\Gamma_{\\text{total}}',
},
{
value: '2137',
description: 'test'
description: 'test',
},
]);
const wrapper = shallow(<PDGKeywords keywords={keywords} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ exports[`PDGKeywords renders with keywords 1`] = `
as="a"
href="https://pdglive.lbl.gov/view/Q007TP"
>
Test description
<Latex>
\\Gamma($ \${{\\mathit W}^{+}}$ $\\rightarrow$ \${{\\mathit \\ell}^{+}}{{\\mathit \\nu}})/\\Gamma_{\\text{total}}
</Latex>
</LinkWithTargetBlank>
<div
className="di pl2"
Expand Down Expand Up @@ -38,7 +40,7 @@ exports[`PDGKeywords renders with keywords 1`] = `
Immutable.List [
Immutable.Map {
"value": "Q007TP",
"description": "Test description",
"description": "\\\\Gamma($ \${{\\\\mathit W}^{+}}$ $\\\\rightarrow$ \${{\\\\mathit \\\\ell}^{+}}{{\\\\mathit \\\\nu}})/\\\\Gamma_{\\\\text{total}}",
},
Immutable.Map {
"value": "2137",
Expand Down

0 comments on commit bfe7472

Please sign in to comment.