Coder Social home page Coder Social logo

Comments (7)

luimot avatar luimot commented on May 14, 2024 2

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.

giovaniceotto avatar giovaniceotto commented on May 14, 2024

@Projeto-Jupiter/back-end

from rocketpy.

Gui-FernandesBR avatar Gui-FernandesBR commented on May 14, 2024

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.

giovaniceotto avatar giovaniceotto commented on May 14, 2024
    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.

giovaniceotto avatar giovaniceotto commented on May 14, 2024

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.

luimot avatar luimot commented on May 14, 2024

@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.

giovaniceotto avatar giovaniceotto commented on May 14, 2024

Issue fixed in the develop branch by #105

from rocketpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.