-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from mwouts/v0.4.1
V0.4.1
- Loading branch information
Showing
6 changed files
with
128 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import nbrmd | ||
import re | ||
from testfixtures import compare | ||
|
||
|
||
def test_read_mostly_py_rmd_file(rmd="""# --- | ||
# title: Simple file | ||
# --- | ||
```{python, echo=TRUE} | ||
x = np.arange(0, 2*math.pi, eps) | ||
``` | ||
```{python, echo=TRUE} | ||
x = np.arange(0,1,eps) | ||
y = np.abs(x)-.5 | ||
``` | ||
```{r} | ||
ls() | ||
``` | ||
```{r, results='asis'} | ||
cat(stringi::stri_rand_lipsum(3), sep='\n\n') | ||
``` | ||
"""): | ||
nb = nbrmd.reads(rmd, ext='.Rmd') | ||
assert nb.metadata == {'main_language': 'python'} | ||
assert nb.cells == [{'cell_type': 'markdown', | ||
'source': '# ---\n# title: Simple file\n# ---', | ||
'metadata': {}}, | ||
{'cell_type': 'code', | ||
'metadata': {'hide_input': False}, | ||
'execution_count': None, | ||
'source': 'x = np.arange(0, 2*math.pi, eps)', | ||
'outputs': []}, | ||
{'cell_type': 'code', | ||
'metadata': {'hide_input': False}, | ||
'execution_count': None, | ||
'source': 'x = np.arange(0,1,eps)\ny = np.abs(x)-.5', | ||
'outputs': []}, | ||
{'cell_type': 'code', | ||
'metadata': {}, | ||
'execution_count': None, | ||
'source': '%%R\nls()', | ||
'outputs': []}, | ||
{'cell_type': 'code', | ||
'metadata': {'results': "'asis'"}, | ||
'execution_count': None, | ||
'source': "%%R\ncat(stringi::" | ||
"stri_rand_lipsum(3), sep='\n\n')", | ||
'outputs': []}] | ||
|
||
rmd2 = nbrmd.writes(nb, ext='.Rmd') | ||
rmd2 = re.sub(r'```{r ', '```{r, ', rmd2) | ||
rmd2 = re.sub(r'```{python ', '```{python, ', rmd2) | ||
compare(rmd, rmd2) |