Skip to content

Commit

Permalink
Merge pull request #58 from CURENT/develop
Browse files Browse the repository at this point in the history
Prep for patch release
  • Loading branch information
jinningwang authored Mar 4, 2024
2 parents 61f7907 + 7e2a68f commit 960faaf
Show file tree
Hide file tree
Showing 48 changed files with 1,469 additions and 1,032 deletions.
4 changes: 3 additions & 1 deletion .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ exclude_paths:
- "ams/_version.py"
- ".github/**"
- "README.md"
- "tests/**"
- "CODE_OF_CONDUCT.md"
- "tests/**"
- "docs/**"
4 changes: 3 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ ignore:
- "ams/_version.py"
- ".github/**"
- "README.md"
- "tests/**"
- "CODE_OF_CONDUCT.md"
- "tests/**"
- "docs/**"
11 changes: 11 additions & 0 deletions .github/dependentbot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "pip"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
10 changes: 9 additions & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Code coverage

on: [push, pull_request]
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

jobs:
build:
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Python application

on: [push, pull_request]
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop

jobs:
build:
Expand Down
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at jwang175@vols.utk.edu. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

Python Software for Power System Dispatch Modeling and Co-Simulation with Dynanic, serving as the market simulator for the [CURENT Largescale Testbed][LTB Repository].

