Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from zincware/npm_pckg
Browse files Browse the repository at this point in the history
add npm package
  • Loading branch information
PythonFZ authored Jan 2, 2024
2 parents b74e618 + 7fa272a commit 71166aa
Show file tree
Hide file tree
Showing 9 changed files with 1,273 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
env:
browser: true
es2021: true
extends: eslint:recommended
parserOptions:
ecmaVersion: latest
sourceType: module
rules: {}
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
args: ["--assume-in-merge"]
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.53.0
hooks:
- id: eslint
args: [--fix]
additional_dependencies:
- eslint@latest
- eslint-config-prettier
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies: ["tomli"]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: "v0.1.5"
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
args: ["--wrap=80"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

# ZnFrame - ASE-like Interface based on dataclasses

This package is designed for light-weight applications that require a structure for managing atomic structures.
It's primary focus lies on the conversion to / from JSON, to send data around easily.
This package is designed for light-weight applications that require a structure
for managing atomic structures. It's primary focus lies on the conversion to /
from JSON, to send data around easily.

```python
from znframe import Frame
Expand All @@ -18,4 +19,4 @@ print(frame.to_json())

# Installation

`pip install znframe`
`pip install znframe`
42 changes: 42 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Replicate znframe.Frame in JavaScript

class Atom {
constructor({ position, number, arrays }) {
this.position = position;
this.number = number;
this.arrays = arrays;
}
}

class Frame {
constructor(numbers, positions, arrays, info, pbc, cell) {
this.numbers = numbers;
this.positions = positions;
this.arrays = arrays;
this.info = info;
this.pbc = pbc;
this.cell = cell;
}

[Symbol.iterator]() {
let index = 0;
return {
next: () => {
if (index < this.numbers.length) {
return {
value: new Atom({
position: this.positions[index],
number: this.numbers[index],
arrays: this.arrays[index],
}),
done: false,
};
} else {
return { done: true };
}
},
};
}
}

export default { Frame, Atom };
Loading

0 comments on commit 71166aa

Please sign in to comment.