-
-
Notifications
You must be signed in to change notification settings - Fork 804
feat: add protocol support to stats/base/range
#5779
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
base: develop
Are you sure you want to change the base?
Conversation
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: ---
@kgryte I have submitted a pull request addressing issue #5679, and I would love to contribute further to resolving this issue completely. I would appreciate your guidance on any necessary improvements or changes required to get this PR merged. Please let me know how I can assist in the process. Looking forward to your feedback. |
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
Coverage Report
The above coverage report was generated for the changes in this PR. |
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
stats/base/range
stats/base/range
var randu = require( '@stdlib/random/base/randu' ); | ||
var round = require( '@stdlib/math/base/special/round' ); | ||
var Float64Array = require( '@stdlib/array/float64' ); | ||
var linspace = require( '@stdlib/array/base/linspace' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use @stdlib/random/array/discrete-uniform
.
x = linspace(-50, 50, 10); | ||
x = x.map(round); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will then become
x = linspace(-50, 50, 10); | |
x = x.map(round); | |
x = discreteUniform( 10, -50, 50, { | |
'dtype': 'float64' | |
}); |
var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
var linspace = require( '@stdlib/array/base/linspace' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use @stdlib/random/array/uniform
, rather than linspace
.
@@ -22,6 +22,7 @@ | |||
|
|||
var bench = require( '@stdlib/bench' ); | |||
var randu = require( '@stdlib/random/base/randu' ); | |||
var linspace = require( '@stdlib/array/linspace' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment.
@@ -1,92 +1,124 @@ | |||
{{alias}}( N, x, strideX ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{alias}}( N, x, strideX ) | |
{{alias}}( N, x, strideX ) |
The `N` and stride parameters determine which elements in the strided | ||
array are accessed at runtime. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
Indexing is relative to the first index. To introduce an offset, use a typed | ||
array view. | ||
The `N` and stride parameters determine which elements in the strided |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look properly wrapped at 80 chars.
Parameters | ||
---------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you adding all these blank lines? Please remove and follow our REPL text style guide.
|
||
Returns | ||
------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
// Standard Usage: | ||
> var x = [ 1.0, -2.0, 2.0 ]; | ||
> {{alias}}( x.length, x, 1 ) | ||
4.0 | ||
|
||
// Using `N` and `stride` parameters: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to go through and remove all these stray lines. Please study other repl.txt files.
for ( i = 0; i < x.length; i++ ) { | ||
x[ i ] = round( (randu()*100.0) - 50.0 ); | ||
} | ||
var x = linspace(-50, 50, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be updated to match any future changes to the README.
return NaN; | ||
} | ||
if ( N === 1 || stride === 0 ) { | ||
const v = get( x, 0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use ES5. All of this ES6+ usage needs to be changed. Please study the conventions in other files.
* // returns 6.0 | ||
*/ | ||
function range( N, x, stride, offset ) { | ||
function range( N, x, strideX, offsetX ) { | ||
var obj = arraylike2object( x ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not what we want. Please study other implementations. Accessing directly in data
is precisely what we want to avoid if x
is an accessor array. That is the entire point of accessors.js
.
@@ -21,7 +21,8 @@ | |||
// MODULES // | |||
|
|||
var isnan = require( '@stdlib/math/base/assert/is-nan' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer used.
|
||
x = [ -3.0, -2.0, -1.0, 1.0, 2.0, 3.0 ]; | ||
v = range( x.length, toAccessorArray( x ), 1, 0 ); | ||
t.ok(isnan(v), 'returns expected value'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these tests are obviously wrong. We shouldn't be returning NaN
.
|
||
v = range( 4, toAccessorArray( x ), 2, 0 ); | ||
|
||
t.ok(isnan(v), 'returns expected value'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left an initial round of comments. The implementation is currently wrong and the tests obviously so. I suggest doing a close study of other packages which have accessor protocol support to better understand what is desired.
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
* @license Apache-2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @license Apache-2.0 | |
* @license Apache-2.0 |
@jalajk3004 Hey the license should not be tempered with here. Hence the CI error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Neerajpathak07, Error is solved.
But I am still facing the problem with Repl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well that's because the expected and the returned values do not match. Check your implementation once again and do go through the repl.txt
file to see if everything is in-line.
Signed-off-by: Athan <kgryte@gmail.com>
Resolves #5679
Description
This pull request:
Related Issues
This pull request:
stats/base/range
#5679Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers