Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce print_citations() in notebooks #1330

Closed
valentinsulzer opened this issue Jan 20, 2021 · 6 comments · Fixed by #1340
Closed

Enforce print_citations() in notebooks #1330

valentinsulzer opened this issue Jan 20, 2021 · 6 comments · Fixed by #1340
Assignees

Comments

@valentinsulzer
Copy link
Member

All notebooks should have the cell pybamm.print_citations() at the end, to encourage people to use this command.
This can be enforced using regex when running the example tests.

@brosaplanella
Copy link
Member

I agree. I would also suggest then to print citations in a more friendly format (probably a LaTeX format won't be possible) but at least some sort of plain text reference list. This links to issue #1182.

@rtimms
Copy link
Contributor

rtimms commented Jan 21, 2021

pybtex seems to work ok now

e.g.

import pybamm
import pybtex

model = pybamm.lithium_ion.SPM()

sim = pybamm.Simulation(model)
sim.solve([0, 3600])
pybamm.print_citations(filename="test.bib")
print(pybtex.format_from_file("test.bib", "unsrt", output_backend="plaintext"))

you can output to markdown too and pick different styles

@brosaplanella
Copy link
Member

That is really cool! Is there a way of doing it without generating a bibtex file every time?

@rtimms
Copy link
Contributor

rtimms commented Jan 22, 2021

You can point to a particular file and then pick some keys to cite

print(pybtex.format_from_file("test.bib", "unsrt", citations=["sulzer2020python", "harris2020array"], output_backend="plaintext"))   

In theory we should just be able to point to our CITATIONS.txt and pass the relevant keys, but I was getting an error when I tried to do this. I think it is a bit picky about how things are typed out/formatted in the bib file...

@rtimms
Copy link
Contributor

rtimms commented Jan 22, 2021

Yeah, e.g doing

print(pybtex.format_from_file("pybamm/CITATIONS.txt", "unsrt", citations=["sulzer2020python", "harris2020array"], output_backend="plaintext"))   

works, but if you don't pass the citations argument (so that it print all citations) it fails. Think it will be a boring job of fixing commas etc, but then in future we can test to make sure it prints ok so that you just fix a single entry.

@brosaplanella
Copy link
Member

Sounds good! It seems that in order to print all the citations you need to pass "[*]". I am happy to give it a go as it lines up with #1182 which I need to tackle at some point.

@brosaplanella brosaplanella self-assigned this Jan 22, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 23, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 23, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 23, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 23, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 23, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 23, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 23, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 24, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 24, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 24, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 24, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 24, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 24, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 24, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 24, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 24, 2021
brosaplanella added a commit to brosaplanella/PyBaMM that referenced this issue Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants