Importing Libraries: Difference between revisions
Line 21: | Line 21: | ||
[[File:Importing_libraries_numpy_import_in_python.png]] | [[File:Importing_libraries_numpy_import_in_python.png]] | ||
==Variables Using Libraries== | |||
Variables and parameters in GRC can now use the NumPy library directly, both for the creation and manipulation of values. For example, the ''sequentialArray'' variable is created using NumPy’s arange() function: | |||
[[File:Importing_libraries_sequential_array_variable.png]] | |||
The ''sequentialArray'' variable is then manipulated by the ''reversedArray'' variable, reversing the order of the array: | |||
[[File:Importing_libraries_reversed_array_variable.png]] |
Revision as of 21:33, 10 April 2024
The import block enables calls to Python-based libraries such as NumPy within GRC, allowing for more sophistication in the use and creation of variables and parameters for blocks.
Import Block
Drag the Import block into the flowgraph.
Double-click the Import block to bring up the properties. The Import field receives any legal Python import statement. For this example, the Numpy library is imported as np.
The Import block then displays the imported library as np.
Running the flowgraph generates a Python flowgraph of the same name, ending in .py. Opening the .py file displays the import statement:
Variables Using Libraries
Variables and parameters in GRC can now use the NumPy library directly, both for the creation and manipulation of values. For example, the sequentialArray variable is created using NumPy’s arange() function:
The sequentialArray variable is then manipulated by the reversedArray variable, reversing the order of the array: