<commit_before># -*- coding: UTF-8 -*-

# Copyright 2015 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import numpy as np

"""
Performs gradient-based centroid detection on the specified spectrum.

input
mzs:
    m/z array
intensities:
    intensity array
max_output (Default: -1):
    limits the amount of centroids to be returned. If not set, all centroids are returned
weighted_bins (Default: 1):

min_intensity (Default: 0):
    threshold beneath which intensity values are ignored. If not set, all intensity values will be considered.

output
mzs_list:
    those m/z values from the input array that correspond to a centroid
intensities_list:
    those intensity values from the input array that correspond to a centroid
indices_list:
    position of the centroids within the original array
"""
def gradient(mzs,intensities,**opt_args):
    function_args = {'max_output': -1, 'weighted_bins':1,'min_intensity':0}
    for key, val in opt_args.iteritems():
        if key in function_args.keys():
            function_args[key] = val
        else:
            print 'possible arguments:'
            for i in function_args.keys():
                   print i
            raise NameError('gradient does not take argument: %s'%(key))
    mzMaxNum = function_args['max_output']
    weighted_bins = function_args['weighted_bins']<commit_msg>making centroid_detection python3-compatible (print)<commit_after># -*- coding: UTF-8 -*-

# Copyright 2015 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import numpy as np

"""
Performs gradient-based centroid detection on the specified spectrum.

input
mzs:
    m/z array
intensities:
    intensity array
max_output (Default: -1):
    limits the amount of centroids to be returned. If not set, all centroids are returned
weighted_bins (Default: 1):

min_intensity (Default: 0):
    threshold beneath which intensity values are ignored. If not set, all intensity values will be considered.

output
mzs_list:
    those m/z values from the input array that correspond to a centroid
intensities_list:
    those intensity values from the input array that correspond to a centroid
indices_list:
    position of the centroids within the original array
"""
def gradient(mzs,intensities,**opt_args):
    function_args = {'max_output': -1, 'weighted_bins':1,'min_intensity':0}
    for key, val in opt_args.iteritems():
        if key in function_args.keys():
            function_args[key] = val
        else:
            print ('possible arguments:')
            for i in function_args.keys():
                   print (i)
            raise NameError('gradient does not take argument: %s'%(key))
    mzMaxNum = function_args['max_output']
    weighted_bins = function_args['weighted_bins']
{'fraction_non_alphanumeric': 0.07964601769911504, 'fraction_numerical': 0.008313220702601234, 'mean_word_length': 3.6450809464508094, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5260536', 'n_tokens_mistral': 1032, 'n_tokens_neox': 997, 'n_words': 436}