-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added BoundedTime, timestamp + timespan
- Loading branch information
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
modules/core/shared/src/main/scala/lucuma/core/model/sequence/BandedTime.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA) | ||
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause | ||
|
||
package lucuma.core.model.sequence | ||
|
||
import cats.Order | ||
import cats.derived.* | ||
import lucuma.core.enums.ScienceBand | ||
|
||
/** | ||
* Pairs an optional science band with a categorized time. Because programs | ||
* may have observations in distinct bands, at the top-level we must group by | ||
* band. | ||
*/ | ||
case class BandedTime( | ||
band: Option[ScienceBand], | ||
time: CategorizedTime | ||
) derives Order | ||
|
||
object BandedTime: | ||
val Empty: BandedTime = BandedTime(None, CategorizedTime.Zero) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
modules/testkit/src/main/scala/lucuma/core/model/sequence/arb/ArbBandedTime.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA) | ||
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause | ||
|
||
package lucuma.core.model.sequence | ||
package arb | ||
|
||
import lucuma.core.enums.ScienceBand | ||
import lucuma.core.util.arb.ArbEnumerated | ||
import org.scalacheck.Arbitrary | ||
import org.scalacheck.Arbitrary.* | ||
import org.scalacheck.Cogen | ||
|
||
trait ArbBandedTime: | ||
import ArbCategorizedTime.given | ||
import ArbEnumerated.given | ||
|
||
given Arbitrary[BandedTime] = | ||
Arbitrary { | ||
arbitrary[(Option[ScienceBand], CategorizedTime)].map(BandedTime.apply) | ||
} | ||
|
||
given Cogen[BandedTime] = | ||
Cogen[(Option[ScienceBand], CategorizedTime)].contramap(b => (b.band, b.time)) | ||
|
||
object ArbBandedTime extends ArbBandedTime |
14 changes: 14 additions & 0 deletions
14
modules/tests/shared/src/test/scala/lucuma/core/model/sequence/BandedTimeSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA) | ||
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause | ||
|
||
package lucuma.core.model.sequence | ||
|
||
import cats.kernel.laws.discipline.* | ||
import lucuma.core.model.sequence.arb.ArbBandedTime | ||
import munit.DisciplineSuite | ||
|
||
final class BandedTimeSuite extends DisciplineSuite: | ||
|
||
import ArbBandedTime.given | ||
|
||
checkAll("Order[BandedTime]", OrderTests[BandedTime].order) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters