module notebook.csmagics

Inheritance diagram of csharpy.notebook.csmagics

Short summary

module csharpy.notebook.csmagics

Defines magic commands to interact with C# in a Python notebook.

source on GitHub

Classes

class truncated documentation
CsMagics Defines magic commands for notebooks.

Functions

function truncated documentation
register_magics Registers magics commands.

Properties

property truncated documentation
Context return the context or None
cross_validation_lock A contextmanager for running a block with our cross validation lock set to True. At the end of the block, …

Static Methods

staticmethod truncated documentation
_linearise_args Makes the list of lists into a list.
_preprocess_line_cell_maml Preprocess the argument for method @see me CS.
CS_parser Defines the way to parse the magic command %%CS.

Methods

method truncated documentation
CS Defines magic command %%CS.

Documentation

Defines magic commands to interact with C# in a Python notebook.

source on GitHub

class csharpy.notebook.csmagics.CsMagics(shell=None, **kwargs)[source]

Bases: pyquickhelper.ipythonhelper.magic_class.MagicClassWithHelpers

Defines magic commands for notebooks.

source on GitHub

CS(line, cell)[source]

Defines magic command %%CS.

%%CS

The magic command wraps the C# code into a Python function the user can call.

%%CS cspower -i System
public static double cspower(double x, double y)
{
    if (y == 0) return 1.0 ;
    return System.Math.Pow(x,y) ;
}

To call it:

cspower(3.0, 3.0)

The magic command relies on create_cs_function and adds it to the notebook context. Dependencies are usually specified on the first line. However, it is quite inconvenient to have a very long first line so the first cell line of the cell will be seen as a continuation if they start by - like follows:

%%CS cspower
-i System
public static double cspower(double x, double y)
{
    if (y == 0) return 1.0 ;
    return System.Math.Pow(x,y) ;
}

source on GitHub

static CS_parser()[source]

Defines the way to parse the magic command %%CS.

source on GitHub

static _linearise_args(ll)[source]

Makes the list of lists into a list.

static _preprocess_line_cell_maml(line, cell)[source]

Preprocess the argument for method @see me CS.

_trait_default_generators = {}
csharpy.notebook.csmagics.register_magics(ip)[source]

Registers magics commands.

source on GitHub