diff --git a/.vscode/settings.json b/.vscode/settings.json index 99693c128..4f40b013e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,7 +7,8 @@ }, "search.exclude": { "**/.venv/": true, - "**/bazel-*/**": true + "**/bazel-*/**": true, + "**/reference/**/*.md": true }, "files.watcherExclude": { "**/.venv/**": true, diff --git a/docs/BUILD b/docs/BUILD index 9f9eddd24..4173b8758 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -15,3 +15,8 @@ py_test( "//temporian", ], ) + +filegroup( + name = "reference", + srcs = glob(["src/reference/**/*.md"]), +) diff --git a/docs/gen_ref_pages.py b/docs/gen_ref_pages.py index 5c5c0f497..e5a32d042 100644 --- a/docs/gen_ref_pages.py +++ b/docs/gen_ref_pages.py @@ -1,111 +1,58 @@ """ Generate the code reference pages. -Source: https://mkdocstrings.github.io/recipes/ +This script traverses the markdown files under docs/src/reference and for each: +- If the file is not empty it will appear in the docs as-is (after mkdocstrings + has filled in any identifiers inside it). +- If the file is empty, it is interpreted as a placeholder for the top-level + symbol with its same name and its reference page is generated in its same + path. E.g., if an empty docs/src/reference/temporian/io/to_csv.md file + exists, the reference page for `temporian.to_csv` will be generated under + reference/temporian/io/to_csv/ in the docs. + +Related: https://mkdocstrings.github.io/recipes/ """ from pathlib import Path -from typing import Set, Tuple import mkdocs_gen_files nav = mkdocs_gen_files.Nav() -SRC_PATH = Path("temporian") +REFERENCE = Path("docs/src/reference") -# Stores symbol and path of each public API member -members: Set[Tuple[str, Path]] = set() +# Sort files by depth and name for alphabetical order and subdirs at the bottom +paths = sorted( + REFERENCE.rglob("*.md"), key=lambda p: str(len(p.parts)) + str(p) +) -non_parsable_imports = [] +non_empty_files = [] -# We need to be able to parse other files to allow wildcard imports -# Storing pair of (prefix, path) to parse in a stack -files_to_parse = [(None, SRC_PATH / "__init__.py")] +for path in paths: + path = Path(path) + ref_path = path.relative_to(REFERENCE) + nav_path = ref_path.with_suffix("") + full_ref_path = "reference" / ref_path -while files_to_parse: - prefix, file = files_to_parse.pop() + nav[list(nav_path.parts)] = ref_path.as_posix() - with open(file, "r", encoding="utf8") as f: - lines = f.read().splitlines() + # If file is empty we assume it's a top-level symbol and auto + # generate the mkdocstring identifier for it + if path.stat().st_size == 0: + with mkdocs_gen_files.open(full_ref_path, "w") as fd: + ident = "temporian." + nav_path.name + fd.write(f"::: {ident}") - for line in lines: - words = line.split(" ") + else: + non_empty_files.append(str(ref_path)) - # It is an import statement - if words[0] == "from": - # Remove trailing "as " if it exists and save symbol's name - symbol = None - if words[-2] == "as": - # If symbol was renamed to a private name, skip it - if words[-1].startswith("_"): - continue - - symbol = words[-1] - words = words[:-2] - - # `words` is now in the form "from module.submodule import symbol" - if words[-2] == "import": - name = words[-1] - - # We only allow wildcard imports from modules explicitly named - # api_symbols to prevent unwanted names in the public API - if name == "*": - module_path = Path(words[1].replace(".", "/")).with_suffix( - ".py" - ) - if module_path.stem == "api_symbols": - new_prefix = ( - (prefix + ".") if prefix else "" - ) + module_path.parent.name - files_to_parse.append((new_prefix, module_path)) - continue - - non_parsable_imports.append(line) - continue - - # If symbol wasn't renamed, use its imported name - if symbol is None: - symbol = name - - path = Path(words[1].replace(".", "/")) / name - - if prefix: - symbol = prefix + "." + symbol - - members.add((symbol, path)) - - # It is a multi-symbol import statement, error will be raised below - else: - non_parsable_imports.append(line) - -if non_parsable_imports: - raise RuntimeError( - "`gen_ref_pages` failed to parse the following import statements in" - f" the top-level __init__.py file: {non_parsable_imports}. Import" - " statements in the top-level module must import a single symbol each," - " in the form `from import `, `from import" - " as `, or `from import *`." - ) - -nav["temporian"] = "index.md" - -for symbol, path in sorted(members): - symbol_path = Path(symbol.replace(".", "/")) - symbol_name = symbol_path.name - src_path = SRC_PATH / symbol_name - - doc_path = SRC_PATH / symbol_path - parts = list(doc_path.parts) - doc_path = doc_path.with_suffix(".md") - full_doc_path = Path("reference", doc_path) - - nav[parts] = doc_path.as_posix() - - with mkdocs_gen_files.open(full_doc_path, "w") as fd: - identifier = ".".join(list(src_path.parts)) - print("::: " + identifier, file=fd) - - mkdocs_gen_files.set_edit_path(full_doc_path, path) +print( + ( + "These md files in docs/src/reference are not empty and will be" + " rendered my mkdocs as-is:" + ), + non_empty_files, +) with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file: nav_file.writelines(nav.build_literate_nav()) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 7855ced07..50679110a 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -59,7 +59,7 @@ plugins: scripts: # Generate the index page from the README.md. - gen_index.py - # Generate the reference pages from docstrings. + # Generate the ref pages and navigation. - gen_ref_pages.py - literate-nav: nav_file: SUMMARY.md diff --git a/docs/src/reference/index.md b/docs/src/reference/index.md index 55a8a43d0..f9dcba1ec 100644 --- a/docs/src/reference/index.md +++ b/docs/src/reference/index.md @@ -18,7 +18,7 @@ Check the index on the left for a more detailed description of any symbol. | ----------------------------------------- | -------------------------------------------------------------------------------------- | | [`tp.evaluate()`][temporian.evaluate] | Evaluates [`Nodes`][temporian.Node] on [`EventSets`][temporian.EventSet]. | | [`tp.plot()`][temporian.plot] | Plots [`EventSets`][temporian.EventSet]. | -| [`tp.event_set()`][temporian.event_set] | Creates an [`EventSet`][temporian.EventSet] from arrays (list, numpy, pandas). | +| [`tp.event_set()`][temporian.event_set] | Creates an [`EventSet`][temporian.EventSet] from arrays (lists, NumPy, Pandas Series.) | | [`tp.input_node()`][temporian.input_node] | Creates an input [`Node`][temporian.Node], that can be used to feed data into a graph. | ## Input/output @@ -60,11 +60,11 @@ Check the index on the left for a more detailed description of any symbol. ### Binary operators -| Symbols | Description | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | -| [`tp.add()`][temporian.add] [`tp.subtract()`][temporian.subtract] [`tp.multiply()`][temporian.multiply] [`tp.divide()`][temporian.divide] [`tp.floordiv()`][temporian.floordiv] [`tp.modulo()`][temporian.modulo] [`tp.power()`][temporian.power] | Compute an arithmetic binary operation between two [`Nodes`][temporian.Node]. | -| [`tp.equal()`][temporian.equal] [`tp.not_equal()`][temporian.not_equal] [`tp.greater()`][temporian.greater] [`tp.greater_equal()`][temporian.greater_equal] [`tp.less()`][temporian.less] [`tp.less_equal()`][temporian.less_equal] | Compute a relational binary operator between two [`Nodes`][temporian.Node]. | -| [`tp.logical_and()`][temporian.logical_and] [`tp.logical_or()`][temporian.logical_or] [`tp.logical_xor()`][temporian.logical_xor] | Compute a logical binary operation between two [`Nodes`][temporian.Node]. | +| Symbols | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | +| [`tp.add()`][temporian.add] [`tp.subtract()`][temporian.subtract] [`tp.multiply()`][temporian.multiply] [`tp.divide()`][temporian.divide] [`tp.floordiv()`][temporian.floordiv] [`tp.modulo()`][temporian.modulo] [`tp.power()`][temporian.power] | Compute an arithmetic binary operation between two [`Nodes`][temporian.Node]. Aliases for `+`, `-`, `\*`, `/`, etc. | +| [`tp.equal()`][temporian.equal] [`tp.not_equal()`][temporian.not_equal] [`tp.greater()`][temporian.greater] [`tp.greater_equal()`][temporian.greater_equal] [`tp.less()`][temporian.less] [`tp.less_equal()`][temporian.less_equal] | Compute a relational binary operator between two [`Nodes`][temporian.Node]. | +| [`tp.logical_and()`][temporian.logical_and] [`tp.logical_or()`][temporian.logical_or] [`tp.logical_xor()`][temporian.logical_xor] | Compute a logical binary operation between two [`Nodes`][temporian.Node]. | ### Unary operators diff --git a/docs/src/reference/temporian/EventSet.md b/docs/src/reference/temporian/EventSet.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/Node.md b/docs/src/reference/temporian/Node.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/Schema.md b/docs/src/reference/temporian/Schema.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/dtypes/bool_.md b/docs/src/reference/temporian/dtypes/bool_.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/dtypes/float32.md b/docs/src/reference/temporian/dtypes/float32.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/dtypes/float64.md b/docs/src/reference/temporian/dtypes/float64.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/dtypes/int32.md b/docs/src/reference/temporian/dtypes/int32.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/dtypes/int64.md b/docs/src/reference/temporian/dtypes/int64.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/dtypes/str_.md b/docs/src/reference/temporian/dtypes/str_.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/duration.md b/docs/src/reference/temporian/duration.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/evaluate.md b/docs/src/reference/temporian/evaluate.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/event_set.md b/docs/src/reference/temporian/event_set.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/input_node.md b/docs/src/reference/temporian/input_node.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/io/from_csv.md b/docs/src/reference/temporian/io/from_csv.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/io/from_pandas.md b/docs/src/reference/temporian/io/from_pandas.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/io/to_csv.md b/docs/src/reference/temporian/io/to_csv.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/io/to_pandas.md b/docs/src/reference/temporian/io/to_pandas.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/add_index.md b/docs/src/reference/temporian/operators/add_index.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/begin.md b/docs/src/reference/temporian/operators/begin.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/add.md b/docs/src/reference/temporian/operators/binary/add.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/divide.md b/docs/src/reference/temporian/operators/binary/divide.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/equal.md b/docs/src/reference/temporian/operators/binary/equal.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/floordiv.md b/docs/src/reference/temporian/operators/binary/floordiv.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/greater.md b/docs/src/reference/temporian/operators/binary/greater.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/greater_equal.md b/docs/src/reference/temporian/operators/binary/greater_equal.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/less.md b/docs/src/reference/temporian/operators/binary/less.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/less_equal.md b/docs/src/reference/temporian/operators/binary/less_equal.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/logical_and.md b/docs/src/reference/temporian/operators/binary/logical_and.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/logical_or.md b/docs/src/reference/temporian/operators/binary/logical_or.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/logical_xor.md b/docs/src/reference/temporian/operators/binary/logical_xor.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/modulo.md b/docs/src/reference/temporian/operators/binary/modulo.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/multiply.md b/docs/src/reference/temporian/operators/binary/multiply.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/not_equal.md b/docs/src/reference/temporian/operators/binary/not_equal.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/power.md b/docs/src/reference/temporian/operators/binary/power.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/binary/subtract.md b/docs/src/reference/temporian/operators/binary/subtract.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/calendar/calendar_day_of_month.md b/docs/src/reference/temporian/operators/calendar/calendar_day_of_month.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/calendar/calendar_day_of_week.md b/docs/src/reference/temporian/operators/calendar/calendar_day_of_week.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/calendar/calendar_day_of_year.md b/docs/src/reference/temporian/operators/calendar/calendar_day_of_year.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/calendar/calendar_hour.md b/docs/src/reference/temporian/operators/calendar/calendar_hour.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/calendar/calendar_iso_week.md b/docs/src/reference/temporian/operators/calendar/calendar_iso_week.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/calendar/calendar_minute.md b/docs/src/reference/temporian/operators/calendar/calendar_minute.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/calendar/calendar_month.md b/docs/src/reference/temporian/operators/calendar/calendar_month.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/calendar/calendar_second.md b/docs/src/reference/temporian/operators/calendar/calendar_second.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/calendar/calendar_year.md b/docs/src/reference/temporian/operators/calendar/calendar_year.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/cast.md b/docs/src/reference/temporian/operators/cast.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/drop_index.md b/docs/src/reference/temporian/operators/drop_index.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/end.md b/docs/src/reference/temporian/operators/end.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/filter.md b/docs/src/reference/temporian/operators/filter.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/glue.md b/docs/src/reference/temporian/operators/glue.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/lag.md b/docs/src/reference/temporian/operators/lag.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/leak.md b/docs/src/reference/temporian/operators/leak.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/prefix.md b/docs/src/reference/temporian/operators/prefix.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/propagate.md b/docs/src/reference/temporian/operators/propagate.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/rename.md b/docs/src/reference/temporian/operators/rename.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/resample.md b/docs/src/reference/temporian/operators/resample.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/add_scalar.md b/docs/src/reference/temporian/operators/scalar/add_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/divide_scalar.md b/docs/src/reference/temporian/operators/scalar/divide_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/equal_scalar.md b/docs/src/reference/temporian/operators/scalar/equal_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/floordiv_scalar.md b/docs/src/reference/temporian/operators/scalar/floordiv_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/greater_equal_scalar.md b/docs/src/reference/temporian/operators/scalar/greater_equal_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/greater_scalar.md b/docs/src/reference/temporian/operators/scalar/greater_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/less_equal_scalar.md b/docs/src/reference/temporian/operators/scalar/less_equal_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/less_scalar.md b/docs/src/reference/temporian/operators/scalar/less_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/modulo_scalar.md b/docs/src/reference/temporian/operators/scalar/modulo_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/multiply_scalar.md b/docs/src/reference/temporian/operators/scalar/multiply_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/not_equal_scalar.md b/docs/src/reference/temporian/operators/scalar/not_equal_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/power_scalar.md b/docs/src/reference/temporian/operators/scalar/power_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/scalar/subtract_scalar.md b/docs/src/reference/temporian/operators/scalar/subtract_scalar.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/select.md b/docs/src/reference/temporian/operators/select.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/set_index.md b/docs/src/reference/temporian/operators/set_index.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/since_last.md b/docs/src/reference/temporian/operators/since_last.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/tick.md b/docs/src/reference/temporian/operators/tick.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/unary/abs.md b/docs/src/reference/temporian/operators/unary/abs.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/unary/invert.md b/docs/src/reference/temporian/operators/unary/invert.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/unary/isnan.md b/docs/src/reference/temporian/operators/unary/isnan.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/unary/log.md b/docs/src/reference/temporian/operators/unary/log.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/unary/notnan.md b/docs/src/reference/temporian/operators/unary/notnan.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/unique_timestamps.md b/docs/src/reference/temporian/operators/unique_timestamps.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/window/cumsum.md b/docs/src/reference/temporian/operators/window/cumsum.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/window/moving_count.md b/docs/src/reference/temporian/operators/window/moving_count.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/window/moving_max.md b/docs/src/reference/temporian/operators/window/moving_max.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/window/moving_min.md b/docs/src/reference/temporian/operators/window/moving_min.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/window/moving_standard_deviation.md b/docs/src/reference/temporian/operators/window/moving_standard_deviation.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/window/moving_sum.md b/docs/src/reference/temporian/operators/window/moving_sum.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/operators/window/simple_moving_average.md b/docs/src/reference/temporian/operators/window/simple_moving_average.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/plot.md b/docs/src/reference/temporian/plot.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/serialization/load.md b/docs/src/reference/temporian/serialization/load.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/src/reference/temporian/serialization/save.md b/docs/src/reference/temporian/serialization/save.md new file mode 100644 index 000000000..e69de29bb diff --git a/temporian/BUILD b/temporian/BUILD index ed687b122..eea910318 100644 --- a/temporian/BUILD +++ b/temporian/BUILD @@ -14,16 +14,37 @@ py_library( "//temporian/core:evaluation", "//temporian/core:graph", "//temporian/core:operator_lib", + "//temporian/core:serialization", + "//temporian/core/data:dtype", "//temporian/core/data:duration", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:api_symbols", - "//temporian/core/operators:api_symbols", + "//temporian/core/operators:add_index", "//temporian/core/operators:base", - "//temporian/core/serialization:api_symbols", + "//temporian/core/operators:begin", + "//temporian/core/operators:cast", + "//temporian/core/operators:drop_index", + "//temporian/core/operators:end", + "//temporian/core/operators:filter", + "//temporian/core/operators:glue", + "//temporian/core/operators:lag", + "//temporian/core/operators:leak", + "//temporian/core/operators:prefix", + "//temporian/core/operators:propagate", + "//temporian/core/operators:rename", + "//temporian/core/operators:resample", + "//temporian/core/operators:select", + "//temporian/core/operators:since_last", + "//temporian/core/operators:tick", + "//temporian/core/operators:unary", + "//temporian/core/operators:unique_timestamps", + "//temporian/core/operators/binary", + "//temporian/core/operators/calendar", + "//temporian/core/operators/scalar", + "//temporian/core/operators/window", "//temporian/implementation/numpy/data:event_set", "//temporian/implementation/numpy/data:io", "//temporian/implementation/numpy/data:plotter", - "//temporian/io:api_symbols", + "//temporian/io", ], ) diff --git a/temporian/__init__.py b/temporian/__init__.py index 49475ac49..43f48e1b1 100644 --- a/temporian/__init__.py +++ b/temporian/__init__.py @@ -12,43 +12,41 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Temporian.""" +# type: ignore +# pylint: disable=wrong-import-position +# pylint: disable=line-too-long +# pylint: disable=no-name-in-module +# fmt: off -# NOTE: The API reference documentation reads this file and expects a single -# import per line. Do not import several symbols from the same module in a -# single line. Do not allow import to break lines. +"""Temporian.""" # NOTE: If you need to import something here that isn't part of the public API, -# and therefore shouldn't show up in the documentation, import it with a private -# name: +# import it with a private name (and delete the symbol if possible): # from temporian.module import submodule as _submodule +# del _submodule -# NOTE: Wildcard imports (*) are treated and parsed as part of root-level -# imports, so same rules apply to modules imported with a wildcard. -# Also: -# - Wildcard imports are only allowed from modules explicitly called api_symbols -# - Modules imported with wildcards are shown as subfolders in the docs, with -# the folder's name being the api_symbols.py file's parent's name. +__version__ = "0.1.1" -# pylint: disable=wrong-import-position -# pylint: disable=line-too-long - -__version__ = "0.0.1" - -# Register the ops definitions and implementations. -from temporian.core.operator_lib import registered_operators as _ops +# Register all operator implementations from temporian.implementation.numpy import operators as _impls +del _impls -# Actual API -# ========== +# ================== # +# PUBLIC API SYMBOLS # +# ================== # -# Nodes and related +# Nodes from temporian.core.data.node import Node from temporian.core.data.node import input_node # Dtypes -from temporian.core.data.dtypes.api_symbols import * +from temporian.core.data.dtype import float64 +from temporian.core.data.dtype import float32 +from temporian.core.data.dtype import int32 +from temporian.core.data.dtype import int64 +from temporian.core.data.dtype import bool_ +from temporian.core.data.dtype import str_ # Schema from temporian.core.data.schema import Schema @@ -56,21 +54,116 @@ # Durations from temporian.core.data import duration -# Event set +# EventSets from temporian.implementation.numpy.data.event_set import EventSet from temporian.implementation.numpy.data.io import event_set -# Graph serialization -from temporian.core.serialization.api_symbols import * +# Serialization +from temporian.core.serialization import load +from temporian.core.serialization import save # Graph execution from temporian.core.evaluation import evaluate -# Operators -from temporian.core.operators.api_symbols import * - # IO -from temporian.io.api_symbols import * +from temporian.io.csv import to_csv +from temporian.io.csv import from_csv +from temporian.io.pandas import to_pandas +from temporian.io.pandas import from_pandas # Plotting from temporian.implementation.numpy.data.plotter import plot + + +# --- OPERATORS --- + +from temporian.core.operators.add_index import add_index +from temporian.core.operators.add_index import set_index +from temporian.core.operators.begin import begin +from temporian.core.operators.cast import cast +from temporian.core.operators.drop_index import drop_index +from temporian.core.operators.end import end +from temporian.core.operators.filter import filter +from temporian.core.operators.glue import glue +from temporian.core.operators.lag import lag +from temporian.core.operators.leak import leak +from temporian.core.operators.prefix import prefix +from temporian.core.operators.propagate import propagate +from temporian.core.operators.rename import rename +from temporian.core.operators.resample import resample +from temporian.core.operators.select import select +from temporian.core.operators.since_last import since_last +from temporian.core.operators.tick import tick +from temporian.core.operators.unique_timestamps import unique_timestamps + +# Binary operators +from temporian.core.operators.binary.arithmetic import add +from temporian.core.operators.binary.arithmetic import subtract +from temporian.core.operators.binary.arithmetic import multiply +from temporian.core.operators.binary.arithmetic import divide +from temporian.core.operators.binary.arithmetic import floordiv +from temporian.core.operators.binary.arithmetic import modulo +from temporian.core.operators.binary.arithmetic import power + +from temporian.core.operators.binary.relational import equal +from temporian.core.operators.binary.relational import not_equal +from temporian.core.operators.binary.relational import greater +from temporian.core.operators.binary.relational import greater_equal +from temporian.core.operators.binary.relational import less +from temporian.core.operators.binary.relational import less_equal + +from temporian.core.operators.binary.logical import logical_and +from temporian.core.operators.binary.logical import logical_or +from temporian.core.operators.binary.logical import logical_xor + +# Calendar operators +from temporian.core.operators.calendar.day_of_month import calendar_day_of_month +from temporian.core.operators.calendar.day_of_week import calendar_day_of_week +from temporian.core.operators.calendar.day_of_year import calendar_day_of_year +from temporian.core.operators.calendar.hour import calendar_hour +from temporian.core.operators.calendar.iso_week import calendar_iso_week +from temporian.core.operators.calendar.minute import calendar_minute +from temporian.core.operators.calendar.month import calendar_month +from temporian.core.operators.calendar.second import calendar_second +from temporian.core.operators.calendar.year import calendar_year + +# Scalar operators +from temporian.core.operators.scalar.arithmetic_scalar import add_scalar +from temporian.core.operators.scalar.arithmetic_scalar import subtract_scalar +from temporian.core.operators.scalar.arithmetic_scalar import multiply_scalar +from temporian.core.operators.scalar.arithmetic_scalar import divide_scalar +from temporian.core.operators.scalar.arithmetic_scalar import floordiv_scalar +from temporian.core.operators.scalar.arithmetic_scalar import modulo_scalar +from temporian.core.operators.scalar.arithmetic_scalar import power_scalar + +from temporian.core.operators.scalar.relational_scalar import equal_scalar +from temporian.core.operators.scalar.relational_scalar import not_equal_scalar +from temporian.core.operators.scalar.relational_scalar import greater_equal_scalar +from temporian.core.operators.scalar.relational_scalar import greater_scalar +from temporian.core.operators.scalar.relational_scalar import less_equal_scalar +from temporian.core.operators.scalar.relational_scalar import less_scalar + +# Unary operators +from temporian.core.operators.unary import invert +from temporian.core.operators.unary import isnan +from temporian.core.operators.unary import notnan +from temporian.core.operators.unary import abs +from temporian.core.operators.unary import log + +# Window operators +from temporian.core.operators.window.simple_moving_average import simple_moving_average +from temporian.core.operators.window.moving_standard_deviation import moving_standard_deviation +from temporian.core.operators.window.moving_sum import cumsum +from temporian.core.operators.window.moving_sum import moving_sum +from temporian.core.operators.window.moving_count import moving_count +from temporian.core.operators.window.moving_min import moving_min +from temporian.core.operators.window.moving_max import moving_max + +# Remove automatic file tree symbols from public API +# pylint: disable=undefined-variable +del proto +del io +del core +del utils +del implementation +# pylint: enable=undefined-variable diff --git a/temporian/core/BUILD b/temporian/core/BUILD index 8ff2ade5e..396c6adae 100644 --- a/temporian/core/BUILD +++ b/temporian/core/BUILD @@ -45,3 +45,11 @@ py_library( "//temporian/core/operators:base", ], ) + +py_library( + name = "serialization", + srcs = ["serialization.py"], + srcs_version = "PY3", + deps = [ + ], +) diff --git a/temporian/core/data/BUILD b/temporian/core/data/BUILD index b30114259..dc982249a 100644 --- a/temporian/core/data/BUILD +++ b/temporian/core/data/BUILD @@ -17,8 +17,8 @@ py_library( srcs = ["node.py"], srcs_version = "PY3", deps = [ + ":dtype", ":schema", - "//temporian/core/data/dtypes:dtype", "//temporian/utils:string", ], ) @@ -28,7 +28,7 @@ py_library( srcs = ["schema.py"], srcs_version = "PY3", deps = [ - "//temporian/core/data/dtypes:dtype", + ":dtype", ], ) @@ -49,3 +49,9 @@ py_library( ":duration", ], ) + +py_library( + name = "dtype", + srcs = ["dtype.py"], + srcs_version = "PY3", +) diff --git a/temporian/core/data/dtypes/dtype.py b/temporian/core/data/dtype.py similarity index 94% rename from temporian/core/data/dtypes/dtype.py rename to temporian/core/data/dtype.py index 34a47f008..872f8fa6d 100644 --- a/temporian/core/data/dtypes/dtype.py +++ b/temporian/core/data/dtype.py @@ -108,9 +108,21 @@ def check_is_valid_index_dtype(dtype: DType): # API dtypes definition + float32 = DType.FLOAT32 +"""32-bit floating point number.""" + float64 = DType.FLOAT64 +"""64-bit floating point number.""" + int32 = DType.INT32 +"""32-bit integer.""" + int64 = DType.INT64 +"""64-bit integer.""" + bool_ = DType.BOOLEAN +"""Boolean value.""" + str_ = DType.STRING +"""String value.""" diff --git a/temporian/core/data/dtypes/BUILD b/temporian/core/data/dtypes/BUILD deleted file mode 100644 index c03ef0570..000000000 --- a/temporian/core/data/dtypes/BUILD +++ /dev/null @@ -1,31 +0,0 @@ -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], -) - -# Libraries -# ========= - -py_library( - name = "dtypes", - srcs = ["__init__.py"], - srcs_version = "PY3", - deps = [ - ":api_symbols", - ], -) - -py_library( - name = "api_symbols", - srcs = ["api_symbols.py"], - srcs_version = "PY3", - deps = [ - ":dtype", - ], -) - -py_library( - name = "dtype", - srcs = ["dtype.py"], - srcs_version = "PY3", -) diff --git a/temporian/core/data/dtypes/__init__.py b/temporian/core/data/dtypes/__init__.py deleted file mode 100644 index 372b8b8d6..000000000 --- a/temporian/core/data/dtypes/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/temporian/core/data/dtypes/api_symbols.py b/temporian/core/data/dtypes/api_symbols.py deleted file mode 100644 index 5e035311d..000000000 --- a/temporian/core/data/dtypes/api_symbols.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# pylint: disable=unused-import - -from temporian.core.data.dtypes.dtype import float64 -from temporian.core.data.dtypes.dtype import float32 -from temporian.core.data.dtypes.dtype import int32 -from temporian.core.data.dtypes.dtype import int64 -from temporian.core.data.dtypes.dtype import bool_ -from temporian.core.data.dtypes.dtype import str_ diff --git a/temporian/core/data/node.py b/temporian/core/data/node.py index 0e40482ae..2f035d304 100644 --- a/temporian/core/data/node.py +++ b/temporian/core/data/node.py @@ -18,7 +18,7 @@ from dataclasses import dataclass from typing import List, Optional, Tuple, TYPE_CHECKING, Any, Union -from temporian.core.data.dtypes.dtype import DType, IndexDType +from temporian.core.data.dtype import DType, IndexDType from temporian.core.data.schema import Schema, FeatureSchema, IndexSchema from temporian.utils import string @@ -298,12 +298,12 @@ def __neg__(self): return multiply_scalar(input=self, value=-1) def __invert__(self): - from temporian.core.operators.unary.unary import invert + from temporian.core.operators.unary import invert return invert(input=self) def __abs__(self): - from temporian.core.operators.unary.unary import abs + from temporian.core.operators.unary import abs return abs(input=self) diff --git a/temporian/core/data/schema.py b/temporian/core/data/schema.py index 033c3ebeb..eee211102 100644 --- a/temporian/core/data/schema.py +++ b/temporian/core/data/schema.py @@ -19,7 +19,7 @@ from typing import List, Tuple, Dict, Union from dataclasses import dataclass -from temporian.core.data.dtypes.dtype import DType, IndexDType +from temporian.core.data.dtype import DType, IndexDType @dataclass diff --git a/temporian/core/operators/BUILD b/temporian/core/operators/BUILD index c69190ad4..6f361c1f9 100644 --- a/temporian/core/operators/BUILD +++ b/temporian/core/operators/BUILD @@ -6,36 +6,6 @@ package( # Libraries # ========= -py_library( - name = "api_symbols", - srcs = ["api_symbols.py"], - srcs_version = "PY3", - deps = [ - ":add_index", - ":begin", - ":cast", - ":drop_index", - ":end", - ":filter", - ":glue", - ":lag", - ":leak", - ":prefix", - ":propagate", - ":rename", - ":resample", - ":select", - ":since_last", - ":tick", - ":unique_timestamps", - "//temporian/core/operators/binary:api_symbols", - "//temporian/core/operators/calendar:api_symbols", - "//temporian/core/operators/scalar:api_symbols", - "//temporian/core/operators/unary:api_symbols", - "//temporian/core/operators/window:api_symbols", - ], -) - py_library( name = "glue", srcs = ["glue.py"], @@ -54,8 +24,8 @@ py_library( srcs = ["base.py"], srcs_version = "PY3", deps = [ + "//temporian/core/data:dtype", "//temporian/core/data:node", - "//temporian/core/data/dtypes:dtype", "//temporian/proto:core_py_proto", ], ) @@ -67,9 +37,9 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", "//temporian/proto:core_py_proto", ], ) @@ -108,8 +78,8 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:node", - "//temporian/core/data/dtypes:dtype", "//temporian/proto:core_py_proto", ], ) @@ -211,8 +181,8 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:node", - "//temporian/core/data/dtypes:dtype", "//temporian/proto:core_py_proto", ], ) @@ -268,3 +238,16 @@ py_library( "//temporian/proto:core_py_proto", ], ) + +py_library( + name = "unary", + srcs = ["unary.py"], + srcs_version = "PY3", + deps = [ + "//temporian/core:operator_lib", + "//temporian/core/data:dtype", + "//temporian/core/data:node", + "//temporian/core/operators:base", + "//temporian/proto:core_py_proto", + ], +) diff --git a/temporian/core/operators/api_symbols.py b/temporian/core/operators/api_symbols.py deleted file mode 100644 index 0b15011bc..000000000 --- a/temporian/core/operators/api_symbols.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Operators API Symbols.""" - -# pylint: disable=unused-import -# pylint: disable=line-too-long -# pylint: disable=wildcard-import -# pylint: disable=unused-wildcard-import -# fmt: off - -from temporian.core.operators.binary.api_symbols import * - -from temporian.core.operators.calendar.api_symbols import * - -from temporian.core.operators.scalar.api_symbols import * - -from temporian.core.operators.window.api_symbols import * - -from temporian.core.operators.unary.api_symbols import * - -from temporian.core.operators.cast import cast -from temporian.core.operators.drop_index import drop_index -from temporian.core.operators.filter import filter -from temporian.core.operators.glue import glue -from temporian.core.operators.add_index import add_index -from temporian.core.operators.add_index import set_index -from temporian.core.operators.lag import lag -from temporian.core.operators.leak import leak -from temporian.core.operators.prefix import prefix -from temporian.core.operators.propagate import propagate -from temporian.core.operators.resample import resample -from temporian.core.operators.select import select -from temporian.core.operators.rename import rename - -from temporian.core.operators.unique_timestamps import unique_timestamps -from temporian.core.operators.since_last import since_last -from temporian.core.operators.begin import begin -from temporian.core.operators.end import end -from temporian.core.operators.tick import tick diff --git a/temporian/core/operators/base.py b/temporian/core/operators/base.py index d572f5170..52f52c72a 100644 --- a/temporian/core/operators/base.py +++ b/temporian/core/operators/base.py @@ -16,7 +16,7 @@ from abc import ABC from typing import Dict, List, Tuple, Union, Any -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import Node from temporian.proto import core_pb2 as pb diff --git a/temporian/core/operators/binary/BUILD b/temporian/core/operators/binary/BUILD index 7334938f7..565daf005 100644 --- a/temporian/core/operators/binary/BUILD +++ b/temporian/core/operators/binary/BUILD @@ -10,18 +10,6 @@ py_library( name = "binary", srcs = ["__init__.py"], srcs_version = "PY3", - deps = [ - ":api_symbols", - ":arithmetic", - ":logical", - ":relational", - ], -) - -py_library( - name = "api_symbols", - srcs = ["api_symbols.py"], - srcs_version = "PY3", deps = [ ":arithmetic", ":logical", @@ -34,9 +22,9 @@ py_library( srcs = ["base.py"], srcs_version = "PY3", deps = [ + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", "//temporian/core/operators:base", "//temporian/proto:core_py_proto", ], @@ -49,8 +37,8 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:node", - "//temporian/core/data/dtypes:dtype", ], ) @@ -61,9 +49,9 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", ], ) @@ -74,8 +62,8 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", ], ) diff --git a/temporian/core/operators/binary/__init__.py b/temporian/core/operators/binary/__init__.py index 3be15f058..dcbdfb498 100644 --- a/temporian/core/operators/binary/__init__.py +++ b/temporian/core/operators/binary/__init__.py @@ -1,3 +1,19 @@ +# Copyright 2021 Google LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Binary operators.""" + # pylint: disable=unused-import from temporian.core.operators.binary.arithmetic import ( diff --git a/temporian/core/operators/binary/api_symbols.py b/temporian/core/operators/binary/api_symbols.py deleted file mode 100644 index 970e82ee3..000000000 --- a/temporian/core/operators/binary/api_symbols.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# pylint: disable=unused-import - -from temporian.core.operators.binary.arithmetic import add -from temporian.core.operators.binary.arithmetic import subtract -from temporian.core.operators.binary.arithmetic import multiply -from temporian.core.operators.binary.arithmetic import divide -from temporian.core.operators.binary.arithmetic import floordiv -from temporian.core.operators.binary.arithmetic import modulo -from temporian.core.operators.binary.arithmetic import power - -from temporian.core.operators.binary.relational import equal -from temporian.core.operators.binary.relational import not_equal -from temporian.core.operators.binary.relational import greater -from temporian.core.operators.binary.relational import greater_equal -from temporian.core.operators.binary.relational import less -from temporian.core.operators.binary.relational import less_equal - -from temporian.core.operators.binary.logical import logical_and -from temporian.core.operators.binary.logical import logical_or -from temporian.core.operators.binary.logical import logical_xor diff --git a/temporian/core/operators/binary/arithmetic.py b/temporian/core/operators/binary/arithmetic.py index c0193b7bf..1bf03a494 100644 --- a/temporian/core/operators/binary/arithmetic.py +++ b/temporian/core/operators/binary/arithmetic.py @@ -16,7 +16,7 @@ from temporian.core import operator_lib from temporian.core.data.node import Node -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.operators.binary.base import BaseBinaryOperator diff --git a/temporian/core/operators/binary/base.py b/temporian/core/operators/binary/base.py index 0a7fd468a..8574f5965 100644 --- a/temporian/core/operators/binary/base.py +++ b/temporian/core/operators/binary/base.py @@ -16,7 +16,7 @@ from abc import abstractmethod -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import ( Node, create_node_new_features_existing_sampling, diff --git a/temporian/core/operators/binary/logical.py b/temporian/core/operators/binary/logical.py index 40bd66b31..c22fc3771 100644 --- a/temporian/core/operators/binary/logical.py +++ b/temporian/core/operators/binary/logical.py @@ -15,7 +15,7 @@ """Binary logic operators classes and public API function definitions.""" from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import Node from temporian.core.data.schema import FeatureSchema from temporian.core.operators.binary.base import BaseBinaryOperator diff --git a/temporian/core/operators/binary/relational.py b/temporian/core/operators/binary/relational.py index 7b2ff20dd..7ffa56dd0 100644 --- a/temporian/core/operators/binary/relational.py +++ b/temporian/core/operators/binary/relational.py @@ -15,7 +15,7 @@ """Binary relational operators classes and public API function definitions.""" from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import Node from temporian.core.data.schema import FeatureSchema from temporian.core.operators.binary.base import BaseBinaryOperator diff --git a/temporian/core/operators/calendar/BUILD b/temporian/core/operators/calendar/BUILD index d9c627849..e285e7001 100644 --- a/temporian/core/operators/calendar/BUILD +++ b/temporian/core/operators/calendar/BUILD @@ -10,15 +10,6 @@ py_library( name = "calendar", srcs = ["__init__.py"], srcs_version = "PY3", - deps = [ - ":api_symbols", - ], -) - -py_library( - name = "api_symbols", - srcs = ["api_symbols.py"], - srcs_version = "PY3", deps = [ ":day_of_month", ":day_of_week", @@ -37,8 +28,8 @@ py_library( srcs = ["base.py"], srcs_version = "PY3", deps = [ + "//temporian/core/data:dtype", "//temporian/core/data:node", - "//temporian/core/data/dtypes:dtype", "//temporian/core/operators:base", "//temporian/proto:core_py_proto", ], diff --git a/temporian/core/operators/calendar/__init__.py b/temporian/core/operators/calendar/__init__.py index e69de29bb..dfc687943 100644 --- a/temporian/core/operators/calendar/__init__.py +++ b/temporian/core/operators/calendar/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2021 Google LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Calendar operators.""" + +# pylint: disable=unused-import + +from temporian.core.operators.calendar.day_of_month import calendar_day_of_month +from temporian.core.operators.calendar.day_of_week import calendar_day_of_week +from temporian.core.operators.calendar.day_of_year import calendar_day_of_year +from temporian.core.operators.calendar.hour import calendar_hour +from temporian.core.operators.calendar.iso_week import calendar_iso_week +from temporian.core.operators.calendar.minute import calendar_minute +from temporian.core.operators.calendar.month import calendar_month +from temporian.core.operators.calendar.second import calendar_second +from temporian.core.operators.calendar.year import calendar_year diff --git a/temporian/core/operators/calendar/api_symbols.py b/temporian/core/operators/calendar/api_symbols.py deleted file mode 100644 index 79cef475a..000000000 --- a/temporian/core/operators/calendar/api_symbols.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# pylint: disable=unused-import - -from temporian.core.operators.calendar.day_of_month import calendar_day_of_month -from temporian.core.operators.calendar.day_of_week import calendar_day_of_week -from temporian.core.operators.calendar.day_of_year import calendar_day_of_year -from temporian.core.operators.calendar.hour import calendar_hour -from temporian.core.operators.calendar.iso_week import calendar_iso_week -from temporian.core.operators.calendar.minute import calendar_minute -from temporian.core.operators.calendar.month import calendar_month -from temporian.core.operators.calendar.second import calendar_second -from temporian.core.operators.calendar.year import calendar_year diff --git a/temporian/core/operators/calendar/base.py b/temporian/core/operators/calendar/base.py index 508da5146..347a53b6f 100644 --- a/temporian/core/operators/calendar/base.py +++ b/temporian/core/operators/calendar/base.py @@ -16,7 +16,7 @@ from abc import ABC, abstractmethod -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import ( Node, create_node_new_features_existing_sampling, diff --git a/temporian/core/operators/cast.py b/temporian/core/operators/cast.py index 59dee39bf..286a7cbee 100644 --- a/temporian/core/operators/cast.py +++ b/temporian/core/operators/cast.py @@ -17,7 +17,7 @@ from typing import Union, Dict, Optional, List, Any, Type from temporian.core.data.schema import Schema, FeatureSchema -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core import operator_lib from temporian.core.data.node import ( Node, diff --git a/temporian/core/operators/filter.py b/temporian/core/operators/filter.py index ba103d098..4a21c58ac 100644 --- a/temporian/core/operators/filter.py +++ b/temporian/core/operators/filter.py @@ -17,7 +17,7 @@ from typing import Optional from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import Node, create_node_new_features_new_sampling from temporian.core.operators.base import Operator from temporian.proto import core_pb2 as pb diff --git a/temporian/core/operators/scalar/BUILD b/temporian/core/operators/scalar/BUILD index 81a904a74..91b52b9b8 100644 --- a/temporian/core/operators/scalar/BUILD +++ b/temporian/core/operators/scalar/BUILD @@ -10,17 +10,6 @@ py_library( name = "scalar", srcs = ["__init__.py"], srcs_version = "PY3", - deps = [ - "api_symbols", - ":arithmetic_scalar", - ":relational_scalar", - ], -) - -py_library( - name = "api_symbols", - srcs = ["api_symbols.py"], - srcs_version = "PY3", deps = [ ":arithmetic_scalar", ":relational_scalar", @@ -32,9 +21,9 @@ py_library( srcs = ["base.py"], srcs_version = "PY3", deps = [ + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", "//temporian/core/operators:base", "//temporian/proto:core_py_proto", ], @@ -47,8 +36,8 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:node", - "//temporian/core/data/dtypes:dtype", ], ) @@ -59,8 +48,8 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", ], ) diff --git a/temporian/core/operators/scalar/__init__.py b/temporian/core/operators/scalar/__init__.py index 5f7d56542..6e576c151 100644 --- a/temporian/core/operators/scalar/__init__.py +++ b/temporian/core/operators/scalar/__init__.py @@ -1,3 +1,19 @@ +# Copyright 2021 Google LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Scalar operators.""" + # pylint: disable=unused-import from temporian.core.operators.scalar.arithmetic_scalar import ( diff --git a/temporian/core/operators/scalar/api_symbols.py b/temporian/core/operators/scalar/api_symbols.py deleted file mode 100644 index 8ed8b9230..000000000 --- a/temporian/core/operators/scalar/api_symbols.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# pylint: disable=unused-import -# pylint: disable=line-too-long -# fmt: off - -from temporian.core.operators.scalar.arithmetic_scalar import add_scalar -from temporian.core.operators.scalar.arithmetic_scalar import subtract_scalar -from temporian.core.operators.scalar.arithmetic_scalar import multiply_scalar -from temporian.core.operators.scalar.arithmetic_scalar import divide_scalar -from temporian.core.operators.scalar.arithmetic_scalar import floordiv_scalar -from temporian.core.operators.scalar.arithmetic_scalar import modulo_scalar -from temporian.core.operators.scalar.arithmetic_scalar import power_scalar - -from temporian.core.operators.scalar.relational_scalar import equal_scalar -from temporian.core.operators.scalar.relational_scalar import not_equal_scalar -from temporian.core.operators.scalar.relational_scalar import greater_equal_scalar -from temporian.core.operators.scalar.relational_scalar import greater_scalar -from temporian.core.operators.scalar.relational_scalar import less_equal_scalar -from temporian.core.operators.scalar.relational_scalar import less_scalar diff --git a/temporian/core/operators/scalar/arithmetic_scalar.py b/temporian/core/operators/scalar/arithmetic_scalar.py index 3330cae0f..b36737c37 100644 --- a/temporian/core/operators/scalar/arithmetic_scalar.py +++ b/temporian/core/operators/scalar/arithmetic_scalar.py @@ -17,7 +17,7 @@ from typing import Union from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import Node from temporian.core.operators.scalar.base import ( BaseScalarOperator, diff --git a/temporian/core/operators/scalar/base.py b/temporian/core/operators/scalar/base.py index 8644d3096..5bd8f6879 100644 --- a/temporian/core/operators/scalar/base.py +++ b/temporian/core/operators/scalar/base.py @@ -16,7 +16,7 @@ from typing import Union, List -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import ( Node, create_node_new_features_existing_sampling, diff --git a/temporian/core/operators/scalar/relational_scalar.py b/temporian/core/operators/scalar/relational_scalar.py index 05f5643a7..04610fac9 100644 --- a/temporian/core/operators/scalar/relational_scalar.py +++ b/temporian/core/operators/scalar/relational_scalar.py @@ -17,7 +17,7 @@ from typing import Union, List from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import Node from temporian.core.data.schema import FeatureSchema from temporian.core.operators.scalar.base import ( diff --git a/temporian/core/operators/since_last.py b/temporian/core/operators/since_last.py index 02184dc3f..2fe6a060c 100644 --- a/temporian/core/operators/since_last.py +++ b/temporian/core/operators/since_last.py @@ -23,7 +23,7 @@ ) from temporian.core.operators.base import Operator from temporian.proto import core_pb2 as pb -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType class SinceLast(Operator): diff --git a/temporian/core/operators/test/BUILD b/temporian/core/operators/test/BUILD index b091bd9d0..b5ea3c1be 100644 --- a/temporian/core/operators/test/BUILD +++ b/temporian/core/operators/test/BUILD @@ -11,7 +11,7 @@ py_test( srcs_version = "PY3", deps = [ # already_there/absl/testing:absltest - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/operators:propagate", ], diff --git a/temporian/core/operators/test/propagate_test.py b/temporian/core/operators/test/propagate_test.py index 8d6d46d7c..d60283542 100644 --- a/temporian/core/operators/test/propagate_test.py +++ b/temporian/core/operators/test/propagate_test.py @@ -15,7 +15,7 @@ from absl.testing import absltest from temporian.core.data.node import input_node -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.operators.propagate import propagate diff --git a/temporian/core/operators/unary/unary.py b/temporian/core/operators/unary.py similarity index 99% rename from temporian/core/operators/unary/unary.py rename to temporian/core/operators/unary.py index 2fa0eac69..1c8b2c147 100644 --- a/temporian/core/operators/unary/unary.py +++ b/temporian/core/operators/unary.py @@ -18,7 +18,7 @@ from typing import List from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import ( Node, create_node_new_features_existing_sampling, diff --git a/temporian/core/operators/unary/BUILD b/temporian/core/operators/unary/BUILD deleted file mode 100644 index a33c08894..000000000 --- a/temporian/core/operators/unary/BUILD +++ /dev/null @@ -1,29 +0,0 @@ -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], -) - -# Libraries -# ========= - -py_library( - name = "unary", - srcs = ["unary.py"], - srcs_version = "PY3", - deps = [ - "//temporian/core:operator_lib", - "//temporian/core/data:node", - "//temporian/core/data/dtypes:dtype", - "//temporian/core/operators:base", - "//temporian/proto:core_py_proto", - ], -) - -py_library( - name = "api_symbols", - srcs = ["api_symbols.py"], - srcs_version = "PY3", - deps = [ - ":unary", - ], -) diff --git a/temporian/core/operators/unary/__init__.py b/temporian/core/operators/unary/__init__.py deleted file mode 100644 index 0a0f1fa52..000000000 --- a/temporian/core/operators/unary/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Unary operators.""" diff --git a/temporian/core/operators/unary/api_symbols.py b/temporian/core/operators/unary/api_symbols.py deleted file mode 100644 index 9f523b0fa..000000000 --- a/temporian/core/operators/unary/api_symbols.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# pylint: disable=unused-import - -from temporian.core.operators.unary.unary import abs -from temporian.core.operators.unary.unary import log -from temporian.core.operators.unary.unary import invert -from temporian.core.operators.unary.unary import isnan -from temporian.core.operators.unary.unary import notnan diff --git a/temporian/core/operators/window/BUILD b/temporian/core/operators/window/BUILD index ff79f4a4c..b951387ea 100644 --- a/temporian/core/operators/window/BUILD +++ b/temporian/core/operators/window/BUILD @@ -10,15 +10,6 @@ py_library( name = "window", srcs = ["__init__.py"], srcs_version = "PY3", - deps = [ - ":api_symbols", - ], -) - -py_library( - name = "api_symbols", - srcs = ["api_symbols.py"], - srcs_version = "PY3", deps = [ ":moving_count", ":moving_max", @@ -34,10 +25,10 @@ py_library( srcs = ["base.py"], srcs_version = "PY3", deps = [ + "//temporian/core/data:dtype", "//temporian/core/data:duration_utils", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", "//temporian/core/operators:base", "//temporian/proto:core_py_proto", ], @@ -50,10 +41,10 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:duration_utils", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", ], ) @@ -64,10 +55,10 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:duration_utils", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", ], ) @@ -79,7 +70,7 @@ py_library( ":base", # already_there/numpy "//temporian/core:operator_lib", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:duration_utils", "//temporian/core/data:node", "//temporian/core/data:schema", @@ -93,10 +84,10 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:duration_utils", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", ], ) @@ -107,10 +98,10 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:duration_utils", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", ], ) @@ -121,9 +112,9 @@ py_library( deps = [ ":base", "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:duration_utils", "//temporian/core/data:node", "//temporian/core/data:schema", - "//temporian/core/data/dtypes:dtype", ], ) diff --git a/temporian/core/operators/window/__init__.py b/temporian/core/operators/window/__init__.py index e69de29bb..93e2e9aaa 100644 --- a/temporian/core/operators/window/__init__.py +++ b/temporian/core/operators/window/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2021 Google LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Window operators.""" + +# pylint: disable=unused-import +# pylint: disable=line-too-long +# fmt: off + +from temporian.core.operators.window.simple_moving_average import simple_moving_average +from temporian.core.operators.window.moving_standard_deviation import moving_standard_deviation +from temporian.core.operators.window.moving_sum import cumsum +from temporian.core.operators.window.moving_sum import moving_sum +from temporian.core.operators.window.moving_count import moving_count +from temporian.core.operators.window.moving_min import moving_min +from temporian.core.operators.window.moving_max import moving_max diff --git a/temporian/core/operators/window/api_symbols.py b/temporian/core/operators/window/api_symbols.py deleted file mode 100644 index bb3115044..000000000 --- a/temporian/core/operators/window/api_symbols.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# pylint: disable=unused-import -# pylint: disable=line-too-long -# fmt: off - -from temporian.core.operators.window.simple_moving_average import simple_moving_average -from temporian.core.operators.window.moving_standard_deviation import moving_standard_deviation -from temporian.core.operators.window.moving_sum import cumsum -from temporian.core.operators.window.moving_sum import moving_sum -from temporian.core.operators.window.moving_count import moving_count -from temporian.core.operators.window.moving_min import moving_min -from temporian.core.operators.window.moving_max import moving_max diff --git a/temporian/core/operators/window/base.py b/temporian/core/operators/window/base.py index ae41633de..6edf852b5 100644 --- a/temporian/core/operators/window/base.py +++ b/temporian/core/operators/window/base.py @@ -19,7 +19,7 @@ from temporian.core.data.duration_utils import NormalizedDuration -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import ( Node, create_node_new_features_existing_sampling, diff --git a/temporian/core/operators/window/moving_count.py b/temporian/core/operators/window/moving_count.py index 7aa07a1f2..26dd46418 100644 --- a/temporian/core/operators/window/moving_count.py +++ b/temporian/core/operators/window/moving_count.py @@ -17,7 +17,7 @@ from typing import Optional from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.duration_utils import Duration, normalize_duration from temporian.core.data.node import Node from temporian.core.data.schema import FeatureSchema diff --git a/temporian/core/operators/window/moving_max.py b/temporian/core/operators/window/moving_max.py index 4dc8ed5cc..1846900d0 100644 --- a/temporian/core/operators/window/moving_max.py +++ b/temporian/core/operators/window/moving_max.py @@ -17,7 +17,7 @@ from typing import Optional from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.duration_utils import Duration, normalize_duration from temporian.core.data.node import Node from temporian.core.data.schema import FeatureSchema diff --git a/temporian/core/operators/window/moving_min.py b/temporian/core/operators/window/moving_min.py index 760349f12..f3778b6b8 100644 --- a/temporian/core/operators/window/moving_min.py +++ b/temporian/core/operators/window/moving_min.py @@ -17,7 +17,7 @@ from typing import Optional from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.duration_utils import Duration, normalize_duration from temporian.core.data.node import Node from temporian.core.data.schema import FeatureSchema diff --git a/temporian/core/operators/window/moving_standard_deviation.py b/temporian/core/operators/window/moving_standard_deviation.py index 6976be2c9..a1cfc970a 100644 --- a/temporian/core/operators/window/moving_standard_deviation.py +++ b/temporian/core/operators/window/moving_standard_deviation.py @@ -16,7 +16,7 @@ from typing import Optional from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.duration_utils import Duration, normalize_duration from temporian.core.data.node import Node from temporian.core.data.schema import FeatureSchema diff --git a/temporian/core/operators/window/moving_sum.py b/temporian/core/operators/window/moving_sum.py index b72c169d8..0ebe12977 100644 --- a/temporian/core/operators/window/moving_sum.py +++ b/temporian/core/operators/window/moving_sum.py @@ -23,7 +23,7 @@ from temporian.core.data.node import Node from temporian.core.data.schema import FeatureSchema from temporian.core.operators.window.base import BaseWindowOperator -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType class MovingSumOperator(BaseWindowOperator): diff --git a/temporian/core/operators/window/simple_moving_average.py b/temporian/core/operators/window/simple_moving_average.py index e63036795..57f4e226d 100644 --- a/temporian/core/operators/window/simple_moving_average.py +++ b/temporian/core/operators/window/simple_moving_average.py @@ -17,7 +17,7 @@ from typing import Optional from temporian.core import operator_lib -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.duration_utils import Duration, normalize_duration from temporian.core.data.node import Node from temporian.core.data.schema import FeatureSchema diff --git a/temporian/core/serialization/serialize.py b/temporian/core/serialization.py similarity index 96% rename from temporian/core/serialization/serialize.py rename to temporian/core/serialization.py index 738174f08..a9e891e7f 100644 --- a/temporian/core/serialization/serialize.py +++ b/temporian/core/serialization.py @@ -23,7 +23,7 @@ from temporian.core.data.node import Node, Sampling, Feature from temporian.core.data.schema import Schema from temporian.core.operators import base -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.proto import core_pb2 as pb DTYPE_MAPPING = { diff --git a/temporian/core/serialization/BUILD b/temporian/core/serialization/BUILD deleted file mode 100644 index 6fa46968d..000000000 --- a/temporian/core/serialization/BUILD +++ /dev/null @@ -1,41 +0,0 @@ -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], -) - -# Libraries -# ========= - -py_library( - name = "serialization", - srcs = ["__init__.py"], - srcs_version = "PY3", - deps = [ - ":api_symbols", - ], -) - -py_library( - name = "api_symbols", - srcs = ["api_symbols.py"], - srcs_version = "PY3", - deps = [ - ":serialize", - ], -) - -py_library( - name = "serialize", - srcs = ["serialize.py"], - srcs_version = "PY3", - deps = [ - # already_there/google/protobuf - "//temporian/core:graph", - "//temporian/core:operator_lib", - "//temporian/core/data/dtypes:dtype", - "//temporian/core/data:node", - "//temporian/core/data:schema", - "//temporian/core/operators:base", - "//temporian/proto:core_py_proto", - ], -) diff --git a/temporian/core/serialization/__init__.py b/temporian/core/serialization/__init__.py deleted file mode 100644 index af1c89fea..000000000 --- a/temporian/core/serialization/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Graph serialization functions.""" diff --git a/temporian/core/serialization/api_symbols.py b/temporian/core/serialization/api_symbols.py deleted file mode 100644 index eaec6143a..000000000 --- a/temporian/core/serialization/api_symbols.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# pylint: disable=unused-import - -from temporian.core.serialization.serialize import load -from temporian.core.serialization.serialize import save diff --git a/temporian/core/test/BUILD b/temporian/core/test/BUILD index 1323d3ce7..65a349baa 100644 --- a/temporian/core/test/BUILD +++ b/temporian/core/test/BUILD @@ -9,8 +9,8 @@ py_library( srcs_version = "PY3", deps = [ "//temporian/core:operator_lib", + "//temporian/core/data:dtype", "//temporian/core/data:node", - "//temporian/core/data/dtypes:dtype", "//temporian/core/operators:base", "//temporian/implementation/numpy/data:event_set", "//temporian/implementation/numpy/data:io", @@ -30,7 +30,7 @@ py_test( ":utils", "//temporian/core/data:node", "//temporian/core/operators:base", - "//temporian/core/operators/unary", + "//temporian/core/operators:unary", "//temporian/core/operators/binary", "//temporian/core/operators/scalar", "//temporian/proto:core_py_proto", @@ -70,8 +70,8 @@ py_test( # already_there/absl/testing:absltest "//temporian", "//temporian/core:graph", - "//temporian/core/serialization:serialize", - "//temporian/core/data/dtypes:dtype", + "//temporian/core:serialization", + "//temporian/core/data:dtype", "//temporian/implementation/numpy/data:io", ], ) @@ -95,6 +95,6 @@ py_test( deps = [ # already_there/absl/testing:absltest "//temporian/core:operator_lib", - "//temporian/core/operators:api_symbols", + "//temporian", ], ) diff --git a/temporian/core/test/magic_methods_test.py b/temporian/core/test/magic_methods_test.py index 26d5f7137..2fc73ce86 100644 --- a/temporian/core/test/magic_methods_test.py +++ b/temporian/core/test/magic_methods_test.py @@ -16,7 +16,7 @@ from temporian.core.data.node import input_node from temporian.core.test import utils -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.operators.binary import ( AddOperator, DivideOperator, @@ -54,7 +54,7 @@ LessEqualScalarOperator, LessScalarOperator, ) -from temporian.core.operators.unary.unary import AbsOperator, InvertOperator +from temporian.core.operators.unary import AbsOperator, InvertOperator class MagicMethodsTest(absltest.TestCase): diff --git a/temporian/core/test/registered_operators_test.py b/temporian/core/test/registered_operators_test.py index c4f8f52bf..ec28e0fcc 100644 --- a/temporian/core/test/registered_operators_test.py +++ b/temporian/core/test/registered_operators_test.py @@ -17,7 +17,8 @@ from absl.testing import absltest from temporian.core import operator_lib -from temporian.core.operators import api_symbols + +import temporian # Load and register all operators class RegisteredOperatorsTest(absltest.TestCase): diff --git a/temporian/core/test/serialization_test.py b/temporian/core/test/serialization_test.py index bc4bcb249..7ef235dc4 100644 --- a/temporian/core/test/serialization_test.py +++ b/temporian/core/test/serialization_test.py @@ -17,9 +17,9 @@ import os import tempfile import temporian as tp -from temporian.core.serialization import serialize +from temporian.core import serialization from temporian.core import graph -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.test import utils from temporian.implementation.numpy.data.io import event_set @@ -41,10 +41,10 @@ def test_serialize(self): ) logging.info("original:\n%s", original) - proto = serialize._serialize(original) + proto = serialization._serialize(original) logging.info("proto:\n%s", proto) - restored = serialize._unserialize(proto) + restored = serialization._unserialize(proto) logging.info("restored:\n%s", restored) self.assertEqual(len(original.samplings), len(restored.samplings)) @@ -61,28 +61,28 @@ def test_serialize(self): # Ensures that "original" and "restored" don't link to the same objects. self.assertFalse( - serialize._all_identifiers(original.samplings) - & serialize._all_identifiers(restored.samplings) + serialization._all_identifiers(original.samplings) + & serialization._all_identifiers(restored.samplings) ) self.assertFalse( - serialize._all_identifiers(original.features) - & serialize._all_identifiers(restored.features) + serialization._all_identifiers(original.features) + & serialization._all_identifiers(restored.features) ) self.assertFalse( - serialize._all_identifiers(original.operators) - & serialize._all_identifiers(restored.operators) + serialization._all_identifiers(original.operators) + & serialization._all_identifiers(restored.operators) ) self.assertFalse( - serialize._all_identifiers(original.nodes) - & serialize._all_identifiers(restored.nodes) + serialization._all_identifiers(original.nodes) + & serialization._all_identifiers(restored.nodes) ) self.assertFalse( - serialize._all_identifiers(original.named_inputs.values()) - & serialize._all_identifiers(restored.named_inputs.values()) + serialization._all_identifiers(original.named_inputs.values()) + & serialization._all_identifiers(restored.named_inputs.values()) ) self.assertFalse( - serialize._all_identifiers(original.named_outputs.values()) - & serialize._all_identifiers(restored.named_outputs.values()) + serialization._all_identifiers(original.named_outputs.values()) + & serialization._all_identifiers(restored.named_outputs.values()) ) def test_serialize_autonode(self): @@ -101,10 +101,10 @@ def test_serialize_autonode(self): ) logging.info("original:\n%s", original) - proto = serialize._serialize(original) + proto = serialization._serialize(original) logging.info("proto:\n%s", proto) - restored = serialize._unserialize(proto) + restored = serialization._unserialize(proto) logging.info("restored:\n%s", restored) def test_serialize_attributes(self): @@ -127,10 +127,10 @@ def test_serialize_attributes(self): ) logging.info("original:\n%s", original) - proto = serialize._serialize(original) + proto = serialization._serialize(original) logging.info("proto:\n%s", proto) - restored = serialize._unserialize(proto) + restored = serialization._unserialize(proto) logging.info("restored:\n%s", restored) self.assertEqual(len(original.operators), len(restored.operators)) @@ -147,16 +147,16 @@ def test_serialize_attributes(self): self.assertEqual(attr_value, restored_attributes[attr_name]) self.assertFalse( - serialize._all_identifiers(original.operators) - & serialize._all_identifiers(restored.operators) + serialization._all_identifiers(original.operators) + & serialization._all_identifiers(restored.operators) ) self.assertFalse( - serialize._all_identifiers(original.named_inputs.values()) - & serialize._all_identifiers(restored.named_inputs.values()) + serialization._all_identifiers(original.named_inputs.values()) + & serialization._all_identifiers(restored.named_inputs.values()) ) self.assertFalse( - serialize._all_identifiers(original.named_outputs.values()) - & serialize._all_identifiers(restored.named_outputs.values()) + serialization._all_identifiers(original.named_outputs.values()) + & serialization._all_identifiers(restored.named_outputs.values()) ) def test_serialize_and_run(self): diff --git a/temporian/core/test/utils.py b/temporian/core/test/utils.py index 6dd18ceb8..c4a00470a 100644 --- a/temporian/core/test/utils.py +++ b/temporian/core/test/utils.py @@ -1,7 +1,7 @@ """Utilities for unit testing.""" from typing import Dict, List, Optional -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import ( Node, input_node, diff --git a/temporian/implementation/numpy/data/BUILD b/temporian/implementation/numpy/data/BUILD index 7c98cd572..6c90b1316 100644 --- a/temporian/implementation/numpy/data/BUILD +++ b/temporian/implementation/numpy/data/BUILD @@ -19,7 +19,7 @@ py_library( deps = [ # already_there/numpy # already_there/pandas - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/utils:string", diff --git a/temporian/implementation/numpy/data/event_set.py b/temporian/implementation/numpy/data/event_set.py index a8c31f33f..9c1ff7a11 100644 --- a/temporian/implementation/numpy/data/event_set.py +++ b/temporian/implementation/numpy/data/event_set.py @@ -22,7 +22,7 @@ import numpy as np -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import Node, create_node_with_new_reference from temporian.core.data.schema import Schema from temporian.utils import string diff --git a/temporian/implementation/numpy/data/io.py b/temporian/implementation/numpy/data/io.py index 4e6e91053..aeaa8e0c8 100644 --- a/temporian/implementation/numpy/data/io.py +++ b/temporian/implementation/numpy/data/io.py @@ -28,7 +28,8 @@ def event_set( is_unix_timestamp: Optional[bool] = None, same_sampling_as: Optional[EventSet] = None, ) -> EventSet: - """Creates an event set from arrays (list, numpy, pandas). + """Creates an [`EventSet`][temporian.EventSet] from arrays (lists, NumPy, + Pandas Series.) Usage examples: diff --git a/temporian/implementation/numpy/data/test/BUILD b/temporian/implementation/numpy/data/test/BUILD index 4674547a3..8585b17c3 100644 --- a/temporian/implementation/numpy/data/test/BUILD +++ b/temporian/implementation/numpy/data/test/BUILD @@ -36,7 +36,7 @@ py_test( # already_there/absl/testing:absltest # already_there/numpy # already_there/pandas - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:schema", "//temporian/implementation/numpy/data:event_set", "//temporian/implementation/numpy/data:io", diff --git a/temporian/implementation/numpy/data/test/io_test.py b/temporian/implementation/numpy/data/test/io_test.py index 4842d8864..0e1b01fe2 100644 --- a/temporian/implementation/numpy/data/test/io_test.py +++ b/temporian/implementation/numpy/data/test/io_test.py @@ -10,7 +10,7 @@ from temporian.implementation.numpy.data.io import event_set from temporian.implementation.numpy.data.event_set import IndexData, EventSet from temporian.core.data.schema import Schema -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType class IOTest(absltest.TestCase): diff --git a/temporian/implementation/numpy/operators/BUILD b/temporian/implementation/numpy/operators/BUILD index a025c4ce0..bcd051254 100644 --- a/temporian/implementation/numpy/operators/BUILD +++ b/temporian/implementation/numpy/operators/BUILD @@ -215,7 +215,7 @@ py_library( deps = [ ":base", # already_there/numpy - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/operators:cast", "//temporian/implementation/numpy:implementation_lib", "//temporian/implementation/numpy/data:event_set", @@ -229,7 +229,7 @@ py_library( deps = [ ":base", # already_there/numpy - "//temporian/core/operators/unary", + "//temporian/core/operators:unary", "//temporian/implementation/numpy:implementation_lib", "//temporian/implementation/numpy/data:event_set", ], diff --git a/temporian/implementation/numpy/operators/binary/BUILD b/temporian/implementation/numpy/operators/binary/BUILD index 345901764..28f337e67 100644 --- a/temporian/implementation/numpy/operators/binary/BUILD +++ b/temporian/implementation/numpy/operators/binary/BUILD @@ -36,7 +36,7 @@ py_library( deps = [ ":base", # already_there/numpy - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/operators/binary", "//temporian/implementation/numpy:implementation_lib", ], diff --git a/temporian/implementation/numpy/operators/binary/arithmetic.py b/temporian/implementation/numpy/operators/binary/arithmetic.py index f8cb888f9..3d20a9782 100644 --- a/temporian/implementation/numpy/operators/binary/arithmetic.py +++ b/temporian/implementation/numpy/operators/binary/arithmetic.py @@ -22,7 +22,7 @@ ModuloOperator, PowerOperator, ) -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.implementation.numpy import implementation_lib from temporian.implementation.numpy.operators.binary.base import ( BaseBinaryNumpyImplementation, diff --git a/temporian/implementation/numpy/operators/cast.py b/temporian/implementation/numpy/operators/cast.py index c8ebc34bb..53cb12ed6 100644 --- a/temporian/implementation/numpy/operators/cast.py +++ b/temporian/implementation/numpy/operators/cast.py @@ -2,7 +2,7 @@ import numpy as np -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.operators.cast import CastOperator from temporian.implementation.numpy import implementation_lib from temporian.implementation.numpy.data.event_set import ( diff --git a/temporian/implementation/numpy/operators/test/BUILD b/temporian/implementation/numpy/operators/test/BUILD index 86578337a..c288a1aaa 100644 --- a/temporian/implementation/numpy/operators/test/BUILD +++ b/temporian/implementation/numpy/operators/test/BUILD @@ -8,8 +8,8 @@ py_library( srcs = ["test_util.py"], srcs_version = "PY3", deps = [ + "//temporian/core:serialization", "//temporian/core/operators:base", - "//temporian/core/serialization:serialize", "//temporian/implementation/numpy/data:event_set", "//temporian/implementation/numpy/operators:base", ], @@ -102,7 +102,7 @@ py_test( # already_there/numpy # already_there/pandas # absl/testing:absltest dep, - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/io:pandas", "//temporian/core/operators/binary", @@ -122,7 +122,7 @@ py_test( # already_there/pandas "//temporian/io:pandas", "//temporian/core:evaluation", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/operators:cast", "//temporian/implementation/numpy/data:event_set", @@ -151,7 +151,7 @@ py_test( deps = [ ":test_util", # already_there/absl/testing:absltest - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/operators:glue", "//temporian/implementation/numpy/data:io", @@ -169,7 +169,7 @@ py_test( # already_there/numpy # already_there/pandas "//temporian/io:pandas", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/implementation/numpy/data:io", "//temporian/implementation/numpy/operators:unary", @@ -421,7 +421,7 @@ py_test( # already_there/numpy "//temporian/io:pandas", ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators/window:simple_moving_average", @@ -441,7 +441,7 @@ py_test( # already_there/numpy "//temporian/io:pandas", ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators/window:moving_standard_deviation", @@ -460,7 +460,7 @@ py_test( # already_there/numpy "//temporian/io:pandas", ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators/window:moving_sum", @@ -479,7 +479,7 @@ py_test( # already_there/numpy "//temporian/io:pandas", ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators/window:moving_count", @@ -498,7 +498,7 @@ py_test( # already_there/numpy "//temporian/io:pandas", ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators/window:moving_min", @@ -517,7 +517,7 @@ py_test( # already_there/numpy "//temporian/io:pandas", ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators/window:moving_max", @@ -536,7 +536,7 @@ py_test( # already_there/numpy "//temporian/io:pandas", ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators:propagate", @@ -556,7 +556,7 @@ py_test( # already_there/numpy "//temporian/io:pandas", ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators:resample", @@ -576,7 +576,7 @@ py_test( # already_there/numpy "//temporian/io:pandas", ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators:prefix", @@ -611,7 +611,7 @@ py_test( # already_there/numpy "//temporian/io:pandas", ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators:since_last", @@ -628,7 +628,7 @@ py_test( # already_there/absl/testing:absltest ":test_util", "//temporian/implementation/numpy/data:io", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators:begin", @@ -644,7 +644,7 @@ py_test( # already_there/absl/testing:absltest ":test_util", "//temporian/implementation/numpy/data:io", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/core/operators:end", @@ -659,7 +659,7 @@ py_test( deps = [ # already_there/absl/testing:absltest ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/implementation/numpy/data:io", diff --git a/temporian/implementation/numpy/operators/test/arithmetic_multi_index_test.py b/temporian/implementation/numpy/operators/test/arithmetic_multi_index_test.py index cc4702ebb..bddb18339 100644 --- a/temporian/implementation/numpy/operators/test/arithmetic_multi_index_test.py +++ b/temporian/implementation/numpy/operators/test/arithmetic_multi_index_test.py @@ -16,7 +16,7 @@ import pandas as pd from absl.testing import absltest -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.core.data.node import input_node from temporian.core.operators.binary import ( AddOperator, diff --git a/temporian/implementation/numpy/operators/test/cast_test.py b/temporian/implementation/numpy/operators/test/cast_test.py index 2d5f02daa..2cdf5d1bb 100644 --- a/temporian/implementation/numpy/operators/test/cast_test.py +++ b/temporian/implementation/numpy/operators/test/cast_test.py @@ -21,7 +21,7 @@ CastNumpyImplementation, ) from temporian.core.operators.cast import CastOperator, cast -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.implementation.numpy.data.event_set import EventSet from temporian.io.pandas import from_pandas from temporian.implementation.numpy.data.io import event_set diff --git a/temporian/implementation/numpy/operators/test/glue_test.py b/temporian/implementation/numpy/operators/test/glue_test.py index a3a1a1dca..ef28c69ac 100644 --- a/temporian/implementation/numpy/operators/test/glue_test.py +++ b/temporian/implementation/numpy/operators/test/glue_test.py @@ -16,7 +16,7 @@ from temporian.core.operators.glue import GlueOperator from temporian.core.data.node import input_node -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.implementation.numpy.operators.glue import ( GlueNumpyImplementation, ) diff --git a/temporian/implementation/numpy/operators/test/test_util.py b/temporian/implementation/numpy/operators/test/test_util.py index 682a24336..7a31023cc 100644 --- a/temporian/implementation/numpy/operators/test/test_util.py +++ b/temporian/implementation/numpy/operators/test/test_util.py @@ -15,7 +15,7 @@ from temporian.implementation.numpy.data.event_set import EventSet from temporian.implementation.numpy.operators.base import OperatorImplementation from temporian.core.operators.base import Operator -from temporian.core.serialization import serialize +from temporian.core import serialization def assertEqualEventSet(self, real: EventSet, expected: EventSet): @@ -41,12 +41,12 @@ def testOperatorAndImp(self, op: Operator, imp: OperatorImplementation): # TODO: Add tests related to the implementation. del imp - serialized_op = serialize._serialize_operator(op) + serialized_op = serialization._serialize_operator(op) nodes = {} for node in op.inputs.values(): - nodes[serialize._identifier(node)] = node + nodes[serialization._identifier(node)] = node for node in op.outputs.values(): - nodes[serialize._identifier(node)] = node + nodes[serialization._identifier(node)] = node - _ = serialize._unserialize_operator(serialized_op, nodes) + _ = serialization._unserialize_operator(serialized_op, nodes) diff --git a/temporian/implementation/numpy/operators/test/unary_test.py b/temporian/implementation/numpy/operators/test/unary_test.py index bde8b8650..448831f1a 100644 --- a/temporian/implementation/numpy/operators/test/unary_test.py +++ b/temporian/implementation/numpy/operators/test/unary_test.py @@ -29,7 +29,7 @@ IsNanOperator, NotNanOperator, ) -from temporian.core.data.dtypes.dtype import DType +from temporian.core.data.dtype import DType from temporian.io.pandas import from_pandas from temporian.implementation.numpy.operators.test.test_util import ( assertEqualEventSet, diff --git a/temporian/implementation/numpy/operators/unary.py b/temporian/implementation/numpy/operators/unary.py index 982c4f89f..17bc51eb2 100644 --- a/temporian/implementation/numpy/operators/unary.py +++ b/temporian/implementation/numpy/operators/unary.py @@ -3,7 +3,7 @@ import numpy as np -from temporian.core.operators.unary.unary import ( +from temporian.core.operators.unary import ( BaseUnaryOperator, AbsOperator, InvertOperator, diff --git a/temporian/io/BUILD b/temporian/io/BUILD index 7a6aba29c..fb5dced15 100644 --- a/temporian/io/BUILD +++ b/temporian/io/BUILD @@ -10,17 +10,6 @@ py_library( name = "io", srcs = ["__init__.py"], srcs_version = "PY3", - deps = [ - ":api_symbols", - ":csv", - ":pandas", - ], -) - -py_library( - name = "api_symbols", - srcs = ["api_symbols.py"], - srcs_version = "PY3", deps = [ ":csv", ":pandas", diff --git a/temporian/io/__init__.py b/temporian/io/__init__.py index 750a84d97..fca495f43 100644 --- a/temporian/io/__init__.py +++ b/temporian/io/__init__.py @@ -13,3 +13,9 @@ # limitations under the License. """Input/output functions.""" + +from temporian.io.csv import to_csv +from temporian.io.csv import from_csv + +from temporian.io.pandas import to_pandas +from temporian.io.pandas import from_pandas diff --git a/temporian/io/api_symbols.py b/temporian/io/api_symbols.py deleted file mode 100644 index f3708b1fa..000000000 --- a/temporian/io/api_symbols.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2021 Google LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# pylint: disable=unused-import - -from temporian.io.csv import to_csv -from temporian.io.csv import from_csv - -from temporian.io.pandas import to_pandas -from temporian.io.pandas import from_pandas diff --git a/temporian/test/BUILD b/temporian/test/BUILD index bf88f0925..fb48ba99f 100644 --- a/temporian/test/BUILD +++ b/temporian/test/BUILD @@ -51,3 +51,16 @@ py_test( "//temporian", ], ) + +py_test( + name = "public_api_test", + srcs = ["public_api_test.py"], + data = [ + "//docs:reference", + ], + srcs_version = "PY3", + deps = [ + # already_there/absl/testing:absltest + "//temporian", + ], +) diff --git a/temporian/test/public_api_test.py b/temporian/test/public_api_test.py new file mode 100644 index 000000000..7c000aab6 --- /dev/null +++ b/temporian/test/public_api_test.py @@ -0,0 +1,143 @@ +# Copyright 2021 Google LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from absl.testing import absltest +from pathlib import Path + +import temporian as tp +from temporian.core.operator_lib import registered_operators + +PUBLIC_API_SYMBOLS = { + "EventSet", + "Node", + "Schema", + "duration", + "evaluate", + "event_set", + "input_node", + "plot", + # IO + "to_csv", + "from_csv", + "to_pandas", + "from_pandas", + # DTYPES + "float64", + "float32", + "int32", + "int64", + "bool_", + "str_", + # SERIALIZATION + "load", + "save", + # OPERATORS + "cast", + "drop_index", + "filter", + "glue", + "add_index", + "set_index", + "lag", + "leak", + "prefix", + "propagate", + "resample", + "select", + "rename", + "unique_timestamps", + "since_last", + "begin", + "end", + "tick", + # BINARY OPERATORS + "add", + "subtract", + "multiply", + "divide", + "floordiv", + "modulo", + "power", + "equal", + "not_equal", + "greater", + "greater_equal", + "less", + "less_equal", + "logical_and", + "logical_or", + "logical_xor", + # CALENDAR OPERATORS + "calendar_day_of_month", + "calendar_day_of_week", + "calendar_day_of_year", + "calendar_hour", + "calendar_iso_week", + "calendar_minute", + "calendar_month", + "calendar_second", + "calendar_year", + # SCALAR OPERATORS + "add_scalar", + "subtract_scalar", + "multiply_scalar", + "divide_scalar", + "floordiv_scalar", + "modulo_scalar", + "power_scalar", + "equal_scalar", + "not_equal_scalar", + "greater_equal_scalar", + "greater_scalar", + "less_equal_scalar", + "less_scalar", + # UNARY OPERATORS + "abs", + "log", + "invert", + "isnan", + "notnan", + # WINDOW OPERATORS + "simple_moving_average", + "moving_standard_deviation", + "cumsum", + "moving_sum", + "moving_count", + "moving_min", + "moving_max", +} + + +class PublicAPITest(absltest.TestCase): + def test_public_symbols(self): + """Asserts that the symbols exposed under tp.<> are exactly the + ones we expect.""" + symbols = {s for s in dir(tp) if not s.startswith("__")} + self.assertEqual(PUBLIC_API_SYMBOLS, symbols) + + def test_public_symbols_in_docs(self): + """Asserts that all symbols exposed under tp.<> have an auto generated + documentation page. + + Note that this might need to change in the future, since for example we + might want to group some symbols under the same page.""" + ref_path = Path("docs/src/reference") + ref_files = ref_path.rglob("*.md") + ref_files_names = {file.with_suffix("").name for file in ref_files} + for symbol in PUBLIC_API_SYMBOLS: + self.assertIn(symbol, ref_files_names) + + +if __name__ == "__main__": + absltest.main() diff --git a/tools/create_operator.py b/tools/create_operator.py index ba017c8b4..9f461c24b 100755 --- a/tools/create_operator.py +++ b/tools/create_operator.py @@ -335,7 +335,7 @@ def test_base(self): deps = [ # already_there/absl/testing:absltest ":test_util", - "//temporian/core/data/dtypes:dtype", + "//temporian/core/data:dtype", "//temporian/core/data:node", "//temporian/core/data:schema", "//temporian/implementation/numpy/data:io", @@ -348,13 +348,13 @@ def test_base(self): print( """Don't forget to register the new operators in: -- The "api_symbols" rule in temporian/core/operators/BUILD -- The "operators" rule in temporian/implementation/numpy/operators/BUILD +- The imports in the top-level init file temporian/__init__.py +- The imports in temporian/implementation/numpy/operators/__init__.py - The "test_base" function in temporian/core/test/registered_operators_test.py - The "test_base" function in temporian/implementation/numpy/test/registered_operators_test.py -- Import of temporian/implementation/numpy/operators/__init__.py -- Import of temporian/core/operators/api_symbols.py -- The API ref's home page docs/reference/index.md +- The PUBLIC_API_SYMBOLS set in temporian/test/public_symbols_test.py +- The docs docs/src/reference/path/to/operator.md +- The docs API ref's home page docs/reference/index.md """ )