or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

arrays.mdchaining.mdcollections.mdfunctions.mdindex.mdnumerical.mdobjects.mdpredicates.mdstrings.mdutilities.md

predicates.mddocs/

0

# Predicates Module

1

2

The Predicates module provides 59 functions for testing and type checking. These functions enable value comparison, type detection, content validation, and sequence analysis with comprehensive predicate and comparator functions.

3

4

## Value Comparison Predicates

5

6

### eq

7

8

```python { .api }

9

def eq(a: Any, b: Any) -> bool

10

```

11

12

Performs SameValueZero comparison between two values to determine if they are equivalent.

13

14

**Parameters:**

15

- `a` (`Any`): First value to compare.

16

- `b` (`Any`): Second value to compare.

17

18

**Returns:**

19

- `bool`: `True` if values are equivalent, else `False`.

20

21

**Example:**

22

```python { .api }

23

from pydash import eq

24

25

eq('a', 'a')

26

# True

27

28

eq('a', 'b')

29

# False

30

31

eq(1, 1.0)

32

# True

33

```

34

35

### eq_cmp

36

37

```python { .api }

38

def eq_cmp(a: Any) -> Callable

39

```

40

41

Creates a comparator function that performs SameValueZero equality comparison with the given value.

42

43

**Parameters:**

44

- `a` (`Any`): Value to compare against.

45

46

**Returns:**

47

- `Callable`: Comparator function.

48

49

**Example:**

50

```python { .api }

51

from pydash import eq_cmp

52

53

is_five = eq_cmp(5)

54

is_five(5) # True

55

is_five(10) # False

56

```

57

58

### gt

59

60

```python { .api }

61

def gt(a: Any, b: Any) -> bool

62

```

63

64

Checks if `a` is greater than `b`.

65

66

**Parameters:**

67

- `a` (`Any`): First value to compare.

68

- `b` (`Any`): Second value to compare.

69

70

**Returns:**

71

- `bool`: `True` if `a > b`, else `False`.

72

73

**Example:**

74

```python { .api }

75

from pydash import gt

76

77

gt(3, 1)

78

# True

79

80

gt(3, 3)

81

# False

82

```

83

84

### gt_cmp

85

86

```python { .api }

87

def gt_cmp(a: Any) -> Callable

88

```

89

90

Creates a comparator function for greater than comparison.

91

92

**Parameters:**

93

- `a` (`Any`): Value to compare against.

94

95

**Returns:**

96

- `Callable`: Comparator function.

97

98

### gte

99

100

```python { .api }

101

def gte(a: Any, b: Any) -> bool

102

```

103

104

Checks if `a` is greater than or equal to `b`.

105

106

**Parameters:**

107

- `a` (`Any`): First value to compare.

108

- `b` (`Any`): Second value to compare.

109

110

**Returns:**

111

- `bool`: `True` if `a >= b`, else `False`.

112

113

**Example:**

114

```python { .api }

115

from pydash import gte

116

117

gte(3, 1)

118

# True

119

120

gte(3, 3)

121

# True

122

```

123

124

### gte_cmp

125

126

```python { .api }

127

def gte_cmp(a: Any) -> Callable

128

```

129

130

Creates a comparator function for greater than or equal comparison.

131

132

**Parameters:**

133

- `a` (`Any`): Value to compare against.

134

135

**Returns:**

136

- `Callable`: Comparator function.

137

138

### lt

139

140

```python { .api }

141

def lt(a: Any, b: Any) -> bool

142

```

143

144

Checks if `a` is less than `b`.

145

146

**Parameters:**

147

- `a` (`Any`): First value to compare.

148

- `b` (`Any`): Second value to compare.

149

150

**Returns:**

151

- `bool`: `True` if `a < b`, else `False`.

152

153

**Example:**

154

```python { .api }

155

from pydash import lt

156

157

lt(1, 3)

158

# True

159

160

lt(3, 3)

161

# False

162

```

163

164

### lt_cmp

165

166

```python { .api }

167

def lt_cmp(a: Any) -> Callable

168

```

169

170

Creates a comparator function for less than comparison.

171

172

**Parameters:**

173

- `a` (`Any`): Value to compare against.

174

175

**Returns:**

176

- `Callable`: Comparator function.

177

178

### lte

179

180

```python { .api }

181

def lte(a: Any, b: Any) -> bool

182

```

183

184

Checks if `a` is less than or equal to `b`.

185

186

**Parameters:**

187

- `a` (`Any`): First value to compare.

188

- `b` (`Any`): Second value to compare.

