<commit_before># frozen_string_literal: true

module Qernel
  module MeritFacade
    # Sets up a Merit participant which will be used last, using any excess
    # energy not exported or assigned to flexibles.
    class CurtailmentAdapter < FlexAdapter
      def inject!
        super

        input_link = target_api.converter.input(@context.carrier).links.first
        demand     = participant.production(:mj)

        if input_link.link_type == :inversed_flexible
          # We need to override the calculation of an inversed flexible link
          # and set the demand explicitly.
          input_link.dataset_set(:value, demand)
          input_link.dataset_set(:calculated, true)
        end

        target_api.demand = demand
      end

      def installed?
        # Curtailment is always available as an consumer-of-last-resort.
        true
      end

      private

      def producer_attributes
        attrs = super

        if @config.group == :curtailment
          attrs[:input_capacity_per_unit]  = Float::INFINITY
          attrs[:output_capacity_per_unit] = Float::INFINITY
        else
          # TODO: Can this be set in FlexAdapter?
          attrs[:input_capacity_per_unit] =
            source_api.input_capacity ||
            source_api.output_capacity
        end

        attrs[:number_of_units] = 1.0

        attrs
      end
    end
  end
end
<commit_msg>Remove unused branch in MF::CurtailmentAdapter<commit_after># frozen_string_literal: true

module Qernel
  module MeritFacade
    # Sets up a Merit participant which will be used last, using any excess
    # energy not exported or assigned to flexibles.
    class CurtailmentAdapter < FlexAdapter
      def inject!
        super

        input_link = target_api.converter.input(@context.carrier).links.first
        demand     = participant.production(:mj)

        if input_link.link_type == :inversed_flexible
          # We need to override the calculation of an inversed flexible link
          # and set the demand explicitly.
          input_link.dataset_set(:value, demand)
          input_link.dataset_set(:calculated, true)
        end

        target_api.demand = demand
      end

      def installed?
        # Curtailment is always available as an consumer-of-last-resort.
        true
      end

      private

      def producer_attributes
        attrs = super

        if @config.group == :curtailment
          attrs[:input_capacity_per_unit]  = Float::INFINITY
          attrs[:output_capacity_per_unit] = Float::INFINITY
        end

        attrs[:number_of_units] = 1.0

        attrs
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.06059451219512195, 'fraction_numerical': 0.001524390243902439, 'mean_word_length': 2.2367447595561036, 'pattern_counts': {'":': 0, '<': 5, '<?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': '672109', 'n_tokens_mistral': 737, 'n_tokens_neox': 698, 'n_words': 205}