<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/scipy/scipy/blob/11509c4a98edded6c59423ac44ca1b7f28fba1fd/scipy/optimize/optimize.py#L1519">scipy/scipy/optimize/optimize.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 1519
      in
      <a data-pjax="true" class="commit-tease-sha" href="/scipy/scipy/commit/11509c4a98edded6c59423ac44ca1b7f28fba1fd">11509c4</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L1519" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="1519"></td>
          <td id="LC1519" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-v">OptimizeResult</span>(<span class="pl-s1">fun</span><span class="pl-c1">=</span><span class="pl-s1">fval</span>, <span class="pl-s1">jac</span><span class="pl-c1">=</span><span class="pl-s1">gfk</span>, <span class="pl-s1">nfev</span><span class="pl-c1">=</span><span class="pl-s1">fcalls</span>[<span class="pl-c1">0</span>], </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">There are several recent PRs featuring new functions for statistical tests:</p>
<ul dir="auto">
<li>A new binomial test function (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="664043707" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/12603" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/12603/hovercard" href="https://github.com/scipy/scipy/pull/12603">gh-12603</a>)</li>
<li>Page's L (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="655478921" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/12531" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/12531/hovercard" href="https://github.com/scipy/scipy/pull/12531">gh-12531</a>)</li>
<li>Somers' D (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="670290829" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/12653" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/12653/hovercard" href="https://github.com/scipy/scipy/pull/12653">gh-12653</a>)</li>
<li>Alexander-Govern (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="705988630" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/12873" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/12873/hovercard" href="https://github.com/scipy/scipy/pull/12873">gh-12873</a>)</li>
<li>Tukey-Kramer (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="730051516" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/13002" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/13002/hovercard" href="https://github.com/scipy/scipy/pull/13002">gh-13002</a>)</li>
<li>Cramer-von-Mises (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="527718745" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/11119" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/11119/hovercard" href="https://github.com/scipy/scipy/pull/11119">gh-11119</a>, merged)</li>
</ul>
<p dir="auto">The new <code class="notranslate">make_tuple_bunch</code> (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="633990589" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/12323" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/12323/hovercard" href="https://github.com/scipy/scipy/pull/12323">gh-12323</a>) is for adding new outputs to existing tests in a backwards compatible way, but <strong>what should the new functions return</strong>?</p>
<p dir="auto">To finish <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="527718745" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/11119" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/11119/hovercard" href="https://github.com/scipy/scipy/pull/11119">gh-11119</a> without needing to make this decision, <code class="notranslate">cramervonmises</code> returns a bare-bones <code class="notranslate">CramerVonMisesResult</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="class CramerVonMisesResult:
    def __init__(self, statistic, pvalue):
        self.statistic = statistic
        self.pvalue = pvalue

    def __repr__(self):
        return (f&quot;{self.__class__.__name__}(statistic={self.statistic}, &quot;
                f&quot;pvalue={self.pvalue})&quot;)"><pre class="notranslate"><code class="notranslate">class CramerVonMisesResult:
    def __init__(self, statistic, pvalue):
        self.statistic = statistic
        self.pvalue = pvalue

    def __repr__(self):
        return (f"{self.__class__.__name__}(statistic={self.statistic}, "
                f"pvalue={self.pvalue})")
</code></pre></div>
<p dir="auto">I'm not sure the decision about supporting Python 3.6 was made yet then (is it official?), but the same behavior could have been achieved with <code class="notranslate">make_dataclass</code>.</p>
<p dir="auto">This suggests a few questions.</p>
<ol dir="auto">
<li>Should there be a class like <a href="https://github.com/scipy/scipy/blob/06f51e32837b4f78f2630701091cd98ff4c6ddf7/scipy/optimize/optimize.py#L82"><code class="notranslate">OptimizeResult</code></a>, say, <code class="notranslate">StatsTestResult</code>, that takes care of some of the common behavior, or should we use <code class="notranslate">make_dataclass</code>? Or should each test make it's own unrelated custom class? What behavior would we want this class to take care of? For instance, <code class="notranslate">OptimizeResult</code> is a subclass of <code class="notranslate">dict</code> but includes a <code class="notranslate">__getattr__</code> that allows accessing elements as if they were fields.</li>
<li>Should fields <code class="notranslate">statistic</code> and <code class="notranslate">pvalue</code> be standard names of the fields (where applicable) or should the name of the statistic be more specific?</li>
</ol>
<p dir="auto">The new <code class="notranslate">BinomTestResult</code> currently returned by <code class="notranslate">binomtest</code> (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="664043707" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/12603" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/12603/hovercard" href="https://github.com/scipy/scipy/pull/12603">gh-12603</a>) brings a few other questions to mind.</p>
<ol start="3" dir="auto">
<li>A relatively expensive calculation that is related but not required by the binomial test is calculation of a confidence interval of the proportion of successes. Currently, a method for performing that test is included in the <code class="notranslate">BinomTestResult</code> so that it is easy for the user to follow up a <code class="notranslate">binomtest</code> with calculation of the confidence interval, but it does not take time if it is not required. Do we agree that this is a good compromise between performing the CI calculation within <code class="notranslate">binomtest</code> and making the CI calculation a totally separate function?</li>
<li>How much information about the test that was performed should be returned in the result? Currently, <code class="notranslate">BinomTestResult</code> includes (beside <code class="notranslate">pvalue</code>)  much of the user's input, including <code class="notranslate">k</code>, <code class="notranslate">n</code>, and <code class="notranslate">alternative</code>. Should it include more of what the user entered (e.g. the proportion of successes of the null hypothesis), or only what it needs to retain for performing follow-up calculations (e.g. confidence interval).</li>
</ol>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/WarrenWeckesser/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/WarrenWeckesser">@WarrenWeckesser</a> please feel free to edit this directly</p>