Skip to content

Commit 0061bae

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d497560 commit 0061bae

File tree

6 files changed

+110
-101
lines changed

6 files changed

+110
-101
lines changed

include/openPMD/IO/ADIOS/CommonADIOS1IOHandler.hpp

+16-11
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,30 @@ class CommonADIOS1IOHandlerImpl : public AbstractIOHandlerImpl
9696
{}
9797

9898
ADIOS_READ_METHOD m_readMethod;
99-
std::unordered_map< Writable*, std::shared_ptr< std::string > > m_filePaths;
100-
std::unordered_map< std::shared_ptr< std::string >, int64_t > m_groups;
101-
std::unordered_map< std::shared_ptr< std::string >, bool > m_existsOnDisk;
102-
std::unordered_map< std::shared_ptr< std::string >, int64_t > m_openWriteFileHandles;
103-
std::unordered_map< std::shared_ptr< std::string >, ADIOS_FILE* > m_openReadFileHandles;
99+
std::unordered_map<Writable *, std::shared_ptr<std::string> > m_filePaths;
100+
std::unordered_map<std::shared_ptr<std::string>, int64_t> m_groups;
101+
std::unordered_map<std::shared_ptr<std::string>, bool> m_existsOnDisk;
102+
std::unordered_map<std::shared_ptr<std::string>, int64_t>
103+
m_openWriteFileHandles;
104+
std::unordered_map<std::shared_ptr<std::string>, ADIOS_FILE *>
105+
m_openReadFileHandles;
104106
struct ScheduledRead
105107
{
106-
ADIOS_SELECTION* selection;
107-
std::shared_ptr< void > data; // needed to avoid early freeing
108+
ADIOS_SELECTION *selection;
109+
std::shared_ptr<void> data; // needed to avoid early freeing
108110
};
109-
std::unordered_map< ADIOS_FILE*, std::vector< ScheduledRead > > m_scheduledReads;
110-
std::unordered_map< int64_t, std::unordered_map< std::string, Attribute > > m_attributeWrites;
111+
std::unordered_map<ADIOS_FILE *, std::vector<ScheduledRead> >
112+
m_scheduledReads;
113+
std::unordered_map<int64_t, std::unordered_map<std::string, Attribute> >
114+
m_attributeWrites;
111115
// config options
112116
std::string m_defaultTransform;
113117
/**
114-
* Call this function to get adios file id for a Writable. Will create one if does not exist
118+
* Call this function to get adios file id for a Writable. Will create one
119+
* if does not exist
115120
* @return returns an adios file id.
116121
*/
117-
int64_t GetFileHandle(Writable*);
122+
int64_t GetFileHandle(Writable *);
118123

119124
void initJson(json::TracingJSON);
120125
}; // ParallelADIOS1IOHandlerImpl

include/openPMD/backend/Attribute.hpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -229,27 +229,27 @@ template <typename U> U Attribute::get() const
229229

230230
namespace std
231231
{
232-
inline string to_string( openPMD::Attribute const & attr )
232+
inline string to_string(openPMD::Attribute const &attr)
233233
{
234234
return std::visit(
235-
[]( auto const & val ) {
236-
using Val_t = remove_cv_t< remove_reference_t< decltype( val ) > >;
235+
[](auto const &val) {
236+
using Val_t = remove_cv_t<remove_reference_t<decltype(val)> >;
237237

238238
std::stringstream os;
239-
if constexpr(
240-
openPMD::auxiliary::IsVector_v< Val_t > ||
241-
openPMD::auxiliary::IsArray_v< Val_t > )
239+
if constexpr (
240+
openPMD::auxiliary::IsVector_v<Val_t> ||
241+
openPMD::auxiliary::IsArray_v<Val_t>)
242242
{
243-
if( val.empty() )
243+
if (val.empty())
244244
{
245245
os << "[]";
246246
}
247247
else
248248
{
249-
os << "[" << val[ 0 ];
250-
for( size_t i = 1; i < val.size(); ++i )
249+
os << "[" << val[0];
250+
for (size_t i = 1; i < val.size(); ++i)
251251
{
252-
os << ", " << val[ i ];
252+
os << ", " << val[i];
253253
}
254254
os << "]";
255255
}
@@ -260,6 +260,6 @@ inline string to_string( openPMD::Attribute const & attr )
260260
}
261261
return os.str();
262262
},
263-
attr.getResource() );
264-
}
263+
attr.getResource());
265264
}
265+
} // namespace std

src/IO/ADIOS/ADIOS1IOHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ std::future<void> ADIOS1IOHandlerImpl::flush()
295295
"[ADIOS1] Internal error: Failed to perform ADIOS reads during "
296296
"dataset reading");
297297

298-
for( auto &sel : file.second )
298+
for (auto &sel : file.second)
299299
adios_selection_delete(sel.selection);
300300
}
301301
m_scheduledReads.clear();

src/binding/python/Attributable.cpp

