Comments (7)
I think this is because in SolidMotor.py
the line in the method importEng()
if line[0] == ";":
is only checking the first character in each line of the .eng file and the last ";" in the file is one tab ahead and breaks this logic, I tested the code block below using simple regex and it seems to resolve it even when ";" is commenting anywhere else in the doc if it's not before any relevant data, like a normal comment line
if re.search(r";.*", line):
# Extract comment
comments.append(re.findall(r";.*", line))
line = re.sub(r";.*", "", line)
if not line.isspace():
if description == []:
# Extract description
description = line.strip().split(" ")
else:
# Extract thrust curve data points
time, thrust = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", line)
dataPoints.append([float(time), float(thrust)])
from rocketpy.
@Projeto-Jupiter/back-end
from rocketpy.
I still have my questions regarding the nature of that extra ";"
Is it that common or was it just 1 simple mistake?
Anyway, I think @luimot 's addition is going to help with the current bug so that's what matters for now.
@luimot would you mind openning a PR with this implementation?
from rocketpy.
comments.append(re.findall(r";.*", line)) line = re.sub(r";.*", "", line) if not line.isspace(): if description == []: # Extract description description = line.strip().split(" ") else: # Extract thrust curve data points time, thrust = re.findall(r"[-+]?\d*\.\d+|[-+]?\d+", line) dataPoints.append([float(time), float(thrust)])
Seems like a perfect implementation to me @luimot. Takes care of comments which are preceded by space or any other character.
Out of curiosity, is using regex in this case faster than just removing trailing whitespace (left and right) and splitting each line by the ;
?
from rocketpy.
I still have my questions regarding the nature of that extra ";" Is it that common or was it just 1 simple mistake?
Anyway, I think @luimot 's addition is going to help with the current bug so that's what matters for now.
@luimot would you mind openning a PR with this implementation?
This extra ;
is allowed by the specification. More details here: RASP format.
from rocketpy.
@giovaniceotto I don't know what could be faster, I think maybe because both are simple operations in their own way it wouldn't be a significant change but wouldn't be surprised if it were faster, regex has a bit cumbersome syntax but it's an awesome tool.
from rocketpy.
Issue fixed in the develop branch by #105
from rocketpy.
Related Issues (20)
- BUG: KeyError: 'I_11' and AttributeError: 'NoneType' object has no attribute 'reset' HOT 1
- ENH: Support for Open Meteo API
- ENH: make rocketpy classes json serializable
- ENH: adds an 3D animation of flight trajectory
- DOC: Software in a Loop (SIL) example with parachute ejection systems
- DOC: update badges on our README
- DOC: stop cloning the whole repository just for examples HOT 1
- ENH: plot inertia tensor components in a single plot
- ENH: display both power_off_drag and power_on_drag in a single plot
- ENH: adds `axial_acceleration` attribute to the Flight class HOT 2
- MNT: EmptyMotor class inherits from Motor(ABC)
- MNT: delete tools.cached_property
- DOC: convert notebooks to .rst files in the documentation
- ENH: Support for Meteomatics API
- ENH: give me a scissor or apply `Function.clip` and `Function.crop`
- BUG: Invalid Center of Pressure for Rockets with Variable Diameter
- Incorrect/incomplete docstring in environment.py HOT 4
- MNT: save ref_factor value when adding aero surfaces to a Rocket
- ENH: Allow saving plots instead of showing them HOT 3
- BLD: change setup.py to pyproject.toml HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rocketpy.