Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to create variables in euler1d.py #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Gene0315
Copy link
Owner

Following the issue solvcon#361
The PR sets the plotting points as an array 'pt_plot'. And then, it changes the points shown on the figure from coord[::2] to coord[self.st.svr.pt_plot].

However, there is something wrong in this code. It failed to create the variable 'svr.pt_plot' in 'modmesh/modmesh/onedim/euler1d.py'.

@yungyuc
Copy link

yungyuc commented Jul 1, 2024

Please paste the complete traceback with the error

@Gene0315
Copy link
Owner Author

Gene0315 commented Jul 2, 2024

Please paste the complete traceback with the error

I ran the python files in VSCODE and got the traceback below.

Traceback (most recent call last):
  File "/Users/genelin/modmesh/modmesh/onedim/euler1d.py", line 14, in <module>
    from .._modmesh import onedim as _impl  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: attempted relative import with no known parent package

@yungyuc
Copy link

yungyuc commented Jul 2, 2024

What is the command you run? If you (cd /Users/genelin/modmesh/modmesh/onedim/; python3 euler1d.py), it's wrong. You need to make modmesh searchable in your path, and modmesh.onedim.euler1d cannot be executed as a script.

@Gene0315
Copy link
Owner Author

Gene0315 commented Jul 2, 2024

What is the command you run? If you (cd /Users/genelin/modmesh/modmesh/onedim/; python3 euler1d.py), it's wrong. You need to make modmesh searchable in your path, and modmesh.onedim.euler1d cannot be executed as a script.

Sorry, I think I ran the modmesh.onedim.euler1d directly.

@Gene0315
Copy link
Owner Author

Gene0315 commented Jul 2, 2024

In order to run the project correctly, I added a new file startu.py to execute the viewer. I ran it in VSCODE, and pressed the button 'Euler solver' like the picture below.
image

However, It failed to run the code and the messages are

bash-3.2$ /Users/genelin/devenv/flavors/new/usr/bin/python3 /Users/genelin/modmesh/startup.py
AttributeError: '_modmesh.onedim.Euler1DCore' object has no attribute 'pt_plot'

At:
  /Users/genelin/modmesh/modmesh/onedim/euler1d.py(41): init_solver
  /Users/genelin/modmesh/modmesh/onedim/euler1d.py(28): __init__
  /Users/genelin/modmesh/modmesh/onedim/euler1d.py(136): build_numerical
  /Users/genelin/modmesh/modmesh/app/euler1d.py(486): init_solver
  /Users/genelin/modmesh/modmesh/app/euler1d.py(496): set_solver_config
  /Users/genelin/modmesh/modmesh/app/euler1d.py(470): __init__
  /Users/genelin/modmesh/modmesh/app/euler1d.py(883): load_app
  /Users/genelin/modmesh/modmesh/view.py(101): launch
  /Users/genelin/modmesh/startup.py(3): <module>

Copy link

@yungyuc yungyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is your pybind11 wrapper?

@@ -0,0 +1,3 @@
import modmesh.view as mv
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not necessary to use a file to run code like this. A one-liner python3 -c 'import modmesh.view as v ; v.launch()' would do it.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I'm not sure which file is appropriate to add this code. Is there anything wrong to add the startup.py in modmesh?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need to add the code in a file. That is a one-liner you type in command line.

@Gene0315
Copy link
Owner Author

Gene0315 commented Jul 3, 2024

Where is your pybind11 wrapper?

It is at /Users/genelin/devenv/flavors/new/usr/lib/python3.11/site-packages/pybind11

@yungyuc
Copy link

yungyuc commented Jul 4, 2024

Where is your pybind11 wrapper?

It is at /Users/genelin/devenv/flavors/new/usr/lib/python3.11/site-packages/pybind11

That is where you install pybind11, not the wrapper. Wrapper is a class and the associated wrapping code like:

        (*this)
            .def_property_readonly(
                "coord",
                [](wrapped_type & self)
                { return to_ndarray(self.coord()); })
            .def_property_readonly(
                "cfl",
                [](wrapped_type & self)
                { return to_ndarray(self.cfl()); })
            .def_property_readonly(
                "so0",
                [](wrapped_type & self)
                { return to_ndarray(self.so0()); })
            .def_property_readonly(
                "so1",
                [](wrapped_type & self)
                { return to_ndarray(self.so1()); });