189

190

**Returns:**

191

- `bool`: `True` if `a <= b`, else `False`.

192

193

**Example:**

194

```python { .api }

195

from pydash import lte

196

197

lte(1, 3)

198

# True

199

200

lte(3, 3)

201

# True

202

```

203

204

### lte_cmp

205

206

```python { .api }

207

def lte_cmp(a: Any) -> Callable

208

```

209

210

Creates a comparator function for less than or equal comparison.

211

212

**Parameters:**

213

- `a` (`Any`): Value to compare against.

214

215

**Returns:**

216

- `Callable`: Comparator function.

217

218

## Equality and Matching Predicates

219

220

### is_equal

221

222

```python { .api }

223

def is_equal(a: Any, b: Any) -> bool

224

```

225

226

Performs a deep comparison to determine if two values are equivalent.

227

228

**Parameters:**

229

- `a` (`Any`): First value to compare.

230

- `b` (`Any`): Second value to compare.

231

232

**Returns:**

233

- `bool`: `True` if values are equivalent, else `False`.

234

235

**Example:**

236

```python { .api }

237

from pydash import is_equal

238

239

is_equal({'a': 1}, {'a': 1})

240

# True

241

242

is_equal([1, 2, 3], [1, 2, 3])

243

# True

244

245

is_equal({'a': {'b': 1}}, {'a': {'b': 1}})

246

# True

247

```

248

249

### is_equal_cmp

250

251

```python { .api }

252

def is_equal_cmp(a: Any) -> Callable

253

```

254

255

Creates a comparator function for deep equality.

256

257

**Parameters:**

258

- `a` (`Any`): Value to compare against.

259

260

**Returns:**

261

- `Callable`: Comparator function.

262

263

### is_equal_with

264

265

```python { .api }

266

def is_equal_with(a: Any, b: Any, customizer: Callable = None) -> bool

267

```

268

269

Like `is_equal` except that it accepts `customizer` which is invoked to compare values.

270

271

**Parameters:**

272

- `a` (`Any`): First value to compare.

273

- `b` (`Any`): Second value to compare.

274

- `customizer` (`Callable`, optional): Function to customize comparisons.

275

276

**Returns:**

277

- `bool`: `True` if values are equivalent, else `False`.

278

279

### is_equal_with_cmp

280

281

```python { .api }

282

def is_equal_with_cmp(a: Any, customizer: Callable = None) -> Callable

283

```

284

285

Creates a comparator function for custom deep equality.

286

287

**Parameters:**

288

- `a` (`Any`): Value to compare against.

289

- `customizer` (`Callable`, optional): Function to customize comparisons.

290

291

**Returns:**

292

- `Callable`: Comparator function.

293

294

### is_match

295

296

```python { .api }

297

def is_match(obj: Any, src: Any) -> bool

298

```

299

300

Performs a partial deep comparison between `obj` and `src` to determine if `obj` contains equivalent property values.

301

302

**Parameters:**

303

- `obj` (`Any`): Object to inspect.

304

- `src` (`Any`): Object of property values to match.

305

306

**Returns:**

307

- `bool`: `True` if `obj` matches, else `False`.

308

309

**Example:**

310

```python { .api }

311

from pydash import is_match

312

313

obj = {'a': 1, 'b': 2, 'c': 3}

314

is_match(obj, {'a': 1, 'c': 3})

315

# True

316

317

is_match(obj, {'a': 1, 'c': 4})

318

# False

319

```

320

321

### is_match_cmp

322

323

```python { .api }

324

def is_match_cmp(src: Any) -> Callable

325

```

326

327

Creates a comparator function for partial deep comparison.

328

329

**Parameters:**

330

- `src` (`Any`): Object of property values to match.

331

332

**Returns:**

333

- `Callable`: Comparator function.

334

335

### is_match_with

336

337

```python { .api }

338

def is_match_with(obj: Any, src: Any, customizer: Callable = None) -> bool

339

```

340

341

Like `is_match` except that it accepts `customizer` which is invoked to compare values.

342

343

**Parameters:**

344

- `obj` (`Any`): Object to inspect.

345

- `src` (`Any`): Object of property values to match.

346

- `customizer` (`Callable`, optional): Function to customize comparisons.

347

348

**Returns:**

349

- `bool`: `True` if `obj` matches, else `False`.

350

351

### is_match_with_cmp

352

353

```python { .api }

354

def is_match_with_cmp(src: Any, customizer: Callable = None) -> Callable

355

```

356

357

Creates a comparator function for custom partial deep comparison.

