<commit_before>import Microcontroller from '../components/Microcontroller';
import * as MicrocontrollerActions from '../actions/microcontroller';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { values } from 'ramda';

const getVisiblePins = (inPins, filter) => {
  let pins = inPins;

  pins = pins.filter(
    pin => (pin.enabled || filter.showDisabled)
  );

  if (!filter.showDigital) {
    pins = pins.filter(pin => pin.isAnalogPin);
  }

  if (!filter.showAnalog) {
    pins = pins.filter(pin => !pin.isAnalogPin);
  }

  return pins;
};

function mapStateToProps(state) {
  return {
    pins: getVisiblePins(
              values(state.pins),
              state.visibilityFilter
          ),
    connectionState: state.connectionState,
    mapping: state.mapping,
    name: state.name,
    visibilityFilter: state.visibilityFilter,
    replay: state.replay,
  };
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators(MicrocontrollerActions, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(Microcontroller);
<commit_msg>Filter out pins with no supported modes and serial pins<commit_after>import Microcontroller from '../components/Microcontroller';
import * as MicrocontrollerActions from '../actions/microcontroller';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { contains, intersection, values } from 'ramda';
import { MODE_NAMES } from '../reducers/microcontrollerEnums';

const getVisiblePins = (inPins, filter) => {
  let pins = inPins;

  // Filter out all pins that don't have any supported modes
  // and all pins that belong to the 'Serial' categorie, e.g. TX1, RX1, etc,
  // because these might be confusing for the user
  pins = pins.filter(
    pin => {
      const supportedModes = intersection(
        pin.supportedModes,
        Object.keys(MODE_NAMES).map(k => parseInt(k, 10))
      );
      return supportedModes.length > 1 && !contains('Serial', pin.categories);
    }
  );

  pins = pins.filter(
    pin => (pin.enabled || filter.showDisabled)
  );

  if (!filter.showDigital) {
    pins = pins.filter(pin => pin.isAnalogPin);
  }

  if (!filter.showAnalog) {
    pins = pins.filter(pin => !pin.isAnalogPin);
  }

  return pins;
};

function mapStateToProps(state) {
  return {
    pins: getVisiblePins(
              values(state.pins),
              state.visibilityFilter
          ),
    connectionState: state.connectionState,
    mapping: state.mapping,
    name: state.name,
    visibilityFilter: state.visibilityFilter,
    replay: state.replay,
  };
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators(MicrocontrollerActions, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(Microcontroller);

{'fraction_non_alphanumeric': 0.11752136752136752, 'fraction_numerical': 0.0017806267806267807, 'mean_word_length': 3.6049180327868853, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '2115527', 'n_tokens_mistral': 874, 'n_tokens_neox': 818, 'n_words': 203}