roopesh puthalath
roopesh puthalath
MModular
Created by roopesh puthalath on 9/25/2023 in #questions
NumPy Stacking error ->error: failed to run the pass manager
from python import Python from time import sleep from python.object import PythonObject fn main() raises: let np = Python.import_module("numpy") # Create two numpy arrays var array1 = np.array([1, 2, 3]) var array2 = np.array([10, 20, 30])
var stackedarray = np.c[array1, array2] #let stacked_array = np.column_stack((array1, array2)) print(stacked_array)
3 replies
MModular
Created by roopesh puthalath on 9/22/2023 in #questions
Get list or tuple index by value.
'Tuple[StringLiteral, StringLiteral, StringLiteral]' is not subscriptable, it does not implement the __getitem__/__setitem__ methodsmojo. is there any ways to acheive this. also need to convert a mojo list to python list.
2 replies
MModular
Created by roopesh puthalath on 9/21/2023 in #questions
Example of ListLiteral -> Saves time for you
example for ListLiteral from python import Python fn main() raises: var Sample_list = ListLiteral("a", "b", "c", "d") var element = Sample_list.get2, StringLiteral # 2 is the index , get the element at index 2 print (element) print("Length of the list:", Sample_list.len()) # will print a value of 4 , get the list length
1 replies
MModular
Created by roopesh puthalath on 9/20/2023 in #questions
Bug, while loop Re-setting values?
for some reason , the while loop is resetting the value of the variable state.is it a bug? var state = "dumb path" print("state assigned dumb path outside of loop", state) let v_sync_enable =glfw.swap_interval(1) while not glfw.window_should_close(window): let v1 = glfw.poll_events() let v2 = impl.process_inputs() let clear_context = glfw.make_context_current(window) let color_clear = gl.glClearColor(0.4, 0.4, 0.4, 1) let all_clear=gl.glClear(gl.GL_COLOR_BUFFER_BIT) let v3 = imgui.new_frame() if imgui.begin_main_menu_bar(): if imgui.begin_menu("File", True): let clicked_exit = imgui.menu_item( "Exit", '', False, True) if clickedexit: print("exit") = exit(0) let end_men =imgui.end_menu() let end_menubar=imgui.end_main_menu_bar() let begin = imgui.begin("My Window", True)
# Display the button and check if it's pressed if imgui.button("select d3plot file"): var state = open_file_explorer() print("state passed to var from function-now in main") print(state) print("state printed") print("candidate not viable:Pcalle expects 0 arguments but 2 ",state) if imgui.button("Load 3Dyna Results"): load_data(state) let end = imgui.end() let render=imgui.render() let impl_render = impl.render(imgui.get_draw_data()) let swap_buff = glfw.swap_buffers(window) let imp_shutdown=impl.shutdown() let terminate = glfw.terminate()
17 replies
MModular
Created by roopesh puthalath on 9/20/2023 in #questions
Printing the type of a variable in Mojo
is there a way to print the variable type in mojo? var state = open_file_explorer() print(type(state))
3 replies
MModular
Created by roopesh puthalath on 9/20/2023 in #questions
Global variable definition from a function?
creation of global variable from a function , with keyword like global. is there any plan to add such a feature?
5 replies
MModular
Created by roopesh puthalath on 9/18/2023 in #questions
Exit main
is there an exit function like exit(0)?
7 replies