How to use Python in Engee scripts
In this example, we will look at the principles of interacting with Python from the Engee environment and do some exercises with graphs.
Getting started
Language selection Python:
using PyCall
using Plots
Importing a computing library NumPy:
py"""
import numpy as np # Фундаментальный пакет для научных вычислений
"""
Plotting graphs
Plotting graphs by points:
plot(py"""[1, 2]""",py"""[3, 4]""")# Отрисовка возрастающего графика
plot!(py"""[1, 2]""",py"""[4, 3]""") # Отрисовка убывающего графика
Building multiple graphs
Declaring a function for plotting graphs.
py"""
def f(t):
return np.exp(-t) * np.cos(2*np.pi*t) # Математическая формула
"""
Declaring arrays.
py"""
t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)
"""
Plotting graphs.
plot(py"""t2""", py"""np.cos(2*np.pi*t2)""")
plot(py"""t1""", py"""f(t1)""")
plot!(py"""t2""", py"""f(t2)""")
It is also possible to import Python libraries directly into Engee. Let's consider such an example by connecting the Math and Numpy libraries.
math = pyimport("math")
To demonstrate the efficiency of this approach, we will use the sin functions for constants and vectors.
math.sin(math.radians(90))
a = math.pi/4;
math.sin(a)
As we can see from the example above, you can set values in Engee and then use them using the Python functions.
a = [1,2,3]
numpy = pyimport("numpy")
a = numpy.sin(a)
using Plots
plot(a)
From this example, it can be seen that we can also work with vector values and process them not only using the Engee, julia functionality, but also using Python.
Conclusion
In this example, we have demonstrated the capabilities of Engee in writing and implementing algorithms in Python. In the modern world, this option is in high demand, as Python is very popular, and a huge amount of functionality is implemented in this language.



