Skip to content

Commit

Permalink
Fmt: use vertical imports
Browse files Browse the repository at this point in the history
These have less noisy line edits.
  • Loading branch information
aschampion committed Dec 11, 2020
1 parent caefb1e commit 6243a5e
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 45 deletions.
1 change: 1 addition & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
imports_layout = "Vertical"
15 changes: 12 additions & 3 deletions benches/parallel_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@ extern crate test;
use std::fs::File;
use std::io::BufReader;

use futures::{self, Future};
use futures_cpupool::{CpuFuture, CpuPool};
use futures::{
self,
Future,
};
use futures_cpupool::{
CpuFuture,
CpuPool,
};
use lazy_static::lazy_static;
use tempdir;
use test::Bencher;
use tiff::decoder::{Decoder, DecodingResult};
use tiff::decoder::{
Decoder,
DecodingResult,
};

use n5::prelude::*;
use n5::smallvec::smallvec;
Expand Down
11 changes: 9 additions & 2 deletions benches/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@

extern crate test;

use rand::{distributions::Standard, Rng};
use rand::{
distributions::Standard,
Rng,
};
use test::Bencher;

use n5::prelude::*;
use n5::smallvec::smallvec;
use n5::{DefaultBlock, DefaultBlockReader, DefaultBlockWriter};
use n5::{
DefaultBlock,
DefaultBlockReader,
DefaultBlockWriter,
};

fn test_block_compression_rw<T>(compression: compression::CompressionType, b: &mut Bencher)
where
Expand Down
10 changes: 8 additions & 2 deletions src/compression/bzip.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
use std::io::{Read, Write};
use std::io::{
Read,
Write,
};

use bzip2::read::BzDecoder;
use bzip2::write::BzEncoder;
use bzip2::Compression as BzCompression;
use serde::{Deserialize, Serialize};
use serde::{
Deserialize,
Serialize,
};

use super::Compression;

Expand Down
10 changes: 8 additions & 2 deletions src/compression/gzip.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
use std::io::{Read, Write};
use std::io::{
Read,
Write,
};

use flate2::read::GzDecoder;
use flate2::write::GzEncoder;
use flate2::Compression as GzCompression;
use serde::{Deserialize, Serialize};
use serde::{
Deserialize,
Serialize,
};

use super::Compression;

Expand Down
21 changes: 17 additions & 4 deletions src/compression/lz.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
use std::io::{Read, Result, Write};

use lz4::{BlockMode, BlockSize, Decoder, Encoder, EncoderBuilder};
use serde::{Deserialize, Serialize};
use std::io::{
Read,
Result,
Write,
};

use lz4::{
BlockMode,
BlockSize,
Decoder,
Encoder,
EncoderBuilder,
};
use serde::{
Deserialize,
Serialize,
};

use super::Compression;

Expand Down
16 changes: 13 additions & 3 deletions src/compression/lz_pure.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
use std::io::{Read, Result, Write};
use std::io::{
Read,
Result,
Write,
};

use lz_fear::framed::{CompressionSettings, LZ4FrameReader};
use serde::{Deserialize, Serialize};
use lz_fear::framed::{
CompressionSettings,
LZ4FrameReader,
};
use serde::{
Deserialize,
Serialize,
};

use super::Compression;

Expand Down
12 changes: 9 additions & 3 deletions src/compression/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
//! Compression for block voxel data.
use std::io::{Read, Write};

use serde::{Deserialize, Serialize};
use std::io::{
Read,
Write,
};

use serde::{
Deserialize,
Serialize,
};

#[cfg(feature = "bzip")]
pub mod bzip;
Expand Down
10 changes: 8 additions & 2 deletions src/compression/raw.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
use std::io::{Read, Write};
use std::io::{
Read,
Write,
};

use serde::{Deserialize, Serialize};
use serde::{
Deserialize,
Serialize,
};

use super::Compression;

Expand Down
10 changes: 8 additions & 2 deletions src/compression/xz.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
use std::io::{Read, Write};
use std::io::{
Read,
Write,
};

use serde::{Deserialize, Serialize};
use serde::{
Deserialize,
Serialize,
};
use xz2::read::XzDecoder;
use xz2::write::XzEncoder;

Expand Down
5 changes: 4 additions & 1 deletion src/data_type.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use serde::{Deserialize, Serialize};
use serde::{
Deserialize,
Serialize,
};

use crate::BlockHeader;
use crate::VecDataBlock;
Expand Down
51 changes: 43 additions & 8 deletions src/filesystem.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
//! A filesystem-backed N5 container.
use std::fs::{self, File};
use std::io::{BufReader, BufWriter, Error, ErrorKind, Read, Result, Seek, SeekFrom};
use std::fs::{
self,
File,
};
use std::io::{
BufReader,
BufWriter,
Error,
ErrorKind,
Read,
Result,
Seek,
SeekFrom,
};
use std::path::PathBuf;
use std::str::FromStr;