+22-17
Original file line numberDiff line numberDiff line change
@@ -458,23 +458,28 @@ void init_Attributable(py::module &m)
458458
// double, 7 > >)
459459

460460
// C++ pass-through API: Getter
461-
.def("get_attribute", []( Attributable & attr, std::string const& key ) {
462-
auto v = attr.getAttribute(key);
463-
std::cout << "Attribute '" << key << "' has type: " << v.dtype
464-
<< std::endl
465-
<< " and value: " << std::to_string(v) << std::endl;
466-
return v.getResource();
467-
// TODO instead of returning lists, return all arrays (ndim > 0) as numpy arrays?
468-
})
469-
.def_property_readonly("attribute_dtypes", []( Attributable const & attributable ) {
470-
std::map< std::string, pybind11::dtype > dtypes;
471-
for( auto const & attr : attributable.attributes() )
472-
{
473-
dtypes[ attr ] =
474-
dtype_to_numpy( attributable.getAttribute( attr ).dtype );
475-
}
476-
return dtypes;
477-
})
461+
.def(
462+
"get_attribute",
463+
[](Attributable &attr, std::string const &key) {
464+
auto v = attr.getAttribute(key);
465+
std::cout << "Attribute '" << key << "' has type: " << v.dtype
466+
<< std::endl
467+
<< " and value: " << std::to_string(v) << std::endl;
468+
return v.getResource();
469+
// TODO instead of returning lists, return all arrays (ndim > 0)
470+
// as numpy arrays?
471+
})
472+
.def_property_readonly(
473+
"attribute_dtypes",
474+
[](Attributable const &attributable) {
475+
std::map<std::string, pybind11::dtype> dtypes;
476+
for (auto const &attr : attributable.attributes())
477+
{
478+
dtypes[attr] =
479+
dtype_to_numpy(attributable.getAttribute(attr).dtype);
480+
}
481+
return dtypes;
482+
})
478483
.def("delete_attribute", &Attributable::deleteAttribute)
479484
.def("contains_attribute", &Attributable::containsAttribute)
480485

src/binding/python/PatchRecordComponent.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ void init_PatchRecordComponent(py::module &m)
102102

103103
// allow one-element n-dimensional buffers as well
104104
py::ssize_t numElements = 1;
105-
if( buf.ndim > 0 )
105+
if (buf.ndim > 0)
106106
{
107107
std::cout << "Buffer has dimensionality: " << buf.ndim
108-
<< std::endl;
109-
for( auto d = 0; d < buf.ndim; ++d )
108+
<< std::endl;
109+
for (auto d = 0; d < buf.ndim; ++d)
110110
{
111111
std::cout << "Extent of dimensionality " << d << ": "
112-
<< buf.shape.at( d ) << std::endl;
113-
numElements *= buf.shape.at( d );
112+
<< buf.shape.at(d) << std::endl;
113+
numElements *= buf.shape.at(d);
114114
}
115115
}
116116

@@ -184,7 +184,7 @@ void init_PatchRecordComponent(py::module &m)
184184
throw std::runtime_error(
185185
"store: "
186186
"Only scalar values supported! (found " +
187-
std::to_string( numElements ) + "values)" );
187+
std::to_string(numElements) + "values)");
188188
}
189189
},
190190
py::arg("idx"),

src/binding/python/RecordComponent.cpp

+53-54
Original file line numberDiff line numberDiff line change
@@ -539,54 +539,54 @@ void load_chunk(
539539
}
540540
}
541541

542-
auto load_data = [ &r, &buffer, &buffer_info, &offset, &extent ](
543-
auto cxxtype ) {
544-
using CXXType = decltype( cxxtype );
545-
buffer.inc_ref();
546-
// buffer_info.inc_ref();
547-
void * data = buffer_info.ptr;
548-
std::shared_ptr< CXXType > shared(
549-
( CXXType * )data, [ buffer ]( CXXType * ) { buffer.dec_ref(); } );
550-
r.loadChunk( std::move( shared ), offset, extent );
551-
};
542+
auto load_data =
543+
[&r, &buffer, &buffer_info, &offset, &extent](auto cxxtype) {
544+
using CXXType = decltype(cxxtype);
545+
buffer.inc_ref();
546+
// buffer_info.inc_ref();
547+
void *data = buffer_info.ptr;
548+
std::shared_ptr<CXXType> shared(
549+
(CXXType *)data, [buffer](CXXType *) { buffer.dec_ref(); });
550+
r.loadChunk(std::move(shared), offset, extent);
551+
};
552552