358

359

**Parameters:**

360

- `src` (`Any`): Object of property values to match.

361

- `customizer` (`Callable`, optional): Function to customize comparisons.

362

363

**Returns:**

364

- `Callable`: Comparator function.

365

366

## Type Checking Predicates

367

368

### is_associative

369

370

```python { .api }

371

def is_associative(value: Any) -> bool

372

```

373

374

Checks if `value` is an associative object (dict-like).

375

376

**Parameters:**

377

- `value` (`Any`): Value to check.

378

379

**Returns:**

380

- `bool`: `True` if `value` is associative, else `False`.

381

382

**Example:**

383

```python { .api }

384

from pydash import is_associative

385

386

is_associative({})

387

# True

388

389

is_associative({'a': 1})

390

# True

391

392

is_associative([])

393

# False

394

```

395

396

### is_boolean

397

398

```python { .api }

399

def is_boolean(value: Any) -> bool

400

```

401

402

Checks if `value` is a boolean primitive or object.

403

404

**Parameters:**

405

- `value` (`Any`): Value to check.

406

407

**Returns:**

408

- `bool`: `True` if `value` is a boolean, else `False`.

409

410

**Example:**

411

```python { .api }

412

from pydash import is_boolean

413

414

is_boolean(False)

415

# True

416

417

is_boolean(True)

418

# True

419

420

is_boolean(0)

421

# False

422

```

423

424

### is_builtin

425

426

```python { .api }

427

def is_builtin(value: Any) -> bool

428

```

429

430

Checks if `value` is a built-in function.

431

432

**Parameters:**

433

- `value` (`Any`): Value to check.

434

435

**Returns:**

436

- `bool`: `True` if `value` is a built-in function, else `False`.

437

438

**Example:**

439

```python { .api }

440

from pydash import is_builtin

441

442

is_builtin(len)

443

# True

444

445

is_builtin(lambda x: x)

446

# False

447

```

448

449

### is_date

450

451

```python { .api }

452

def is_date(value: Any) -> bool

453

```

454

455

Checks if `value` is a date object.

456

457

**Parameters:**

458

- `value` (`Any`): Value to check.

459

460

**Returns:**

461

- `bool`: `True` if `value` is a date object, else `False`.

462

463

**Example:**

464

```python { .api }

465

from pydash import is_date

466

from datetime import datetime

467

468

is_date(datetime.now())

469

# True

470

471

is_date('2021-01-01')

472

# False

473

```

474

475

### is_dict

476

477

```python { .api }

478

def is_dict(value: Any) -> bool

479

```

480

481

Checks if `value` is a dictionary.

482

483

**Parameters:**

484

- `value` (`Any`): Value to check.

485

486

**Returns:**

487

- `bool`: `True` if `value` is a dictionary, else `False`.

488

489

**Example:**

490

```python { .api }

491

from pydash import is_dict

492

493

is_dict({})

494

# True

495

496

is_dict({'a': 1})

497

# True

498

499

is_dict([])

500

# False

501

```

502

503

### is_error

504

505

```python { .api }

506

def is_error(value: Any) -> bool

507

```

508

509

Checks if `value` is an Error object.

510

511

**Parameters:**

512

- `value` (`Any`): Value to check.

513

514

**Returns:**

515

- `bool`: `True` if `value` is an error, else `False`.

516

517

**Example:**

518

```python { .api }

519

from pydash import is_error

520

521

is_error(Exception('Error'))

522

# True

523

524

is_error('Error')

525

# False

526

```

527

528

### is_float

529

530

```python { .api }

531

def is_float(value: Any) -> bool

532

```

533

534

Checks if `value` is a float.

535

536

**Parameters:**

537

- `value` (`Any`): Value to check.

538

539

**Returns:**

540

- `bool`: `True` if `value` is a float, else `False`.

541

542

**Example:**

543

```python { .api }

544

from pydash import is_float

545

546

is_float(1.5)

547

# True

548

549

is_float(1)

550

# False

551

```

552

553

### is_function

554

555

```python { .api }

556

def is_function(value: Any) -> bool

557

```

558

559

Checks if `value` is a function.

560

561

**Parameters:**

562

- `value` (`Any`): Value to check.

563

564

**Returns:**

565

- `bool`: `True` if `value` is a function, else `False`.

566

567

**Example:**

568

```python { .api }

569

from pydash import is_function

570

571

is_function(lambda x: x)

572

# True

573

574

is_function(len)

575

# True

576

577

is_function('string')

578

# False

579

```