@Gene0315
Copy link
Owner Author

Gene0315 commented Jul 6, 2024

Where is your pybind11 wrapper?

It is at /Users/genelin/devenv/flavors/new/usr/lib/python3.11/site-packages/pybind11

That is where you install pybind11, not the wrapper. Wrapper is a class and the associated wrapping code like:

        (*this)
            .def_property_readonly(
                "coord",
                [](wrapped_type & self)
                { return to_ndarray(self.coord()); })
            .def_property_readonly(
                "cfl",
                [](wrapped_type & self)
                { return to_ndarray(self.cfl()); })
            .def_property_readonly(
                "so0",
                [](wrapped_type & self)
                { return to_ndarray(self.so0()); })
            .def_property_readonly(
                "so1",
                [](wrapped_type & self)
                { return to_ndarray(self.so1()); });

The wrap wrap_onedim.cpp is at /Users/genelin/modmesh/cpp/modmesh/onedim/pymod.

@yungyuc
Copy link

yungyuc commented Jul 6, 2024

The wrap wrap_onedim.cpp is at /Users/genelin/modmesh/cpp/modmesh/onedim/pymod.

Please provide a link to a file in your repository, not to your local path.

@yungyuc
Copy link

yungyuc commented Jul 6, 2024

You can also add in-line annotation in this PR.

@Gene0315
Copy link
Owner Author

Gene0315 commented Jul 6, 2024

The wrap wrap_onedim.cpp is at /Users/genelin/modmesh/cpp/modmesh/onedim/pymod.

Please provide a link to a file in your repository, not to your local path.

The link to the wrap_onedim.cpp is here

Copy link

@yungyuc yungyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gene0315 your comment in #1 (comment) was not clear enough. Please see how the inline annotation in this review comment makes discussions more accurate.

Please try to resolve the testing failures shown in CI (e.g., https://github.com/Gene0315/modmesh/actions/runs/9817249358/job/27108402762?pr=1).

@@ -109,6 +109,10 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapEuler1DCore
{ return to_ndarray(self.gamma()); });

(*this)
.def_property_readonly(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An inline annotation can be added like this.

@Gene0315
Copy link
Owner Author

@Gene0315 your comment in #1 (comment) was not clear enough. Please see how the inline annotation in this review comment makes discussions more accurate.

Please try to resolve the testing failures shown in CI (e.g., https://github.com/Gene0315/modmesh/actions/runs/9817249358/job/27108402762?pr=1).

@yungyuc sorry, I don't know what is resolving the testing failure mentioned above. Does it mean that I have to execute the code by terminal with command

make cmakeclean
make buildext viewer VERBOSE=1 
./build/dev311/cpp/binary/viewer/viewer.app/Contents/MacOS/viewer

or how can I do it?

@yungyuc
Copy link

yungyuc commented Jul 16, 2024

@Gene0315 your comment in #1 (comment) was not clear enough. Please see how the inline annotation in this review comment makes discussions more accurate.
Please try to resolve the testing failures shown in CI (e.g., https://github.com/Gene0315/modmesh/actions/runs/9817249358/job/27108402762?pr=1).

@yungyuc sorry, I don't know what is resolving the testing failure mentioned above. Does it mean that I have to execute the code by terminal with command

make cmakeclean
make buildext viewer VERBOSE=1 
./build/dev311/cpp/binary/viewer/viewer.app/Contents/MacOS/viewer

or how can I do it?

In that link, you can see Github Actions encountered a testing failure:

=================================== FAILURES ===================================
____________________ ShockTubeTC.test_field_with_numerical _____________________

self = <test_onedim_euler.ShockTubeTC testMethod=test_field_with_numerical>

    def test_field_with_numerical(self):
        self.st.build_numerical(xmin=-1, xmax=1, ncoord=21,
                                time_increment=0.05)
        self.st.build_field(t=0.0)
        self.assertIsInstance(self.st.svr, euler1d.Euler1DSolver)
>       self.assertEqual(len(self.st.coord), 11)
E       AssertionError: 9 != 11

tests/test_onedim_euler.py:110: AssertionError
=========================== short test summary info ============================
FAILED tests/test_onedim_euler.py::ShockTubeTC::test_field_with_numerical - AssertionError: 9 != 11
=================== 1 failed, 178 passed, 5 skipped in 4.31s ===================
make: *** [pytest] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants