Skip to content

Commit 6cec06a

Browse files
committed
feat(multi): Initial implementation
0 parents  commit 6cec06a

30 files changed

+16022
-0
lines changed

Diff for: .editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

Diff for: .eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

Diff for: .eslintrc.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true,
5+
},
6+
plugins: [
7+
'markdown',
8+
'import'
9+
],
10+
extends: [
11+
'eslint:recommended',
12+
'plugin:json/recommended',
13+
'plugin:@typescript-eslint/recommended',
14+
'plugin:sonarjs/recommended',
15+
'prettier/@typescript-eslint',
16+
'plugin:prettier/recommended', // Make sure this is always the last entry.
17+
],
18+
parserOptions: {
19+
ecmaVersion: 2020,
20+
},
21+
rules: {
22+
'@typescript-eslint/explicit-module-boundary-types': 0,
23+
'@typescript-eslint/no-unused-vars': 'error',
24+
'import/default': 1,
25+
'import/no-useless-path-segments': [
26+
'error',
27+
{
28+
noUselessIndex: true,
29+
},
30+
],
31+
'import/order': [
32+
'error',
33+
{
34+
groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
35+
'newlines-between': 'always',
36+
},
37+
],
38+
},
39+
overrides: [
40+
{
41+
files: ['tests/**/*.test.ts'],
42+
env: {
43+
jest: true,
44+
},
45+
},
46+
],
47+
};

Diff for: .github/workflows/auto-approve.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Auto approve
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
auto-approve:
7+
runs-on: ubuntu-latest
8+
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
9+
steps:
10+
- uses: hmarr/[email protected]
11+
with:
12+
github-token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'

Diff for: .github/workflows/check-pr.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Check PR
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
danger:
7+
runs-on: ubuntu-latest
8+
9+
strategy:
10+
matrix:
11+
node-version: [10.20.1]
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Use Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
- name: Install dependencies
20+
run: npm install
21+
- name: Run danger checks
22+
env:
23+
DANGER_GITHUB_API_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
24+
run: npx danger ci

Diff for: .github/workflows/release.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
node-version: [10.20.1]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
- name: Install dependencies
23+
run: npm install
24+
- name: Release
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
27+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
28+
run: npx semantic-release

Diff for: .github/workflows/test.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
cancel-previous:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: rokroskar/workflow-run-cleanup-action@master
10+
env:
11+
GITHUB_TOKEN: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
12+
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [10.20.1]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
- name: Install dependencies
27+
run: npm install
28+
- name: Test
29+
run: npm test

Diff for: .gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.DS_Store
2+
node_modules
3+
4+
# local env files
5+
.env.local
6+
.env.*.local
7+
8+
# Log files
9+
npm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
pnpm-debug.log*
13+
14+
# Editor directories and files
15+
.idea
16+
.vscode
17+
*.suo
18+
*.ntvs*
19+
*.njsproj
20+
*.sln
21+
*.sw?
22+
23+
# Project specific
24+
dist
25+
docs
26+
coverage

Diff for: .nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10.20

Diff for: .prettierrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
singleQuote: true,
3+
semi: true,
4+
trailingComma: 'es5',
5+
};