580

581

### is_indexed

582

583

```python { .api }

584

def is_indexed(value: Any) -> bool

585

```

586

587

Checks if `value` is indexed (array-like with integer indexing).

588

589

**Parameters:**

590

- `value` (`Any`): Value to check.

591

592

**Returns:**

593

- `bool`: `True` if `value` is indexed, else `False`.

594

595

**Example:**

596

```python { .api }

597

from pydash import is_indexed

598

599

is_indexed([1, 2, 3])

600

# True

601

602

is_indexed((1, 2, 3))

603

# True

604

605

is_indexed({'a': 1})

606

# False

607

```

608

609

### is_instance_of

610

611

```python { .api }

612

def is_instance_of(value: Any, types: Union[type, Tuple[type, ...]]) -> bool

613

```

614

615

Checks if `value` is an instance of `types`.

616

617

**Parameters:**

618

- `value` (`Any`): Value to check.

619

- `types` (`Union[type, Tuple[type, ...]]`): Type or tuple of types to check against.

620

621

**Returns:**

622

- `bool`: `True` if `value` is an instance of `types`, else `False`.

623

624

**Example:**

625

```python { .api }

626

from pydash import is_instance_of

627

628

is_instance_of('hello', str)

629

# True

630

631

is_instance_of(42, (int, float))

632

# True

633

634

is_instance_of([], str)

635

# False

636

```

637

638

### is_instance_of_cmp

639

640

```python { .api }

641

def is_instance_of_cmp(types: Union[type, Tuple[type, ...]]) -> Callable

642

```

643

644

Creates a comparator function for instance checking.

645

646

**Parameters:**

647

- `types` (`Union[type, Tuple[type, ...]]`): Type or tuple of types to check against.

648

649

**Returns:**

650

- `Callable`: Comparator function.

651

652

### is_integer

653

654

```python { .api }

655

def is_integer(value: Any) -> bool

656

```

657

658

Checks if `value` is an integer.

659

660

**Parameters:**

661

- `value` (`Any`): Value to check.

662

663

**Returns:**

664

- `bool`: `True` if `value` is an integer, else `False`.

665

666

**Example:**

667

```python { .api }

668

from pydash import is_integer

669

670

is_integer(1)

671

# True

672

673

is_integer(1.0)

674

# False

675

676

is_integer('1')

677

# False

678

```

679

680

### is_iterable

681

682

```python { .api }

683

def is_iterable(value: Any) -> bool

684

```

685

686

Checks if `value` is iterable.

687

688

**Parameters:**

689

- `value` (`Any`): Value to check.

690

691

**Returns:**

692

- `bool`: `True` if `value` is iterable, else `False`.

693

694

**Example:**

695

```python { .api }

696

from pydash import is_iterable

697

698

is_iterable([1, 2, 3])

699

# True

700

701

is_iterable('hello')

702

# True

703

704

is_iterable(42)

705

# False

706

```

707

708

### is_list

709

710

```python { .api }

711

def is_list(value: Any) -> bool

712

```

713

714

Checks if `value` is a list.

715

716

**Parameters:**

717

- `value` (`Any`): Value to check.

718

719

**Returns:**

720

- `bool`: `True` if `value` is a list, else `False`.

721

722

**Example:**

723

```python { .api }

724

from pydash import is_list

725

726

is_list([1, 2, 3])

727

# True

728

729

is_list((1, 2, 3))

730

# False

731

```

732

733

### is_none

734

735

```python { .api }

736

def is_none(value: Any) -> bool

737

```

738

739

Checks if `value` is `None`.

740

741

**Parameters:**

742

- `value` (`Any`): Value to check.

743

744

**Returns:**

745

- `bool`: `True` if `value` is `None`, else `False`.

746

747

**Example:**

748

```python { .api }

749

from pydash import is_none

750

751

is_none(None)

752

# True

753

754

is_none(0)

755

# False

756

757

is_none('')

758

# False

759

```

760

761

### is_number

762

763

```python { .api }

764

def is_number(value: Any) -> bool

765

```

766

767

Checks if `value` is a number (int or float).

768

769

**Parameters:**

770

- `value` (`Any`): Value to check.

771

772

**Returns:**

773

- `bool`: `True` if `value` is a number, else `False`.

774

775

**Example:**

776

```python { .api }

777

from pydash import is_number

778

779

is_number(1)

780

# True

781

782

is_number(1.5)

783

# True

784

785

is_number('1')

786

# False

787

```

788

789

### is_object

790

791

