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

Tests for the neuralNetwork addData function. #102

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lindapaiste
Copy link
Contributor

This is a draft because there is a some obnoxious issue with and import statement in the @tensorflow/tfjs-vis package which causes Jest to crash while testing the NeuralNetwork/index.js file. I had to comment out a few lines regarding the NeuralNetworkVis while working on the tests. Make I can make a jest mock for the file?

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    D:\projects\ml5.js\ml5-next-gen\node_modules\@tensorflow\tfjs-core\dist\public\chained_ops\register_all_chained_ops.js:17
    import './abs';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      1 | // import * as tf from '@tensorflow/tfjs';
    > 2 | import * as tfvis from "@tensorflow/tfjs-vis";
        | ^
      3 | // https://js.tensorflow.org/api_vis/latest/#render.barchart
      4 |
      5 | class NeuralNetworkVis {

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
      at Object.<anonymous> (node_modules/@tensorflow/tfjs-vis/src/index.ts:19:1)
      at Object.require (src/NeuralNetwork/NeuralNetworkVis.js:2:1)
      at Object.require (src/NeuralNetwork/index.js:9:1)
      at Object.require (src/NeuralNetwork/index.test.js:2:1)

There are a bunch of tests which fail at the moment that are being ignored with .skip. These are things that I would like to improve in the neural network code eventually, such as throwing errors on logging warnings on incomplete data.

  • classification
    • using property names for inputs and outputs
      • creates a model
      • can add data from a dictionary object
      • ignores excess properties
      • errors on missing properties
      • can add data as an array
      • errors on too few inputs
      • warns on too many inputs
    • using numbers for inputs and outputs
      • creates a model
      • can add data from a dictionary object
      • can add data as an array
  • image classification
    • can add HTML images
    • can add untyped pixel arrays
    • can add typed pixel arrays

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.

1 participant