Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 10 additions & 40 deletions src/aero_particle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,36 +207,18 @@ struct AeroParticle {
}

static auto scatter_cross_sect(const AeroParticle &self) {
int len = n_swbands;
double val;
f_aero_particle_scatter_cross_sect(
self.ptr.f_arg(),
&val,
&len
);
return val;
auto fn = f_aero_particle_scatter_cross_sect;
return pypartmc::get_array_values_set_len(self, fn, n_swbands);
}

static auto absorb_cross_sect(const AeroParticle &self) {
int len = n_swbands;
double val;
f_aero_particle_absorb_cross_sect(
self.ptr.f_arg(),
&val,
&len
);
return val;
auto fn = f_aero_particle_absorb_cross_sect;
return pypartmc::get_array_values_set_len(self, fn, n_swbands);
}

static auto asymmetry(const AeroParticle &self) {
int len = n_swbands;
double val;
f_aero_particle_asymmetry(
self.ptr.f_arg(),
&val,
&len
);
return val;
auto fn = f_aero_particle_asymmetry;
return pypartmc::get_array_values_set_len(self, fn, n_swbands);
}

static auto sources(const AeroParticle &self) {
Expand All @@ -262,25 +244,13 @@ struct AeroParticle {
}

static auto refract_shell(const AeroParticle &self) {
int len = n_swbands;
std::complex<double> refract_shell;
f_aero_particle_refract_shell(
self.ptr.f_arg(),
&refract_shell,
&len
);
return refract_shell;
auto fn = f_aero_particle_refract_shell;
return pypartmc::get_array_values_set_len<std::complex<double>>(self, fn, n_swbands);
}

static auto refract_core(const AeroParticle &self) {
int len = n_swbands;
std::complex<double> refract_core;
f_aero_particle_refract_core(
self.ptr.f_arg(),
&refract_core,
&len
);
return refract_core;
auto fn = f_aero_particle_refract_core;
return pypartmc::get_array_values_set_len<std::complex<double>>(self, fn, n_swbands);
}

static auto get_weight_class(const AeroParticle &self) {
Expand Down
35 changes: 20 additions & 15 deletions tests/test_aero_particle.py
Comment thread
slayoo marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -441,59 +441,64 @@ def test_absorb_cross_sect():
sut = ppmc.AeroParticle(ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL), [44])

# act
value = sut.absorb_cross_sect
value = list(sut.absorb_cross_sect)

# assert
assert value == 0
assert isinstance(value, float)
assert len(value) >= 1
assert all(v == 0 for v in value)
assert isinstance(value[0], float)

@staticmethod
def test_scatter_cross_sect():
# arrange
sut = ppmc.AeroParticle(ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL), [44])

# act
value = sut.scatter_cross_sect
value = list(sut.scatter_cross_sect)

# assert
assert value == 0
assert isinstance(value, float)
assert len(value) >= 1
assert all(v == 0 for v in value)
assert isinstance(value[0], float)

@staticmethod
def test_asymmetry():
# arrange
sut = ppmc.AeroParticle(ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL), [44])

# act
value = sut.asymmetry
value = list(sut.asymmetry)

# assert
assert value == 0
assert isinstance(value, float)
assert len(value) >= 1
assert all(v == 0 for v in value)
assert isinstance(value[0], float)

@staticmethod
def test_refract_shell():
# arrange
sut = ppmc.AeroParticle(ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL), [44])

# act
value = sut.refract_shell
value = list(sut.refract_shell)

# assert
assert value == 0 + 0j
assert isinstance(value, complex)
assert len(value) >= 1
assert all(v == 0 + 0j for v in value)
assert isinstance(value[0], complex)

@staticmethod
def test_refract_core():
# arrange
sut = ppmc.AeroParticle(ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL), [44])

# act
value = sut.refract_core
value = list(sut.refract_core)

# assert
assert value == 0 + 0j
assert isinstance(value, complex)
assert len(value) >= 1
assert all(v == 0 + 0j for v in value)
assert isinstance(value[0], complex)

@staticmethod
def test_sources():
Expand Down
Loading