```python { .api }

792

def is_object(value: Any) -> bool

793

```

794

795

Checks if `value` is an object (not a primitive type).

796

797

**Parameters:**

798

- `value` (`Any`): Value to check.

799

800

**Returns:**

801

- `bool`: `True` if `value` is an object, else `False`.

802

803

**Example:**

804

```python { .api }

805

from pydash import is_object

806

807

is_object({})

808

# True

809

810

is_object([])

811

# True

812

813

is_object('string')

814

# False

815

```

816

817

### is_reg_exp

818

819

```python { .api }

820

def is_reg_exp(value: Any) -> bool

821

```

822

823

Checks if `value` is a regular expression object.

824

825

**Parameters:**

826

- `value` (`Any`): Value to check.

827

828

**Returns:**

829

- `bool`: `True` if `value` is a regular expression, else `False`.

830

831

**Example:**

832

```python { .api }

833

from pydash import is_reg_exp

834

import re

835

836

is_reg_exp(re.compile(r'\d+'))

837

# True

838

839

is_reg_exp(r'\d+')

840

# False

841

```

842

843

### is_set

844

845

```python { .api }

846

def is_set(value: Any) -> bool

847

```

848

849

Checks if `value` is a set.

850

851

**Parameters:**

852

- `value` (`Any`): Value to check.

853

854

**Returns:**

855

- `bool`: `True` if `value` is a set, else `False`.

856

857

**Example:**

858

```python { .api }

859

from pydash import is_set

860

861

is_set({1, 2, 3})

862

# True

863

864

is_set([1, 2, 3])

865

# False

866

```

867

868

### is_string

869

870

```python { .api }

871

def is_string(value: Any) -> bool

872

```

873

874

Checks if `value` is a string.

875

876

**Parameters:**

877

- `value` (`Any`): Value to check.

878

879

**Returns:**

880

- `bool`: `True` if `value` is a string, else `False`.

881

882

**Example:**

883

```python { .api }

884

from pydash import is_string

885

886

is_string('hello')

887

# True

888

889

is_string(123)

890

# False

891

```

892

893

### is_tuple

894

895

```python { .api }

896

def is_tuple(value: Any) -> bool

897

```

898

899

Checks if `value` is a tuple.

900

901

**Parameters:**

902

- `value` (`Any`): Value to check.

903

904

**Returns:**

905

- `bool`: `True` if `value` is a tuple, else `False`.

906

907

**Example:**

908

```python { .api }

909

from pydash import is_tuple

910

911

is_tuple((1, 2, 3))

912

# True

913

914

is_tuple([1, 2, 3])

915

# False

916

```

917

918

## Content and State Predicates

919

920

### is_blank

921

922

```python { .api }

923

def is_blank(value: Any) -> bool

924

```

925

926

Checks if `value` is blank (empty string or whitespace only).

927

928

**Parameters:**

929

- `value` (`Any`): Value to check.

930

931

**Returns:**

932

- `bool`: `True` if `value` is blank, else `False`.

933

934

**Example:**

935

```python { .api }

936

from pydash import is_blank

937

938

is_blank('')

939

# True

940

941

is_blank(' ')

942

# True

943

944

is_blank('hello')

945

# False

946

```

947

948

### is_empty

949

950

```python { .api }

951

def is_empty(value: Any) -> bool

952

```

953

954

Checks if `value` is empty. A value is considered empty if it's falsey or an empty iterable.

955

956

**Parameters:**

957

- `value` (`Any`): Value to check.

958

959

**Returns:**

960

- `bool`: `True` if `value` is empty, else `False`.

961

962

**Example:**

963

```python { .api }

964

from pydash import is_empty

965

966

is_empty([])

967

# True

968

969

is_empty({})

970

# True

971

972

is_empty('')

973

# True

974

975

is_empty([1, 2, 3])

976

# False

977

```

978

979

### is_json

980

981

```python { .api }

982

def is_json(value: Any) -> bool

983

```

984

985

Checks if `value` is a valid JSON string.

986

987

**Parameters:**

988

- `value` (`Any`): Value to check.

989

990

**Returns:**

991

- `bool`: `True` if `value` is valid JSON, else `False`.

992

993

**Example:**

994

```python { .api }

995

from pydash import is_json

996

997

is_json('{"a": 1}')

998

# True

999

1000

is_json('[1, 2, 3]')

1001

# True

1002

1003

is_json('{invalid json}')

1004

# False

1005

```

1006

1007

## Numerical Predicates

1008

1009

### is_even

1010

1011