553-
if( r.getDatatype() == Datatype::CHAR )
554-
load_data( ( char )0 );
555-
else if( r.getDatatype() == Datatype::UCHAR )
556-
load_data( ( unsigned char )0 );
557-
else if( r.getDatatype() == Datatype::SHORT )
558-
load_data( ( short )0 );
559-
else if( r.getDatatype() == Datatype::INT )
560-
load_data( ( int )0 );
561-
else if( r.getDatatype() == Datatype::LONG )
562-
load_data( ( long )0 );
563-
else if( r.getDatatype() == Datatype::LONGLONG )
564-
load_data( ( long long )0 );
565-
else if( r.getDatatype() == Datatype::USHORT )
566-
load_data( ( unsigned short )0 );
567-
else if( r.getDatatype() == Datatype::UINT )
568-
load_data( ( unsigned int )0 );
569-
else if( r.getDatatype() == Datatype::ULONG )
570-
load_data( ( unsigned long )0 );
571-
else if( r.getDatatype() == Datatype::ULONGLONG )
572-
load_data( ( unsigned long long )0 );
573-
else if( r.getDatatype() == Datatype::LONG_DOUBLE )
574-
load_data( ( long double )0 );
575-
else if( r.getDatatype() == Datatype::DOUBLE )
576-
load_data( ( double )0 );
577-
else if( r.getDatatype() == Datatype::FLOAT )
578-
load_data( ( float )0 );
579-
else if( r.getDatatype() == Datatype::CLONG_DOUBLE )
580-
load_data( ( std::complex< long double > )0 );
581-
else if( r.getDatatype() == Datatype::CDOUBLE )
582-
load_data( ( std::complex< double > )0 );
583-
else if( r.getDatatype() == Datatype::CFLOAT )
584-
load_data( ( std::complex< float > )0 );
585-
else if( r.getDatatype() == Datatype::BOOL )
586-
load_data( ( bool )0 );
553+
if (r.getDatatype() == Datatype::CHAR)
554+
load_data((char)0);
555+
else if (r.getDatatype() == Datatype::UCHAR)
556+
load_data((unsigned char)0);
557+
else if (r.getDatatype() == Datatype::SHORT)
558+
load_data((short)0);
559+
else if (r.getDatatype() == Datatype::INT)
560+
load_data((int)0);
561+
else if (r.getDatatype() == Datatype::LONG)
562+
load_data((long)0);
563+
else if (r.getDatatype() == Datatype::LONGLONG)
564+
load_data((long long)0);
565+
else if (r.getDatatype() == Datatype::USHORT)
566+
load_data((unsigned short)0);
567+
else if (r.getDatatype() == Datatype::UINT)
568+
load_data((unsigned int)0);
569+
else if (r.getDatatype() == Datatype::ULONG)
570+
load_data((unsigned long)0);
571+
else if (r.getDatatype() == Datatype::ULONGLONG)
572+
load_data((unsigned long long)0);
573+
else if (r.getDatatype() == Datatype::LONG_DOUBLE)
574+
load_data((long double)0);
575+
else if (r.getDatatype() == Datatype::DOUBLE)
576+
load_data((double)0);
577+
else if (r.getDatatype() == Datatype::FLOAT)
578+
load_data((float)0);
579+
else if (r.getDatatype() == Datatype::CLONG_DOUBLE)
580+
load_data((std::complex<long double>)0);
581+
else if (r.getDatatype() == Datatype::CDOUBLE)
582+
load_data((std::complex<double>)0);
583+
else if (r.getDatatype() == Datatype::CFLOAT)
584+
load_data((std::complex<float>)0);
585+
else if (r.getDatatype() == Datatype::BOOL)
586+
load_data((bool)0);
587587
else
588588
throw std::runtime_error(
589-
std::string( "Datatype not known in 'loadChunk'!" ) );
589+
std::string("Datatype not known in 'loadChunk'!"));
590590
}
591591

592592
/** Load Chunk
@@ -773,15 +773,15 @@ void init_RecordComponent(py::module &m)
773773

774774
// allow one-element n-dimensional buffers as well
775775
py::ssize_t numElements = 1;
776-
if( buf.ndim > 0 )
776+
if (buf.ndim > 0)
777777
{
778778
std::cout << "Buffer has dimensionality: " << buf.ndim
779779
<< std::endl;
780-
for( auto d = 0; d < buf.ndim; ++d )
780+
for (auto d = 0; d < buf.ndim; ++d)
781781
{
782782
std::cout << "Extent of dimensionality " << d << ": "
783-
<< buf.shape.at( d ) << std::endl;
784-
numElements *= buf.shape.at( d );
783+
<< buf.shape.at(d) << std::endl;
784+
numElements *= buf.shape.at(d);
785785
}
786786
}
787787

@@ -866,19 +866,18 @@ void init_RecordComponent(py::module &m)
866866
default:
867867
throw std::runtime_error(
868868
"make_constant: "
869-
"Unknown Datatype!" );
869+
"Unknown Datatype!");
870870
}
871871
}
872872
else
873873
{
874874
throw std::runtime_error(
875875
"make_constant: "
876876
"Only scalar values supported! (found " +
877-
std::to_string( numElements ) + "values)" );
877+
std::to_string(numElements) + "values)");
878878
}
879-
880-
}, py::arg("value")
881-
)
879+
},
880+
py::arg("value"))
882881
// allowed python intrinsics, after (!) buffer matching
883882
.def(
884883
"make_constant",

0 commit comments

Comments
 (0)