Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize the codebase - and, or, not #2498

Merged
merged 13 commits into from
Oct 19, 2022
Merged
2 changes: 1 addition & 1 deletion libnestutil/lockptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class lockPTR
~PointerObject()
{
assert( not locked );
if ( ( pointee != NULL ) && deletable && ( not locked ) )
if ( ( pointee != NULL ) and deletable and not locked )
heplesser marked this conversation as resolved.
Show resolved Hide resolved
jougs marked this conversation as resolved.
Show resolved Hide resolved
{
delete pointee;
}
Expand Down
2 changes: 1 addition & 1 deletion libnestutil/stopwatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class Stopwatch
inline bool
Stopwatch::correct_timeunit( timeunit_t t )
{
return t == MICROSEC || t == MILLISEC || t == SECONDS || t == MINUTES || t == HOURS || t == DAYS;
return t == MICROSEC or t == MILLISEC or t == SECONDS or t == MINUTES or t == HOURS or t == DAYS;
}

inline void
Expand Down
2 changes: 1 addition & 1 deletion models/ac_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ nest::ac_generator::pre_run_hook()
void
nest::ac_generator::update( Time const& origin, const long from, const long to )
{
assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() );
jougs marked this conversation as resolved.
Show resolved Hide resolved
assert( from < to );

long start = origin.get_steps();
Expand Down
8 changes: 4 additions & 4 deletions models/aeif_cond_alpha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ nest::aeif_cond_alpha::Parameters_::set( const DictionaryDatum& d, Node* node )
throw BadProperty( "Refractory time cannot be negative." );
}

