-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from deepmodeling/master
Sync devel with master
- Loading branch information
Showing
35 changed files
with
1,189 additions
and
759 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
name: Bug report | ||
about: Create a bug report to help us eliminate issues and improve dpdata. If this | ||
doesn’t look right, [choose a different type](https://github.com/deepmodeling/dpdata/issues/new/choose). | ||
title: "[BUG] _Replace With Suitable Title_" | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Summary** | ||
|
||
<!--Please provide a clear and concise description of what the bug is.--> | ||
|
||
<!--Please provide necessary information including the version of software and installation way, input file, running commands, error log , etc., AS DETAILED AS POSSIBLE to help locate and reproduce your problem. --> | ||
|
||
<!--If applicable, specify what platform you are running on. --> | ||
|
||
**Steps to Reproduce** | ||
|
||
<!--Describe the steps required to (quickly) reproduce the issue. You can attach (small) files to the section below or add URLs where to download an archive with all necessary files. Please try to create an input set that is as minimal and small as possible and reproduces the bug as quickly as possible. **NOTE:** the less effort and time it takes to reproduce your reported bug, the more likely it becomes, that somebody will look into it and fix the problem.--> | ||
|
||
**Further Information, Files, and Links** | ||
|
||
<!--Put any additional information here, attach relevant text or image files and URLs to external sites, e.g. relevant publications--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project. If this doesn’t work right, [choose a different | ||
type]( https://github.com/deepmodeling/dpdata/issues/new/choose). | ||
title: "[Feature Request] _Replace with Title_" | ||
labels: enhancement | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Summary** | ||
|
||
<!--Please provide a brief and concise description of the suggested feature or change--> | ||
|
||
**Detailed Description** | ||
|
||
<!--Please explain how you would like to see dpdata enhanced, what feature(s) you are looking for, what specific data format this will support or what specific problems this will solve. If possible, provide references to relevant background information like publications or web pages, and whether you are planning to implement the enhancement yourself or would like to participate in the implementation. If applicable add a reference to an existing bug report or issue that this will address.--> | ||
|
||
**Further Information, Files, and Links** | ||
|
||
<!--Put any additional information here, attach relevant text or image files and URLs to external sites, e.g. relevant publications--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Generic issue | ||
about: For issues that do not fit any of the other categories. If this doesn’t work | ||
right, [choose a different type]( https://github.com/deepmodeling/dpdata/issues/new/choose). | ||
title: '' | ||
labels: wontfix | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Summary** | ||
|
||
<!--Please provide a clear and concise description of what the question is.--> | ||
|
||
**Details** | ||
|
||
<!--Please explain the issue in detail here--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
name: Request for Help | ||
about: Don't post help requests here, go to [discussions](https://github.com/deepmodeling/dpdata/discussions) | ||
instead. If this doesn’t look right, choose a different type. | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
Before asking questions, you can | ||
|
||
search the previous issues or discussions | ||
check the [README](https://github.com/deepmodeling/dpdata/#readme). | ||
|
||
Please **do not** post requests for help (e.g. with installing or using dpdata) here. | ||
Instead go to [discussions](https://github.com/deepmodeling/dpdata/discussions). | ||
|
||
This issue tracker is for tracking dpdata development related issues only. | ||
|
||
Thanks for your cooperation. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
"""Implement the format plugin system.""" | ||
import os | ||
from collections import abc | ||
from abc import ABC | ||
|
||
from .plugin import Plugin | ||
|
||
|
||
class Format(ABC): | ||
__FormatPlugin = Plugin() | ||
__FromPlugin = Plugin() | ||
__ToPlugin = Plugin() | ||
|
||
@staticmethod | ||
def register(key): | ||
return Format.__FormatPlugin.register(key) | ||
|
||
@staticmethod | ||
def register_from(key): | ||
return Format.__FromPlugin.register(key) | ||
|
||
@staticmethod | ||
def register_to(key): | ||
return Format.__ToPlugin.register(key) | ||
|
||
@staticmethod | ||
def get_formats(): | ||
return Format.__FormatPlugin.plugins | ||
|
||
@staticmethod | ||
def get_from_methods(): | ||
return Format.__FromPlugin.plugins | ||
|
||
@staticmethod | ||
def get_to_methods(): | ||
return Format.__ToPlugin.plugins | ||
|
||
@staticmethod | ||
def post(func_name): | ||
def decorator(object): | ||
if not isinstance(func_name, (list, tuple, set)): | ||
object.post_func = (func_name,) | ||
else: | ||
object.post_func = func_name | ||
return object | ||
return decorator | ||
|
||
def from_system(self, file_name, **kwargs): | ||
"""System.from | ||
Parameters | ||
---------- | ||
file_name: str | ||
file name | ||
Returns | ||
------- | ||
data: dict | ||
system data | ||
""" | ||
raise NotImplementedError("%s doesn't support System.from" %(self.__class__.__name__)) | ||
|
||
def to_system(self, data, *args, **kwargs): | ||
"""System.to | ||
Parameters | ||
---------- | ||
data: dict | ||
system data | ||
""" | ||
raise NotImplementedError("%s doesn't support System.to" %(self.__class__.__name__)) | ||
|
||
def from_labeled_system(self, file_name, **kwargs): | ||
raise NotImplementedError("%s doesn't support LabeledSystem.from" %(self.__class__.__name__)) | ||
|
||
def to_labeled_system(self, data, *args, **kwargs): | ||
return self.to_system(data, *args, **kwargs) | ||
|
||
def from_bond_order_system(self, file_name, **kwargs): | ||
raise NotImplementedError("%s doesn't support BondOrderSystem.from" %(self.__class__.__name__)) | ||
|
||
def to_bond_order_system(self, data, rdkit_mol, *args, **kwargs): | ||
return self.to_system(data, *args, **kwargs) | ||
|
||
class MultiModes: | ||
"""File mode for MultiSystems | ||
0 (default): not implemented | ||
1: every directory under the top-level directory is a system | ||
""" | ||
NotImplemented = 0 | ||
Directory = 1 | ||
|
||
MultiMode = MultiModes.NotImplemented | ||
|
||
def from_multi_systems(self, directory, **kwargs): | ||
"""MultiSystems.from | ||
Parameters | ||
---------- | ||
directory: str | ||
directory of system | ||
Returns | ||
------- | ||
filenames: list[str] | ||
list of filenames | ||
""" | ||
if self.MultiMode == self.MultiModes.Directory: | ||
return [name for name in os.listdir(directory) if os.path.isdir(os.path.join(directory, name))] | ||
raise NotImplementedError("%s doesn't support MultiSystems.from" %(self.__class__.__name__)) | ||
|
||
def to_multi_systems(self, formulas, directory, **kwargs): | ||
if self.MultiMode == self.MultiModes.Directory: | ||
return [os.path.join(directory, ff) for ff in formulas] | ||
raise NotImplementedError("%s doesn't support MultiSystems.to" %(self.__class__.__name__)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Base of plugin systems.""" | ||
|
||
|
||
class Plugin: | ||
"""A class to register plugins. | ||
Examples | ||
-------- | ||
>>> Plugin = Register() | ||
>>> @Plugin.register("xx") | ||
def xxx(): | ||
pass | ||
>>> print(Plugin.plugins['xx']) | ||
""" | ||
def __init__(self): | ||
self.plugins = {} | ||
|
||
def register(self, key): | ||
"""Register a plugin. | ||
Parameter | ||
--------- | ||
key: str | ||
Key of the plugin. | ||
""" | ||
def decorator(object): | ||
self.plugins[key] = object | ||
return object | ||
return decorator | ||
|
||
def get_plugin(self, key): | ||
return self.plugins[key] | ||
|
||
def __add__(self, other): | ||
self.plugins.update(other.plugins) | ||
return self |
Oops, something went wrong.