<p dir="auto">When running a the test suite we get a number <code class="notranslate">PendingDeprecationWarning</code>,</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
  return matrix(data, dtype=dtype, copy=False)"><pre class="notranslate"><code class="notranslate">PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.
  return matrix(data, dtype=dtype, copy=False)
</code></pre></div>
<p dir="auto">See for instance <a href="https://ci.appveyor.com/project/sklearn-ci/scikit-learn/builds/19341228/job/q6rysq7flma8hi6v" rel="nofollow">https://ci.appveyor.com/project/sklearn-ci/scikit-learn/builds/19341228/job/q6rysq7flma8hi6v</a>  Warnings seems to be hidden on Travis so we don't see those there.</p>
<p dir="auto">This typically happens when we have a sparse matrix, sum along one axis to get a dense one, than do some mathematical operation with this matrix. It should be explicitly converted to an array first.</p>
<p dir="auto">This has also been reported by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/drorata/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/drorata">@drorata</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="331924701" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/11251" data-hovercard-type="pull_request" data-hovercard-url="/scikit-learn/scikit-learn/pull/11251/hovercard?comment_id=427865173&amp;comment_type=issue_comment" href="https://github.com/scikit-learn/scikit-learn/pull/11251#issuecomment-427865173">#11251 (comment)</a>. There was previous discussion about this in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="331924701" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/11251" data-hovercard-type="pull_request" data-hovercard-url="/scikit-learn/scikit-learn/pull/11251/hovercard" href="https://github.com/scikit-learn/scikit-learn/pull/11251">#11251</a> but it doesn't look like it's fixed.  I also saw this recently when running PyPy CI.</p>
<p dir="auto">To investigate where this happen it's sufficient to run pytest tests with <code class="notranslate">-Werror::PendingDeprecationWarning</code> to error on those warnings, as they don't seem to be raised with the right stacklevel (see also <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="193111938" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/7963" data-hovercard-type="issue" data-hovercard-url="/scikit-learn/scikit-learn/issues/7963/hovercard?comment_id=265420200&amp;comment_type=issue_comment" href="https://github.com/scikit-learn/scikit-learn/issues/7963#issuecomment-265420200">#7963 (comment)</a> for workarounds)</p>
<p dir="auto">For example: <a href="https://travis-ci.org/scikit-learn/scikit-learn/builds/340387057" rel="nofollow">https://travis-ci.org/scikit-learn/scikit-learn/builds/340387057</a>. I can reproduce locally.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="________________________________ test_max_iter _________________________________
    @ignore_warnings
    def test_max_iter():
        # Test that the maximum number of iteration is reached
        X, y_bin = iris.data, iris.target.copy()
        y_bin[y_bin == 2] = 0
    
        solvers = ['newton-cg', 'liblinear', 'sag', 'saga', 'lbfgs']
    
        for max_iter in range(1, 5):
            for solver in solvers:
                for multi_class in ['ovr', 'multinomial']:
                    if solver == 'liblinear' and multi_class == 'multinomial':
                        continue
                    lr = LogisticRegression(max_iter=max_iter, tol=1e-15,
                                            multi_class=multi_class,
                                            random_state=0, solver=solver)
                    lr.fit(X, y_bin)
&gt;                   assert_equal(lr.n_iter_[0], max_iter)
X          = array([[ 5.1,  3.5,  1.4,  0.2],
       [ 4.9,  3. ,  1.4,  0.2],
       [ 4.7,  3.2,  1.3,  0.2],
       [ 4.6,  3.1,...  2.5,  5. ,  1.9],
       [ 6.5,  3. ,  5.2,  2. ],
       [ 6.2,  3.4,  5.4,  2.3],
       [ 5.9,  3. ,  5.1,  1.8]])
lr         = LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
          intercept_scaling=1, max_iter=1...r', n_jobs=1,
          penalty='l2', random_state=0, solver='lbfgs', tol=1e-15,
          verbose=0, warm_start=False)