if ( tau_syn_ex <= 0 || tau_syn_in <= 0 || tau_w <= 0 )
if ( tau_syn_ex <= 0 or tau_syn_in <= 0 or tau_w <= 0 )
{
throw BadProperty( "All time constants must be strictly positive." );
}
Expand Down Expand Up @@ -302,7 +302,7 @@ nest::aeif_cond_alpha::State_::set( const DictionaryDatum& d, const Parameters_&
updateValueParam< double >( d, names::g_in, y_[ G_INH ], node );
updateValueParam< double >( d, names::dg_in, y_[ DG_INH ], node );
updateValueParam< double >( d, names::w, y_[ W ], node );
if ( y_[ G_EXC ] < 0 || y_[ G_INH ] < 0 )
if ( y_[ G_EXC ] < 0 or y_[ G_INH ] < 0 )
{
throw BadProperty( "Conductances must not be negative." );
}
Expand Down Expand Up @@ -448,7 +448,7 @@ nest::aeif_cond_alpha::pre_run_hook()
void
nest::aeif_cond_alpha::update( Time const& origin, const long from, const long to )
{
assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( from < to );
assert( State_::V_M == 0 );

Expand Down Expand Up @@ -485,7 +485,7 @@ nest::aeif_cond_alpha::update( Time const& origin, const long from, const long t
}

// check for unreasonable values; we allow V_M to explode
if ( S_.y_[ State_::V_M ] < -1e3 || S_.y_[ State_::W ] < -1e6 || S_.y_[ State_::W ] > 1e6 )
if ( S_.y_[ State_::V_M ] < -1e3 or S_.y_[ State_::W ] < -1e6 or S_.y_[ State_::W ] > 1e6 )
{
throw NumericalInstability( get_name() );
}
Expand Down
16 changes: 8 additions & 8 deletions models/aeif_cond_alpha_multisynapse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ aeif_cond_alpha_multisynapse::Parameters_::set( const DictionaryDatum& d, Node*
const size_t old_n_receptors = n_receptors();
bool Erev_flag = updateValue< std::vector< double > >( d, names::E_rev, E_rev );
bool tau_flag = updateValue< std::vector< double > >( d, names::tau_syn, tau_syn );
if ( Erev_flag || tau_flag )
if ( Erev_flag or tau_flag )
{ // receptor arrays have been modified
if ( ( E_rev.size() != old_n_receptors || tau_syn.size() != old_n_receptors )
and ( not Erev_flag || not tau_flag ) )
if ( ( E_rev.size() != old_n_receptors or tau_syn.size() != old_n_receptors )
and ( not Erev_flag or not tau_flag ) )
{
throw BadProperty(
"If the number of receptor ports is changed, both arrays "
Expand All @@ -233,7 +233,7 @@ aeif_cond_alpha_multisynapse::Parameters_::set( const DictionaryDatum& d, Node*
"The reversal potential, and synaptic time constant arrays "
"must have the same size." );
}
if ( tau_syn.size() < old_n_receptors && has_connections_ )
if ( tau_syn.size() < old_n_receptors and has_connections_ )
{
throw BadProperty(
"The neuron has connections, therefore the number of ports cannot be "
Expand Down Expand Up @@ -486,7 +486,7 @@ aeif_cond_alpha_multisynapse::pre_run_hook()
void
aeif_cond_alpha_multisynapse::update( Time const& origin, const long from, const long to )
{
assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( from < to );
assert( State_::V_M == 0 );

Expand Down Expand Up @@ -524,7 +524,7 @@ aeif_cond_alpha_multisynapse::update( Time const& origin, const long from, const
}

// check for unreasonable values; we allow V_M to explode
if ( S_.y_[ State_::V_M ] < -1e3 || S_.y_[ State_::W ] < -1e6 || S_.y_[ State_::W ] > 1e6 )
if ( S_.y_[ State_::V_M ] < -1e3 or S_.y_[ State_::W ] < -1e6 or S_.y_[ State_::W ] > 1e6 )
{
throw NumericalInstability( get_name() );
}
Expand Down Expand Up @@ -574,7 +574,7 @@ aeif_cond_alpha_multisynapse::update( Time const& origin, const long from, const
port
aeif_cond_alpha_multisynapse::handles_test_event( SpikeEvent&, rport receptor_type )
{
if ( receptor_type <= 0 || receptor_type > static_cast< port >( P_.n_receptors() ) )
if ( receptor_type <= 0 or receptor_type > static_cast< port >( P_.n_receptors() ) )
{
throw IncompatibleReceptorType( receptor_type, get_name(), "SpikeEvent" );
}
Expand All @@ -592,7 +592,7 @@ aeif_cond_alpha_multisynapse::handle( SpikeEvent& e )
"must be positive." );
}
assert( e.get_delay_steps() > 0 );
assert( ( e.get_rport() > 0 ) && ( ( size_t ) e.get_rport() <= P_.n_receptors() ) );
assert( ( e.get_rport() > 0 ) and ( ( size_t ) e.get_rport() <= P_.n_receptors() ) );

B_.spikes_[ e.get_rport() - 1 ].add_value(
e.get_rel_delivery_steps( kernel().simulation_manager.get_slice_origin() ), e.get_weight() * e.get_multiplicity() );
Expand Down
22 changes: 11 additions & 11 deletions models/aeif_cond_beta_multisynapse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,31 +221,31 @@ aeif_cond_beta_multisynapse::Parameters_::set( const DictionaryDatum& d, Node* n
bool Erev_flag = updateValue< std::vector< double > >( d, names::E_rev, E_rev );
bool taur_flag = updateValue< std::vector< double > >( d, names::tau_rise, tau_rise );
bool taud_flag = updateValue< std::vector< double > >( d, names::tau_decay, tau_decay );
if ( Erev_flag || taur_flag || taud_flag )
if ( Erev_flag or taur_flag or taud_flag )
{ // receptor arrays have been modified
if ( ( E_rev.size() != old_n_receptors || tau_rise.size() != old_n_receptors
|| tau_decay.size() != old_n_receptors )
&& ( not Erev_flag || not taur_flag || not taud_flag ) )
if ( ( E_rev.size() != old_n_receptors or tau_rise.size() != old_n_receptors
or tau_decay.size() != old_n_receptors )
and ( not Erev_flag or not taur_flag or not taud_flag ) )
{
throw BadProperty(
"If the number of receptor ports is changed, all three arrays "
"E_rev, tau_rise and tau_decay must be provided." );
}
if ( ( E_rev.size() != tau_rise.size() ) || ( E_rev.size() != tau_decay.size() ) )
if ( ( E_rev.size() != tau_rise.size() ) or ( E_rev.size() != tau_decay.size() ) )
{
throw BadProperty(
"The reversal potential, synaptic rise time and synaptic decay time "
"arrays must have the same size." );
}
if ( tau_rise.size() < old_n_receptors && has_connections_ )
if ( tau_rise.size() < old_n_receptors and has_connections_ )
{
throw BadProperty(
"The neuron has connections, therefore the number of ports cannot be "
"reduced." );
}
for ( size_t i = 0; i < tau_rise.size(); ++i )
{
if ( tau_rise[ i ] <= 0 || tau_decay[ i ] <= 0 )
if ( tau_rise[ i ] <= 0 or tau_decay[ i ] <= 0 )
{
throw BadProperty( "All synaptic time constants must be strictly positive" );
}
Expand Down Expand Up @@ -495,7 +495,7 @@ aeif_cond_beta_multisynapse::pre_run_hook()
void
aeif_cond_beta_multisynapse::update( Time const& origin, const long from, const long to )
{
assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( from < to );
assert( State_::V_M == 0 );

Expand Down Expand Up @@ -533,7 +533,7 @@ aeif_cond_beta_multisynapse::update( Time const& origin, const long from, const
}

// check for unreasonable values; we allow V_M to explode
if ( S_.y_[ State_::V_M ] < -1e3 || S_.y_[ State_::W ] < -1e6 || S_.y_[ State_::W ] > 1e6 )
if ( S_.y_[ State_::V_M ] < -1e3 or S_.y_[ State_::W ] < -1e6 or S_.y_[ State_::W ] > 1e6 )
{
throw NumericalInstability( get_name() );
}
Expand Down Expand Up @@ -583,7 +583,7 @@ aeif_cond_beta_multisynapse::update( Time const& origin, const long from, const
port
aeif_cond_beta_multisynapse::handles_test_event( SpikeEvent&, rport receptor_type )
{
if ( receptor_type <= 0 || receptor_type > static_cast< port >( P_.n_receptors() ) )
if ( receptor_type <= 0 or receptor_type > static_cast< port >( P_.n_receptors() ) )
{
throw IncompatibleReceptorType( receptor_type, get_name(), "SpikeEvent" );
}
Expand All @@ -601,7 +601,7 @@ aeif_cond_beta_multisynapse::handle( SpikeEvent& e )
"must be positive." );
}
assert( e.get_delay_steps() > 0 );
assert( ( e.get_rport() > 0 ) && ( ( size_t ) e.get_rport() <= P_.n_receptors() ) );
assert( ( e.get_rport() > 0 ) and ( ( size_t ) e.get_rport() <= P_.n_receptors() ) );

B_.spikes_[ e.get_rport() - 1 ].add_value(
e.get_rel_delivery_steps( kernel().simulation_manager.get_slice_origin() ), e.get_weight() * e.get_multiplicity() );
Expand Down
8 changes: 4 additions & 4 deletions models/aeif_cond_exp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ nest::aeif_cond_exp::Parameters_::set( const DictionaryDatum& d, Node* node )
throw BadProperty( "Refractory time cannot be negative." );
}

if ( tau_syn_ex <= 0 || tau_syn_in <= 0 || tau_w <= 0 )
if ( tau_syn_ex <= 0 or tau_syn_in <= 0 or tau_w <= 0 )
{
throw BadProperty( "All time constants must be strictly positive." );
}
Expand All @@ -297,7 +297,7 @@ nest::aeif_cond_exp::State_::set( const DictionaryDatum& d, const Parameters_&,
updateValueParam< double >( d, names::g_ex, y_[ G_EXC ], node );
updateValueParam< double >( d, names::g_in, y_[ G_INH ], node );
updateValueParam< double >( d, names::w, y_[ W ], node );
if ( y_[ G_EXC ] < 0 || y_[ G_INH ] < 0 )
if ( y_[ G_EXC ] < 0 or y_[ G_INH ] < 0 )
{
throw BadProperty( "Conductances must not be negative." );
}
Expand Down Expand Up @@ -441,7 +441,7 @@ nest::aeif_cond_exp::pre_run_hook()
void
nest::aeif_cond_exp::update( const Time& origin, const long from, const long to )
{
assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( from < to );
assert( State_::V_M == 0 );

Expand Down Expand Up @@ -475,7 +475,7 @@ nest::aeif_cond_exp::update( const Time& origin, const long from, const long to
}

// check for unreasonable values; we allow V_M to explode
if ( S_.y_[ State_::V_M ] < -1e3 || S_.y_[ State_::W ] < -1e6 || S_.y_[ State_::W ] > 1e6 )
if ( S_.y_[ State_::V_M ] < -1e3 or S_.y_[ State_::W ] < -1e6 or S_.y_[ State_::W ] > 1e6 )
{
throw NumericalInstability( get_name() );
}
Expand Down
8 changes: 4 additions & 4 deletions models/aeif_psc_alpha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ nest::aeif_psc_alpha::Parameters_::set( const DictionaryDatum& d, Node* node )
throw BadProperty( "Refractory time cannot be negative." );
}

if ( tau_syn_ex <= 0 || tau_syn_in <= 0 || tau_w <= 0 )
if ( tau_syn_ex <= 0 or tau_syn_in <= 0 or tau_w <= 0 )
{
throw BadProperty( "All time constants must be strictly positive." );
}
Expand Down Expand Up @@ -292,7 +292,7 @@ nest::aeif_psc_alpha::State_::set( const DictionaryDatum& d, const Parameters_&,
updateValueParam< double >( d, names::I_syn_in, y_[ I_INH ], node );
updateValueParam< double >( d, names::dI_syn_in, y_[ DI_INH ], node );
updateValueParam< double >( d, names::w, y_[ W ], node );
if ( y_[ I_EXC ] < 0 || y_[ I_INH ] < 0 )
if ( y_[ I_EXC ] < 0 or y_[ I_INH ] < 0 )
{
throw BadProperty( "Conductances must not be negative." );
}
Expand Down Expand Up @@ -438,7 +438,7 @@ nest::aeif_psc_alpha::pre_run_hook()
void
nest::aeif_psc_alpha::update( Time const& origin, const long from, const long to )
{
assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() );
jougs marked this conversation as resolved.
Show resolved Hide resolved
assert( from < to );
assert( State_::V_M == 0 );

Expand Down Expand Up @@ -475,7 +475,7 @@ nest::aeif_psc_alpha::update( Time const& origin, const long from, const long to
}

// check for unreasonable values; we allow V_M to explode
if ( S_.y_[ State_::V_M ] < -1e3 || S_.y_[ State_::W ] < -1e6 || S_.y_[ State_::W ] > 1e6 )
if ( S_.y_[ State_::V_M ] < -1e3 or S_.y_[ State_::W ] < -1e6 or S_.y_[ State_::W ] > 1e6 )
{
throw NumericalInstability( get_name() );
}
Expand Down
6 changes: 3 additions & 3 deletions models/aeif_psc_delta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ nest::aeif_psc_delta::pre_run_hook()
void
nest::aeif_psc_delta::update( const Time& origin, const long from, const long to )
{
assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( from < to );
assert( State_::V_M == 0 );
const double h = Time::get_resolution().get_ms();
Expand Down Expand Up @@ -451,7 +451,7 @@ nest::aeif_psc_delta::update( const Time& origin, const long from, const long to
throw GSLSolverFailure( get_name(), status );
}
// check for unreasonable values; we allow V_M to explode
if ( S_.y_[ State_::V_M ] < -1e3 || S_.y_[ State_::W ] < -1e6 || S_.y_[ State_::W ] > 1e6 )
if ( S_.y_[ State_::V_M ] < -1e3 or S_.y_[ State_::W ] < -1e6 or S_.y_[ State_::W ] > 1e6 )
{
throw NumericalInstability( get_name() );
}
Expand All @@ -465,7 +465,7 @@ nest::aeif_psc_delta::update( const Time& origin, const long from, const long to

// if we have accumulated spikes from refractory period,
// add and reset accumulator
if ( P_.with_refr_input_ && S_.refr_spikes_buffer_ != 0.0 )
if ( P_.with_refr_input_ and S_.refr_spikes_buffer_ != 0.0 )
{
S_.y_[ State_::V_M ] += S_.refr_spikes_buffer_;
S_.refr_spikes_buffer_ = 0.0;
Expand Down
12 changes: 6 additions & 6 deletions models/aeif_psc_delta_clopath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ nest::aeif_psc_delta_clopath_dynamics( double, const double y[], double f[], voi

// Clamp membrane potential to V_reset while refractory, otherwise bound
// it to V_peak.
const double& V = ( is_refractory || is_clamped ) ? ( is_clamped ? node.P_.V_clamp_ : node.P_.V_reset_ )
const double& V = ( is_refractory or is_clamped ) ? ( is_clamped ? node.P_.V_clamp_ : node.P_.V_reset_ )
: std::min( y[ S::V_M ], node.P_.V_peak_ );
// shorthand for the other state variables
const double& w = y[ S::W ];
Expand All @@ -112,7 +112,7 @@ nest::aeif_psc_delta_clopath_dynamics( double, const double y[], double f[], voi
node.P_.Delta_T == 0. ? 0. : ( node.P_.g_L * node.P_.Delta_T * std::exp( ( V - V_th ) / node.P_.Delta_T ) );

// dv/dt
f[ S::V_M ] = ( is_refractory || is_clamped )
f[ S::V_M ] = ( is_refractory or is_clamped )
? 0.0
: ( -node.P_.g_L * ( V - node.P_.E_L ) + I_spike - w + z + node.P_.I_e + node.B_.I_stim_ ) / node.P_.C_m;

Expand Down Expand Up @@ -475,7 +475,7 @@ nest::aeif_psc_delta_clopath::pre_run_hook()
void
nest::aeif_psc_delta_clopath::update( const Time& origin, const long from, const long to )
{
assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( from < to );
assert( State_::V_M == 0 );

Expand Down Expand Up @@ -509,14 +509,14 @@ nest::aeif_psc_delta_clopath::update( const Time& origin, const long from, const
throw GSLSolverFailure( get_name(), status );
}
// check for unreasonable values; we allow V_M to explode
if ( S_.y_[ State_::V_M ] < -1e3 || S_.y_[ State_::W ] < -1e6 || S_.y_[ State_::W ] > 1e6 )
if ( S_.y_[ State_::V_M ] < -1e3 or S_.y_[ State_::W ] < -1e6 or S_.y_[ State_::W ] > 1e6 )
{
throw NumericalInstability( get_name() );
}

// spikes are handled inside the while-loop
// due to spike-driven adaptation
if ( S_.r_ == 0 && S_.clamp_r_ == 0 )
if ( S_.r_ == 0 and S_.clamp_r_ == 0 )
{
// neuron not refractory
S_.y_[ State_::V_M ] = S_.y_[ State_::V_M ] + B_.spikes_.get_value( lag );
Expand All @@ -533,7 +533,7 @@ nest::aeif_psc_delta_clopath::update( const Time& origin, const long from, const
// Delta_T == 0.
}

if ( S_.y_[ State_::V_M ] >= V_.V_peak_ && S_.clamp_r_ == 0 )
if ( S_.y_[ State_::V_M ] >= V_.V_peak_ and S_.clamp_r_ == 0 )
{
S_.y_[ State_::V_M ] = P_.V_clamp_;
S_.y_[ State_::W ] += P_.b; // spike-driven adaptation
Expand Down
8 changes: 4 additions & 4 deletions models/aeif_psc_exp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ nest::aeif_psc_exp::Parameters_::set( const DictionaryDatum& d, Node* node )
throw BadProperty( "Refractory time cannot be negative." );
}

if ( tau_syn_ex <= 0 || tau_syn_in <= 0 || tau_w <= 0 )
if ( tau_syn_ex <= 0 or tau_syn_in <= 0 or tau_w <= 0 )
{
throw BadProperty( "All time constants must be strictly positive." );
}
Expand All @@ -287,7 +287,7 @@ nest::aeif_psc_exp::State_::set( const DictionaryDatum& d, const Parameters_&, N
updateValueParam< double >( d, names::I_syn_ex, y_[ I_EXC ], node );
updateValueParam< double >( d, names::I_syn_in, y_[ I_INH ], node );
updateValueParam< double >( d, names::w, y_[ W ], node );
if ( y_[ I_EXC ] < 0 || y_[ I_INH ] < 0 )
if ( y_[ I_EXC ] < 0 or y_[ I_INH ] < 0 )
{
throw BadProperty( "Conductances must not be negative." );
}
Expand Down Expand Up @@ -431,7 +431,7 @@ nest::aeif_psc_exp::pre_run_hook()
void
nest::aeif_psc_exp::update( const Time& origin, const long from, const long to )
{
assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( to >= 0 and ( delay ) from < kernel().connection_manager.get_min_delay() );
assert( from < to );
assert( State_::V_M == 0 );

Expand Down Expand Up @@ -465,7 +465,7 @@ nest::aeif_psc_exp::update( const Time& origin, const long from, const long to )
}

// check for unreasonable values; we allow V_M to explode
if ( S_.y_[ State_::V_M ] < -1e3 || S_.y_[ State_::W ] < -1e6 || S_.y_[ State_::W ] > 1e6 )
if ( S_.y_[ State_::V_M ] < -1e3 or S_.y_[ State_::W ] < -1e6 or S_.y_[ State_::W ] > 1e6 )
{
throw NumericalInstability( get_name() );
}
Expand Down
Loading