CXC-Number

 view release on metacpan or  search on metacpan

lib/CXC/Number/Grid.pm  view on Meta::CPAN

package CXC::Number::Grid;

# ABSTRACT: A class representing a one dimensional numeric grid

use v5.28;

use POSIX ();

use Types::Standard qw( ArrayRef Bool Dict Enum HashRef InstanceOf Optional Slurpy );
use Type::Params    qw( signature signature_for );
use Ref::Util       qw( is_plain_hashref is_blessed_ref );
use List::Util      qw( uniqnum );

use CXC::Number::Grid::Types -types;
use CXC::Number::Grid::Failure qw( parameter_interface parameter_constraint internal );

use CXC::Number::Grid::Tree;
use constant Tree => 'CXC::Number::Grid::Tree';

use Safe::Isa;

use Moo;

our $VERSION = '0.13';

use constant GridObject   => InstanceOf [ ( __PACKAGE__ ) ];
use constant IncludeArray => ArrayRef [ Enum [ 0, 1 ] ];

use experimental 'signatures';

use Exporter::Shiny qw( join_n overlay_n );

use namespace::clean;

use MooX::StrictConstructor;

use overload
  '!'      => \&_overload_not,
  '|'      => \&_overload_or,
  '&'      => \&_overload_and,
  fallback => 1,
  bool     => sub { 1 };

BEGIN { with 'MooX::Tag::TO_HASH' }    # so can see has

my sub _croak {
    require Carp;
    goto \&Carp::croak;
}

sub _convert ( $self, $bignum ) {
    require Ref::Util;

    return Ref::Util::is_plain_arrayref( $bignum )
      ? [ map { $_->numify } $bignum->@* ]
      : $bignum->numify;
}









has oob => (
    is      => 'ro',
    isa     => Bool,
    default => 0,
    to_hash => 1,
);







has _raw_edges => (
    is       => 'ro',
    init_arg => 'edges',
    isa      => BinEdges,
    required => 1,
    coerce   => 1,
    to_hash  => 'edges',
);







has _include => (
    is       => 'lazy',
    init_arg => 'include',
    isa      => IncludeArray,
    builder  => sub { [ ( 1 ) x $_[0]->nbins ] },
    to_hash  => 'include,if_exists',
);















( run in 3.415 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )