Skip to content

Commit

Permalink
chore(format): apply isort rule, split long comment lines (#47)
Browse files Browse the repository at this point in the history
* extend default rules in pyproject.toml
* apply import sorting
* split comment lines where needed to fully observe E501
  • Loading branch information
wpbonelli authored Apr 4, 2024
1 parent c6811fd commit 0c632e5
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 35 deletions.
1 change: 0 additions & 1 deletion autotest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import pytest
from filelock import FileLock

from modflow_devtools.download import download_and_unzip

# import modflow-devtools fixtures
Expand Down
11 changes: 7 additions & 4 deletions autotest/test_mf6_examples.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from pathlib import Path
from shutil import copytree
from modflowapi import run_simulation

import pytest

from autotest.conftest import is_nested
from modflowapi import run_simulation

pytestmark = pytest.mark.mf6
dll = "libmf6"
Expand Down Expand Up @@ -35,13 +36,15 @@ def callback(sim, step):
pass

def run_models():
# run models in order received (should be alphabetical, so gwf precedes gwt)
# run models in order received (should be alphabetical,
# so gwf precedes gwt)
for namfile in mf6_example_namfiles:
namfile_path = Path(namfile).resolve()
model_path = namfile_path.parent

# working directory must be named according to the name file's parent (e.g.
# 'mf6gwf') because coupled models refer to each other with relative paths
# working directory must be named according to namefile's parent
# (e.g. 'mf6gwf') because coupled models refer to each other with
# relative paths
wrkdir = (
Path(function_tmpdir / model_path.name)
if nested
Expand Down
19 changes: 11 additions & 8 deletions examples/notebooks/Head_Monitor_Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from flopy.discretization import StructuredGrid\n",
"from flopy.plot import PlotMapView\n",
"from IPython.display import (\n",
" clear_output,\n",
" display,\n",
") # remove this import if adapted to python script\n",
")\n",
"\n",
"from modflowapi import run_simulation, Callbacks\n",
"from flopy.discretization import StructuredGrid\n",
"from flopy.plot import PlotMapView\n",
"from pathlib import Path\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
"# remove this import if adapted to python script\n",
"from modflowapi import Callbacks, run_simulation"
]
},
{
Expand Down Expand Up @@ -126,7 +128,8 @@
" idm = self.pmv.plot_inactive()\n",
" self.pc = self.pmv.plot_array(heads, vmin=self.vmin, vmax=self.vmax)\n",
"\n",
" # only applicable to jupyter notebooks, remove these two lines in python scipt\n",
" # only applicable to jupyter notebooks, remove these\n",
" # two lines in python scipt\n",
" display(self.fig)\n",
" if ml.kper == (ml.nper - 1) and ml.kstp == (ml.nstp - 1):\n",
" pass\n",
Expand Down
7 changes: 4 additions & 3 deletions examples/notebooks/MODFLOW-API_extensions_objects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
"metadata": {},
"outputs": [],
"source": [
"import modflowapi\n",
"from modflowapi.extensions import ApiSimulation\n",
"import platform\n",
"from pathlib import Path\n",
"import platform"
"\n",
"import modflowapi\n",
"from modflowapi.extensions import ApiSimulation"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions examples/notebooks/Quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"\n",
"import modflowapi\n",
"from modflowapi import Callbacks\n",
"from pathlib import Path"
"from modflowapi import Callbacks"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion modflowapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ruff: noqa: F401, allow imports directly from modflowapi
from .version import __version__
from modflowapi.modflowapi import ModflowApi

from . import extensions
from .extensions.runner import Callbacks, run_simulation
from .version import __version__
4 changes: 2 additions & 2 deletions modflowapi/extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ruff: noqa: F401, allow imports directly from modflowapi.extensions
from .apisimulation import ApiSimulation
from .apimodel import ApiModel
from .apiexchange import ApiExchange
from .apimodel import ApiModel
from .apisimulation import ApiSimulation
2 changes: 1 addition & 1 deletion modflowapi/extensions/apiexchange.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .pakbase import ListPackage
from .apimodel import ApiMbase
from .pakbase import ListPackage


class ApiExchange(ApiMbase):
Expand Down
4 changes: 2 additions & 2 deletions modflowapi/extensions/apimodel.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import numpy as np

from .pakbase import (
AdvancedPackage,
ArrayPackage,
ListPackage,
package_factory,
)
import numpy as np


gridshape = {
"dis": ["nlay", "nrow", "ncol"],
Expand Down
5 changes: 3 additions & 2 deletions modflowapi/extensions/apisimulation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from .apimodel import ApiMbase, ApiModel
import numpy as np

from .apiexchange import ApiExchange
from .apimodel import ApiMbase, ApiModel
from .pakbase import ApiSlnPackage, ListPackage, ScalarPackage, package_factory
import numpy as np


class ApiSimulation:
Expand Down
3 changes: 2 additions & 1 deletion modflowapi/extensions/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ def dataframe(self, dataframe):

class ArrayPointer:
"""
Data object for storing single pointers and working with array based input data
Data object for storing single pointers and
working with array based input data
Parameters
----------
Expand Down
3 changes: 2 additions & 1 deletion modflowapi/extensions/runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from enum import Enum

from .. import ModflowApi
from .apisimulation import ApiSimulation
from enum import Enum


class Callbacks(Enum):
Expand Down
1 change: 1 addition & 0 deletions modflowapi/modflowapi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from xmipy import XmiWrapper

from .util import amend_libmf6_path


Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ extend-include = [
]

[tool.ruff.lint]
select = ["F", "E", "I001"]
ignore = [
"F841" # local variable assigned but never used
]
14 changes: 7 additions & 7 deletions scripts/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from datetime import datetime
from os.path import basename
from pathlib import Path
from packaging.version import Version

from filelock import FileLock
from packaging.version import Version

_project_name = "modflowapi"
_project_root_path = Path(__file__).parent.parent
Expand Down Expand Up @@ -81,11 +81,11 @@ def update_version(
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=textwrap.dedent(
"""\
Update version information stored in version.txt in the project root,
as well as several other files in the repository. If --version is not
provided, the version number will not be changed. A file lock is held
to synchronize file access. The version tag must comply with standard
'<major>.<minor>.<patch>' format conventions for semantic versioning.
Update version information in version.txt in the project root,
as well as several other files in the repository. If --version
is not provided, the version number will not be changed. A file
lock is held to synchronize file access. The version tag must be
standard '<major>.<minor>.<patch>' format for semantic versioning.
"""
),
)
Expand All @@ -100,7 +100,7 @@ def update_version(
"--get",
required=False,
action="store_true",
help="Just get the current version number, don't update anything (defaults to false)",
help="Get the current version number, no updates (defaults false)",
)
args = parser.parse_args()

Expand Down

0 comments on commit 0c632e5

Please sign in to comment.