```python { .api }

1012

def is_even(value: Any) -> bool

1013

```

1014

1015

Checks if `value` is an even number.

1016

1017

**Parameters:**

1018

- `value` (`Any`): Value to check.

1019

1020

**Returns:**

1021

- `bool`: `True` if `value` is even, else `False`.

1022

1023

**Example:**

1024

```python { .api }

1025

from pydash import is_even

1026

1027

is_even(2)

1028

# True

1029

1030

is_even(3)

1031

# False

1032

1033

is_even(0)

1034

# True

1035

```

1036

1037

### is_odd

1038

1039

```python { .api }

1040

def is_odd(value: Any) -> bool

1041

```

1042

1043

Checks if `value` is an odd number.

1044

1045

**Parameters:**

1046

- `value` (`Any`): Value to check.

1047

1048

**Returns:**

1049

- `bool`: `True` if `value` is odd, else `False`.

1050

1051

**Example:**

1052

```python { .api }

1053

from pydash import is_odd

1054

1055

is_odd(1)

1056

# True

1057

1058

is_odd(2)

1059

# False

1060

1061

is_odd(3)

1062

# True

1063

```

1064

1065

### is_nan

1066

1067

```python { .api }

1068

def is_nan(value: Any) -> bool

1069

```

1070

1071

Checks if `value` is NaN (Not a Number).

1072

1073

**Parameters:**

1074

- `value` (`Any`): Value to check.

1075

1076

**Returns:**

1077

- `bool`: `True` if `value` is NaN, else `False`.

1078

1079

**Example:**

1080

```python { .api }

1081

from pydash import is_nan

1082

import math

1083

1084

is_nan(float('nan'))

1085

# True

1086

1087

is_nan(math.nan)

1088

# True

1089

1090

is_nan(1)

1091

# False

1092

```

1093

1094

### is_negative

1095

1096

```python { .api }

1097

def is_negative(value: Any) -> bool

1098

```

1099

1100

Checks if `value` is a negative number.

1101

1102

**Parameters:**

1103

- `value` (`Any`): Value to check.

1104

1105

**Returns:**

1106

- `bool`: `True` if `value` is negative, else `False`.

1107

1108

**Example:**

1109

```python { .api }

1110

from pydash import is_negative

1111

1112

is_negative(-1)

1113

# True

1114

1115

is_negative(0)

1116

# False

1117

1118

is_negative(1)

1119

# False

1120

```

1121

1122

### is_positive

1123

1124

```python { .api }

1125

def is_positive(value: Any) -> bool

1126

```

1127

1128

Checks if `value` is a positive number.

1129

1130

**Parameters:**

1131

- `value` (`Any`): Value to check.

1132

1133

**Returns:**

1134

- `bool`: `True` if `value` is positive, else `False`.

1135

1136

**Example:**

1137

```python { .api }

1138

from pydash import is_positive

1139

1140

is_positive(1)

1141

# True

1142

1143

is_positive(0)

1144

# False

1145

1146

is_positive(-1)

1147

# False

1148

```

1149

1150

### is_zero

1151

1152

```python { .api }

1153

def is_zero(value: Any) -> bool

1154

```

1155

1156

Checks if `value` is zero.

1157

1158

**Parameters:**

1159

- `value` (`Any`): Value to check.

1160

1161

**Returns:**

1162

- `bool`: `True` if `value` is zero, else `False`.

1163

1164

**Example:**

1165

```python { .api }

1166

from pydash import is_zero

1167

1168

is_zero(0)

1169

# True

1170

1171

is_zero(0.0)

1172

# True

1173

1174

is_zero(1)

1175

# False

1176

```

1177

1178

### in_range

1179

1180

```python { .api }

1181

def in_range(value: Union[int, float], start: Union[int, float] = 0, end: Union[int, float] = None) -> bool

1182

```

1183

1184

Checks if `value` is between `start` and up to, but not including, `end`.

1185

1186

**Parameters:**

1187

- `value` (`Union[int, float]`): Number to check.

1188

- `start` (`Union[int, float]`): Start of range. Defaults to `0`.

1189

- `end` (`Union[int, float]`, optional): End of range.

1190

1191

**Returns:**

1192

- `bool`: `True` if `value` is in range, else `False`.

1193

1194

**Example:**

1195

```python { .api }

1196

from pydash import in_range

1197

1198

in_range(3, 2, 4)

1199

# True

1200

1201

in_range(4, 8)

1202

# True (equivalent to in_range(4, 0, 8))

1203

1204

in_range(2, 2)

1205

# False (start = 2, end = 0, so range is empty)

1206

```