use fs2::FileExt;
use serde_json::{self, json, Value};
use serde_json::{
self,
json,
Value,
};
use walkdir::WalkDir;

use crate::{
is_version_compatible, DataBlock, DataBlockMetadata, DatasetAttributes, DefaultBlockReader,
DefaultBlockWriter, GridCoord, N5Lister, N5Reader, N5Writer, ReadableDataBlock, ReflectedType,
ReinitDataBlock, VecDataBlock, Version, WriteableDataBlock,
is_version_compatible,
DataBlock,
DataBlockMetadata,
DatasetAttributes,
DefaultBlockReader,
DefaultBlockWriter,
GridCoord,
N5Lister,
N5Reader,
N5Writer,
ReadableDataBlock,
ReflectedType,
ReinitDataBlock,
VecDataBlock,
Version,
WriteableDataBlock,
};

/// Name of the attributes file stored in the container root and dataset dirs.
Expand Down Expand Up @@ -92,7 +121,10 @@ impl N5Filesystem {
// Note: cannot use `canonicalize` on both the constructed dataset path
// and `base_path` and check `starts_with`, because `canonicalize` also
// requires the path exist.
use std::path::{Component, Path};
use std::path::{
Component,
Path,
};

// Normalize the path to be relative.
let mut components = Path::new(path_name).components();
Expand Down Expand Up @@ -394,7 +426,10 @@ impl N5Writer for N5Filesystem {
mod tests {
use super::*;
use crate::test_backend;
use crate::tests::{ContextWrapper, N5Testable};
use crate::tests::{
ContextWrapper,
N5Testable,
};
use tempdir::TempDir;

impl crate::tests::N5Testable for N5Filesystem {
Expand Down
17 changes: 14 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,23 @@ doc_comment::doctest!("../README.md");
#[macro_use]
pub extern crate smallvec;

use std::io::{Error, ErrorKind};
use std::io::{
Error,
ErrorKind,
};
use std::marker::PhantomData;
use std::time::SystemTime;

use byteorder::{BigEndian, ByteOrder, ReadBytesExt, WriteBytesExt};
use serde::{Deserialize, Serialize};
use byteorder::{
BigEndian,
ByteOrder,
ReadBytesExt,
WriteBytesExt,
};
use serde::{
Deserialize,
Serialize,
};
use smallvec::SmallVec;

use crate::compression::Compression;
Expand Down
33 changes: 28 additions & 5 deletions src/ndarray.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
use std::cmp;
use std::io::{Error, ErrorKind};
use std::io::{
Error,
ErrorKind,
};
use std::ops::Sub;

use itertools::Itertools;
use ndarray::{Array, ArrayView, IxDyn, ShapeBuilder, SliceInfo};
use ndarray::{
Array,
ArrayView,
IxDyn,
ShapeBuilder,
SliceInfo,
};

use crate::{
BlockCoord, CoordVec, DataBlock, DatasetAttributes, GridCoord, N5Reader, N5Writer,
ReadableDataBlock, ReflectedType, ReinitDataBlock, SliceDataBlock, VecDataBlock,
BlockCoord,
CoordVec,
DataBlock,
DatasetAttributes,
GridCoord,
N5Reader,
N5Writer,
ReadableDataBlock,
ReflectedType,
ReinitDataBlock,
SliceDataBlock,
VecDataBlock,
WriteableDataBlock,
};

pub mod prelude {
pub use super::{BoundingBox, N5NdarrayReader, N5NdarrayWriter};
pub use super::{
BoundingBox,
N5NdarrayReader,
N5NdarrayWriter,
};
}

/// Specifes the extents of an axis-aligned bounding box.
Expand Down
19 changes: 16 additions & 3 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,25 @@
//! ```
#[doc(no_inline)]
pub use crate::compression::{self, CompressionType};
pub use crate::compression::{
self,
CompressionType,
};
#[cfg(feature = "filesystem")]
#[doc(no_inline)]
pub use crate::filesystem::N5Filesystem;
#[doc(no_inline)]
pub use crate::{
BlockCoord, DataBlock, DataBlockMetadata, DataType, DatasetAttributes, GridCoord, N5Lister,
N5Reader, N5Writer, ReflectedType, SliceDataBlock, VecDataBlock,
BlockCoord,
DataBlock,
DataBlockMetadata,
DataType,
DatasetAttributes,
GridCoord,
N5Lister,
N5Reader,
N5Writer,
ReflectedType,
SliceDataBlock,
VecDataBlock,
};
5 changes: 4 additions & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use super::*;
use std::io::{Cursor, Result};
use std::io::{
Cursor,
Result,
};

use serde_json::json;

Expand Down
5 changes: 4 additions & 1 deletion tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use rand::{distributions::Standard, Rng};
use rand::{
distributions::Standard,
Rng,
};
use smallvec::smallvec;

use n5::prelude::*;
Expand Down

0 comments on commit 6243a5e

Please sign in to comment.