How to use the julia.Julia function in julia

To help you get started, we’ve selected a few julia examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JuliaPy / pyjulia / test / test_core.py View on Github external
import array
import math
import unittest

from julia import Julia, JuliaError
import sys
import os

python_version = sys.version_info


julia = Julia(jl_runtime_path=os.getenv("JULIA_EXE"), debug=True)

class JuliaTest(unittest.TestCase):

    def test_call(self):
        julia._call('1 + 1')
        julia._call('sqrt(2.0)')

    def test_eval(self):
        self.assertEqual(2, julia.eval('1 + 1'))
        self.assertEqual(math.sqrt(2.0), julia.eval('sqrt(2.0)'))
        self.assertEqual(1, julia.eval('PyObject(1)'))
        self.assertEqual(1000, julia.eval('PyObject(1000)'))
        self.assertEqual((1, 2, 3), julia.eval('PyObject((1, 2, 3))'))

    def test_call_error(self):
        try:
github e2nIEE / pandapower / pandapower / opf / pm_conversion.py View on Github external
def _call_powermodels(buffer_file, julia_file):  # pragma: no cover
    # checks if julia works, otherwise raises an error
    try:
        import julia
        from julia import Main
    except ImportError:
        raise ImportError("Please install pyjulia to run pandapower with PowerModels.jl")
    try:
        j = julia.Julia()
    except:
        raise UserWarning(
            "Could not connect to julia, please check that Julia is installed and pyjulia is correctly configured")

    # import two julia scripts and runs powermodels julia_file
    Main.include(os.path.join(pp_dir, "opf", 'pp_2_pm.jl'))
    try:
        run_powermodels = Main.include(julia_file)
    except ImportError:
        raise UserWarning("File %s could not be imported" % julia_file)
    result_pm = run_powermodels(buffer_file)
    return result_pm
github JuliaPy / pyjulia / src / julia / ipy / monkeypatch_completer.py View on Github external
def __init__(self, julia=None):
        from julia import Julia

        self.julia = Julia() if julia is None else julia
        self.magic_re = re.compile(r".*(\s|^)%%?julia\s*")
        # With this regexp, "=%julia Cha" won't work.  But maybe
github odlgroup / odl / odl / contrib / shearlab / shearlab_operator.py View on Github external
def load_julia_with_Shearlab():
    """Function to load Shearlab."""
    # Importing base
    j = julia.Julia()
    j.eval('using Shearlab')
    j.eval('using PyPlot')
    j.eval('using Images')
    return j
github una-dinosauria / Rayuela.jl / smac / configure.py View on Github external
# Import ConfigSpace and different types of parameters
from smac.configspace import ConfigurationSpace
from ConfigSpace.hyperparameters import CategoricalHyperparameter, \
    UniformFloatHyperparameter, UniformIntegerHyperparameter
from ConfigSpace.conditions import InCondition

# Import SMAC-utilities
from smac.tae.execute_func import AbstractTAFunc
from smac.scenario.scenario import Scenario
from smac.facade.smac_facade import SMAC

# Otherwise we leak GPU memory. See https://github.com/JuliaGPU/CuArrays.jl/releases/tag/v0.6.1
os.environ['CUARRAYS_MANAGED_POOL'] = 'false'

j = julia.Julia()
j.include("smac/test_lsq.jl")
rdqb = j.eval("smac_util.run_demos_query_base")
rdtqb = j.eval("smac_util.run_demos_train_query_base")

# call_counter = 1


def recall_from_cfg(cfg):
    """ Runs MCQ from julia based on the passed configuration

    Params
    cfg: Configuration (ConfigSpace.ConfigurationSpace.Configuration)
        Configuration containing the parameters.
        Configurations are indexable!

    Returns: