Skip to content

Commit

Permalink
Add exceptions tests for direct coords
Browse files Browse the repository at this point in the history
  • Loading branch information
nunofachada committed Jun 11, 2023
1 parent 080160a commit 9717f5e
Showing 1 changed file with 114 additions and 0 deletions.
114 changes: 114 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,3 +707,117 @@ def test_clugen_exceptions(prng):
angle_deltas_fn=langles_fn,
rng=prng,
)

# Invalid direct clusizes
with pytest.raises(
ValueError,
match=re.escape(
"clusizes_fn has to be either a function or a `num_clusters`-sized array"
),
):
clugen(
nd,
nclu,
tpts,
direc,
astd,
clu_sep,
len_mu,
len_std,
lat_std,
allow_empty=ae,
cluster_offset=clu_off,
proj_dist_fn=pt_dist,
point_dist_fn=pt_off,
clusizes_fn=prng.integers(1, tpts * nclu, size=nclu + 1),
clucenters_fn=ccenters_fn,
llengths_fn=llengths_fn,
angle_deltas_fn=langles_fn,
rng=prng,
)

# Invalid direct clucenters
with pytest.raises(
ValueError,
match=re.escape(
"clucenters_fn has to be either a function or a matrix of size "
+ "`num_clusters` x `num_dims`"
),
):
clugen(
nd,
nclu,
tpts,
direc,
astd,
clu_sep,
len_mu,
len_std,
lat_std,
allow_empty=ae,
cluster_offset=clu_off,
proj_dist_fn=pt_dist,
point_dist_fn=pt_off,
clusizes_fn=csizes_fn,
clucenters_fn=prng.normal(size=(nclu + 1, nd + 1)),
llengths_fn=llengths_fn,
angle_deltas_fn=langles_fn,
rng=prng,
)

# Invalid direct llengths
with pytest.raises(
ValueError,
match=re.escape(
"llengths_fn has to be either a function or a `num_clusters`-sized array"
),
):
clugen(
nd,
nclu,
tpts,
direc,
astd,
clu_sep,
len_mu,
len_std,
lat_std,
allow_empty=ae,
cluster_offset=clu_off,
proj_dist_fn=pt_dist,
point_dist_fn=pt_off,
clusizes_fn=csizes_fn,
clucenters_fn=ccenters_fn,
llengths_fn=prng.random(size=nclu + 1),
angle_deltas_fn=langles_fn,
rng=prng,
)

# Invalid direct langles
with pytest.raises(
ValueError,
match=re.escape(
"angle_deltas_fn has to be either a function or a "
+ "`num_clusters`-sized array"
),
):
clugen(
nd,
nclu,
tpts,
direc,
astd,
clu_sep,
len_mu,
len_std,
lat_std,
allow_empty=ae,
cluster_offset=clu_off,
proj_dist_fn=pt_dist,
point_dist_fn=pt_off,
clusizes_fn=csizes_fn,
clucenters_fn=ccenters_fn,
llengths_fn=llengths_fn,
angle_deltas_fn=prng.random(size=nclu + 1),
rng=prng,
)

0 comments on commit 9717f5e

Please sign in to comment.