Skip to content

Commit

Permalink
ruff-format with settings that match HOOMD-blue.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaander committed Nov 27, 2024
1 parent 43d8f7d commit df4bc80
Show file tree
Hide file tree
Showing 49 changed files with 508 additions and 509 deletions.
7 changes: 4 additions & 3 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
target-version = "py38"

extend-include = ["*.ipynb"]
line-length = 88
indent-width = 4

[lint]

Expand Down Expand Up @@ -50,7 +50,8 @@ ignore = [
convention = "google"

[format]
quote-style = "single"
indent-style = "space"
line-ending = "auto"

[lint.flake8-import-conventions]
# Prefer no import aliases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"metadata": {},
"outputs": [],
"source": [
"mc.shape['octahedron'] = dict(\n",
"mc.shape[\"octahedron\"] = dict(\n",
" vertices=[\n",
" (-0.5, 0, 0),\n",
" (0.5, 0, 0),\n",
Expand Down Expand Up @@ -113,8 +113,8 @@
"outputs": [],
"source": [
"mc.nselect = 2\n",
"mc.d['octahedron'] = 0.15\n",
"mc.a['octahedron'] = 0.2"
"mc.d[\"octahedron\"] = 0.15\n",
"mc.a[\"octahedron\"] = 0.2"
]
},
{
Expand Down
16 changes: 8 additions & 8 deletions 00-Introducing-HOOMD-blue/03-Initializing-the-System-State.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"source": [
"import os\n",
"\n",
"fn = os.path.join(os.getcwd(), 'lattice.gsd')\n",
"fn = os.path.join(os.getcwd(), \"lattice.gsd\")\n",
"![ -e \"$fn\" ] && rm \"$fn\""
]
},
Expand Down Expand Up @@ -85,18 +85,18 @@
"device = fresnel.Device()\n",
"tracer = fresnel.tracer.Path(device=device, w=300, h=300)\n",
"\n",
"FRESNEL_MIN_VERSION = packaging.version.parse('0.13.0')\n",
"FRESNEL_MAX_VERSION = packaging.version.parse('0.14.0')\n",
"FRESNEL_MIN_VERSION = packaging.version.parse(\"0.13.0\")\n",
"FRESNEL_MAX_VERSION = packaging.version.parse(\"0.14.0\")\n",
"\n",
"\n",
"def render(position, orientation, L):\n",
" if (\n",
" 'version' not in dir(fresnel)\n",
" \"version\" not in dir(fresnel)\n",
" or packaging.version.parse(fresnel.version.version) < FRESNEL_MIN_VERSION\n",
" or packaging.version.parse(fresnel.version.version) >= FRESNEL_MAX_VERSION\n",
" ):\n",
" warnings.warn(\n",
" f'Unsupported fresnel version {fresnel.version.version} - expect errors.'\n",
" f\"Unsupported fresnel version {fresnel.version.version} - expect errors.\"\n",
" )\n",
" vertices = [\n",
" (-0.5, 0, 0),\n",
Expand Down Expand Up @@ -361,7 +361,7 @@
"metadata": {},
"outputs": [],
"source": [
"frame.particles.types = ['octahedron']"
"frame.particles.types = [\"octahedron\"]"
]
},
{
Expand Down Expand Up @@ -393,7 +393,7 @@
"metadata": {},
"outputs": [],
"source": [
"with gsd.hoomd.open(name='lattice.gsd', mode='x') as f:\n",
"with gsd.hoomd.open(name=\"lattice.gsd\", mode=\"x\") as f:\n",
" f.append(frame)"
]
},
Expand Down Expand Up @@ -430,7 +430,7 @@
"metadata": {},
"outputs": [],
"source": [
"simulation.create_state_from_gsd(filename='lattice.gsd')"
"simulation.create_state_from_gsd(filename=\"lattice.gsd\")"
]
},
{
Expand Down
16 changes: 8 additions & 8 deletions 00-Introducing-HOOMD-blue/04-Randomizing-the-System.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"source": [
"import os\n",
"\n",
"fn = os.path.join(os.getcwd(), 'random.gsd')\n",
"fn = os.path.join(os.getcwd(), \"random.gsd\")\n",
"![ -e \"$fn\" ] && rm \"$fn\""
]
},
Expand Down Expand Up @@ -82,18 +82,18 @@
"device = fresnel.Device()\n",
"tracer = fresnel.tracer.Path(device=device, w=300, h=300)\n",
"\n",
"FRESNEL_MIN_VERSION = packaging.version.parse('0.13.0')\n",
"FRESNEL_MAX_VERSION = packaging.version.parse('0.14.0')\n",
"FRESNEL_MIN_VERSION = packaging.version.parse(\"0.13.0\")\n",
"FRESNEL_MAX_VERSION = packaging.version.parse(\"0.14.0\")\n",
"\n",
"\n",
"def render(snapshot):\n",
" if (\n",
" 'version' not in dir(fresnel)\n",
" \"version\" not in dir(fresnel)\n",
" or packaging.version.parse(fresnel.version.version) < FRESNEL_MIN_VERSION\n",
" or packaging.version.parse(fresnel.version.version) >= FRESNEL_MAX_VERSION\n",
" ):\n",
" warnings.warn(\n",
" f'Unsupported fresnel version {fresnel.version.version} - expect errors.'\n",
" f\"Unsupported fresnel version {fresnel.version.version} - expect errors.\"\n",
" )\n",
" L = snapshot.configuration.box[0]\n",
" vertices = [\n",
Expand Down Expand Up @@ -166,7 +166,7 @@
"simulation = hoomd.Simulation(device=cpu, seed=12)\n",
"\n",
"mc = hoomd.hpmc.integrate.ConvexPolyhedron()\n",
"mc.shape['octahedron'] = dict(\n",
"mc.shape[\"octahedron\"] = dict(\n",
" vertices=[\n",
" (-0.5, 0, 0),\n",
" (0.5, 0, 0),\n",
Expand All @@ -178,7 +178,7 @@
")\n",
"\n",
"simulation.operations.integrator = mc\n",
"simulation.create_state_from_gsd(filename='lattice.gsd')"
"simulation.create_state_from_gsd(filename=\"lattice.gsd\")"
]
},
{
Expand Down Expand Up @@ -480,7 +480,7 @@
"metadata": {},
"outputs": [],
"source": [
"hoomd.write.GSD.write(state=simulation.state, mode='xb', filename='random.gsd')"
"hoomd.write.GSD.write(state=simulation.state, mode=\"xb\", filename=\"random.gsd\")"
]
},
{
Expand Down
24 changes: 12 additions & 12 deletions 00-Introducing-HOOMD-blue/05-Compressing-the-System.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"source": [
"import os\n",
"\n",
"fn = os.path.join(os.getcwd(), 'compressed.gsd')\n",
"fn = os.path.join(os.getcwd(), \"compressed.gsd\")\n",
"![ -e \"$fn\" ] && rm \"$fn\""
]
},
Expand Down Expand Up @@ -82,18 +82,18 @@
"device = fresnel.Device()\n",
"tracer = fresnel.tracer.Path(device=device, w=300, h=300)\n",
"\n",
"FRESNEL_MIN_VERSION = packaging.version.parse('0.13.0')\n",
"FRESNEL_MAX_VERSION = packaging.version.parse('0.14.0')\n",
"FRESNEL_MIN_VERSION = packaging.version.parse(\"0.13.0\")\n",
"FRESNEL_MAX_VERSION = packaging.version.parse(\"0.14.0\")\n",
"\n",
"\n",
"def render(snapshot):\n",
" if (\n",
" 'version' not in dir(fresnel)\n",
" \"version\" not in dir(fresnel)\n",
" or packaging.version.parse(fresnel.version.version) < FRESNEL_MIN_VERSION\n",
" or packaging.version.parse(fresnel.version.version) >= FRESNEL_MAX_VERSION\n",
" ):\n",
" warnings.warn(\n",
" f'Unsupported fresnel version {fresnel.version.version} - expect errors.'\n",
" f\"Unsupported fresnel version {fresnel.version.version} - expect errors.\"\n",
" )\n",
" L = snapshot.configuration.box[0]\n",
" vertices = [\n",
Expand Down Expand Up @@ -153,7 +153,7 @@
"source": [
"cpu = hoomd.device.CPU()\n",
"simulation = hoomd.Simulation(device=cpu, seed=12)\n",
"simulation.create_state_from_gsd(filename='random.gsd')"
"simulation.create_state_from_gsd(filename=\"random.gsd\")"
]
},
{
Expand Down Expand Up @@ -222,7 +222,7 @@
"outputs": [],
"source": [
"mc = hoomd.hpmc.integrate.ConvexPolyhedron()\n",
"mc.shape['octahedron'] = dict(\n",
"mc.shape[\"octahedron\"] = dict(\n",
" vertices=[\n",
" (-0.5, 0, 0),\n",
" (0.5, 0, 0),\n",
Expand Down Expand Up @@ -311,7 +311,7 @@
"source": [
"periodic = hoomd.trigger.Periodic(10)\n",
"tune = hoomd.hpmc.tune.MoveSize.scale_solver(\n",
" moves=['a', 'd'],\n",
" moves=[\"a\", \"d\"],\n",
" target=0.2,\n",
" trigger=periodic,\n",
" max_translation_move=0.2,\n",
Expand Down Expand Up @@ -383,7 +383,7 @@
"outputs": [],
"source": [
"if not compress.complete:\n",
" message = 'Compression failed to complete'\n",
" message = \"Compression failed to complete\"\n",
" raise RuntimeError(message)"
]
},
Expand Down Expand Up @@ -411,7 +411,7 @@
}
],
"source": [
"mc.a['octahedron']"
"mc.a[\"octahedron\"]"
]
},
{
Expand All @@ -431,7 +431,7 @@
}
],
"source": [
"mc.d['octahedron']"
"mc.d[\"octahedron\"]"
]
},
{
Expand Down Expand Up @@ -475,7 +475,7 @@
"metadata": {},
"outputs": [],
"source": [
"hoomd.write.GSD.write(state=simulation.state, mode='xb', filename='compressed.gsd')"
"hoomd.write.GSD.write(state=simulation.state, mode=\"xb\", filename=\"compressed.gsd\")"
]
}
],
Expand Down
18 changes: 9 additions & 9 deletions 00-Introducing-HOOMD-blue/06-Equilibrating-the-System.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"source": [
"import os\n",
"\n",
"fn = os.path.join(os.getcwd(), 'trajectory.gsd')\n",
"fn = os.path.join(os.getcwd(), \"trajectory.gsd\")\n",
"![ -e \"$fn\" ] && rm \"$fn\""
]
},
Expand Down Expand Up @@ -84,18 +84,18 @@
"device = fresnel.Device()\n",
"tracer = fresnel.tracer.Path(device=device, w=300, h=300)\n",
"\n",
"FRESNEL_MIN_VERSION = packaging.version.parse('0.13.0')\n",
"FRESNEL_MAX_VERSION = packaging.version.parse('0.14.0')\n",
"FRESNEL_MIN_VERSION = packaging.version.parse(\"0.13.0\")\n",
"FRESNEL_MAX_VERSION = packaging.version.parse(\"0.14.0\")\n",
"\n",
"\n",
"def render(snapshot):\n",
" if (\n",
" 'version' not in dir(fresnel)\n",
" \"version\" not in dir(fresnel)\n",
" or packaging.version.parse(fresnel.version.version) < FRESNEL_MIN_VERSION\n",
" or packaging.version.parse(fresnel.version.version) >= FRESNEL_MAX_VERSION\n",
" ):\n",
" warnings.warn(\n",
" f'Unsupported fresnel version {fresnel.version.version} - expect errors.'\n",
" f\"Unsupported fresnel version {fresnel.version.version} - expect errors.\"\n",
" )\n",
"\n",
" L = snapshot.configuration.box[0]\n",
Expand Down Expand Up @@ -158,7 +158,7 @@
"cpu = hoomd.device.CPU()\n",
"simulation = hoomd.Simulation(device=cpu, seed=12)\n",
"mc = hoomd.hpmc.integrate.ConvexPolyhedron()\n",
"mc.shape['octahedron'] = dict(\n",
"mc.shape[\"octahedron\"] = dict(\n",
" vertices=[\n",
" (-0.5, 0, 0),\n",
" (0.5, 0, 0),\n",
Expand All @@ -185,7 +185,7 @@
"metadata": {},
"outputs": [],
"source": [
"simulation.create_state_from_gsd(filename='compressed.gsd')"
"simulation.create_state_from_gsd(filename=\"compressed.gsd\")"
]
},
{
Expand All @@ -209,7 +209,7 @@
"outputs": [],
"source": [
"gsd_writer = hoomd.write.GSD(\n",
" filename='trajectory.gsd', trigger=hoomd.trigger.Periodic(1000), mode='xb'\n",
" filename=\"trajectory.gsd\", trigger=hoomd.trigger.Periodic(1000), mode=\"xb\"\n",
")\n",
"simulation.operations.writers.append(gsd_writer)"
]
Expand All @@ -236,7 +236,7 @@
"outputs": [],
"source": [
"tune = hoomd.hpmc.tune.MoveSize.scale_solver(\n",
" moves=['a', 'd'],\n",
" moves=[\"a\", \"d\"],\n",
" target=0.2,\n",
" trigger=hoomd.trigger.And(\n",
" [hoomd.trigger.Periodic(100), hoomd.trigger.Before(simulation.timestep + 5000)]\n",
Expand Down
Loading

0 comments on commit df4bc80

Please sign in to comment.