max_iter   = 1
multi_class = 'ovr'
solver     = 'lbfgs'
solvers    = ['newton-cg', 'liblinear', 'sag', 'saga', 'lbfgs']
y_bin      = array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
/home/travis/build/scikit-learn/scikit-learn/sklearn/linear_model/tests/test_logistic.py:1053: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/python/3.6.3/lib/python3.6/unittest/case.py:829: in assertEqual
    assertion_func(first, second, msg=msg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = &lt;sklearn.utils._unittest_backport.TestCase testMethod=__init__&gt;
first = 0, second = 1, msg = '0 != 1'
    def _baseAssertEqual(self, first, second, msg=None):
        &quot;&quot;&quot;The default assertEqual implementation, not type specific.&quot;&quot;&quot;
        if not first == second:
            standardMsg = '%s != %s' % _common_shorten_repr(first, second)
            msg = self._formatMessage(msg, standardMsg)
&gt;           raise self.failureException(msg)
E           AssertionError: 0 != 1
first      = 0
msg        = '0 != 1'
second     = 1
self       = &lt;sklearn.utils._unittest_backport.TestCase testMethod=__init__&gt;
standardMsg = '0 != 1'
/opt/python/3.6.3/lib/python3.6/unittest/case.py:822: AssertionError"><pre class="notranslate"><code class="notranslate">________________________________ test_max_iter _________________________________
    @ignore_warnings
    def test_max_iter():
        # Test that the maximum number of iteration is reached
        X, y_bin = iris.data, iris.target.copy()
        y_bin[y_bin == 2] = 0
    
        solvers = ['newton-cg', 'liblinear', 'sag', 'saga', 'lbfgs']
    
        for max_iter in range(1, 5):
            for solver in solvers:
                for multi_class in ['ovr', 'multinomial']:
                    if solver == 'liblinear' and multi_class == 'multinomial':
                        continue
                    lr = LogisticRegression(max_iter=max_iter, tol=1e-15,
                                            multi_class=multi_class,
                                            random_state=0, solver=solver)
                    lr.fit(X, y_bin)
&gt;                   assert_equal(lr.n_iter_[0], max_iter)
X          = array([[ 5.1,  3.5,  1.4,  0.2],
       [ 4.9,  3. ,  1.4,  0.2],
       [ 4.7,  3.2,  1.3,  0.2],
       [ 4.6,  3.1,...  2.5,  5. ,  1.9],
       [ 6.5,  3. ,  5.2,  2. ],
       [ 6.2,  3.4,  5.4,  2.3],
       [ 5.9,  3. ,  5.1,  1.8]])
lr         = LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
          intercept_scaling=1, max_iter=1...r', n_jobs=1,
          penalty='l2', random_state=0, solver='lbfgs', tol=1e-15,
          verbose=0, warm_start=False)
max_iter   = 1
multi_class = 'ovr'
solver     = 'lbfgs'
solvers    = ['newton-cg', 'liblinear', 'sag', 'saga', 'lbfgs']
y_bin      = array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
/home/travis/build/scikit-learn/scikit-learn/sklearn/linear_model/tests/test_logistic.py:1053: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/python/3.6.3/lib/python3.6/unittest/case.py:829: in assertEqual
    assertion_func(first, second, msg=msg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = &lt;sklearn.utils._unittest_backport.TestCase testMethod=__init__&gt;
first = 0, second = 1, msg = '0 != 1'
    def _baseAssertEqual(self, first, second, msg=None):
        """The default assertEqual implementation, not type specific."""
        if not first == second:
            standardMsg = '%s != %s' % _common_shorten_repr(first, second)
            msg = self._formatMessage(msg, standardMsg)
&gt;           raise self.failureException(msg)
E           AssertionError: 0 != 1
first      = 0
msg        = '0 != 1'
second     = 1
self       = &lt;sklearn.utils._unittest_backport.TestCase testMethod=__init__&gt;
standardMsg = '0 != 1'
/opt/python/3.6.3/lib/python3.6/unittest/case.py:822: AssertionError
</code></pre></div>
<p dir="auto">Very likely due to a scipy lbfgs fix: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="295072337" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/8374" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/8374/hovercard" href="https://github.com/scipy/scipy/pull/8374">scipy/scipy#8374</a>. It looks like we will need to adapt <code class="notranslate">n_iter_</code> depending on the scipy version ...</p>