1207

1208

### in_range_cmp

1209

1210

```python { .api }

1211

def in_range_cmp(start: Union[int, float] = 0, end: Union[int, float] = None) -> Callable

1212

```

1213

1214

Creates a comparator function for range checking.

1215

1216

**Parameters:**

1217

- `start` (`Union[int, float]`): Start of range. Defaults to `0`.

1218

- `end` (`Union[int, float]`, optional): End of range.

1219

1220

**Returns:**

1221

- `Callable`: Comparator function.

1222

1223

## Sequence Analysis Predicates

1224

1225

### is_decreasing

1226

1227

```python { .api }

1228

def is_decreasing(value: Iterable) -> bool

1229

```

1230

1231

Checks if `value` is a monotonically decreasing sequence.

1232

1233

**Parameters:**

1234

- `value` (`Iterable`): Sequence to check.

1235

1236

**Returns:**

1237

- `bool`: `True` if sequence is decreasing, else `False`.

1238

1239

**Example:**

1240

```python { .api }

1241

from pydash import is_decreasing

1242

1243

is_decreasing([5, 4, 3, 2, 1])

1244

# True

1245

1246

is_decreasing([5, 4, 4, 2, 1])

1247

# True (allows equal values)

1248

1249

is_decreasing([5, 4, 5, 2, 1])

1250

# False

1251

```

1252

1253

### is_increasing

1254

1255

```python { .api }

1256

def is_increasing(value: Iterable) -> bool

1257

```

1258

1259

Checks if `value` is a monotonically increasing sequence.

1260

1261

**Parameters:**

1262

- `value` (`Iterable`): Sequence to check.

1263

1264

**Returns:**

1265

- `bool`: `True` if sequence is increasing, else `False`.

1266

1267

**Example:**

1268

```python { .api }

1269

from pydash import is_increasing

1270

1271

is_increasing([1, 2, 3, 4, 5])

1272

# True

1273

1274

is_increasing([1, 2, 2, 4, 5])

1275

# True (allows equal values)

1276

1277

is_increasing([1, 2, 1, 4, 5])

1278

# False

1279

```

1280

1281

### is_monotone

1282

1283

```python { .api }

1284

def is_monotone(value: Iterable, op: Callable = None) -> bool

1285

```

1286

1287

Checks if `value` is a monotonic sequence using the given operator.

1288

1289

**Parameters:**

1290

- `value` (`Iterable`): Sequence to check.

1291

- `op` (`Callable`, optional): Operator function for comparison.

1292

1293

**Returns:**

1294

- `bool`: `True` if sequence is monotonic, else `False`.

1295

1296

**Example:**

1297

```python { .api }

1298

from pydash import is_monotone

1299

import operator

1300

1301

is_monotone([1, 2, 3, 4, 5], operator.le)

1302

# True (non-decreasing)

1303

1304

is_monotone([5, 4, 3, 2, 1], operator.ge)

1305

# True (non-increasing)

1306

```

1307

1308

### is_monotone_cmp

1309

1310

```python { .api }

1311

def is_monotone_cmp(op: Callable) -> Callable

1312

```

1313

1314

Creates a comparator function for monotone checking.

1315

1316

**Parameters:**

1317

- `op` (`Callable`): Operator function for comparison.

1318

1319

**Returns:**

1320

- `Callable`: Comparator function.

1321

1322

### is_strictly_decreasing

1323

1324

```python { .api }

1325

def is_strictly_decreasing(value: Iterable) -> bool

1326

```

1327

1328

Checks if `value` is a strictly decreasing sequence (no equal adjacent elements).

1329

1330

**Parameters:**

1331

- `value` (`Iterable`): Sequence to check.

1332

1333

**Returns:**

1334

- `bool`: `True` if sequence is strictly decreasing, else `False`.

1335

1336

**Example:**

1337

```python { .api }

1338

from pydash import is_strictly_decreasing

1339

1340

is_strictly_decreasing([5, 4, 3, 2, 1])

1341

# True

1342

1343

is_strictly_decreasing([5, 4, 4, 2, 1])

1344

# False (has equal adjacent elements)

1345

```

1346

1347

### is_strictly_increasing

1348

1349

```python { .api }

1350

def is_strictly_increasing(value: Iterable) -> bool

1351

```

1352

1353

Checks if `value` is a strictly increasing sequence (no equal adjacent elements).

1354

1355

**Parameters:**

1356

- `value` (`Iterable`): Sequence to check.

1357

1358

**Returns:**

