Skip to content

Commit

Permalink
Add constant sequences (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
VascoSch92 authored Jan 3, 2024
2 parents 0f09783 + 6a1722c commit c3ee435
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The version is represented by three digits: a.b.c.

ENHANCEMENT:
- sequentium.github.workflows.release.yml: workflow for automatic upload on pypi
- sequentium.sequence.sequences.integer.periodic_generalised.py: added class for representing constant sequences

---
## [0.0.1] - 2024-01-02
Expand Down
17 changes: 9 additions & 8 deletions sequence/SEQUENCES_LIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ List of implemented integer sequences.

List of implemented generalised integer sequences.

| Sequence Name | Sequence class name(s) | Reference |
|---------------------------------|-----------------------------|--------------------------------------------------------------------|
| The generalised Nexus numbers | `GeneralisedNexusNumbers` | https://mathworld.wolfram.com/NexusNumber.html |
| High order Fibonacci numbers | `HighOrderFibonacciNumbers` | https://en.wikipedia.org/wiki/Generalizations_of_Fibonacci_numbers |
| The Lucas sequence U_n | `LucasSequenceU` | https://en.wikipedia.org/wiki/Lucas_sequence |
| The Lucas sequence V_n | `LucasSequenceV` | https://en.wikipedia.org/wiki/Lucas_sequence |
| The primes of a given sequence | `PrimesOfSequence` | - |
| The polygonal numbers | `PolygonalNumbers` | https://en.m.wikipedia.org/wiki/Polygonal_number |
| Sequence Name | Sequence class name(s) | Reference |
|--------------------------------|-----------------------------|--------------------------------------------------------------------|
| The constant sequence | `ConstantSequence` | - |
| The generalised Nexus numbers | `GeneralisedNexusNumbers` | https://mathworld.wolfram.com/NexusNumber.html |
| High order Fibonacci numbers | `HighOrderFibonacciNumbers` | https://en.wikipedia.org/wiki/Generalizations_of_Fibonacci_numbers |
| The Lucas sequence U_n | `LucasSequenceU` | https://en.wikipedia.org/wiki/Lucas_sequence |
| The Lucas sequence V_n | `LucasSequenceV` | https://en.wikipedia.org/wiki/Lucas_sequence |
| The primes of a given sequence | `PrimesOfSequence` | - |
| The polygonal numbers | `PolygonalNumbers` | https://en.m.wikipedia.org/wiki/Polygonal_number |


1 change: 1 addition & 0 deletions sequence/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from sequence.sequences.integer.explicit import *
from sequence.sequences.integer.finite import *
from sequence.sequences.integer.periodic import *
from sequence.sequences.integer.periodic_generalised import *
from sequence.sequences.integer.property_defined import *
from sequence.sequences.integer.recursive import *

Expand Down
2 changes: 1 addition & 1 deletion sequence/sequences/integer/explicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sequence.core.infinite_type import Explicit
from sequence.core.mixin import MonotonicIncreasingMixin
from sequence.sequences.integer.explicit_generalised_sequences import GeneralisedNexusNumbers, PolygonalNumbers
from sequence.sequences.integer.explicit_generalised import GeneralisedNexusNumbers, PolygonalNumbers


class A000027(Explicit):
Expand Down
16 changes: 16 additions & 0 deletions sequence/sequences/integer/periodic_generalised.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from sequence.core.finite_type import Periodic
from sequence.core.utils.validation import validate_positive_integer


class ConstantSequence(Periodic):
"""
The class represent a constant sequence of a given value
Attributes:
value (int): the values that the constant sequence is taking
"""
sequence_name = 'value sequence'

def __init__(self, value: int) -> None:
super().__init__(_period=1)
self.sequence = [validate_positive_integer(integer=value)]
2 changes: 1 addition & 1 deletion sequence/sequences/integer/property_defined.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from sequence.core.infinite_type import PropertyDefined
from sequence.core.utils.functions import is_prime
from sequence.sequences.integer.explicit import A000027
from sequence.sequences.integer.property_defined_generalised_sequences import PrimesOfSequence
from sequence.sequences.integer.property_defined_generalised import PrimesOfSequence


class A000040(PrimesOfSequence):
Expand Down
2 changes: 1 addition & 1 deletion sequence/sequences/integer/recursive.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Tuple, List, ClassVar
from sequence.core.mixin import AlmostMonotonicIncreasingMixin
from sequence.core.infinite_type import Recursive
from sequence.sequences.integer.recursive_generalised_sequences import (
from sequence.sequences.integer.recursive_generalised import (
HighOrderFibonacciNumbers,
LucasSequenceU,
LucasSequenceV,
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_meta/test_cases.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
TEST_CASES_ORDER_SCRIPT = [
('sequence/sequences/integer/explicit.py', r'^A\d{6}$'),
('sequence/sequences/integer/explicit_generalised_sequences.py', None),
('sequence/sequences/integer/explicit_generalised.py', None),
('sequence/sequences/integer/finite.py', r'^A\d{6}$'),
('sequence/sequences/integer/periodic.py', r'^A\d{6}$'),
('tests/tests_integer_sequences/test_periodic.py', None),
('sequence/sequences/integer/property_defined.py', r'^A\d{6}$'),
('sequence/sequences/integer/property_defined_generalised_sequences.py', None),
('sequence/sequences/integer/property_defined_generalised.py', None),
('sequence/sequences/integer/recursive.py', r'^A\d{6}$'),
('sequence/sequences/integer/recursive_generalised_sequences.py', None),
('sequence/sequences/integer/recursive_generalised.py', None),
('tests/tests_integer_sequences/test_explicit.py', None),
('tests/tests_integer_sequences/test_finite.py', None),
('tests/tests_integer_sequences/test_periodic.py', None),
Expand Down

0 comments on commit c3ee435

Please sign in to comment.