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

Update flake lock and add new CI tests #415

Merged
merged 7 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 33 additions & 32 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
inputs.ihaskell.inputs.nixpkgs.follows = "nixpkgs";
inputs.ihaskell.inputs.flake-compat.follows = "flake-compat";
inputs.ihaskell.inputs.flake-utils.follows = "flake-utils";
inputs.npmlock2nix.url = "github:nix-community/npmlock2nix";
inputs.npmlock2nix.url = "github:nix-community/npmlock2nix/0ba0746d62974403daf717cded3f24c617622bc7";
inputs.npmlock2nix.flake = false;
inputs.opam-nix.url = "github:tweag/opam-nix/fix-list-repo-func";
inputs.opam-nix.url = "github:tweag/opam-nix/75199758e1954f78286e7e79c0e3916e28b732b0";
inputs.opam-nix.inputs.flake-compat.follows = "flake-compat";
inputs.opam-nix.inputs.flake-utils.follows = "flake-utils";
inputs.opam-nix.inputs.nixpkgs.follows = "nixpkgs";
Expand Down Expand Up @@ -192,14 +192,14 @@
alejandra.enable = true;
typos = {
enable = true;
name = "typos";
description = "Source code spell checker";
entry = "${pkgs.typos}/bin/typos --write-changes --config _typos.toml";
types = ["file"];
files = "\\.((txt)|(md)|(nix)|\\d)$";
};
};
excludes = ["^\\.jupyter/"]; # JUPYTERLAB_DIR
settings = {
typos.write = true;
};
};

mkdocs = python.withPackages (p: [
Expand Down
11 changes: 11 additions & 0 deletions kernels/example/python/science/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
availableKernels,
name,
extraArgs,
}:
availableKernels.python {
inherit name;
inherit (extraArgs) system;
displayName = "Example Python Kernel";
extraPackages = ps: [ps.numpy ps.scipy ps.matplotlib];
}
69 changes: 69 additions & 0 deletions kernels/example/python/science/test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "d13cad64-62c0-4b87-b8ef-0242658baa0f",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import scipy as sp\n",
"import matplotlib as mpl"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "16f8a525-ab66-407d-b978-78af1ee27a4d",
"metadata": {},
"outputs": [],
"source": [
"x = np.arange(5)\n",
"print(x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "97728667-fbc5-4e71-a3b7-52f174309b92",
"metadata": {},
"outputs": [],
"source": [
"y_new = sp.interpolate.interp1d(x, x ** 2)(x[:-1] + 0.5)\n",
"print(y_new)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d03e077a-add4-472f-afba-0c1f17e0159a",
"metadata": {},
"outputs": [],
"source": [
"print(mpl.colormaps['viridis'].resampled(8)(0.56))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Example Python Kernel",
"language": "python",
"name": "example-python-science"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
19 changes: 19 additions & 0 deletions kernels/example/python/science/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
from testbook import testbook

current_dir = os.path.dirname(os.path.abspath(__file__))

@testbook(f'{current_dir}/test.ipynb', execute=True, kernel_name="example-python-science")
def test_nb(tb):
np_result = tb.cell_output_text(1)
assert np_result == "[0 1 2 3 4]"

sp_result = tb.cell_output_text(2)
assert sp_result == "[ 0.5 2.5 6.5 12.5]"

mpl_result = tb.cell_output_text(3)
assert mpl_result == "(0.122312, 0.633153, 0.530398, 1.0)"

if __name__ == '__main__':
test_nb()