Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import os
import sys
from julia import Main
script_dir = os.path.dirname(os.path.realpath(__file__))
Main.include(os.path.join(script_dir, "setup.jl"))
from julia import DifferentialEquations
sys.modules[__name__] = DifferentialEquations # mutate myself
from julia.api import Julia
jl = Julia(compiled_modules=False)
from julia import Main
cosmo_solver = Main.include("solver_explicit.jl")
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
# 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
def __getattr__(self, name):
from julia import Main
warnings.warn(
"Accessing `Julia().` to obtain Julia objects is"
" deprecated. Use `from julia import Main; Main.` or"
" `jl = Julia(); jl.eval('')`.",
FutureWarning,
)
try:
return getattr(self.__julia, name)
except AttributeError:
return getattr(Main, name)