[![License: GPL-3.0](https://img.shields.io/badge/License-GPL--3.0-blue.svg)](https://github.com/CURENT/ams/blob/master/LICENSE)
![platforms](https://anaconda.org/conda-forge/ltbams/badges/platforms.svg)
[![Python Versions](https://img.shields.io/badge/Python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://www.python.org/)
![Repo Size](https://img.shields.io/github/repo-size/CURENT/ams)
![Code Lines](https://tokei.rs/b1/github/CURENT/ams?category=code)
![Files](https://tokei.rs/b1/github/CURENT/ams?category=files)
![GitHub Last Commit](https://img.shields.io/github/last-commit/CURENT/ams)
[![HitCount](https://hits.dwyl.com/CURENT/ams.svg)](https://hits.dwyl.com/CURENT/ams)
[![libraries](https://img.shields.io/librariesio/release/pypi/ltbams)](https://libraries.io/pypi/ltbams)
[![Structure](https://img.shields.io/badge/code_base-visualize-blue)](https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=CURENT%2Fams)

<img src="docs/source/images/sponsors/CURENT_Logo_NameOnTrans.png" alt="CURENT ERC Logo" width="300" height="auto">

| | Latest | Stable |
Expand All @@ -15,8 +26,6 @@ Python Software for Power System Dispatch Modeling and Co-Simulation with Dynani
| Try on Binder | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/curent/ams/master) | |
| Code Quality |[![Codacy Badge](https://app.codacy.com/project/badge/Grade/69456da1b8634f2f984bd769e35f0050)](https://app.codacy.com/gh/CURENT/ams/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)| [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/69456da1b8634f2f984bd769e35f0050)](https://app.codacy.com/gh/CURENT/ams/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage) |
| Build Status | [![GitHub Action Status](https://github.com/CURENT/ams/workflows/Python%20application/badge.svg)](https://github.com/curent/ams/actions) | [![Build Status](https://dev.azure.com/curentltb/ams/_apis/build/status%2FCURENT.ams?branchName=master)](https://dev.azure.com/curentltb/ams/_build/latest?definitionId=2&branchName=master) |
| Structure | [![Structure](https://img.shields.io/badge/code_base-visualize-blue)](https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=CURENT%2Fams)
| Python Version | [![Python Versions](https://img.shields.io/badge/Python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)](https://www.python.org/) |


# Why AMS
Expand Down
18 changes: 3 additions & 15 deletions ams/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
logger = logging.getLogger(__name__)

command_aliases = {
'prepare': ['prep'],
'selftest': ['st'],
}

Expand All @@ -41,10 +40,8 @@ def create_parser():
type=int, default=20, choices=(1, 10, 20, 30, 40))

sub_parsers = parser.add_subparsers(dest='command', help='[run] run simulation routine; '
'[plot] plot results; '
'[doc] quick documentation; '
'[misc] misc. functions; '
'[prepare] prepare the numerical code; '
'[selftest] run self test; '
)

Expand Down Expand Up @@ -76,10 +73,7 @@ def create_parser():
type=str, default='', nargs='*')

doc = sub_parsers.add_parser('doc')
# TODO: fit to AMS
# doc.add_argument('attribute', help='System attribute name to get documentation', nargs='?')
# doc.add_argument('--config', '-c', help='Config help')
doc.add_argument('--list', '-l', help='List supported models and groups', action='store_true',
doc.add_argument('--list', '-l', help='List supported routines', action='store_true',
dest='list_supported')

misc = sub_parsers.add_parser('misc')
Expand All @@ -92,15 +86,9 @@ def create_parser():
misc.add_argument('-C', '--clean', help='Clean output files', action='store_true')
misc.add_argument('-r', '--recursive', help='Recursively clean outputs (combined useage with --clean)',
action='store_true')
# TODO: fit to AMS
misc.add_argument('-O', '--config-option',
help='Set configuration option specificied by '
'NAME.FIELD=VALUE with no space. For example, "TDS.tf=2"',
type=str, default='', nargs='*')
misc.add_argument('--version', action='store_true', help='Display version information')

# TODO: add quick or extra options for selftest
selftest = sub_parsers.add_parser('selftest', aliases=command_aliases['selftest']) # NOQA
sub_parsers.add_parser('selftest', aliases=command_aliases['selftest']) # NOQA

return parser

Expand Down Expand Up @@ -139,7 +127,7 @@ def main():

module = importlib.import_module('ams.main')

if args.command in ('plot', 'doc', 'misc'):
if args.command in ('doc', 'misc'):
pass
elif args.command == 'run' and args.no_preamble is True:
pass
Expand Down
48 changes: 46 additions & 2 deletions ams/core/documenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def get(self, max_width=78, export='plain'):
self.parent.syms.generate_symbols()
out += self._obj_doc(max_width=max_width, export=export)
out += self._constr_doc(max_width=max_width, export=export)
out += self._expr_doc(max_width=max_width, export=export)
out += self._var_doc(max_width=max_width, export=export)
out += self._service_doc(max_width=max_width, export=export)
out += self._param_doc(max_width=max_width, export=export)
Expand Down Expand Up @@ -286,9 +287,9 @@ def _constr_doc(self, max_width=78, export='plain'):
if export == 'rest':
for p in self.constrs.values():
expr = _tex_pre(self, p, self.parent.syms.tex_map)
if p.type == 'eq':
if p.is_eq:
expr = f'{expr} = 0'
elif p.type == 'uq':
else:
expr = f'{expr} \\leq 0'
logger.debug(f'{p.name} math: {expr}')
expressions.append(expr)
Expand All @@ -314,6 +315,49 @@ def _constr_doc(self, max_width=78, export='plain'):
plain_dict=plain_dict,
rest_dict=rest_dict)

def _expr_doc(self, max_width=78, export='plain'):
# expression documentation
if len(self.parent.exprs) == 0:
return ''

# prepare temporary lists
names, var_names, info = list(), list(), list()

for p in self.parent.exprs.values():
names.append(p.name)
var_names.append(p.var)
info.append(p.info if p.info else '')

# expressions based on output format
expressions = []
if export == 'rest':
for p in self.parent.exprs.values():
expr = _tex_pre(self, p, self.parent.syms.tex_map)
logger.debug(f'{p.name} math: {expr}')
expressions.append(expr)

title = 'Expressions\n----------------------------------'
else:
title = 'Expressions'
expressions = math_wrap(expressions, export=export)

plain_dict = OrderedDict([('Name', names),
('Variable', var_names),
('Description', info),
])
rest_dict = OrderedDict([('Name', names),
('Variable', var_names),
('Description', info),
('Expression', expressions),
])

# convert to rows and export as table
return make_doc_table(title=title,
max_width=max_width,
export=export,
plain_dict=plain_dict,
rest_dict=rest_dict)

def _obj_doc(self, max_width=78, export='plain'):
# variable documentation
if self.parent.obj is None:
Expand Down
4 changes: 2 additions & 2 deletions ams/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

import numpy as np
from andes.core.common import Config
from andes.core.param import ExtParam
from andes.core.service import BaseService, BackRef
from andes.utils.func import list_flatten

from ams.core.documenter import Documenter
from ams.core.var import Algeb
from ams.core.param import ExtParam
from ams.core.service import BaseService, BackRef

logger = logging.getLogger(__name__)

Expand Down
8 changes: 3 additions & 5 deletions ams/core/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import numpy as np
from scipy.sparse import issparse

from andes.core import BaseParam, DataParam, IdxParam, NumParam, ExtParam # NOQA

from ams.opt.omodel import Param

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -58,7 +56,7 @@ class RParam(Param):
True to set the parameter as non-negative.
nonpos: bool, optional
True to set the parameter as non-positive.
complex: bool, optional
cplx: bool, optional
True to set the parameter as complex.
imag: bool, optional
True to set the parameter as imaginary.
Expand Down Expand Up @@ -114,7 +112,7 @@ def __init__(self,
no_parse: Optional[bool] = False,
nonneg: Optional[bool] = False,
nonpos: Optional[bool] = False,
complex: Optional[bool] = False,
cplx: Optional[bool] = False,
imag: Optional[bool] = False,
symmetric: Optional[bool] = False,
diag: Optional[bool] = False,
Expand All @@ -126,7 +124,7 @@ def __init__(self,
sparse: Optional[list] = None,
):
Param.__init__(self, nonneg=nonneg, nonpos=nonpos,
complex=complex, imag=imag, symmetric=symmetric,
cplx=cplx, imag=imag, symmetric=symmetric,
diag=diag, hermitian=hermitian, boolean=boolean,
integer=integer, pos=pos, neg=neg, sparse=sparse)
self.name = name
Expand Down
Loading

0 comments on commit 960faaf

Please sign in to comment.