Skip to content

Commit

Permalink
docs: improve doc structure (#33)
Browse files Browse the repository at this point in the history
* fix build errors

* fix build errors

* docs: wip - improve doc structure

* update tsconfig

* docs: add CONTRIBUTING.md

* use rome instead of eslint

* update yarn lock
  • Loading branch information
universalmind303 authored Mar 27, 2023
1 parent ca8b7b8 commit e021cc0
Show file tree
Hide file tree
Showing 55 changed files with 6,408 additions and 7,162 deletions.
82 changes: 0 additions & 82 deletions .eslintrc.json

This file was deleted.

Binary file added .yarn/install-state.gz
Binary file not shown.
10 changes: 5 additions & 5 deletions @types/jest.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {DataFrame} from "@polars/dataframe";
import {Series} from "@polars/series/series";
import {Series} from "@polars/series";

declare global {
namespace jest {
Expand All @@ -12,11 +12,11 @@ declare global {
*
* @example
* ```
* >>> df = pl.Dataframe([pl.Series("int32": [1,2], pl.Int32)])
* >>> other = pl.Dataframe([pl.Series("int32": [1,2], pl.UInt32)])
* > df = pl.Dataframe([pl.Series("int32": [1,2], pl.Int32)])
* > other = pl.Dataframe([pl.Series("int32": [1,2], pl.UInt32)])
*
* >>> expect(df).toFrameEqual(other) // passes
* >>> expect(df).toFrameStrictEqual(other) // fails
* > expect(df).toFrameEqual(other) // passes
* > expect(df).toFrameStrictEqual(other) // fails
* ```
*/
toFrameStrictEqual(b: DataFrame): R;
Expand Down
71 changes: 71 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Contributing to nodejs-polars

First of all, thank you for considering contributing to nodejs-polars!

The following is a set of guidelines for contributing to nodejs-polars. These are just guidelines, not rules, use your best judgment and feel free to propose changes to this document in a pull request.

## How Can I Contribute?

### Reporting Bugs

- **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/pola-rs/nodejs-polars/issues).

- If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.

- If possible, use the relevant bug report templates to create the issue.

### Suggesting Enhancements

- Open a new GitHub issue in the [Issues](https://github.com/pola-rs/nodejs-polars/issues) with a **clear title** and **description**.

- If possible, use the relevant enhancement request templates to create the issue.


### Pull Requests

- Fill in the required template
- Use a descriptive title. *(This will end up in the changelog)*
- In the pull request description, link to the issue you were working on.
- Add any relevant information to the description that you think may help the maintainers review your code.
- Make sure your branch is [rebased](https://docs.github.com/en/get-started/using-git/about-git-rebase) against the latest version of the `main` branch.
- Make sure all GitHub Actions checks pass.



## Development
### Vscode
If using VScode, it is recommended to install the following extensions
- rust-analyzer
- rome
---

- Fork the repository, then clone it from your fork
```
git clone https://github.com/<your-github-username>/nodejs-polars.git
```

- Install dependencies
```
yarn install
```

- Build the binary
```
yarn build:debug
```

- Run the tests
```
yarn jest
```

- Make your changes
- Test your changes
-
You can run the `precommit` command to make sure all of your tests pass & code is formatted correctly.
```
yarn precommit
```

- Update the documentation if necessary
- Create a new pull request
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,45 @@ const pl = require('nodejs-polars');
### Series

```js
>>> const fooSeries = pl.Series("foo", [1, 2, 3])
>>> fooSeries.sum()
> const fooSeries = pl.Series("foo", [1, 2, 3])
> fooSeries.sum()
6

// a lot operations support both positional and named arguments
// you can see the full specs in the docs or the type definitions
>>> fooSeries.sort(true)
>>> fooSeries.sort({reverse: true})
> fooSeries.sort(true)
> fooSeries.sort({reverse: true})
shape: (3,)
Series: 'foo' [f64]
[
3
2
1
]
>>> fooSeries.toArray()
> fooSeries.toArray()
[1, 2, 3]

// Series are 'Iterables' so you can use javascript iterable syntax on them
>>> [...fooSeries]
> [...fooSeries]
[1, 2, 3]

>>> fooSeries[0]
> fooSeries[0]
1

```

### DataFrame

```js
>>> const df = pl.DataFrame(
>const df = pl.DataFrame(
... {
... A: [1, 2, 3, 4, 5],
... fruits: ["banana", "banana", "apple", "apple", "banana"],
... B: [5, 4, 3, 2, 1],
... cars: ["beetle", "audi", "beetle", "beetle", "beetle"],
... }
... )
>>> df
... .sort("fruits")
... .select(
> df.sort("fruits").select(
... "fruits",
... "cars",
... pl.lit("fruits").alias("literal_string_fruits"),
Expand Down Expand Up @@ -90,7 +88,7 @@ shape: (5, 8)
```

```js
>>> df["cars"] // or df.getColumn("cars")
> df["cars"] // or df.getColumn("cars")
shape: (5,)
Series: 'cars' [str]
[
Expand Down
5 changes: 1 addition & 4 deletions __tests__/complex_types.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import pl from "@polars";


describe("complex types", () => {

test.skip("nested arrays round trip", () => {
const arr = [[["foo"]], [], null];
const s = pl.Series("", arr);
const actual = s.toArray();
expect(actual).toEqual(arr);
});
test.skip("struct arrays round trip", () => {
const arr = [{foo: "a", bar: 1}, null, null];
const arr = [{ foo: "a", bar: 1 }, null, null];
const s = pl.Series("", arr);
const actual = s.toArray();
expect(actual).toEqual(arr);
});

});
Loading

0 comments on commit e021cc0

Please sign in to comment.