Diff for: README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# tensorflow-load-csv
2+
3+
A library that aims to remove the overhead of creating tensors from CSV files completely; allowing you to dive right into the fun parts of your ML project.
4+
5+
- Lightweight.
6+
- Fast.
7+
- Flexible.
8+
- TypeScript compatible.
9+
- 100% test coverage.
10+
11+
## Installation
12+
13+
NPM:
14+
sh
15+
```
16+
npm install tensorflow-load-csv
17+
```
18+
19+
Yarn:
20+
sh
21+
```
22+
yarn add tensorflow-load-csv
23+
```
24+
25+
## Usage
26+
27+
Simple usage:
28+
js
29+
```
30+
import loadCsv from 'tensorflow-load-csv';
31+
32+
const { features, labels } = loadCsv('./data.csv', {
33+
featureColumns: ['lat', 'lng', 'height'],
34+
labelColumns: ['temperature'],
35+
});
36+
```
37+
38+
Advanced usage:
39+
js
40+
```
41+
import loadCsv from 'tensorflow-load-csv';
42+
43+
const {
44+
features,
45+
labels,
46+
testFeatures,
47+
testLabels,
48+
mean, // tensor holding mean of features, ignores testFeatures
49+
variance // tensor holding variance of features, ignores testFeatures
50+
} = loadCsv('./data.csv', {
51+
featureColumns: ['lat', 'lng', 'height'],
52+
labelColumns: ['temperature'],
53+
shuffle: true,
54+
splitTest: true, // Splits your data in half. You can also provide a certain row count for the test data.
55+
prependOnes: true, // Prepends a column of 1s to your features and testFeatures tensors, useful for linear regression.
56+
standardise: true, // Calculates the standard deviation for each feature and testFeature column and standardises the values in those columns. Does not touch labels.
57+
});
58+
```

Diff for: assets/csv/simple.csv

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
lat,lng,country
2+
0.234,1.47,SomeCountria
3+
-93.2,103.34,SomeOtherCountria
4+
5,40.34,Landistan
5+
102,-164,Landotzka

Diff for: commitlint.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
const scopes = require('./commitlint.scopes');
3+
4+
module.exports = {
5+
extends: ['@commitlint/config-conventional'],
6+
rules: {
7+
'scope-empty': [2, 'never'],
8+
'scope-enum': [2, 'always', scopes],
9+
'subject-case': [2, 'always', ['sentence-case']],
10+
},
11+
};

Diff for: commitlint.scopes.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = [
2+
'multi',
3+
'config',
4+
'github',
5+
'script',
6+
'deps',
7+
'dev-deps',
8+
'asset',
9+
'lib',
10+
'release',
11+
];

Diff for: dangerfile.ts

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { danger, fail, warn } from 'danger';
2+
3+
import scopes from './commitlint.scopes';
4+
5+
const titlePattern = /^(\w+)\(([a-z-]+)\): (.+)$/;
6+
7+
const pr = danger.github.pr;
8+
const isBotPr = pr.user.type === 'Bot';
9+
10+
/**
11+
* Rules
12+
*/
13+
14+
if (!isBotPr) {
15+
// Check PR title
16+
if (!titlePattern.test(pr.title)) {
17+
fail('The PR title needs to be in format: `type(scope): Description`.');
18+
} else {
19+
const titleParts = pr.title.match(titlePattern);
20+
21+
if (!titleParts || titleParts.length < 3) {
22+
fail('Unexpected PR title parsing error');
23+
} else {
24+
const scope = titleParts[2];
25+
26+
if (!scopes.includes(scope)) {
27+
fail(
28+
'Scope in PR title must be one included in the wc.config.js file of the project.'
29+
);
30+
}
31+
}
32+
}
33+
}
34+
35+
// Make sure someone is assigned to merge
36+
if (pr.assignee === null) {
37+
warn(
38+
'Please assign someone to merge this PR, and optionally include people who should review.'
39+
);
40+
}

Diff for: husky.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
hooks: {
3+
'pre-commit': 'lint-staged',
4+
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
5+
'pre-push': 'npm test',
6+
},
7+
};

Diff for: jest.config.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
globals: {
5+
'ts-jest': {
6+
tsConfig: 'tsconfig.jest.json',
7+
},
8+
},
9+
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
10+
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|js)$',
11+
moduleFileExtensions: ['ts', 'js'],
12+
coveragePathIgnorePatterns: ['/node_modules/', '/tests/'],
13+
coverageThreshold: {
14+
global: {
15+
branches: 90,
16+
functions: 95,
17+
lines: 95,
18+
statements: 95,
19+
},
20+
},
21+
collectCoverageFrom: ['src/*.{js,ts}'],
22+
};

Diff for: lint-staged.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
'*.{js,ts,json}': ['eslint --fix', 'jest --findRelatedTests'],
3+
'*.md': 'eslint --fix',
4+
};

0 commit comments

Comments
 (0)