https://issues.qgis.org/https://issues.qgis.org/favicon.ico2018-07-03T16:26:13ZQGIS Issue TrackingQGIS Application - Bug report #19322: Random selection within subsets throws exceptionhttps://issues.qgis.org/issues/19322?journal_id=906402018-07-03T16:26:13ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>Did it worked as expected (with the described values) in previous releases?</p> QGIS Application - Bug report #19322: Random selection within subsets throws exceptionhttps://issues.qgis.org/issues/19322?journal_id=906412018-07-03T16:58:55ZDénes Szalontaiszadini@freemail.hu
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Open</i></li></ul><p>I checked it in QGIS 3.0.3 and the same issue occurs:</p>
<pre>
Traceback (most recent call last):
File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\algs\qgis\RandomSelectionWithinSubsets.py", line 137, in processAlgorithm
selran.extend(random.sample(subset, selValue))
File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\random.py", line 317, in sample
raise ValueError("Sample larger than population or is negative")
ValueError: Sample larger than population or is negative
</pre>
<p>It works well and produces the expected result in QGIS 2.18.10 with the same input data and the same settings.</p> QGIS Application - Bug report #19322: Random selection within subsets throws exceptionhttps://issues.qgis.org/issues/19322?journal_id=906422018-07-03T17:00:03ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Regression?</strong> changed from <i>No</i> to <i>Yes</i></li><li><strong>Priority</strong> changed from <i>Normal</i> to <i>High</i></li></ul> QGIS Application - Bug report #19322: Random selection within subsets throws exceptionhttps://issues.qgis.org/issues/19322?journal_id=906492018-07-04T06:02:23ZAlexander Bruy
<ul><li><strong>Category</strong> changed from <i>Python plugins</i> to <i>Processing/QGIS</i></li><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>Please provide test dataset and steps to reproduce the issue</p> QGIS Application - Bug report #19322: Random selection within subsets throws exceptionhttps://issues.qgis.org/issues/19322?journal_id=906762018-07-04T12:05:06ZDénes Szalontaiszadini@freemail.hu
<ul><li><strong>File</strong> <a href="/attachments/download/12923/Sample.csv">Sample.csv</a><a href="/attachments/12923/Sample.csv"><img alt="Magnifier" src="/images/magnifier.png" /></a> added</li><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Open</i></li></ul>Steps to reproduce:
<ol>
<li>Add the attached sample.csv layer with <em>Layer -> Add Layer -> Add Delimited Text Layer</em> (delimiter: semicolon, the first record has field names, EPSG: 4326)</li>
<li>Start the <em>Random selection within subsets</em> tool from <em>Vector -> Research Tools</em></li>
<li>Select <strong>Sample</strong> as <em>Input layer</em>, <strong>SPEEDLIMIT</strong> as <em>ID field</em>, <strong>Number of selected features</strong> as <em>Method</em> and <strong>5</strong> as <em>Number/percentage of selected features</em></li>
<li>Hit <em>Run</em> to start processing</li>
</ol>
<p>Actual behaviour in QGIS 3.x:<br />An exception is thrown and the execution fails with the error message<br /><pre>
Traceback (most recent call last):
File "C:/PROGRA~1/QGIS3~1.2/apps/qgis/./python/plugins\processing\algs\qgis\RandomSelectionWithinSubsets.py", line 141, in processAlgorithm
selran.extend(random.sample(subset, selValue))
File "C:\PROGRA~1\QGIS3~1.2\apps\Python36\lib\random.py", line 317, in sample
raise ValueError("Sample larger than population or is negative")
ValueError: Sample larger than population or is negative
</pre></p>
<p>Actual behaviour in QGIS 2.18.10:<br />Process finishes successfully with the expected result</p>
<p><strong>Note:</strong> The sample data contains the value 110 less than 5 times (only once) in SPEEDLIMIT column. If I set <em>Number/percentage of selected features</em> to <strong>1</strong> then process finishes successfully in QGIS 3.x as well but it fails with any other values.<br /><strong>Note 2</strong>: <em>Random extract within subsets</em> tool fails as well with this data in QGIS 3.x</p> QGIS Application - Bug report #19322: Random selection within subsets throws exceptionhttps://issues.qgis.org/issues/19322?journal_id=906792018-07-04T16:53:25ZAlexander Bruy
<ul><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" href="https://issues.qgis.org/projects/qgis/repository/revisions/29207a1617678eb3a3922ff3dd74c3b6b6b193a5" title="[processing] fix Random extract/select within subset when subset is smaller than number of reques...">qgis|29207a1617678eb3a3922ff3dd74c3b6b6b193a5</a>.</p>