Skip to content
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

Andowinger add median #896

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

andowinger
Copy link

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

https://discourse.nodered.org/t/feature-request-smooth-add-median-filter-to-node-red-node-smooth/60359

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run grunt to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 27, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@andowinger
Copy link
Author

Added "median" option to the Smooth function filters

@dceejay
Copy link
Member

dceejay commented Mar 27, 2022

Looks good - would be great if you could add some tests to tests/function/17-smooth_spec.js as well... Thanks

@andowinger
Copy link
Author

Looks good - would be great if you could add some tests to tests/function/17-smooth_spec.js as well... Thanks

Ok, I will try to do that soon

@andowinger
Copy link
Author

@dceejay I added a test, but I don't know how to run the test: At least installing the two required modules and running a node .\17-smooth_spec.js didnot work since describe is not defined. I guess I would need to install a real test environment or something.
If you could run it or give guidance what I am missing out, this would be great.

@dceejay
Copy link
Member

dceejay commented Apr 11, 2022

Hi @andowinger - If you have mocha installed you should be able to run (at the top directory level of the overall project)
mocha test/function/smooth/17-smooth_spec.js
to run the tests for this node - you should get an output like


  smooth node
    ✓ should be loaded with correct defaults
    ✓ should average over a number of inputs
    ✓ should average over a number of inputs using median
    ✓ should average over a number of inputs - another property - foo
    ✓ should be able to be reset
    ✓ should be able to be reset - while using another property - foo
    ✓ should output max over a number of inputs
    ✓ should output min over a number of inputs
    ✓ should output standard deviation over a number of inputs
    ✓ should do a low pass filter over a number of inputs
    ✓ should do a high pass filter over a number of inputs
    ✓ ignore msg with non numeric payload (55ms)
    ✓ ignore msg with no payload (53ms)
    ✓ should average over a number of inputs on different topics
    ✓ should average over different topics if asked
    ✓ should reduce the number of messages by averaging if asked
    ✓ should reduce the number of messages by max value, if asked
    ✓ should reduce the number of messages by min value, if asked


  18 passing (313ms)

Then optionally you could run grunt (you may need to sudo npm i -g grunt-cli to install it) - to run all the tests in the project.

@andowinger
Copy link
Author

andowinger commented Apr 21, 2022

Hey @dceejay
I get this error message:

  1. smooth node
    "before each" hook for "should be loaded with correct defaults":
    TypeError: Cannot read property 'init' of undefined
    at NodeTestHelper.startServer (node_modules\node-red-node-test-helper\index.js:315:19)
    at Context. (test\function\smooth\17-smooth_spec.js:10:16)
    at processImmediate (internal/timers.js:461:21)

  2. smooth node
    "after each" hook for "should be loaded with correct defaults":
    TypeError: Cannot read property 'clearRegistry' of undefined
    at NodeTestHelper.unload (node_modules\node-red-node-test-helper\index.js:283:24)
    at Context. (test\function\smooth\17-smooth_spec.js:14:16)
    at processImmediate (internal/timers.js:461:21)

I am using node with Windows. I guess I should set up a VM with a Linux distribution and retry it... I will do this within the next few days - except that you now by any chance the reason for this error and how to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants