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

Update the tests to Python 3 #19

Closed
agodemar opened this issue May 2, 2018 · 10 comments
Closed

Update the tests to Python 3 #19

agodemar opened this issue May 2, 2018 · 10 comments

Comments

@agodemar
Copy link
Contributor

agodemar commented May 2, 2018

No description provided.

@seanmcleod
Copy link
Member

I looked at this very briefly the other day when testing the CMake support in VS2017. I thought it may be trivial in terms of just fixing simple things like changing print statements into print functions etc. to make then compatible with both python 2 and 3.

But it looks like we'll need to look into the differences between bytes and strings between python 2 and 3, in particular with SGPath.

`ERROR: testAircrafts (main.CheckAircrafts)

Traceback (most recent call last):
File ".\CheckAircrafts.py", line 45, in testAircrafts
fdm = CreateFDM(self.sandbox)
File "C:\Users\Sean\CMakeBuilds\3f00c6d9-d323-5a32-8a90-665138817fd4\build\x64-Release\tests\JSBSim_utils.py", line 53, in CreateFDM
_fdm = jsbsim.FGFDMExec(root_dir=os.path.join(sandbox(), ''))
File "jsbsim.pyx", line 142, in jsbsim.FGFDMExec.cinit (tests\jsbsim.cxx:3025)
File "jsbsim.pyx", line 308, in jsbsim.FGFDMExec.set_root_dir (tests\jsbsim.cxx:5541)
File "stringsource", line 15, in string.from_py.__pyx_convert_string_from_py_std__in_string (tests\jsbsim.cxx:8873)
TypeError: expected bytes, str found`

@agodemar
Copy link
Contributor Author

agodemar commented May 2, 2018

FYI
I have added a folder Jupyter_Notebooks in the reference manual repository here.

The folder contains a couple of preliminary tests made via Jupyter notebooks (formerly IPython) running a Python 3 kernel. There are some helper classes defined in the subfolder python which are designed to perform multiple JSBSim simulations. The classes are adapted from this work that I did in collaboration with one of my former students and colleagues at Fraunhofer Institute for Wind Energy Systems, IWES (Germany).

I run my simulations in Windows and I've put a recent build of JSBSim.exe (not uploaded) in the subfolder JSBSim.

@seanmcleod
Copy link
Member

So you didn't have any issues then with using Python 3 to call into the JSBSim code? Actually taking a quick glance at some of your Python code it looks like you're using os.system('JSBSim.exe --script...') to execute instances of JSBSim then and you're not using the Python API wrapper to call the JSBSim classes directly from Python?

@agodemar
Copy link
Contributor Author

agodemar commented May 3, 2018

... you're not using the Python API wrapper to call the JSBSim classes directly from Python?

In fact, that was my approach. But I would love to adapt that work in order to use a Python 3 API wrapper. We might use it to make reports on engineering flight simulations via Jupyter.

@agodemar
Copy link
Contributor Author

agodemar commented May 5, 2018

FYI
I'm continuing to create more Jupyter notebooks (with Python3 kernel) to check various aspects in JSBSim ecosystem. Here is one that parses FDM config files, searches for tabular data, and make plots: Jupyter_Notebooks/02_reading_jsbsim_config.ipynb

@seanmcleod
Copy link
Member

@agodemar perfect, I was actually starting to write something very similar. My aim is to given an FDM generate a set of plots for a visual/graph representation, e.g. Cl vs AoA, Cd vs AoA, Cl vs Cd, plus graph the individual items that make up for example Cd, so Cd0, Cdi etc.

Did you notice the funny kink in the ground effect curve of your C172 versus the one retrieved from GitHub? I checked in a fix for the kink a while ago.

@agodemar
Copy link
Contributor Author

agodemar commented May 5, 2018

@seanmcleod Jupyter notebooks can help a lot in creating reports on FDM config files as well on results. The classes that I've put here have been designed with that in mind. They need to be enhanced with the task you were mentioning:

given an FDM generate a set of plots for a visual/graph representation, e.g. Cl vs AoA, Cd vs AoA, Cl vs Cd, plus graph the individual items that make up for example Cd, so Cd0, Cdi etc.

Yes, I did notice the kink and I knew you submitted a smother version of that curve.

@seanmcleod
Copy link
Member

@agodemar yep I've used Jupyter notebooks on other non-JSBSim related projects.

In terms of plotting data from the FDM I was thinking of using the JSBSim python API in order to be able to evaluate functions that are defined rather than parsing the xml looking for table data etc.

So for example if Cdi is defined as a function using Cl^2 etc. the graphing code would evaluate it as well as handling functions with table data.

The Cdi based on Cl^2 is actually more complicated since the code would need to first lookup the Cl values from the Cl vs AoA function and then use those when evaluating the Cdi function etc.

@bcoconni
Copy link
Member

bcoconni commented May 8, 2018

FYI @ezietsman made the pull request #23 to update the tests to Python 3.6 and keep them compatible with Python 2.7. The PR is currently needing some changes before being merged but this is just a matter of a couple of details. I am confident they should be resolved quickly.

@bcoconni
Copy link
Member

bcoconni commented May 9, 2018

@agodemar and @seanmcleod The PR #23 has been merged. I think we can close this issue.

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

No branches or pull requests

3 participants