<commit_before>module KerbalDyn
  # The namespace for all orbital maneuvers
  module OrbitalManeuver
    # The base-class for all orbital maneuvers.
    class Base
      include Mixin::OptionsProcessor
      include Mixin::ParameterAttributes

      def initialize(initial_orbit, final_orbit, options={})
        # For now this is a safe thing to do, *way* in the future we may have to differentiate
        # between complex maneuvers to other systems and maneuvers within the system.
        raise ArgumentError, "Expected the initial and final orbit to orbit the same body." unless initial_orbit.primary_body == final_orbit.primary_body
        self.initial_orbit = initial_orbit
        self.final_orbit = final_orbit

        process_options(options)
      end

      # The orbit you are starting at.
      attr_accessor :initial_orbit

      # The orbit you are going to maneuver into.
      attr_accessor :final_orbit

      # Calculates the total delta-v for this maneuver.
      #
      # This is always a positive quantity that relates the total amount of
      # velocity change necessary, and hence a sense of the total amount of
      # fuel used during the maneuver.
      #
      # The baseclass implementation is to sum the absolute values of the
      # deltas in the velocity list +delta_velocities+.
      def delta_velocity
        return self.delta_velocities.reduce {|a,b| a.abs + b.abs}
      end

      # An alias to delta_velocity.
      def delta_v
        return self.delta_velocity
      end

      # Calculates the total time for completion.
      #
      # For some kinds of idealized maneuvers this may be meaningless, in which
      # case nil is returned.
      #
      # Subclasses should override this.
      def delta_time
        return nil
      end

      # An alias to delta_time.
      def delta_t
        return self.delta_time
      end

      # The list of velocity deltas.
      #
      # For most kinds of maneuvers, the signedness of the delta is meaningful.
      # For example, prograde burns are usually positive, and retrograde burns
      # are usually negative.
      #
      # Subclasses should override this.
      def delta_velocities
        return []
      end

    end
  end
end
<commit_msg>OrbitalManeuver::Base: Repaired an errant total delta_v calculation.<commit_after>module KerbalDyn
  # The namespace for all orbital maneuvers
  module OrbitalManeuver
    # The base-class for all orbital maneuvers.
    class Base
      include Mixin::OptionsProcessor
      include Mixin::ParameterAttributes

      def initialize(initial_orbit, final_orbit, options={})
        # For now this is a safe thing to do, *way* in the future we may have to differentiate
        # between complex maneuvers to other systems and maneuvers within the system.
        raise ArgumentError, "Expected the initial and final orbit to orbit the same body." unless initial_orbit.primary_body == final_orbit.primary_body
        self.initial_orbit = initial_orbit
        self.final_orbit = final_orbit

        process_options(options)
      end

      # The orbit you are starting at.
      attr_accessor :initial_orbit

      # The orbit you are going to maneuver into.
      attr_accessor :final_orbit

      # Calculates the total delta-v for this maneuver.
      #
      # This is always a positive quantity that relates the total amount of
      # velocity change necessary, and hence a sense of the total amount of
      # fuel used during the maneuver.
      #
      # The baseclass implementation is to sum the absolute values of the
      # deltas in the velocity list +delta_velocities+.
      def delta_velocity
        return self.delta_velocities.reduce(0) {|a,b| a.abs + b.abs}
      end

      # An alias to delta_velocity.
      def delta_v
        return self.delta_velocity
      end

      # Calculates the total time for completion.
      #
      # For some kinds of idealized maneuvers this may be meaningless, in which
      # case nil is returned.
      #
      # Subclasses should override this.
      def delta_time
        return nil
      end

      # An alias to delta_time.
      def delta_t
        return self.delta_time
      end

      # The list of velocity deltas.
      #
      # For most kinds of maneuvers, the signedness of the delta is meaningful.
      # For example, prograde burns are usually positive, and retrograde burns
      # are usually negative.
      #
      # Subclasses should override this.
      def delta_velocities
        return []
      end

    end
  end
end

{'fraction_non_alphanumeric': 0.045634050021939446, 'fraction_numerical': 0.00021939447125932427, 'mean_word_length': 2.377037037037037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6329967', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1165, 'n_words': 498}