1359

- `bool`: `True` if sequence is strictly increasing, else `False`.

1360

1361

**Example:**

1362

```python { .api }

1363

from pydash import is_strictly_increasing

1364

1365

is_strictly_increasing([1, 2, 3, 4, 5])

1366

# True

1367

1368

is_strictly_increasing([1, 2, 2, 4, 5])

1369

# False (has equal adjacent elements)

1370

```

1371

1372

## Usage Examples

1373

1374

### Data Validation

1375

```python { .api }

1376

from pydash import is_string, is_number, is_empty, is_json, in_range

1377

1378

def validate_user_data(data):

1379

errors = []

1380

1381

# Check required fields

1382

if is_empty(data.get('name')):

1383

errors.append('Name is required')

1384

elif not is_string(data.get('name')):

1385

errors.append('Name must be a string')

1386

1387

# Validate age

1388

age = data.get('age')

1389

if not is_number(age):

1390

errors.append('Age must be a number')

1391

elif not in_range(age, 0, 150):

1392

errors.append('Age must be between 0 and 150')

1393

1394

# Validate JSON preferences

1395

prefs = data.get('preferences')

1396

if prefs and not is_json(prefs):

1397

errors.append('Preferences must be valid JSON')

1398

1399

return errors

1400

1401

# Usage

1402

user_data = {'name': 'John', 'age': 25, 'preferences': '{"theme": "dark"}'}

1403

errors = validate_user_data(user_data) # []

1404

```

1405

1406

### Type-Safe Operations

1407

```python { .api }

1408

from pydash import is_list, is_dict, is_string, is_number

1409

1410

def safe_process(data):

1411

if is_list(data):

1412

return [item * 2 if is_number(item) else item for item in data]

1413

elif is_dict(data):

1414

return {k: v.upper() if is_string(v) else v for k, v in data.items()}

1415

elif is_string(data):

1416

return data.upper()

1417

elif is_number(data):

1418

return data * 2

1419

else:

1420

return data

1421

1422

# Usage

1423

safe_process([1, 2, 'hello']) # [2, 4, 'hello']

1424

safe_process({'a': 'hello', 'b': 42}) # {'a': 'HELLO', 'b': 42}

1425

```

1426

1427

### Filtering with Complex Predicates

1428

```python { .api }

1429

from pydash import is_even, is_positive, gt, filter_

1430

1431

def advanced_filter(numbers):

1432

# Filter positive even numbers greater than 10

1433

return filter_(numbers, lambda x: is_even(x) and is_positive(x) and gt(x, 10))

1434

1435

numbers = [-5, 2, 12, -8, 15, 20, 3]

1436

result = advanced_filter(numbers) # [12, 20]

1437

```

1438

1439

### Sequence Analysis

1440

```python { .api }

1441

from pydash import is_increasing, is_decreasing, is_strictly_increasing

1442

1443

def analyze_trend(data):

1444

if is_strictly_increasing(data):

1445

return "Strong upward trend"

1446

elif is_increasing(data):

1447

return "Upward trend (with plateaus)"

1448

elif is_strictly_decreasing(data):

1449

return "Strong downward trend"

1450

elif is_decreasing(data):

1451

return "Downward trend (with plateaus)"

1452

else:

1453

return "No clear trend"

1454

1455

# Usage

1456

stock_prices = [100, 105, 110, 115, 120]

1457

trend = analyze_trend(stock_prices) # "Strong upward trend"

1458

```

1459

1460

### Custom Comparators

1461

```python { .api }

1462

from pydash import is_match_cmp, filter_

1463

1464

# Create reusable predicate functions

1465

is_adult = lambda person: person.get('age', 0) >= 18

1466

is_active_user = is_match_cmp({'status': 'active'})

1467

is_premium = is_match_cmp({'plan': 'premium'})

1468

1469

users = [

1470

{'name': 'John', 'age': 25, 'status': 'active', 'plan': 'basic'},

1471

{'name': 'Jane', 'age': 17, 'status': 'active', 'plan': 'premium'},

1472

{'name': 'Bob', 'age': 30, 'status': 'inactive', 'plan': 'premium'}

1473

]

1474

1475

# Filter using composed predicates

1476

active_adults = filter_(users, lambda u: is_adult(u) and is_active_user(u))

1477

premium_users = filter_(users, is_premium)

1478

```

1479

1480

This Predicates module provides comprehensive testing and validation capabilities with 56 functions covering all aspects of type checking, value comparison, content validation, and sequence analysis for robust data validation and filtering operations.