Skip to content

Commit

Permalink
Allow Co57 and Ni57 columns in downscale3dgrid (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles authored May 16, 2023
1 parent fe358ff commit 4e54608
Show file tree
Hide file tree
Showing 34 changed files with 238 additions and 232 deletions.
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,6 @@ jobs:
with:
options: --check --verbose

flake8:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
cache: pip
python-version-file: .python-version

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip wheel flake8
# python3 -m pip install -r requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --show-source --statistics
mypy:
runs-on: ubuntu-latest
steps:
Expand Down
10 changes: 2 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,16 @@ repos:
hooks:
- id: yamlfmt
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.265
rev: v0.0.267
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
hooks:
- id: reorder-python-imports
types: [python]
args: [--py39-plus, --exit-zero-even-if-changed]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
rev: v1.3.0
hooks:
- id: mypy
additional_dependencies: [numpy, types-PyYAML, types-psutil]
Expand Down
1 change: 1 addition & 0 deletions artistools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import artistools.spectra
import artistools.transitions
import artistools.writecomparisondata

from .__main__ import addargs
from .__main__ import main
from .configuration import get_config
Expand Down
6 changes: 3 additions & 3 deletions artistools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import argcomplete

from .commands import dictcommands
from .commands import dictcommands as atdictcommands
from .misc import CustomArgHelpFormatter


def addargs(parser=None) -> None:
def addargs(parser: argparse.ArgumentParser) -> None:
pass


Expand Down Expand Up @@ -49,7 +49,7 @@ def main(args=None, argsraw=None, **kwargs) -> None:
)
parser.set_defaults(func=None)

addsubparsers(parser, "artistools", dictcommands)
addsubparsers(parser, "artistools", atdictcommands)

argcomplete.autocomplete(parser)
args = parser.parse_args(argsraw)
Expand Down
6 changes: 4 additions & 2 deletions artistools/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import argparse
import subprocess
from pathlib import Path
from typing import Any
from typing import Union

try:
Expand Down Expand Up @@ -118,7 +120,7 @@ def get_console_scripts() -> list[str]:
return console_scripts


def setup_completions(*args, **kwargs) -> None:
def setup_completions(*args: Any, **kwargs: Any) -> None:
# Add the following lines to your .zshrc file to get command completion:
# autoload -U bashcompinit
# bashcompinit
Expand Down Expand Up @@ -148,5 +150,5 @@ def setup_completions(*args, **kwargs) -> None:
print("source artistoolscompletions.sh")


def addargs(parser=None) -> None:
def addargs(parser: argparse.ArgumentParser) -> None:
pass
22 changes: 11 additions & 11 deletions artistools/estimators/estimators_classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ def get_atomic_composition(modelpath):
"""Read ion list from output file."""
atomic_composition = {}

output = open(modelpath / "output_0-0.txt").read().splitlines()
ioncount = 0
for row in output:
if row.split()[0] == "[input.c]":
split_row = row.split()
if split_row[1] == "element":
Z = int(split_row[4])
ioncount = 0
elif split_row[1] == "ion":
ioncount += 1
atomic_composition[Z] = ioncount
with open(modelpath / "output_0-0.txt") as foutput:
ioncount = 0
for row in foutput:
if row.split()[0] == "[input.c]":
split_row = row.split()
if split_row[1] == "element":
Z = int(split_row[4])
ioncount = 0
elif split_row[1] == "ion":
ioncount += 1
atomic_composition[Z] = ioncount
return atomic_composition


Expand Down
2 changes: 1 addition & 1 deletion artistools/hesma_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def plot_hesma_spectrum(timeavg, axes):
# print(hesma_spec)

def match_closest_time(reftime):
return str("{}".format(min([float(x) for x in hesma_spec.keys()[1:]], key=lambda x: abs(x - reftime))))
return str(f"{min([float(x) for x in hesma_spec.keys()[1:]], key=lambda x: abs(x - reftime))}")

closest_time = match_closest_time(timeavg)
closest_time = f"{closest_time:.2f}"
Expand Down
9 changes: 5 additions & 4 deletions artistools/inputmodel/1dslicefrom3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import math
import os
import sys
from pathlib import Path

import matplotlib.pyplot as plt

Expand Down Expand Up @@ -33,12 +34,12 @@ def main(args=None, argsraw=None, **kwargs):
parser.set_defaults(**kwargs)
args = parser.parse_args()

if not os.path.exists(args.outputfolder):
os.makedirs(args.outputfolder)
elif os.path.exists(os.path.join(args.outputfolder, "model.txt")):
if not Path(args.outputfolder).exists():
Path(args.outputfolder).mkdir(parents=True)
elif Path(args.outputfolder, "model.txt").exists():
print("ABORT: model.txt already exists")
sys.exit()
elif os.path.exists(os.path.join(args.outputfolder, "abundances.txt")):
elif Path(args.outputfolder, "abundances.txt").exists():
print("ABORT: abundances.txt already exists")
sys.exit()

Expand Down
1 change: 1 addition & 0 deletions artistools/inputmodel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import artistools.inputmodel.modelfromhydro
import artistools.inputmodel.opacityinputfile
import artistools.inputmodel.rprocess_from_trajectory

from .inputmodel_misc import add_derived_cols_to_modeldata
from .inputmodel_misc import get_2d_modeldata
from .inputmodel_misc import get_3d_model_data_merged_model_and_abundances_minimal
Expand Down
Loading

0 comments on commit 4e54608

Please sign in to comment.