Skip to content

Commit

Permalink
Ruff Updates (#728)
Browse files Browse the repository at this point in the history
* update ruff

* update ruff

* add notebooks to pre-commit

* run pre-commit on notebooks

* pre-commit on notebooks, fix unusued imports

* update pre-commit

---------

Co-authored-by: Orhan Eroglu <32553057+erogluorhan@users.noreply.github.com>
  • Loading branch information
philipc2 and erogluorhan authored May 8, 2024
1 parent 41763ad commit 3107ae6
Show file tree
Hide file tree
Showing 12 changed files with 526 additions and 273 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ repos:
# Run the linter.
- id: ruff
args: [ --fix ]
types_or: [ python, pyi, jupyter ]

# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
5 changes: 1 addition & 4 deletions docs/examples/000-template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import uxarray as ux"
]
"source": []
},
{
"cell_type": "code",
Expand Down
106 changes: 51 additions & 55 deletions docs/examples/001-working-with-unstructured-grids.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"grid_path = base_path + \"grid.nc\"\n",
"\n",
"# Paths to Data Variable files\n",
"var_names = ['v1.nc', 'v2.nc', 'v3.nc']\n",
"var_names = [\"v1.nc\", \"v2.nc\", \"v3.nc\"]\n",
"\n",
"data_paths = [base_path + name for name in var_names]"
]
Expand Down Expand Up @@ -130,12 +130,12 @@
},
{
"cell_type": "markdown",
"source": [
"## Grid Topology"
],
"metadata": {
"collapsed": false
}
},
"source": [
"## Grid Topology"
]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -221,126 +221,122 @@
},
{
"cell_type": "markdown",
"source": [
"## Data Variables"
],
"metadata": {
"collapsed": false
}
},
"source": [
"## Data Variables"
]
},
{
"cell_type": "markdown",
"source": [
"While grid-specific variables and functions are stored under the `uxgrid` property, data variables that lie on the grid are stored directly in the `UxDataset` or `UxDataArray`. Most `Xarray` functions and operators can be executed on these data structures.\n"
],
"metadata": {
"collapsed": false
}
},
"source": [
"While grid-specific variables and functions are stored under the `uxgrid` property, data variables that lie on the grid are stored directly in the `UxDataset` or `UxDataArray`. Most `Xarray` functions and operators can be executed on these data structures.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"uxds_single.values"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"uxds_single.dims"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"uxds_single.coords"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"uxds_single.attrs"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"uxds_single.min()"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"uxds_single > 0"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"grid = uxds_single.uxgrid\n",
"foo = ux.UxDataArray(\n",
" data = np.random.random(grid.n_face),\n",
" dims = [\"n_face\"],\n",
" uxgrid = grid\n",
")\n",
"foo = ux.UxDataArray(data=np.random.random(grid.n_face), dims=[\"n_face\"], uxgrid=grid)\n",
"foo"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"uxds_new_var = uxds_single.assign({\"foo\" : foo})"
],
"metadata": {
"collapsed": false
}
},
"outputs": [],
"source": [
"uxds_new_var = uxds_single.assign({\"foo\": foo})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"uxds_new_var"
],
"metadata": {
"collapsed": false
}
]
}
],
"metadata": {
Expand Down
33 changes: 16 additions & 17 deletions docs/examples/002-grid-topology.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"metadata": {},
"outputs": [],
"source": [
"import uxarray\n",
"import uxarray as ux"
]
},
Expand Down Expand Up @@ -265,43 +264,43 @@
},
{
"cell_type": "markdown",
"source": [
"As described in the UGRID conventions, these connectivity variables are stored as integer arrays and may contain a Fill Value. UXarray standardizes both of these at the data loading step, meaning that the data type and fill value can always be guaranteed to be the following:"
],
"metadata": {
"collapsed": false
}
},
"source": [
"As described in the UGRID conventions, these connectivity variables are stored as integer arrays and may contain a Fill Value. UXarray standardizes both of these at the data loading step, meaning that the data type and fill value can always be guaranteed to be the following:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ux.INT_DTYPE"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ux.INT_FILL_VALUE"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"source": [
"Below we can see how to access these connectivity variables."
],
"metadata": {
"collapsed": false
}
},
"source": [
"Below we can see how to access these connectivity variables."
]
},
{
"cell_type": "code",
Expand Down
Loading

0 comments on commit 3107ae6

Please sign in to comment.