obsplus.utils.testing module

Testing utilities for ObsPlus.

class obsplus.utils.testing.ArchiveDirectory(path, starttime=None, endtime=None, sampling_rate=1, duration=3600, overlap=0, gaps=None, seed_ids=('TA.M17A..VHZ', 'TA.BOB..VHZ'))[source]

Bases: object

class for creating a simple archive

create_directory()[source]

create the directory with gaps in it

create_directory_from_bulk_args(bulk_args)[source]

Create a directory from bulk waveform arguments

create_stream(starttime, endtime, seed_ids=None, sampling_rate=None)[source]

create a waveforms from random data

Return type:

Stream

get_gap_stream(t1, t2, gaps)[source]

return streams with gaps in it

obsplus.utils.testing.assert_streams_almost_equal(st1, st2, basic_stats=True, atol=1e-05, rtol=1e-08, equal_nan=True, allow_off_by_one=False)[source]

Assert that two streams are almost equal else raise helpful exceptions.

Parameters:
  • st1 (Stream) – The first stream

  • st2 (Stream) – The second stream

  • basic_stats (bool) – If True, only compare basic stats of the streams including: network, station, location, channel, starttime, endtime

  • atol (float) – The absolute tolerance parameter

  • rtol (float) – The relative tolerance parameter

  • equal_nan (bool) – If True evaluate NaNs as equal

  • allow_off_by_one (bool) – If True, allow the arrays and time alignments to be off by one sample.

Return type:

None

Notes

See numpy.allclose for description of atol and rtol paramter.

Raises:

AssertionError if streams are not about equal.

obsplus.utils.testing.instrument_methods(obj)[source]

Temporarily instrument an object’s methods.

This allows the calls to each of the objects methods to be counted.