8000 DOC Remove some str/unicode leftovers from Python 2 by DimitriPapadopoulos · Pull Request #21270 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC Remove some str/unicode leftovers from Python 2 #21270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sklearn/datasets/_base.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ def load_files(

Parameters
----------
container_path : str or unicode
container_path : str
Path to the main folder holding one subfolder per category

description : str or unicode, default=None
description : str, default=None
A paragraph describing the characteristic of the dataset: its source,
reference, etc.

Expand Down
2 changes: 1 addition & 1 deletion sklearn/datasets/_california_housing.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def fetch_california_housing(
If ``as_frame`` is True, ``target`` is a pandas object.
feature_names : list of length 8
Array of ordered feature names used in the dataset.
DESCR : string
DESCR : str
Description of the California housing dataset.
frame : pandas DataFrame
Only present when `as_frame=True`. DataFrame with ``data`` and
Expand Down
4 changes: 2 additions & 2 deletions sklearn/datasets/_lfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def fetch_lfw_people(
target : numpy array of shape (13233,)
Labels associated to each face image.
Those labels range from 0-5748 and correspond to the person IDs.
DESCR : string
DESCR : str
Description of the Labeled Faces in the Wild (LFW) dataset.

(data, target) : tuple if ``return_X_y`` is True
Expand Down Expand Up @@ -486,7 +486,7 @@ def fetch_lfw_pairs(
target : numpy array of shape (2200,). Shape depends on ``subset``.
Labels associated to each pair of images.
The two label values being different persons or the same person.
DESCR : string
DESCR : str
Description of the Labeled Faces in the Wild (LFW) dataset.

"""
Expand Down
5 changes: 2 additions & 3 deletions sklearn/datasets/_svmlight_format_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def dump_svmlight_file(
integer or float, or array-like objects of integer or float for
multilabel classifications.

f : string or file-like in binary mode
f : str or file-like in binary mode
If string, specifies the path that will contain the data.
If file-like, data will be written to f. f should be opened in binary
mode.
Expand All @@ -455,7 +455,7 @@ def dump_svmlight_file(
Whether column indices should be written zero-based (True) or one-based
(False).

comment : string, default=None
comment : str, default=None
Comment to insert at the top of the file. This should be either a
Unicode string, which will be encoded as UTF-8, or an ASCII byte
string.
Expand All @@ -478,7 +478,6 @@ def dump_svmlight_file(
# Convert comment string to list of lines in UTF-8.
# If a byte string is passed, then check whether it's ASCII;
# if a user wants to get fancy, they'll have to decode themselves.
# Avoid mention of str and unicode types for Python 3.x compat.
if isinstance(comment, bytes):
comment.decode("ascii") # just for the exception
else:
Expand Down
2 changes: 1 addition & 1 deletion sklearn/datasets/_twenty_newsgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def fetch_20newsgroups(
Select the dataset to load: 'train' for the training set, 'test'
for the test set, 'all' for both, with shuffled ordering.

categories : array-like, dtype=str or unicode, default=None
categories : array-like, dtype=str, default=None
If None (default), load all the categories.
If not None, list of category names to load (other categories
ignored).
Expand Down
8 changes: 4 additions & 4 deletions sklearn/feature_extraction/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def strip_accents_ascii(s):

Parameters
----------
s : string
s : str
The string to strip

See Also
Expand All @@ -175,7 +175,7 @@ def strip_tags(s):

Parameters
----------
s : string
s : str
The string to strip
"""
return re.compile(r"<([^>]+)>", flags=re.UNICODE).sub(" ", s)
Expand Down Expand Up @@ -204,7 +204,7 @@ def decode(self, doc):

Parameters
----------
doc : str
doc : bytes or str
The string to decode.

Returns
Expand Down Expand Up @@ -620,7 +620,7 @@ class HashingVectorizer(TransformerMixin, _VectorizerMixin, BaseEstimator):
Remove accents and perform other character normalization
during the preprocessing step.
'ascii' is a fast method that only works on characters that have
an direct ASCII mapping.
a direct ASCII mapping.
'unicode' is a slightly slower method that works on any characters.
None (default) does nothing.

Expand Down
2 changes: 1 addition & 1 deletion sklearn/linear_model/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _deprecate_normalize(normalize, default, estimator_name):
default : bool,
default normalize value used by the estimator

estimator_name : string,
estimator_name : str
name of the linear estimator which calls this function.
The name will be used for writing the deprecation warnings

Expand Down
2 changes: 1 addition & 1 deletion sklearn/linear_model/_stochastic_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def fit_binary(
C : float
Maximum step size for passive aggressive

learning_rate : string
learning_rate : str
The learning rate. Accepted values are 'constant', 'optimal',
'invscaling', 'pa1' and 'pa2'.

Expand Down
2 changes: 1 addition & 1 deletion sklearn/metrics/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _average_binary_score(binary_metric, y_true, y_score, average, sample_weight
Target scores, can either be probability estimates of the positive
class, confidence values, or binary decisions.

average : string, [None, 'micro', 'macro' (default), 'samples', 'weighted']
average : {None, 'micro', 'macro', 'samples', 'weighted'}, default='macro'
If ``None``, the scores for each class are returned. Otherwise,
this determines the type of averaging performed on the data:

Expand Down
2 changes: 1 addition & 1 deletion sklearn/metrics/_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ def classification_report(

Returns
-------
report : string / dict
report : str or dict
Text summary of the precision, recall, F1 score for each class.
Dictionary returned if output_dict is True. Dictionary has the
following structure::
Expand Down
2 changes: 1 addition & 1 deletion sklearn/mixture/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _check_shape(param, param_shape, name):

param_shape : tuple

name : string
name : str
"""
param = np.array(param)
if param.shape != param_shape:
Expand Down
2 changes: 1 addition & 1 deletion sklearn/mixture/_gaussian_mixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _check_precisions(precisions, covariance_type, n_components, n_features):
'diag' : shape of (n_components, n_features)
'spherical' : shape of (n_components,)

covariance_type : string
covariance_type : str

n_components : int
Number of components.
Expand Down
2 changes: 1 addition & 1 deletion sklearn/neighbors/_dist_metrics.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ cdef class DistanceMetric:

Parameters
----------
metric : string or class name
metric : str or class name
The distance metric to use
**kwargs
additional arguments will be passed to the requested metric
Expand Down
4 changes: 2 additions & 2 deletions sklearn/preprocessing/tests/test_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ def test_encoder_dtypes():
for X in [
np.array([[1, 2], [3, 4]], dtype="int64"),
np.array([[1, 2], [3, 4]], dtype="float64"),
np.array([["a", "b"], ["c", "d"]]), # unicode dtype
np.array([[b"a", b"b"], [b"c", b"d"]]), # string dtype
np.array([["a", "b"], ["c", "d"]]), # str dtype
np.array([[b"a", b"b"], [b"c", b"d"]]), # bytes dtype
np.array([[1, "a"], [3, "b"]], dtype="object"),
]:
enc.fit(X)
Expand Down
4 changes: 2 additions & 2 deletions sklearn/tree/_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def export_graphviz(

Returns
-------
dot_data : string
dot_data : str
String representation of the input tree in GraphViz dot format.
Only returned if ``out_file`` is None.

Expand Down Expand Up @@ -961,7 +961,7 @@ def export_text(

Returns
-------
report : string
report : str
Text summary of all the rules in the decision tree.

Examples
Expand Down
2 changes: 1 addition & 1 deletion sklearn/utils/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def graph_shortest_path(dist_matrix, directed=True, method="auto"):
if False, then find the shortest path on an undirected graph: the
algorithm can progress from a point to its neighbors and vice versa.

method : string ['auto'|'FW'|'D']
method : {'auto', 'FW', 'D'}, default='auto'
method to use. Options are
'auto' : attempt to choose the best method for the current problem
'FW' : Floyd-Warshall algorithm. O[N^3]
Expand Down
2 changes: 1 addition & 1 deletion sklearn/utils/metaestimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def if_delegate_has_method(delegate):

Parameters
----------
delegate : string, list of strings or tuple of strings
delegate : str, list of str or tuple of str
Name of the sub-estimator that can be accessed as an attribute of the
base object. If a list or a tuple of names are provided, the first
sub-estimator that is an attribute of the base object will be used.
Expand Down
0